Tag Info

Hot answers tagged

22

if you need the gmt_offset then <?php echo get_option('gmt_offset'); ?> this will give you an integer like 2 or -2. and if you need the timezone string use <?php echo get_option('timezone_string'); ?> this will give you a string like America/Indianapolis


14

if you look at the do_settings_sections function more specifically the line 1164 where the callback function is being executed : call_user_func($section['callback'], $section); you can see that the $section array is being passed to the callback function, so you can identify the callback by the $section['id'] hope this make since. Update here is an ...


8

better is, you use the functions of WP for this, a example for multilanguage: add_action( 'admin_enqueue_scripts', 'add_scripts' ); function add_scripts($where) { wp_localize_script( 'post2media', 'post2media_strings', $this->localize_vars() ); } function localize_vars() { $strings = array( 'btntext' ...


7

You're absolutely right that you can pass reusable form field markup to add_settings_field(). The trick is to define the data type for each setting, and then pass the same callback to each call to add_settings_field(). Within that callback, you simply add a switch that includes cases for each data type. Here's how I do it in Oenology: First, I dynamically ...


7

Joining two answers(*), I've done a plugin to add a custom meta option when registering a new site (front and back end) and display its value in a column in the Sites screen. Multisite Categories ... (*) code references 1 - WordPress + Multisite: How to add custom blog options to Add New Site form in Network Admin?, by @dennisg 2 - Multisite: How to ...


7

Never de-register core-bundled scripts in the WP-Admin. You shouldn't do it on the front end, either, unless you really, really know what you're doing. But especially in the WP-Admin, just use the core-bundled scripts. Also, when you use core-bundled jQuery UI, WordPress already knows that jQuery is a dependency. Just change the first callback to this: ...


6

There is the function is_plugin_active() which can be used easily for this check, but what if the user decides to change the folder name of the plugin? Simply put, you're doing it wrong. If you're making extensions for a plugin, then you should provide hooks in the "parent" plugin for those addons to hook into and change things. Take tabs, for ...


6

That's because your options are stored as a serialised array, in one row with name XX_theme_settings. To update one option, you would still need to retrieve the existing settings, ammend the appropriate value and update all options in your array together. For example: $my_options= get_option('XX_theme_settings');//retrieve all options ...


6

The Multisite signup process is not an easy thing to tweak. It does have many hooks to play with, unlike other processes, but they don't seem to come together too well for heavy customization, so I understand your frustration. If I understand correctly, it's not that complicated to achieve what you want, although it cannot be a one-step solution without ...


6

The Options API is primarily a database API, allowing you to get and store values in the options table of the database easily. The Settings API is an interface API. It allows you to build settings screens in a manner that will adapt with future changes to the WordPress interface, as well as to handle security (nonces and whitelisting and validation and ...


6

My point of view is that main purpose and benefit of Settings API is structure. It helps to keep complex settings setups: orderly (logic of registration and sections); secure (nonces, validation callbacks); extensible (hooking into another page or allowing to be hooked into). As with any such structural overhead it benefits more complex use cases and ...


5

If you use callbacks properly, there's no need for all the redundant code. Here's how I implement the Settings API, in a way that is completely scalable. Advantages (among other things): The Settings API forces sanitization of untrusted user data. The Settings API forces options to be registered as an options array, resulting in a single wp_options DB ...


5

You just need to register_setting() on your setting and it will be saved automatically. See the Settings API for more info. Here's a complete example: function spw_cb() { if( !($value = get_option('sprockets_per_widget')) ) { $value = 7; } ?> <input type="text" size="3" name="sprockets_per_widget" value="<?php echo $value; ...


5

The problem is they are getting saved... it's just you're always saving the defaults! $ev_options = ev_theme_settings_defaults(); if ( false === $ev_options ) { $ev_options = ev_theme_settings_defaults(); } update_option( 'theme_evolutionary_options', $ev_options ); And that's running on every page load (it's hooked to the action after_theme_setup). ...


5

Yep you are missing something, On your validate_options function you need to: get an array of all existing options. update only the options your Submenu page handles. return that array. So something like: function validate_options($input){ //do regular validation stuff //... //... //get all options $options = get_option(THEMENAME . ...


5

There's a wpmu_options action that lets you append more HTML on the Network Settings page. If you want to add your own sub-menu/page to the Settings parent menu: add_action('network_admin_menu', 'add_my_netw_settings_page'); function add_my_netw_settings_page() { add_submenu_page( 'settings.php', 'Co za asy', 'Co za asy', ...


5

First off, check if the theme is available in wordpress.org themes: http://wordpress.org/extend/themes/ If it's not, find the name of the theme developer and contact them. Many developers of wordpress.com themes are happy for people to use their themes on self-hosted WordPress blogs. The developer's name and contact details can be found by looking at ...


5

As a reference To create network or global settings, you need to do the following Add a settings page add_submenu_page( 'settings.php'... # cf options.php for blog level` Add a global option add_site_option($key,$value) Update a global option update_site_option($key,$value) Get a site option get_site_option($key) Global settings are saved to the ...


5

In addition to what Joseph suggested, you can also define the upload path in the wp-config.php file like this: define( 'UPLOADS', 'wp-content/'.'files' ); If you'd like it outside the wp-content folder, specify path like this: define( 'UPLOADS', ''.'uploads' ); For uploading to a folder like example.com/images, use this code: //Custom upload path ...


4

This is a little late, but I had to figure out the other part of this question on my own and thought I would share. To create a default menu and place it into a theme location, you will need a pre-existing location in the theme, and you will need to ensure any pages you link in your menu are also created already. In your theme's function.php, register any ...


4

for reference, see also: How to use Multiple-Domains in one Multi-Site Installation? 301 Redirects for posts, category, pages from original domain to sub-domain of multisite Full Domain Mapping with WP3 in Multiuser Mode


4

The default favicon location on your server gives a 404: http://www.steve.doig.com.au/favicon.ico Your blogs homepage source-code related to linking to another location is: <link rel="icon" type="image/png" href="http://www.steve.doig.com.au/wordpress/wp-content/themes/grid-focus-public-10/images/favicon.ico"> Note: The file suffix is .ico ...


4

Ok, I think I have an idea what is going on. The list of notices to display is retrieved by get_settings_errors() ( source ). This function reads notices from global $wp_settings_errors unless there is settings_errors transient set, which trumps global var. When settings are saved there is check for no setting errors and if so Settings saved. notice is ...


4

Hm, core WP files are usually die properly if opened directly. It probably slipped developers to include check in this one or something. The simple ways to fix this (and not really WP-specific) would be to: configure PHP on server to not display errors by default; restrict access to file with .htaccess or other means.


4

The reason is that if you are on page 1, the data that is posted to be saved is an array of the form: XX_theme_settings=array('XX_Option1' =>'input1','XX_Option2'=>'input2',...) and contains no data from page 2. This is because the input from page 2 is not posted with it (since it wasn't in the same <form> - it's not on the page). Thus when ...


4

have you ticked the 'Description' box under 'Show advanced menu properties' in the 'screen options' tab in the appearance -> menus page? and have a look at this related post: http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output


3

If you have an options page (which should be inside one form), then all data is sent from that form, regardless of whether or not the option has been changed. The array received for validation is the data received from (your part of) the form. If the data is 'empty' it is because the data wasn't sent. Normally this would be because the user has deliberately ...


3

If you configure your Theme settings code properly, the Theme will work fine without having any user-defined settings. The key is to define a defaults array, and anytime you need to output a Theme option, run an array_merge() on the defaults array, and the theme's options DB entry. Something like this: <?php global $mytheme_options; $mytheme_options = ...


3

If the setting in question is $setting, and is a checkbox type, you validate it like so: <?php $valid_input[$setting] = ( isset( $input[$setting] ) && true == $input[$setting] ? true : false ); ?> In this case, $input is the form data passed to the validation callback, where $input is an array-of-arrays. The validation method is known as ...


3

if you are using the Settings API then you can use your own php inside the $sanitize_callback of your register_setting and return the value you want to save after doing your "more complex handling".



Only top voted, non community-wiki answers of a minimum length are eligible