| @@ -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() ); |
| @@ -165,14 +164,14 @@ | ||
| 165 | 164 | */ |
| 166 | 165 | public function activation_hook() { |
| 167 | 166 | // Add custom capabilities to administrator role. |
| 168 | 167 | $this->snippets_type->add_capabilities(); |
| 169 | - | |
| 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 | /** |
| @@ -292,9 +291,9 @@ | ||
| 292 | 291 | } |
| 293 | 292 | |
| 294 | 293 | /** |
| 295 | 294 | * Logger data. |
| 296 | - * | |
| 295 | + * | |
| 297 | 296 | * @return array<string, mixed> |
| 298 | 297 | */ |
| 299 | 298 | public function get_logger_data() { |
| 300 | 299 | $settings = WINP_Settings::get_instance()->get_settings(); |
| @@ -315,9 +314,9 @@ | ||
| 315 | 314 | |
| 316 | 315 | // Count snippets by type. |
| 317 | 316 | $snippet_types = [ 'php', 'css', 'js', 'text', 'html', 'advert', 'universal' ]; |
| 318 | 317 | $types_count = []; |
| 319 | - | |
| 318 | + | |
| 320 | 319 | foreach ( $snippet_types as $type ) { |
| 321 | 320 | $count = get_posts( |
| 322 | 321 | [ |
| 323 | 322 | 'post_type' => WINP_SNIPPETS_POST_TYPE, |
| @@ -327,9 +326,9 @@ | ||
| 327 | 326 | 'posts_per_page' => -1, |
| 328 | 327 | 'fields' => 'ids', |
| 329 | 328 | ] |
| 330 | 329 | ); |
| 331 | - | |
| 330 | + | |
| 332 | 331 | if ( ! empty( $count ) ) { |
| 333 | 332 | $types_count[ $type ] = count( $count ); |
| 334 | 333 | } |
| 335 | 334 | } |
| @@ -340,69 +339,7 @@ | ||
| 340 | 339 | 'total_snippets' => $total_snippets, |
| 341 | 340 | 'types' => $types_count, |
| 342 | 341 | ], |
| 343 | 342 | ]; |
| 344 | - } | |
| 345 | - | |
| 346 | - /** | |
| 347 | - * Set the black friday data. | |
| 348 | - * | |
| 349 | - * @param array<string, mixed> $configs The configuration array for the loaded products. | |
| 350 | - * | |
| 351 | - * @return array<string, mixed> The configurations. | |
| 352 | - */ | |
| 353 | - public function add_black_friday_data( $configs ) { | |
| 354 | - $config = $configs['default']; | |
| 355 | - | |
| 356 | - $message = __( 'Conditional logic, revision history, import/export. Manage your custom code properly. Exclusively for existing Woody users.', 'insert-php' ); | |
| 357 | - $cta_label = __( 'Get Woody Pro', 'insert-php' ); | |
| 358 | - | |
| 359 | - $plan = apply_filters( 'product_woody_license_plan', 0 ); | |
| 360 | - $status = apply_filters( 'product_woody_license_status', 'invalid' ); | |
| 361 | - $license = apply_filters( 'product_woody_license_key', false ); | |
| 362 | - $pro_product_slug = defined( 'WASP_PLUGIN_FILE' ) ? basename( dirname( WASP_PLUGIN_FILE ) ) : ''; | |
| 363 | - | |
| 364 | - $is_pro = 'valid' === $status; | |
| 365 | - $is_expired = 'expired' === $status || 'active-expired' === $status; | |
| 366 | - | |
| 367 | - if ( $is_pro ) { | |
| 368 | - // translators: %s is the discount percentage. | |
| 369 | - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - up to %s off', 'insert-php' ), '30%' ); | |
| 370 | - // translators: %1$s - discount, %2$s - discount. | |
| 371 | - $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%' ); | |
| 372 | - $cta_label = __( 'See your options', 'insert-php' ); | |
| 373 | - } elseif ( $is_expired ) { | |
| 374 | - // translators: %s is the discount percentage. | |
| 375 | - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'insert-php' ), '50%' ); | |
| 376 | - $message = __( 'Your Woody Pro features are still here, just locked. Renew at a reduced rate this week.', 'insert-php' ); | |
| 377 | - $cta_label = __( 'Reactivate now', 'insert-php' ); | |
| 378 | - } else { | |
| 379 | - // translators: %s - discount. | |
| 380 | - $config['title'] = sprintf( __( 'Woody Pro: %s off this week', 'insert-php' ), '60%' ); | |
| 381 | - // translators: %s is the discount percentage. | |
| 382 | - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'insert-php' ), '60%' ); | |
| 383 | - } | |
| 384 | - | |
| 385 | - $url_params = [ | |
| 386 | - 'utm_term' => $is_pro ? 'plan-' . $plan : 'free', | |
| 387 | - 'lkey' => ! empty( $license ) ? $license : false, | |
| 388 | - 'expired' => $is_expired ? '1' : false, | |
| 389 | - ]; | |
| 390 | - | |
| 391 | - if ( ( $is_pro || $is_expired ) && ! empty( $pro_product_slug ) ) { | |
| 392 | - $config['plugin_meta_targets'] = [ $pro_product_slug ]; | |
| 393 | - } | |
| 394 | - | |
| 395 | - $config['cta_label'] = $cta_label; | |
| 396 | - $config['message'] = $message; | |
| 397 | - | |
| 398 | - $config['sale_url'] = add_query_arg( | |
| 399 | - $url_params, | |
| 400 | - tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/woody-bf', 'bfcm', 'woody' ) ) | |
| 401 | - ); | |
| 402 | - | |
| 403 | - $configs[ WINP_PLUGIN_SLUG ] = $config; | |
| 404 | - | |
| 405 | - return $configs; | |
| 406 | 343 | } |
| 407 | 344 | } |
| 408 | 345 | } |