PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.14
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.14
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | classes/Visualizer/Module/Admin.php +35 -323 4.0.33.11.14 View file →
@@ -29,10 +29,8 @@
29 29 class Visualizer_Module_Admin extends Visualizer_Module {
30 30
31 31 const NAME = __CLASS__;
32 32
33 - const OPTION_GLOBAL_SETTINGS = 'visualizer_global_settings';
34 -
35 33 /**
36 34 * Library page suffix.
37 35 *
38 36 * @since 1.0.0
@@ -50,16 +48,8 @@
50 48 */
51 49 private $_supportPage;
52 50
53 51 /**
54 - * Settings page suffix.
55 - *
56 - * @access private
57 - * @var string
58 - */
59 - private $_settingsPage;
60 -
61 - /**
62 52 * Constructor.
63 53 *
64 54 * @since 1.0.0
65 55 *
@@ -74,10 +64,8 @@
74 64 $this->_addAction( 'enqueue_block_editor_assets', 'enqueueMediaScripts' );
75 65 $this->_addAction( 'admin_footer', 'renderTemplates' );
76 66 $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 0 );
77 67 $this->_addAction( 'admin_enqueue_scripts', 'enqueue_support_page' );
78 - $this->_addAction( 'admin_enqueue_scripts', 'enqueueSettingsScripts' );
79 - $this->_addAction( 'admin_post_visualizer_save_global_settings', 'saveGlobalSettings' );
80 68 $this->_addAction( 'admin_menu', 'registerAdminMenu' );
81 69 $this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' );
82 70 $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
83 71 $this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 );
@@ -100,15 +88,16 @@
100 88 $this->_addAction( 'visualizer_chart_languages', 'addMultilingualSupport' );
101 89
102 90 $this->_addFilter( 'admin_footer_text', 'render_review_notice' );
103 91
104 - if ( ! defined( 'TI_E2E_TESTING' ) ) {
92 + if ( ! defined( 'TI_CYPRESS_TESTING' ) ) {
105 93 $this->_addFilter( 'themeisle-sdk/survey/' . VISUALIZER_DIRNAME, 'get_survey_metadata', 10, 2 );
106 94 }
107 95
108 - if ( defined( 'TI_E2E_TESTING' ) ) {
96 + if ( defined( 'TI_CYPRESS_TESTING' ) ) {
109 97 $this->load_cypress_hooks();
110 98 }
99 +
111 100 }
112 101 /**
113 102 * Display review notice.
114 103 */
@@ -114,9 +103,9 @@
114 103 */
115 104 public function render_review_notice( $footer_text ) {
116 105 $current_screen = get_current_screen();
117 106
118 - $visualizer_page_ids = array( 'toplevel_page_visualizer', 'visualizer_page_viz-support', 'visualizer_page_ti-about-visualizer' );
107 + $visualizer_page_ids = ['toplevel_page_visualizer', 'visualizer_page_viz-support', 'visualizer_page_ti-about-visualizer' ];
119 108
120 109 if ( ! empty( $current_screen ) && isset( $current_screen->id ) ) {
121 110 foreach ( $visualizer_page_ids as $page_to_check ) {
122 111 if ( strpos( $current_screen->id, $page_to_check ) !== false ) {
@@ -124,9 +113,9 @@
124 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.
125 114 __( 'Enjoying %1$s? %2$s %3$s rating. Thank you for being so supportive!', 'visualizer' ),
126 115 '<b>Visualizer</b>',
127 116 esc_html__( 'You can help us by leaving a', 'visualizer' ),
128 - '<a href="https://wordpress.org/support/plugin/visualizer/reviews/#new-post" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
117 + '<a href="https://wordpress.org/support/plugin/visualizer/reviews/" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
129 118 );
130 119 break;
131 120 }
132 121 }
@@ -144,9 +133,9 @@
144 133 */
145 134 private function load_cypress_hooks() {
146 135 // all charts should load on the same page without pagination.
147 136 add_filter(
148 - 'visualizer_query_args', function ( $args ) {
137 + 'visualizer_query_args', function( $args ) {
149 138 $args['posts_per_page'] = 20;
150 139 return $args;
151 140 }, 10, 1
152 141 );
@@ -263,9 +252,10 @@
263 252 *
264 253 * @access public
265 254 */
266 255 public function init() {
267 - if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) && 'true' === get_user_option( 'rich_editing' ) ) {
256 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
257 + if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) && 'true' == get_user_option( 'rich_editing' ) ) {
268 258 $this->_addFilter( 'mce_external_languages', 'add_tinymce_lang', 10, 1 );
269 259 $this->_addFilter( 'mce_external_plugins', 'tinymce_plugin', 10, 1 );
270 260 $this->_addFilter( 'mce_buttons', 'register_mce_button', 10, 1 );
271 261 $this->_addFilter( 'tiny_mce_before_init', 'get_strings_for_block', 10, 1 );
@@ -277,9 +267,9 @@
277 267 *
278 268 * @since ?
279 269 * @access friendly
280 270 */
281 - public function get_strings_for_block( $settings ) {
271 + function get_strings_for_block( $settings ) {
282 272 $class = new Visualizer_Module_Language();
283 273 $strings = $class->get_strings();
284 274 $array = array( 'visualizer_tinymce_plugin' => json_encode( $strings ) );
285 275 return array_merge( $settings, $array );
@@ -360,31 +350,8 @@
360 350
361 351 if ( post_type_supports( $typenow, 'editor' ) || $current_screen->id === 'widgets' || $current_screen->id === 'customize' ) {
362 352 wp_enqueue_style( 'visualizer-media', VISUALIZER_ABSURL . 'css/media.css', array( 'media-views' ), Visualizer_Plugin::VERSION );
363 353
364 - $d3_renderer_asset = VISUALIZER_ABSPATH . '/classes/Visualizer/D3Renderer/build/index.asset.php';
365 - if ( file_exists( $d3_renderer_asset ) && ! wp_script_is( 'visualizer-d3-renderer', 'registered' ) ) {
366 - // @phpstan-ignore-next-line
367 - $d3_asset = include $d3_renderer_asset;
368 - wp_register_script(
369 - 'visualizer-d3-renderer',
370 - VISUALIZER_ABSURL . 'classes/Visualizer/D3Renderer/build/index.js',
371 - array_merge( $d3_asset['dependencies'], array( 'jquery' ) ),
372 - $d3_asset['version'],
373 - true
374 - );
375 - }
376 - if ( wp_script_is( 'visualizer-d3-renderer', 'registered' ) ) {
377 - wp_enqueue_script( 'visualizer-d3-renderer' );
378 - wp_localize_script(
379 - 'visualizer-d3-renderer',
380 - 'vizD3Renderer',
381 - array(
382 - 'iframeJsUrl' => VISUALIZER_ABSURL . 'classes/Visualizer/D3Renderer/build/iframe.js',
383 - )
384 - );
385 - }
386 -
387 354 // Load all the assets for the different libraries we support.
388 355 $deps = array(
389 356 Visualizer_Render_Sidebar_Google::enqueue_assets( array( 'media-editor' ) ),
390 357 Visualizer_Render_Sidebar_Type_DataTable_Tabular::enqueue_assets( array( 'media-editor' ) ),
@@ -398,9 +365,9 @@
398 365 'visualizer-media-view',
399 366 'visualizer',
400 367 array(
401 368 'i10n' => array(
402 - 'insert' => __( 'Insert Chart', 'visualizer' ),
369 + 'insert' => __( 'Insert', 'visualizer' ),
403 370 ),
404 371 )
405 372 );
406 373 wp_enqueue_script( 'visualizer-media-toolbar', VISUALIZER_ABSURL . 'js/media/toolbar.js', array( 'visualizer-media-view' ), Visualizer_Plugin::VERSION, true );
@@ -429,9 +396,9 @@
429 396 'controller' => array(
430 397 'title' => esc_html__( 'Visualizations', 'visualizer' ),
431 398 ),
432 399 'routers' => array(
433 - 'library' => esc_html__( 'Insert from Library', 'visualizer' ),
400 + 'library' => esc_html__( 'From Library', 'visualizer' ),
434 401 'create' => esc_html__( 'Create New', 'visualizer' ),
435 402 ),
436 403 'library' => array(
437 404 'filters' => $chart_types,
@@ -461,9 +428,9 @@
461 428 'enabled' => true,
462 429 );
463 430 }
464 431
465 - $enabled = self::proFeaturesEnabled();
432 + $enabled = self::proFeaturesLocked();
466 433
467 434 $types = array_merge(
468 435 $additional,
469 436 array(
@@ -703,9 +670,8 @@
703 670 );
704 671
705 672 wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
706 673
707 - $has_d3 = false;
708 674 $query = $this->getQuery();
709 675 while ( $query->have_posts() ) {
710 676 $chart = $query->next_post();
711 677 $library = $this->load_chart_type( $chart->ID );
@@ -718,107 +684,10 @@
718 684 apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
719 685 Visualizer_Plugin::VERSION,
720 686 true
721 687 );
722 - if ( 'd3' === $library ) {
723 - $has_d3 = true;
724 - }
725 688 }
726 689
727 - if ( $has_d3 ) {
728 - $d3_renderer_asset = VISUALIZER_ABSPATH . '/classes/Visualizer/D3Renderer/build/index.asset.php';
729 - if ( file_exists( $d3_renderer_asset ) && ! wp_script_is( 'visualizer-d3-renderer', 'registered' ) ) {
730 - /**
731 - * Ignore missing build asset in source checkout.
732 - *
733 - * @phpstan-ignore-next-line
734 - */
735 - $d3_asset = include $d3_renderer_asset;
736 - wp_register_script(
737 - 'visualizer-d3-renderer',
738 - VISUALIZER_ABSURL . 'classes/Visualizer/D3Renderer/build/index.js',
739 - array_merge( $d3_asset['dependencies'], array( 'jquery' ) ),
740 - $d3_asset['version'],
741 - true
742 - );
743 - wp_enqueue_script( 'visualizer-d3-renderer' );
744 - }
745 - wp_localize_script(
746 - 'visualizer-d3-renderer',
747 - 'vizD3Renderer',
748 - array(
749 - 'iframeJsUrl' => VISUALIZER_ABSURL . 'classes/Visualizer/D3Renderer/build/iframe.js',
750 - )
751 - );
752 - }
753 -
754 - $chart_builder_asset = VISUALIZER_ABSPATH . '/classes/Visualizer/ChartBuilder/build/index.asset.php';
755 - if ( file_exists( $chart_builder_asset ) ) {
756 - /**
757 - * Ignore missing build asset in source checkout.
758 - *
759 - * @phpstan-ignore-next-line
760 - */
761 - $asset = include $chart_builder_asset;
762 - $chart_builder_deps = $asset['dependencies'];
763 - if ( ! wp_script_is( 'visualizer-handsontable', 'registered' ) && defined( 'Visualizer_Pro_ABSURL' ) && defined( 'VISUALIZER_PRO_VERSION' ) ) {
764 - wp_register_script(
765 - 'visualizer-handsontable',
766 - Visualizer_Pro_ABSURL . 'vendor/handsontable/dist/handsontable.full.min.js',
767 - array(),
768 - VISUALIZER_PRO_VERSION,
769 - true
770 - );
771 - }
772 - if ( ! wp_style_is( 'visualizer-handsontable', 'registered' ) && defined( 'Visualizer_Pro_ABSURL' ) && defined( 'VISUALIZER_PRO_VERSION' ) ) {
773 - wp_register_style(
774 - 'visualizer-handsontable',
775 - Visualizer_Pro_ABSURL . 'vendor/handsontable/dist/handsontable.full.min.css',
776 - array(),
777 - VISUALIZER_PRO_VERSION
778 - );
779 - }
780 - if ( wp_script_is( 'visualizer-handsontable', 'registered' ) ) {
781 - wp_enqueue_script( 'visualizer-handsontable' );
782 - $chart_builder_deps = array_unique( array_merge( $chart_builder_deps, array( 'visualizer-handsontable' ) ) );
783 - }
784 - if ( wp_style_is( 'visualizer-handsontable', 'registered' ) ) {
785 - wp_enqueue_style( 'visualizer-handsontable' );
786 - }
787 - wp_enqueue_script(
788 - 'visualizer-chart-builder',
789 - VISUALIZER_ABSURL . 'classes/Visualizer/ChartBuilder/build/index.js',
790 - $chart_builder_deps,
791 - $asset['version'],
792 - true
793 - );
794 - wp_enqueue_style(
795 - 'visualizer-chart-builder',
796 - VISUALIZER_ABSURL . 'classes/Visualizer/ChartBuilder/build/style-index.css',
797 - array(),
798 - $asset['version']
799 - );
800 - $chart_builder_css = VISUALIZER_ABSPATH . '/classes/Visualizer/ChartBuilder/build/index.css';
801 - if ( file_exists( $chart_builder_css ) ) {
802 - wp_enqueue_style(
803 - 'visualizer-chart-builder-runtime',
804 - VISUALIZER_ABSURL . 'classes/Visualizer/ChartBuilder/build/index.css',
805 - array( 'visualizer-chart-builder' ),
806 - $asset['version']
807 - );
808 - }
809 - wp_localize_script(
810 - 'visualizer-chart-builder',
811 - 'vizAIBuilder',
812 - array(
813 - 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
814 - 'nonce' => wp_create_nonce( 'visualizer-ai-builder' ),
815 - 'isPro' => Visualizer_Module::is_pro(),
816 - 'upgradeUrl' => tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'aiBuilderUpgrade', 'dataSource' ),
817 - )
818 - );
819 - }
820 -
821 690 do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' );
822 691 }
823 692
824 693 /**
@@ -876,17 +745,8 @@
876 745 'edit_posts',
877 746 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew'
878 747 );
879 748
880 - $this->_settingsPage = add_submenu_page(
881 - Visualizer_Plugin::NAME,
882 - __( 'Settings', 'visualizer' ),
883 - __( 'Settings', 'visualizer' ),
884 - 'manage_options',
885 - 'viz-settings',
886 - array( $this, 'renderSettingsPage' )
887 - );
888 -
889 749 $this->_supportPage = add_submenu_page(
890 750 Visualizer_Plugin::NAME,
891 751 __( 'Support', 'visualizer' ),
892 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>',
@@ -936,9 +796,9 @@
936 796
937 797 /**
938 798 * Adds the screen options for pagination.
939 799 */
940 - public function addScreenOptions() {
800 + function addScreenOptions() {
941 801 $screen = get_current_screen();
942 802
943 803 // bail if it's some other page.
944 804 if ( ! is_object( $screen ) || $screen->id !== $this->_libraryPage ) {
@@ -955,9 +815,9 @@
955 815
956 816 /**
957 817 * Returns the screen option for pagination.
958 818 */
959 - public function setScreenOptions( $status, $option, $value ) {
819 + function setScreenOptions( $status, $option, $value ) {
960 820 if ( 'visualizer_library_per_page' === $option ) {
961 821 return $value;
962 822 }
963 823 }
@@ -1109,91 +969,8 @@
1109 969 include_once VISUALIZER_ABSPATH . '/templates/support.php';
1110 970 }
1111 971
1112 972 /**
1113 - * Enqueues scripts/styles for the Settings page.
1114 - *
1115 - * @access public
1116 - */
1117 - public function enqueueSettingsScripts( string $hook_suffix ): void {
1118 - if ( $this->_settingsPage !== $hook_suffix ) {
1119 - return;
1120 - }
1121 - wp_enqueue_style( 'wp-color-picker' );
1122 - wp_enqueue_script( 'wp-color-picker' );
1123 - }
1124 -
1125 - /**
1126 - * Renders the global style settings page.
1127 - *
1128 - * @access public
1129 - */
1130 - public function renderSettingsPage(): void {
1131 - if ( ! current_user_can( 'manage_options' ) ) {
1132 - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'visualizer' ) );
1133 - }
1134 - $settings = self::getGlobalSettings();
1135 - include_once VISUALIZER_ABSPATH . '/templates/global-settings.php';
1136 - }
1137 -
1138 - /**
1139 - * Returns the global style settings option.
1140 - *
1141 - * @return array<string, string>
1142 - * @access public
1143 - * @static
1144 - */
1145 - public static function getGlobalSettings(): array {
1146 - $defaults = array(
1147 - 'color_primary' => '',
1148 - 'color_secondary' => '',
1149 - 'apply_existing' => '0',
1150 - );
1151 - $saved = get_option( self::OPTION_GLOBAL_SETTINGS, array() );
1152 - return wp_parse_args( $saved, $defaults );
1153 - }
1154 -
1155 - /**
1156 - * Handles saving of the global style settings.
1157 - *
1158 - * @access public
1159 - */
1160 - public function saveGlobalSettings(): void {
1161 - if ( ! current_user_can( 'manage_options' ) ) {
1162 - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'visualizer' ) );
1163 - }
1164 -
1165 - check_admin_referer( 'visualizer_save_global_settings' );
1166 -
1167 - $color_primary = sanitize_hex_color( wp_unslash( $_POST['visualizer_color_primary'] ?? '' ) );
1168 - $color_secondary = sanitize_hex_color( wp_unslash( $_POST['visualizer_color_secondary'] ?? '' ) );
1169 - $apply_existing = ! empty( $_POST['visualizer_apply_existing'] ) ? '1' : '0';
1170 - $clear = ! empty( $_POST['visualizer_clear_settings'] );
1171 -
1172 - if ( $clear ) {
1173 - delete_option( self::OPTION_GLOBAL_SETTINGS );
1174 - } else {
1175 - $settings = array(
1176 - 'color_primary' => $color_primary ? $color_primary : '',
1177 - 'color_secondary' => $color_secondary ? $color_secondary : '',
1178 - 'apply_existing' => $apply_existing,
1179 - );
1180 - update_option( self::OPTION_GLOBAL_SETTINGS, $settings );
1181 - }
1182 -
1183 - wp_safe_redirect(
1184 - add_query_arg(
1185 - array(
1186 - 'page' => 'viz-settings',
1187 - 'updated' => $clear ? 'cleared' : 'true',
1188 - ),
1189 - admin_url( 'admin.php' )
1190 - )
1191 - );
1192 - exit;
1193 - }
1194 -
1195 - /**
1196 973 * Renders visualizer library page.
1197 974 *
1198 975 * @since 1.0.0
1199 976 *
@@ -1277,9 +1054,8 @@
1277 1054
1278 1055 // add chart to the array
1279 1056 $charts[ $id ] = array(
1280 1057 'id' => $chart->ID,
1281 - 'title' => $chart->post_title,
1282 1058 'type' => $type,
1283 1059 'series' => $series,
1284 1060 'settings' => $settings,
1285 1061 'data' => $data,
@@ -1284,11 +1060,8 @@
1284 1060 'settings' => $settings,
1285 1061 'data' => $data,
1286 1062 'library' => $library,
1287 1063 );
1288 - if ( 'd3' === $library ) {
1289 - $charts[ $id ]['code'] = get_post_meta( $chart->ID, Visualizer_Module_AIBuilder::CF_D3_CODE, true );
1290 - }
1291 1064 }
1292 1065 // enqueue charts array
1293 1066 $ajaxurl = admin_url( 'admin-ajax.php' );
1294 1067
@@ -1391,36 +1164,19 @@
1391 1164 *
1392 1165 * @return array Updated array of plugin meta links.
1393 1166 */
1394 1167 public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
1395 - if ( Visualizer_Module::is_pro() ) {
1396 - return $plugin_meta;
1397 - }
1398 -
1399 - // Also suppress the upsell when Pro is installed but not currently active.
1400 - if ( ! function_exists( 'get_plugins' ) ) {
1401 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
1402 - }
1403 - foreach ( array_keys( get_plugins() ) as $installed_plugin ) {
1404 - if ( false !== strpos( $installed_plugin, 'visualizer-pro' ) ) {
1405 - return $plugin_meta;
1406 - }
1407 - }
1408 -
1409 1168 if ( $plugin_file === plugin_basename( VISUALIZER_BASEFILE ) ) {
1410 - $is_black_friday = apply_filters( 'themeisle_sdk_is_black_friday_sale', false );
1411 1169 // knowledge base link
1412 1170 $plugin_meta[] = sprintf(
1413 1171 '<a href="' . VISUALIZER_MAIN_DOC . '" target="_blank">%s</a>',
1414 1172 esc_html__( 'Docs', 'visualizer' )
1415 1173 );
1416 - if ( ! $is_black_friday ) {
1417 - // flattr link
1418 - $plugin_meta[] = sprintf(
1419 - '<a style="color:red" href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'pluginrow' ) . '" target="_blank">%s</a>',
1420 - esc_html__( 'Get Visualizer Pro', 'visualizer' )
1421 - );
1422 - }
1174 + // flattr link
1175 + $plugin_meta[] = sprintf(
1176 + '<a style="color:red" href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'pluginrow' ) . '" target="_blank">%s</a>',
1177 + esc_html__( 'Get Visualizer Pro', 'visualizer' )
1178 + );
1423 1179 }
1424 1180
1425 1181 return $plugin_meta;
1426 1182 }
@@ -1425,39 +1181,17 @@
1425 1181 return $plugin_meta;
1426 1182 }
1427 1183
1428 1184 /**
1429 - * Returns true when premium chart types should be enabled for the current user.
1185 + * If check is existing user.
1430 1186 *
1431 - * Pro 1.9.0+ hooks the 'visualizer_is_pro' filter and returns true only when
1432 - * the license is valid. Pre-1.9.0 Pro defined a Visualizer_Pro class instead;
1433 - * we detect that as a fallback so those legacy installs still work.
1434 - *
1435 - * Passing false as the filter default ensures the constant VISUALIZER_PRO
1436 - * (which is set to true whenever the Pro class exists, regardless of license
1437 - * state) cannot bypass the license check.
1438 - *
1439 - * @return bool
1187 + * @return bool Default false
1440 1188 */
1441 - public static function proFeaturesEnabled() {
1442 - $is_pro_filter = apply_filters( 'visualizer_is_pro', false );
1443 -
1444 - // Pro 1.9.0+: filter is hooked and returns true only with a valid license.
1445 - if ( $is_pro_filter ) {
1189 + public static function proFeaturesLocked() {
1190 + if ( Visualizer_Module::is_pro() ) {
1446 1191 return true;
1447 1192 }
1448 -
1449 - // Pro is installed (active) but the license check above did not pass.
1450 - // Do NOT fall through to the legacy "old user" path — that path exists
1451 - // only for sites that never had Pro installed. If Pro is present but
1452 - // the license is inactive we should lock, regardless of chart history.
1453 - if ( class_exists( 'Visualizer_Pro', false ) ) {
1454 - return false;
1455 - }
1456 -
1457 - // No Pro installed at all: grant legacy access to existing users so
1458 - // their charts are not suddenly broken when they upgrade the free plugin.
1459 - return 'yes' === get_option( 'visualizer-new-user' ) ? false : true;
1193 + return 'yes' === get_option( 'visualizer-new-user', 'yes' ) ? false : true;
1460 1194 }
1461 1195
1462 1196 /**
1463 1197 * Multilingual Support.
@@ -1600,53 +1334,31 @@
1600 1334 */
1601 1335 public function add_black_friday_data( $configs ) {
1602 1336 $config = $configs['default'];
1603 1337
1604 - $message = __( 'Database queries, private charts, auto-sync. Go beyond basic charts. Exclusively for existing Visualizer users.', 'visualizer' );
1605 - $cta_label = __( 'Get Visualizer Pro', 'visualizer' );
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%';
1606 1342
1607 1343 $plan = apply_filters( 'product_visualizer_license_plan', 0 );
1608 1344 $license = apply_filters( 'product_visualizer_license_key', false );
1609 - $status = apply_filters( 'product_visualizer_license_status', false );
1610 - $pro_product_slug = defined( 'VISUALIZER_PRO_BASEFILE' ) ? basename( dirname( VISUALIZER_PRO_BASEFILE ) ) : '';
1345 + $is_pro = 0 < $plan;
1611 1346
1612 - $is_pro = 'valid' === $status;
1613 - $is_expired = 'expired' === $status || 'active-expired' === $status;
1614 -
1615 1347 if ( $is_pro ) {
1616 - // translators: %s is the discount percentage.
1617 - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - up to %s off', 'visualizer' ), '30%' );
1618 - // translators: %1$s - discount, %2$s - discount.
1619 - $message = sprintf( __( 'Upgrade your Visualizer Pro plan: %1$s off this week. Already on the plan you need? Renew early and save up to %2$s.', 'visualizer' ), '30%', '20%' );
1620 - $cta_label = __( 'See your options', 'visualizer' );
1621 - } elseif ( $is_expired ) {
1622 - // translators: %s is the discount percentage.
1623 - $config['upgrade_menu_text'] = sprintf( __( 'BF Sale - %s off', 'visualizer' ), '50%' );
1624 - // translators: %s is the discount percentage.
1625 - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'visualizer' ), '50%' );
1626 - $message = __( 'Your Visualizer Pro features are still here, just locked. Renew at a reduced rate this week.', 'visualizer' );
1627 - $cta_label = __( 'Reactivate now', 'visualizer' );
1628 - } else {
1629 - // translators: %s is the discount percentage.
1630 - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'visualizer' ), '60%' );
1631 - $config['title'] = __( 'Visualizer Pro: 60% off this week', 'visualizer' );
1632 - // translators: %s is the discount percentage.
1633 - $config['upgrade_menu_text'] = sprintf( __( 'BF Sale - %s off', 'visualizer' ), '60%' );
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%';
1634 1352 }
1635 1353
1354 + $product_label = sprintf( '<strong>%s</strong>', $product_label );
1636 1355 $url_params = array(
1637 1356 'utm_term' => $is_pro ? 'plan-' . $plan : 'free',
1638 1357 'lkey' => ! empty( $license ) ? $license : false,
1639 - 'expired' => $is_expired ? '1' : false,
1640 1358 );
1641 1359
1642 - if ( ( $is_pro || $is_expired ) && ! empty( $pro_product_slug ) ) {
1643 - $config['plugin_meta_targets'] = array( $pro_product_slug );
1644 - }
1645 -
1646 - $config['message'] = $message;
1647 - $config['cta_label'] = $cta_label;
1648 -
1360 + $config['message'] = sprintf( $message_template, '<strong>', $discount, '</strong>', $product_label );
1649 1361 $config['sale_url'] = add_query_arg(
1650 1362 $url_params,
1651 1363 tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/vizualizer-bf', 'bfcm', 'visualizer' ) )
1652 1364 );