PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.12
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.12
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 +36 -177 3.1.23.0.12 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,16 +212,11 @@
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 = array(
219 - Visualizer_Render_Sidebar_Google::enqueue_assets( array( 'media-editor' ) ),
220 - Visualizer_Render_Sidebar_Type_DataTable::enqueue_assets( array( 'media-editor' ) ),
221 - );
222 -
223 - 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 );
224 219 wp_enqueue_script( 'visualizer-media-collection', VISUALIZER_ABSURL . 'js/media/collection.js', array( 'visualizer-media-model' ), Visualizer_Plugin::VERSION, true );
225 220 wp_enqueue_script( 'visualizer-media-controller', VISUALIZER_ABSURL . 'js/media/controller.js', array( 'visualizer-media-collection' ), Visualizer_Plugin::VERSION, true );
226 221 wp_enqueue_script( 'visualizer-media-view', VISUALIZER_ABSURL . 'js/media/view.js', array( 'visualizer-media-controller' ), Visualizer_Plugin::VERSION, true );
227 222 wp_localize_script(
@@ -282,9 +277,9 @@
282 277 * @static
283 278 * @access private
284 279 * @return array The associated array of chart types with localized names.
285 280 */
286 - public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false, $add_select = false, $where = null ) {
281 + public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false, $add_select = false ) {
287 282 $additional = array();
288 283 if ( $add_select ) {
289 284 $additional['select'] = array(
290 285 'name' => esc_html__( 'All', 'visualizer' ),
@@ -294,12 +289,8 @@
294 289
295 290 $types = array_merge(
296 291 $additional,
297 292 array(
298 - 'dataTable' => array(
299 - 'name' => esc_html__( 'Table (New)', 'visualizer' ),
300 - 'enabled' => true,
301 - ),
302 293 'pie' => array(
303 294 'name' => esc_html__( 'Pie', 'visualizer' ),
304 295 'enabled' => true,
305 296 ),
@@ -322,16 +313,16 @@
322 313 'column' => array(
323 314 'name' => esc_html__( 'Column', 'visualizer' ),
324 315 'enabled' => true,
325 316 ),
317 + 'gauge' => array(
318 + 'name' => esc_html__( 'Gauge', 'visualizer' ),
319 + 'enabled' => true,
320 + ),
326 321 'scatter' => array(
327 322 'name' => esc_html__( 'Scatter', 'visualizer' ),
328 323 'enabled' => true,
329 324 ),
330 - 'gauge' => array(
331 - 'name' => esc_html__( 'Gauge', 'visualizer' ),
332 - 'enabled' => true,
333 - ),
334 325 'candlestick' => array(
335 326 'name' => esc_html__( 'Candlestick', 'visualizer' ),
336 327 'enabled' => true,
337 328 ),
@@ -336,9 +327,9 @@
336 327 'enabled' => true,
337 328 ),
338 329 // pro types
339 330 'table' => array(
340 - 'name' => esc_html__( 'Table (Deprecated)', 'visualizer' ),
331 + 'name' => esc_html__( 'Table', 'visualizer' ),
341 332 'enabled' => false,
342 333 ),
343 334 'timeline' => array(
344 335 'name' => esc_html__( 'Timeline', 'visualizer' ),
@@ -376,83 +367,8 @@
376 367 }
377 368 $types = $doubleD;
378 369 }
379 370
380 - return self::handleDeprecatedCharts( $types, $enabledOnly, $get2Darray, $where );
381 - }
382 -
383 - /**
384 - * Handle (soon-to-be) deprecated charts.
385 - */
386 - private static function handleDeprecatedCharts( $types, $enabledOnly, $get2Darray, $where ) {
387 - $deprecated = array();
388 -
389 - switch ( $where ) {
390 - case 'library':
391 - // if the user has a Google Table chart, show it as deprecated otherwise remove the option from the library.
392 - if ( ! self::hasChartType( 'table' ) ) {
393 - $deprecated[] = 'table';
394 - if ( $get2Darray ) {
395 - $types['dataTable'] = esc_html__( 'Table', 'visualizer' );
396 - } else {
397 - $types['dataTable']['name'] = esc_html__( 'Table', 'visualizer' );
398 - }
399 - }
400 -
401 - // if a user has a Gauge/Candlestick chart, then let them keep using it.
402 - if ( ! VISUALIZER_PRO ) {
403 - if ( ! self::hasChartType( 'gauge' ) ) {
404 - if ( $get2Darray ) {
405 - $deprecated[] = 'gauge';
406 - } else {
407 - $types['gauge']['enabled'] = false;
408 - }
409 - }
410 - if ( ! self::hasChartType( 'candlestick' ) ) {
411 - if ( $get2Darray ) {
412 - $deprecated[] = 'candlestick';
413 - } else {
414 - $types['candlestick']['enabled'] = false;
415 - }
416 - }
417 - }
418 - break;
419 - default:
420 - // remove the option to create a Google Table chart.
421 - $deprecated[] = 'table';
422 -
423 - // rename the new table chart type.
424 - if ( $get2Darray ) {
425 - $types['dataTable'] = esc_html__( 'Table', 'visualizer' );
426 - } else {
427 - $types['dataTable']['name'] = esc_html__( 'Table', 'visualizer' );
428 - }
429 -
430 - // if a user has a Gauge/Candlestick chart, then let them keep using it.
431 - if ( ! VISUALIZER_PRO ) {
432 - if ( ! self::hasChartType( 'gauge' ) ) {
433 - if ( $get2Darray ) {
434 - $deprecated[] = 'gauge';
435 - } else {
436 - $types['gauge']['enabled'] = false;
437 - }
438 - }
439 - if ( ! self::hasChartType( 'candlestick' ) ) {
440 - if ( $get2Darray ) {
441 - $deprecated[] = 'candlestick';
442 - } else {
443 - $types['candlestick']['enabled'] = false;
444 - }
445 - }
446 - }
447 - }
448 -
449 - if ( $deprecated ) {
450 - foreach ( $deprecated as $type ) {
451 - unset( $types[ $type ] );
452 - }
453 - }
454 -
455 371 return $types;
456 372 }
457 373
458 374 /**
@@ -462,9 +378,9 @@
462 378 * @global string $pagenow The name of the current page.
463 379 *
464 380 * @access public
465 381 */
466 - public function renderTemplates() {
382 + public function renderTempaltes() {
467 383 global $pagenow;
468 384 if ( 'post.php' != $pagenow && 'post-new.php' != $pagenow ) {
469 385 return;
470 386 }
@@ -498,26 +414,22 @@
498 414 ),
499 415 Visualizer_Plugin::VERSION,
500 416 true
501 417 );
502 -
418 + wp_enqueue_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
419 + wp_enqueue_script( 'google-jsapi-old', '//www.google.com/jsapi', array( 'google-jsapi-new' ), null, true );
503 420 wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
504 -
505 - $query = $this->getQuery();
506 - while ( $query->have_posts() ) {
507 - $chart = $query->next_post();
508 - $library = $this->load_chart_type( $chart->ID );
509 - if ( is_null( $library ) ) {
510 - continue;
511 - }
512 - wp_enqueue_script(
513 - "visualizer-render-$library",
514 - VISUALIZER_ABSURL . 'js/render-facade.js',
515 - apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
516 - Visualizer_Plugin::VERSION,
517 - true
518 - );
519 - }
421 + wp_enqueue_script(
422 + 'visualizer-render',
423 + VISUALIZER_ABSURL . 'js/render.js',
424 + array(
425 + 'google-jsapi-old',
426 + 'visualizer-library',
427 + 'visualizer-customization',
428 + ),
429 + Visualizer_Plugin::VERSION,
430 + true
431 + );
520 432 }
521 433 }
522 434
523 435 /**
@@ -550,16 +462,15 @@
550 462 $this->_libraryPage = add_submenu_page( 'upload.php', $title, $title, 'edit_posts', Visualizer_Plugin::NAME, $callback );
551 463 }
552 464
553 465 /**
554 - * Get the instance of WP_Query that fetches the charts as per the given criteria.
466 + * Renders visualizer library page.
467 + *
468 + * @since 1.0.0
469 + *
470 + * @access public
555 471 */
556 - private function getQuery() {
557 - static $q;
558 - if ( ! is_null( $q ) ) {
559 - return $q;
560 - }
561 -
472 + public function renderLibraryPage() {
562 473 // get current page
563 474 $page = filter_input(
564 475 INPUT_GET,
565 476 'vpage',
@@ -601,81 +512,31 @@
601 512 $meta = isset( $query_args['meta_query'] ) ? $query_args['meta_query'] : array();
602 513 $meta[] = $query;
603 514 $query_args['meta_query'] = $meta;
604 515 }
605 - $q = new WP_Query( $query_args );
606 - return $q;
607 - }
608 -
609 - /**
610 - * Renders visualizer library page.
611 - *
612 - * @since 1.0.0
613 - *
614 - * @access public
615 - */
616 - public function renderLibraryPage() {
516 + // Added by Ash/Upwork
517 + // fetch charts
617 518 $charts = array();
618 - $query = $this->getQuery();
619 -
620 - // get current page
621 - $page = filter_input(
622 - INPUT_GET,
623 - 'vpage',
624 - FILTER_VALIDATE_INT,
625 - array(
626 - 'options' => array(
627 - 'min_range' => 1,
628 - 'default' => 1,
629 - ),
630 - )
631 - );
632 - // add chart type filter to the query arguments
633 - $filter = filter_input( INPUT_GET, 'type' );
634 - if ( ! ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) ) {
635 - $filter = 'all';
636 - }
637 -
638 - $css = '';
519 + $query = new WP_Query( $query_args );
639 520 while ( $query->have_posts() ) {
640 521 $chart = $query->next_post();
641 522
642 523 // 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.
643 524 $chart = $this->handleExistingRevisions( $chart->ID, $chart );
644 - // refresh a "live" db query chart.
645 - $chart = apply_filters( 'visualizer_schedule_refresh_chart', $chart, $chart->ID, false );
646 525
647 - $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
648 -
649 526 // fetch and update settings
650 527 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
651 -
652 - $settings = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SETTINGS, $settings, $chart->ID, $type );
653 - if ( ! empty( $atts['settings'] ) ) {
654 - $settings = apply_filters( $atts['settings'], $settings, $chart->ID, $type );
655 - }
656 -
657 528 unset( $settings['height'], $settings['width'] );
529 + $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
658 530 $series = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ), $chart->ID, $type );
659 531 $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $chart->ID, $type );
660 -
661 - $library = $this->load_chart_type( $chart->ID );
662 -
663 - $id = 'visualizer-' . $chart->ID;
664 - $arguments = $this->get_inline_custom_css( $id, $settings );
665 - if ( ! empty( $arguments ) ) {
666 - $css .= $arguments[0];
667 - $settings = $arguments[1];
668 - }
669 -
670 532 // add chart to the array
671 - $charts[ $id ] = array(
533 + $charts[ 'visualizer-' . $chart->ID ] = array(
672 534 'id' => $chart->ID,
673 535 'type' => $type,
674 536 'series' => $series,
675 537 'settings' => $settings,
676 538 'data' => $data,
677 - 'library' => $library,
678 539 );
679 540 }
680 541 // enqueue charts array
681 542 $ajaxurl = admin_url( 'admin-ajax.php' );
@@ -703,9 +564,8 @@
703 564 ),
704 565 $ajaxurl
705 566 ),
706 567 ),
707 - 'page_type' => 'library',
708 568 )
709 569 );
710 570 // render library page
711 571 $render = new Visualizer_Render_Library();
@@ -710,10 +570,9 @@
710 570 // render library page
711 571 $render = new Visualizer_Render_Library();
712 572 $render->charts = $charts;
713 573 $render->type = $filter;
714 - $render->types = self::_getChartTypesLocalized( false, false, false, true );
715 - $render->custom_css = $css;
574 + $render->types = self::_getChartTypesLocalized();
716 575 $render->pagination = paginate_links(
717 576 array(
718 577 'base' => add_query_arg( 'vpage', '%#%' ),
719 578 'format' => '',