PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.10
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 -198 3.1.13.0.10 View file →
@@ -52,9 +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( 'admin_footer', 'renderTemplates' );
56 + $this->_addAction( 'admin_footer', 'renderTempaltes' );
57 57 $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 8 );
58 58 $this->_addAction( 'admin_menu', 'registerAdminMenu' );
59 59 $this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' );
60 60 $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
@@ -212,21 +212,16 @@
212 212 public function enqueueMediaScripts() {
213 213 global $typenow;
214 214 if ( post_type_supports( $typenow, 'editor' ) ) {
215 215 wp_enqueue_style( 'visualizer-media', VISUALIZER_ABSURL . 'css/media.css', array( 'media-views' ), Visualizer_Plugin::VERSION );
216 -
217 - // Load all the assets for the different libraries we support.
218 - $deps = Visualizer_Render_Sidebar_Google::enqueue_assets( array( 'media-editor' ) );
219 - $deps += Visualizer_Render_Sidebar_Type_DataTable::enqueue_assets( array( 'media-editor' ) );
220 -
221 - wp_enqueue_script( 'visualizer-media-model', VISUALIZER_ABSURL . 'js/media/model.js', $deps, Visualizer_Plugin::VERSION, true );
216 + wp_enqueue_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array( 'media-editor' ), null, true );
217 + wp_enqueue_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true );
218 + wp_enqueue_script( 'visualizer-media-model', VISUALIZER_ABSURL . 'js/media/model.js', array( 'visualizer-google-jsapi-old' ), Visualizer_Plugin::VERSION, true );
222 219 wp_enqueue_script( 'visualizer-media-collection', VISUALIZER_ABSURL . 'js/media/collection.js', array( 'visualizer-media-model' ), Visualizer_Plugin::VERSION, true );
223 220 wp_enqueue_script( 'visualizer-media-controller', VISUALIZER_ABSURL . 'js/media/controller.js', array( 'visualizer-media-collection' ), Visualizer_Plugin::VERSION, true );
224 221 wp_enqueue_script( 'visualizer-media-view', VISUALIZER_ABSURL . 'js/media/view.js', array( 'visualizer-media-controller' ), Visualizer_Plugin::VERSION, true );
225 222 wp_localize_script(
226 - 'visualizer-media-view',
227 - 'visualizer',
228 - array(
223 + 'visualizer-media-view', 'visualizer', array(
229 224 'i10n' => array(
230 225 'insert' => __( 'Insert', 'visualizer' ),
231 226 ),
232 227 )
@@ -280,9 +275,9 @@
280 275 * @static
281 276 * @access private
282 277 * @return array The associated array of chart types with localized names.
283 278 */
284 - public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false, $add_select = false, $where = null ) {
279 + public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false, $add_select = false ) {
285 280 $additional = array();
286 281 if ( $add_select ) {
287 282 $additional['select'] = array(
288 283 'name' => esc_html__( 'All', 'visualizer' ),
@@ -290,14 +285,9 @@
290 285 );
291 286 }
292 287
293 288 $types = array_merge(
294 - $additional,
295 - array(
296 - 'dataTable' => array(
297 - 'name' => esc_html__( 'Table (New)', 'visualizer' ),
298 - 'enabled' => true,
299 - ),
289 + $additional, array(
300 290 'pie' => array(
301 291 'name' => esc_html__( 'Pie', 'visualizer' ),
302 292 'enabled' => true,
303 293 ),
@@ -320,16 +310,16 @@
320 310 'column' => array(
321 311 'name' => esc_html__( 'Column', 'visualizer' ),
322 312 'enabled' => true,
323 313 ),
314 + 'gauge' => array(
315 + 'name' => esc_html__( 'Gauge', 'visualizer' ),
316 + 'enabled' => true,
317 + ),
324 318 'scatter' => array(
325 319 'name' => esc_html__( 'Scatter', 'visualizer' ),
326 320 'enabled' => true,
327 321 ),
328 - 'gauge' => array(
329 - 'name' => esc_html__( 'Gauge', 'visualizer' ),
330 - 'enabled' => true,
331 - ),
332 322 'candlestick' => array(
333 323 'name' => esc_html__( 'Candlestick', 'visualizer' ),
334 324 'enabled' => true,
335 325 ),
@@ -334,9 +324,9 @@
334 324 'enabled' => true,
335 325 ),
336 326 // pro types
337 327 'table' => array(
338 - 'name' => esc_html__( 'Table (Deprecated)', 'visualizer' ),
328 + 'name' => esc_html__( 'Table', 'visualizer' ),
339 329 'enabled' => false,
340 330 ),
341 331 'timeline' => array(
342 332 'name' => esc_html__( 'Timeline', 'visualizer' ),
@@ -374,83 +364,8 @@
374 364 }
375 365 $types = $doubleD;
376 366 }
377 367
378 - return self::handleDeprecatedCharts( $types, $enabledOnly, $get2Darray, $where );
379 - }
380 -
381 - /**
382 - * Handle (soon-to-be) deprecated charts.
383 - */
384 - private static function handleDeprecatedCharts( $types, $enabledOnly, $get2Darray, $where ) {
385 - $deprecated = array();
386 -
387 - switch ( $where ) {
388 - case 'library':
389 - // if the user has a Google Table chart, show it as deprecated otherwise remove the option from the library.
390 - if ( ! self::hasChartType( 'table' ) ) {
391 - $deprecated[] = 'table';
392 - if ( $get2Darray ) {
393 - $types['dataTable'] = esc_html__( 'Table', 'visualizer' );
394 - } else {
395 - $types['dataTable']['name'] = esc_html__( 'Table', 'visualizer' );
396 - }
397 - }
398 -
399 - // if a user has a Gauge/Candlestick chart, then let them keep using it.
400 - if ( ! VISUALIZER_PRO ) {
401 - if ( ! self::hasChartType( 'gauge' ) ) {
402 - if ( $get2Darray ) {
403 - $deprecated[] = 'gauge';
404 - } else {
405 - $types['gauge']['enabled'] = false;
406 - }
407 - }
408 - if ( ! self::hasChartType( 'candlestick' ) ) {
409 - if ( $get2Darray ) {
410 - $deprecated[] = 'candlestick';
411 - } else {
412 - $types['candlestick']['enabled'] = false;
413 - }
414 - }
415 - }
416 - break;
417 - default:
418 - // remove the option to create a Google Table chart.
419 - $deprecated[] = 'table';
420 -
421 - // rename the new table chart type.
422 - if ( $get2Darray ) {
423 - $types['dataTable'] = esc_html__( 'Table', 'visualizer' );
424 - } else {
425 - $types['dataTable']['name'] = esc_html__( 'Table', 'visualizer' );
426 - }
427 -
428 - // if a user has a Gauge/Candlestick chart, then let them keep using it.
429 - if ( ! VISUALIZER_PRO ) {
430 - if ( ! self::hasChartType( 'gauge' ) ) {
431 - if ( $get2Darray ) {
432 - $deprecated[] = 'gauge';
433 - } else {
434 - $types['gauge']['enabled'] = false;
435 - }
436 - }
437 - if ( ! self::hasChartType( 'candlestick' ) ) {
438 - if ( $get2Darray ) {
439 - $deprecated[] = 'candlestick';
440 - } else {
441 - $types['candlestick']['enabled'] = false;
442 - }
443 - }
444 - }
445 - }
446 -
447 - if ( $deprecated ) {
448 - foreach ( $deprecated as $type ) {
449 - unset( $types[ $type ] );
450 - }
451 - }
452 -
453 368 return $types;
454 369 }
455 370
456 371 /**
@@ -460,9 +375,9 @@
460 375 * @global string $pagenow The name of the current page.
461 376 *
462 377 * @access public
463 378 */
464 - public function renderTemplates() {
379 + public function renderTempaltes() {
465 380 global $pagenow;
466 381 if ( 'post.php' != $pagenow && 'post-new.php' != $pagenow ) {
467 382 return;
468 383 }
@@ -487,35 +402,21 @@
487 402 wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
488 403 $this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
489 404 wp_enqueue_media();
490 405 wp_enqueue_script(
491 - 'visualizer-library',
492 - VISUALIZER_ABSURL . 'js/library.js',
493 - array(
406 + 'visualizer-library', VISUALIZER_ABSURL . 'js/library.js', array(
494 407 'jquery',
495 408 'media-views',
496 - ),
497 - Visualizer_Plugin::VERSION,
498 - true
409 + ), Visualizer_Plugin::VERSION, true
499 410 );
500 -
501 - wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
502 -
503 - $query = $this->getQuery();
504 - while ( $query->have_posts() ) {
505 - $chart = $query->next_post();
506 - $library = $this->load_chart_type( $chart->ID );
507 - if ( is_null( $library ) ) {
508 - continue;
509 - }
510 - wp_enqueue_script(
511 - "visualizer-render-$library",
512 - VISUALIZER_ABSURL . 'js/render-facade.js',
513 - apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
514 - Visualizer_Plugin::VERSION,
515 - true
516 - );
517 - }
411 + wp_enqueue_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
412 + wp_enqueue_script( 'google-jsapi-old', '//www.google.com/jsapi', array( 'google-jsapi-new' ), null, true );
413 + wp_enqueue_script(
414 + 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array(
415 + 'google-jsapi-old',
416 + 'visualizer-library',
417 + ), Visualizer_Plugin::VERSION, true
418 + );
518 419 }
519 420 }
520 421
521 422 /**
@@ -548,22 +449,18 @@
548 449 $this->_libraryPage = add_submenu_page( 'upload.php', $title, $title, 'edit_posts', Visualizer_Plugin::NAME, $callback );
549 450 }
550 451
551 452 /**
552 - * Get the instance of WP_Query that fetches the charts as per the given criteria.
453 + * Renders visualizer library page.
454 + *
455 + * @since 1.0.0
456 + *
457 + * @access public
553 458 */
554 - private function getQuery() {
555 - static $q;
556 - if ( ! is_null( $q ) ) {
557 - return $q;
558 - }
559 -
459 + public function renderLibraryPage() {
560 460 // get current page
561 461 $page = filter_input(
562 - INPUT_GET,
563 - 'vpage',
564 - FILTER_VALIDATE_INT,
565 - array(
462 + INPUT_GET, 'vpage', FILTER_VALIDATE_INT, array(
566 463 'options' => array(
567 464 'min_range' => 1,
568 465 'default' => 1,
569 466 ),
@@ -599,89 +496,37 @@
599 496 $meta = isset( $query_args['meta_query'] ) ? $query_args['meta_query'] : array();
600 497 $meta[] = $query;
601 498 $query_args['meta_query'] = $meta;
602 499 }
603 - $q = new WP_Query( $query_args );
604 - return $q;
605 - }
606 -
607 - /**
608 - * Renders visualizer library page.
609 - *
610 - * @since 1.0.0
611 - *
612 - * @access public
613 - */
614 - public function renderLibraryPage() {
500 + // Added by Ash/Upwork
501 + // fetch charts
615 502 $charts = array();
616 - $query = $this->getQuery();
617 -
618 - // get current page
619 - $page = filter_input(
620 - INPUT_GET,
621 - 'vpage',
622 - FILTER_VALIDATE_INT,
623 - array(
624 - 'options' => array(
625 - 'min_range' => 1,
626 - 'default' => 1,
627 - ),
628 - )
629 - );
630 - // add chart type filter to the query arguments
631 - $filter = filter_input( INPUT_GET, 'type' );
632 - if ( ! ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) ) {
633 - $filter = 'all';
634 - }
635 -
636 - $css = '';
503 + $query = new WP_Query( $query_args );
637 504 while ( $query->have_posts() ) {
638 505 $chart = $query->next_post();
639 506
640 507 // if the user has updated a chart and instead of saving it, has closed the modal. If the user refreshes, they should get the original chart.
641 508 $chart = $this->handleExistingRevisions( $chart->ID, $chart );
642 - // refresh a "live" db query chart.
643 - $chart = apply_filters( 'visualizer_schedule_refresh_chart', $chart, $chart->ID, false );
644 509
645 - $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
646 -
647 510 // fetch and update settings
648 511 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
649 -
650 - $settings = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SETTINGS, $settings, $chart->ID, $type );
651 - if ( ! empty( $atts['settings'] ) ) {
652 - $settings = apply_filters( $atts['settings'], $settings, $chart->ID, $type );
653 - }
654 -
655 512 unset( $settings['height'], $settings['width'] );
513 + $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
656 514 $series = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ), $chart->ID, $type );
657 515 $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $chart->ID, $type );
658 -
659 - $library = $this->load_chart_type( $chart->ID );
660 -
661 - $id = 'visualizer-' . $chart->ID;
662 - $arguments = $this->get_inline_custom_css( $id, $settings );
663 - if ( ! empty( $arguments ) ) {
664 - $css .= $arguments[0];
665 - $settings = $arguments[1];
666 - }
667 -
668 516 // add chart to the array
669 - $charts[ $id ] = array(
517 + $charts[ 'visualizer-' . $chart->ID ] = array(
670 518 'id' => $chart->ID,
671 519 'type' => $type,
672 520 'series' => $series,
673 521 'settings' => $settings,
674 522 'data' => $data,
675 - 'library' => $library,
676 523 );
677 524 }
678 525 // enqueue charts array
679 526 $ajaxurl = admin_url( 'admin-ajax.php' );
680 527 wp_localize_script(
681 - 'visualizer-library',
682 - 'visualizer',
683 - array(
528 + 'visualizer-library', 'visualizer', array(
684 529 'language' => $this->get_language(),
685 530 'map_api_key' => get_option( 'visualizer-map-api-key' ),
686 531 'charts' => $charts,
687 532 'urls' => array(
@@ -690,20 +535,17 @@
690 535 array(
691 536 'action' => Visualizer_Plugin::ACTION_CREATE_CHART,
692 537 'library' => 'yes',
693 538 'type' => isset( $_GET['type'] ) ? $_GET['type'] : '',
694 - ),
695 - $ajaxurl
539 + ), $ajaxurl
696 540 ),
697 541 'edit' => add_query_arg(
698 542 array(
699 543 'action' => Visualizer_Plugin::ACTION_EDIT_CHART,
700 544 'library' => 'yes',
701 - ),
702 - $ajaxurl
545 + ), $ajaxurl
703 546 ),
704 547 ),
705 - 'page_type' => 'library',
706 548 )
707 549 );
708 550 // render library page
709 551 $render = new Visualizer_Render_Library();
@@ -708,10 +550,9 @@
708 550 // render library page
709 551 $render = new Visualizer_Render_Library();
710 552 $render->charts = $charts;
711 553 $render->type = $filter;
712 - $render->types = self::_getChartTypesLocalized( false, false, false, true );
713 - $render->custom_css = $css;
554 + $render->types = self::_getChartTypesLocalized();
714 555 $render->pagination = paginate_links(
715 556 array(
716 557 'base' => add_query_arg( 'vpage', '%#%' ),
717 558 'format' => '',