| @@ -174,9 +174,9 @@ | ||
| 174 | 174 | self::_renderGroupEnd(); |
| 175 | 175 | |
| 176 | 176 | self::_renderGroupStart( esc_html__( 'Manual Configuration', 'visualizer' ) ); |
| 177 | 177 | self::_renderSectionStart(); |
| 178 | - self::_renderSectionDescription( '<span class="viz-gvlink">' . sprintf( __( 'Configure the graph by providing configuration variables right from the %1$sGoogle Visualization API%2$s', 'visualizer' ), '<a href="https://developers.google.com/chart/interactive/docs/gallery/?#configuration-options" target="_blank">', '</a>' ) . '</span>' ); | |
| 178 | + 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>' ); | |
| 179 | 179 | |
| 180 | 180 | $example = ' |
| 181 | 181 | { |
| 182 | 182 | "vAxis": { |
| @@ -216,27 +216,27 @@ | ||
| 216 | 216 | self::_renderSectionStart( esc_html__( 'Actions', 'visualizer' ), false ); |
| 217 | 217 | self::_renderCheckboxItem( |
| 218 | 218 | esc_html__( 'Print', 'visualizer' ), |
| 219 | 219 | 'actions[]', |
| 220 | - isset( $this->actions ) && in_array( 'print', $this->actions ) ? true : false, | |
| 220 | + isset( $this->actions ) && in_array( 'print', $this->actions, true ) ? true : false, | |
| 221 | 221 | 'print', |
| 222 | - $disable_actions ? '<span class="viz-section-error">' . esc_html__( 'Upgrade to at least WordPress 4.7 to use this.', 'visualizer' ) . '</span>' : esc_html__( 'To enable printing the data.', 'visualizer' ), | |
| 222 | + $disable_actions ? '<span class="viz-section-error">' . esc_html__( 'Upgrade to at least WordPress 4.7 to use this.', 'visualizer' ) . '</span>' : esc_html__( 'To enable printing the chart/data.', 'visualizer' ), | |
| 223 | 223 | $disable_actions |
| 224 | 224 | ); |
| 225 | 225 | self::_renderCheckboxItem( |
| 226 | 226 | esc_html__( 'CSV', 'visualizer' ), |
| 227 | 227 | 'actions[]', |
| 228 | - isset( $this->actions ) && in_array( 'csv;application/csv', $this->actions ) ? true : false, | |
| 228 | + isset( $this->actions ) && in_array( 'csv;application/csv', $this->actions, true ) ? true : false, | |
| 229 | 229 | 'csv;application/csv', |
| 230 | 230 | $disable_actions ? '<span class="viz-section-error">' . esc_html__( 'Upgrade to at least WordPress 4.7 to use this.', 'visualizer' ) . '</span>' : esc_html__( 'To enable downloading the data as a CSV.', 'visualizer' ), |
| 231 | 231 | $disable_actions |
| 232 | 232 | ); |
| 233 | 233 | |
| 234 | - $disabled = ! ( class_exists( 'PHPExcel' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && version_compare( PHP_VERSION, '5.2.0', '>' ) ); | |
| 234 | + $disabled = ! self::is_excel_enabled(); | |
| 235 | 235 | self::_renderCheckboxItem( |
| 236 | 236 | esc_html__( 'Excel', 'visualizer' ), |
| 237 | 237 | 'actions[]', |
| 238 | - isset( $this->actions ) && in_array( 'xls;application/vnd.ms-excel', $this->actions ) ? true : false, | |
| 238 | + isset( $this->actions ) && in_array( 'xls;application/vnd.ms-excel', $this->actions, true ) ? true : false, | |
| 239 | 239 | 'xls;application/vnd.ms-excel', |
| 240 | 240 | $disable_actions ? '<span class="viz-section-error">' . esc_html__( 'Upgrade to at least WordPress 4.7 to use this.', 'visualizer' ) . '</span>' : ( $disabled ? '<span class="viz-section-error">' . esc_html__( 'Enable the ZIP and XML extensions to use this setting.', 'visualizer' ) . '</span>' : esc_html__( 'To enable downloading the data as an Excel spreadsheet.', 'visualizer' ) ), |
| 241 | 241 | $disable_actions || $disabled |
| 242 | 242 | ); |
| @@ -242,9 +242,9 @@ | ||
| 242 | 242 | ); |
| 243 | 243 | self::_renderCheckboxItem( |
| 244 | 244 | esc_html__( 'Copy', 'visualizer' ), |
| 245 | 245 | 'actions[]', |
| 246 | - isset( $this->actions ) && in_array( 'copy', $this->actions ) ? true : false, | |
| 246 | + isset( $this->actions ) && in_array( 'copy', $this->actions, true ) ? true : false, | |
| 247 | 247 | 'copy', |
| 248 | 248 | $disable_actions ? '<span class="viz-section-error">' . esc_html__( 'Upgrade to at least WordPress 4.7 to use this.', 'visualizer' ) . '</span>' : esc_html__( 'To enable copying the data to the clipboard.', 'visualizer' ), |
| 249 | 249 | $disable_actions |
| 250 | 250 | ); |
| @@ -251,8 +251,20 @@ | ||
| 251 | 251 | self::_renderSectionEnd(); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | + * Checks if the Excel module can be enabled. | |
| 256 | + */ | |
| 257 | + private static function is_excel_enabled() { | |
| 258 | + $vendor_file = VISUALIZER_ABSPATH . '/vendor/autoload.php'; | |
| 259 | + if ( is_readable( $vendor_file ) ) { | |
| 260 | + include_once( $vendor_file ); | |
| 261 | + } | |
| 262 | + | |
| 263 | + return class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && extension_loaded( 'fileinfo' ) && version_compare( PHP_VERSION, '5.6.0', '>' ); | |
| 264 | + } | |
| 265 | + | |
| 266 | + /** | |
| 255 | 267 | * Renders chart general settings group. |
| 256 | 268 | * |
| 257 | 269 | * @since 1.0.0 |
| 258 | 270 | * |
| @@ -350,9 +362,9 @@ | ||
| 350 | 362 | |
| 351 | 363 | self::_renderCheckboxItem( |
| 352 | 364 | esc_html__( 'Animate on startup', 'visualizer' ), |
| 353 | 365 | 'animation[startup]', |
| 354 | - $this->animation['startup'], | |
| 366 | + isset( $this->animation['startup'] ) ? $this->animation['startup'] : 0, | |
| 355 | 367 | true, |
| 356 | 368 | esc_html__( 'Determines if the chart will animate on the initial draw.', 'visualizer' ) |
| 357 | 369 | ); |
| 358 | 370 | |
| @@ -552,9 +564,9 @@ | ||
| 552 | 564 | echo '<a class="more-info" href="javascript:;">[?]</a>'; |
| 553 | 565 | echo '<b>', $title, '</b>'; |
| 554 | 566 | echo '<select class="control-select ', implode( ' ', $classes ) , '" name="', $name, '" ', ( $multiple ? 'multiple' : '' ), ' ' , $atts, '>'; |
| 555 | 567 | foreach ( $options as $key => $label ) { |
| 556 | - $extra = $multiple && is_array( $value ) ? ( in_array( $key, $value ) ? 'selected' : '' ) : selected( $key, $value, false ); | |
| 568 | + $extra = $multiple && is_array( $value ) ? ( in_array( $key, $value, true ) ? 'selected' : '' ) : selected( $key, $value, false ); | |
| 557 | 569 | echo '<option value="', $key, '"', $extra, '>'; |
| 558 | 570 | echo $label; |
| 559 | 571 | echo '</option>'; |
| 560 | 572 | } |
| @@ -735,9 +747,9 @@ | ||
| 735 | 747 | protected static function _renderCheckboxItem( $title, $name, $value, $default, $desc, $disabled = false ) { |
| 736 | 748 | echo '<div class="viz-section-item">'; |
| 737 | 749 | echo '<a class="more-info" href="javascript:;">[?]</a>'; |
| 738 | 750 | echo '<b>', $title, '</b>'; |
| 739 | - echo '<input type="checkbox" class="control-check" value="', $default, '" name="', $name, '" ', ( $value == $default ? 'checked' : '' ), ' ', ( $disabled ? 'disabled=disabled' : '' ), '>'; | |
| 751 | + echo '<input type="checkbox" class="control-check" value="', $default, '" name="', $name, '" ', ( $value === $default ? 'checked' : '' ), ' ', ( $disabled ? 'disabled=disabled' : '' ), '>'; | |
| 740 | 752 | echo '<p class="viz-section-description">', $desc, '</p>'; |
| 741 | 753 | echo '</div>'; |
| 742 | 754 | } |
| 743 | 755 | |