| @@ -132,8 +132,9 @@ | ||
| 132 | 132 | * |
| 133 | 133 | * @access public |
| 134 | 134 | */ |
| 135 | 135 | public function init() { |
| 136 | + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison | |
| 136 | 137 | if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) && 'true' == get_user_option( 'rich_editing' ) ) { |
| 137 | 138 | $this->_addFilter( 'mce_external_languages', 'add_tinymce_lang', 10, 1 ); |
| 138 | 139 | $this->_addFilter( 'mce_external_plugins', 'tinymce_plugin', 10, 1 ); |
| 139 | 140 | $this->_addFilter( 'mce_buttons', 'register_mce_button', 10, 1 ); |
| @@ -214,10 +215,12 @@ | ||
| 214 | 215 | if ( post_type_supports( $typenow, 'editor' ) ) { |
| 215 | 216 | wp_enqueue_style( 'visualizer-media', VISUALIZER_ABSURL . 'css/media.css', array( 'media-views' ), Visualizer_Plugin::VERSION ); |
| 216 | 217 | |
| 217 | 218 | // 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' ) ); | |
| 219 | + $deps = array( | |
| 220 | + Visualizer_Render_Sidebar_Google::enqueue_assets( array( 'media-editor' ) ), | |
| 221 | + Visualizer_Render_Sidebar_Type_DataTable::enqueue_assets( array( 'media-editor' ) ), | |
| 222 | + ); | |
| 220 | 223 | |
| 221 | 224 | wp_enqueue_script( 'visualizer-media-model', VISUALIZER_ABSURL . 'js/media/model.js', $deps, Visualizer_Plugin::VERSION, true ); |
| 222 | 225 | wp_enqueue_script( 'visualizer-media-collection', VISUALIZER_ABSURL . 'js/media/collection.js', array( 'visualizer-media-model' ), Visualizer_Plugin::VERSION, true ); |
| 223 | 226 | wp_enqueue_script( 'visualizer-media-controller', VISUALIZER_ABSURL . 'js/media/controller.js', array( 'visualizer-media-collection' ), Visualizer_Plugin::VERSION, true ); |
| @@ -320,16 +323,16 @@ | ||
| 320 | 323 | 'column' => array( |
| 321 | 324 | 'name' => esc_html__( 'Column', 'visualizer' ), |
| 322 | 325 | 'enabled' => true, |
| 323 | 326 | ), |
| 327 | + 'scatter' => array( | |
| 328 | + 'name' => esc_html__( 'Scatter', 'visualizer' ), | |
| 329 | + 'enabled' => true, | |
| 330 | + ), | |
| 324 | 331 | 'gauge' => array( |
| 325 | 332 | 'name' => esc_html__( 'Gauge', 'visualizer' ), |
| 326 | 333 | 'enabled' => true, |
| 327 | 334 | ), |
| 328 | - 'scatter' => array( | |
| 329 | - 'name' => esc_html__( 'Scatter', 'visualizer' ), | |
| 330 | - 'enabled' => true, | |
| 331 | - ), | |
| 332 | 335 | 'candlestick' => array( |
| 333 | 336 | 'name' => esc_html__( 'Candlestick', 'visualizer' ), |
| 334 | 337 | 'enabled' => true, |
| 335 | 338 | ), |
| @@ -398,12 +401,20 @@ | ||
| 398 | 401 | |
| 399 | 402 | // if a user has a Gauge/Candlestick chart, then let them keep using it. |
| 400 | 403 | if ( ! VISUALIZER_PRO ) { |
| 401 | 404 | if ( ! self::hasChartType( 'gauge' ) ) { |
| 402 | - $deprecated[] = 'gauge'; | |
| 405 | + if ( $get2Darray ) { | |
| 406 | + $deprecated[] = 'gauge'; | |
| 407 | + } else { | |
| 408 | + $types['gauge']['enabled'] = false; | |
| 409 | + } | |
| 403 | 410 | } |
| 404 | 411 | if ( ! self::hasChartType( 'candlestick' ) ) { |
| 405 | - $deprecated[] = 'candlestick'; | |
| 412 | + if ( $get2Darray ) { | |
| 413 | + $deprecated[] = 'candlestick'; | |
| 414 | + } else { | |
| 415 | + $types['candlestick']['enabled'] = false; | |
| 416 | + } | |
| 406 | 417 | } |
| 407 | 418 | } |
| 408 | 419 | break; |
| 409 | 420 | default: |
| @@ -410,23 +421,29 @@ | ||
| 410 | 421 | // remove the option to create a Google Table chart. |
| 411 | 422 | $deprecated[] = 'table'; |
| 412 | 423 | |
| 413 | 424 | // 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 | - } | |
| 425 | + if ( $get2Darray ) { | |
| 426 | + $types['dataTable'] = esc_html__( 'Table', 'visualizer' ); | |
| 427 | + } else { | |
| 428 | + $types['dataTable']['name'] = esc_html__( 'Table', 'visualizer' ); | |
| 420 | 429 | } |
| 421 | 430 | |
| 422 | 431 | // if a user has a Gauge/Candlestick chart, then let them keep using it. |
| 423 | 432 | if ( ! VISUALIZER_PRO ) { |
| 424 | 433 | if ( ! self::hasChartType( 'gauge' ) ) { |
| 425 | - $deprecated[] = 'gauge'; | |
| 434 | + if ( $get2Darray ) { | |
| 435 | + $deprecated[] = 'gauge'; | |
| 436 | + } else { | |
| 437 | + $types['gauge']['enabled'] = false; | |
| 438 | + } | |
| 426 | 439 | } |
| 427 | 440 | if ( ! self::hasChartType( 'candlestick' ) ) { |
| 428 | - $deprecated[] = 'candlestick'; | |
| 441 | + if ( $get2Darray ) { | |
| 442 | + $deprecated[] = 'candlestick'; | |
| 443 | + } else { | |
| 444 | + $types['candlestick']['enabled'] = false; | |
| 445 | + } | |
| 429 | 446 | } |
| 430 | 447 | } |
| 431 | 448 | } |
| 432 | 449 | |
| @@ -448,9 +465,9 @@ | ||
| 448 | 465 | * @access public |
| 449 | 466 | */ |
| 450 | 467 | public function renderTemplates() { |
| 451 | 468 | global $pagenow; |
| 452 | - if ( 'post.php' != $pagenow && 'post-new.php' != $pagenow ) { | |
| 469 | + if ( 'post.php' !== $pagenow && 'post-new.php' !== $pagenow ) { | |
| 453 | 470 | return; |
| 454 | 471 | } |
| 455 | 472 | $render = new Visualizer_Render_Templates(); |
| 456 | 473 | $render->render(); |
| @@ -468,9 +485,9 @@ | ||
| 468 | 485 | * |
| 469 | 486 | * @param string $suffix The current page suffix. |
| 470 | 487 | */ |
| 471 | 488 | public function enqueueLibraryScripts( $suffix ) { |
| 472 | - if ( $suffix == $this->_libraryPage ) { | |
| 489 | + if ( $suffix === $this->_libraryPage ) { | |
| 473 | 490 | wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION ); |
| 474 | 491 | $this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' ); |
| 475 | 492 | wp_enqueue_media(); |
| 476 | 493 | wp_enqueue_script( |
| @@ -562,9 +579,9 @@ | ||
| 562 | 579 | 'paged' => $page, |
| 563 | 580 | ); |
| 564 | 581 | // add chart type filter to the query arguments |
| 565 | 582 | $filter = filter_input( INPUT_GET, 'type' ); |
| 566 | - if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) { | |
| 583 | + if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes(), true ) ) { | |
| 567 | 584 | $query_args['meta_query'] = array( |
| 568 | 585 | array( |
| 569 | 586 | 'key' => Visualizer_Plugin::CF_CHART_TYPE, |
| 570 | 587 | 'value' => $filter, |
| @@ -614,9 +631,9 @@ | ||
| 614 | 631 | ) |
| 615 | 632 | ); |
| 616 | 633 | // add chart type filter to the query arguments |
| 617 | 634 | $filter = filter_input( INPUT_GET, 'type' ); |
| 618 | - if ( ! ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) ) { | |
| 635 | + if ( ! ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes(), true ) ) ) { | |
| 619 | 636 | $filter = 'all'; |
| 620 | 637 | } |
| 621 | 638 | |
| 622 | 639 | $css = ''; |
| @@ -688,8 +705,9 @@ | ||
| 688 | 705 | $ajaxurl |
| 689 | 706 | ), |
| 690 | 707 | ), |
| 691 | 708 | 'page_type' => 'library', |
| 709 | + 'is_front' => false, | |
| 692 | 710 | ) |
| 693 | 711 | ); |
| 694 | 712 | // render library page |
| 695 | 713 | $render = new Visualizer_Render_Library(); |
| @@ -721,9 +739,9 @@ | ||
| 721 | 739 | * |
| 722 | 740 | * @return array Updated array of action links. |
| 723 | 741 | */ |
| 724 | 742 | public function getPluginActionLinks( $links, $file ) { |
| 725 | - if ( $file == plugin_basename( VISUALIZER_BASEFILE ) ) { | |
| 743 | + if ( $file === plugin_basename( VISUALIZER_BASEFILE ) ) { | |
| 726 | 744 | array_unshift( |
| 727 | 745 | $links, |
| 728 | 746 | sprintf( |
| 729 | 747 | '<a href="%s">%s</a>', |
| @@ -748,9 +766,9 @@ | ||
| 748 | 766 | * |
| 749 | 767 | * @return array Updated array of plugin meta links. |
| 750 | 768 | */ |
| 751 | 769 | public function getPluginMetaLinks( $plugin_meta, $plugin_file ) { |
| 752 | - if ( $plugin_file == plugin_basename( VISUALIZER_BASEFILE ) ) { | |
| 770 | + if ( $plugin_file === plugin_basename( VISUALIZER_BASEFILE ) ) { | |
| 753 | 771 | // knowledge base link |
| 754 | 772 | $plugin_meta[] = sprintf( |
| 755 | 773 | '<a href="https://github.com/codeinwp/visualizer/wiki" target="_blank">%s</a>', |
| 756 | 774 | esc_html__( 'Knowledge Base', 'visualizer' ) |