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
0answers
25 views

Manipulate javascript code from custom made admin page menu

I have javascript peace of code that I load into my custom template page. It is quiz application based on pure javascript and I keep the questions with answers inside the array object. The thing is ...
1
vote
1answer
166 views

redirect on theme switch - WordPress

How to redirect on theme switch to my theme option page, what is the best to redirect wp_redirect or wp_safe_redirect: here my code: <?php function sunset_add_admin_page() { //Generate Sunset ...
1
vote
1answer
578 views

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 ...
0
votes
1answer
423 views

settings api - add_settings_section not working

I'm building a plugin options page but I can't get the sections to appear. This is my code: ini.php: class Setup { public function init() { add_action( 'admin_menu', array( $this, '...
1
vote
1answer
347 views

When to use add_settings_section vs just register_setting?

I’m trying to add some options to my plugin but can’t understand why use add_settings_section when you could just use register_setting? I’m registering my settings page via add_menu_page like so: ...
1
vote
1answer
2k views

PHP Notice: Undefined offset: 0 in /wordpress/wp-includes/plugin.php and Register Settings API change

Errors of the following type encountered with a plugin running on WordPress v4.6.x and isolated to a register_setting() call. [02-Nov-2017 00:55:35 UTC] PHP Notice: Undefined offset: 0 in /wordpress/...
1
vote
1answer
357 views

Sections and tabs DRY - WordPress settings API

I have made a custom setting page containing 3 settings sections under 3 tabs. However I am a total noob when it comes to PHP and I feel like I have written a lot of unnecessary, repeated code. My ...
0
votes
2answers
565 views

Section Name for Menu in Theme Customizer

I browsed many articles to know the section Name of the "Menu" in the theme customizer. Here are the few resources that proclaim and identifies that the default section name is "nav" → https://...
0
votes
1answer
62 views

Theme Customize API Panel Concept

I am assuming while writing this post that I have a clear understanding of the theme customizer API: There are sections → Under which we have Panels → and under these panels we have Fields. I am ...
0
votes
2answers
159 views

Can I use register_settings and unregister_setting once the settings page has loaded?

I want to add few settings fields dynamically on settings page depending on user action. I am planning to register these new fields dynamically once user asks for it and show the corresponding HTML ...
1
vote
2answers
3k views

site identity section name?

In the customizer, the site identity section is missing a logo upload field. Adding such field is not a big deal: A field can be added, but I don't know the section name that is created in the core of ...
0
votes
1answer
28 views

Settings API and 'type' => 'font'

array( 'name' => 'textarea', 'label' => __( 'Textarea Input', 'wedevs' ), 'desc' => __( 'Textarea description', 'wedevs' ), 'placeholder' => __( '...
0
votes
1answer
51 views

settings api sub menu and data not populating

IN FUNCTIONS.PHP → locate_template( 'inc/admin/class.settings-api.php', true ); locate_template( 'inc/admin/o-functions.php', true ); o-functions.php code: <?php /** * Registers settings ...
0
votes
2answers
173 views

Update WP option by plugin

I wanted to set value of WP option (more specifically - 'admin_email') by using plugin, its option (plugin option) and update_option(). I tried using lines like below, but when plugin code contains ...
0
votes
1answer
156 views

How can I save a setting field with multiple checkbox options generated by a foreach loop on a custom wordpress admin page?

function ld_reports_plus_register_submenu_page(){ add_submenu_page( 'ld-reports-plus', 'LearnDash Reports Plus Settings', 'Report Settings', 'manage_options', ...
0
votes
2answers
1k views

add_settings_error on validating plugin options API

I am developing a plugin which uses options API. I defined a class that uses a function to sanitize the inputs, but when I submit the options form, It displays errors and info twice. And also I didn'...
0
votes
1answer
2k views

How to save plugin custom settings page fields

I want to implement a plugin which gets 2 fields in admin area and saves those in options as array I read the page Custom Settings Page but seems it doesn't describe how to save fields values in ...
1
vote
1answer
902 views

Plugin settings page checkbox not saving - one options array with sub array

I'm driving myself crazy here trying to get a checkbox to save on a plugin settings page. Right now, as a template, I'm working through the excellent example given here: Settings API with arrays ...
0
votes
1answer
55 views

Using a variable in name of dynamically-called helper function

I'm trying to add some functionality to my "Settings" page so that if a new season is added in a custom post's metabox, a new field is generated in Settings to allow users to add a title and ...
1
vote
1answer
174 views

Preserve old values on error in setting API

I am trying to preserve old value of form when it fails the validation defined in sanitize callback of register_setting. But it does not do so, instead it save the default values register_setting('...
0
votes
0answers
142 views

Add Logo Upload per Setting API

I have created a section field like this → // Logo Upload Option add_settings_field( 'logo_upload', // The ID (or the name) of the field 'Upload the Header ...
1
vote
1answer
447 views

Wordpress API Setting : the title of the section rendered not showing

Please see the below-mentioned code → function klogeto_initialize_theme_options() { // Let's introduce a section for the header options add_settings_section( 'header_section', ...
1
vote
0answers
124 views

Seeking clarity on data sanitization fields for settings textarea

Wanting to learn more about the settings page I wanted to be able to add code such as Google Adsense, Google Analytics and anything code related in a textarea within a custom settings page but I've ...
0
votes
1answer
916 views

flush_rewrite_rules() not working on updating Settings API

I'm providing a checkbox to my plugin Settings API to enable/disable certain Rewrite rules to my plugins CPT. I want to flush the rewrite rules when the specific setting is changed. So I did the ...
1
vote
1answer
518 views

Adding settings link to plugin doesn't work

I'm trying to add a "settings" link to my plugin on the plugins page. I used this code, which I found on various sites and also in the documentation, but it simply doesn't work (the link doesn't show)....
5
votes
2answers
11k views

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 ...
1
vote
1answer
36 views

Cannot display settings field

A plugin with a settings page does not render its settings field rma_base_url. No errors are thrown. Page is created in Settings, heading and submit button are rendered. Code: add_action('admin_menu'...
2
votes
0answers
20 views

Submit options page input values with decimals

I have an Options page for my plugin using Settings API. I want to submit the settings values with two places after decimals. Right now when I submit a number let's say: 35.00 it submits as 35. How ...
1
vote
2answers
83 views

What is the best way to save and retrieve Multiple rows of data with the Settings API?

I'm a beginner plugin developer. I need my plugin to save and edit multiple indexed sets of key/value pairs on my custom settings page and retrieve later them by their index on the Appearance>>...
0
votes
2answers
2k views

Add two input fields in add_settings_field

I want to add a third column consisting of an input textfield using the Settings API. Is this possible? function print_custom_field() { $value = get_option( 'my_first_field', '' ); $...
5
votes
2answers
5k views

Adding an html editor to plugin settings page

I am creating a plugin settings page using the register_settings() api. How can i create a html editor (wordpress default editor would be splendid) instead of just a text area. This is an example ...
0
votes
1answer
414 views

register_setting() for single site vs update_site_option() for mu

I'm looking at some code for an admin setting pages that goes something like this: //Save options for multisite if ( defined( 'MY_IS_NETWORK' ) && MY_IS_NETWORK && isset( $...
0
votes
2answers
160 views

remove_query_arg on options.php

I have a normal WordPress settings page. It POSTs to options.php. In options.php it uses wp_get_referer to redirect back to the page it came from. I need to use remove_query_arg to remove an ...
-1
votes
2answers
44 views

Wordpress Plugin default option

i'm working on a plugin and i got a checkbox with the setting code: register_setting('plugin551-setting-group', 'livechat_option'); I want it to be default true, the checkbox in the setting page ...
0
votes
0answers
588 views

add_option_{$option} action hook not being called

I'm trying to write some files to the server when the settings for my plugin are saved. I'm using the Settings API and a class that looks like - class AAPF_Admin { public function __construct() { ...
1
vote
1answer
668 views

Checkbox conflict in my custom plugin admin page

I'm trying to make a custom plugin for WordPress with an admin option page. In the option page, the user has to be able to check an option and if the checkbox is checked, the plugin should add a ...
1
vote
1answer
6k views

Set the checkbox as checked by default at options page

I'm making a theme settings page, so when I start coding the checkbox options, it works fine if the default value is unchecked. Here is the code: function classy_show_resume_section_callback () { ...
0
votes
2answers
1k views

Using WP Color Picker in Repeatable Fields

I wrote a repeater script that clones the last field group before it. My issue is that cloned WP Color Picker fields don't open the new color spectrum when clicked on but instead opens the color ...
1
vote
1answer
323 views

Prevent invalid or empty values from being saved to the database and retain the form field values upon error

I'm using the Settings API to save the settings of my plugin. I want a positive integer value from the settings field. register_setting( $option_group, $option_name . '_number', '...
0
votes
1answer
22 views

Wordpress Customazation API section in section

Heyo, I'm once again stuck with my Customizer API. How can I put my sections together in another Section/Folder (however you wana call it)? Like the standard Widget section: I have searched for ...
0
votes
0answers
80 views

User specific settings, limited by role

I generally know how create plugin settings, and limit a users access to these plugin's settings based on their role or capability. However in this case, I want the user to be able to create settings ...
0
votes
2answers
32 views

Access saved Options / Settings

For some reason, I am battling to make sense of everything. This is my code on paste bin: http://pastebin.com/dJxGS6x6 I want to be able to retrieve the options that are saved in the fields. This ...
4
votes
1answer
9k views

register_setting() vs add_option()

Im creating my first WordPress plugin. I added a custom function on plugin activation hook where I create new rows in wp_options table by using add_option() function. Now, I want to create a custom ...
1
vote
1answer
55 views

Wordpress setting API strucked

The entire day today I remained frustrated with few things. I am learning WordPress setting API from a Video Course offered by Team Tree House. I was watching Videos and writing the codes ditto, but ...
0
votes
1answer
39 views

Wordpress theme options Menu

I am struggling from last 1 Hour couldn't find why the menu is not appearing WordPress admin. <?php function wpt_add_theme_page() { add_theme_page( __('Theme Options','wpsettings'), ...
2
votes
1answer
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 ...
1
vote
0answers
61 views

WordPress custom setting page - add flashing message

I have a custom settings page for my plugin that has in the same page a submit button and a link like http://mysite.dev/wp-admin/options-general.php?page=my-page&action=update-cache&_wpnonce=...
1
vote
1answer
233 views

add_settings_section() order

I made on a custom theme for a client. For this theme I created a settings page so that the client could edit some variables to his liking. This part is working properly. For this same site, I ...
0
votes
0answers
76 views

Create settings field on button click

currently I facing the problem how to add an option field or setting dynamical with a button click. There are a few similar questions here but no one helped me respectively many where not answered. ...
1
vote
1answer
240 views

Why can't I use "%s" format value in the Wordpress function checked?

I try to safe a checkbox with the Wordpress settings API. For that I use the checked() function. First I make my field with add_settings_field() and pass a view parameters in an array to the callback ...

1 2
3
4 5
9