settings_fields doesn’t appear to be running
You need to add a fifth parameter to add_settings_field() that contains the section slug, $settings_slug_name.
You need to add a fifth parameter to add_settings_field() that contains the section slug, $settings_slug_name.
There are several ways to implement an options page. You can implement a quick and easy options page via Advanced Custom Fields Pro (find out more here: https://www.advancedcustomfields.com/resources/options-page/) To do things the WordPress way(without the help of plugins), you will want to follow this guide here: https://developer.wordpress.org/plugins/settings/custom-settings-page/ Once implemented, you should be able to save … Read more
From what I could see, the problem is not with the field callback, but it’s the section ID whereby you’re setting it to default — see $field[“section”] = ‘default’ below: // In the foreach in AddSettings.php add_settings_field( $field[“id”], $field[“title”], isset( $field[“callback”] ) ? $field[“callback”] : “”, $field[“page”], $field[“section”] = ‘default’, $field[“args”] = array() ); So … Read more
How can I have a single sanitization callback for multiple fields and then access the values of it ($input)? For fields with the same validation logic, just set sanitize_callback to the same callback, e.g. if field_1 and field_2 are single-line and text-only fields (i.e. no HTML allowed), you can use ‘sanitize_callback’ => ‘sanitize_text_field’ for both … Read more
Excerpt from the register_setting() documentation: ‘default’ (mixed) Default value when calling get_option(). So the purpose of the default argument is to provide a default value which get_option() would return if the option does not exist (or has not yet been saved) in the database. And register_setting() sets the option’s default value via filter_default_option() which is … Read more
I think the approach you’re attempting is prohibitively complex, and will not scale well at all. I would suggest two possible alternatives to the approach you’re trying to take: Create a Widget to display your Plugin output, so that the Widgets API handles the settings for multiple instances of your Plugin output. Create a Shortcode … Read more
Since the layout names are dynamic, perhaps it’s better to store them in a numerically indexed nested array? Something like: wpv_settings[layouts][0][name] = $key wpv_settings[layouts][0][markup] = $value wpv_settings[layouts][1][name] = $key wpv_settings[layouts][1][markup] = $value …etc?
$wpdb->insert( $wpdb->term_relationships, array( “object_id” => $thisMenuItem, “term_taxonomy_id” => $menuID ), array( “%d”, “%d” ) ); This was missing from the Question code. It allows the menu items to bind to the navigation menu itself.
You want to manipulate and return the same input you have coming into the function. In your case that is $input. That is how filters work. function add_validation( $input ) { // here I want to add some validation for a simple field named ‘example’ if ( isset( $input[‘example’] ) && !empty( $input[‘example’] ) ) … Read more
Here you go my friend: add_filter( ‘admin_init’ , ‘register_fields’ ); function register_fields() { register_setting( ‘general’, ‘msp_duration’, ‘esc_attr’ ); add_settings_field( ‘msp_duration’, __(‘Cache Duration’) ,’fields_html’, ‘general’ ); } function fields_html() { $value = get_option( ‘msp_duration’ ); $fields = array( array( “name” => __(‘Every 6 hours’), “value” => 60 * 60 * 6, ), array( “name” => __(‘Every … Read more