1111use Code_Snippets \Welcome_API ;
1212use function Code_Snippets \clean_snippets_cache ;
1313use function Code_Snippets \code_snippets ;
14+ use const Code_Snippets \CACHE_GROUP ;
1415
1516const CACHE_KEY = 'code_snippets_settings ' ;
1617const OPTION_GROUP = 'code-snippets ' ;
@@ -79,7 +80,7 @@ function are_settings_unified(): bool {
7980 * @return array<string, array<string, mixed>>
8081 */
8182function get_settings_values (): array {
82- $ settings = wp_cache_get ( CACHE_KEY );
83+ $ settings = wp_cache_get ( CACHE_KEY , CACHE_GROUP );
8384 if ( $ settings ) {
8485 return $ settings ;
8586 }
@@ -93,7 +94,7 @@ function get_settings_values(): array {
9394 }
9495 }
9596
96- wp_cache_set ( CACHE_KEY , $ settings );
97+ wp_cache_set ( CACHE_KEY , $ settings, CACHE_GROUP );
9798 return $ settings ;
9899}
99100
@@ -125,7 +126,7 @@ function update_setting( string $section, string $field, $new_value ): bool {
125126
126127 $ settings [ $ section ][ $ field ] = $ new_value ;
127128
128- wp_cache_set ( CACHE_KEY , $ settings );
129+ wp_cache_set ( CACHE_KEY , $ settings, CACHE_GROUP );
129130 return update_self_option ( are_settings_unified (), OPTION_NAME , $ settings );
130131}
131132
@@ -136,17 +137,11 @@ function update_setting( string $section, string $field, $new_value ): bool {
136137 */
137138function get_settings_sections (): array {
138139 $ sections = array (
139- 'general ' => __ ( 'General ' , 'code-snippets ' ),
140- 'editor ' => __ ( 'Code Editor ' , 'code-snippets ' ),
141- 'debug ' => __ ( 'Debug ' , 'code-snippets ' ),
140+ 'general ' => __ ( 'General ' , 'code-snippets ' ),
141+ 'editor ' => __ ( 'Code Editor ' , 'code-snippets ' ),
142+ 'debug ' => __ ( 'Debug ' , 'code-snippets ' ),
142143 );
143144
144- // Only show the Version section when the debug setting to enable version changes is enabled.
145- $ enable_version = get_setting ( 'debug ' , 'enable_version_change ' );
146- if ( $ enable_version ) {
147- $ sections ['version-switch ' ] = __ ( 'Version ' , 'code-snippets ' );
148- }
149-
150145 return apply_filters ( 'code_snippets_settings_sections ' , $ sections );
151146}
152147
@@ -174,13 +169,8 @@ function register_plugin_settings() {
174169 add_settings_section ( $ section_id , $ section_name , '__return_empty_string ' , 'code-snippets ' );
175170 }
176171
177- // Register settings fields. Only register fields for sections that exist (some sections may be gated by settings).
178- $ registered_sections = get_settings_sections ();
172+ // Register settings fields.
179173 foreach ( get_settings_fields () as $ section_id => $ fields ) {
180- if ( ! isset ( $ registered_sections [ $ section_id ] ) ) {
181- continue ;
182- }
183-
184174 foreach ( $ fields as $ field_id => $ field ) {
185175 $ field_object = new Setting_Field ( $ section_id , $ field_id , $ field );
186176 add_settings_field ( $ field_id , $ field ['name ' ], [ $ field_object , 'render ' ], 'code-snippets ' , $ section_id );
@@ -306,7 +296,7 @@ function process_settings_actions( array $input ): ?array {
306296 * @return array<string, array<string, mixed>> The validated settings.
307297 */
308298function sanitize_settings ( array $ input ): array {
309- wp_cache_delete ( CACHE_KEY );
299+ wp_cache_delete ( CACHE_KEY , CACHE_GROUP );
310300 $ result = process_settings_actions ( $ input );
311301
312302 if ( ! is_null ( $ result ) ) {
0 commit comments