PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 4.0.8
Visualizer – Tables & Charts Manager with Built-in AI Generator v4.0.8
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/Csv.php +19 -13 4.0.54.0.8 View file →
@@ -116,9 +116,9 @@
116 116 * @since 1.4.2
117 117 *
118 118 * @access protected
119 119 * @param string $filename Optional file name to get handle. If omitted, $_filename is used.
120 - * @return resource File handle resource on success, otherwise FALSE.
120 + * @return resource|false File handle resource on success, otherwise FALSE.
121 121 */
122 122 protected function _get_file_handle( $filename = false ) {
123 123 // open file and return handle
124 124 return fopen( $filename ? $filename : $this->_filename, 'rb' );
@@ -140,24 +140,30 @@
140 140 }
141 141
142 142 // read file and fill arrays
143 143 $handle = $this->_get_file_handle();
144 - if ( $handle ) {
145 - // fetch series
146 - if ( ! $this->_fetchSeries( $handle ) ) {
147 - return false;
144 + if ( ! $handle ) {
145 + if ( empty( $this->_error ) ) {
146 + $this->_error = esc_html__( 'The file could not be opened. Please try again.', 'visualizer' );
148 147 }
148 + return false;
149 + }
149 150
150 - // fetch data
151 + // fetch series
152 + if ( ! $this->_fetchSeries( $handle ) ) {
153 + fclose( $handle );
154 + return false;
155 + }
156 +
157 + // fetch data
158 + $data = fgetcsv( $handle, 0, VISUALIZER_CSV_DELIMITER, VISUALIZER_CSV_ENCLOSURE );
159 + while ( $data !== false ) {
160 + $this->_data[] = $this->_normalizeData( $data );
151 161 $data = fgetcsv( $handle, 0, VISUALIZER_CSV_DELIMITER, VISUALIZER_CSV_ENCLOSURE );
152 - while ( $data !== false ) {
153 - $this->_data[] = $this->_normalizeData( $data );
154 - $data = fgetcsv( $handle, 0, VISUALIZER_CSV_DELIMITER, VISUALIZER_CSV_ENCLOSURE );
155 - }
162 + }
156 163
157 - // close file handle
158 - fclose( $handle );
159 - }
164 + // close file handle
165 + fclose( $handle );
160 166
161 167 return true;
162 168 }
163 169