当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Customize_Manager::is_preview方法代码示例

本文整理汇总了PHP中WP_Customize_Manager::is_preview方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Manager::is_preview方法的具体用法?PHP WP_Customize_Manager::is_preview怎么用?PHP WP_Customize_Manager::is_preview使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Customize_Manager的用法示例。


在下文中一共展示了WP_Customize_Manager::is_preview方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ajax_customizer_reset

 public function ajax_customizer_reset()
 {
     if (!$this->wp_customize->is_preview()) {
         wp_send_json_error('not_preview');
     }
     if (!check_ajax_referer('customizer-reset', 'nonce', false)) {
         wp_send_json_error('invalid_nonce');
     }
     $this->reset_customizer();
     wp_send_json_success();
 }
开发者ID:jorgeonidas,项目名称:woocomtuto,代码行数:11,代码来源:customizer-reset.php

示例2: coursepress_customize_register

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function coursepress_customize_register($wp_customize)
{
    $wp_customize->get_setting('blogname')->transport = 'postMessage';
    $wp_customize->get_setting('blogdescription')->transport = 'postMessage';
    $wp_customize->get_setting('header_textcolor')->transport = 'postMessage';
    $colors = array();
    $colors[] = array('slug' => 'body_text_color', 'default' => '#878786', 'label' => __('Body Text Color', 'cp'));
    $colors[] = array('slug' => 'content_text_color', 'default' => '#666666', 'label' => __('Content Text Color', 'cp'));
    $colors[] = array('slug' => 'content_header_color', 'default' => '#878786', 'label' => __('Content Header Color', 'cp'));
    $colors[] = array('slug' => 'content_link_color', 'default' => '#1cb8ea', 'label' => __('Content Links Color', 'cp'));
    $colors[] = array('slug' => 'content_link_hover_color', 'default' => '#1cb8ea', 'label' => __('Content Links Hover Color', 'cp'));
    $colors[] = array('slug' => 'main_navigation_link_color', 'default' => '#666', 'label' => __('Main Navigation Links Color', 'cp'));
    $colors[] = array('slug' => 'main_navigation_link_hover_color', 'default' => '#74d1d4', 'label' => __('Main Navigation Links Hover Color', 'cp'));
    $colors[] = array('slug' => 'footer_background_color', 'default' => '#f2f6f8', 'label' => __('Footer Background Color', 'cp'));
    $colors[] = array('slug' => 'footer_link_color', 'default' => '#83abb6', 'label' => __('Footer Links Color', 'cp'));
    $colors[] = array('slug' => 'footer_link_hover_color', 'default' => '#74d1d4', 'label' => __('Footer Links Hover Color', 'cp'));
    $colors[] = array('slug' => 'widget_title_color', 'default' => '#c0c21e', 'label' => __('Widgets Title Color', 'cp'));
    sort($colors);
    foreach ($colors as $color) {
        // SETTINGS
        $wp_customize->add_setting($color['slug'], array('default' => $color['default'], 'type' => 'option', 'capability' => 'edit_theme_options'));
        // CONTROLS
        $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $color['slug'], array('label' => $color['label'], 'section' => 'colors', 'settings' => $color['slug'])));
    }
    $wp_customize->add_setting('coursepress_logo', array('default' => get_template_directory_uri() . '/images/logo-default.png', 'type' => 'theme_mod', 'capability' => 'edit_theme_options'));
    $wp_customize->add_section('cp_logo_section', array('title' => __('Logo', 'cp'), 'priority' => 1));
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'logo', array('label' => __('Upload a logo', 'cp'), 'section' => 'cp_logo_section', 'settings' => 'coursepress_logo')));
    if ($wp_customize->is_preview() && !is_admin()) {
        add_action('wp_footer', 'coursepress_customize_preview', 21);
    }
}
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:36,代码来源:customizer.php

示例3: theme_customizer_register_site_title

 /**
  * Enable real-time editing of site title and tagline via the customizer.
  *
  * @since 0.1.0
  *
  * @param WP_Customize_Manager $wp_customize Customizer object.
  *
  * @return void
  */
 public function theme_customizer_register_site_title($wp_customize)
 {
     /* Reference theme customizer option defaults. */
     global $wpgo_customizer_defaults;
     /* Add checkbox to display/hide site tagline. */
     $wp_customize->add_setting(WPGO_CUSTOMIZE_DB_NAME . '[wpgo_chk_hide_description]', array('default' => $wpgo_customizer_defaults['wpgo_chk_hide_description'], 'type' => 'option'));
     $wp_customize->add_control(WPGO_CUSTOMIZE_DB_NAME . '[wpgo_chk_hide_description]', array('label' => __('Hide tagline', 'wpgothemes'), 'section' => 'title_tagline', 'type' => 'checkbox'));
     /* Add JS to footer to make the site title and tagline update in real-time. */
     if ($wp_customize->is_preview() && !is_admin()) {
         add_action('wp_footer', array($this, 'real_time_customize_preview'), 21);
     }
     /* Update theme customizer transport setting for site title and tagline so they change in real-time. */
     $wp_customize->get_setting('blogname')->transport = 'postMessage';
     $wp_customize->get_setting('blogdescription')->transport = 'postMessage';
 }
开发者ID:vihoangson,项目名称:vihoangson.com,代码行数:24,代码来源:customize-site-title-and-tagline.php

示例4: tesseract_customize_register

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function tesseract_customize_register($wp_customize)
{
    $wp_customize->get_setting('blogname')->transport = 'postMessage';
    $wp_customize->get_setting('blogdescription')->transport = 'postMessage';
    $wp_customize->get_setting('header_textcolor')->transport = 'postMessage';
    $wp_customize->add_panel('tesseract_general_options', array('priority' => 3, 'capability' => 'edit_theme_options', 'title' => 'General'));
    $wp_customize->add_panel('tesseract_header_options', array('priority' => 4, 'capability' => 'edit_theme_options', 'title' => 'Header Options'));
    $wp_customize->add_panel('tesseract_footer_options', array('priority' => 5, 'capability' => 'edit_theme_options', 'title' => 'Footer Options'));
    $wp_customize->add_panel('tesseract_social', array('priority' => 9999, 'capability' => 'edit_theme_options', 'title' => 'Social'));
    $wp_customize->get_section('title_tagline')->panel = 'tesseract_header_options';
    $wp_customize->get_section('title_tagline')->priority = 3;
    $wp_customize->get_section('static_front_page')->panel = 'tesseract_general_options';
    $wp_customize->get_section('static_front_page')->priority = 4;
    $wp_customize->get_section('background_image')->panel = 'tesseract_general_options';
    $wp_customize->get_section('background_image')->priority = 2;
    $wp_customize->get_section('colors')->panel = 'tesseract_general_options';
    $wp_customize->get_section('colors')->title = __('Background Color', 'tesseract');
    $wp_customize->get_section('colors')->priority = 1;
    $wp_customize->get_control('background_color')->label = __('Choose a background color', 'tesseract');
    $wp_customize->get_control('background_color')->description = __('(This is only for the site\'s generic background color. You can define header and footer background colors in the Header Options and Footer Options respectively.)', 'tesseract');
    $wp_customize->remove_section('header_image');
    $wp_customize->remove_section('nav');
    $wp_customize->remove_control('header_textcolor');
    require get_template_directory() . '/inc/sections/header-colors.php';
    require get_template_directory() . '/inc/sections/logo.php';
    require get_template_directory() . '/inc/sections/header-menu.php';
    require get_template_directory() . '/inc/sections/header-content.php';
    require get_template_directory() . '/inc/sections/social/facebook.php';
    require get_template_directory() . '/inc/sections/social/twitter.php';
    require get_template_directory() . '/inc/sections/social/googleplus.php';
    require get_template_directory() . '/inc/sections/social/linkedin.php';
    require get_template_directory() . '/inc/sections/social/youtube.php';
    require get_template_directory() . '/inc/sections/social/vimeo.php';
    require get_template_directory() . '/inc/sections/social/tumblr.php';
    require get_template_directory() . '/inc/sections/social/flickr.php';
    require get_template_directory() . '/inc/sections/social/pinterest.php';
    require get_template_directory() . '/inc/sections/social/dribbble.php';
    require get_template_directory() . '/inc/sections/footer-colors.php';
    require get_template_directory() . '/inc/sections/footer-content.php';
    if ($wp_customize->is_preview() && !is_admin()) {
        add_action('wp_footer', 'tesseract_customize_preview', 21);
    }
}
开发者ID:AhmedElmasry2015,项目名称:WordPress-Project,代码行数:48,代码来源:customizer.php

示例5: sosimplecustomize_register

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @since 3.0.0
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 * @return void
 */
function sosimplecustomize_register($wp_customize)
{
    if ($wp_customize->is_preview() && !is_admin()) {
        add_action('wp_footer', 'sosimplecustomize_preview', 21);
    }
    /**
     * Site Title & Description Section
     */
    $wp_customize->get_setting('blogname')->transport = 'postMessage';
    $wp_customize->get_setting('blogdescription')->transport = 'postMessage';
    /**
     * Create So Simple Panel
     */
    $wp_customize->add_panel('sosimplecustomizer', array('priority' => 10, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('So Simple Customizer Options', 'so-simple-75'), 'description' => __('Theme Options for So Simple', 'so-simple-75')));
    /**
     * Logos Section
     */
    $wp_customize->add_section('logo_section', array('title' => __('Logos', 'so-simple-75'), 'priority' => 100, 'panel' => 'sosimplecustomizer'));
    $wp_customize->add_setting('sosimpleoptions[logo]', array('default' => '', 'sanitize_callback' => 'sosimple_sanitize_text'));
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'logo', array('section' => 'logo_section', 'label' => __('Custom Logo', 'so-simple-75'), 'settings' => 'sosimpleoptions[logo]', 'priority' => 100)));
    $wp_customize->add_setting('sosimpleoptions[favicon]', array('default' => '', 'sanitize_callback' => 'sosimple_sanitize_text'));
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'favicon', array('section' => 'logo_section', 'label' => __('Custom Favicon', 'so-simple-75'), 'settings' => 'sosimpleoptions[favicon]', 'priority' => 150)));
    /**
     * Social Info
     */
    $wp_customize->add_section('social_section', array('title' => __('Social Media', 'so-simple-75'), 'priority' => 200, 'description' => __('Social Media', 'so-simple-75'), 'panel' => 'sosimplecustomizer'));
    $wp_customize->add_setting('sosimpleoptions[facebook]', array('default' => '', 'sanitize_callback' => 'sosimple_sanitize_text'));
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'facebook', array('section' => 'social_section', 'label' => __('Facebook', 'so-simple-75'), 'settings' => 'sosimpleoptions[facebook]', 'priority' => 200)));
    $wp_customize->add_setting('sosimpleoptions[twitter]', array('default' => '', 'sanitize_callback' => 'sosimple_sanitize_text'));
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'twitter', array('section' => 'social_section', 'label' => __('Twitter', 'so-simple-75'), 'settings' => 'sosimpleoptions[twitter]', 'priority' => 200)));
    $wp_customize->add_setting('sosimpleoptions[linkedin]', array('default' => '', 'sanitize_callback' => 'sosimple_sanitize_text'));
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'linkedin', array('section' => 'social_section', 'label' => __('Linkedin', 'so-simple-75'), 'settings' => 'sosimpleoptions[linkedin]', 'priority' => 200)));
    $wp_customize->add_setting('sosimpleoptions[pinterest]', array('default' => '', 'sanitize_callback' => 'sosimple_sanitize_text'));
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'pinterest', array('section' => 'social_section', 'label' => __('Pinterest', 'so-simple-75'), 'settings' => 'sosimpleoptions[pinterest]', 'priority' => 200)));
    $wp_customize->add_setting('sosimpleoptions[instagram]', array('default' => '', 'sanitize_callback' => 'sosimple_sanitize_text'));
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'instagram', array('section' => 'social_section', 'label' => __('Instagram', 'so-simple-75'), 'settings' => 'sosimpleoptions[instagram]', 'priority' => 200)));
    /**
     * Copyright
     */
    $wp_customize->add_section('copyright_section', array('title' => __('Copyright', 'so-simple-75'), 'priority' => 200, 'description' => __('Display copyright', 'so-simple-75'), 'panel' => 'sosimplecustomizer'));
    $wp_customize->add_setting('sosimpleoptions[copyright]', array('default' => '', 'sanitize_callback' => 'sosimple_sanitize_text'));
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'copyright', array('section' => 'copyright_section', 'label' => __('Copyright', 'so-simple-75'), 'settings' => 'sosimpleoptions[copyright]', 'priority' => 200, 'type' => 'checkbox')));
}
开发者ID:pixwind,项目名称:pixwind,代码行数:51,代码来源:customizer.php

示例6: chow_customize_register

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function chow_customize_register($wp_customize)
{
    $wp_customize->get_setting('blogname')->transport = 'postMessage';
    $wp_customize->get_setting('blogdescription')->transport = 'postMessage';
    $wp_customize->get_setting('header_textcolor')->transport = 'postMessage';
    // color section
    $wp_customize->add_section('chow_color_settings', array('title' => __('Main theme color', 'chow'), 'priority' => 35));
    $wp_customize->add_setting('chow_main_color', array('default' => '#73b819', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'chow_main_color', array('label' => __('Color Settings', 'chow'), 'section' => 'colors', 'settings' => 'chow_main_color')));
    // bof layout section
    $wp_customize->add_section('chow_layout_settings', array('title' => __('Layout', 'chow'), 'priority' => 36));
    $wp_customize->add_setting('chow_layout_style', array('default' => 'boxed', 'sanitize_callback' => 'esc_attr', 'transport' => 'postMessage'));
    $wp_customize->add_control('chow_layout_choose', array('label' => __('Select layout type', 'chow'), 'section' => 'chow_layout_settings', 'settings' => 'chow_layout_style', 'type' => 'select', 'choices' => array('boxed' => 'Boxed', 'fullwidth' => 'Wide')));
    $wp_customize->add_setting('chow_menu_currcolor', array('default' => '#505050', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'chow_menu_currcolor', array('label' => __('Menu current element color', 'chow'), 'section' => 'colors', 'settings' => 'chow_menu_currcolor')));
    $wp_customize->add_setting('chow_tagline_switch', array('default' => 'show', 'transport' => 'refresh', 'sanitize_callback' => 'esc_attr'));
    $wp_customize->add_control('chow_tagline_switcher', array('settings' => 'chow_tagline_switch', 'label' => __('Display Tagline', 'chow'), 'section' => 'title_tagline', 'type' => 'select', 'choices' => array('hide' => 'Hide', 'show' => 'Show')));
    if ($wp_customize->is_preview() && !is_admin()) {
        add_action('wp_footer', 'chow_customize_preview', 21);
    }
}
开发者ID:net0,项目名称:lecook,代码行数:26,代码来源:customizer.php

示例7:

 /**
  * Test WP_Customize_Manager::wp_loaded().
  *
  * Ensure that post values are previewed even without being in preview.
  *
  * @ticket 30937
  * @covers WP_Customize_Manager::wp_loaded()
  */
 function test_wp_loaded()
 {
     wp_set_current_user(self::$admin_user_id);
     $wp_customize = new WP_Customize_Manager();
     $title = 'Hello World';
     $wp_customize->set_post_value('blogname', $title);
     $this->assertNotEquals($title, get_option('blogname'));
     $wp_customize->wp_loaded();
     $this->assertFalse($wp_customize->is_preview());
     $this->assertEquals($title, $wp_customize->get_setting('blogname')->value());
     $this->assertEquals($title, get_option('blogname'));
 }
开发者ID:CompositeUK,项目名称:clone.WordPress-Develop,代码行数:20,代码来源:manager.php

示例8: theme_customizer_register_color_pickers

 /**
  * Add color pickers to theme customizer 'colors' section.
  *
  * @since 0.2.0
  *
  * @param WP_Customize_Manager $wp_customize Customizer object.
  *
  * @return void
  */
 public function theme_customizer_register_color_pickers($wp_customize)
 {
     global $wpgo_customizer_defaults, $wpgo_color_pickers;
     /* Get color scheme from drop down box or use default. */
     $current_color_scheme = WPGo_Theme_Customizer::get_customizer_theme_option('wpgo_drp_color_scheme');
     /* Get the default colors for the currently selected color scheme. */
     foreach ($this->_wpgo_color_schemes as $wpgo_color_scheme) {
         if ($wpgo_color_scheme['name'] == $current_color_scheme) {
             $color_picker_defaults = $wpgo_color_scheme['default_colors'];
             break;
         }
     }
     /* If no defined color scheme has been found to match the color scheme drop down value then use the core defaults. */
     if (empty($color_picker_defaults)) {
         /* Get the default colors for the currently selected color scheme. */
         foreach ($this->_wpgo_color_schemes as $wpgo_color_scheme) {
             // save default color scheme colors
             if ($wpgo_color_scheme['name'] == 'default') {
                 $color_picker_defaults = $wpgo_color_scheme['default_colors'];
                 break;
             }
         }
         // update color scheme drop down option to default
         WPGo_Theme_Customizer::set_customizer_theme_option('wpgo_drp_color_scheme', 'default');
     }
     /* Add default background color from color scheme array rather than value specified in functions.php. */
     if (current_theme_supports('custom-background')) {
         $wp_customize->get_setting('background_color')->default = $color_picker_defaults['background_color'];
     }
     foreach ($wpgo_color_pickers as $color_picker) {
         $transport = !isset($color_picker['transport']) ? 'postMessage' : $color_picker['transport'];
         $setting = WPGO_CUSTOMIZE_DB_NAME . '[' . $color_picker['setting'] . ']';
         // test if color picker has a specified value in the current color scheme, if so use it
         if (isset($color_picker_defaults[$color_picker['setting']])) {
             $default = $color_picker_defaults[$color_picker['setting']];
             // default color for a particular color scheme, and color picker
         } else {
             // check there actually is a default color specified for the color picker in the default color scheme
             if (isset($wpgo_customizer_defaults[$color_picker['setting']])) {
                 $default = $wpgo_customizer_defaults[$color_picker['setting']];
             } else {
                 $default = '#000000';
             }
         }
         /* Add setting. */
         $wp_customize->add_setting($setting, array('transport' => $transport, 'default' => $default, 'type' => 'option', 'capability' => 'edit_theme_options'));
         /* Add control. */
         $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $setting, array('label' => $color_picker['label'], 'section' => 'colors', 'settings' => $setting, 'priority' => $color_picker['priority'])));
     }
     if ($wp_customize->is_preview() && !is_admin()) {
         add_action('wp_footer', array($this, 'add_theme_specific_footer_js'), 21);
     }
 }
开发者ID:vihoangson,项目名称:vihoangson.com,代码行数:62,代码来源:customize-theme-colors.php


注:本文中的WP_Customize_Manager::is_preview方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。