[wp-trac] [WordPress Trac] #35168: 4.4 Customizer - serialized options can no longer be created

WordPress Trac noreply at wordpress.org
Sat Dec 19 22:47:24 UTC 2015


#35168: 4.4 Customizer - serialized options can no longer be created
--------------------------+----------------------
 Reporter:  Looimaster    |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Customize     |     Version:
 Severity:  normal        |  Resolution:  invalid
 Keywords:                |     Focuses:
--------------------------+----------------------

Comment (by Looimaster):

 For anyone having the same issue this was my problem:


 {{{
 function tn_options_init() {
         register_setting( 'tn_options', 'my_theme_name_options',
 'tn_validate' );
         add_settings_section( 'general', '', '__return_false',
 'theme_options' );
         add_settings_field( 'x', __( 'x', 'tn' ), 'tn_settings_field_x',
 'theme_options', 'general' );
         add_settings_field( 'y', __( 'y', 'tn' ), 'tn_settings_field_y',
 'theme_options', 'general' );
         add_settings_field( 'z', __( 'z', 'tn' ), 'tn_settings_field_z',
 'theme_options', 'general' );
 }
 add_action( 'admin_init', 'tn_options_init' );
 }}}

 It looks like if you use `my_theme_name_options` in `register_setting()`
 then you can't be using it in Customizer. Or `tn_validate` must include
 sanitization for all your admin page options and Customizer options.

 I thought Customizer does saving separately and has its own sanitization
 callback and I didn't suspect that something else may be interfering.

 When I mentioned that I renamed that to `my_opts[opt_name]` and it didn't
 work then it's because I actually renamed that database setting everywhere
 using "Find and replace in Files..." and not just in my
 /inc/customizer.php.

 It's not a bug then.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35168#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list