PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.7.1
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.7.1
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
← All changes | includes/class.plugin.php +12 -94 2.7.72.7.1 View file →
@@ -28,9 +28,9 @@
28 28
29 29 /**
30 30 * Snippets custom post type instance.
31 31 *
32 - * @var WINP_SnippetsType|null
32 + * @var WINP_SnippetsType
33 33 */
34 34 private $snippets_type;
35 35
36 36 /**
@@ -55,9 +55,9 @@
55 55 WINP_SnippetLibrary::get_instance();
56 56
57 57 $this->load_global();
58 58
59 - if ( is_admin() || WINP_Helper::doing_rest_api() ) {
59 + if ( is_admin() ) {
60 60
61 61 if ( WINP_Helper::doing_ajax() ) {
62 62 require WINP_PLUGIN_DIR . '/admin/ajax/ajax.php';
63 63 require WINP_PLUGIN_DIR . '/admin/ajax/snippet-library.php';
@@ -70,18 +70,17 @@
70 70 function () {
71 71 if ( WINP_Plugin::app()->premium->is_active() ) {
72 72 update_option( WINP_PLUGIN_NAMESPACE . '_logger_flag', 'yes' );
73 73 }
74 - }
74 + }
75 75 );
76 76
77 77 add_filter( WINP_PLUGIN_NAMESPACE . '_logger_data', [ $this, 'get_logger_data' ] );
78 - add_filter( 'themeisle_sdk_blackfriday_data', [ $this, 'add_black_friday_data' ] );
79 78 }
80 79
81 80 /**
82 81 * Get plugin instance
83 - *
82 + *
84 83 * @return WINP_Plugin
85 84 */
86 85 public static function app() {
87 86 return self::$app;
@@ -88,9 +87,9 @@
88 87 }
89 88
90 89 /**
91 90 * Survey data.
92 - *
91 + *
93 92 * @return array<string, mixed>
94 93 */
95 94 public function get_survey_data() {
96 95 $install_time = get_option( WINP_PLUGIN_NAMESPACE . '_install', time() );
@@ -164,15 +163,15 @@
164 163 * @return void
165 164 */
166 165 public function activation_hook() {
167 166 // Add custom capabilities to administrator role.
168 - $this->get_snippets_type()->add_capabilities();
169 -
167 + $this->snippets_type->add_capabilities();
168 +
170 169 // Create demo snippets with examples of use.
171 170 if ( ! get_option( 'wbcr_inp_demo_snippets_created' ) ) {
172 171 WINP_Helper::create_demo_snippets();
173 172 }
174 -
173 +
175 174 WINP_Helper::flush_page_cache();
176 175 }
177 176
178 177 /**
@@ -182,31 +181,12 @@
182 181 * @return void
183 182 */
184 183 public function deactivation_hook() {
185 184 // Remove custom capabilities from administrator role.
186 - $this->get_snippets_type()->remove_capabilities();
185 + $this->snippets_type->remove_capabilities();
187 186 }
188 187
189 188 /**
190 - * Get the snippets post type handler, loading it on demand.
191 - *
192 - * The (de)activation hooks can run outside of admin/REST requests
193 - * (e.g. `wp plugin activate` via WP-CLI), where load_backend() and
194 - * therefore register_types() never ran.
195 - *
196 - * @return WINP_SnippetsType
197 - */
198 - private function get_snippets_type() {
199 - if ( is_null( $this->snippets_type ) ) {
200 - require_once WINP_PLUGIN_DIR . '/admin/includes/class.snippets.viewtable.php';
201 - require_once WINP_PLUGIN_DIR . '/admin/types/snippets-post-types.php';
202 - $this->snippets_type = new WINP_SnippetsType();
203 - }
204 -
205 - return $this->snippets_type;
206 - }
207 -
208 - /**
209 189 * Register custom post types and taxonomies.
210 190 *
211 191 * @throws \Exception Exception.
212 192 * @since 2.2.0
@@ -311,9 +291,9 @@
311 291 }
312 292
313 293 /**
314 294 * Logger data.
315 - *
295 + *
316 296 * @return array<string, mixed>
317 297 */
318 298 public function get_logger_data() {
319 299 $settings = WINP_Settings::get_instance()->get_settings();
@@ -334,9 +314,9 @@
334 314
335 315 // Count snippets by type.
336 316 $snippet_types = [ 'php', 'css', 'js', 'text', 'html', 'advert', 'universal' ];
337 317 $types_count = [];
338 -
318 +
339 319 foreach ( $snippet_types as $type ) {
340 320 $count = get_posts(
341 321 [
342 322 'post_type' => WINP_SNIPPETS_POST_TYPE,
@@ -346,9 +326,9 @@
346 326 'posts_per_page' => -1,
347 327 'fields' => 'ids',
348 328 ]
349 329 );
350 -
330 +
351 331 if ( ! empty( $count ) ) {
352 332 $types_count[ $type ] = count( $count );
353 333 }
354 334 }
@@ -359,69 +339,7 @@
359 339 'total_snippets' => $total_snippets,
360 340 'types' => $types_count,
361 341 ],
362 342 ];
363 - }
364 -
365 - /**
366 - * Set the black friday data.
367 - *
368 - * @param array<string, mixed> $configs The configuration array for the loaded products.
369 - *
370 - * @return array<string, mixed> The configurations.
371 - */
372 - public function add_black_friday_data( $configs ) {
373 - $config = $configs['default'];
374 -
375 - $message = __( 'Conditional logic, revision history, import/export. Manage your custom code properly. Exclusively for existing Woody users.', 'insert-php' );
376 - $cta_label = __( 'Get Woody Pro', 'insert-php' );
377 -
378 - $plan = apply_filters( 'product_woody_license_plan', 0 );
379 - $status = apply_filters( 'product_woody_license_status', 'invalid' );
380 - $license = apply_filters( 'product_woody_license_key', false );
381 - $pro_product_slug = defined( 'WASP_PLUGIN_FILE' ) ? basename( dirname( WASP_PLUGIN_FILE ) ) : '';
382 -
383 - $is_pro = 'valid' === $status;
384 - $is_expired = 'expired' === $status || 'active-expired' === $status;
385 -
386 - if ( $is_pro ) {
387 - // translators: %s is the discount percentage.
388 - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - up to %s off', 'insert-php' ), '30%' );
389 - // translators: %1$s - discount, %2$s - discount.
390 - $message = sprintf( __( 'Upgrade your Woody Pro plan: %1$s off this week. Already on the plan you need? Renew early and save up to %2$s.', 'insert-php' ), '30%', '20%' );
391 - $cta_label = __( 'See your options', 'insert-php' );
392 - } elseif ( $is_expired ) {
393 - // translators: %s is the discount percentage.
394 - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'insert-php' ), '50%' );
395 - $message = __( 'Your Woody Pro features are still here, just locked. Renew at a reduced rate this week.', 'insert-php' );
396 - $cta_label = __( 'Reactivate now', 'insert-php' );
397 - } else {
398 - // translators: %s - discount.
399 - $config['title'] = sprintf( __( 'Woody Pro: %s off this week', 'insert-php' ), '60%' );
400 - // translators: %s is the discount percentage.
401 - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'insert-php' ), '60%' );
402 - }
403 -
404 - $url_params = [
405 - 'utm_term' => $is_pro ? 'plan-' . $plan : 'free',
406 - 'lkey' => ! empty( $license ) ? $license : false,
407 - 'expired' => $is_expired ? '1' : false,
408 - ];
409 -
410 - if ( ( $is_pro || $is_expired ) && ! empty( $pro_product_slug ) ) {
411 - $config['plugin_meta_targets'] = [ $pro_product_slug ];
412 - }
413 -
414 - $config['cta_label'] = $cta_label;
415 - $config['message'] = $message;
416 -
417 - $config['sale_url'] = add_query_arg(
418 - $url_params,
419 - tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/woody-bf', 'bfcm', 'woody' ) )
420 - );
421 -
422 - $configs[ WINP_PLUGIN_SLUG ] = $config;
423 -
424 - return $configs;
425 343 }
426 344 }
427 345 }