PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 2.2.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v2.2.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/Frontend.php +22 -69 3.1.12.2.0 View file →
@@ -53,10 +53,8 @@
53 53 public function __construct( Visualizer_Plugin $plugin ) {
54 54 parent::__construct( $plugin );
55 55
56 56 $this->_addAction( 'wp_enqueue_scripts', 'enqueueScripts' );
57 - $this->_addAction( 'visualizer_enqueue_scripts', 'enqueueScripts' );
58 - $this->_addFilter( 'visualizer_get_language', 'getLanguage' );
59 57 $this->_addShortcode( 'visualizer', 'renderChart' );
60 58
61 59 // add do_shortocde hook for widget_text filter
62 60 if ( ! has_filter( 'widget_text', 'do_shortcode' ) ) {
@@ -71,16 +69,8 @@
71 69 add_action( 'rest_api_init', array( $this, 'endpoint_register' ) );
72 70 }
73 71
74 72 /**
75 - * Returns the language/locale.
76 - */
77 - function getLanguage( $dummy, $only_language ) {
78 - return $this->get_language();
79 - }
80 -
81 -
82 - /**
83 73 * Registers the endpoints
84 74 */
85 75 function endpoint_register() {
86 76 register_rest_route(
@@ -86,9 +76,9 @@
86 76 register_rest_route(
87 77 'visualizer/v' . VISUALIZER_REST_VERSION,
88 78 '/action/(?P<chart>\d+)/(?P<type>.+)/',
89 79 array(
90 - 'methods' => array( 'GET', 'POST' ),
80 + 'methods' => 'GET',
91 81 'callback' => array( $this, 'perform_action' ),
92 82 )
93 83 );
94 84 }
@@ -99,10 +89,9 @@
99 89 * @access private
100 90 */
101 91 private function get_actions() {
102 92 return apply_filters(
103 - 'visualizer_action_buttons',
104 - array(
93 + 'visualizer_action_buttons', array(
105 94 'print' => __( 'Print', 'visualizer' ),
106 95 'csv' => __( 'CSV', 'visualizer' ),
107 96 'xls' => __( 'Excel', 'visualizer' ),
108 97 'copy' => __( 'Copy', 'visualizer' ),
@@ -140,9 +129,9 @@
140 129 case 'xls':
141 130 $data = $this->_getDataAs( $chart_id, 'xls' );
142 131 break;
143 132 default:
144 - $data = apply_filters( 'visualizer_action_data', $data, $chart_id, $type, $params, $this );
133 + $data = apply_filters( 'visualizer_action_data', $data, $chart_id, $type );
145 134 break;
146 135 }
147 136
148 137 return new WP_REST_Response( array( 'data' => $data ) );
@@ -156,12 +145,13 @@
156 145 *
157 146 * @access public
158 147 */
159 148 public function enqueueScripts() {
160 - wp_register_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
149 + wp_register_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
150 + wp_register_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true );
151 + wp_register_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'visualizer-google-jsapi-old', 'jquery' ), Visualizer_Plugin::VERSION, true );
161 152 wp_register_script( 'visualizer-clipboardjs', VISUALIZER_ABSURL . 'js/lib/clipboardjs/clipboard.min.js', array( 'jquery' ), Visualizer_Plugin::VERSION, true );
162 - wp_register_style( 'visualizer-front', VISUALIZER_ABSURL . 'css/front.css', array(), Visualizer_Plugin::VERSION );
163 - do_action( 'visualizer_pro_frontend_load_resources' );
153 + wp_enqueue_script( 'visualizer-clipboardjs' );
164 154 }
165 155
166 156 /**
167 157 * Returns placeholder for chart according to visualizer shortcode attributes.
@@ -176,18 +166,16 @@
176 166 * @access public
177 167 * @param array $atts The array of shortcode attributes.
178 168 */
179 169 public function renderChart( $atts ) {
180 - global $wp_version;
181 170 $atts = shortcode_atts(
182 171 array(
183 172 'id' => false, // chart id
184 - 'class' => false, // chart class
185 - 'series' => false, // series filter hook
186 - 'data' => false, // data filter hook
187 - 'settings' => false, // data filter hook
188 - ),
189 - $atts
173 + 'class' => false, // chart class
174 + 'series' => false, // series filter hook
175 + 'data' => false, // data filter hook
176 + 'settings' => false, // data filter hook
177 + ), $atts
190 178 );
191 179
192 180 // if empty id or chart does not exists, then return empty string
193 181 if ( ! $atts['id'] || ! ( $chart = get_post( $atts['id'] ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
@@ -193,17 +181,8 @@
193 181 if ( ! $atts['id'] || ! ( $chart = get_post( $atts['id'] ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
194 182 return '';
195 183 }
196 184
197 - if ( ! apply_filters( 'visualizer_pro_show_chart', true, $atts['id'] ) ) {
198 - return '';
199 - }
200 -
201 - // in case revisions exist.
202 - if ( true === ( $revisions = $this->undoRevisions( $chart->ID, true ) ) ) {
203 - $chart = get_post( $chart->ID );
204 - }
205 -
206 185 $id = 'visualizer-' . $atts['id'];
207 186 $defaultClass = 'visualizer-front';
208 187 $class = apply_filters( Visualizer_Plugin::FILTER_CHART_WRAPPER_CLASS, $atts['class'], $atts['id'] );
209 188 $class = $defaultClass . ' ' . $class . ' ' . 'visualizer-front-' . $atts['id'];
@@ -210,11 +189,9 @@
210 189 $class = ! empty( $class ) ? ' class="' . trim( $class ) . '"' : '';
211 190
212 191 $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
213 192
214 - $chart = apply_filters( 'visualizer_schedule_refresh_chart', $chart, $chart->ID, false );
215 -
216 - // fetch and update settings
193 + // faetch and update settings
217 194 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
218 195 if ( empty( $settings['height'] ) ) {
219 196 $settings['height'] = '400';
220 197 }
@@ -230,22 +207,15 @@
230 207 $settings = apply_filters( $atts['settings'], $settings, $chart->ID, $type );
231 208 }
232 209
233 210 // handle data filter hooks
234 - $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $chart->ID, $type );
211 + $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( $chart->post_content ), $chart->ID, $type );
235 212 if ( ! empty( $atts['data'] ) ) {
236 213 $data = apply_filters( $atts['data'], $data, $chart->ID, $type );
237 214 }
238 215
239 - $css = '';
240 - $arguments = $this->get_inline_custom_css( $id, $settings );
241 - if ( ! empty( $arguments ) ) {
242 - $css = $arguments[0];
243 - $settings = $arguments[1];
244 - }
216 + $id = $id . '-' . rand();
245 217
246 - $library = $this->load_chart_type( $chart->ID );
247 -
248 218 // add chart to the array
249 219 $this->_charts[ $id ] = array(
250 220 'type' => $type,
251 221 'series' => $series,
@@ -250,42 +220,28 @@
250 220 'type' => $type,
251 221 'series' => $series,
252 222 'settings' => $settings,
253 223 'data' => $data,
254 - 'library' => $library,
255 224 );
256 225
257 - wp_register_script(
258 - "visualizer-render-$library",
259 - VISUALIZER_ABSURL . 'js/render-facade.js',
260 - apply_filters( 'visualizer_assets_render', array( 'jquery', 'visualizer-customization' ), true ),
261 - Visualizer_Plugin::VERSION,
262 - true
263 - );
264 -
265 - wp_enqueue_script( "visualizer-render-$library" );
226 + // enqueue visualizer render and update render localizations
227 + wp_enqueue_script( 'visualizer-render' );
266 228 wp_localize_script(
267 - "visualizer-render-$library",
268 - 'visualizer',
269 - array(
229 + 'visualizer-render', 'visualizer', array(
270 230 'charts' => $this->_charts,
271 - 'language' => $this->get_language(),
272 231 'map_api_key' => get_option( 'visualizer-map-api-key' ),
273 - 'rest_url' => version_compare( $wp_version, '4.7.0', '>=' ) ? rest_url( 'visualizer/v' . VISUALIZER_REST_VERSION . '/action/#id#/#type#/' ) : '',
232 + 'rest_url' => rest_url( 'visualizer/v' . VISUALIZER_REST_VERSION . '/action/#id#/#type#/' ),
274 233 'i10n' => array(
275 234 'copied' => __( 'Copied!', 'visualizer' ),
276 235 ),
277 - 'page_type' => 'frontend',
278 236 )
279 237 );
280 - wp_enqueue_style( 'visualizer-front' );
281 238
282 239 $actions_div = '';
283 - $actions_visible = apply_filters( 'visualizer_pro_add_actions', isset( $settings['actions'] ) ? $settings['actions'] : array(), $atts['id'] );
284 - if ( ! empty( $actions_visible ) ) {
240 + if ( ! empty( $settings['actions'] ) ) {
285 241 $actions = $this->get_actions();
286 242 $actions_div = '<div class="visualizer-actions">';
287 - foreach ( $actions_visible as $action_type ) {
243 + foreach ( $settings['actions'] as $action_type ) {
288 244 $key = $action_type;
289 245 $mime = '';
290 246 if ( strpos( $action_type, ';' ) !== false ) {
291 247 $array = explode( ';', $action_type );
@@ -297,9 +253,8 @@
297 253
298 254 if ( 'copy' === $key ) {
299 255 $copy = $this->_getDataAs( $atts['id'], 'csv' );
300 256 $actions_div .= ' data-clipboard-text="' . esc_attr( $copy['csv'] ) . '"';
301 - wp_enqueue_script( 'visualizer-clipboardjs' );
302 257 }
303 258
304 259 $actions_div .= apply_filters( 'visualizer_action_attributes', '', $key, $atts['id'] );
305 260 $actions_div .= '>' . $label . '</a> &nbsp;';
@@ -306,11 +261,9 @@
306 261 }
307 262
308 263 $actions_div .= '</div>';
309 264 }
310 -
311 - $actions_div .= $css;
312 -
313 265 // return placeholder div
314 266 return $actions_div . '<div id="' . $id . '"' . $class . '></div>';
315 267 }
268 +
316 269 }