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/Module.php +60 -2 3.3.43.4.0 View file →
@@ -66,12 +66,27 @@
66 66
67 67 $this->_addFilter( Visualizer_Plugin::FILTER_UNDO_REVISIONS, 'undoRevisions', 10, 2 );
68 68 $this->_addFilter( Visualizer_Plugin::FILTER_HANDLE_REVISIONS, 'handleExistingRevisions', 10, 2 );
69 69 $this->_addFilter( Visualizer_Plugin::FILTER_GET_CHART_DATA_AS, 'getDataAs', 10, 3 );
70 + register_shutdown_function( array($this, 'onShutdown') );
70 71
71 72 }
72 73
73 74 /**
75 + * Register a shutdown hook to catch fatal errors.
76 + *
77 + * @since ?
78 + *
79 + * @access public
80 + */
81 + public function onShutdown() {
82 + $error = error_get_last();
83 + if ( $error['type'] === E_ERROR && false !== strpos( $error['file'], 'Visualizer/' ) ) {
84 + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Critical error %s', print_r( $error, true ) ), 'error', __FILE__, __LINE__ );
85 + }
86 + }
87 +
88 + /**
74 89 * Registers an action hook.
75 90 *
76 91 * @since 1.0.0
77 92 * @uses add_action() To register action hook.
@@ -221,10 +236,13 @@
221 236 $filename = $title;
222 237
223 238 switch ( $type ) {
224 239 case 'csv':
225 - $final = $this->_getCSV( $rows, $filename );
240 + $final = $this->_getCSV( $rows, $filename, false );
226 241 break;
242 + case 'csv-display':
243 + $final = $this->_getCSV( $rows, $filename, true );
244 + break;
227 245 case 'xls':
228 246 $final = $this->_getExcel( $rows, $filename );
229 247 break;
230 248 case 'print':
@@ -240,10 +258,11 @@
240 258 *
241 259 * @access private
242 260 * @param array $rows The array of data.
243 261 * @param string $filename The name of the file to use.
262 + * @param bool $enclose Enclose strings that have commas in them in double quotes.
244 263 */
245 - private function _getCSV( $rows, $filename ) {
264 + private function _getCSV( $rows, $filename, $enclose ) {
246 265 $filename .= '.csv';
247 266
248 267 $bom = chr( 0xEF ) . chr( 0xBB ) . chr( 0xBF );
249 268 $fp = tmpfile();
@@ -258,8 +277,20 @@
258 277 while ( ( $array = fgetcsv( $fp ) ) !== false ) {
259 278 if ( strlen( $csv ) > 0 ) {
260 279 $csv .= PHP_EOL;
261 280 }
281 + // if enclosure is required, check every item of this line
282 + // if a comma exists in the item, add enclosure.
283 + if ( $enclose ) {
284 + $temp_array = array();
285 + foreach ( $array as $item ) {
286 + if ( strpos( $item, ',' ) !== false ) {
287 + $item = VISUALIZER_CSV_ENCLOSURE . $item . VISUALIZER_CSV_ENCLOSURE;
288 + }
289 + $temp_array[] = $item;
290 + }
291 + $array = $temp_array;
292 + }
262 293 $csv .= implode( ',', $array );
263 294 }
264 295 fclose( $fp );
265 296
@@ -637,7 +668,34 @@
637 668 * @since 3.3.0
638 669 */
639 670 public static function is_pro_older_than( $version ) {
640 671 return version_compare( VISUALIZER_PRO_VERSION, $version, '<' );
672 + }
673 +
674 + /**
675 + * Should we show some specific feature on the basis of the version?
676 + *
677 + * @since 3.4.0
678 + */
679 + public static function can_show_feature( $feature ) {
680 + switch ( $feature ) {
681 + case 'simple-editor':
682 + // if user has pro but an older version, then don't load the simple editor functionality
683 + // as the select box will not behave as expected because the pro editor's functionality will supercede.
684 + return ! Visualizer_Module::is_pro() || ! Visualizer_Module::is_pro_older_than( '1.9.2' );
685 + }
686 + return false;
687 + }
688 +
689 + /**
690 + * Gets the features for the provided license type.
691 + */
692 + public static final function get_features_for_license( $plan ) {
693 + switch ( $plan ) {
694 + case 1:
695 + return array( 'import-wp', 'db-query' );
696 + case 2:
697 + return array( 'schedule-chart', 'chart-permissions' );
698 + }
641 699 }
642 700
643 701 }