Environment Specific Options Token

See the filter reference on the codex. In particular, note that you can use the form option_$foo to filter just a specific option key. So if you wanted a filter specific to the siteurl option, you could do: add_filter( ‘option_siteurl’, ‘my_url_filter’ );

How can you upload an image from within a settings page?

WordPress provides a convenient function for just this purpose: wp_handle_upload(). Assuming that you already have the appropriate file form field in your settings page, and that you’re using register_setting() for your options, and therefore already have an options validation callback, simply handle the file form field data using wp_handle_upload(). Here’s an example: <?php // Validate … Read more

Outputting results from select box option in options panel

I use the same options framework plugin and this is how I specify a select menu using this framework; $test_array = array( ‘one’ => __(‘One’, ‘options_framework_theme’), ‘two’ => __(‘Two’, ‘options_framework_theme’), ‘three’ => __(‘Three’, ‘options_framework_theme’), ‘four’ => __(‘Four’, ‘options_framework_theme’), ‘five’ => __(‘Five’, ‘options_framework_theme’) ); $options[] = array( ‘name’ => __(‘Select a Tag’, ‘options_check’), ‘desc’ => __(‘Passed … Read more

Making a configurable field translatable

What I have seen in translation plugins (qTranslate, WPML, Multilingual Press) are two approaches. One is qTranslate’s (and the defunct xLanguage): use one field (one for title, other for content, etc) to hold all translations. And then, in the front end, decode its output according to the actual language. <!–en–>English<–:–><!–es–>Español<–:–> In the back end, the … Read more

Custom editor field displaying HTML in Visual editor

I found out I needed to add html_entity_decode() around the value so my final code is… /** * Add Copyright text to general settings menu */ $custom_general_settings = new FD_Custom_General_Settings(); class FD_Custom_General_Settings { function __construct() { add_filter(‘admin_init’, array(&$this , ‘register_fields’)); } function register_fields() { register_setting(‘general’, ‘footer_text’, ‘esc_attr’); add_settings_field(‘footer_text’, ‘<label for=”footer_text”>’.__(‘Footer Text’ , ‘footer_text’ ).'</label>’ , … Read more

wp_options table value

The only really interesting (and very important) part of the 3rd query is this: ‘project_location_children’, ‘a:7:{i:22;a:1:{i:0;i:23;}…etc…}}’ The a:n:{i:n; etc } stuff is a serialized PHP array. WordPress – for some historical reason – keeps track of term children in one option entry per taxonomy term. The painful thing is, that a lot of people don’t … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)