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
1answer
12 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 &...
0
votes
1answer
15 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 ...
0
votes
0answers
15 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', '...
0
votes
0answers
11 views

Data passed to the Sanitization function is empty

The seemingly related question offered not much help except for the first answer saying it could be Nonce related, but it doesn't help in finding out how...? (neither do I understand the documentation)...
0
votes
0answers
17 views

Wordpress Settings API using angularJS

i'm trying to update Wordpress General Settings page with AngularJS with a $http.post $scope.update = function(genSet){ $scope.generalSettings = angular.copy(genSet); $http.post('options-...
0
votes
0answers
28 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 ...
0
votes
0answers
43 views

Update File using Settings API init_form_fields

I have an existing plugin(payment gateway for woocommerce) that goes about generating settings as follows: In the constructor, It does the following: $this->init_form_fields(); $this->...
0
votes
1answer
10 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 ...
0
votes
2answers
96 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 ...
0
votes
1answer
70 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 ...
1
vote
1answer
37 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 ...
0
votes
0answers
20 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....
0
votes
1answer
14 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 ...
1
vote
1answer
25 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 ...
0
votes
0answers
40 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 ...
0
votes
2answers
48 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( ...
1
vote
1answer
41 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 ...
1
vote
1answer
51 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,...
2
votes
1answer
58 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-...
0
votes
0answers
21 views

Custom theme options display specific section and saving problem

I have a custom theme options page with multiple sections and fields. What I cannot figure out is how to display specific sections at specific places and in addition if there are 2 or more sections ...
1
vote
1answer
20 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 =...
1
vote
2answers
381 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 ...
0
votes
0answers
39 views

How to add a setting to a custom control defined in the parent theme for use in the customizer?

I am using the Spicepress Pro theme and its child theme Stacy. It provides a settings page in the customizer to customize the slider on the homepage. Every Slide is customized by a custom class that ...
0
votes
0answers
14 views

Multi select plugin options: Only one value is saved [duplicate]

At the moment I'm stuck with a multi select option for my plugin. I took one of my working select callbacks and added multiple="multiple" to it. Doesen't matter what I'm selecting only the option ...
0
votes
1answer
37 views

How to save Checkbox-Options in Plugin Options Page

First of all: I am really a newbie. So I used a template for my options page and tried to customize it (works pretty good so far). About my plugin: It creates to post types and some meta boxes ...
0
votes
0answers
45 views

Image upload in custom theme settings page

I need to upload a logo image and set other options on a custom settings page. I can't retrieve the URL and upload the custom image, what is wrong with my code? <?php /*** New menu item ***/ ...
1
vote
2answers
25 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 ...
1
vote
2answers
32 views

Most efficient way to use classes to create admin pages using Settings API

I've built a class which creates admin pages with the Settings API. I'm trying to optimize it to run only where I need it. Most of the examples and tutorials I've seen say to instantiate it from the ...
2
votes
1answer
380 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' ); ...
0
votes
0answers
11 views

Add countdown to options page using date input and settings API

I'm using the Settings API with some troubles that I'm solving thanks to the help of this community. I want to add a countdown to a page but I'm not sure how to proceed. I've a checkbox in my custom ...
0
votes
0answers
38 views

register_setting not save checkbox

To understand the Settings API I'm creating a custom settings page for a custom plugin. I have some trouble to save the settings, I have a single checkbox to test if the code works well, but if I ...
1
vote
1answer
357 views

Implement toggle switch for theme options in settings API

I love to work with bootstrap for the forntend part of my projects, but this time I need to create a theme settings page to manage the activation of some template parts of a custom theme. I want to ...
2
votes
0answers
72 views

Callback function is being called twice

I have registered a setting, added a section in my plugin. Inside that section, multiple inputs (checkboxes) fields have been added using the add_settings_field method. This method has a callback ...
2
votes
1answer
32 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) ...
0
votes
0answers
21 views

Why are my fields not saving to the settings API

So I create a settings page on my Wordpress site, yesterday it was working fine but for some reason now when i click save none of the values are being saved? Are there any issues with the below code? ...
0
votes
0answers
18 views

How do I give the user the option to toggle the sidebar to the left or right side of the theme?

I know how to create a settings page with add_menu_page, and add a drop-down menu with two options using add_settings_field. What I need to find out is how do I then allow the user to save their ...
0
votes
0answers
41 views

Settings API issue with tabbed navigation

I've created a subpage of WooCommerce and I am trying to add tabbed navigation. The tabs work, but I can't get the fields setup properly so they display correctly. They all display regardless of my if ...
1
vote
1answer
37 views

settings_fields doesn't appear to be running

I'm creating a settings page for a plugin. It adds: a submenu item registers a setting adds a section adds a field and then renders the page/section/field. It is all pretty straightforward, only "...
0
votes
1answer
111 views

Assign value to custom checkbox using get_option()

I have a bootstrap 4 switch that is a custom checkbox input type introduced from the 4.3 version. I want to integrate it in a custom option page and assign to it a default value when my option page is ...
4
votes
1answer
35 views

Where to store some per-template preferences?

I'm in the midst of reworking a site and in trying to make the backend as friendly as possible I'm trying to avoid hard-coding some of my options in template files. I've got a few archive pages where ...
1
vote
0answers
29 views

Show admin notice on incorrect value on form field

So I'm still learning about the Settings API on WordPress and can't seem to figure out how to handle admin notices on an empty database and then have validation. Registration: function ...
1
vote
0answers
48 views

Updating Woocommerce Settings API when Wordpress Settings API saved and vise versa

Working on a woocommerce gateway and i am trying to make it in such a way that when users saved changes on the woocommerce payment gateway settings page, some values are updated in the admin setting ...
0
votes
1answer
94 views

How to call a WP Class inside my theme

I wrote a WP theme using namespaces and autoload. Everything went smooth until I started to use WP classes which I understand of course because I understand how namespacing works. My question is, is ...
3
votes
2answers
381 views

Nonce in settings API with tabbed navigation

I'm rewording this because, as it's correctly been pointed out, the original post was "woefully inadequate." I made a plugin which has tabbed views for the various settings. It's based on this ...
0
votes
1answer
44 views

Multiple plugins linked to same settings page

I have several custom plugins that do very different things but I use on each of them (or almost) the Jenkins and Mantis Rest APIs. For the moment, the API settings (as URL or tokens) are hard coded ...
0
votes
1answer
327 views

Hide / show settings field based on other field's value

I created a class to manage my plugin's settings, this works okay apart from one thing - I would like to hide fields lal_login_text, lal_logout_text and lal_account_text together with their labels ...
0
votes
1answer
156 views

Settings page - can't change checkbox to unchecked

I thought that I got my plugin settings finally working with defaults, without overriding db with them, but it's only the case for acau_update_delay which is numeric value and not for the checkboxes. ...
0
votes
1answer
46 views

Default settings aren't used

I use Example #2 from this source: https://codex.wordpress.org/Creating_Options_Pages Using a class, it creates settings page. I can access values like this: $options['id_number'] Or remove ...
0
votes
1answer
159 views

How do I render content from a wp_editor in a plugin setting field?

I have a plugin setting that uses wp_editor() to handle the input and will get echoed as part of a shortcode. Everything is working great on the admin side but when I echo the output on the client ...
2
votes
1answer
50 views

plugin development: storing language specific options

I'm currently rewriting a little plugin that shows visitors a small info text. This plugin is German only so far and so I want to add multi language support as I am working on a page that should be in ...

1
2 3 4 5
9