PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.6.6
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.6.6
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 3.10.4 All 148 releases
← All changes | classes/Visualizer/Module/Admin.php +112 -289 3.0.71.6.6 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 // +----------------------------------------------------------------------+
3 4 // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
4 5 // +----------------------------------------------------------------------+
5 6 // | This program is free software; you can redistribute it and/or modify |
@@ -17,8 +18,9 @@
17 18 // | MA 02110-1301 USA |
18 19 // +----------------------------------------------------------------------+
19 20 // | Author: Eugene Manuilov <eugene@manuilov.org> |
20 21 // +----------------------------------------------------------------------+
22 +
21 23 /**
22 24 * The module for all admin stuff.
23 25 *
24 26 * @category Visualizer
@@ -45,101 +47,53 @@
45 47 *
46 48 * @since 1.0.0
47 49 *
48 50 * @access public
49 - *
50 51 * @param Visualizer_Plugin $plugin The instance of the plugin.
51 52 */
52 53 public function __construct( Visualizer_Plugin $plugin ) {
53 54 parent::__construct( $plugin );
55 +
54 56 $this->_addAction( 'load-post.php', 'enqueueMediaScripts' );
55 57 $this->_addAction( 'load-post-new.php', 'enqueueMediaScripts' );
56 58 $this->_addAction( 'admin_footer', 'renderTempaltes' );
57 - $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 8 );
59 + $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts' );
58 60 $this->_addAction( 'admin_menu', 'registerAdminMenu' );
61 +
59 62 $this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' );
60 63 $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
61 - $this->_addFilter( 'visualizer_logger_data', 'getLoggerData' );
62 - $this->_addFilter( 'visualizer_get_chart_counts', 'getChartCountsByTypeAndMeta' );
63 - $this->_addFilter( 'visualizer_feedback_review_trigger', 'feedbackReviewTrigger' );
64 -
65 - $this->_addAction( 'admin_init', 'init' );
64 + $this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 );
66 65 }
67 66
68 67 /**
69 - * Admin init.
68 + * Returns associated array of chart types and localized names.
70 69 *
71 - * @access public
72 - */
73 - public function init() {
74 - if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) && 'true' == get_user_option( 'rich_editing' ) ) {
75 - $this->_addFilter( 'mce_external_languages', 'add_tinymce_lang', 10, 1 );
76 - $this->_addFilter( 'mce_external_plugins', 'tinymce_plugin', 10, 1 );
77 - $this->_addFilter( 'mce_buttons', 'register_mce_button', 10, 1 );
78 - }
79 - }
80 -
81 - /**
82 - * Load plugin translation for - TinyMCE API
70 + * @since 1.0.0
83 71 *
84 - * @access public
85 - * @param array $arr The tinymce_lang array.
86 - * @return array
72 + * @static
73 + * @access private
74 + * @return array The associated array of chart types with localized names.
87 75 */
88 - public function add_tinymce_lang( $arr ) {
89 - $ui_lang = VISUALIZER_ABSPATH . '/classes/Visualizer/Module/Language.php';
90 - $ui_lang = apply_filters( 'visualizer_ui_lang_filter', $ui_lang );
91 - $arr[] = $ui_lang;
92 - return $arr;
93 - }
76 + public static function _getChartTypesLocalized() {
77 + $types = array(
78 + 'all' => esc_html__( 'All', Visualizer_Plugin::NAME ),
79 + 'pie' => esc_html__( 'Pie', Visualizer_Plugin::NAME ),
80 + 'line' => esc_html__( 'Line', Visualizer_Plugin::NAME ),
81 + 'area' => esc_html__( 'Area', Visualizer_Plugin::NAME ),
82 + 'geo' => esc_html__( 'Geo', Visualizer_Plugin::NAME ),
83 + 'bar' => esc_html__( 'Bar', Visualizer_Plugin::NAME ),
84 + 'column' => esc_html__( 'Column', Visualizer_Plugin::NAME ),
85 + 'gauge' => esc_html__( 'Gauge', Visualizer_Plugin::NAME ),
86 + 'scatter' => esc_html__( 'Scatter', Visualizer_Plugin::NAME ),
87 + 'candlestick' => esc_html__( 'Candlestick', Visualizer_Plugin::NAME ),
88 + );
94 89
95 - /**
96 - * Load custom js options - TinyMCE API
97 - *
98 - * @access public
99 - * @param array $plugin_array The tinymce plugin array.
100 - * @return array
101 - */
102 - public function tinymce_plugin( $plugin_array ) {
103 - $plugin_array['visualizer_mce_button'] = VISUALIZER_ABSURL . 'js/mce.js';
104 - return $plugin_array;
105 - }
90 + $types = apply_filters("visualizer_pro_chart_types", $types);
106 91
107 - /**
108 - * Register new button in the editor
109 - *
110 - * @access public
111 - * @param array $buttons The tinymce buttons array.
112 - * @return array
113 - */
114 - public function register_mce_button( $buttons ) {
115 - array_push( $buttons, 'visualizer_mce_button' );
116 - return $buttons;
92 + return $types;
117 93 }
118 94
119 95 /**
120 - * Whether to show the feedback review or not.
121 - *
122 - * @access public
123 - */
124 - public function feedbackReviewTrigger( $dumb ) {
125 - $query = new WP_Query(
126 - array(
127 - 'posts_per_page' => 50,
128 - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
129 - 'fields' => 'ids',
130 - 'update_post_meta_cache' => false,
131 - 'update_post_term_cache' => false,
132 - )
133 - );
134 -
135 - if ( $query->have_posts() && $query->post_count > 0 ) {
136 - return true;
137 - }
138 - return false;
139 - }
140 -
141 - /**
142 96 * Enqueues media scripts and styles.
143 97 *
144 98 * @since 1.0.0
145 99 * @uses wp_enqueue_style To enqueue style file.
@@ -148,25 +102,20 @@
148 102 * @access public
149 103 */
150 104 public function enqueueMediaScripts() {
151 105 global $typenow;
106 +
152 107 if ( post_type_supports( $typenow, 'editor' ) ) {
153 108 wp_enqueue_style( 'visualizer-media', VISUALIZER_ABSURL . 'css/media.css', array( 'media-views' ), Visualizer_Plugin::VERSION );
154 - wp_enqueue_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array( 'media-editor' ), null, true );
155 - wp_enqueue_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true );
156 - wp_enqueue_script( 'visualizer-media-model', VISUALIZER_ABSURL . 'js/media/model.js', array( 'visualizer-google-jsapi-old' ), Visualizer_Plugin::VERSION, true );
157 - wp_enqueue_script( 'visualizer-media-collection', VISUALIZER_ABSURL . 'js/media/collection.js', array( 'visualizer-media-model' ), Visualizer_Plugin::VERSION, true );
109 +
110 + wp_enqueue_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array( 'media-editor' ), null, true );
111 + wp_enqueue_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true );
112 + wp_enqueue_script( 'visualizer-media-model', VISUALIZER_ABSURL . 'js/media/model.js', array( 'visualizer-google-jsapi-old' ), Visualizer_Plugin::VERSION, true );
113 + wp_enqueue_script( 'visualizer-media-collection', VISUALIZER_ABSURL . 'js/media/collection.js', array( 'visualizer-media-model' ), Visualizer_Plugin::VERSION, true );
158 114 wp_enqueue_script( 'visualizer-media-controller', VISUALIZER_ABSURL . 'js/media/controller.js', array( 'visualizer-media-collection' ), Visualizer_Plugin::VERSION, true );
159 - wp_enqueue_script( 'visualizer-media-view', VISUALIZER_ABSURL . 'js/media/view.js', array( 'visualizer-media-controller' ), Visualizer_Plugin::VERSION, true );
160 - wp_localize_script(
161 - 'visualizer-media-view', 'visualizer', array(
162 - 'i10n' => array(
163 - 'insert' => __( 'Insert', 'visualizer' ),
164 - ),
165 - )
166 - );
167 - wp_enqueue_script( 'visualizer-media-toolbar', VISUALIZER_ABSURL . 'js/media/toolbar.js', array( 'visualizer-media-view' ), Visualizer_Plugin::VERSION, true );
168 - wp_enqueue_script( 'visualizer-media', VISUALIZER_ABSURL . 'js/media.js', array( 'visualizer-media-toolbar' ), Visualizer_Plugin::VERSION, true );
115 + wp_enqueue_script( 'visualizer-media-view', VISUALIZER_ABSURL . 'js/media/view.js', array( 'visualizer-media-controller' ), Visualizer_Plugin::VERSION, true );
116 + wp_enqueue_script( 'visualizer-media-toolbar', VISUALIZER_ABSURL . 'js/media/toolbar.js', array( 'visualizer-media-view' ), Visualizer_Plugin::VERSION, true );
117 + wp_enqueue_script( 'visualizer-media', VISUALIZER_ABSURL . 'js/media.js', array( 'visualizer-media-toolbar' ), Visualizer_Plugin::VERSION, true );
169 118 }
170 119 }
171 120
172 121 /**
@@ -174,33 +123,29 @@
174 123 *
175 124 * @since 1.0.0
176 125 *
177 126 * @access public
178 - *
179 127 * @param array $strings The array of media view strings.
180 - *
181 128 * @return array The extended array of media view strings.
182 129 */
183 130 public function setupMediaViewStrings( $strings ) {
184 - $chart_types = self::_getChartTypesLocalized( true, true, true );
185 131 $strings['visualizer'] = array(
186 - 'actions' => array(
132 + 'actions' => array(
187 133 'get_charts' => Visualizer_Plugin::ACTION_GET_CHARTS,
188 134 'delete_chart' => Visualizer_Plugin::ACTION_DELETE_CHART,
189 135 ),
190 136 'controller' => array(
191 - 'title' => esc_html__( 'Visualizations', 'visualizer' ),
137 + 'title' => esc_html__( 'Visualizations', Visualizer_Plugin::NAME ),
192 138 ),
193 - 'routers' => array(
194 - 'library' => esc_html__( 'From Library', 'visualizer' ),
195 - 'create' => esc_html__( 'Create New', 'visualizer' ),
139 + 'routers' => array(
140 + 'library' => esc_html__( 'From Library', Visualizer_Plugin::NAME ),
141 + 'create' => esc_html__( 'Create New', Visualizer_Plugin::NAME ),
196 142 ),
197 - 'library' => array(
198 - 'filters' => $chart_types,
199 - 'types' => array_keys( $chart_types ),
143 + 'library' => array(
144 + 'filters' => self::_getChartTypesLocalized(),
200 145 ),
201 - 'nonce' => wp_create_nonce(),
202 - 'buildurl' => add_query_arg( 'action', Visualizer_Plugin::ACTION_CREATE_CHART, admin_url( 'admin-ajax.php' ) ),
146 + 'nonce' => wp_create_nonce(),
147 + 'buildurl' => add_query_arg( 'action', Visualizer_Plugin::ACTION_CREATE_CHART, admin_url( 'admin-ajax.php' ) ),
203 148 );
204 149
205 150 return $strings;
206 151 }
@@ -205,109 +150,8 @@
205 150 return $strings;
206 151 }
207 152
208 153 /**
209 - * Returns associated array of chart types and localized names.
210 - *
211 - * @since 1.0.0
212 - *
213 - * @static
214 - * @access private
215 - * @return array The associated array of chart types with localized names.
216 - */
217 - public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false, $add_select = false ) {
218 - $additional = array();
219 - if ( $add_select ) {
220 - $additional['select'] = array(
221 - 'name' => esc_html__( 'All', 'visualizer' ),
222 - 'enabled' => true,
223 - );
224 - }
225 -
226 - $types = array_merge(
227 - $additional, array(
228 - 'pie' => array(
229 - 'name' => esc_html__( 'Pie', 'visualizer' ),
230 - 'enabled' => true,
231 - ),
232 - 'line' => array(
233 - 'name' => esc_html__( 'Line', 'visualizer' ),
234 - 'enabled' => true,
235 - ),
236 - 'area' => array(
237 - 'name' => esc_html__( 'Area', 'visualizer' ),
238 - 'enabled' => true,
239 - ),
240 - 'geo' => array(
241 - 'name' => esc_html__( 'Geo', 'visualizer' ),
242 - 'enabled' => true,
243 - ),
244 - 'bar' => array(
245 - 'name' => esc_html__( 'Bar', 'visualizer' ),
246 - 'enabled' => true,
247 - ),
248 - 'column' => array(
249 - 'name' => esc_html__( 'Column', 'visualizer' ),
250 - 'enabled' => true,
251 - ),
252 - 'gauge' => array(
253 - 'name' => esc_html__( 'Gauge', 'visualizer' ),
254 - 'enabled' => true,
255 - ),
256 - 'scatter' => array(
257 - 'name' => esc_html__( 'Scatter', 'visualizer' ),
258 - 'enabled' => true,
259 - ),
260 - 'candlestick' => array(
261 - 'name' => esc_html__( 'Candlestick', 'visualizer' ),
262 - 'enabled' => true,
263 - ),
264 - // pro types
265 - 'table' => array(
266 - 'name' => esc_html__( 'Table', 'visualizer' ),
267 - 'enabled' => false,
268 - ),
269 - 'timeline' => array(
270 - 'name' => esc_html__( 'Timeline', 'visualizer' ),
271 - 'enabled' => false,
272 - ),
273 - 'combo' => array(
274 - 'name' => esc_html__( 'Combo', 'visualizer' ),
275 - 'enabled' => false,
276 - ),
277 - )
278 - );
279 - $types = apply_filters( 'visualizer_pro_chart_types', $types );
280 - if ( $enabledOnly ) {
281 - $filtered = array();
282 - foreach ( $types as $type => $array ) {
283 - if ( ! is_array( $array ) ) {
284 - // support for old pro
285 - $array = array( 'enabled' => true, 'name' => $array );
286 - }
287 - if ( ! $array['enabled'] ) {
288 - continue;
289 - }
290 - $filtered[ $type ] = $array;
291 - }
292 - $types = $filtered;
293 - }
294 - if ( $get2Darray ) {
295 - $doubleD = array();
296 - foreach ( $types as $type => $array ) {
297 - if ( ! is_array( $array ) ) {
298 - // support for old pro
299 - $array = array( 'enabled' => true, 'name' => $array );
300 - }
301 - $doubleD[ $type ] = $array['name'];
302 - }
303 - $types = $doubleD;
304 - }
305 -
306 - return $types;
307 - }
308 -
309 - /**
310 154 * Renders templates to use in media popup.
311 155 *
312 156 * @since 1.0.0
313 157 * @global string $pagenow The name of the current page.
@@ -315,11 +159,13 @@
315 159 * @access public
316 160 */
317 161 public function renderTempaltes() {
318 162 global $pagenow;
163 +
319 164 if ( 'post.php' != $pagenow && 'post-new.php' != $pagenow ) {
320 165 return;
321 166 }
167 +
322 168 $render = new Visualizer_Render_Templates();
323 169 $render->render();
324 170 }
325 171
@@ -331,30 +177,21 @@
331 177 * @uses wp_enqueue_script() To enqueue javascript file.
332 178 * @uses wp_enqueue_media() To enqueue media stuff.
333 179 *
334 180 * @access public
335 - *
336 181 * @param string $suffix The current page suffix.
337 182 */
338 183 public function enqueueLibraryScripts( $suffix ) {
339 184 if ( $suffix == $this->_libraryPage ) {
340 185 wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
186 +
341 187 $this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
188 +
342 189 wp_enqueue_media();
343 - wp_enqueue_script(
344 - 'visualizer-library', VISUALIZER_ABSURL . 'js/library.js', array(
345 - 'jquery',
346 - 'media-views',
347 - ), Visualizer_Plugin::VERSION, true
348 - );
190 + wp_enqueue_script( 'visualizer-library', VISUALIZER_ABSURL . 'js/library.js', array( 'jquery', 'media-views' ), Visualizer_Plugin::VERSION, true );
349 191 wp_enqueue_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
350 - wp_enqueue_script( 'google-jsapi-old', '//www.google.com/jsapi', array( 'google-jsapi-new' ), null, true );
351 - wp_enqueue_script(
352 - 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array(
353 - 'google-jsapi-old',
354 - 'visualizer-library',
355 - ), Visualizer_Plugin::VERSION, true
356 - );
192 + wp_enqueue_script( 'google-jsapi-old', '//www.google.com/jsapi', array('google-jsapi-new'), null, true );
193 + wp_enqueue_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'google-jsapi-old', 'visualizer-library' ), Visualizer_Plugin::VERSION, true );
357 194 }
358 195 }
359 196
360 197 /**
@@ -362,16 +199,13 @@
362 199 *
363 200 * @since 1.0.0
364 201 *
365 202 * @access public
366 - *
367 203 * @param array $tabs The array of media upload tabs.
368 - *
369 204 * @return array Extended array of media upload tabs.
370 205 */
371 206 public function setupVisualizerTab( $tabs ) {
372 207 $tabs['visualizer'] = 'Visualizer';
373 -
374 208 return $tabs;
375 209 }
376 210
377 211 /**
@@ -381,10 +215,10 @@
381 215 *
382 216 * @access public
383 217 */
384 218 public function registerAdminMenu() {
385 - $title = esc_html__( 'Visualizer Library', 'visualizer' );
386 - $callback = array( $this, 'renderLibraryPage' );
219 + $title = esc_html__( 'Visualizer Library', Visualizer_Plugin::NAME );
220 + $callback = array( $this, 'renderLibraryPage' );
387 221 $this->_libraryPage = add_submenu_page( 'upload.php', $title, $title, 'edit_posts', Visualizer_Plugin::NAME, $callback );
388 222 }
389 223
390 224 /**
@@ -395,16 +229,15 @@
395 229 * @access public
396 230 */
397 231 public function renderLibraryPage() {
398 232 // get current page
399 - $page = filter_input(
400 - INPUT_GET, 'vpage', FILTER_VALIDATE_INT, array(
401 - 'options' => array(
402 - 'min_range' => 1,
403 - 'default' => 1,
404 - ),
233 + $page = filter_input( INPUT_GET, 'vpage', FILTER_VALIDATE_INT, array(
234 + 'options' => array(
235 + 'min_range' => 1,
236 + 'default' => 1,
405 237 )
406 - );
238 + ) );
239 +
407 240 // the initial query arguments to fetch charts
408 241 $query_args = array(
409 242 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
410 243 'posts_per_page' => 6,
@@ -409,8 +242,9 @@
409 242 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
410 243 'posts_per_page' => 6,
411 244 'paged' => $page,
412 245 );
246 +
413 247 // add chart type filter to the query arguments
414 248 $filter = filter_input( INPUT_GET, 'type' );
415 249 if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) {
416 250 $query_args['meta_query'] = array(
@@ -422,34 +256,39 @@
422 256 );
423 257 } else {
424 258 $filter = 'all';
425 259 }
426 - // Added by Ash/Upwork
427 - $filterByMeta = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING );
428 - if ( $filterByMeta ) {
429 - $query = array(
430 - 'key' => Visualizer_Plugin::CF_SETTINGS,
431 - 'value' => $filterByMeta,
432 - 'compare' => 'LIKE',
433 - );
434 - $meta = isset( $query_args['meta_query'] ) ? $query_args['meta_query'] : array();
435 - $meta[] = $query;
436 - $query_args['meta_query'] = $meta;
437 - }
438 - // Added by Ash/Upwork
260 +
261 + // Added by Ash/Upwork
262 + $filterByMeta = filter_input( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
263 + if($filterByMeta){
264 + $query = array(
265 + 'key' => Visualizer_Plugin::CF_SETTINGS,
266 + 'value' => $filterByMeta,
267 + 'compare' => 'LIKE',
268 + );
269 + $meta = isset($query_args['meta_query']) ? $query_args['meta_query'] : array();
270 + $meta[] = $query;
271 + $query_args['meta_query'] = $meta;
272 + }
273 + // Added by Ash/Upwork
274 +
439 275 // fetch charts
440 276 $charts = array();
441 - $query = new WP_Query( $query_args );
442 - while ( $query->have_posts() ) {
277 + $query = new WP_Query( $query_args );
278 + while( $query->have_posts() ) {
443 279 $chart = $query->next_post();
280 +
444 281 // fetch and update settings
445 282 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
446 283 unset( $settings['height'], $settings['width'] );
447 - $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
284 +
285 + $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
448 286 $series = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ), $chart->ID, $type );
449 - $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $chart->ID, $type );
287 + $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( $chart->post_content ), $chart->ID, $type );
288 +
450 289 // add chart to the array
451 - $charts[ 'visualizer-' . $chart->ID ] = array(
290 + $charts['visualizer-' . $chart->ID] = array(
452 291 'id' => $chart->ID,
453 292 'type' => $type,
454 293 'series' => $series,
455 294 'settings' => $settings,
@@ -455,46 +294,34 @@
455 294 'settings' => $settings,
456 295 'data' => $data,
457 296 );
458 297 }
298 +
459 299 // enqueue charts array
460 300 $ajaxurl = admin_url( 'admin-ajax.php' );
461 - wp_localize_script(
462 - 'visualizer-library', 'visualizer', array(
463 - 'language' => $this->get_language(),
464 - 'map_api_key' => get_option( 'visualizer-map-api-key' ),
465 - 'charts' => $charts,
466 - 'urls' => array(
467 - 'base' => add_query_arg( 'vpage', false ),
468 - 'create' => add_query_arg(
469 - array(
470 - 'action' => Visualizer_Plugin::ACTION_CREATE_CHART,
471 - 'library' => 'yes',
472 - ), $ajaxurl
473 - ),
474 - 'edit' => add_query_arg(
475 - array(
476 - 'action' => Visualizer_Plugin::ACTION_EDIT_CHART,
477 - 'library' => 'yes',
478 - ), $ajaxurl
479 - ),
480 - ),
481 - )
482 - );
301 + wp_localize_script( 'visualizer-library', 'visualizer', array(
302 + 'charts' => $charts,
303 + 'urls' => array(
304 + 'base' => add_query_arg( 'vpage', false ),
305 + 'create' => add_query_arg( array( 'action' => Visualizer_Plugin::ACTION_CREATE_CHART, 'library' => 'yes' ), $ajaxurl ),
306 + 'edit' => add_query_arg( array( 'action' => Visualizer_Plugin::ACTION_EDIT_CHART, 'library' => 'yes' ), $ajaxurl ),
307 + ),
308 + ) );
309 +
483 310 // render library page
484 - $render = new Visualizer_Render_Library();
485 - $render->charts = $charts;
486 - $render->type = $filter;
487 - $render->types = self::_getChartTypesLocalized();
488 - $render->pagination = paginate_links(
489 - array(
490 - 'base' => add_query_arg( 'vpage', '%#%' ),
491 - 'format' => '',
492 - 'current' => $page,
493 - 'total' => $query->max_num_pages,
494 - 'type' => 'array',
495 - )
496 - );
311 + $render = new Visualizer_Render_Library();
312 +
313 + $render->charts = $charts;
314 + $render->type = $filter;
315 + $render->types = self::_getChartTypesLocalized();
316 + $render->pagination = paginate_links( array(
317 + 'base' => add_query_arg( 'vpage', '%#%' ),
318 + 'format' => '',
319 + 'current' => $page,
320 + 'total' => $query->max_num_pages,
321 + 'type' => 'array',
322 + ) );
323 +
497 324 $render->render();
498 325 }
499 326
500 327 /**
@@ -502,12 +329,10 @@
502 329 *
503 330 * @since 1.0.0
504 331 *
505 332 * @access public
506 - *
507 - * @param array $links The array of original action links.
333 + * @param array $links The array of original action links.
508 334 * @param string $file The plugin basename.
509 - *
510 335 * @return array Updated array of action links.
511 336 */
512 337 public function getPluginActionLinks( $links, $file ) {
513 338 if ( $file == plugin_basename( VISUALIZER_BASEFILE ) ) {
@@ -515,9 +340,9 @@
515 340 $links,
516 341 sprintf(
517 342 '<a href="%s">%s</a>',
518 343 admin_url( 'upload.php?page=' . Visualizer_Plugin::NAME ),
519 - esc_html__( 'Library', 'visualizer' )
344 + esc_html__( 'Library', Visualizer_Plugin::NAME )
520 345 )
521 346 );
522 347 }
523 348
@@ -529,12 +354,10 @@
529 354 *
530 355 * @since 1.0.0
531 356 *
532 357 * @access public
533 - *
534 - * @param array $plugin_meta The array of a plugin meta links.
358 + * @param array $plugin_meta The array of a plugin meta links.
535 359 * @param string $plugin_file The plugin's basename.
536 - *
537 360 * @return array Updated array of plugin meta links.
538 361 */
539 362 public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
540 363 if ( $plugin_file == plugin_basename( VISUALIZER_BASEFILE ) ) {
@@ -540,14 +363,14 @@
540 363 if ( $plugin_file == plugin_basename( VISUALIZER_BASEFILE ) ) {
541 364 // knowledge base link
542 365 $plugin_meta[] = sprintf(
543 366 '<a href="https://github.com/codeinwp/visualizer/wiki" target="_blank">%s</a>',
544 - esc_html__( 'Knowledge Base', 'visualizer' )
367 + esc_html__( 'Knowledge Base', Visualizer_Plugin::NAME )
545 368 );
546 369 // flattr link
547 370 $plugin_meta[] = sprintf(
548 371 '<a style="color:red" href="https://themeisle.com/plugins/visualizer-charts-and-graphs-pro-addon/" target="_blank">%s</a>',
549 - esc_html__( 'Pro Addon', 'visualizer' )
372 + esc_html__( 'Pro Addon', Visualizer_Plugin::NAME )
550 373 );
551 374 }
552 375
553 376 return $plugin_meta;
@@ -552,5 +375,5 @@
552 375
553 376 return $plugin_meta;
554 377 }
555 378
556 -}
379 +}