/** * Register our customizer options */ public function action_customize_register($wp_customize) { $this->require_controls(); // Static front pages aren't commonly used $wp_customize->remove_section('static_front_page'); // Register the settings $settings = array('[site_blurb]' => array('type' => 'option', 'sanitize_callback' => 'wp_filter_nohtml_kses'), '[home_template]' => array('type' => 'option', 'sanitize_callback' => 'sanitize_text_field'), '[num_posts_home]' => array('type' => 'option', 'sanitize_callback' => 'absint'), '[homepage_bottom]' => array('type' => 'option', 'sanitize_callback' => 'sanitize_key'), '[single_social_icons]' => array('type' => 'option', 'sanitize_callback' => 'sanitize_key'), '[fb_verb]' => array('type' => 'option', 'sanitize_callback' => 'sanitize_key'), '[footer_layout]' => array('type' => 'option', 'sanitize_callback' => 'sanitize_key')); foreach ($settings as $setting => $options) { $wp_customize->add_setting($this->get_setting_key($setting), $options); } // Site description $wp_customize->add_control(new Largo_WP_Customize_Textarea_Control($wp_customize, 'largo_site_description', array('label' => __('Site Description', 'largo'), 'section' => 'title_tagline', 'settings' => $this->get_setting_key('[site_blurb]')))); /** * Homepage layout */ $wp_customize->add_section('largo_homepage', array('title' => __('Home Layout', 'largo'), 'priority' => 20)); $home_templates = array(); $home_templates_data = largo_get_home_layouts(); if (count($home_templates_data)) { foreach ($home_templates_data as $name => $data) { $home_templates[$data['path']] = array('img' => $data['thumb'], 'label' => $name, 'desc' => $data['desc']); } } $wp_customize->add_control(new Largo_WP_Customize_Rich_Radio_Control($wp_customize, 'largo_home_template', array('label' => __('Body', 'largo'), 'section' => 'largo_homepage', 'settings' => $this->get_setting_key('[home_template]'), 'type' => 'rich_radio', 'choices' => $home_templates))); $post_choices = array(); for ($i = 1; $i <= 20; $i++) { $post_choices[$i] = $i; } $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'largo_num_posts_home', array('label' => __('Number of Posts', 'largo'), 'section' => 'largo_homepage', 'settings' => $this->get_setting_key('[num_posts_home]'), 'type' => 'select', 'choices' => $post_choices))); $wp_customize->add_control(new Largo_WP_Customize_Rich_Radio_Control($wp_customize, 'largo_homepage_bottom', array('label' => __('Bottom', 'largo'), 'section' => 'largo_homepage', 'settings' => $this->get_setting_key('[homepage_bottom]'), 'type' => 'rich_radio', 'choices' => array('list' => array('label' => __('List', 'largo'), 'img' => get_template_directory_uri() . '/lib/options-framework/images/list.png'), 'widgets' => array('label' => __('Widgets', 'largo'), 'img' => get_template_directory_uri() . '/lib/options-framework/images/widgets.png'), 'none' => array('label' => __('None', 'largo'), 'img' => get_template_directory_uri() . '/lib/options-framework/images/none.png'))))); /** * Single Post Options */ $wp_customize->add_section('largo_single_post', array('title' => __('Single Post', 'largo'), 'priority' => 24)); $services = array('facebook', 'twitter', 'print'); $service_settings = array(); foreach ($services as $service) { $service_settings[$service] = $this->get_setting_key('[article_utilities][' . $service . ']'); $wp_customize->add_setting($this->get_setting_key('[article_utilities][' . $service . ']'), array('type' => 'option', 'sanitize_callback' => 'sanitize_key')); } $wp_customize->add_control(new Largo_WP_Customize_Multi_Checkbox_Control($wp_customize, 'largo_article_utilities', array('label' => __('Social Icons to Display', 'largo'), 'section' => 'largo_single_post', 'settings' => $service_settings, 'type' => 'multi_checkbox', 'choices' => array('facebook' => __('Facebook', 'largo'), 'twitter' => __('Twitter', 'largo'), 'print' => __('Print', 'largo'))))); $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'largo_single_social_icons', array('label' => __('Display Social Icons', 'largo'), 'section' => 'largo_single_post', 'settings' => $this->get_setting_key('[single_social_icons]'), 'type' => 'checkbox'))); $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'largo_fb_verb', array('label' => __('Facebook Button Text', 'largo'), 'section' => 'largo_single_post', 'settings' => $this->get_setting_key('[fb_verb]'), 'type' => 'select', 'choices' => array('like' => 'Like', 'recommend' => 'Recommend')))); /** * Footer layout */ $wp_customize->add_section('largo_footer_layout', array('title' => __('Footer Layout', 'largo'), 'priority' => 25)); $imagepath = get_template_directory_uri() . '/lib/options-framework/images/'; $wp_customize->add_control(new Largo_WP_Customize_Rich_Radio_Control($wp_customize, 'largo_footer_layout', array('label' => false, 'section' => 'largo_footer_layout', 'settings' => $this->get_setting_key('[footer_layout]'), 'type' => 'rich_radio', 'choices' => array('3col-default' => array('label' => __('3 column large center', 'largo'), 'img' => $imagepath . 'footer-3col-lg-center.png'), '3col-equal' => array('label' => __('3 column equal', 'largo'), 'img' => $imagepath . 'footer-3col-equal.png'), '4col' => array('label' => __('4 column', 'largo'), 'img' => $imagepath . 'footer-4col.png'))))); /** * Colors */ if (Largo()->is_less_enabled()) { $wp_customize->add_section('largo_colors', array('title' => __('Colors', 'largo'), 'priority' => 30)); $field_groups = Largo_Custom_Less_Variables::get_editable_variables(); $colors = array(); foreach ($field_groups as $field_group => $fields) { foreach ($fields as $field_name => $field) { if ('color' !== $field['type']) { continue; } $colors[$field_name] = $field; } } foreach ($colors as $color => $options) { $setting = 'largo_color_' . $color; $wp_customize->add_setting($setting, array('type' => $setting, 'default' => $options['default_value'], 'sanitize_callback' => 'sanitize_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $setting, array('label' => $options['label'], 'section' => 'largo_colors', 'settings' => $setting))); $settings[$setting] = array('type' => $setting); } add_action('customize_save', array($this, 'action_customize_save_fetch_less_variables')); add_action('customize_save_after', array($this, 'action_customize_save_after_save_less_variables')); } // Because the Customizer doesn't easily support custom callbacks, let's add our own foreach ($settings as $setting => $options) { // These types have native support if (in_array($options['type'], array('option', 'theme_mod'))) { continue; } add_filter('customize_value_' . $setting, array($this, 'filter_customize_value')); add_action('customize_update_' . $options['type'], array($this, 'action_customize_update')); add_action('customize_preview_' . $options['type'], array($this, 'action_customize_preview')); } }
<?php /** * Move the author dropdown to the publish metabox so it's easier to find * * @since 0.3 * @global $post */ // if (!Largo()->is_plugin_active('co-authors-plus')) { function largo_move_author_to_publish_metabox() { global $post_ID; $post = get_post($post_ID); printf('<div id="author" class="misc-pub-section" style="padding: 8px 10px;">%s: ', __('Author', 'largo')); post_author_meta_box($post); echo '</div>'; } add_action('post_submitbox_misc_actions', 'largo_move_author_to_publish_metabox'); } /** * Hide some of the less commonly used metaboxes to cleanup the post and page edit screens * * @since 0.3 */ function largo_remove_default_post_screen_metaboxes() { remove_meta_box('trackbacksdiv', 'post', 'normal'); // trackbacks remove_meta_box('revisionsdiv', 'post', 'normal'); // revisions