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
0 votes
0 answers
21 views

It is possible to pass $args that sent by add_settings_field() inside another function?

I'm trying To do my plugin Setting with OOP PHP when I'm Creating Setting Filed it sends $args so I can use it in their function, but when I call this function in another place it is for $args and it'...
user avatar
1 vote
0 answers
15 views

How to get specific setting by settings_fields()?

I am working on a plugin and on the settings page I have 2 settings and I want to show Only one setting "backgroundColor" so how should i do that? This is the code: <form action="...
user avatar
1 vote
1 answer
31 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 ...
user avatar
1 vote
1 answer
41 views

Displaying validation message in options-general.php

I have added a setting field in the general settings page. The field and the validation work, but the validation error message does not show. <?php add_action( 'admin_init', '...
user avatar
  • 111
0 votes
0 answers
14 views

How to register dynamic settings in WordPress Customizer?

I have been experimenting with the Customizer JS API to create Panels, Sections, Settings and Controls in the Customizer. Till now, I have been using the PHP API but decided to try the JS API for the ...
user avatar
0 votes
0 answers
20 views

How to save Setting pages data to the database?

I have created a setting page and I have a basic form in there I want to save its data in the database how can I achieve that. This is the HTML form: <label class=""><?php _e('...
user avatar
1 vote
1 answer
33 views

How to get bool with `get_option()` when already registered setting with type `boolean`

When I register a boolean setting using register_setting() I already pass the data type: register_setting( option_group: '…', option_name: '…', args: [ ...
user avatar
1 vote
0 answers
59 views

Settings API not saving values to database

Here is what I'm attempting to do: I have two fields called Client ID and Client Secret. I would like to save each individual item in the database as the following keys: instagram_client_id and ...
user avatar
  • 11
0 votes
0 answers
14 views

Add a field in my rest api

I am developing a small program that allows me to recover the header and the script of my wordpress articles in order to add it to a field of my Wordpress API. So for that I created a theme with a ...
user avatar
1 vote
1 answer
87 views

Saving plugin's settings in 1 field in json format

This is a question about performance. I've used the Wordpress Settings API in order to register fields and for a plugin that has 30+ fields that can cause a huge amounts of lines of code, in addition, ...
user avatar
  • 96
0 votes
0 answers
20 views

Multisite Equivalent of `register_setting`?

Working on converting a custom plugin to run in multisite. I want the settings to apply globally, not per-site. I've converted all of the get_option calls to get_site_option and the equivalent for ...
user avatar
  • 101
1 vote
0 answers
14 views

How I can Make two input field at add_settings_section

How I can make two input fields in the add_settings_section? I want the First Input type to be text The second Input type is the Select option and Inside Foreach and here is an exmple: function ...
user avatar
0 votes
0 answers
33 views

How to Save value from two inputs as array?

I don't know how to make two inputs as array and save them.. /* Add Settings Field */ add_settings_field( 'plugin-test', __('Style Seelct', 'plugin_name'), '...
user avatar
0 votes
1 answer
105 views

Settings API form - submit with AJAX

I'm creating a plugin where I have a dashboard that is done with Settings API. I'm trying to save data from that form via AJAX. Form: public function agy_dashboard_page() { ?> <form id=&...
user avatar
0 votes
0 answers
61 views

403 Error When Fetching Data from the Settings Rest Route for Non-Admin Users

I am using the /settings/ rest api endpoint to check plugin's options and display data based on these options in the Block Editor's sidebar (inside WordPress admin only). The code is working fine for ...
user avatar
  • 105
1 vote
1 answer
75 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('...
user avatar
1 vote
1 answer
116 views

Settings API - sanitize_callback is not called and it leads to an incorrect behavior

I am in the process of creating some options / the options page for my plugin. In the context of this I have only added two checkboxes so far to store boolean values. The creation, display on the page ...
user avatar
0 votes
1 answer
67 views

Call require_once form admin page with checkbox

I'm creating a custom WP plugin. Inside my main plugin file (functions.php) I've includes the following line of code so a second file (module_2.php) with additional code will be loaded: define( '...
user avatar
0 votes
1 answer
49 views

how to save checkbox data for custom setting?

I am creating one custom setting panel, my codes are function custom_text_field_html(){ $text = get_option( 'homepage_text' ); printf( '<input type="text" id="...
user avatar
  • 39
0 votes
1 answer
103 views

update_option_{$option} not working (do function after options are saved)

Below is my code for a simple plugin settings page. It works and saves an option ("EN", "CZ"). However, what I intend to do is run a function after the options get saved (see at ...
user avatar
0 votes
1 answer
44 views

Add description to custom plugin setting

Using add_settings_field(); i am able to add my custom setting: add_settings_field('AUTOPLAY', 'Auto Play', 'printAutoPlayCheckbox', 'my_settings'); function printAutoPlayCheckbox() { $id = '...
user avatar
  • 103
0 votes
1 answer
42 views

Settings API not saving

I've been through this code a hundred times and I just can't spot what's wrong with it. What it does: ✓ display options page, settings section, setting fields ✓ go through the sanitation function at ...
user avatar
0 votes
0 answers
466 views

Retrieve my custom settings in the settings/ API endpoint

I did read this post: Serialized settings in rest api and while I am actually convinced the answer is what I need, I cannot make it work. What I am trying to achieve is to get my own settings ...
user avatar
  • 153
0 votes
1 answer
286 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 ...
user avatar
2 votes
1 answer
31 views

Settings Page won't save

I've created a simple settings page with just one page, one section and two fields, it all displays just fine, but I can't for the life of me figure out why it won't save. There's either a typo or I'm ...
user avatar
0 votes
1 answer
47 views

Extend my plugin settings with hooks

I need to add a new options to my settings, the new filed shown in settings page but not saved. My add_settings_field callback: public function field_option_callback() { ?> &...
user avatar
  • 112
0 votes
0 answers
174 views

Whats the best practise on how to store json data from a custom settings page?

I'm creating my first Wordpress Plugin and want to let the user configure multiple urls which he can name and safe as "channels". I've set up a settings page and wanted to store the data ...
user avatar
0 votes
1 answer
553 views

register_setting & add_settings_error validation issues with multiple fields

I've been trying to use the Settings API for the first time. I managed to piece together a working example but I'm stuck on how to make multiple input fields required. Right now I have an admin ...
user avatar
  • 191
0 votes
2 answers
62 views

website is not loading home page (moving from one server to another server)

I have a wordpress site and i want same site with other domain name at same server. I moved all files and folders to new domains directory and also successfully moved database. My admin panel is ...
user avatar
0 votes
0 answers
8 views

Is it possible to have a global parameter page which allows to configure other plugins in the same place?

I have a wordpress mu installation which brings together several different sites for clients and I would like to provide them with a settings page to manage the settings of other plugins. In short, I ...
user avatar
  • 1
1 vote
1 answer
313 views

Callback is not called in add_settings_field() when passed as part of an array, but recognises that it's there. It's passed Class to Class using OOP

I am building a plugin, I created a new admin page and subpage, and inside that subpage, I want to add some Settings. That's why I'm building them using the Settings API. I am using Composer and ...
user avatar
2 votes
1 answer
39 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() ...
user avatar
  • 147
0 votes
1 answer
29 views

Multiple checkbox doesn't work in wordpress settings api

I was creating a checkbox of roles n WordPress. I successfully generated them but the checked function doesn't seem to work. Also, it is throwing this warning. Warning: Illegal string offset '...
user avatar
0 votes
1 answer
40 views

Custom plugin: how do I call a PHP file if settings option is set to true?

I am making a custom plugin with various functions that do different things. I have created a settings page using the Settings API to save data to the options db. That works fine. Now I'm trying to &...
user avatar
  • 279
0 votes
1 answer
96 views

Settings API: Setting default option via 'get_option' fails

All my options are stored in one array test_hs_options I have select list settings field ( test_hs_options['duration_months'] ) which stores the selected month (1-12). For this settings field, I would ...
user avatar
  • 593
0 votes
0 answers
139 views

Sanitization and validation input fields - Settings API

I'm creating a plugin and I am a quite newbie. So I have difficulty to properly validate and sanitize input fields. This is my code: register_setting( 'wp_banner_settings_fields', '...
user avatar
0 votes
0 answers
270 views

Warning: This page allows direct access to your site settings. You can break things here. Please be cautious!

I am currently developing a wordpress theme and it has 2 custom admin settings sub pages which is created with wordpress settings API. However, in first sub page i can apply settings and save without ...
user avatar
  • 13
0 votes
1 answer
13 views

Is there a standard technique or API for getting the site header image?

There is this function: get_header_image() which can be called from within WordPress. Is there a way to access this externally, i.e. from the API? The use case might be a header for an external RSS ...
user avatar
  • 455
0 votes
2 answers
600 views

How to save custom settings api fields with custom section fuction

I am creating wordpress theme on a single options page. I have customized the default do_settings_fields and do_settings_sections functions. my fields are displaying fine but when i am trying to save ...
user avatar
0 votes
1 answer
784 views

Wordpress theme options checkbox default checked state

I am developing a custom theme. I added a checkbox with the settings api. They all work except for the ones that are checked by default (checked="checked"). They do not save when they get ...
user avatar
  • 3
3 votes
1 answer
281 views

Setting 'autoload' to 'no' with Settings API

I've looked at the Settings API codex page, https://codex.wordpress.org/Settings_API, and I can't find anything related to setting autoload to no for any options using the Settings API. Is there any ...
user avatar
  • 33
0 votes
0 answers
27 views

Help to create the best plugin settings!

Can you help me about how to create the best WordPress settings for plugins? I have a custom setting page and I need to create some field with WordPress API. Actually I use this solution: https://gist....
user avatar
0 votes
1 answer
31 views

Wordpress theme settings not saving

I am trying to develop a theme. I am at the part of using the settings API. The code I use for the settings are as follows: In the example snippets I'm using variables to show the structure of my ...
user avatar
  • 3
1 vote
1 answer
239 views

Settings Page - Option won't save in database

I created an option in the options table and I am trying to save data from a custom settings page but I isn't saving. Below is my code adding the the fields and sections as well as their respective ...
user avatar
  • 147
0 votes
0 answers
46 views

WordPress Settings API Overrides My Previous Value

I have created the following custom menu page to save some data, I've included some repeatable fields inside the form. The problem that I have is that every time I click the submit button it overrides ...
user avatar
  • 13
0 votes
2 answers
266 views

WordPress Settings API Repeatable fields

I'm trying to find a way to add repeatable fields inside a custom admin page that I've made. Code: /*WordPress Menus API.*/ function add_new_menu_items() { add_menu_page( ...
user avatar
  • 13
2 votes
1 answer
523 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 ...
user avatar
  • 379
1 vote
1 answer
353 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,...
user avatar
  • 379
2 votes
1 answer
119 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-...
user avatar
  • 379
1 vote
1 answer
21 views

Customize format of settings

I am adding some settings to the "General" settings page: add_settings_section( 'foobar_settings_section', 'Foobar Options', [$this, 'foobar_options_callback'], 'general' ); $fields =...
user avatar
  • 113

1
2 3 4 5
9