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
1
vote
2answers
27 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 ...
1
vote
1answer
19 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
9 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
12 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
24 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
27 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
26 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
10 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
15 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
29 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
32 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
0answers
14 views

How to create a Settings Page with a list of existing taxonomies and allows the admin to associate a CPT with these?

I'm working on a plugin that includes a custom post type, by default this CPT will not be associated with any taxonomies. On the Settings page for the plugin I'm looking to show a list of the ...
0
votes
1answer
24 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 ...
0
votes
0answers
10 views

Settings API - registered fields not loaded

I have a problem with my plugin settings page. I've read on wordpress codex how to create an option page for wordpress plugins, I'm able to see the created page, but I'm not able to display the ...
0
votes
0answers
33 views

Correct way to use the Settings API

I'm learning how to add a settings page for my plugin. I've found this tutorial but I'm stuck to the add_settings_field and add_settings_section part. I have added my first setting field but I'm not ...
0
votes
0answers
17 views

add_settings_error - Settings API

How would I be able to return the saved get_option call when an empty field is set? Usage: When an user changes an input to empty, return the old value that's set using get_option('insta_id'); and ...
4
votes
1answer
33 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
21 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
30 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
41 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 ...
0
votes
0answers
75 views

insert post with wp_insert_post

EDITED: I'm trying to create a post when I submit my form from my custom themes page on the backend function simplyme_portfolio_icon_1() { $options = get_option( '...
3
votes
2answers
136 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
0answers
21 views

Dynamic form with Settings API?

I have a form in the admin-backend of a selfmade plugin, written the old fashioned style. So I'm not using the Settings API. Instead I've written a form, added nonces, wrote an endpoint checking the ...
0
votes
1answer
35 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
0answers
38 views

Cannot save with wp_dropdown_pages() in page options

I don't understand why, the custom select option works, but even when wp_dropdown_pages() is outputting the same exact HTML, it doesn't save as the select option does! I'm out of ideas :( Here's my ...
0
votes
1answer
89 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
81 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
44 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
43 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
47 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 ...
0
votes
1answer
33 views

Settings Fields not showing up in Submenu Page

I'm working on my first plugin. I am having difficulty getting the settings_fields function to display the results of the settings fields' callback functions. I've been studying the settings api, but ...
0
votes
1answer
51 views

Some fields in Settings API form are saving, others are not

I have a class used for a plugin's admin form, using the Settings API. It has a lot of fields, and some of those fields depend on already existing values in wp_options. The existing options determine ...
0
votes
1answer
58 views

Whitelisting items from custom options page

I'm a relative beginner, so anything that points me in the right direction is appreciated. I'm trying to whitelist options from the admin panel. I have an array in another file (item-whitelist.php) ...
0
votes
0answers
32 views

woocommerce plugin to query external vendors REST API

All, I am attempting to assist a friend with some research as to how much it efford /cost it would take to start a woocommerce site to sell ATV/Motorcycle parts and accessories. The site would be ...
0
votes
1answer
33 views

Display shortcode in text field with wordpress settings api

I'm trying to figure out how to display the output of a shortcode in a text field using wordpress settings api. My goal is to create a few shortcodes so that I can use one or the other along with some ...
0
votes
1answer
437 views

update_option_$option action not working as expected

I have a custom admin page that uses the settings API. Form submits to options.php. After submission I am attempting to do something in the background. I am hooking into update_option_$option to do ...
0
votes
0answers
27 views

add_settings_field on permalink page

I'm trying to add settings fields on the permalink page. For some reason, it's the only page that doesn't save the settings. To reproduce: <?php function add_settings_permalink() { ...
1
vote
1answer
226 views

Error: options page not found when I try to save the changes made in my settings page

I'm developing a plugin... everything was fine but suddenly when I try to save the plugin settings.. I found with the error that says the page options not found.. I was looking for some answer but ...
0
votes
1answer
195 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 ...
0
votes
0answers
24 views

Options API: Options does not save

My Settings wont save and I dont really know why. Here is my Code: <?php class STLI_New_Settings { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $...
0
votes
1answer
16 views

image on homepage disappeared due to change of permalink name

where to do this in Wordpress backend? I need to add the missing icons for "Smart living" and "Smart workspace" on homepage section - image is not in available in Media - It is in a section of the ...
0
votes
1answer
25 views

Integrating colorpicker into array field

I am using this code and i am trying to show a colorpicker onto an array field. Any ideas, how to do it? <?php class Smashing_Fields_Plugin { public function __construct() { // Hook ...
1
vote
1answer
38 views

Two Types of settings in WP - The Doubt

I was trying to learn some basics of wordpress plugin development, and I stumbled upon two types of settings. 1 add_settings_field( 'custom_title', esc_html__('Custom Title', 'myplugin'), ...
0
votes
1answer
30 views

Problem with checkbox in Settings API

I am trying to create a simple checkbox setting that toggles a section in a blog post on or off in a theme settings page. Unfortunately it's not saving the checkbox setting. I check the box and when ...
0
votes
1answer
13 views

input on custom settings page adds http://

how do I get the textbox to not add the HTTP://? function skype_callback() { $options = get_option( 'theme_social_options' ); $url = ''; if ( isset( $options['skype'] ) ) { $url ...
1
vote
0answers
70 views

The plugin does not save data

I'm trying to make the plugin save data, but I'm getting this error and I do not know why. The code: function ippluginmenu() { add_menu_page( 'ip configuración', 'ip', '...
0
votes
1answer
40 views

How to save the option's new values plus old value without overwrite old one

i have just tried this function myplugin_update_field_foo( $new_value, $old_value ) { if ($newvalue !== $oldvalue && !empty($oldvalue)) { $newvalue = array_unique( array_merge( $newvalue, ...
0
votes
1answer
42 views

Reading settings in the home page precisely home.php

/* ---------------------------------------------- */ /* Setting Post Limits on the HomePage */ /* ---------------------------------------------- */ if ( ! function_exists( 'the_post_limit' ) ) { ...
1
vote
1answer
123 views

Settings not set after calling register_setting()

I have a plugin with an activation hooked function. This function has to register 4 setting variables. I can't see why, but only the first setting is registered correctly, the last 3 are somehow ...
2
votes
1answer
153 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', '...