PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.2.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.2.0
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 +391 -88 3.0.53.2.0 View file →
@@ -52,9 +52,9 @@
52 52 public function __construct( Visualizer_Plugin $plugin ) {
53 53 parent::__construct( $plugin );
54 54 $this->_addAction( 'load-post.php', 'enqueueMediaScripts' );
55 55 $this->_addAction( 'load-post-new.php', 'enqueueMediaScripts' );
56 - $this->_addAction( 'admin_footer', 'renderTempaltes' );
56 + $this->_addAction( 'admin_footer', 'renderTemplates' );
57 57 $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 8 );
58 58 $this->_addAction( 'admin_menu', 'registerAdminMenu' );
59 59 $this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' );
60 60 $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
@@ -60,11 +60,127 @@
60 60 $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
61 61 $this->_addFilter( 'visualizer_logger_data', 'getLoggerData' );
62 62 $this->_addFilter( 'visualizer_get_chart_counts', 'getChartCountsByTypeAndMeta' );
63 63 $this->_addFilter( 'visualizer_feedback_review_trigger', 'feedbackReviewTrigger' );
64 +
65 + // revision support.
66 + $this->_addFilter( 'wp_revisions_to_keep', 'limitRevisions', null, 10, 2 );
67 + $this->_addAction( '_wp_put_post_revision', 'addRevision', null, 10, 1 );
68 + $this->_addAction( 'wp_restore_post_revision', 'restoreRevision', null, 10, 2 );
69 +
70 + $this->_addAction( 'admin_init', 'init' );
64 71 }
65 72
66 73 /**
74 + * No limits on revisions.
75 + */
76 + public function limitRevisions( $num, $post ) {
77 + if ( Visualizer_Plugin::CPT_VISUALIZER === $post->post_type ) {
78 + return -1;
79 + }
80 + return $num;
81 + }
82 +
83 + /**
84 + * Add a revision.
85 + */
86 + public function addRevision( $revision_id ) {
87 + $parent_id = wp_is_post_revision( $revision_id );
88 + if ( Visualizer_Plugin::CPT_VISUALIZER === get_post_type( $parent_id ) ) {
89 + // add the meta data to this revision.
90 + $meta = get_post_meta( $parent_id, '', true );
91 +
92 + if ( $meta ) {
93 + foreach ( $meta as $key => $value ) {
94 + if ( 0 === strpos( $key, 'visualizer' ) ) {
95 + add_metadata( 'post', $revision_id, $key, maybe_unserialize( $value[0] ) );
96 + }
97 + }
98 + }
99 + }
100 + }
101 +
102 + /**
103 + * Restore a revision.
104 + */
105 + public function restoreRevision( $post_id, $revision_id ) {
106 + if ( Visualizer_Plugin::CPT_VISUALIZER === get_post_type( $post_id ) ) {
107 + // get the meta information from the revision.
108 + $meta = get_metadata( 'post', $revision_id, '', true );
109 +
110 + // delete all meta information from the post before adding.
111 + $post_meta = get_post_meta( $post_id, '', true );
112 + if ( $post_meta ) {
113 + foreach ( $meta as $key => $value ) {
114 + if ( 0 === strpos( $key, 'visualizer' ) ) {
115 + delete_post_meta( $post_id, $key );
116 + }
117 + }
118 + }
119 +
120 + if ( $meta ) {
121 + foreach ( $meta as $key => $value ) {
122 + if ( 0 === strpos( $key, 'visualizer' ) ) {
123 + add_post_meta( $post_id, $key, maybe_unserialize( $value[0] ) );
124 + }
125 + }
126 + }
127 + }
128 + }
129 +
130 + /**
131 + * Admin init.
132 + *
133 + * @access public
134 + */
135 + public function init() {
136 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
137 + if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) && 'true' == get_user_option( 'rich_editing' ) ) {
138 + $this->_addFilter( 'mce_external_languages', 'add_tinymce_lang', 10, 1 );
139 + $this->_addFilter( 'mce_external_plugins', 'tinymce_plugin', 10, 1 );
140 + $this->_addFilter( 'mce_buttons', 'register_mce_button', 10, 1 );
141 + }
142 + }
143 +
144 + /**
145 + * Load plugin translation for - TinyMCE API
146 + *
147 + * @access public
148 + * @param array $arr The tinymce_lang array.
149 + * @return array
150 + */
151 + public function add_tinymce_lang( $arr ) {
152 + $ui_lang = VISUALIZER_ABSPATH . '/classes/Visualizer/Module/Language.php';
153 + $ui_lang = apply_filters( 'visualizer_ui_lang_filter', $ui_lang );
154 + $arr[] = $ui_lang;
155 + return $arr;
156 + }
157 +
158 + /**
159 + * Load custom js options - TinyMCE API
160 + *
161 + * @access public
162 + * @param array $plugin_array The tinymce plugin array.
163 + * @return array
164 + */
165 + public function tinymce_plugin( $plugin_array ) {
166 + $plugin_array['visualizer_mce_button'] = VISUALIZER_ABSURL . 'js/mce.js';
167 + return $plugin_array;
168 + }
169 +
170 + /**
171 + * Register new button in the editor
172 + *
173 + * @access public
174 + * @param array $buttons The tinymce buttons array.
175 + * @return array
176 + */
177 + public function register_mce_button( $buttons ) {
178 + array_push( $buttons, 'visualizer_mce_button' );
179 + return $buttons;
180 + }
181 +
182 + /**
67 183 * Whether to show the feedback review or not.
68 184 *
69 185 * @access public
70 186 */
@@ -97,14 +213,28 @@
97 213 public function enqueueMediaScripts() {
98 214 global $typenow;
99 215 if ( post_type_supports( $typenow, 'editor' ) ) {
100 216 wp_enqueue_style( 'visualizer-media', VISUALIZER_ABSURL . 'css/media.css', array( 'media-views' ), Visualizer_Plugin::VERSION );
101 - wp_enqueue_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array( 'media-editor' ), null, true );
102 - wp_enqueue_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true );
103 - wp_enqueue_script( 'visualizer-media-model', VISUALIZER_ABSURL . 'js/media/model.js', array( 'visualizer-google-jsapi-old' ), Visualizer_Plugin::VERSION, true );
217 +
218 + // Load all the assets for the different libraries we support.
219 + $deps = array(
220 + Visualizer_Render_Sidebar_Google::enqueue_assets( array( 'media-editor' ) ),
221 + Visualizer_Render_Sidebar_Type_DataTable::enqueue_assets( array( 'media-editor' ) ),
222 + );
223 +
224 + wp_enqueue_script( 'visualizer-media-model', VISUALIZER_ABSURL . 'js/media/model.js', $deps, Visualizer_Plugin::VERSION, true );
104 225 wp_enqueue_script( 'visualizer-media-collection', VISUALIZER_ABSURL . 'js/media/collection.js', array( 'visualizer-media-model' ), Visualizer_Plugin::VERSION, true );
105 226 wp_enqueue_script( 'visualizer-media-controller', VISUALIZER_ABSURL . 'js/media/controller.js', array( 'visualizer-media-collection' ), Visualizer_Plugin::VERSION, true );
106 227 wp_enqueue_script( 'visualizer-media-view', VISUALIZER_ABSURL . 'js/media/view.js', array( 'visualizer-media-controller' ), Visualizer_Plugin::VERSION, true );
228 + wp_localize_script(
229 + 'visualizer-media-view',
230 + 'visualizer',
231 + array(
232 + 'i10n' => array(
233 + 'insert' => __( 'Insert', 'visualizer' ),
234 + ),
235 + )
236 + );
107 237 wp_enqueue_script( 'visualizer-media-toolbar', VISUALIZER_ABSURL . 'js/media/toolbar.js', array( 'visualizer-media-view' ), Visualizer_Plugin::VERSION, true );
108 238 wp_enqueue_script( 'visualizer-media', VISUALIZER_ABSURL . 'js/media.js', array( 'visualizer-media-toolbar' ), Visualizer_Plugin::VERSION, true );
109 239 }
110 240 }
@@ -120,8 +250,9 @@
120 250 *
121 251 * @return array The extended array of media view strings.
122 252 */
123 253 public function setupMediaViewStrings( $strings ) {
254 + $chart_types = self::_getChartTypesLocalized( true, true, true );
124 255 $strings['visualizer'] = array(
125 256 'actions' => array(
126 257 'get_charts' => Visualizer_Plugin::ACTION_GET_CHARTS,
127 258 'delete_chart' => Visualizer_Plugin::ACTION_DELETE_CHART,
@@ -133,10 +264,10 @@
133 264 'library' => esc_html__( 'From Library', 'visualizer' ),
134 265 'create' => esc_html__( 'Create New', 'visualizer' ),
135 266 ),
136 267 'library' => array(
137 - 'filters' => self::_getChartTypesLocalized( true, true ),
138 - 'types' => array_keys( self::_getChartTypesLocalized( true, true ) ),
268 + 'filters' => $chart_types,
269 + 'types' => array_keys( $chart_types ),
139 270 ),
140 271 'nonce' => wp_create_nonce(),
141 272 'buildurl' => add_query_arg( 'action', Visualizer_Plugin::ACTION_CREATE_CHART, admin_url( 'admin-ajax.php' ) ),
142 273 );
@@ -152,59 +283,74 @@
152 283 * @static
153 284 * @access private
154 285 * @return array The associated array of chart types with localized names.
155 286 */
156 - public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false ) {
157 - $types = array(
158 - 'pie' => array(
159 - 'name' => esc_html__( 'Pie', 'visualizer' ),
287 + public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false, $add_select = false, $where = null ) {
288 + $additional = array();
289 + if ( $add_select ) {
290 + $additional['select'] = array(
291 + 'name' => esc_html__( 'All', 'visualizer' ),
160 292 'enabled' => true,
161 - ),
162 - 'line' => array(
163 - 'name' => esc_html__( 'Line', 'visualizer' ),
164 - 'enabled' => true,
165 - ),
166 - 'area' => array(
167 - 'name' => esc_html__( 'Area', 'visualizer' ),
168 - 'enabled' => true,
169 - ),
170 - 'geo' => array(
171 - 'name' => esc_html__( 'Geo', 'visualizer' ),
172 - 'enabled' => true,
173 - ),
174 - 'bar' => array(
175 - 'name' => esc_html__( 'Bar', 'visualizer' ),
176 - 'enabled' => true,
177 - ),
178 - 'column' => array(
179 - 'name' => esc_html__( 'Column', 'visualizer' ),
180 - 'enabled' => true,
181 - ),
182 - 'gauge' => array(
183 - 'name' => esc_html__( 'Gauge', 'visualizer' ),
184 - 'enabled' => true,
185 - ),
186 - 'scatter' => array(
187 - 'name' => esc_html__( 'Scatter', 'visualizer' ),
188 - 'enabled' => true,
189 - ),
190 - 'candlestick' => array(
191 - 'name' => esc_html__( 'Candlestick', 'visualizer' ),
192 - 'enabled' => true,
193 - ),
194 - // pro types
195 - 'table' => array(
196 - 'name' => esc_html__( 'Table', 'visualizer' ),
197 - 'enabled' => false,
198 - ),
199 - 'timeline' => array(
200 - 'name' => esc_html__( 'Timeline', 'visualizer' ),
201 - 'enabled' => false,
202 - ),
203 - 'combo' => array(
204 - 'name' => esc_html__( 'Combo', 'visualizer' ),
205 - 'enabled' => false,
206 - ),
293 + );
294 + }
295 +
296 + $types = array_merge(
297 + $additional,
298 + array(
299 + 'dataTable' => array(
300 + 'name' => esc_html__( 'Table (New)', 'visualizer' ),
301 + 'enabled' => true,
302 + ),
303 + 'pie' => array(
304 + 'name' => esc_html__( 'Pie', 'visualizer' ),
305 + 'enabled' => true,
306 + ),
307 + 'line' => array(
308 + 'name' => esc_html__( 'Line', 'visualizer' ),
309 + 'enabled' => true,
310 + ),
311 + 'area' => array(
312 + 'name' => esc_html__( 'Area', 'visualizer' ),
313 + 'enabled' => true,
314 + ),
315 + 'geo' => array(
316 + 'name' => esc_html__( 'Geo', 'visualizer' ),
317 + 'enabled' => true,
318 + ),
319 + 'bar' => array(
320 + 'name' => esc_html__( 'Bar', 'visualizer' ),
321 + 'enabled' => true,
322 + ),
323 + 'column' => array(
324 + 'name' => esc_html__( 'Column', 'visualizer' ),
325 + 'enabled' => true,
326 + ),
327 + 'scatter' => array(
328 + 'name' => esc_html__( 'Scatter', 'visualizer' ),
329 + 'enabled' => true,
330 + ),
331 + 'gauge' => array(
332 + 'name' => esc_html__( 'Gauge', 'visualizer' ),
333 + 'enabled' => true,
334 + ),
335 + 'candlestick' => array(
336 + 'name' => esc_html__( 'Candlestick', 'visualizer' ),
337 + 'enabled' => true,
338 + ),
339 + // pro types
340 + 'table' => array(
341 + 'name' => esc_html__( 'Table (Deprecated)', 'visualizer' ),
342 + 'enabled' => false,
343 + ),
344 + 'timeline' => array(
345 + 'name' => esc_html__( 'Timeline', 'visualizer' ),
346 + 'enabled' => false,
347 + ),
348 + 'combo' => array(
349 + 'name' => esc_html__( 'Combo', 'visualizer' ),
350 + 'enabled' => false,
351 + ),
352 + )
207 353 );
208 354 $types = apply_filters( 'visualizer_pro_chart_types', $types );
209 355 if ( $enabledOnly ) {
210 356 $filtered = array();
@@ -231,8 +377,83 @@
231 377 }
232 378 $types = $doubleD;
233 379 }
234 380
381 + return self::handleDeprecatedCharts( $types, $enabledOnly, $get2Darray, $where );
382 + }
383 +
384 + /**
385 + * Handle (soon-to-be) deprecated charts.
386 + */
387 + private static function handleDeprecatedCharts( $types, $enabledOnly, $get2Darray, $where ) {
388 + $deprecated = array();
389 +
390 + switch ( $where ) {
391 + case 'library':
392 + // if the user has a Google Table chart, show it as deprecated otherwise remove the option from the library.
393 + if ( ! self::hasChartType( 'table' ) ) {
394 + $deprecated[] = 'table';
395 + if ( $get2Darray ) {
396 + $types['dataTable'] = esc_html__( 'Table', 'visualizer' );
397 + } else {
398 + $types['dataTable']['name'] = esc_html__( 'Table', 'visualizer' );
399 + }
400 + }
401 +
402 + // if a user has a Gauge/Candlestick chart, then let them keep using it.
403 + if ( ! VISUALIZER_PRO ) {
404 + if ( ! self::hasChartType( 'gauge' ) ) {
405 + if ( $get2Darray ) {
406 + $deprecated[] = 'gauge';
407 + } else {
408 + $types['gauge']['enabled'] = false;
409 + }
410 + }
411 + if ( ! self::hasChartType( 'candlestick' ) ) {
412 + if ( $get2Darray ) {
413 + $deprecated[] = 'candlestick';
414 + } else {
415 + $types['candlestick']['enabled'] = false;
416 + }
417 + }
418 + }
419 + break;
420 + default:
421 + // remove the option to create a Google Table chart.
422 + $deprecated[] = 'table';
423 +
424 + // rename the new table chart type.
425 + if ( $get2Darray ) {
426 + $types['dataTable'] = esc_html__( 'Table', 'visualizer' );
427 + } else {
428 + $types['dataTable']['name'] = esc_html__( 'Table', 'visualizer' );
429 + }
430 +
431 + // if a user has a Gauge/Candlestick chart, then let them keep using it.
432 + if ( ! VISUALIZER_PRO ) {
433 + if ( ! self::hasChartType( 'gauge' ) ) {
434 + if ( $get2Darray ) {
435 + $deprecated[] = 'gauge';
436 + } else {
437 + $types['gauge']['enabled'] = false;
438 + }
439 + }
440 + if ( ! self::hasChartType( 'candlestick' ) ) {
441 + if ( $get2Darray ) {
442 + $deprecated[] = 'candlestick';
443 + } else {
444 + $types['candlestick']['enabled'] = false;
445 + }
446 + }
447 + }
448 + }
449 +
450 + if ( $deprecated ) {
451 + foreach ( $deprecated as $type ) {
452 + unset( $types[ $type ] );
453 + }
454 + }
455 +
235 456 return $types;
236 457 }
237 458
238 459 /**
@@ -242,11 +463,11 @@
242 463 * @global string $pagenow The name of the current page.
243 464 *
244 465 * @access public
245 466 */
246 - public function renderTempaltes() {
467 + public function renderTemplates() {
247 468 global $pagenow;
248 - if ( 'post.php' != $pagenow && 'post-new.php' != $pagenow ) {
469 + if ( 'post.php' !== $pagenow && 'post-new.php' !== $pagenow ) {
249 470 return;
250 471 }
251 472 $render = new Visualizer_Render_Templates();
252 473 $render->render();
@@ -264,26 +485,40 @@
264 485 *
265 486 * @param string $suffix The current page suffix.
266 487 */
267 488 public function enqueueLibraryScripts( $suffix ) {
268 - if ( $suffix == $this->_libraryPage ) {
489 + if ( $suffix === $this->_libraryPage ) {
269 490 wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
270 491 $this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
271 492 wp_enqueue_media();
272 493 wp_enqueue_script(
273 - 'visualizer-library', VISUALIZER_ABSURL . 'js/library.js', array(
494 + 'visualizer-library',
495 + VISUALIZER_ABSURL . 'js/library.js',
496 + array(
274 497 'jquery',
275 498 'media-views',
276 - ), Visualizer_Plugin::VERSION, true
499 + ),
500 + Visualizer_Plugin::VERSION,
501 + true
277 502 );
278 - wp_enqueue_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
279 - wp_enqueue_script( 'google-jsapi-old', '//www.google.com/jsapi', array( 'google-jsapi-new' ), null, true );
280 - wp_enqueue_script(
281 - 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array(
282 - 'google-jsapi-old',
283 - 'visualizer-library',
284 - ), Visualizer_Plugin::VERSION, true
285 - );
503 +
504 + wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
505 +
506 + $query = $this->getQuery();
507 + while ( $query->have_posts() ) {
508 + $chart = $query->next_post();
509 + $library = $this->load_chart_type( $chart->ID );
510 + if ( is_null( $library ) ) {
511 + continue;
512 + }
513 + wp_enqueue_script(
514 + "visualizer-render-$library",
515 + VISUALIZER_ABSURL . 'js/render-facade.js',
516 + apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
517 + Visualizer_Plugin::VERSION,
518 + true
519 + );
520 + }
286 521 }
287 522 }
288 523
289 524 /**
@@ -316,18 +551,22 @@
316 551 $this->_libraryPage = add_submenu_page( 'upload.php', $title, $title, 'edit_posts', Visualizer_Plugin::NAME, $callback );
317 552 }
318 553
319 554 /**
320 - * Renders visualizer library page.
321 - *
322 - * @since 1.0.0
323 - *
324 - * @access public
555 + * Get the instance of WP_Query that fetches the charts as per the given criteria.
325 556 */
326 - public function renderLibraryPage() {
557 + private function getQuery() {
558 + static $q;
559 + if ( ! is_null( $q ) ) {
560 + return $q;
561 + }
562 +
327 563 // get current page
328 564 $page = filter_input(
329 - INPUT_GET, 'vpage', FILTER_VALIDATE_INT, array(
565 + INPUT_GET,
566 + 'vpage',
567 + FILTER_VALIDATE_INT,
568 + array(
330 569 'options' => array(
331 570 'min_range' => 1,
332 571 'default' => 1,
333 572 ),
@@ -340,9 +579,9 @@
340 579 'paged' => $page,
341 580 );
342 581 // add chart type filter to the query arguments
343 582 $filter = filter_input( INPUT_GET, 'type' );
344 - if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) {
583 + if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes(), true ) ) {
345 584 $query_args['meta_query'] = array(
346 585 array(
347 586 'key' => Visualizer_Plugin::CF_CHART_TYPE,
348 587 'value' => $filter,
@@ -363,33 +602,91 @@
363 602 $meta = isset( $query_args['meta_query'] ) ? $query_args['meta_query'] : array();
364 603 $meta[] = $query;
365 604 $query_args['meta_query'] = $meta;
366 605 }
367 - // Added by Ash/Upwork
368 - // fetch charts
606 + $q = new WP_Query( $query_args );
607 + return $q;
608 + }
609 +
610 + /**
611 + * Renders visualizer library page.
612 + *
613 + * @since 1.0.0
614 + *
615 + * @access public
616 + */
617 + public function renderLibraryPage() {
369 618 $charts = array();
370 - $query = new WP_Query( $query_args );
619 + $query = $this->getQuery();
620 +
621 + // get current page
622 + $page = filter_input(
623 + INPUT_GET,
624 + 'vpage',
625 + FILTER_VALIDATE_INT,
626 + array(
627 + 'options' => array(
628 + 'min_range' => 1,
629 + 'default' => 1,
630 + ),
631 + )
632 + );
633 + // add chart type filter to the query arguments
634 + $filter = filter_input( INPUT_GET, 'type' );
635 + if ( ! ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes(), true ) ) ) {
636 + $filter = 'all';
637 + }
638 +
639 + $css = '';
371 640 while ( $query->have_posts() ) {
372 641 $chart = $query->next_post();
642 +
643 + // if the user has updated a chart and instead of saving it, has closed the modal. If the user refreshes, they should get the original chart.
644 + $chart = $this->handleExistingRevisions( $chart->ID, $chart );
645 + // refresh a "live" db query chart.
646 + $chart = apply_filters( 'visualizer_schedule_refresh_chart', $chart, $chart->ID, false );
647 +
648 + $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
649 +
373 650 // fetch and update settings
374 651 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
652 +
653 + $settings = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SETTINGS, $settings, $chart->ID, $type );
654 + if ( ! empty( $atts['settings'] ) ) {
655 + $settings = apply_filters( $atts['settings'], $settings, $chart->ID, $type );
656 + }
657 +
375 658 unset( $settings['height'], $settings['width'] );
376 - $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
377 659 $series = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ), $chart->ID, $type );
378 660 $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $chart->ID, $type );
661 +
662 + $library = $this->load_chart_type( $chart->ID );
663 +
664 + $id = 'visualizer-' . $chart->ID;
665 + $arguments = $this->get_inline_custom_css( $id, $settings );
666 + if ( ! empty( $arguments ) ) {
667 + $css .= $arguments[0];
668 + $settings = $arguments[1];
669 + }
670 +
379 671 // add chart to the array
380 - $charts[ 'visualizer-' . $chart->ID ] = array(
672 + $charts[ $id ] = array(
381 673 'id' => $chart->ID,
382 674 'type' => $type,
383 675 'series' => $series,
384 676 'settings' => $settings,
385 677 'data' => $data,
678 + 'library' => $library,
386 679 );
387 680 }
388 681 // enqueue charts array
389 682 $ajaxurl = admin_url( 'admin-ajax.php' );
390 683 wp_localize_script(
391 - 'visualizer-library', 'visualizer', array(
684 + 'visualizer-library',
685 + 'visualizer',
686 + array(
687 + 'language' => $this->get_language(),
688 + 'map_api_key' => get_option( 'visualizer-map-api-key' ),
392 689 'charts' => $charts,
393 690 'urls' => array(
394 691 'base' => add_query_arg( 'vpage', false ),
395 692 'create' => add_query_arg(
@@ -395,17 +692,22 @@
395 692 'create' => add_query_arg(
396 693 array(
397 694 'action' => Visualizer_Plugin::ACTION_CREATE_CHART,
398 695 'library' => 'yes',
399 - ), $ajaxurl
696 + 'type' => isset( $_GET['type'] ) ? $_GET['type'] : '',
697 + ),
698 + $ajaxurl
400 699 ),
401 700 'edit' => add_query_arg(
402 701 array(
403 702 'action' => Visualizer_Plugin::ACTION_EDIT_CHART,
404 703 'library' => 'yes',
405 - ), $ajaxurl
704 + ),
705 + $ajaxurl
406 706 ),
407 707 ),
708 + 'page_type' => 'library',
709 + 'is_front' => false,
408 710 )
409 711 );
410 712 // render library page
411 713 $render = new Visualizer_Render_Library();
@@ -410,9 +712,10 @@
410 712 // render library page
411 713 $render = new Visualizer_Render_Library();
412 714 $render->charts = $charts;
413 715 $render->type = $filter;
414 - $render->types = self::_getChartTypesLocalized();
716 + $render->types = self::_getChartTypesLocalized( false, false, false, true );
717 + $render->custom_css = $css;
415 718 $render->pagination = paginate_links(
416 719 array(
417 720 'base' => add_query_arg( 'vpage', '%#%' ),
418 721 'format' => '',
@@ -436,9 +739,9 @@
436 739 *
437 740 * @return array Updated array of action links.
438 741 */
439 742 public function getPluginActionLinks( $links, $file ) {
440 - if ( $file == plugin_basename( VISUALIZER_BASEFILE ) ) {
743 + if ( $file === plugin_basename( VISUALIZER_BASEFILE ) ) {
441 744 array_unshift(
442 745 $links,
443 746 sprintf(
444 747 '<a href="%s">%s</a>',
@@ -463,9 +766,9 @@
463 766 *
464 767 * @return array Updated array of plugin meta links.
465 768 */
466 769 public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
467 - if ( $plugin_file == plugin_basename( VISUALIZER_BASEFILE ) ) {
770 + if ( $plugin_file === plugin_basename( VISUALIZER_BASEFILE ) ) {
468 771 // knowledge base link
469 772 $plugin_meta[] = sprintf(
470 773 '<a href="https://github.com/codeinwp/visualizer/wiki" target="_blank">%s</a>',
471 774 esc_html__( 'Knowledge Base', 'visualizer' )