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/Source.php +80 -1 3.3.43.4.0 View file →
@@ -214,9 +214,10 @@
214 214 case 'number':
215 215 $data[ $i ] = ( is_numeric( $data[ $i ] ) ) ? floatval( $data[ $i ] ) : ( is_numeric( str_replace( ',', '', $data[ $i ] ) ) ? floatval( str_replace( ',', '', $data[ $i ] ) ) : null );
216 216 break;
217 217 case 'boolean':
218 - $data[ $i ] = ! empty( $data[ $i ] ) ? filter_var( $data[ $i ], FILTER_VALIDATE_BOOLEAN ) : null;
218 + $datum = trim( strval( $data[ $i ] ) );
219 + $data[ $i ] = in_array( $datum, array( 'true', 'yes', '1' ), true ) ? 'true' : 'false';
219 220 break;
220 221 case 'timeofday':
221 222 $date = new DateTime( '1984-03-16T' . $data[ $i ] );
222 223 if ( $date ) {
@@ -383,8 +384,86 @@
383 384 * @return string
384 385 */
385 386 public function get_error() {
386 387 return $this->_error;
388 + }
389 +
390 + /**
391 + * Fetches information from the editable table and parses it to build series and data arrays.
392 + *
393 + * @since ?
394 + *
395 + * @access public
396 + * @return boolean TRUE on success, otherwise FALSE.
397 + */
398 + public function fetchFromEditableTable() {
399 + if ( empty( $this->_args ) ) {
400 + return false;
401 + }
402 +
403 + $this->_fetchSeriesFromEditableTable();
404 + $this->_fetchDataFromEditableTable();
405 + return true;
406 + }
407 +
408 + /**
409 + * Fetches series information from the editable table. This is fetched only through the UI and not while refreshing the chart data.
410 + *
411 + * @since 1.0.0
412 + *
413 + * @access private
414 + */
415 + private function _fetchSeriesFromEditableTable() {
416 + $params = $this->_args;
417 + $headers = array_filter( $params['header'] );
418 + $types = array_filter( $params['type'] );
419 + $header_row = $type_row = array();
420 + if ( $headers ) {
421 + foreach ( $headers as $header ) {
422 + if ( ! empty( $types[ $header ] ) ) {
423 + $this->_series[] = array(
424 + 'label' => $header,
425 + 'type' => $types[ $header ],
426 + );
427 + }
428 + }
429 + }
430 +
431 + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Series found for %s = %s', print_r( $this->_args, true ), print_r( $this->_series, true ) ), 'debug', __FILE__, __LINE__ );
432 +
433 + return true;
434 + }
435 +
436 +
437 + /**
438 + * Fetches data information from the editable table.
439 + *
440 + * @since 1.0.0
441 + *
442 + * @access private
443 + */
444 + private function _fetchDataFromEditableTable() {
445 + $params = $this->_args;
446 + $headers = wp_list_pluck( $this->_series, 'label' );
447 + $this->fetch();
448 +
449 + $data = $this->_data;
450 + $this->_data = array();
451 +
452 + foreach ( $data as $line ) {
453 + $data_row = array();
454 + foreach ( $line as $header => $value ) {
455 + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
456 + if ( in_array( $header, $headers ) ) {
457 + $data_row[] = $value;
458 + }
459 + }
460 + $this->_data[] = $this->_normalizeData( $data_row );
461 + }
462 +
463 + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Data found for %s = %s', print_r( $this->_args, true ), print_r( $this->_data, true ) ), 'debug', __FILE__, __LINE__ );
464 +
465 + return true;
387 466 }
388 467
389 468
390 469 }