register_setting sanitize callback $input is null
It turned out to be nonce related: the form didn’t have a nonce. Solved this by adding wp_nonce_field to the form.
It turned out to be nonce related: the form didn’t have a nonce. Solved this by adding wp_nonce_field to the form.
Your question is very abstract. As far I understood you want some thing like categories. So for that adding metaboxes is not necessary. I think categories are enough. If categories are not full filling your need then make another custom taxonomy with ‘hierarchical’ => true,. I think it will serve your need. Also giving permissions … Read more
You need to pass last parameter $args, if you want add_settings_field to output <label> use `label_for’ argument, see code snippet below <?php add_settings_field( ‘my-id’, ‘Test Filed’, ‘mamaduka_test_field’, ‘general’, ‘my-section’, array( ‘label_for’ => ‘my-test-field’ ) ); ?>
You’re passing the same ID to every single setting of a given type, rather than passing the $setting to the callback. Have a look at how I implement this type of callback in Oenology. function oenology_setting_callback( $option ) { $oenology_options = oenology_get_options(); $option_parameters = oenology_get_option_parameters(); $optionname = $option[‘name’]; $optiontitle = $option[‘title’]; $optiondescription = $option[‘description’]; $fieldtype … Read more
Your code will certainly use get_option() to retrieve the values for your options. get_option() accepts a second argument that allows you to specify a default. Use that instead of inserted values into the database unnecessarily. get_option( $option, $default ); If you are concerned about third party code, there is there is the option_{$option} filter that … Read more
Solved it by using show_user_profile and edit_user_profile instead: add_action( ‘show_user_profile’, ‘wpse_237901_user_edit_section’, 999 ); add_action( ‘edit_user_profile’, ‘wpse_237901_user_edit_section’, 999 ); function wpse_237901_user_edit_section() { # Code here… }
I just came across your question while trying to do a similar thing. I figured out what I needed so I thought I would post an answer here in case someone else finds it useful. In short I used this filter: https://codex.wordpress.org/Plugin_API/Filter_Reference/pre_update_option_(option_name) And it looks something like this: function set_admin_notice_options( $new_value, $old_value ) { // … Read more
Cannot update my options using wp_ajax
That’s because your options are stored as a serialised array, in one row with name XX_theme_settings. To update one option, you would still need to retrieve the existing settings, ammend the appropriate value and update all options in your array together. For example: $my_options= get_option(‘XX_theme_settings’);//retrieve all options $my_options[‘XX_Option2’] = ‘my new value’; //amend value in … Read more
Customizer > Menus is a panel named nav_menus. Customizer > Menus > Menu Locations is a section inside the nav_menus panel called menu_locations. Each menu is added a little differently, but I believe they are sections inside the nav_menus panel whose ID is nav_menu[menu_id]’ where menu_id is the term_id of the menu. Customizer > Menus … Read more