Tag Info

Hot answers tagged

27

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


19

get_option('date_format'); get_option('time_format');


15

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' ...


8

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

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 ...


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

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: ...


7

Shortly after, I was able to find Otto's tutorial on the topic. WordPress 3.0: Multisite Domain Mapping Tutorial


6

Check the Option Reference page. The option gmt_offset returns an integer. For example, if the timezone is set to Easter time, gmt_offset should be -5.


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 ...


6

Use the page_for_posts option: <?php $page_for_posts = get_option( 'page_for_posts' ); ?> This will return the ID of the Page assigned to display the Blog Posts Index.


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 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

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 ...


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

Look at the declaration for the function: function add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() ) { } The last parameter takes your arguments and passes them to the callback function. Example from my plugin Public Contact Data foreach ( $this->fields as $type => $desc ) ...


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 ...


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

You can use is_plugin_active_for_network( $plugin )


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

You have the name parameters set to "$id" which means that they'll be things like "show_header_2" and such. You actually want them to be "second_section[show_header_2]" and similar instead, so that the array of settings is what you get back from the form.


5

You want get_option(). In particular: $date_format = get_option( 'date_format' ); $time_format = get_option( 'time_format' );


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

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

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

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 ...


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 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 ...



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