我开发了一个WordPress主题,它使用了一些自定义函数,模板和帖子类型。在我的测试服务器上一切正常。当我在托管服务器上安装主题时,一旦我安装任何插件,它会导致Customizer功能停止工作。安装插件后,单击Customizer按钮后只有一个空白屏幕。 WP-Debug设置为true时,我没有收到任何错误。
任何想法?
//Functions PHP
<?php
require_once('widgets/class-wp-widget-recent-posts.php');
require_once('widgets/class-wp-widget-recent-comments.php');
require_once('widgets/class-wp-widget-categories.php');
require_once('wp_bootstrap_navwalker.php');
function expressivegraphics_enqueue_styles() {
wp_register_style('bootstrap', get_template_directory_uri() . '/bootstrap/css/bootstrap.min.css' );
$dependencies = array('bootstrap');
wp_enqueue_style( 'expressivegraphics-style', get_stylesheet_uri(), $dependencies );
}
function expressivegraphics_enqueue_scripts() {
$dependencies = array('jquery');
wp_enqueue_script('bootstrap', get_template_directory_uri(). '/bootstrap/js/bootstrap.js', $dependencies, '', true );
}
add_action( 'wp_enqueue_scripts', 'expressivegraphics_enqueue_styles' );
add_action( 'wp_enqueue_scripts', 'expressivegraphics_enqueue_scripts' );
function expressivegraphics_theme_setup(){
// RSS Feed support
add_theme_support( 'automatic-feed-links' );
// Translation
load_theme_textdomain( 'expressivegraphics', get_template_directory() . '/languages' );
// Post Types
add_theme_support( 'post-formats', array ( 'aside', 'gallery', 'quote', 'image', 'video','pricing','store' ) );
// Featured Image Support
add_theme_support('post-thumbnails');
add_image_size('slider-large', 1260, 606);
add_image_size('graphic', 250, 250);
// Nav Menus
register_nav_menus(array(
'primary' => __('Primary Menu')
));
// Logo Support
add_theme_support( 'custom-logo', array(
'height' => 100,
'width' => 100,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
));
}
add_action('after_setup_theme', 'expressivegraphics_theme_setup');
// Get Customizer File
require get_template_directory() . '/inc/customizer.php';
function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-7,-8,-9,-17' );
}
}
add_action( 'pre_get_posts', 'exclude_category' );
// Widget Locations
function init_widgets($id){
register_sidebar(array(
'name' => 'Footer 1',
'id' => 'footer-1',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h4>',
'after_title' => '</h4>'
));
register_sidebar(array(
'name' => 'Footer 2',
'id' => 'footer-2',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h4>',
'after_title' => '</h4>'
));
register_sidebar(array(
'name' => 'Footer 3',
'id' => 'footer-3',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h4>',
'after_title' => '</h4>'
));
register_sidebar(array(
'name' => 'Pricing 1',
'id' => 'pricing-1',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
register_sidebar(array(
'name' => 'Pricing 2',
'id' => 'pricing-2',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
register_sidebar(array(
'name' => 'Pricing 3',
'id' => 'pricing-3',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
register_sidebar(array(
'name' => 'Sidebar',
'id' => 'sidebar',
'before_widget' => '<div class="panel panel-default sidebar-widget">',
'after_widget' => '</div></div>
',
'before_title' => '<div class="panel-heading"><h3 class="panel-title">',
'after_title' => '</h3></div><div class="panel-body">'
));
}
add_action('widgets_init', 'init_widgets');
// Adds 'list-group-item' to categories li
function add_new_class_list_categories($list){
$list = str_replace('cat-item', 'cat-item list-group-item', $list);
return $list;
}
add_filter('wp_list_categories', 'add_new_class_list_categories');
// Register Widgets
function expressivegraphics_register_widgets(){
register_widget('WP_Widget_Recent_Posts_Custom');
register_widget('WP_Widget_Recent_Comments_Custom');
register_widget('WP_Widget_Categories_Custom');
}
// Add Comments
function add_theme_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li class="well comment-item"';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="col-md-2">
<div class="comment-author vcard">
<?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
<?php printf( __( '<cite class="fn">%s</cite>' ), get_comment_author_link() ); ?>
</div>
</div>
<div class="col-md-10">
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), ' ', '' );
?>
</div>
<?php comment_text(); ?>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
// `Customizer PHP`
<?php
function expressivegraphics_customize_register($wp_customize){
// Boxes Section
$wp_customize->add_section('boxes', array(
'title' => __('Boxes', 'expressivegraphics'),
'description' => sprintf( __('Options for homepage boxes', 'expressivegraphics')
),
'priority' => 130,
));
// BOX 1
// Box 1 Heading Setting
$wp_customize->add_setting( 'box1_heading', array(
'default' => _x('Box 1 Heading', 'expressivegraphics'),
'type' => 'theme_mod'
));
// Box 1 Heading Control
$wp_customize->add_control( 'box1_heading', array(
'label' => __('Box 1 Heading', 'expressivegraphics'),
'section' => 'boxes',
'priority' => 20,
));
// Box 1 Text Setting
$wp_customize->add_setting( 'box1_text', array(
'default' => _x('Maecenas sed diam eget risus varius blandit sit amet non magna.', 'expressivegraphics'),
'type' => 'theme_mod'
));
// Box 1 Text Control
$wp_customize->add_control( 'box1_text', array(
'label' => __('Box 1 Text', 'expressivegraphics'),
'section' => 'boxes',
'priority' => 20,
));
// Box 1 Icon Setting
$wp_customize->add_setting( 'box1_icon', array(
'default' => _x('bar-chart', 'expressivegraphics'),
'type' => 'theme_mod'
));
// Box 1 Icon Control
$wp_customize->add_control( 'box1_icon', array(
'label' => __('Box 1 Icon', 'expressivegraphics'),
'section' => 'boxes',
'priority' => 20,
));
// Box 1 URL Setting
$wp_customize->add_setting('box1_url', array(
'default' => _x('http://www.expressivegraphics.com', 'expressivegraphics'),
'type' => 'theme_mod'
));
// Box 1 URL Control
$wp_customize->add_control( 'box1_url', array(
'label' => __('Box 1 URL', 'expressivegraphics'),
'section' => 'boxes',
'priority' => 1,
));
// Contact Box Section
$wp_customize->add_section('contact', array(
'title' => __('Contact', 'expressivegraphics'),
'description' => sprintf( __('Options for homepage section contact', 'expressivegraphics')
),
'priority' => 150,
));
// Contact 1
// Contact 1 Heading Setting
$wp_customize->add_setting( 'contact1_heading', array(
'default' => _x('Contact 1 Heading', 'expressivegraphics'),
'type' => 'theme_mod'
));
// Contact 1 Heading Control
$wp_customize->add_control( 'contact1_heading', array(
'label' => __('Box 1 Heading', 'expressivegraphics'),
'section' => 'contact',
'priority' => 20,
));
// Contact 1 Text Setting
$wp_customize->add_setting( 'contact1_text', array(
'default' => _x('Maecenas sed diam eget risus varius blandit sit amet non magna.', 'expressivegraphics'),
'type' => 'theme_mod'
));
// Contact 1 Text Control
$wp_customize->add_control( 'contact1_text', array(
'label' => __('Contact 1 Text', 'expressivegraphics'),
'section' => 'contact',
'priority' => 20,
));
// Contact 1 Icon Setting
$wp_customize->add_setting( 'contact1_icon', array(
'default' => _x('bar-chart', 'expressivegraphics'),
'type' => 'theme_mod'
));
// Contact 1 Icon Control
$wp_customize->add_control( 'contact1_icon', array(
'label' => __('Contact 1 Icon', 'expressivegraphics'),
'section' => 'contact',
'priority' => 20,
));
// Contact 2
// Contact 2 Heading Setting
$wp_customize->add_setting( 'contact2_heading', array(
'default' => _x('Contact 2 Heading', 'expressivegraphics'),
'type' => 'theme_mod'
));
// Contact 2 Heading Control
$wp_customize->add_control( 'contact2_heading', array(
'label' => __('Contact 2 Heading', 'expressivegraphics'),
'section' => 'contact',
'priority' => 20,
));
// Contact 2 Text Setting
$wp_customize->add_setting( 'contact2_text', array(
'default' => _x('Maecenas sed diam eget risus varius blandit sit amet non magna.', 'expressivegraphics'),
'type' => 'theme_mod'
));
// Contact 2 Text Control
$wp_customize->add_control( 'contact2_text', array(
'label' => __('Contact 2 Text', 'expressivegraphics'),
'section' => 'contact',
'priority' => 20,
));
// Contact 2 Icon Setting
$wp_customize->add_setting( 'contact2_icon', array(
'default' => _x('code', 'expressivegraphics'),
'type' => 'theme_mod'
));
// Contact 2 Icon Control
$wp_customize->add_control( 'contact2_icon', array(
'label' => __('Contact 2 Icon', 'expressivegraphics'),
'section' => 'contact',
'priority' => 20,
));
}
add_action('customize_register', 'expressivegraphics_customize_register');