@@ -53,7 +53,7 @@ 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 ' );
@@ -278,7 +278,7 @@ public function setupMediaViewStrings( $strings ) {
278
278
* @access private
279
279
* @return array The associated array of chart types with localized names.
280
280
*/
281
- public static function _getChartTypesLocalized ( $ enabledOnly = false , $ get2Darray = false , $ add_select = false ) {
281
+ public static function _getChartTypesLocalized ( $ enabledOnly = false , $ get2Darray = false , $ add_select = false , $ where = null ) {
282
282
$ additional = array ();
283
283
if ( $ add_select ) {
284
284
$ additional ['select ' ] = array (
@@ -372,6 +372,45 @@ public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darra
372
372
$ types = $ doubleD ;
373
373
}
374
374
375
+ return self ::handleDeprecatedCharts ( $ types , $ enabledOnly , $ get2Darray , $ where );
376
+ }
377
+
378
+ /**
379
+ * Handle (soon-to-be) deprecated charts.
380
+ */
381
+ private static function handleDeprecatedCharts ( $ types , $ enabledOnly , $ get2Darray , $ where ) {
382
+ $ deprecated = array ();
383
+
384
+ switch ( $ where ) {
385
+ case 'library ' :
386
+ // if the user has a Google Table chart, show it as deprecated otherwise remove the option from the library.
387
+ if ( ! self ::hasChartType ( 'table ' ) ) {
388
+ $ deprecated [] = 'table ' ;
389
+ if ( $ get2Darray ) {
390
+ $ types ['dataTable ' ] = esc_html__ ( 'Table ' , 'visualizer ' );
391
+ } else {
392
+ $ types ['dataTable ' ]['name ' ] = esc_html__ ( 'Table ' , 'visualizer ' );
393
+ }
394
+ }
395
+ break ;
396
+ default :
397
+ // remove the option to create a Google Table chart.
398
+ if ( self ::hasChartType ( 'table ' ) ) {
399
+ $ deprecated [] = 'table ' ;
400
+ if ( $ get2Darray ) {
401
+ $ types ['dataTable ' ] = esc_html__ ( 'Table ' , 'visualizer ' );
402
+ } else {
403
+ $ types ['dataTable ' ]['name ' ] = esc_html__ ( 'Table ' , 'visualizer ' );
404
+ }
405
+ }
406
+ }
407
+
408
+ if ( $ deprecated ) {
409
+ foreach ( $ deprecated as $ type ) {
410
+ unset( $ types [ $ type ] );
411
+ }
412
+ }
413
+
375
414
return $ types ;
376
415
}
377
416
@@ -383,7 +422,7 @@ public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darra
383
422
*
384
423
* @access public
385
424
*/
386
- public function renderTempaltes () {
425
+ public function renderTemplates () {
387
426
global $ pagenow ;
388
427
if ( 'post.php ' != $ pagenow && 'post-new.php ' != $ pagenow ) {
389
428
return ;
@@ -628,7 +667,7 @@ public function renderLibraryPage() {
628
667
$ render = new Visualizer_Render_Library ();
629
668
$ render ->charts = $ charts ;
630
669
$ render ->type = $ filter ;
631
- $ render ->types = self ::_getChartTypesLocalized ();
670
+ $ render ->types = self ::_getChartTypesLocalized ( false , false , false , true );
632
671
$ render ->custom_css = $ css ;
633
672
$ render ->pagination = paginate_links (
634
673
array (
0 commit comments