20

The answer that yes, the theme_mod functions will be slower, but not significantly, and the benefits outweigh the differences. Theme mods are stored as options. So, in essence, the theme_mod functions are wrappers around the options functions. First, understand that theme_mod settings are stored as an array in a single option, keyed to the specific theme ...


10

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() { $...


9

The base paradigm in WordPress is The Callback Handler. Actions, filters, widgets, metaboxes and so on … everything runs by registering specific callback handlers for some triggers. This is not always the most elegant way, but the one every beginner must learn, so stick to that paradigm, whenever you’re not sure what to do. So offer four actions: do_action(...


9

The problem here is that you don’t allow PHP to read more than one value, because all values use the same name site_options[categorychoice], so they overwrite each other, and the last one wins. You need more brackets. Set the name attribute of your select element to site_options[categorychoice][], and all values will be read by PHP.


9

Best place is the uploads directory - it'll be writable by the server, and it's the defacto directory for storing any user-generated/uploaded files: $dirs = wp_upload_dir(); $path = $dirs['basedir']; // /path/to/wordpress/wp-content/uploads


9

Try nav_menus instead of menus with remove_panel() function mytheme_customize_register( $wp_customize ) { //All our sections, settings, and controls will be added here $wp_customize->remove_section( 'title_tagline'); $wp_customize->remove_section( 'colors'); $wp_customize->remove_section( 'header_image'); $wp_customize->remove_section(...


8

For anyone who comes across this after WordPress 4.0 is released, custom controls are no longer necessary. This functionality is baked right into WordPress: https://core.trac.wordpress.org/ticket/27981.


8

For anyone still interested in customizer export/import functionality, we just released a new plugin on the wordpress.org repo that does exactly that! https://wordpress.org/plugins/customizer-export-import/ Don’t hesitate to let us know what you think!


8

These classes are generated by WordPress. For instance, if a user inserts an image in his post and says it must be aligned right, WP will generate code like this in the post: <img class="alignright" src="..."> Now, if your theme doesn't define the alignright class, the image won't be aligned right and the user won't get what he expects. You can ...


6

wp_add_inline_style() is intended to add additional CSS to an existing stylesheet. The idea is that you may need to dynamically alter the stylesheet - for instance, you have user-selected colours associated with categories and you would like to colour each category's title accordingly. You can't hardcode this since the colours in question are not known, but ...


6

Theme mod settings are stored as a single database entry in the options table. For example, If I look in my wp_options table in a localhost install, and find the key of theme_mods_twentythirteen, then this is the content of it: a:3:{s:16:"header_textcolor";s:6:"220e10";s:12:"header_image";s:84:"http://localhost/wptrunk/wp-content/themes/twentythirteen/...


6

Ok. Here's the correct bit of code, I got solution with: <select multiple="multiple" name="site_options[categorychoice][]"> <?php $option = get_option('site_options'); ?> <?php $args = array( 'orderby' => 'name', 'parent' => 0, 'exclude' => 1 ); $categories = get_categories( $args ); foreach ($...


6

The correct way to disable nav menus in the customizer is via the customize_loaded_components filter as documented on its hook reference page: /** * Removes the core 'Menus' panel from the Customizer. * * @param array $components Core Customizer components list. * @return array (Maybe) modified components list. */ function wpdocs_remove_nav_menus_panel(...


5

I'm the lead dev for Redux Framework. This is because you use the same function name. You must change the add_another_section name to something less common. Otherwise you'll always get an error. That's unfortunately a limitation of PHP. One name per function per instance.


5

I think the problem is that you are using uppercase letters in the options id: footer-nav1_URL Try instead: footer-nav1_url In general you should avoid using uppercase letters in options names in WordPress.


5

Edit: Updated with the added context from your comment. You could do this with a custom Page template. In your theme, create a new file. In this example, my theme will be "mytheme2015," my new file is "template-holiday-card.php": in wp-content/themes/mytheme2015/template-holiday-card.php <?php /** * Template Name: Holiday Card */ Now, once you have ...


5

It depends on the theme itself. A theme may store some data in the database. For example, a theme may have an option called "Social Accounts" section in settings page and a field "Facebook Page URL" in it. If you fill the field and save settings, it will store this value to database. But, as a common practice, these type of data should be removed when you ...


5

Add Section to Theme Customizer: $wp_customize->add_section( 'parsmizban_options', array( 'title' => __( 'Theme Options', 'parsmizban' ), //Visible title of section 'priority' => 20, //Determines what order this appears in 'capability' => 'edit_theme_options', //Capability needed to tweak 'description' => __('...


4

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


4

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( $types ) { ...


4

I have no idea how the framework actually stores its options, but I guess it uses the name redux_demo, not redux_demo[10]. If the option is an array, you can access the element 10 like this: $redux_demo = get_option( 'redux_demo' ); if ( ! empty ( $redux_demo[ 10 ] ) and 1 === $redux_demo[ 10 ] ) { print '<h1>Text</h1>'; }


4

You can use PHP's stripslashes() command: <?php echo stripslashes( get_option( 'myOption' ) );


4

never* execute code outside of hooks as you are more likely to call a function or use a variable before they were declared and initialized. your code should be function css() { if (ot_get_option('css', false) != false) { echo'<style>'.ot_get_option('css').'</style>'; } } add_action( 'wp_head', 'css', 100 ); *...


4

The only directory with guaranteed write access is the upload directory. Everything else might be protected. Nowadays, we deploy sites with Composer, keep everything under version control and create completely new sites with each deploy in order to be able to roll back the deployed site. That means that the directory will be created completely new with ...


3

The description argument adds a description under the control. If you want to add something above the control title, like an extra header or something, you can use the customize_render_control_{id} action. For example, if you wanted to add a button above a control with the id hi_shawn you could do this: add_action( 'customize_render_control_hi_shawn', ...


3

The options.php in question is WordPress's /wp-admin/options.php file. Your code's hidden action & page_options fields tell options.php what to do (update) and with what (options_value). Reference Trac page for options.php


3

I was having a similar issue, and it turned out that setting 'type' => 'option' for add_setting was the cause. Removing this solved my problem, and below is what I am currently using and it works just fine. $wp_customize->add_section('footer_social_media_section' , array( 'title' => __('Footer Social Media', 'dd_theme'), 'priority' =&...


3

There's a bug(ish) report regarding this here: http://make.wordpress.org/themes/2011/07/01/wordpress-3-2-fixing-the-edit_theme_optionsmanage_options-bug/ You can use a filter to modify the theme page capability. First you'll want to edit your register_setting() calls to look like this: register_setting( 'map-options', 'map_zoom' ); register_setting( 'map-...


3

The settings API can be puzzling ;-) Replace: do_settings_sections( 'ia_section_id' ); with do_settings_sections( 'srchild' ); to display your defined settings section. The general usage is: do_settings_sections( $page ); where: $page (string) (required) The slug name of the page whose settings sections you want to output. This should match ...


3

get_theme_mod is just a wrapper around get_option. In theory because it is another layer of abstraction it will work slower but in practice the difference should not be big enough to be noticed by a human. Actual speed differences can be caused if you have some slow code hooked on the theme_mod hooks.


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