Questions tagged [settings-api]

The Settings API, added in WordPress 2.7, allows admin pages containing settings forms to be managed semi-automatically. It lets you define settings pages, sections within those pages and fields within the sections. New settings pages can be registered along with sections and fields inside them. Existing settings pages can also be added to by registering new settings sections or fields inside of them.

Filter by
Sorted by
Tagged with
3 votes
1 answer
4k views

When should I use register_setting() and add_settings_field()

When the time comes that one wants to create a settings page, one stumbles upon two semantically similar WP functions called: register_setting() add_settings_field() I read the docs and am confused ...
Álvaro Franz's user avatar
3 votes
1 answer
286 views

Secure my "add_settings_field" translation?

I am using "add_settings_field" and want to provide translation for it , but my problem is security. So is __('My Checbox:' , 'domain') secure enough for translation? If not what can I do about it? I ...
Dejo Dekic's user avatar
3 votes
2 answers
3k views

Using tabs for wordpress plugin

Done my research and found this is how to call the built-in ui tabs jquery script in wp for the admin area but I'm stuck on implementing the other jquery scripts needed that I believe are built into ...
Jes's user avatar
  • 45
3 votes
2 answers
5k views

How to handel multiple checkbox field in the admin settings page with Settings API

I'm trying to incorporate a list of checkbox in my plugin's admin settings page from which users can select a few countries from the list of all countries. So far I've done this: add_action( '...
iSaumya's user avatar
  • 934
3 votes
1 answer
3k views

Custom plugin settings: clicking "save changes" does not display success message

I don't entirely understanding how to save my plugin's settings properly. When I click on the "Save Changes" button it saves data but it does not show any successful like message. Do I need to add an ...
Selim Rana's user avatar
3 votes
1 answer
5k views

Add custom content in user-edit.php page

When I go to edit a user's account located in: http://web.site/wp-admin/user-edit.php?user_id=ID I want to add a custom section with my own information (just text), similar to the ...
Ethan O'Sullivan's user avatar
3 votes
1 answer
3k views

Dynamic settings fields with Settings API

I am at my first Settings API application and I hit a snag. In a submenu page, I need to generate a number of fields (say color picker) for each of the values retrieved from another setting. To be ...
Anca's user avatar
  • 71
3 votes
1 answer
4k views

Settings API repeater fields

I'm new to the WP settings API, and a fairly novice PHP developer. To get started I followed this great tutorial Using Settings API - part 1 — Create a Theme Options Page and customized it to ...
Slatiner's user avatar
3 votes
1 answer
586 views

How can I include a setting that has a variable number of values in a settings page using register_setting?

I have one option on a settings page that can have between 1 and 5 values. I have a basic understanding on how to set up single value settings using the Settings API, but how do I go about generating ...
ProfK's user avatar
  • 172
3 votes
2 answers
15k views

Add Settings to Custom Post Type

I have a custom post type called Portfolio. It is associated with three custom taxonomies. This is all working fine. For the archive page, however, I need to add a few custom settings. Due to a ...
dotZak's user avatar
  • 68
3 votes
1 answer
216 views

do_settings_sections() doesn't escape quotes

I'm using the Settings API on a custom settings page: <form action='options.php' method='post'> <?php settings_fields('myplugin_settingsPage'); do_settings_sections('...
Francisco R's user avatar
3 votes
1 answer
1k views

What exactly is the purpose of settings_fields()?

In the API description for settings_fields() it reads: Output nonce, action, and option_page fields for a settings page. And a look in the includes/plugin.php file turns this up: function ...
shmuli's user avatar
  • 215
3 votes
1 answer
6k views

Saving Plugin settings to the database

I'm not a complete novice with php or wordpress but am wanting to approach this problem the most efficient way so believe asking here will help. I've got a plugin that randomly generates a quote - I'...
Dannyw24's user avatar
3 votes
1 answer
1k views

Settings API get_option best practices

I have a lot of options in my custom theme and most of them are like: get_option('my_option')['depth']['more_depth'] as they are arrays. In order to write code in a "cleaner", more compact way I have ...
Arg Geo's user avatar
  • 429
3 votes
1 answer
1k views

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 ...
zipzit's user avatar
  • 316
3 votes
1 answer
126 views

How to Save Different Settings Options Using Settings API and/or the Theme Optimizer

I would like to allow users to save different versions in the options panel using the Settings API and/or the Theme Optimzer. For instance, imagine that I have styled my site using via an admin panel ...
user avatar
3 votes
0 answers
321 views

Cannot update my options using wp_ajax

I have implemented wp_ajax in on my options page but the value of my options are not getting saved or updated. Here is my form: public function email_settings_form(){ // Set class property $...
Amen Ra's user avatar
  • 121
2 votes
2 answers
3k views

Wp die causing 500 Internal Server Error?

I have function to upload images inside my settings API ,it uploads images as expected but the problem comes when user chooses to upload non-image file to stop users from uploading other files (non-...
Dejo Dekic's user avatar
2 votes
2 answers
2k views

Serialized settings in rest api

I have registered settings and need it to be showed in REST API. $args = [ 'show_in_rest' => true ]; register_setting('default_sidebars', 'default_sidebars', $args); When I save a single ...
Tomáš Vavřinka's user avatar
2 votes
1 answer
2k views

Saving multiple checkboxes with WordPress settings api

I'm having trouble saving multiple checkboxes using WordPress settings api. I can add multiple values, but only the last checked box gets saved. This is what I currently have function ...
John Cook's user avatar
2 votes
1 answer
1k views

how can I detect that option value has changed?

I am working on a plugin and I want to fire a different action based on each option value change. so how can I do that ? example: $options = get_option('ACP_settings'); if $options['acp-select'] has ...
Bhavin Toliya's user avatar
2 votes
1 answer
380 views

Adding labels to Setting titles with API

If I add a setting using add_settings_field(), it doesn't create a <label> around the title so that it can be clicked to focus on the field. Some of the core settings do this, but they just add ...
Ian Dunn's user avatar
  • 4,837
2 votes
1 answer
1k views

get_option array value defaults and best practices

I have a custom options page. I have several sections of settings and some of them are even more closely related to each other so I decided to store them in arrays, seems more logical to me. It surely,...
Arg Geo's user avatar
  • 429
2 votes
3 answers
1k views

Settings API - Undefined Index when unchecking checkbox

I know this may be a duplicate however I haven't been able to make sense of previous questions. I have a checkbox on a settings page. Everything is okay on the first load of the page, if I check the ...
Ben H's user avatar
  • 363
2 votes
2 answers
4k views

register_setting sanitize callback $input is null

I am struggling to get my settings page to save my options. I've got it showing up correctly and it hits the sanitize function register_setting( 'my_options', // Option group '...
dhuyvetter's user avatar
2 votes
3 answers
6k views

Plugin set default setting value when it activated

I have set up my plugin option on admin panel with /** * Register and add settings */ public function page_init() { register_setting( 'my_option_group'...
Ohsik's user avatar
  • 407
2 votes
2 answers
2k views

wordpress settings api add fields

I am trying to add some code to a theme that will allow the user to change the logo or have some text instead. I managed to find some code that otto posted to do the file upload. I have added what I ...
Lee's user avatar
  • 155
2 votes
1 answer
961 views

The Settings API - What is the purpose of default value in register_setting?

I'm trying to wrap my head around the Settings and Options APIs as I'm writing a simple plugin. One thing that has really stomped me is the possibility to add a default value to an option when calling ...
Tomas Eklund's user avatar
2 votes
2 answers
264 views

WordPress setting with select - where is my mistake?

I have two option callbacks in my plugin, one with a ckeckbox and one with a select field. The first one is working perfectly, the second not. The select field doesn't save its value. I double checked ...
t3chernobyl's user avatar
2 votes
2 answers
495 views

How to: add option to add more checkboxes on custom post type

I have created a custom post type where in one of the metaboxes I have checkboxes where author can select what he would like to add on the post. Now, if the author wants to add something that is not ...
Abdul Qadeer's user avatar
2 votes
1 answer
55 views

Does settings API create settings on run time?

I'm tweaking a plugin and I'd like to have an option value different for each backoffice user. Currently the options are defined using the add_settings_field method that is performed in the ...
snowflake's user avatar
2 votes
1 answer
2k views

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 ...
Starfs's user avatar
  • 507
2 votes
1 answer
2k views

Add Admin Menu Inside Construct or Init

I thought I was making headway in my WordPress Development education until I ran across the Boilerplate for WordPress plugins and it uses a class object. I'm fine with that and understand those ...
clockwiseq's user avatar
2 votes
1 answer
1k views

Can I dynamically create duplicate fields with the Settings API?

I'm not sure that my title accurately explains what I'm trying to do, but it's the best way I could think of to explain what I'm attempting to do. I'm writing my first Wordpress plugin, and while it'...
drewbug's user avatar
  • 123
2 votes
2 answers
540 views

Import / Export Settings API fields values?

I've been storing all my theme options using Settings API for some time now and it's lacking one functionality. I have multiple pages (different servers) using my custom themes and I would love to ...
Wordpressor's user avatar
  • 5,041
2 votes
2 answers
528 views

How to display some settings for super admin user only using Settings API

I'm developing a plugin with an options page using the Settings API. I'd like to have one options array stored for my plugin, but on the settings page, I'd only like some of the settings to be ...
jessica's user avatar
  • 1,394
2 votes
2 answers
10k views

How to save array of datas in option page by setting api?

I am trying to create my own first plugin but I am coding novice so please guide me to the right direction. This plugin is to set the post expiry date based on the user's role. Now I am stuck at ...
dev-jim's user avatar
  • 1,978
2 votes
2 answers
615 views

Single sanitization callback for multiple fields

hope everyone is doing good! How can I have a single sanitization callback for multiple fields? Here is my code add_action('admin_init','settings'); function settings(){ add_settings_section('...
Shakti Goyal's user avatar
2 votes
1 answer
113 views

Performance of several get_option() calls

I am currently working on my first WordPress plugin. To save and output certain settings I use the native Settings API. Now the question arises, how performant are several calls of the get_option() ...
Jonas's user avatar
  • 159
2 votes
1 answer
168 views

Custom theme options Radio inputs not saving

Why isn't the following option getting saved? Have been searching for quite some time and can't get it to work. Settings code: add_settings_section( 'aa_myoption_section', null, null, 'mypage-...
Arg Geo's user avatar
  • 429
2 votes
1 answer
4k views

Get page slug in Admin menu

I'm trying to add a settings menu to my plugin, but within that menu, I can't get the 'page' slug. I'm basically doing something like this: add_action( 'admin_menu', 'MyPlugin_AddAdminMenus' ); ...
Jamin Grey's user avatar
2 votes
1 answer
586 views

What is the use of get_option method

I am a new learner of Wordpress plugin. recently I came across a method get_option(). When I pass the page parameter of add_settings_field() function then it outputs all the input fields (checkboxes) ...
fahad shaikh's user avatar
2 votes
1 answer
1k views

Stop the form of beign submitted on "Save changes" custom option page

Using the Settings API of Wordpress i want to try cancel the submission of the options when the validation/sanitization fails. Registering the settings: register_setting( 'mysettingspage', '...
Guillermo Teixeira's user avatar
2 votes
1 answer
1k views

Extend plugin options page

I had recently installed Post Views Counter plugin, which created an options page under the Wordpress Settings menu. Now, I'd like to extend plugin functionalities by adding few more options. It will ...
R99Photography's user avatar
2 votes
1 answer
886 views

Add a Custom Permalink option in the Permalink Admin Screen?

My plugin has several custom post types and the main one I want to make its permalink slug changeable. I would prefer to keep things clean and add that option in WordPress' Permalink admin screen, ...
Lazhar's user avatar
  • 183
2 votes
2 answers
329 views

Settings API - input always updates over validation

I am following a Wordpress book and am trying to create a plugin and have got an option page showing. In this page I have two text fields (which values are stored in one array). I am trying to add ...
thairish's user avatar
  • 213
2 votes
1 answer
1k views

When should I call add_settings_section and add_settings_field?

All of the examples I've seen for add_settings_section & add_settings_field have them being called on the admin_init action. This means that they're being called when loading every single admin ...
alnorth29's user avatar
  • 123
2 votes
1 answer
434 views

Am I using the flush_rewrite_rules function in the right place?

Hello dears I'm writing an admin panel for my new WordPress plugin base on the WordPress Settings APIs. I am defining a field for changing custom post slug from this admin panel. After the custom ...
saeed shabani's user avatar
2 votes
2 answers
4k views

Can't output do_settings_sections . Can't understand why

I've this code: /* Hook to admin_menu the yasr_add_pages function above */ add_action('admin_menu', 'yasr_add_pages'); function yasr_add_pages() { //Add Settings Page add_options_page( '...
Dudo1985's user avatar
  • 223
2 votes
2 answers
306 views

Can I use the different settings sections over different pages using the save options group?

I registered one options group with few different options sections. Each section is meant for different page. register_setting( // http://codex.wordpress.org/Function_Reference/...
Radek's user avatar
  • 595

1
2
3 4 5
9