PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.3
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/Render/Sidebar.php +79 -33 3.1.23.4.3 View file →
@@ -159,8 +159,31 @@
159 159 );
160 160 }
161 161
162 162 /**
163 + * Add the correct description for the manual configuration box.
164 + */
165 + protected function _renderManualConfigDescription() {
166 + self::_renderSectionStart();
167 + 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>' );
168 + }
169 +
170 + /**
171 + * Add the correct example for the manual configuration box.
172 + */
173 + protected function _renderManualConfigExample() {
174 + return '{
175 + "vAxis": {
176 + "ticks": [5, 10, 15, 20],
177 + "titleTextStyle": {
178 + "color": "red"
179 + },
180 + "textPosition": "in"
181 + }
182 + }';
183 + }
184 +
185 + /**
163 186 * Renders chart advanced settings group.
164 187 *
165 188 * @access protected
166 189 */
@@ -166,9 +189,9 @@
166 189 */
167 190 protected function _renderAdvancedSettings() {
168 191 self::_renderGroupStart( esc_html__( 'Frontend Actions', 'visualizer' ) );
169 192 self::_renderSectionStart();
170 - self::_renderSectionDescription( esc_html__( 'Configure frontend actions here.', 'visualizer' ) );
193 + self::_renderSectionDescription( esc_html__( 'Configure frontend actions that need to be shown.', 'visualizer' ) );
171 194 self::_renderSectionEnd();
172 195
173 196 $this->_renderActionSettings();
174 197 self::_renderGroupEnd();
@@ -173,22 +196,9 @@
173 196 $this->_renderActionSettings();
174 197 self::_renderGroupEnd();
175 198
176 199 self::_renderGroupStart( esc_html__( 'Manual Configuration', 'visualizer' ) );
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>' );
179 -
180 - $example = '
181 -{
182 - "vAxis": {
183 - "ticks": [5, 10, 15, 20],
184 - "titleTextStyle": {
185 - "color": "red"
186 - },
187 - "textPosition": "in"
188 - }
189 -}';
190 -
200 + $this->_renderManualConfigDescription();
191 201 self::_renderTextAreaItem(
192 202 esc_html__( 'Configuration', 'visualizer' ),
193 203 'manual',
194 204 $this->manual,
@@ -193,9 +203,9 @@
193 203 'manual',
194 204 $this->manual,
195 205 sprintf(
196 206 esc_html__( 'One per line in valid JSON (key:value) format e.g. %s', 'visualizer' ),
197 - '<br><code>' . $example . '</code>'
207 + '<br><code>' . $this->_renderManualConfigExample() . '</code>'
198 208 ),
199 209 '',
200 210 array( 'rows' => 5 )
201 211 );
@@ -212,31 +222,33 @@
212 222 */
213 223 protected function _renderActionSettings() {
214 224 global $wp_version;
215 225 $disable_actions = version_compare( $wp_version, '4.7.0', '<' );
216 - self::_renderSectionStart( esc_html__( 'Actions', 'visualizer' ), false );
226 + // default open this section when not testing through cypress because cypress expects to click and open each section
227 + // and may not like finding a section is already open.
228 + self::_renderSectionStart( esc_html__( 'Actions', 'visualizer' ), ! defined( 'TI_CYPRESS_TESTING' ) );
217 229 self::_renderCheckboxItem(
218 230 esc_html__( 'Print', 'visualizer' ),
219 231 'actions[]',
220 - isset( $this->actions ) && in_array( 'print', $this->actions ) ? true : false,
232 + isset( $this->actions ) && in_array( 'print', $this->actions, true ) ? true : false,
221 233 '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' ),
234 + $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 235 $disable_actions
224 236 );
225 237 self::_renderCheckboxItem(
226 238 esc_html__( 'CSV', 'visualizer' ),
227 239 'actions[]',
228 - isset( $this->actions ) && in_array( 'csv;application/csv', $this->actions ) ? true : false,
240 + isset( $this->actions ) && in_array( 'csv;application/csv', $this->actions, true ) ? true : false,
229 241 'csv;application/csv',
230 242 $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 243 $disable_actions
232 244 );
233 245
234 - $disabled = ! ( class_exists( 'PHPExcel' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && version_compare( PHP_VERSION, '5.2.0', '>' ) );
246 + $disabled = ! self::is_excel_enabled();
235 247 self::_renderCheckboxItem(
236 248 esc_html__( 'Excel', 'visualizer' ),
237 249 'actions[]',
238 - isset( $this->actions ) && in_array( 'xls;application/vnd.ms-excel', $this->actions ) ? true : false,
250 + isset( $this->actions ) && in_array( 'xls;application/vnd.ms-excel', $this->actions, true ) ? true : false,
239 251 'xls;application/vnd.ms-excel',
240 252 $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 253 $disable_actions || $disabled
242 254 );
@@ -242,9 +254,9 @@
242 254 );
243 255 self::_renderCheckboxItem(
244 256 esc_html__( 'Copy', 'visualizer' ),
245 257 'actions[]',
246 - isset( $this->actions ) && in_array( 'copy', $this->actions ) ? true : false,
258 + isset( $this->actions ) && in_array( 'copy', $this->actions, true ) ? true : false,
247 259 'copy',
248 260 $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 261 $disable_actions
250 262 );
@@ -251,8 +263,25 @@
251 263 self::_renderSectionEnd();
252 264 }
253 265
254 266 /**
267 + * Checks if the Excel module can be enabled.
268 + */
269 + private static function is_excel_enabled() {
270 + $vendor_file = VISUALIZER_ABSPATH . '/vendor/autoload.php';
271 + if ( is_readable( $vendor_file ) ) {
272 + include_once( $vendor_file );
273 + }
274 +
275 + if ( version_compare( phpversion(), '5.6.0', '<' ) ) {
276 + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'PHP version %s not supported', phpversion() ), 'error', __FILE__, __LINE__ );
277 + return false;
278 + }
279 +
280 + return class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && extension_loaded( 'fileinfo' );
281 + }
282 +
283 + /**
255 284 * Renders chart general settings group.
256 285 *
257 286 * @since 1.0.0
258 287 *
@@ -332,8 +361,10 @@
332 361 self::_renderSectionEnd();
333 362
334 363 $this->_renderAnimationSettings();
335 364
365 + do_action( 'visualizer_chart_settings', get_class( $this ), $this->_data, 'general', array( 'generic' => true ) );
366 +
336 367 self::_renderGroupEnd();
337 368 }
338 369
339 370 /**
@@ -350,9 +381,9 @@
350 381
351 382 self::_renderCheckboxItem(
352 383 esc_html__( 'Animate on startup', 'visualizer' ),
353 384 'animation[startup]',
354 - $this->animation['startup'],
385 + isset( $this->animation['startup'] ) ? $this->animation['startup'] : 0,
355 386 true,
356 387 esc_html__( 'Determines if the chart will animate on the initial draw.', 'visualizer' )
357 388 );
358 389
@@ -419,10 +450,10 @@
419 450 *
420 451 * @access protected
421 452 */
422 453 protected function _renderViewSettings() {
423 - self::_renderGroupStart( esc_html__( 'Layout & Chart Area', 'visualizer' ) );
424 - self::_renderSectionStart( esc_html__( 'Layout', 'visualizer' ), false );
454 + self::_renderGroupStart( esc_html__( 'Chart Size & Placement', 'visualizer' ) );
455 + self::_renderSectionStart( esc_html__( 'Chart Size/Layout', 'visualizer' ), false );
425 456 self::_renderSectionDescription( esc_html__( 'Configure the total size of the chart. Two formats are supported: a number, or a number followed by %. A simple number is a value in pixels; a number followed by % is a percentage.', 'visualizer' ) );
426 457
427 458 echo '<div class="viz-section-item">';
428 459 echo '<a class="more-info" href="javascript:;">[?]</a>';
@@ -439,9 +470,9 @@
439 470 echo '</tr>';
440 471 echo '</table>';
441 472
442 473 echo '<p class="viz-section-description">';
443 - esc_html_e( 'Determines the total width and height of the chart.', 'visualizer' );
474 + esc_html_e( 'Determines the total width and height of the chart. This will only show in the front-end.', 'visualizer' );
444 475 echo '</p>';
445 476 echo '</div>';
446 477
447 478 echo '<div class="viz-section-delimiter"></div>';
@@ -478,9 +509,9 @@
478 509 echo '</label>';
479 510 echo '</div>';
480 511 self::_renderSectionEnd();
481 512
482 - self::_renderSectionStart( esc_html__( 'Chart Area', 'visualizer' ), false );
513 + self::_renderSectionStart( esc_html__( 'Placement', 'visualizer' ), false );
483 514 self::_renderSectionDescription( esc_html__( 'Configure the placement and size of the chart area (where the chart itself is drawn, excluding axis and legends). Two formats are supported: a number, or a number followed by %. A simple number is a value in pixels; a number followed by % is a percentage.', 'visualizer' ) );
484 515
485 516 echo '<div class="viz-section-item">';
486 517 echo '<a class="more-info" href="javascript:;">[?]</a>';
@@ -552,8 +583,9 @@
552 583 echo '<a class="more-info" href="javascript:;">[?]</a>';
553 584 echo '<b>', $title, '</b>';
554 585 echo '<select class="control-select ', implode( ' ', $classes ) , '" name="', $name, '" ', ( $multiple ? 'multiple' : '' ), ' ' , $atts, '>';
555 586 foreach ( $options as $key => $label ) {
587 + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
556 588 $extra = $multiple && is_array( $value ) ? ( in_array( $key, $value ) ? 'selected' : '' ) : selected( $key, $value, false );
557 589 echo '<option value="', $key, '"', $extra, '>';
558 590 echo $label;
559 591 echo '</option>';
@@ -578,9 +610,9 @@
578 610 protected static function _renderColorPickerItem( $title, $name, $value, $default ) {
579 611 echo '<div class="viz-section-item">';
580 612 echo '<b>', $title, '</b>';
581 613 echo '<div>';
582 - echo '<input type="text" class="color-picker-hex" name="', $name, '" maxlength="7" placeholder="', esc_attr__( 'Hex Value', 'visualizer' ), '" value="', is_null( $value ) ? $default : esc_attr( $value ), '" data-default-color="', $default, '">';
614 + echo '<input type="text" class="color-picker-hex color-picker" data-alpha="true" name="', $name, '" maxlength="7" placeholder="', esc_attr__( 'Hex Value', 'visualizer' ), '" value="', is_null( $value ) ? $default : esc_attr( $value ), '" data-default-color="', $default, '">';
583 615 echo '</div>';
584 616 echo '</div>';
585 617 }
586 618
@@ -624,10 +656,10 @@
624 656 * @param string $title The title of this group.
625 657 * @param string $html Any additional HTML.
626 658 * @param string $class Any additional classes.
627 659 */
628 - public static function _renderGroupStart( $title, $html = '', $class = '' ) {
629 - echo '<li class="viz-group ' . $class . '">';
660 + public static function _renderGroupStart( $title, $html = '', $class = '', $id = '' ) {
661 + echo '<li id="' . $id . '" class="viz-group ' . $class . '">';
630 662 echo '<h3 class="viz-group-title">', $title, '</h3>';
631 663 echo $html;
632 664 echo '<ul class="viz-group-content">';
633 665 }
@@ -689,11 +721,11 @@
689 721 * @static
690 722 * @access public
691 723 * @param string $description The description text.
692 724 */
693 - public static function _renderSectionDescription( $description ) {
725 + public static function _renderSectionDescription( $description, $classes = '' ) {
694 726 echo '<div class="viz-section-item">';
695 - echo '<div class="viz-section-description">', $description, '</div>';
727 + echo '<div class="viz-section-description ' . $classes . '">', $description, '</div>';
696 728 echo '</div>';
697 729 }
698 730
699 731 /**
@@ -735,8 +767,9 @@
735 767 protected static function _renderCheckboxItem( $title, $name, $value, $default, $desc, $disabled = false ) {
736 768 echo '<div class="viz-section-item">';
737 769 echo '<a class="more-info" href="javascript:;">[?]</a>';
738 770 echo '<b>', $title, '</b>';
771 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
739 772 echo '<input type="checkbox" class="control-check" value="', $default, '" name="', $name, '" ', ( $value == $default ? 'checked' : '' ), ' ', ( $disabled ? 'disabled=disabled' : '' ), '>';
740 773 echo '<p class="viz-section-description">', $desc, '</p>';
741 774 echo '</div>';
742 775 }
@@ -765,5 +798,18 @@
765 798 public function getLibrary() {
766 799 return $this->_library;
767 800 }
768 801
802 + /**
803 + * Loads generic libraries conditionally.
804 + */
805 + protected function load_dependent_assets( $libs ) {
806 + if ( in_array( 'moment', $libs, true ) && ! wp_script_is( 'moment', 'registered' ) ) {
807 + wp_register_script( 'moment', VISUALIZER_ABSURL . 'js/lib/moment.min.js', array(), Visualizer_Plugin::VERSION );
808 + }
809 +
810 + if ( in_array( 'numeral', $libs, true ) && ! wp_script_is( 'numeral', 'registered' ) ) {
811 + wp_register_script( 'numeral', VISUALIZER_ABSURL . 'js/lib/numeral.min.js', array(), Visualizer_Plugin::VERSION );
812 + }
813 +
814 + }
769 815 }