Articles of add settings field

Why this global array is returning NULL from a callback function

This drove me crazy for hours now… Please tell me why the $ppk_fields array is empty in the ppk_field_callback function? Note that it returns the correct values in the ppk_default_id function but that is not a callback function. Thank you! ppk.php class Ppk { public function ini() { add_action( ‘admin_menu’, array( $this, ‘add_ppk_p_menu’ ) ); […]

Letting user dynamically create fields using Settings API

I created a settings page, using the Settings API, following this tutorial. Now I want to have a button that lets users dynamically add fields, similar to the way it is done in this other one. I don’t want to try to “merge” these two things together. There must be a right way to do […]

Settings API – generating field value based on a different field?

I store my themes settings using Settings API. If I create a new setting using add_settings_field() is it possible to create another setting that will be based on the first one? Why? Imagine I have three settings: main_color lighter_color darker_color User opens Theme Options page and sets main_color to #444. Now I want lighter_color and […]

settings API: how to create a multi checkbox with blog categories?

i need to create a callback function with a multi checkbox with all the web/blog categories as multi options. my add_settings_fields are: add_settings_field( ‘select_page’, ‘Select Blog Page’, / ‘journal_combo_select_page_callback’, ‘journal_theme_blog_2_col’, ‘blog_page_blog_2_col_section’ ); add_settings_field( ‘limit_posts’, ‘Limit Posts’, ‘journal_limit_posts_callback’, ‘journal_theme_blog_2_col’, ‘blog_page_blog_2_col_section’ ); add_settings_field( // $id, $title, $callback, $page, $section, $args ‘check_categories’, // $id ‘Choose Categories’, // $title […]

Add your own settings page for plugin

I’m using the WordPress Plugin Boilerplate to make a plugin and I’m having some trouble outputting a form for users to input configuration options for the said plugin. I have the following methods for a class public function admin_add_menu() { add_menu_page( ‘Paypal Me Order’, ‘Paypal Me’, ‘manage_options’, ‘paypal_me_order’, array($this, ‘admin_display’), ‘dashicons-fa-cc-paypal’, 20 ); } function […]

How can one utilize a variable as a callback function name for add_settings_field

I’m trying to cut down on the amount of code that is in my theme options function. I’m adding my settings like so: add_settings_field($k,$v,$callback,$the_options,$the_group,$args); This works for me in every way as long as I write out the name of the function. For example, if $callback = ‘awesome_callback’ – and I create a function called […]

Theme customizer: How do you grab the value later?

I’m working on a custom site, doing all my work in a child theme. I need to add one variable, slider speed, to the customize control system. I’ve been able to modify the custom controls via the following additions to my child-theme functions.php file: function Primm_customize_register( $wp_customize ) { $wp_customize->add_section( ‘primm_section’ , array( ‘title’ => […]

Default value for add_settings_field

I’m creating a simple settings page by following these instructions. Since this is a custom plugin, I’d like one of my settings to start with a predefined value (that can later be changed). What is the recommended way to set a default value for a setting added with add_settings_field?

Settings API – changing add_settings_field() output?

I’m using Settings API and wondering if there’s any way of editing default output of add_settings_field() function? add_settings_field(‘the_field’, ‘bar’, ‘foo’, ‘page’, ‘section’); function foo() { echo ‘foo’; } Outputs: <table class=”form-table”> <tr valign=”top”> <th scope=”row”>bar</th> <td>foo</td> </tr> How to get rid of these table tags and replace them with something else?

Settings API – adding setting fields dynamically?

Is there a way of adding settings fields dynamically? I have my own Settings API options generator just like in Chip Bennet’s Oenology Theme, everything works perfect but I can’t find a way to create dynamic fields. Here’s how I add option fields. 1. First I describe all fields: function my_options() { $options = array( […]