File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
src/plugins/global-settings/preset-controls Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ function __construct() {
4545 $ this ->custom_presets = get_option ( 'stackable_global_custom_preset_controls ' );
4646 $ this ->theme_presets = WP_Theme_JSON_Resolver::get_theme_data ()->get_settings ();
4747 $ this ->default_presets = WP_Theme_JSON_Resolver::get_core_data ()->get_settings ();
48- $ this ->stackable_presets = $ this ->load_presets ( __DIR__ . '/presets.json ' );
48+ $ this ->stackable_presets = $ this ->load_json_file ( __DIR__ . '/presets.json ' );
4949
5050 add_filter ( 'stackable_inline_styles_nodep ' , array ( $ this , 'add_preset_controls_styles ' ) );
5151 add_filter ( 'stackable_inline_editor_styles ' , array ( $ this , 'add_preset_controls_styles ' ) );
@@ -55,10 +55,11 @@ public static function sanitize_array_setting( $input ) {
5555 return ! is_array ( $ input ) ? array ( array () ) : $ input ;
5656 }
5757
58- private function load_presets ( $ json_path ) {
58+ private function load_json_file ( $ json_path ) {
5959 if ( file_exists ( $ json_path ) ) {
60- $ json_data = file_get_contents ( $ json_path );
61- $ decoded_data = json_decode ( $ json_data , true );
60+ $ decoded_data = wp_json_file_decode ( $ json_path , [
61+ 'associative ' => true ,
62+ ] );
6263 return $ decoded_data [ 'settings ' ] ?? [];
6364 }
6465 return [];
You can’t perform that action at this time.
0 commit comments