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