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 +12 -45 3.0.92.2.0 View file →
@@ -53,9 +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->_addFilter( 'visualizer_get_language', 'getLanguage' );
58 57 $this->_addShortcode( 'visualizer', 'renderChart' );
59 58
60 59 // add do_shortocde hook for widget_text filter
61 60 if ( ! has_filter( 'widget_text', 'do_shortcode' ) ) {
@@ -70,16 +69,8 @@
70 69 add_action( 'rest_api_init', array( $this, 'endpoint_register' ) );
71 70 }
72 71
73 72 /**
74 - * Returns the language/locale.
75 - */
76 - function getLanguage( $dummy, $only_language ) {
77 - return $this->get_language();
78 - }
79 -
80 -
81 - /**
82 73 * Registers the endpoints
83 74 */
84 75 function endpoint_register() {
85 76 register_rest_route(
@@ -85,9 +76,9 @@
85 76 register_rest_route(
86 77 'visualizer/v' . VISUALIZER_REST_VERSION,
87 78 '/action/(?P<chart>\d+)/(?P<type>.+)/',
88 79 array(
89 - 'methods' => array( 'GET', 'POST' ),
80 + 'methods' => 'GET',
90 81 'callback' => array( $this, 'perform_action' ),
91 82 )
92 83 );
93 84 }
@@ -138,9 +129,9 @@
138 129 case 'xls':
139 130 $data = $this->_getDataAs( $chart_id, 'xls' );
140 131 break;
141 132 default:
142 - $data = apply_filters( 'visualizer_action_data', $data, $chart_id, $type, $params, $this );
133 + $data = apply_filters( 'visualizer_action_data', $data, $chart_id, $type );
143 134 break;
144 135 }
145 136
146 137 return new WP_REST_Response( array( 'data' => $data ) );
@@ -158,10 +149,9 @@
158 149 wp_register_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
159 150 wp_register_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true );
160 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,16 +166,15 @@
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
173 + 'class' => false, // chart class
174 + 'series' => false, // series filter hook
175 + 'data' => false, // data filter hook
176 + 'settings' => false, // data filter hook
188 177 ), $atts
189 178 );
190 179
191 180 // if empty id or chart does not exists, then return empty string
@@ -192,17 +181,8 @@
192 181 if ( ! $atts['id'] || ! ( $chart = get_post( $atts['id'] ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
193 182 return '';
194 183 }
195 184
196 - if ( ! apply_filters( 'visualizer_pro_show_chart', true, $atts['id'] ) ) {
197 - return '';
198 - }
199 -
200 - // in case revisions exist.
201 - if ( true === ( $revisions = $this->undoRevisions( $chart->ID, true ) ) ) {
202 - $chart = get_post( $chart->ID );
203 - }
204 -
205 185 $id = 'visualizer-' . $atts['id'];
206 186 $defaultClass = 'visualizer-front';
207 187 $class = apply_filters( Visualizer_Plugin::FILTER_CHART_WRAPPER_CLASS, $atts['class'], $atts['id'] );
208 188 $class = $defaultClass . ' ' . $class . ' ' . 'visualizer-front-' . $atts['id'];
@@ -232,16 +212,9 @@
232 212 if ( ! empty( $atts['data'] ) ) {
233 213 $data = apply_filters( $atts['data'], $data, $chart->ID, $type );
234 214 }
235 215
236 - $id = $id . '-' . rand();
237 - $arguments = array( '', $id, $settings );
238 - $css = '';
239 - apply_filters_ref_array( 'visualizer_pro_inline_css', array( &$arguments ) );
240 - if ( ! empty( $arguments ) ) {
241 - $css = $arguments[0];
242 - $settings = $arguments[2];
243 - }
216 + $id = $id . '-' . rand();
244 217
245 218 // add chart to the array
246 219 $this->_charts[ $id ] = array(
247 220 'type' => $type,
@@ -254,24 +227,21 @@
254 227 wp_enqueue_script( 'visualizer-render' );
255 228 wp_localize_script(
256 229 'visualizer-render', 'visualizer', array(
257 230 'charts' => $this->_charts,
258 - 'language' => $this->get_language(),
259 231 'map_api_key' => get_option( 'visualizer-map-api-key' ),
260 - '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#/' ),
261 233 'i10n' => array(
262 234 'copied' => __( 'Copied!', 'visualizer' ),
263 235 ),
264 236 )
265 237 );
266 - wp_enqueue_style( 'visualizer-front' );
267 238
268 239 $actions_div = '';
269 - $actions_visible = apply_filters( 'visualizer_pro_add_actions', isset( $settings['actions'] ) ? $settings['actions'] : array(), $atts['id'] );
270 - if ( ! empty( $actions_visible ) ) {
240 + if ( ! empty( $settings['actions'] ) ) {
271 241 $actions = $this->get_actions();
272 242 $actions_div = '<div class="visualizer-actions">';
273 - foreach ( $actions_visible as $action_type ) {
243 + foreach ( $settings['actions'] as $action_type ) {
274 244 $key = $action_type;
275 245 $mime = '';
276 246 if ( strpos( $action_type, ';' ) !== false ) {
277 247 $array = explode( ';', $action_type );
@@ -283,9 +253,8 @@
283 253
284 254 if ( 'copy' === $key ) {
285 255 $copy = $this->_getDataAs( $atts['id'], 'csv' );
286 256 $actions_div .= ' data-clipboard-text="' . esc_attr( $copy['csv'] ) . '"';
287 - wp_enqueue_script( 'visualizer-clipboardjs' );
288 257 }
289 258
290 259 $actions_div .= apply_filters( 'visualizer_action_attributes', '', $key, $atts['id'] );
291 260 $actions_div .= '>' . $label . '</a> &nbsp;';
@@ -292,11 +261,9 @@
292 261 }
293 262
294 263 $actions_div .= '</div>';
295 264 }
296 -
297 - $actions_div .= $css;
298 -
299 265 // return placeholder div
300 266 return $actions_div . '<div id="' . $id . '"' . $class . '></div>';
301 267 }
268 +
302 269 }