| @@ -40,8 +40,16 @@ | ||
| 40 | 40 | */ |
| 41 | 41 | private $_libraryPage; |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | + * Support page suffix. | |
| 45 | + * | |
| 46 | + * @access private | |
| 47 | + * @var string | |
| 48 | + */ | |
| 49 | + private $_supportPage; | |
| 50 | + | |
| 51 | + /** | |
| 44 | 52 | * Constructor. |
| 45 | 53 | * |
| 46 | 54 | * @since 1.0.0 |
| 47 | 55 | * |
| @@ -55,8 +63,9 @@ | ||
| 55 | 63 | $this->_addAction( 'load-post-new.php', 'enqueueMediaScripts' ); |
| 56 | 64 | $this->_addAction( 'enqueue_block_editor_assets', 'enqueueMediaScripts' ); |
| 57 | 65 | $this->_addAction( 'admin_footer', 'renderTemplates' ); |
| 58 | 66 | $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 0 ); |
| 67 | + $this->_addAction( 'admin_enqueue_scripts', 'enqueue_support_page' ); | |
| 59 | 68 | $this->_addAction( 'admin_menu', 'registerAdminMenu' ); |
| 60 | 69 | $this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' ); |
| 61 | 70 | $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 ); |
| 62 | 71 | $this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 ); |
| @@ -61,8 +70,9 @@ | ||
| 61 | 70 | $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 ); |
| 62 | 71 | $this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 ); |
| 63 | 72 | $this->_addFilter( 'visualizer_logger_data', 'getLoggerData' ); |
| 64 | 73 | $this->_addFilter( 'visualizer_feedback_review_trigger', 'feedbackReviewTrigger' ); |
| 74 | + $this->_addFilter( 'themeisle_sdk_blackfriday_data', 'add_black_friday_data' ); | |
| 65 | 75 | |
| 66 | 76 | // screen pagination |
| 67 | 77 | $this->_addFilter( 'set-screen-option', 'setScreenOptions', 10, 3 ); |
| 68 | 78 | |
| @@ -99,8 +109,9 @@ | ||
| 99 | 109 | if ( ! empty( $current_screen ) && isset( $current_screen->id ) ) { |
| 100 | 110 | foreach ( $visualizer_page_ids as $page_to_check ) { |
| 101 | 111 | if ( strpos( $current_screen->id, $page_to_check ) !== false ) { |
| 102 | 112 | $footer_text = sprintf( |
| 113 | + // translators: %1$s - the name of the plugin (Visualizer), %2$s - message (You can help us by leaving a), %3$s - HTML entity code. | |
| 103 | 114 | __( 'Enjoying %1$s? %2$s %3$s rating. Thank you for being so supportive!', 'visualizer' ), |
| 104 | 115 | '<b>Visualizer</b>', |
| 105 | 116 | esc_html__( 'You can help us by leaving a', 'visualizer' ), |
| 106 | 117 | '<a href="https://wordpress.org/support/plugin/visualizer/reviews/" target="_blank">★★★★★</a>' |
| @@ -638,42 +649,58 @@ | ||
| 638 | 649 | * |
| 639 | 650 | * @param string $suffix The current page suffix. |
| 640 | 651 | */ |
| 641 | 652 | public function enqueueLibraryScripts( $suffix ) { |
| 642 | - if ( $suffix === $this->_libraryPage ) { | |
| 643 | - wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION ); | |
| 644 | - $this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' ); | |
| 645 | - wp_enqueue_media(); | |
| 653 | + if ( $suffix !== $this->_libraryPage ) { | |
| 654 | + return; | |
| 655 | + } | |
| 656 | + | |
| 657 | + wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION ); | |
| 658 | + $this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' ); | |
| 659 | + wp_enqueue_media(); | |
| 660 | + wp_enqueue_script( | |
| 661 | + 'visualizer-library', | |
| 662 | + VISUALIZER_ABSURL . 'js/library.js', | |
| 663 | + array( | |
| 664 | + 'jquery', | |
| 665 | + 'media-views', | |
| 666 | + 'clipboard', | |
| 667 | + ), | |
| 668 | + Visualizer_Plugin::VERSION, | |
| 669 | + true | |
| 670 | + ); | |
| 671 | + | |
| 672 | + wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true ); | |
| 673 | + | |
| 674 | + $query = $this->getQuery(); | |
| 675 | + while ( $query->have_posts() ) { | |
| 676 | + $chart = $query->next_post(); | |
| 677 | + $library = $this->load_chart_type( $chart->ID ); | |
| 678 | + if ( is_null( $library ) ) { | |
| 679 | + continue; | |
| 680 | + } | |
| 646 | 681 | wp_enqueue_script( |
| 647 | - 'visualizer-library', | |
| 648 | - VISUALIZER_ABSURL . 'js/library.js', | |
| 649 | - array( | |
| 650 | - 'jquery', | |
| 651 | - 'media-views', | |
| 652 | - 'clipboard', | |
| 653 | - ), | |
| 682 | + "visualizer-render-$library", | |
| 683 | + VISUALIZER_ABSURL . 'js/render-facade.js', | |
| 684 | + apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ), | |
| 654 | 685 | Visualizer_Plugin::VERSION, |
| 655 | 686 | true |
| 656 | 687 | ); |
| 688 | + } | |
| 657 | 689 | |
| 658 | - wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true ); | |
| 690 | + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' ); | |
| 691 | + } | |
| 659 | 692 | |
| 660 | - $query = $this->getQuery(); | |
| 661 | - while ( $query->have_posts() ) { | |
| 662 | - $chart = $query->next_post(); | |
| 663 | - $library = $this->load_chart_type( $chart->ID ); | |
| 664 | - if ( is_null( $library ) ) { | |
| 665 | - continue; | |
| 666 | - } | |
| 667 | - wp_enqueue_script( | |
| 668 | - "visualizer-render-$library", | |
| 669 | - VISUALIZER_ABSURL . 'js/render-facade.js', | |
| 670 | - apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ), | |
| 671 | - Visualizer_Plugin::VERSION, | |
| 672 | - true | |
| 673 | - ); | |
| 674 | - } | |
| 693 | + /** | |
| 694 | + * Enqueue script for support page. | |
| 695 | + * | |
| 696 | + * @param string $hook_suffix Current hook. | |
| 697 | + */ | |
| 698 | + public function enqueue_support_page( $hook_suffix ) { | |
| 699 | + if ( $this->_supportPage !== $hook_suffix ) { | |
| 700 | + return; | |
| 675 | 701 | } |
| 702 | + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' ); | |
| 676 | 703 | } |
| 677 | 704 | |
| 678 | 705 | /** |
| 679 | 706 | * Adds visualizer tab for media upload tabs array. |
| @@ -717,9 +744,10 @@ | ||
| 717 | 744 | __( 'Add New Chart', 'visualizer' ), |
| 718 | 745 | 'edit_posts', |
| 719 | 746 | 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew' |
| 720 | 747 | ); |
| 721 | - add_submenu_page( | |
| 748 | + | |
| 749 | + $this->_supportPage = add_submenu_page( | |
| 722 | 750 | Visualizer_Plugin::NAME, |
| 723 | 751 | __( 'Support', 'visualizer' ), |
| 724 | 752 | __( 'Support', 'visualizer' ) . '<span class="dashicons dashicons-editor-help more-features-icon" style="width: 17px; height: 17px; margin-left: 4px; color: #ffca54; font-size: 17px; vertical-align: -3px;"></span>', |
| 725 | 753 | 'edit_posts', |
| @@ -937,9 +965,8 @@ | ||
| 937 | 965 | * @access public |
| 938 | 966 | */ |
| 939 | 967 | public function renderSupportPage() { |
| 940 | 968 | wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION ); |
| 941 | - do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' ); | |
| 942 | 969 | include_once VISUALIZER_ABSPATH . '/templates/support.php'; |
| 943 | 970 | } |
| 944 | 971 | |
| 945 | 972 | /** |
| @@ -1094,14 +1121,8 @@ | ||
| 1094 | 1121 | 'type' => 'array', |
| 1095 | 1122 | ) |
| 1096 | 1123 | ); |
| 1097 | 1124 | |
| 1098 | - do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' ); | |
| 1099 | - | |
| 1100 | - if ( ! apply_filters( 'visualizer_is_business', false ) ) { | |
| 1101 | - do_action( 'themeisle_sdk_load_banner', 'visualizer' ); | |
| 1102 | - } | |
| 1103 | - | |
| 1104 | 1125 | $render->render(); |
| 1105 | 1126 | } |
| 1106 | 1127 | |
| 1107 | 1128 | /** |
| @@ -1302,6 +1323,48 @@ | ||
| 1302 | 1323 | ); |
| 1303 | 1324 | |
| 1304 | 1325 | $query = new WP_Query( $args); |
| 1305 | 1326 | return $query->post_count; |
| 1327 | + } | |
| 1328 | + | |
| 1329 | + /** | |
| 1330 | + * Set the black friday data. | |
| 1331 | + * | |
| 1332 | + * @param array $configs The configuration array for the loaded products. | |
| 1333 | + * @return array | |
| 1334 | + */ | |
| 1335 | + public function add_black_friday_data( $configs ) { | |
| 1336 | + $config = $configs['default']; | |
| 1337 | + | |
| 1338 | + // translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name. | |
| 1339 | + $message_template = __( 'Our biggest sale of the year: %1$sup to %2$s OFF%3$s on %4$s. Don\'t miss this limited-time offer.', 'visualizer' ); | |
| 1340 | + $product_label = 'Visualizer'; | |
| 1341 | + $discount = '70%'; | |
| 1342 | + | |
| 1343 | + $plan = apply_filters( 'product_visualizer_license_plan', 0 ); | |
| 1344 | + $license = apply_filters( 'product_visualizer_license_key', false ); | |
| 1345 | + $is_pro = 0 < $plan; | |
| 1346 | + | |
| 1347 | + if ( $is_pro ) { | |
| 1348 | + // translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name. | |
| 1349 | + $message_template = __( 'Get %1$sup to %2$s off%3$s when you upgrade your %4$s plan or renew early.', 'visualizer' ); | |
| 1350 | + $product_label = 'Visualizer Pro'; | |
| 1351 | + $discount = '30%'; | |
| 1352 | + } | |
| 1353 | + | |
| 1354 | + $product_label = sprintf( '<strong>%s</strong>', $product_label ); | |
| 1355 | + $url_params = array( | |
| 1356 | + 'utm_term' => $is_pro ? 'plan-' . $plan : 'free', | |
| 1357 | + 'lkey' => ! empty( $license ) ? $license : false, | |
| 1358 | + ); | |
| 1359 | + | |
| 1360 | + $config['message'] = sprintf( $message_template, '<strong>', $discount, '</strong>', $product_label ); | |
| 1361 | + $config['sale_url'] = add_query_arg( | |
| 1362 | + $url_params, | |
| 1363 | + tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/vizualizer-bf', 'bfcm', 'visualizer' ) ) | |
| 1364 | + ); | |
| 1365 | + | |
| 1366 | + $configs[ VISUALIZER_DIRNAME ] = $config; | |
| 1367 | + | |
| 1368 | + return $configs; | |
| 1306 | 1369 | } |
| 1307 | 1370 | } |