| @@ -124,9 +124,14 @@ | ||
| 124 | 124 | self::_renderTextAreaItem( |
| 125 | 125 | esc_html__( 'Chart Description', 'visualizer' ), |
| 126 | 126 | 'description', |
| 127 | 127 | $this->description, |
| 128 | - sprintf( esc_html__( 'Description to display in the structured data schema as explained %1$shere%2$s', 'visualizer' ), '<a href="https://developers.google.com/search/docs/data-types/dataset#dataset" target="_blank">', '</a>' ) | |
| 128 | + sprintf( | |
| 129 | + // translators: %1$s - HTML link tag, %2$s - HTML closing link tag. | |
| 130 | + esc_html__( 'Description to display in the structured data schema as explained %1$shere%2$s', 'visualizer' ), | |
| 131 | + '<a href="https://developers.google.com/search/docs/data-types/dataset#dataset" target="_blank">', | |
| 132 | + '</a>' | |
| 133 | + ) | |
| 129 | 134 | ); |
| 130 | 135 | } |
| 131 | 136 | |
| 132 | 137 | /** |
| @@ -133,9 +138,17 @@ | ||
| 133 | 138 | * Add the correct description for the manual configuration box. |
| 134 | 139 | */ |
| 135 | 140 | protected function _renderManualConfigDescription() { |
| 136 | 141 | self::_renderSectionStart(); |
| 137 | - self::_renderSectionDescription( '<span class="viz-gvlink">' . sprintf( __( 'Configure the graph by providing configuration variables right from the %1$sGoogle Visualization API%2$s. You can refer to to some examples %3$shere%4$s.', 'visualizer' ), '<a href="https://developers.google.com/chart/interactive/docs/gallery/?#configuration-options" target="_blank">', '</a>', '<a href="https://docs.themeisle.com/article/728-manual-configuration" target="_blank">', '</a>' ) . '</span>' ); | |
| 142 | + self::_renderSectionDescription( | |
| 143 | + '<span class="viz-gvlink">' . sprintf( | |
| 144 | + // translators: %1$s - HTML link tag, %2$s - HTML closing link tag, %3$s - HTML link tag, %4$s - HTML closing link tag. | |
| 145 | + __( 'Configure the graph by providing configuration variables right from the %1$sGoogle Visualization API%2$s. You can refer to %3$sCommon Snippets%4$s for examples.', 'visualizer' ), '<a href="https://developers.google.com/chart/interactive/docs/gallery/?#configuration-options" target="_blank">', | |
| 146 | + '</a>', | |
| 147 | + '<a href="https://docs.themeisle.com/article/728-manual-configuration" target="_blank">', | |
| 148 | + '</a>' | |
| 149 | + ) . '</span>' | |
| 150 | + ); | |
| 138 | 151 | } |
| 139 | 152 | |
| 140 | 153 | /** |
| 141 | 154 | * Add the correct example for the manual configuration box. |
| @@ -140,17 +153,18 @@ | ||
| 140 | 153 | /** |
| 141 | 154 | * Add the correct example for the manual configuration box. |
| 142 | 155 | */ |
| 143 | 156 | protected function _renderManualConfigExample() { |
| 144 | - return '{ | |
| 145 | - "vAxis": { | |
| 146 | - "ticks": [5, 10, 15, 20], | |
| 147 | - "titleTextStyle": { | |
| 148 | - "color": "red" | |
| 149 | - }, | |
| 150 | - "textPosition": "in" | |
| 151 | - } | |
| 152 | - }'; | |
| 157 | + return json_encode( | |
| 158 | + array( | |
| 159 | + 'vAxis' => array( | |
| 160 | + 'ticks' => array( 5, 10, 15, 20 ), | |
| 161 | + 'titleTextStyle' => array( 'color' => 'red' ), | |
| 162 | + 'textPosition' => 'in', | |
| 163 | + ), | |
| 164 | + ), | |
| 165 | + JSON_PRETTY_PRINT | |
| 166 | + ); | |
| 153 | 167 | } |
| 154 | 168 | |
| 155 | 169 | /** |
| 156 | 170 | * Renders chart advanced settings group. |
| @@ -160,9 +174,9 @@ | ||
| 160 | 174 | protected function _renderAdvancedSettings() { |
| 161 | 175 | // Chart control settings. |
| 162 | 176 | $this->_renderChartControlsGroup(); |
| 163 | 177 | |
| 164 | - if ( Visualizer_Module_Admin::proFeaturesLocked() ) { | |
| 178 | + if ( Visualizer_Module_Admin::proFeaturesEnabled() ) { | |
| 165 | 179 | self::_renderGroupStart( esc_html__( 'Frontend Actions', 'visualizer' ) ); |
| 166 | 180 | } else { |
| 167 | 181 | self::_renderGroupStart( esc_html__( 'Frontend Actions', 'visualizer' ) . '<span class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-frontend-actions' ), 'vz-frontend-actions' ); |
| 168 | 182 | echo '<div style="position: relative">'; |
| @@ -171,10 +185,10 @@ | ||
| 171 | 185 | self::_renderSectionDescription( esc_html__( 'Configure frontend actions that need to be shown.', 'visualizer' ) ); |
| 172 | 186 | self::_renderSectionEnd(); |
| 173 | 187 | |
| 174 | 188 | $this->_renderActionSettings(); |
| 175 | - if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) { | |
| 176 | - echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions' ); | |
| 189 | + if ( ! Visualizer_Module_Admin::proFeaturesEnabled() ) { | |
| 190 | + echo apply_filters( 'visualizer_pro_upsell', '', 'frontend-actions' ); | |
| 177 | 191 | echo '</div>'; |
| 178 | 192 | } |
| 179 | 193 | self::_renderGroupEnd(); |
| 180 | 194 | |
| @@ -184,10 +198,11 @@ | ||
| 184 | 198 | esc_html__( 'Configuration', 'visualizer' ), |
| 185 | 199 | 'manual', |
| 186 | 200 | $this->manual, |
| 187 | 201 | sprintf( |
| 188 | - esc_html__( 'One per line in valid JSON (key:value) format e.g. %s', 'visualizer' ), | |
| 189 | - '<br><code>' . $this->_renderManualConfigExample() . '</code>' | |
| 202 | + // translators: %s - JSON example. | |
| 203 | + esc_html__( 'Provide a valid JSON configuration object. Example: %s', 'visualizer' ), | |
| 204 | + '<code class="viz-manual-config-example">' . esc_html( $this->_renderManualConfigExample() ) . '</code>' | |
| 190 | 205 | ), |
| 191 | 206 | '', |
| 192 | 207 | array( 'rows' => 5 ) |
| 193 | 208 | ); |
| @@ -193,9 +208,8 @@ | ||
| 193 | 208 | ); |
| 194 | 209 | |
| 195 | 210 | self::_renderSectionEnd(); |
| 196 | 211 | self::_renderGroupEnd(); |
| 197 | - | |
| 198 | 212 | } |
| 199 | 213 | |
| 200 | 214 | /** |
| 201 | 215 | * Renders chart action buttons group. |
| @@ -206,9 +220,9 @@ | ||
| 206 | 220 | global $wp_version; |
| 207 | 221 | $disable_actions = version_compare( $wp_version, '4.7.0', '<' ); |
| 208 | 222 | // default open this section when not testing through cypress because cypress expects to click and open each section |
| 209 | 223 | // and may not like finding a section is already open. |
| 210 | - self::_renderSectionStart( esc_html__( 'Actions', 'visualizer' ), ! defined( 'TI_CYPRESS_TESTING' ) ); | |
| 224 | + self::_renderSectionStart( esc_html__( 'Actions', 'visualizer' ), ! defined( 'TI_E2E_TESTING' ) ); | |
| 211 | 225 | self::_renderCheckboxItem( |
| 212 | 226 | esc_html__( 'Print', 'visualizer' ), |
| 213 | 227 | 'actions[]', |
| 214 | 228 | isset( $this->actions ) && in_array( 'print', $this->actions, true ) ? true : false, |
| @@ -261,9 +275,9 @@ | ||
| 261 | 275 | */ |
| 262 | 276 | private static function is_excel_enabled() { |
| 263 | 277 | $vendor_file = VISUALIZER_ABSPATH . '/vendor/autoload.php'; |
| 264 | 278 | if ( is_readable( $vendor_file ) ) { |
| 265 | - include_once( $vendor_file ); | |
| 279 | + include_once $vendor_file; | |
| 266 | 280 | } |
| 267 | 281 | |
| 268 | 282 | if ( version_compare( phpversion(), '5.6.0', '<' ) ) { |
| 269 | 283 | do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'PHP version %s not supported', phpversion() ), 'error', __FILE__, __LINE__ ); |
| @@ -269,9 +283,9 @@ | ||
| 269 | 283 | do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'PHP version %s not supported', phpversion() ), 'error', __FILE__, __LINE__ ); |
| 270 | 284 | return false; |
| 271 | 285 | } |
| 272 | 286 | |
| 273 | - return class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && extension_loaded( 'fileinfo' ); | |
| 287 | + return class_exists( 'OpenSpout\Writer\Common\Creator\WriterEntityFactory' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && extension_loaded( 'fileinfo' ); | |
| 274 | 288 | } |
| 275 | 289 | |
| 276 | 290 | /** |
| 277 | 291 | * Renders select item. |
| @@ -298,9 +312,9 @@ | ||
| 298 | 312 | } |
| 299 | 313 | echo '<div class="viz-section-item">'; |
| 300 | 314 | echo '<a class="more-info" href="javascript:;">[?]</a>'; |
| 301 | 315 | echo '<b>', $title, '</b>'; |
| 302 | - echo '<select class="control-select ', implode( ' ', $classes ) , '" name="', $name, '" ', ( $multiple ? 'multiple' : '' ), ' ' , $atts, '>'; | |
| 316 | + echo '<select class="control-select ', implode( ' ', $classes ), '" name="', $name, '" ', ( $multiple ? 'multiple' : '' ), ' ', $atts, '>'; | |
| 303 | 317 | foreach ( $options as $key => $label ) { |
| 304 | 318 | // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict |
| 305 | 319 | $extra = $multiple && is_array( $value ) ? ( in_array( $key, $value ) ? 'selected' : '' ) : selected( $key, $value, false ); |
| 306 | 320 | echo '<option value="', $key, '"', $extra, '>'; |
| @@ -321,15 +335,15 @@ | ||
| 321 | 335 | * @access protected |
| 322 | 336 | * @param string $title The title of the select item. |
| 323 | 337 | * @param string $name The name of the select item. |
| 324 | 338 | * @param string $value The actual value of the select item. |
| 325 | - * @param string $default The default value of the color picker. | |
| 339 | + * @param string $default_color The default value of the color picker. | |
| 326 | 340 | */ |
| 327 | - protected static function _renderColorPickerItem( $title, $name, $value, $default ) { | |
| 341 | + protected static function _renderColorPickerItem( $title, $name, $value, $default_color ) { | |
| 328 | 342 | echo '<div class="viz-section-item">'; |
| 329 | 343 | echo '<b>', $title, '</b>'; |
| 330 | 344 | echo '<div>'; |
| 331 | - echo '<input type="text" class="color-picker-hex color-picker" data-alpha-enabled="true" name="', $name, '" maxlength="7" placeholder="', esc_attr__( 'Hex Value', 'visualizer' ), '" value="', is_null( $value ) ? $default : esc_attr( $value ), '" data-default-color="', $default, '">'; | |
| 345 | + echo '<input type="text" class="color-picker-hex color-picker" data-alpha-enabled="true" name="', $name, '" maxlength="7" placeholder="', esc_attr__( 'Hex Color Code', 'visualizer' ), '" value="', is_null( $value ) ? $default_color : esc_attr( $value ), '" data-default-color="', $default_color, '">'; | |
| 332 | 346 | echo '</div>'; |
| 333 | 347 | echo '</div>'; |
| 334 | 348 | } |
| 335 | 349 | |
| @@ -372,12 +386,12 @@ | ||
| 372 | 386 | * @static |
| 373 | 387 | * @access public |
| 374 | 388 | * @param string $title The title of this group. |
| 375 | 389 | * @param string $html Any additional HTML. |
| 376 | - * @param string $class Any additional classes. | |
| 390 | + * @param string $extra_class Any additional classes. | |
| 377 | 391 | */ |
| 378 | - public static function _renderGroupStart( $title, $html = '', $class = '', $id = '' ) { | |
| 379 | - echo '<li id="' . $id . '" class="viz-group ' . $class . '">'; | |
| 392 | + public static function _renderGroupStart( $title, $html = '', $extra_class = '', $id = '' ) { | |
| 393 | + echo '<li id="' . $id . '" class="viz-group ' . $extra_class . '">'; | |
| 380 | 394 | echo '<h3 class="viz-group-title">', $title, '</h3>'; |
| 381 | 395 | echo $html; |
| 382 | 396 | echo '<ul class="viz-group-content">'; |
| 383 | 397 | } |
| @@ -460,9 +474,14 @@ | ||
| 460 | 474 | self::_renderTextItem( |
| 461 | 475 | esc_html__( 'Number Format', 'visualizer' ), |
| 462 | 476 | 'series[' . $index . '][format]', |
| 463 | 477 | isset( $this->series[ $index ]['format'] ) ? $this->series[ $index ]['format'] : '', |
| 464 | - sprintf( esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU pattern set%2$s. Use something like #,### to get 1,234 as output, or $# to add dollar sign before digits. Pay attention that if you use % percentage format then your values will be multiplied by 100.', 'visualizer' ), '<a href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details" target="_blank">', '</a>' ), | |
| 478 | + sprintf( | |
| 479 | + // translators: %1$s - HTML link tag, %2$s - HTML closing link tag. | |
| 480 | + esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU pattern set%2$s. Use something like #,### to get 1,234 as output, or $# to add dollar sign before digits. Note: Using the % percentage format will multiply your values by 100.', 'visualizer' ), | |
| 481 | + '<a href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details" target="_blank">', | |
| 482 | + '</a>' | |
| 483 | + ), | |
| 465 | 484 | '#,###.##' |
| 466 | 485 | ); |
| 467 | 486 | break; |
| 468 | 487 | case 'date': |
| @@ -471,9 +490,14 @@ | ||
| 471 | 490 | self::_renderTextItem( |
| 472 | 491 | esc_html__( 'Date Format', 'visualizer' ), |
| 473 | 492 | 'series[' . $index . '][format]', |
| 474 | 493 | isset( $this->series[ $index ]['format'] ) ? $this->series[ $index ]['format'] : '', |
| 475 | - sprintf( esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU date and time format%2$s.', 'visualizer' ), '<a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax" target="_blank">', '</a>' ), | |
| 494 | + sprintf( | |
| 495 | + // translators: %1$s - HTML link tag, %2$s - HTML closing link tag. | |
| 496 | + esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU date and time format%2$s.', 'visualizer' ), | |
| 497 | + '<a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax" target="_blank">', | |
| 498 | + '</a>' | |
| 499 | + ), | |
| 476 | 500 | 'eeee, dd LLLL yyyy' |
| 477 | 501 | ); |
| 478 | 502 | break; |
| 479 | 503 | } |
| @@ -481,14 +505,13 @@ | ||
| 481 | 505 | |
| 482 | 506 | /** |
| 483 | 507 | * Render a checkbox item |
| 484 | 508 | */ |
| 485 | - protected static function _renderCheckboxItem( $title, $name, $value, $default, $desc, $disabled = false ) { | |
| 509 | + protected static function _renderCheckboxItem( $title, $name, $value, $default_value, $desc, $disabled = false ) { | |
| 486 | 510 | echo '<div class="viz-section-item">'; |
| 487 | 511 | echo '<a class="more-info" href="javascript:;">[?]</a>'; |
| 488 | 512 | echo '<b>', $title, '</b>'; |
| 489 | - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison | |
| 490 | - echo '<input type="checkbox" class="control-check" value="', $default, '" name="', $name, '" ', ( $value == $default ? 'checked' : '' ), ' ', ( $disabled ? 'disabled=disabled' : '' ), '>'; | |
| 513 | + echo '<input type="checkbox" class="control-check" value="', $default_value, '" name="', $name, '" ', ( $value ? 'checked' : '' ), ' ', ( $disabled ? 'disabled=disabled' : '' ), '>'; | |
| 491 | 514 | echo '<p class="viz-section-description">', $desc, '</p>'; |
| 492 | 515 | echo '</div>'; |
| 493 | 516 | } |
| 494 | 517 | |
| @@ -527,9 +550,8 @@ | ||
| 527 | 550 | |
| 528 | 551 | if ( in_array( 'numeral', $libs, true ) && ! wp_script_is( 'numeral', 'registered' ) ) { |
| 529 | 552 | wp_register_script( 'numeral', VISUALIZER_ABSURL . 'js/lib/numeral.min.js', array(), Visualizer_Plugin::VERSION ); |
| 530 | 553 | } |
| 531 | - | |
| 532 | 554 | } |
| 533 | 555 | |
| 534 | 556 | /** |
| 535 | 557 | * Renders save chart as image setting group. |
| @@ -580,9 +602,9 @@ | ||
| 580 | 602 | protected function _renderChartControlsGroup() { |
| 581 | 603 | if ( 'google' !== $this->getLibrary() ) { |
| 582 | 604 | return; |
| 583 | 605 | } |
| 584 | - if ( Visualizer_Module_Admin::proFeaturesLocked() ) { | |
| 606 | + if ( Visualizer_Module_Admin::proFeaturesEnabled() ) { | |
| 585 | 607 | self::_renderGroupStart( esc_html__( 'Chart Data Filter Configuration', 'visualizer' ) ); |
| 586 | 608 | } else { |
| 587 | 609 | self::_renderGroupStart( esc_html__( 'Chart Data Filter Configuration', 'visualizer' ) . '<span class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-filter-controls' ), 'vz-data-controls' ); |
| 588 | 610 | echo '<div style="position: relative">'; |
| @@ -587,13 +609,20 @@ | ||
| 587 | 609 | self::_renderGroupStart( esc_html__( 'Chart Data Filter Configuration', 'visualizer' ) . '<span class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-filter-controls' ), 'vz-data-controls' ); |
| 588 | 610 | echo '<div style="position: relative">'; |
| 589 | 611 | } |
| 590 | 612 | self::_renderSectionStart(); |
| 591 | - self::_renderSectionDescription( '<span class="viz-gvlink">' . sprintf( __( 'Configure the data filter controls by providing configuration variables right from the %1$sChart Controls API%2$s. ', 'visualizer' ), '<a href="https://developers.google.com/chart/interactive/docs/gallery/controls#controls-gallery" target="_blank">', '</a>' ) . '</span>' ); | |
| 613 | + self::_renderSectionDescription( | |
| 614 | + '<span class="viz-gvlink">' . sprintf( | |
| 615 | + // translators: %1$s - HTML link tag, %2$s - HTML closing link tag. | |
| 616 | + __( 'Configure the data filter controls by providing configuration variables right from the %1$sChart Controls API%2$s. ', 'visualizer' ), | |
| 617 | + '<a href="https://developers.google.com/chart/interactive/docs/gallery/controls#controls-gallery" target="_blank">', | |
| 618 | + '</a>' | |
| 619 | + ) . '</span>' | |
| 620 | + ); | |
| 592 | 621 | self::_renderSectionEnd(); |
| 593 | 622 | $this->_renderChartControlsSettings(); |
| 594 | - if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) { | |
| 595 | - echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions' ); | |
| 623 | + if ( ! Visualizer_Module_Admin::proFeaturesEnabled() ) { | |
| 624 | + echo apply_filters( 'visualizer_pro_upsell', '', 'data-filter-configuration' ); | |
| 596 | 625 | echo '</div>'; |
| 597 | 626 | } |
| 598 | 627 | self::_renderGroupEnd(); |
| 599 | 628 | } |
| @@ -624,16 +653,21 @@ | ||
| 624 | 653 | false, |
| 625 | 654 | array( 'vz-controls-opt' ) |
| 626 | 655 | ); |
| 627 | 656 | |
| 628 | - $column_index = [ 'false' => '' ]; | |
| 629 | - $column_label = [ 'false' => '' ]; | |
| 657 | + $column_index = array( 'false' => '' ); | |
| 658 | + $column_label = array( 'false' => '' ); | |
| 630 | 659 | if ( ! empty( $this->__series ) ) { |
| 631 | 660 | foreach ( $this->__series as $key => $column ) { |
| 632 | 661 | $column_type = isset( $column['type'] ) ? $column['type'] : ''; |
| 633 | 662 | $label = isset( $column['label'] ) ? $column['label'] : ''; |
| 634 | 663 | $column_label[ $label ] = $label; |
| 635 | - $column_index[ $key ] = sprintf( __( '%1$d — Column Type: %2$s ', 'visualizer' ), $key, ucfirst( $column_type ) ); | |
| 664 | + $column_index[ $key ] = sprintf( | |
| 665 | + // translators: %1$d - the column key, %2$s - the column type. | |
| 666 | + __( '%1$d — Column Type: %2$s ', 'visualizer' ), | |
| 667 | + $key, | |
| 668 | + ucfirst( $column_type ) | |
| 669 | + ); | |
| 636 | 670 | } |
| 637 | 671 | } |
| 638 | 672 | |
| 639 | 673 | self::_renderSelectItem( |