@@ -72,7 +72,7 @@ public function __construct( Visualizer_Plugin $plugin ) {
72
72
* @access private
73
73
* @return array The associated array of chart types with localized names.
74
74
*/
75
- public static function _getChartTypesLocalized () {
75
+ public static function _getChartTypesLocalized ( $ enabledOnly = false , $ get2Darray = false ) {
76
76
$ types = array (
77
77
'pie ' => array ( 'name ' => esc_html__ ( 'Pie ' , 'visualizer ' ), 'enabled ' => true ),
78
78
'line ' => array ( 'name ' => esc_html__ ( 'Line ' , 'visualizer ' ), 'enabled ' => true ),
@@ -91,6 +91,24 @@ public static function _getChartTypesLocalized() {
91
91
92
92
$ types = apply_filters ( 'visualizer_pro_chart_types ' , $ types );
93
93
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
+
94
112
return $ types ;
95
113
}
96
114
@@ -143,7 +161,8 @@ public function setupMediaViewStrings( $strings ) {
143
161
'create ' => esc_html__ ( 'Create New ' , 'visualizer ' ),
144
162
),
145
163
'library ' => array (
146
- 'filters ' => self ::_getChartTypesLocalized (),
164
+ 'filters ' => self ::_getChartTypesLocalized ( true , true ),
165
+ 'types ' => array_keys ( self ::_getChartTypesLocalized ( true , true ) ),
147
166
),
148
167
'nonce ' => wp_create_nonce (),
149
168
'buildurl ' => add_query_arg ( 'action ' , Visualizer_Plugin::ACTION_CREATE_CHART , admin_url ( 'admin-ajax.php ' ) ),
0 commit comments