PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.0
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 +92 -30 3.0.93.4.0 View file →
@@ -91,8 +91,16 @@
91 91 */
92 92 protected $_supportsAnimation = true;
93 93
94 94 /**
95 + * Which library does this this chart implement?
96 + *
97 + * @access protected
98 + * @var string
99 + */
100 + protected $_library = null;
101 +
102 + /**
95 103 * Constructor.
96 104 *
97 105 * @since 1.0.0
98 106 *
@@ -123,8 +131,10 @@
123 131 '' => '',
124 132 '1' => esc_html__( 'Yes', 'visualizer' ),
125 133 '0' => esc_html__( 'No', 'visualizer' ),
126 134 );
135 +
136 + $this->hooks();
127 137 }
128 138
129 139 /**
130 140 * Renders chart title settings.
@@ -149,8 +159,31 @@
149 159 );
150 160 }
151 161
152 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 + /**
153 186 * Renders chart advanced settings group.
154 187 *
155 188 * @access protected
156 189 */
@@ -156,9 +189,9 @@
156 189 */
157 190 protected function _renderAdvancedSettings() {
158 191 self::_renderGroupStart( esc_html__( 'Frontend Actions', 'visualizer' ) );
159 192 self::_renderSectionStart();
160 - self::_renderSectionDescription( esc_html__( 'Configure frontend actions here.', 'visualizer' ) );
193 + self::_renderSectionDescription( esc_html__( 'Configure frontend actions that need to be shown.', 'visualizer' ) );
161 194 self::_renderSectionEnd();
162 195
163 196 $this->_renderActionSettings();
164 197 self::_renderGroupEnd();
@@ -163,28 +196,16 @@
163 196 $this->_renderActionSettings();
164 197 self::_renderGroupEnd();
165 198
166 199 self::_renderGroupStart( esc_html__( 'Manual Configuration', 'visualizer' ) );
167 - self::_renderSectionStart();
168 - self::_renderSectionDescription( __( 'Configure the graph by providing configuration variables right from the', 'visualizer' ) . ' <a href="https://developers.google.com/chart/interactive/docs/reference" target="_blank">Google Visualization</a> API.' );
169 -
170 - $example = '
171 -{
172 - "vAxis": {
173 - "ticks": [5, 10, 15, 20],
174 - "titleTextStyle": {
175 - "color": "red"
176 - },
177 - "textPosition": "in"
178 - }
179 -}';
180 -
200 + $this->_renderManualConfigDescription();
181 201 self::_renderTextAreaItem(
182 202 esc_html__( 'Configuration', 'visualizer' ),
183 203 'manual',
184 204 $this->manual,
185 205 sprintf(
186 - esc_html__( 'One per line in valid JSON (key:value) format e.g. %s', 'visualizer' ), '<br><code>' . $example . '</code>'
206 + esc_html__( 'One per line in valid JSON (key:value) format e.g. %s', 'visualizer' ),
207 + '<br><code>' . $this->_renderManualConfigExample() . '</code>'
187 208 ),
188 209 '',
189 210 array( 'rows' => 5 )
190 211 );
@@ -205,27 +226,27 @@
205 226 self::_renderSectionStart( esc_html__( 'Actions', 'visualizer' ), false );
206 227 self::_renderCheckboxItem(
207 228 esc_html__( 'Print', 'visualizer' ),
208 229 'actions[]',
209 - isset( $this->actions ) && in_array( 'print', $this->actions ) ? true : false,
230 + isset( $this->actions ) && in_array( 'print', $this->actions, true ) ? true : false,
210 231 'print',
211 - $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' ),
232 + $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' ),
212 233 $disable_actions
213 234 );
214 235 self::_renderCheckboxItem(
215 236 esc_html__( 'CSV', 'visualizer' ),
216 237 'actions[]',
217 - isset( $this->actions ) && in_array( 'csv;application/csv', $this->actions ) ? true : false,
238 + isset( $this->actions ) && in_array( 'csv;application/csv', $this->actions, true ) ? true : false,
218 239 'csv;application/csv',
219 240 $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' ),
220 241 $disable_actions
221 242 );
222 243
223 - $disabled = ! ( class_exists( 'PHPExcel' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && version_compare( PHP_VERSION, '5.2.0', '>' ) );
244 + $disabled = ! self::is_excel_enabled();
224 245 self::_renderCheckboxItem(
225 246 esc_html__( 'Excel', 'visualizer' ),
226 247 'actions[]',
227 - isset( $this->actions ) && in_array( 'xls;application/vnd.ms-excel', $this->actions ) ? true : false,
248 + isset( $this->actions ) && in_array( 'xls;application/vnd.ms-excel', $this->actions, true ) ? true : false,
228 249 'xls;application/vnd.ms-excel',
229 250 $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' ) ),
230 251 $disable_actions || $disabled
231 252 );
@@ -231,9 +252,9 @@
231 252 );
232 253 self::_renderCheckboxItem(
233 254 esc_html__( 'Copy', 'visualizer' ),
234 255 'actions[]',
235 - isset( $this->actions ) && in_array( 'copy', $this->actions ) ? true : false,
256 + isset( $this->actions ) && in_array( 'copy', $this->actions, true ) ? true : false,
236 257 'copy',
237 258 $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' ),
238 259 $disable_actions
239 260 );
@@ -240,8 +261,25 @@
240 261 self::_renderSectionEnd();
241 262 }
242 263
243 264 /**
265 + * Checks if the Excel module can be enabled.
266 + */
267 + private static function is_excel_enabled() {
268 + $vendor_file = VISUALIZER_ABSPATH . '/vendor/autoload.php';
269 + if ( is_readable( $vendor_file ) ) {
270 + include_once( $vendor_file );
271 + }
272 +
273 + if ( version_compare( phpversion(), '5.6.0', '<' ) ) {
274 + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'PHP version %s not supported', phpversion() ), 'error', __FILE__, __LINE__ );
275 + return false;
276 + }
277 +
278 + return class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && extension_loaded( 'fileinfo' );
279 + }
280 +
281 + /**
244 282 * Renders chart general settings group.
245 283 *
246 284 * @since 1.0.0
247 285 *
@@ -321,8 +359,10 @@
321 359 self::_renderSectionEnd();
322 360
323 361 $this->_renderAnimationSettings();
324 362
363 + do_action( 'visualizer_chart_settings', get_class( $this ), $this->_data, 'general', array( 'generic' => true ) );
364 +
325 365 self::_renderGroupEnd();
326 366 }
327 367
328 368 /**
@@ -339,9 +379,9 @@
339 379
340 380 self::_renderCheckboxItem(
341 381 esc_html__( 'Animate on startup', 'visualizer' ),
342 382 'animation[startup]',
343 - $this->animation['startup'],
383 + isset( $this->animation['startup'] ) ? $this->animation['startup'] : 0,
344 384 true,
345 385 esc_html__( 'Determines if the chart will animate on the initial draw.', 'visualizer' )
346 386 );
347 387
@@ -408,10 +448,10 @@
408 448 *
409 449 * @access protected
410 450 */
411 451 protected function _renderViewSettings() {
412 - self::_renderGroupStart( esc_html__( 'Layout & Chart Area', 'visualizer' ) );
413 - self::_renderSectionStart( esc_html__( 'Layout', 'visualizer' ), false );
452 + self::_renderGroupStart( esc_html__( 'Chart Size & Placement', 'visualizer' ) );
453 + self::_renderSectionStart( esc_html__( 'Chart Size/Layout', 'visualizer' ), false );
414 454 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' ) );
415 455
416 456 echo '<div class="viz-section-item">';
417 457 echo '<a class="more-info" href="javascript:;">[?]</a>';
@@ -428,9 +468,9 @@
428 468 echo '</tr>';
429 469 echo '</table>';
430 470
431 471 echo '<p class="viz-section-description">';
432 - esc_html_e( 'Determines the total width and height of the chart.', 'visualizer' );
472 + esc_html_e( 'Determines the total width and height of the chart. This will only show in the front-end.', 'visualizer' );
433 473 echo '</p>';
434 474 echo '</div>';
435 475
436 476 echo '<div class="viz-section-delimiter"></div>';
@@ -467,9 +507,9 @@
467 507 echo '</label>';
468 508 echo '</div>';
469 509 self::_renderSectionEnd();
470 510
471 - self::_renderSectionStart( esc_html__( 'Chart Area', 'visualizer' ), false );
511 + self::_renderSectionStart( esc_html__( 'Placement', 'visualizer' ), false );
472 512 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' ) );
473 513
474 514 echo '<div class="viz-section-item">';
475 515 echo '<a class="more-info" href="javascript:;">[?]</a>';
@@ -541,8 +581,9 @@
541 581 echo '<a class="more-info" href="javascript:;">[?]</a>';
542 582 echo '<b>', $title, '</b>';
543 583 echo '<select class="control-select ', implode( ' ', $classes ) , '" name="', $name, '" ', ( $multiple ? 'multiple' : '' ), ' ' , $atts, '>';
544 584 foreach ( $options as $key => $label ) {
585 + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
545 586 $extra = $multiple && is_array( $value ) ? ( in_array( $key, $value ) ? 'selected' : '' ) : selected( $key, $value, false );
546 587 echo '<option value="', $key, '"', $extra, '>';
547 588 echo $label;
548 589 echo '</option>';
@@ -567,9 +608,9 @@
567 608 protected static function _renderColorPickerItem( $title, $name, $value, $default ) {
568 609 echo '<div class="viz-section-item">';
569 610 echo '<b>', $title, '</b>';
570 611 echo '<div>';
571 - 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, '">';
612 + 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, '">';
572 613 echo '</div>';
573 614 echo '</div>';
574 615 }
575 616
@@ -678,11 +719,11 @@
678 719 * @static
679 720 * @access public
680 721 * @param string $description The description text.
681 722 */
682 - public static function _renderSectionDescription( $description ) {
723 + public static function _renderSectionDescription( $description, $classes = '' ) {
683 724 echo '<div class="viz-section-item">';
684 - echo '<div class="viz-section-description">', $description, '</div>';
725 + echo '<div class="viz-section-description ' . $classes . '">', $description, '</div>';
685 726 echo '</div>';
686 727 }
687 728
688 729 /**
@@ -724,8 +765,9 @@
724 765 protected static function _renderCheckboxItem( $title, $name, $value, $default, $desc, $disabled = false ) {
725 766 echo '<div class="viz-section-item">';
726 767 echo '<a class="more-info" href="javascript:;">[?]</a>';
727 768 echo '<b>', $title, '</b>';
769 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
728 770 echo '<input type="checkbox" class="control-check" value="', $default, '" name="', $name, '" ', ( $value == $default ? 'checked' : '' ), ' ', ( $disabled ? 'disabled=disabled' : '' ), '>';
729 771 echo '<p class="viz-section-description">', $desc, '</p>';
730 772 echo '</div>';
731 773 }
@@ -747,5 +789,25 @@
747 789 echo '<p class="viz-section-description">', $desc, '</p>';
748 790 echo '</div>';
749 791 }
750 792
793 + /**
794 + * Returns the library this chart implements.
795 + */
796 + public function getLibrary() {
797 + return $this->_library;
798 + }
799 +
800 + /**
801 + * Loads generic libraries conditionally.
802 + */
803 + protected function load_dependent_assets( $libs ) {
804 + if ( in_array( 'moment', $libs, true ) && ! wp_script_is( 'moment', 'registered' ) ) {
805 + wp_register_script( 'moment', VISUALIZER_ABSURL . 'js/lib/moment.min.js', array(), Visualizer_Plugin::VERSION );
806 + }
807 +
808 + if ( in_array( 'numeral', $libs, true ) && ! wp_script_is( 'numeral', 'registered' ) ) {
809 + wp_register_script( 'numeral', VISUALIZER_ABSURL . 'js/lib/numeral.min.js', array(), Visualizer_Plugin::VERSION );
810 + }
811 +
812 + }
751 813 }