doujianwei8217 2018-09-27 19:41
浏览 73

Wordpress customizer.php未显示部分/设置

I am having issues with Wordpress Customizer not loading my sections/settings when I visit the customizer.php page.

Below I have included all of my customizer.php and the include section of my functions.php.

    <?php
    function customizer_settings( $wp_customize ) {
        $wp_customize->add_section('menu_colors', array(
            'title' => 'Menu Colors',
            'priority' => 10,
      ) );
      $wp_customize->add_setting('toggle_color', array(
        'default' => '#fff',
        'transport' => 'refresh',
      ) );
      $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'toggle_color', array(
        'label' => 'Toggle Color',
        'section' => 'menu_colors',
        'settings' => 'toggle_color',
      ) ) );
      $wp_customize->add_setting('link_color', array(
        'default' => '#fff',
        'transport' => 'refresh',
      ) );
      $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'link_color', array(
        'label' => 'Menu Link Color',
        'section' => 'menu_colors',
        'settings' => 'link_color',
      ) ) );
      $wp_customize->add_setting('link_hover_color', array(
        'default' => '#fff',
        'transport' => 'refresh',
      ) );
      $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'link_hover_color', array(
        'label' => 'Menu Link Hover Color',
        'section' => 'menu_colors',
        'settings' => 'link_hover_color',
      ) ) );
      $wp_customize->add_setting('overlay_background_color', array(
        'default' => '#fff',
        'transport' => 'refresh',
      ) );
      $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'overlay_background_color', array(
        'label' => 'Overlay Background Color',
        'section' => 'menu_colors',
        'settings' => 'overlay_background_color',
      ) ) );
      $wp_customize->add_setting('menu_background_color', array(
        'default' => '#fff',
        'transport' => 'refresh',
      ) );
      $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'menu_background_color', array(
        'label' => 'Menu Background Color',
        'section' => 'menu_colors',
        'settings' => 'menu_background_color',
      ) ) );
    }
    // Setup the Theme Customizer settings and controls...
    add_action( 'customize_register' , 'customizer_settings' );

    function header_output() {
    ?>
    <!--Customizer CSS-->
    <style type="text/css">
       <?php self::generate_css('.nav-menu' , 'background-color' , 'menu_background_color', ''); ?>
       <?php self::generate_css('.collapse-btn' , 'color' , 'toggle_color', ''); ?>
       <?php self::generate_css('.collapse-btn:hover' , 'color' , 'toggle_hover_color', ''); ?>
       <?php self::generate_css('.closebtn' , 'color' , 'toggle_color', ''); ?>
       <?php self::generate_css('.closebtn:hover' , 'color' , 'toggle_hover_color', ''); ?>
       <?php self::generate_css('.overlay' , 'background-color' , 'overlay_background_color', ''); ?>
       <?php self::generate_css('.overlay li a' , 'color' , 'link_color', ''); ?>
       <?php self::generate_css('.overlay li a:hover' , 'color' , 'link_color', ''); ?>
       <?php self::generate_css('.overlay li a:focus' , 'color' , 'link_color', ''); ?>
    </style>
    <!--/Customizer CSS-->
    <?php
  }
  // Output custom CSS to live site
  add_action( 'customize_controls_print_styles', 'header_output' );
?>

This section is the functions.php theme_setup function:

    function Sentrytheme_setup() {
      load_theme_textdomain( 'Sentrytheme' );

      //Add default posts and comments RSS feed links to head
      add_theme_support( 'automatic-feed-links' );

      //Let WordPress manage the document title
      add_theme_support( 'title-tag' );

      //Enables post thumbnails on posts and pages.
      add_theme_support( 'post-thumbnails' );

      add_theme_support('html5', array('comment-form','comment-list','gallery','caption',));

      add_theme_support('post-formats', array('aside','image','video','quote','link','gallery','audio',));

      add_theme_support('custom-logo', array('width' => 250,'height' => 100,'flex-width' => true,));

      include('/inc/customizer.php');

      add_theme_support('menus');

      function register_my_menus() {
          $args = array(
              'menu-1' => __( 'Main Menu' )
          );
          register_nav_menus( $args );
      }
      add_action( 'init', 'register_my_menus' );
    }
    add_action( 'after_setup_theme', 'Sentrytheme_setup' );

What I see when I view the customizer in Wordpress Admin iscustomizer page

This set of code(with modification) came from https://premium.wpmudev.org/blog/wordpress-theme-customizer-guide/ and https://codex.wordpress.org/Theme_Customization_API

Any help is appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)