| @@ -52,8 +52,9 @@ | ||
| 52 | 52 | public function __construct( Visualizer_Plugin $plugin ) { |
| 53 | 53 | parent::__construct( $plugin ); |
| 54 | 54 | $this->_addAction( 'load-post.php', 'enqueueMediaScripts' ); |
| 55 | 55 | $this->_addAction( 'load-post-new.php', 'enqueueMediaScripts' ); |
| 56 | + $this->_addAction( 'enqueue_block_editor_assets', 'enqueueMediaScripts' ); | |
| 56 | 57 | $this->_addAction( 'admin_footer', 'renderTemplates' ); |
| 57 | 58 | $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 0 ); |
| 58 | 59 | $this->_addAction( 'admin_menu', 'registerAdminMenu' ); |
| 59 | 60 | $this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' ); |
| @@ -75,14 +76,41 @@ | ||
| 75 | 76 | $this->_addAction( 'admin_init', 'init' ); |
| 76 | 77 | |
| 77 | 78 | $this->_addAction( 'visualizer_chart_languages', 'addMultilingualSupport' ); |
| 78 | 79 | |
| 80 | + $this->_addFilter( 'admin_footer_text', 'render_review_notice' ); | |
| 81 | + | |
| 79 | 82 | if ( defined( 'TI_CYPRESS_TESTING' ) ) { |
| 80 | 83 | $this->load_cypress_hooks(); |
| 81 | 84 | } |
| 82 | 85 | |
| 83 | 86 | } |
| 87 | + /** | |
| 88 | + * Display review notice. | |
| 89 | + */ | |
| 90 | + public function render_review_notice( $footer_text ) { | |
| 91 | + $current_screen = get_current_screen(); | |
| 84 | 92 | |
| 93 | + $visualizer_page_ids = ['toplevel_page_visualizer', 'visualizer_page_viz-support', 'visualizer_page_ti-about-visualizer' ]; | |
| 94 | + | |
| 95 | + if ( ! empty( $current_screen ) && isset( $current_screen->id ) ) { | |
| 96 | + foreach ( $visualizer_page_ids as $page_to_check ) { | |
| 97 | + if ( strpos( $current_screen->id, $page_to_check ) !== false ) { | |
| 98 | + $footer_text = sprintf( | |
| 99 | + __( 'Enjoying %1$s? %2$s %3$s rating. Thank you for being so supportive!', 'visualizer' ), | |
| 100 | + '<b>Visualizer</b>', | |
| 101 | + esc_html__( 'You can help us by leaving a', 'visualizer' ), | |
| 102 | + '<a href="https://wordpress.org/support/plugin/visualizer/reviews/" target="_blank">★★★★★</a>' | |
| 103 | + ); | |
| 104 | + break; | |
| 105 | + } | |
| 106 | + } | |
| 107 | + } | |
| 108 | + | |
| 109 | + return $footer_text; | |
| 110 | + } | |
| 111 | + | |
| 112 | + | |
| 85 | 113 | /** |
| 86 | 114 | * Define the hooks that are needed for cypress. |
| 87 | 115 | * |
| 88 | 116 | * @since 3.4.0 |
| @@ -113,23 +141,16 @@ | ||
| 113 | 141 | if ( apply_filters( 'visualizer_is_business', false ) ) { |
| 114 | 142 | return; |
| 115 | 143 | } |
| 116 | 144 | |
| 117 | - $license = __( 'PRO', 'visualizer' ); | |
| 118 | - if ( Visualizer_Module::is_pro() ) { | |
| 119 | - switch ( $plan ) { | |
| 120 | - case 1: | |
| 121 | - $license = __( 'Developer', 'visualizer' ); | |
| 122 | - break; | |
| 123 | - } | |
| 124 | - } | |
| 145 | + $is_new_personal = apply_filters( 'visualizer_is_new_personal', false ); | |
| 125 | 146 | |
| 126 | 147 | $hours = array( |
| 127 | - '0' => __( 'Live', 'visualizer' ), | |
| 128 | - '1' => __( 'Each hour', 'visualizer' ), | |
| 129 | - '12' => __( 'Each 12 hours', 'visualizer' ), | |
| 130 | - '24' => __( 'Each day', 'visualizer' ), | |
| 131 | - '72' => __( 'Each 3 days', 'visualizer' ), | |
| 148 | + '0.16' => __( '10 minutes', 'visualizer' ), | |
| 149 | + '1' => __( 'Each hour', 'visualizer' ), | |
| 150 | + '12' => __( 'Each 12 hours', 'visualizer' ), | |
| 151 | + '24' => __( 'Each day', 'visualizer' ), | |
| 152 | + '72' => __( 'Each 3 days', 'visualizer' ), | |
| 132 | 153 | ); |
| 133 | 154 | |
| 134 | 155 | switch ( $feature ) { |
| 135 | 156 | case 'json': |
| @@ -134,9 +155,9 @@ | ||
| 134 | 155 | switch ( $feature ) { |
| 135 | 156 | case 'json': |
| 136 | 157 | case 'csv': |
| 137 | 158 | // no more schedules if pro is already active. |
| 138 | - if ( Visualizer_Module::is_pro() ) { | |
| 159 | + if ( Visualizer_Module::is_pro() && ! $is_new_personal ) { | |
| 139 | 160 | return; |
| 140 | 161 | } |
| 141 | 162 | break; |
| 142 | 163 | case 'wp': |
| @@ -146,9 +167,9 @@ | ||
| 146 | 167 | default: |
| 147 | 168 | return; |
| 148 | 169 | } |
| 149 | 170 | |
| 150 | - echo '<optgroup disabled label="' . sprintf( __( 'More in the %s version', 'visualizer' ), $license ) . '">'; | |
| 171 | + echo '<optgroup disabled label="' . __( 'Upgrade required', 'visualizer' ) . '">'; | |
| 151 | 172 | foreach ( $hours as $hour => $desc ) { |
| 152 | 173 | echo '<option disabled>' . $desc . '</option>'; |
| 153 | 174 | } |
| 154 | 175 | echo '</optgroup>'; |
| @@ -309,9 +330,11 @@ | ||
| 309 | 330 | * @access public |
| 310 | 331 | */ |
| 311 | 332 | public function enqueueMediaScripts() { |
| 312 | 333 | global $typenow; |
| 313 | - if ( post_type_supports( $typenow, 'editor' ) ) { | |
| 334 | + global $current_screen; | |
| 335 | + | |
| 336 | + if ( post_type_supports( $typenow, 'editor' ) || $current_screen->id === 'widgets' || $current_screen->id === 'customize' ) { | |
| 314 | 337 | wp_enqueue_style( 'visualizer-media', VISUALIZER_ABSURL . 'css/media.css', array( 'media-views' ), Visualizer_Plugin::VERSION ); |
| 315 | 338 | |
| 316 | 339 | // Load all the assets for the different libraries we support. |
| 317 | 340 | $deps = array( |
| @@ -403,14 +426,14 @@ | ||
| 403 | 426 | ), |
| 404 | 427 | 'pie' => array( |
| 405 | 428 | 'name' => esc_html__( 'Pie/Donut', 'visualizer' ), |
| 406 | 429 | 'enabled' => true, |
| 407 | - 'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ), | |
| 430 | + 'supports' => array( 'Google Charts', 'ChartJS' ), | |
| 408 | 431 | ), |
| 409 | 432 | 'line' => array( |
| 410 | 433 | 'name' => esc_html__( 'Line', 'visualizer' ), |
| 411 | 434 | 'enabled' => true, |
| 412 | - 'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ), | |
| 435 | + 'supports' => array( 'Google Charts', 'ChartJS' ), | |
| 413 | 436 | ), |
| 414 | 437 | 'bar' => array( |
| 415 | 438 | 'name' => esc_html__( 'Bar', 'visualizer' ), |
| 416 | 439 | 'enabled' => true, |
| @@ -420,18 +443,21 @@ | ||
| 420 | 443 | 'name' => esc_html__( 'Area', 'visualizer' ), |
| 421 | 444 | 'enabled' => $enabled, |
| 422 | 445 | // in ChartJS, the fill option is used to make Line chart an area: https://www.chartjs.org/docs/latest/charts/area.html |
| 423 | 446 | 'supports' => array( 'Google Charts' ), |
| 447 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/area-chart/', | |
| 424 | 448 | ), |
| 425 | 449 | 'geo' => array( |
| 426 | 450 | 'name' => esc_html__( 'Geo', 'visualizer' ), |
| 427 | 451 | 'enabled' => $enabled, |
| 428 | 452 | 'supports' => array( 'Google Charts' ), |
| 453 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/geo-chart/', | |
| 429 | 454 | ), |
| 430 | 455 | 'column' => array( |
| 431 | 456 | 'name' => esc_html__( 'Column', 'visualizer' ), |
| 432 | 457 | 'enabled' => $enabled, |
| 433 | 458 | 'supports' => array( 'Google Charts', 'ChartJS' ), |
| 459 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/column-chart/', | |
| 434 | 460 | ), |
| 435 | 461 | 'bubble' => array( |
| 436 | 462 | 'name' => esc_html__( 'Bubble', 'visualizer' ), |
| 437 | 463 | 'enabled' => $enabled, |
| @@ -436,23 +462,27 @@ | ||
| 436 | 462 | 'name' => esc_html__( 'Bubble', 'visualizer' ), |
| 437 | 463 | 'enabled' => $enabled, |
| 438 | 464 | // chartjs' bubble is ugly looking (and it won't work off the default bubble.csv) so it is being excluded for the time being. |
| 439 | 465 | 'supports' => array( 'Google Charts' ), |
| 466 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/bubble-chart/', | |
| 440 | 467 | ), |
| 441 | 468 | 'scatter' => array( |
| 442 | 469 | 'name' => esc_html__( 'Scatter', 'visualizer' ), |
| 443 | 470 | 'enabled' => $enabled, |
| 444 | 471 | 'supports' => array( 'Google Charts' ), |
| 472 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/scatter-chart/', | |
| 445 | 473 | ), |
| 446 | 474 | 'gauge' => array( |
| 447 | 475 | 'name' => esc_html__( 'Gauge', 'visualizer' ), |
| 448 | 476 | 'enabled' => $enabled, |
| 449 | 477 | 'supports' => array( 'Google Charts' ), |
| 478 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/gauge-chart/', | |
| 450 | 479 | ), |
| 451 | 480 | 'candlestick' => array( |
| 452 | 481 | 'name' => esc_html__( 'Candlestick', 'visualizer' ), |
| 453 | 482 | 'enabled' => $enabled, |
| 454 | 483 | 'supports' => array( 'Google Charts' ), |
| 484 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/candlestick-chart/', | |
| 455 | 485 | ), |
| 456 | 486 | // pro types |
| 457 | 487 | 'timeline' => array( |
| 458 | 488 | 'name' => esc_html__( 'Timeline', 'visualizer' ), |
| @@ -457,23 +487,27 @@ | ||
| 457 | 487 | 'timeline' => array( |
| 458 | 488 | 'name' => esc_html__( 'Timeline', 'visualizer' ), |
| 459 | 489 | 'enabled' => false, |
| 460 | 490 | 'supports' => array( 'Google Charts', 'ChartJS' ), |
| 491 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/timeline-chart/', | |
| 461 | 492 | ), |
| 462 | 493 | 'combo' => array( |
| 463 | 494 | 'name' => esc_html__( 'Combo', 'visualizer' ), |
| 464 | 495 | 'enabled' => false, |
| 465 | 496 | 'supports' => array( 'Google Charts' ), |
| 497 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/combo-chart/', | |
| 466 | 498 | ), |
| 467 | 499 | 'polarArea' => array( |
| 468 | 500 | 'name' => esc_html__( 'Polar Area', 'visualizer' ), |
| 469 | 501 | 'enabled' => false, |
| 470 | 502 | 'supports' => array( 'ChartJS' ), |
| 503 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/polar-area-chart/', | |
| 471 | 504 | ), |
| 472 | 505 | 'radar' => array( |
| 473 | 506 | 'name' => esc_html__( 'Radar/Spider', 'visualizer' ), |
| 474 | 507 | 'enabled' => false, |
| 475 | 508 | 'supports' => array( 'ChartJS' ), |
| 509 | + 'demo_url' => 'https://demo.themeisle.com/visualizer/radar-spider-chart/', | |
| 476 | 510 | ), |
| 477 | 511 | ) |
| 478 | 512 | ); |
| 479 | 513 | $types = apply_filters( 'visualizer_pro_chart_types', $types ); |
| @@ -707,9 +741,9 @@ | ||
| 707 | 741 | font-size: 14px; |
| 708 | 742 | font-weight: 600; |
| 709 | 743 | color: #fff; |
| 710 | 744 | } |
| 711 | - #toplevel_page_visualizer ul.wp-submenu li:last-child > a { | |
| 745 | + #toplevel_page_visualizer ul.wp-submenu li:last-child > a > span { | |
| 712 | 746 | color: #fff !important; |
| 713 | 747 | } |
| 714 | 748 | #toplevel_page_visualizer ul.wp-submenu li:last-child > a:hover { |
| 715 | 749 | box-shadow: inherit; |
| @@ -998,8 +1032,9 @@ | ||
| 998 | 1032 | ); |
| 999 | 1033 | } |
| 1000 | 1034 | // enqueue charts array |
| 1001 | 1035 | $ajaxurl = admin_url( 'admin-ajax.php' ); |
| 1036 | + | |
| 1002 | 1037 | wp_localize_script( |
| 1003 | 1038 | 'visualizer-library', |
| 1004 | 1039 | 'visualizer', |
| 1005 | 1040 | array( |
| @@ -1036,8 +1071,9 @@ | ||
| 1036 | 1071 | 'i10n' => array( |
| 1037 | 1072 | 'copied' => __( 'The shortcode has been copied to your clipboard. Hit Ctrl-V/Cmd-V to paste it.', 'visualizer' ), |
| 1038 | 1073 | 'conflict' => __( 'We have detected a potential conflict with another component that prevents Visualizer from functioning properly. Please disable any of the following components if they are activated on your instance: Modern Events Calendar plugin, Acronix plugin. In case the aforementioned components are not activated or you continue to see this error message, please disable all other plugins and enable them one by one to find out the component that is causing the conflict.', 'visualizer' ), |
| 1039 | 1074 | ), |
| 1075 | + 'is_pro_user' => Visualizer_Module::is_pro(), | |
| 1040 | 1076 | ) |
| 1041 | 1077 | ); |
| 1042 | 1078 | // render library page |
| 1043 | 1079 | $render = new Visualizer_Render_Library(); |
| @@ -1056,8 +1092,12 @@ | ||
| 1056 | 1092 | ); |
| 1057 | 1093 | |
| 1058 | 1094 | $this->load_survey(); |
| 1059 | 1095 | |
| 1096 | + if ( ! apply_filters( 'visualizer_is_business', false ) ) { | |
| 1097 | + do_action( 'themeisle_sdk_load_banner', 'visualizer' ); | |
| 1098 | + } | |
| 1099 | + | |
| 1060 | 1100 | $render->render(); |
| 1061 | 1101 | } |
| 1062 | 1102 | |
| 1063 | 1103 | /** |
| @@ -1108,9 +1148,9 @@ | ||
| 1108 | 1148 | ); |
| 1109 | 1149 | // flattr link |
| 1110 | 1150 | $plugin_meta[] = sprintf( |
| 1111 | 1151 | '<a style="color:red" href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'pluginrow' ) . '" target="_blank">%s</a>', |
| 1112 | - esc_html__( 'Pro Addon', 'visualizer' ) | |
| 1152 | + esc_html__( 'Get Visualizer Pro', 'visualizer' ) | |
| 1113 | 1153 | ); |
| 1114 | 1154 | } |
| 1115 | 1155 | |
| 1116 | 1156 | return $plugin_meta; |
| @@ -1220,9 +1260,9 @@ | ||
| 1220 | 1260 | |
| 1221 | 1261 | $user_id = 'visualizer_' . preg_replace( '/[^\w\d]*/', '', get_site_url() ); // Use a normalized version of the site URL as a user ID. |
| 1222 | 1262 | |
| 1223 | 1263 | $license_data = get_option( 'visualizer_pro_license_data', false ); |
| 1224 | - if ( false !== $license_data ) { | |
| 1264 | + if ( false !== $license_data && isset( $license_data->key ) ) { | |
| 1225 | 1265 | $user_id = 'visualizer_' . $license_data->key; |
| 1226 | 1266 | } |
| 1227 | 1267 | |
| 1228 | 1268 | return array( |
| @@ -1227,9 +1267,9 @@ | ||
| 1227 | 1267 | |
| 1228 | 1268 | return array( |
| 1229 | 1269 | 'userId' => $user_id, |
| 1230 | 1270 | 'attributes' => array( |
| 1231 | - 'days_since_install' => $install_category, | |
| 1271 | + 'days_since_install' => strval( $install_category ), | |
| 1232 | 1272 | 'free_version' => $plugin_version, |
| 1233 | 1273 | 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '', |
| 1234 | 1274 | 'license_status' => apply_filters( 'product_visualizer_license_status', 'invalid' ), |
| 1235 | 1275 | ), |