| @@ -63,9 +63,8 @@ | ||
| 63 | 63 | |
| 64 | 64 | $this->_addAction( 'wp_print_footer_scripts', 'printFooterScripts' ); |
| 65 | 65 | $this->_addAction( 'wp_enqueue_scripts', 'enqueueScripts' ); |
| 66 | 66 | $this->_addAction( 'load-index.php', 'enqueueScripts' ); |
| 67 | - $this->_addAction( 'load-visualizer_page_visualizer-setup-wizard', 'enqueueScripts' ); | |
| 68 | 67 | $this->_addAction( 'visualizer_enqueue_scripts', 'enqueueScripts' ); |
| 69 | 68 | $this->_addFilter( 'visualizer_get_language', 'getLanguage' ); |
| 70 | 69 | $this->_addShortcode( 'visualizer', 'renderChart' ); |
| 71 | 70 | |
| @@ -305,25 +304,8 @@ | ||
| 305 | 304 | ), |
| 306 | 305 | $atts |
| 307 | 306 | ); |
| 308 | 307 | |
| 309 | - $atts['id'] = (int) $atts['id']; | |
| 310 | - $atts['class'] = esc_attr( $atts['class'] ); | |
| 311 | - $atts['lazy'] = esc_attr( $atts['lazy'] ); | |
| 312 | - $atts['use_image'] = esc_attr( $atts['use_image'] ); | |
| 313 | - | |
| 314 | - global $sitepress; | |
| 315 | - if ( Visualizer_Module::is_pro() && ( function_exists( 'icl_get_languages' ) && $sitepress instanceof \SitePress ) ) { | |
| 316 | - global $sitepress; | |
| 317 | - $locale = icl_get_current_language(); | |
| 318 | - $locale = strtolower( str_replace( '_', '-', $locale ) ); | |
| 319 | - $trid = $sitepress->get_element_trid( $atts['id'], 'post_' . Visualizer_Plugin::CPT_VISUALIZER ); | |
| 320 | - $translations = $sitepress->get_element_translations( $trid ); | |
| 321 | - if ( isset( $translations[ $locale ] ) && is_object( $translations[ $locale ] ) ) { | |
| 322 | - $atts['id'] = $translations[ $locale ]->element_id; | |
| 323 | - } | |
| 324 | - } | |
| 325 | - | |
| 326 | 308 | $chart_data = $this->getChartData( Visualizer_Plugin::CF_CHART_CACHE, $atts['id'] ); |
| 327 | 309 | // if empty chart does not exists, then return empty string. |
| 328 | 310 | if ( ! $chart_data ) { |
| 329 | 311 | return ''; |
| @@ -336,12 +318,8 @@ | ||
| 336 | 318 | if ( ! apply_filters( 'visualizer_pro_show_chart', true, $atts['id'] ) ) { |
| 337 | 319 | return ''; |
| 338 | 320 | } |
| 339 | 321 | |
| 340 | - if ( ! is_admin() && ! empty( $chart_data['is_woocommerce_report'] ) ) { | |
| 341 | - return ''; | |
| 342 | - } | |
| 343 | - | |
| 344 | 322 | // in case revisions exist. |
| 345 | 323 | // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.Found |
| 346 | 324 | if ( true === ( $revisions = $this->undoRevisions( $chart->ID, true ) ) ) { |
| 347 | 325 | $chart = get_post( $chart->ID ); |
| @@ -362,15 +340,12 @@ | ||
| 362 | 340 | if ( ctype_digit( $atts['lazy'] ) ) { |
| 363 | 341 | $attributes['data-lazy-limit'] = $atts['lazy']; |
| 364 | 342 | } |
| 365 | 343 | |
| 366 | - $attributes = apply_filters( 'visualizer_container_attributes', $attributes, $chart->ID ); | |
| 367 | - | |
| 368 | 344 | $chart = apply_filters( 'visualizer_schedule_refresh_chart', $chart, $chart->ID, false ); |
| 369 | 345 | |
| 370 | 346 | // Get and update settings. |
| 371 | 347 | $settings = $chart_data['settings']; |
| 372 | - $settings = ! empty( $settings ) ? $settings : array(); | |
| 373 | 348 | if ( empty( $settings['height'] ) ) { |
| 374 | 349 | $settings['height'] = '400'; |
| 375 | 350 | } |
| 376 | 351 | |
| @@ -417,21 +392,8 @@ | ||
| 417 | 392 | if ( isset( $settings['chart-img'] ) ) { |
| 418 | 393 | unset( $settings['chart-img'] ); |
| 419 | 394 | } |
| 420 | 395 | |
| 421 | - $enable_controls = false; | |
| 422 | - if ( isset( $settings['controls'] ) && ! empty( $settings['controls']['controlType'] ) ) { | |
| 423 | - $column_index = $settings['controls']['filterColumnIndex']; | |
| 424 | - $column_label = $settings['controls']['filterColumnLabel']; | |
| 425 | - if ( 'false' !== $column_index || 'false' !== $column_label ) { | |
| 426 | - $enable_controls = true; | |
| 427 | - } | |
| 428 | - } | |
| 429 | - | |
| 430 | - if ( ! $enable_controls ) { | |
| 431 | - unset( $settings['controls'] ); | |
| 432 | - } | |
| 433 | - | |
| 434 | 396 | // add chart to the array |
| 435 | 397 | $this->_charts[ $id ] = array( |
| 436 | 398 | 'type' => $type, |
| 437 | 399 | 'series' => $series, |
| @@ -513,13 +475,10 @@ | ||
| 513 | 475 | $prefix = 'C' . 'h' . 'a' . 'rt'; |
| 514 | 476 | if ( $type === 'tabular' ) { |
| 515 | 477 | $prefix = 'T' . 'a' . 'bl' . 'e'; |
| 516 | 478 | } |
| 517 | - if ( Visualizer_Module::is_pro() && $enable_controls ) { | |
| 518 | - $actions_div .= '<div id="control_wrapper_' . $id . '"></div>'; | |
| 519 | - } | |
| 520 | 479 | // return placeholder div |
| 521 | - return '<div class="' . $container_class . '" id="chart_wrapper_' . $id . '">' . $actions_div . '<div id="' . $id . '"' . $this->getHtmlAttributes( $attributes ) . '></div>' . $this->addSchema( $chart->ID ) . ( ! Visualizer_Module::is_pro() ? ( '<' . 'di' . 'v st' . 'yl' . 'e="' . 'op' . 'a' . 'ci' . 't' . 'y:' . '0' . '.7' . ';t' . 'ex' . 't-a' . 'li' . 'gn:' . 'ri' . 'gh' . 't;b' . 'o' . 'tto' . 'm: 1' . '0px; z-i' . 'nd' . 'ex:1' . '00' . '0; ' . 'le' . 'ft' . ':2' . '0px' . '; fo' . 'nt-si' . 'ze: 1' . '4px">' . $prefix . ' b' . 'y' . ' <a ' . 'h' . 're' . 'f="ht' . 'tp' . 's:/' . '/t' . 'he' . 'me' . 'i' . 'sl' . 'e' . '.c' . 'om' . '/p' . 'lu' . 'gi' . 'ns' . '/v' . 'i' . 'su' . 'al' . 'iz' . 'er' . '-c' . 'ha' . 'rts' . '-a' . 'nd' . '-gr' . 'ap' . 'hs' . '/" t' . 'arg' . 'et="' . '_bl' . 'an' . 'k" re' . 'l=' . '"no' . 'fol' . 'l' . 'ow"' . '>V' . 'is' . 'u' . 'a' . 'l' . 'i' . 'z' . 'e' . 'r' . '</' . 'a' . '>' . '<' . '/' . 'd' . 'i' . 'v' . '>' ) : '' ) . '</div>'; | |
| 480 | + return '<div class="' . $container_class . '">' . $actions_div . '<div id="' . $id . '"' . $this->getHtmlAttributes( $attributes ) . '></div>' . $this->addSchema( $chart->ID ) . ( ! Visualizer_Module::is_pro() ? ( '<' . 'di' . 'v st' . 'yl' . 'e="' . 'op' . 'a' . 'ci' . 't' . 'y:' . '0' . '.' . '.7' . ';t' . 'ex' . 't-a' . 'li' . 'gn:' . 'ri' . 'gh' . 't;b' . 'o' . 'tto' . 'm: 1' . '0px; z-i' . 'nd' . 'ex:1' . '00' . '0; ' . 'le' . 'ft' . ':2' . '0px' . '; fo' . 'nt-si' . 'ze: 1' . '4px">' . $prefix . ' b' . 'y' . ' <a ' . 'h' . 're' . 'f="ht' . 'tp' . 's:/' . '/t' . 'he' . 'me' . 'i' . 'sl' . 'e' . '.c' . 'om' . '/p' . 'lu' . 'gi' . 'ns' . '/v' . 'i' . 'su' . 'al' . 'iz' . 'er' . '-c' . 'ha' . 'rts' . '-a' . 'nd' . '-gr' . 'ap' . 'hs' . '/" t' . 'arg' . 'et="' . '_bl' . 'an' . 'k" re' . 'l=' . '"no' . 'fol' . 'l' . 'ow"' . '>V' . 'is' . 'u' . 'a' . 'l' . 'i' . 'z' . 'e' . 'r' . '</' . 'a' . '>' . '<' . '/' . 'd' . 'i' . 'v' . '>' ) : '' ) . '</div>'; | |
| 522 | 481 | } |
| 523 | 482 | |
| 524 | 483 | /** |
| 525 | 484 | * Converts the array of attributes to a string of HTML attributes. |
| @@ -661,11 +620,10 @@ | ||
| 661 | 620 | |
| 662 | 621 | // Get chart by ID. |
| 663 | 622 | $chart = get_post( $chart_id ); |
| 664 | 623 | if ( $chart && Visualizer_Plugin::CPT_VISUALIZER === $chart->post_type ) { |
| 665 | - $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true ); | |
| 666 | - $series = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ); | |
| 667 | - $is_woocommerce_report = get_post_meta( $chart->ID, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE, true ); | |
| 624 | + $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true ); | |
| 625 | + $series = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ); | |
| 668 | 626 | |
| 669 | 627 | if ( isset( $settings['series'] ) && ! ( count( $settings['series'] ) - count( $series ) > 1 ) ) { |
| 670 | 628 | $diff_total_series = abs( count( $settings['series'] ) - count( $series ) ); |
| 671 | 629 | if ( $diff_total_series ) { |
| @@ -674,14 +632,13 @@ | ||
| 674 | 632 | } |
| 675 | 633 | } |
| 676 | 634 | } |
| 677 | 635 | $chart_data = array( |
| 678 | - 'chart' => $chart, | |
| 679 | - 'type' => get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true ), | |
| 680 | - 'settings' => $settings, | |
| 681 | - 'series' => $series, | |
| 682 | - 'chart_image' => get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_IMAGE, true ), | |
| 683 | - 'is_woocommerce_report' => $is_woocommerce_report, | |
| 636 | + 'chart' => $chart, | |
| 637 | + 'type' => get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true ), | |
| 638 | + 'settings' => $settings, | |
| 639 | + 'series' => $series, | |
| 640 | + 'chart_image' => get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_IMAGE, true ), | |
| 684 | 641 | ); |
| 685 | 642 | |
| 686 | 643 | // Put the results in a transient. Expire after 12 hours. |
| 687 | 644 | set_transient( $cache_key, $chart_data, apply_filters( Visualizer_Plugin::FILTER_HANDLE_CACHE_EXPIRATION_TIME, 12 * HOUR_IN_SECONDS ) ); |