@@ -72,7 +72,7 @@ public function __construct( Visualizer_Plugin $plugin ) {
7272 * @access private
7373 * @return array The associated array of chart types with localized names.
7474 */
75- public static function _getChartTypesLocalized () {
75+ public static function _getChartTypesLocalized ( $ enabledOnly = false , $ get2Darray = false ) {
7676 $ types = array (
7777 'pie ' => array ( 'name ' => esc_html__ ( 'Pie ' , 'visualizer ' ), 'enabled ' => true ),
7878 'line ' => array ( 'name ' => esc_html__ ( 'Line ' , 'visualizer ' ), 'enabled ' => true ),
@@ -91,6 +91,24 @@ public static function _getChartTypesLocalized() {
9191
9292 $ types = apply_filters ( 'visualizer_pro_chart_types ' , $ types );
9393
94+ if ( $ enabledOnly ) {
95+ $ filtered = array ();
96+ foreach ( $ types as $ type => $ array ) {
97+ if ( ! $ array ['enabled ' ] ) { continue ;
98+ }
99+ $ filtered [ $ type ] = $ array ;
100+ }
101+ $ types = $ filtered ;
102+ }
103+
104+ if ( $ get2Darray ) {
105+ $ doubleD = array ();
106+ foreach ( $ types as $ type => $ array ) {
107+ $ doubleD [ $ type ] = $ array ['name ' ];
108+ }
109+ $ types = $ doubleD ;
110+ }
111+
94112 return $ types ;
95113 }
96114
@@ -143,7 +161,8 @@ public function setupMediaViewStrings( $strings ) {
143161 'create ' => esc_html__ ( 'Create New ' , 'visualizer ' ),
144162 ),
145163 'library ' => array (
146- 'filters ' => self ::_getChartTypesLocalized (),
164+ 'filters ' => self ::_getChartTypesLocalized ( true , true ),
165+ 'types ' => array_keys ( self ::_getChartTypesLocalized ( true , true ) ),
147166 ),
148167 'nonce ' => wp_create_nonce (),
149168 'buildurl ' => add_query_arg ( 'action ' , Visualizer_Plugin::ACTION_CREATE_CHART , admin_url ( 'admin-ajax.php ' ) ),
0 commit comments