PluginProbe
Style Kits for Elementor / trunk
Style Kits for Elementor vtrunk
2.6.6 2.6.5 2.6.3 trunk 0.0.1 1.0.0 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.2 All 102 releases
analogwp-templates / analogwp-templates.php

analogwp-templates.php in Style Kits for Elementor trunk, at analogwp-templates.php

319 lines 9.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin main file.
4 *
5 * @package Analog
6 * @copyright 2026 SmallTownDev.
7 * @link https://analogwp.com
8 *
9 * @wordpress-plugin
10 * Plugin Name: Style Kits for Elementor
11 * Plugin URI: https://analogwp.com/
12 * Description: Style Kits extends the Elementor theme styles editor with more global styling options. Boost your design workflow in Elementor with intuitive global controls and theme style presets.
13 * Version: 2.6.6
14 * Author: AnalogWP
15 * Author URI: https://analogwp.com/
16 * License: GPL2
17 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
18 * Text Domain: analogwp-templates
19 * Requires at least: 6.0
20 * Requires PHP: 7.4
21 *
22 * Elementor tested up to: 4.2.3
23 * Elementor Pro tested up to: 4.2.2
24 */
25
26 defined( 'ABSPATH' ) || exit;
27
28 define( 'ANG_ELEMENTOR_MINIMUM', '3.32.0' );
29 define( 'ANG_PHP_MINIMUM', '7.4' );
30 define( 'ANG_WP_MINIMUM', '6.0' );
31 define( 'ANG_VERSION', '2.6.6' );
32 define( 'ANG_TEXT_DOMAIN', 'analogwp-templates' );
33 define( 'ANG_LEGACY_TEXT_DOMAIN', 'ang' );
34 define( 'ANG_PLUGIN_FILE', __FILE__ );
35 define( 'ANG_PLUGIN_URL', plugin_dir_url( ANG_PLUGIN_FILE ) );
36 define( 'ANG_PLUGIN_DIR', plugin_dir_path( ANG_PLUGIN_FILE ) );
37 define( 'ANG_PLUGIN_BASE', plugin_basename( ANG_PLUGIN_FILE ) );
38
39 /**
40 * Handles plugin activation.
41 *
42 * Throws an error if the plugin is activated on an older version than PHP 7.4.
43 *
44 * @since 1.6.0
45 * @access private
46 * @return void
47 */
48 function analog_activate_plugin() {
49 if ( version_compare( PHP_VERSION, ANG_PHP_MINIMUM, '<' ) ) {
50 wp_die(
51 /* translators: %s: version number */
52 esc_html( sprintf( __( 'Style Kit for Elementor requires PHP version %s', 'analogwp-templates' ), ANG_PHP_MINIMUM ) ),
53 esc_html__( 'Error Activating', 'analogwp-templates' )
54 );
55 }
56
57 do_action( 'analog_activation' );
58 }
59
60 register_activation_hook( __FILE__, 'analog_activate_plugin' );
61
62 /**
63 * Handles plugin deactivation.
64 *
65 * @since 1.6.0
66 * @access private
67 * @return void
68 */
69 function analog_deactivate_plugin() {
70 if ( version_compare( PHP_VERSION, ANG_PHP_MINIMUM, '<' ) ) {
71 return;
72 }
73
74 do_action( 'analog_deactivation' );
75 }
76
77 register_deactivation_hook( __FILE__, 'analog_deactivate_plugin' );
78
79 /**
80 * Fail loading, if WordPress version requirements not met.
81 *
82 * @since 1.1
83 * @return void
84 */
85 function analog_fail_wp_version() {
86 /* translators: %s: WordPress version */
87 $message = sprintf( esc_html__( 'Style Kits requires WordPress version %s+. Because you are using an earlier version, the plugin is currently NOT RUNNING.', 'analogwp-templates' ), ANG_WP_MINIMUM );
88 $html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
89
90 echo wp_kses_post( $html_message );
91 }
92
93 /**
94 * Elementor version requirements are not met.
95 *
96 * @return mixed
97 */
98 function analog_require_minimum_elementor() {
99 $file_path = 'elementor/elementor.php';
100 $allowed_notice_html = array(
101 'div' => array(
102 'class' => array(),
103 ),
104 'p' => array(),
105 'a' => array(
106 'href' => array(),
107 'class' => array(),
108 'style' => array(),
109 ),
110 );
111
112 $link = add_query_arg(
113 array(
114 'action' => 'upgrade-plugin',
115 'plugin' => $file_path,
116 ),
117 admin_url( 'update.php' )
118 );
119
120 $update_url = wp_nonce_url( $link, 'upgrade-plugin_' . $file_path );
121
122 /* translators: %s: Minimum required Elementor version. */
123 $minimum_elementor_message = __( 'Style Kits requires Elementor v%s or newer in order to work. Please update Elementor to the latest version.', 'analogwp-templates' );
124
125 $message = sprintf(
126 '<p>%s</p>',
127 esc_html( sprintf( $minimum_elementor_message, ANG_ELEMENTOR_MINIMUM ) )
128 );
129
130 $versions = get_transient( 'ang_rollback_versions_' . ANG_VERSION );
131 /* translators: %s: Version number. */
132 $rollback_version_label = __( 'Rollback to v%s', 'analogwp-templates' );
133
134 $message .= '<p>';
135 /* translators: %s: Link to update Elementor. */
136 $message .= sprintf( '<a href="%s" class="button-primary">%s</a>', esc_url( $update_url ), esc_html__( 'Update Elementor Now', 'analogwp-templates' ) );
137 /* translators: %s: Link to rollback plugin to previous version. */
138 $message .= sprintf(
139 '<a href="%s" class="button-secondary" style="margin-left:10px">%s</a>',
140 esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=analog_style_kits_rollback&version=' . $versions[0] ), 'analog_style_kits_rollback' ) ),
141 esc_html( sprintf( $rollback_version_label, $versions[0] ) )
142 );
143 $message .= '</p>';
144
145 echo wp_kses( '<div class="error">' . $message . '</div>', $allowed_notice_html );
146 }
147
148 /**
149 * Fail plugin initiialization if requirements are not met.
150 *
151 * @return mixed|bool
152 */
153 function analog_fail_load() {
154 if ( ! function_exists( 'get_current_screen' ) ) {
155 require_once ABSPATH . 'wp-admin/includes/screen.php';
156 }
157
158 $screen = get_current_screen();
159
160 if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
161 return;
162 }
163
164 $file_path = 'elementor/elementor.php';
165 $allowed_notice_html = array(
166 'div' => array(
167 'class' => array(),
168 ),
169 'p' => array(),
170 'a' => array(
171 'href' => array(),
172 'class' => array(),
173 ),
174 );
175
176 $is_not_activated = false;
177 $is_not_installed = false;
178
179 if ( ! function_exists( 'get_plugins' ) ) {
180 require_once ABSPATH . 'wp-admin/includes/plugin.php';
181 }
182
183 $installed_plugins = get_plugins();
184 $elementor = isset( $installed_plugins[ $file_path ] );
185
186 if ( $elementor ) {
187 $is_not_activated = true;
188 } else {
189 $is_not_installed = true;
190 }
191
192 if ( $is_not_activated ) {
193 if ( ! current_user_can( 'activate_plugins' ) ) {
194 return;
195 }
196
197 $activation_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $file_path . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $file_path );
198 $message = sprintf( '<p>%s</p>', esc_html__( 'Style Kits is not working because you need to activate the Elementor plugin.', 'analogwp-templates' ) );
199 $message .= sprintf( '<p><a href="%s" class="button-primary">%s</a></p>', esc_url( $activation_url ), esc_html__( 'Activate Elementor Now', 'analogwp-templates' ) );
200 } elseif ( $is_not_installed ) {
201 if ( ! current_user_can( 'install_plugins' ) ) {
202 return;
203 }
204
205 $install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
206 $message = sprintf( '<p>%s</p>', esc_html__( 'Style Kits is not working because you need to install the Elementor plugin.', 'analogwp-templates' ) );
207 $message .= sprintf( '<p><a href="%s" class="button-primary">%s</a></p>', esc_url( $install_url ), esc_html__( 'Install Elementor Now', 'analogwp-templates' ) );
208 }
209
210 echo wp_kses( '<div class="error">' . $message . '</div>', $allowed_notice_html );
211 }
212
213 // Third party dependencies.
214 if ( is_readable( __DIR__ . '/third-party/vendor/scoper-autoload.php' ) ) {
215 require_once __DIR__ . '/third-party/vendor/scoper-autoload.php';
216 }
217
218 if ( ! function_exists( 'sk_fs' ) ) {
219 /**
220 * Create a helper function for easy SDK access.
221 */
222 function sk_fs() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
223 global $sk_fs;
224
225 if ( ! isset( $sk_fs ) ) {
226 $freemius_bootstrap_paths = array(
227 __DIR__ . '/vendor/freemius/wordpress-sdk/start.php',
228 __DIR__ . '/vendor/freemius/start.php',
229 __DIR__ . '/freemius/start.php',
230 );
231
232 $freemius_bootstrap = '';
233
234 foreach ( $freemius_bootstrap_paths as $bootstrap_path ) {
235 if ( is_readable( $bootstrap_path ) ) {
236 $freemius_bootstrap = $bootstrap_path;
237 break;
238 }
239 }
240
241 // Include Freemius SDK.
242 require_once $freemius_bootstrap;
243
244 $sk_fs = fs_dynamic_init( // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
245 array(
246 'id' => '17032',
247 'slug' => 'analogwp-templates',
248 'type' => 'plugin',
249 'public_key' => 'pk_e05579cda0ad78db31e94616185cc',
250 'is_premium' => false,
251 'has_addons' => true,
252 'has_paid_plans' => false,
253 'menu' => array(
254 'slug' => 'analogwp_templates',
255 'first-path' => 'admin.php?page=analog_onboarding&from=freemius',
256 'account' => false,
257 'support' => false,
258 'contact' => false,
259 'addons' => false,
260 ),
261 )
262 );
263 }
264
265 return $sk_fs;
266 }
267
268 // Init Freemius.
269 sk_fs();
270 // Signal that SDK was initiated.
271 do_action( 'sk_fs_loaded' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
272 }
273
274 /**
275 * Fire up plugin instance.
276 *
277 * @since 1.6.0 Add PHP version check.
278 */
279 add_action(
280 'plugins_loaded',
281 static function () {
282 if ( version_compare( PHP_VERSION, ANG_PHP_MINIMUM, '<' ) ) {
283 wp_die(
284 /* translators: %s: version number */
285 esc_html( sprintf( __( 'Style Kit for Elementor requires PHP version %s', 'analogwp-templates' ), ANG_PHP_MINIMUM ) ),
286 esc_html__( 'Error Activating', 'analogwp-templates' )
287 );
288 }
289
290 // Begin onboarding.
291 require_once ANG_PLUGIN_DIR . 'inc/class-onboarding.php';
292
293 if ( ! did_action( 'elementor/loaded' ) ) {
294 add_action( 'admin_notices', 'analog_fail_load' );
295 return;
296 }
297
298 if ( ! version_compare( ELEMENTOR_VERSION, ANG_ELEMENTOR_MINIMUM, '>=' ) ) {
299 // Include files temporarily, required for rollbacks to work.
300 require_once ANG_PLUGIN_DIR . 'inc/class-base.php';
301 require_once ANG_PLUGIN_DIR . 'inc/Core/Storage/Transients.php';
302 require_once ANG_PLUGIN_DIR . 'inc/elementor/class-tools.php';
303 require_once ANG_PLUGIN_DIR . 'inc/Utils.php';
304
305 add_action( 'admin_notices', 'analog_require_minimum_elementor' );
306 return;
307 }
308
309 if ( ! version_compare( get_bloginfo( 'version' ), ANG_WP_MINIMUM, '>=' ) ) {
310 add_action( 'admin_notices', 'analog_fail_wp_version' );
311 return;
312 }
313
314 require_once ANG_PLUGIN_DIR . 'inc/Plugin.php';
315
316 \Analog\Plugin::load( ANG_PLUGIN_FILE );
317 }
318 );
319