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 +35 -180 3.1.03.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 ),
@@ -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,69 +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 - $deprecated[] = 'gauge';
403 - }
404 - if ( ! self::hasChartType( 'candlestick' ) ) {
405 - $deprecated[] = 'candlestick';
406 - }
407 - }
408 - break;
409 - default:
410 - // remove the option to create a Google Table chart.
411 - $deprecated[] = 'table';
412 -
413 - // rename the new table chart type.
414 - if ( self::hasChartType( 'table' ) ) {
415 - if ( $get2Darray ) {
416 - $types['dataTable'] = esc_html__( 'Table', 'visualizer' );
417 - } else {
418 - $types['dataTable']['name'] = esc_html__( 'Table', 'visualizer' );
419 - }
420 - }
421 -
422 - // if a user has a Gauge/Candlestick chart, then let them keep using it.
423 - if ( ! VISUALIZER_PRO ) {
424 - if ( ! self::hasChartType( 'gauge' ) ) {
425 - $deprecated[] = 'gauge';
426 - }
427 - if ( ! self::hasChartType( 'candlestick' ) ) {
428 - $deprecated[] = 'candlestick';
429 - }
430 - }
431 - }
432 -
433 - if ( $deprecated ) {
434 - foreach ( $deprecated as $type ) {
435 - unset( $types[ $type ] );
436 - }
437 - }
438 -
439 368 return $types;
440 369 }
441 370
442 371 /**
@@ -446,9 +375,9 @@
446 375 * @global string $pagenow The name of the current page.
447 376 *
448 377 * @access public
449 378 */
450 - public function renderTemplates() {
379 + public function renderTempaltes() {
451 380 global $pagenow;
452 381 if ( 'post.php' != $pagenow && 'post-new.php' != $pagenow ) {
453 382 return;
454 383 }
@@ -473,35 +402,21 @@
473 402 wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
474 403 $this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
475 404 wp_enqueue_media();
476 405 wp_enqueue_script(
477 - 'visualizer-library',
478 - VISUALIZER_ABSURL . 'js/library.js',
479 - array(
406 + 'visualizer-library', VISUALIZER_ABSURL . 'js/library.js', array(
480 407 'jquery',
481 408 'media-views',
482 - ),
483 - Visualizer_Plugin::VERSION,
484 - true
409 + ), Visualizer_Plugin::VERSION, true
485 410 );
486 -
487 - wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
488 -
489 - $query = $this->getQuery();
490 - while ( $query->have_posts() ) {
491 - $chart = $query->next_post();
492 - $library = $this->load_chart_type( $chart->ID );
493 - if ( is_null( $library ) ) {
494 - continue;
495 - }
496 - wp_enqueue_script(
497 - "visualizer-render-$library",
498 - VISUALIZER_ABSURL . 'js/render-facade.js',
499 - apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
500 - Visualizer_Plugin::VERSION,
501 - true
502 - );
503 - }
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 + );
504 419 }
505 420 }
506 421
507 422 /**
@@ -534,22 +449,18 @@
534 449 $this->_libraryPage = add_submenu_page( 'upload.php', $title, $title, 'edit_posts', Visualizer_Plugin::NAME, $callback );
535 450 }
536 451
537 452 /**
538 - * 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
539 458 */
540 - private function getQuery() {
541 - static $q;
542 - if ( ! is_null( $q ) ) {
543 - return $q;
544 - }
545 -
459 + public function renderLibraryPage() {
546 460 // get current page
547 461 $page = filter_input(
548 - INPUT_GET,
549 - 'vpage',
550 - FILTER_VALIDATE_INT,
551 - array(
462 + INPUT_GET, 'vpage', FILTER_VALIDATE_INT, array(
552 463 'options' => array(
553 464 'min_range' => 1,
554 465 'default' => 1,
555 466 ),
@@ -585,89 +496,37 @@
585 496 $meta = isset( $query_args['meta_query'] ) ? $query_args['meta_query'] : array();
586 497 $meta[] = $query;
587 498 $query_args['meta_query'] = $meta;
588 499 }
589 - $q = new WP_Query( $query_args );
590 - return $q;
591 - }
592 -
593 - /**
594 - * Renders visualizer library page.
595 - *
596 - * @since 1.0.0
597 - *
598 - * @access public
599 - */
600 - public function renderLibraryPage() {
500 + // Added by Ash/Upwork
501 + // fetch charts
601 502 $charts = array();
602 - $query = $this->getQuery();
603 -
604 - // get current page
605 - $page = filter_input(
606 - INPUT_GET,
607 - 'vpage',
608 - FILTER_VALIDATE_INT,
609 - array(
610 - 'options' => array(
611 - 'min_range' => 1,
612 - 'default' => 1,
613 - ),
614 - )
615 - );
616 - // add chart type filter to the query arguments
617 - $filter = filter_input( INPUT_GET, 'type' );
618 - if ( ! ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) ) {
619 - $filter = 'all';
620 - }
621 -
622 - $css = '';
503 + $query = new WP_Query( $query_args );
623 504 while ( $query->have_posts() ) {
624 505 $chart = $query->next_post();
625 506
626 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.
627 508 $chart = $this->handleExistingRevisions( $chart->ID, $chart );
628 - // refresh a "live" db query chart.
629 - $chart = apply_filters( 'visualizer_schedule_refresh_chart', $chart, $chart->ID, false );
630 509
631 - $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
632 -
633 510 // fetch and update settings
634 511 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
635 -
636 - $settings = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SETTINGS, $settings, $chart->ID, $type );
637 - if ( ! empty( $atts['settings'] ) ) {
638 - $settings = apply_filters( $atts['settings'], $settings, $chart->ID, $type );
639 - }
640 -
641 512 unset( $settings['height'], $settings['width'] );
513 + $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
642 514 $series = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ), $chart->ID, $type );
643 515 $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $chart->ID, $type );
644 -
645 - $library = $this->load_chart_type( $chart->ID );
646 -
647 - $id = 'visualizer-' . $chart->ID;
648 - $arguments = $this->get_inline_custom_css( $id, $settings );
649 - if ( ! empty( $arguments ) ) {
650 - $css .= $arguments[0];
651 - $settings = $arguments[1];
652 - }
653 -
654 516 // add chart to the array
655 - $charts[ $id ] = array(
517 + $charts[ 'visualizer-' . $chart->ID ] = array(
656 518 'id' => $chart->ID,
657 519 'type' => $type,
658 520 'series' => $series,
659 521 'settings' => $settings,
660 522 'data' => $data,
661 - 'library' => $library,
662 523 );
663 524 }
664 525 // enqueue charts array
665 526 $ajaxurl = admin_url( 'admin-ajax.php' );
666 527 wp_localize_script(
667 - 'visualizer-library',
668 - 'visualizer',
669 - array(
528 + 'visualizer-library', 'visualizer', array(
670 529 'language' => $this->get_language(),
671 530 'map_api_key' => get_option( 'visualizer-map-api-key' ),
672 531 'charts' => $charts,
673 532 'urls' => array(
@@ -676,20 +535,17 @@
676 535 array(
677 536 'action' => Visualizer_Plugin::ACTION_CREATE_CHART,
678 537 'library' => 'yes',
679 538 'type' => isset( $_GET['type'] ) ? $_GET['type'] : '',
680 - ),
681 - $ajaxurl
539 + ), $ajaxurl
682 540 ),
683 541 'edit' => add_query_arg(
684 542 array(
685 543 'action' => Visualizer_Plugin::ACTION_EDIT_CHART,
686 544 'library' => 'yes',
687 - ),
688 - $ajaxurl
545 + ), $ajaxurl
689 546 ),
690 547 ),
691 - 'page_type' => 'library',
692 548 )
693 549 );
694 550 // render library page
695 551 $render = new Visualizer_Render_Library();
@@ -694,10 +550,9 @@
694 550 // render library page
695 551 $render = new Visualizer_Render_Library();
696 552 $render->charts = $charts;
697 553 $render->type = $filter;
698 - $render->types = self::_getChartTypesLocalized( false, false, false, true );
699 - $render->custom_css = $css;
554 + $render->types = self::_getChartTypesLocalized();
700 555 $render->pagination = paginate_links(
701 556 array(
702 557 'base' => add_query_arg( 'vpage', '%#%' ),
703 558 'format' => '',