-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsydney-toolbox.php
224 lines (195 loc) · 6.06 KB
/
sydney-toolbox.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
/**
*
* @link http://athemes.com
* @since 1.0
* @package Sydney_Toolbox
*
* @wordpress-plugin
* Plugin Name: Sydney Toolbox
* Plugin URI: http://athemes.com/plugins/sydney-toolbox
* Description: Registers custom post types and custom fields for the Sydney theme
* Version: 1.17
* Author: aThemes
* Author URI: http://athemes.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: sydney-toolbox
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* Set up and initialize
*/
class Sydney_Toolbox {
private static $instance;
/**
* Actions setup
*/
public function __construct() {
add_action( 'plugins_loaded', array( $this, 'constants' ), 2 );
add_action( 'plugins_loaded', array( $this, 'i18n' ), 3 );
add_action( 'plugins_loaded', array( $this, 'includes' ), 4 );
add_action( 'admin_notices', array( $this, 'admin_notice' ), 4 );
//SVG styles
add_action( 'wp_head', array( $this, 'svg_styles' ) );
//Elementor actions
add_action( 'elementor/widgets/widgets_registered', array( $this, 'elementor_includes' ), 4 );
add_action( 'elementor/init', array( $this, 'elementor_category' ), 4 );
add_action( 'elementor/frontend/after_register_scripts', array( $this, 'scripts' ), 4 );
}
/**
* Constants
*/
function constants() {
define( 'ST_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
define( 'ST_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
}
/**
* Includes
*/
function includes() {
if ( defined( 'SITEORIGIN_PANELS_VERSION' ) ) {
//Post types
require_once( ST_DIR . 'inc/post-type-services.php' );
require_once( ST_DIR . 'inc/post-type-employees.php' );
require_once( ST_DIR . 'inc/post-type-testimonials.php' );
require_once( ST_DIR . 'inc/post-type-clients.php' );
require_once( ST_DIR . 'inc/post-type-projects.php' );
require_once( ST_DIR . 'inc/post-type-timeline.php' );
//Metaboxes
require_once( ST_DIR . 'inc/metaboxes/services-metabox.php' );
require_once( ST_DIR . 'inc/metaboxes/employees-metabox.php' );
require_once( ST_DIR . 'inc/metaboxes/testimonials-metabox.php' );
require_once( ST_DIR . 'inc/metaboxes/clients-metabox.php' );
require_once( ST_DIR . 'inc/metaboxes/projects-metabox.php' );
require_once( ST_DIR . 'inc/metaboxes/timeline-metabox.php' );
require_once( ST_DIR . 'inc/metaboxes/singles-metabox.php' );
}
/**
* Demo content setup
*
* @since 1.07
*/
if ( !$this->is_pro() ) {
require_once( ST_DIR . 'demo-content/setup.php' );
}
}
function elementor_includes() {
if ( !version_compare(PHP_VERSION, '5.4', '<=') ) {
require_once( ST_DIR . 'inc/elementor/block-testimonials.php' );
require_once( ST_DIR . 'inc/elementor/block-posts.php' );
require_once( ST_DIR . 'inc/elementor/block-portfolio.php' );
require_once( ST_DIR . 'inc/elementor/block-employee-carousel.php' );
require_once( ST_DIR . 'inc/elementor/block-slider.php' );
if ( $this->is_pro() ) {
require_once( ST_DIR . 'inc/elementor/block-employee.php' );
require_once( ST_DIR . 'inc/elementor/block-pricing.php' );
require_once( ST_DIR . 'inc/elementor/block-timeline.php' );
}
}
}
function elementor_category() {
if ( !version_compare(PHP_VERSION, '5.4', '<=') ) {
\Elementor\Plugin::$instance->elements_manager->add_category(
'sydney-elements',
[
'title' => __( 'Sydney Elements', 'sydney-toolbox' ),
'icon' => 'fa fa-plug',
],
2
);
}
}
static function install() {
if ( version_compare(PHP_VERSION, '5.4', '<=') ) {
wp_die( __( 'Sydney Toolbox requires PHP 5.4. Please contact your host to upgrade your PHP. The plugin was <strong>not</strong> activated.', 'sydney-toolbox' ) );
};
}
/**
* Translations
*/
function i18n() {
load_plugin_textdomain( 'sydney-toolbox', false, 'sydney-toolbox/languages' );
}
/**
* Admin notice
*/
function admin_notice() {
$theme = wp_get_theme();
$parent = wp_get_theme()->parent();
if ( ($theme != 'Sydney' ) && ($theme != 'Sydney Pro' ) && ($parent != 'Sydney') && ($parent != 'Sydney Pro') ) {
echo '<div class="error">';
echo '<p>' . __('Please note that the <strong>Sydney Toolbox</strong> plugin is meant to be used only with the <a href="http://wordpress.org/themes/sydney/" target="_blank">Sydney theme</a></p>', 'sydney-toolbox');
echo '</div>';
}
}
/**
* SVG styles
*/
function svg_styles() {
?>
<style>
.sydney-svg-icon {
display: inline-block;
width: 16px;
height: 16px;
vertical-align: middle;
line-height: 1;
}
.team-item .team-social li .sydney-svg-icon {
fill: #fff;
}
.team-item .team-social li:hover .sydney-svg-icon {
fill: #000;
}
.team_hover_edits .team-social li a .sydney-svg-icon {
fill: #000;
}
.team_hover_edits .team-social li:hover a .sydney-svg-icon {
fill: #fff;
}
</style>
<?php
}
/**
* Scripts
*/
function scripts() {
$forked_owl = get_theme_mod( 'forked_owl_carousel', false );
if ( $forked_owl ) {
wp_enqueue_script( 'st-carousel', ST_URI . 'js/main.js', array(), '20200504', true );
} else {
wp_enqueue_script( 'st-carousel', ST_URI . 'js/main-legacy.js', array(), '20200504', true );
}
}
/**
* Get current theme
*/
public static function is_pro() {
$theme = wp_get_theme();
$parent = wp_get_theme()->parent();
if ( ( $theme != 'Sydney Pro' ) && ( $parent != 'Sydney Pro') ) {
return false;
} else {
return true;
}
}
/**
* Returns the instance.
*/
public static function get_instance() {
if ( !self::$instance )
self::$instance = new self;
return self::$instance;
}
}
function sydney_toolbox_plugin() {
return Sydney_Toolbox::get_instance();
}
add_action('plugins_loaded', 'sydney_toolbox_plugin', 1);
//Does not activate the plugin on PHP less than 5.4
register_activation_hook( __FILE__, array( 'sydney-toolbox', 'install' ) );