Is it possible ( or advisable) to allow open access to the new theme customizer for potential clients?

Just an idea: Make a user called ‘Guest’ and look up the user ID When redirecting your potential clients to the admin page, redirect to a script that’s logging in your clients as the guest user (Code #1) Add an WordPress action to disallow the user when logged in as ‘Guest’ and not on customize.php … Read more

Best practices for a Style/CSS based theme options page?

creating a custom script that writes to the static CSS file is a bad idea!!! you would need to regenerate the file each time you save any changes. a better solution would be to save all options in an array of options say for example: $MyCSS[‘background_color’] = #009988; $MyCSS[‘background_repeat’] = no-repeat; update_option(‘theme_settings’,$MyCSS); and that why … Read more

How To Add New Option Types To Option Tree?

What you’re trying to do can be accomplished without ever editing the core files in OptionTree. Add your custom option type functions to your themes functions.php and the following code, as well. /** * Filter to add custom option types. * * @param array An array of option types. * @return array */ function add_custom_option_types( … Read more

Adding a description to theme customizer controls

Here is one way to do it by extending the control you want to use. Below is an example where we extend the text control and add an extra description like the one seen here on the screenshot: function mytheme_customizer( $wp_customize ) { class Custom_Text_Control extends WP_Customize_Control { public $type=”customtext”; public $extra=””; // we add … Read more

Passing boolean values with wp_localize_script

Try this: $options = get_option( ‘theme’ ); wp_localize_script( ‘flexslider’, ‘flex_vars’, array ( ‘flex_auto’ => ($options[‘slide-auto’]) ? ‘true’ : ‘false’, ‘flex_animation’ => $options[‘slide-animation’], ‘flex_direction’ => $options[‘slide-direction’] ) ); Assuming slide-auto is the option you made a boolean. This script isn’t tested, I directly typed it in here.

How do I add settings to the Background Options Page?

The page content for custom backgrounds is created in wp-admin/custom-background.php. There is no action available where the fields are printed. To add new fields we have to print JavaScript into the page footer. The action is ‘admin_footer-appearance_page_custom-background’. To save those field values we have to hook into ‘load-appearance_page_custom-background’. The following example adds a new option … Read more

What are the advantages and disadvantages of Option Tree over the Customization API?

disadvantage using option tree: Your theme depend on other work as a core You need to always keep an eye for the plugin update ( which is really not good if you’re going to use it in premium theme ) If you’re going to integrate it in your theme, then when there is update from … Read more

How to Use Checkbox in Custom Option Page Using The Setting API

Have a look at: The Complete Guide To The WordPress Settings API (Part 8: Validation, Sanitisation, and Input II): add_settings_field( ‘Checkbox Element’, ‘Checkbox Element’, ‘sandbox_checkbox_element_callback’, ‘sandbox_theme_input_examples’, ‘input_examples_section’ ); function sandbox_checkbox_element_callback() { $options = get_option( ‘sandbox_theme_input_examples’ ); $html=”<input type=”checkbox” id=”checkbox_example” name=”sandbox_theme_input_examples[checkbox_example]” value=”1″” . checked( 1, $options[‘checkbox_example’], false ) . ‘/>’; $html .= ‘<label for=”checkbox_example”>This is an … Read more