Мне нужно больше sh взглянуть на настройщик моей детской темы Genesis. php файл. Я не могу понять, почему он не будет применять какие-либо изменения через панель настроек настройщика. Я думаю, что смотрю на это слишком долго ... Я не вижу конфликта.
Я успешно использовал код ранее для других тем, но обычно требуется, чтобы css для цвета по умолчанию должны быть включены в файл стиля. css (просто для переопределения применяемой «пользовательской таблицы пользователя»), но все, что делает с этой темой, это блокирует коды цвета по умолчанию, чтобы пользователь темы не мог вносить изменения цвета.
Если я оставлю css вне стиля. css он по-прежнему не позволяет применять какие-либо изменения.
Любые предложения приветствуются.
<?php
function lunatek_customizer_get_default_sitetitle_color() {
return '#000';
}
function lunatek_customizer_get_default_headingstitles_color() {
return '#000';
}
function lunatek_customizer_get_default_topnavbase_color() {
return '#444';
}
function lunatek_customizer_get_default_topnavlink_color() {
return '#000';
}
function lunatek_customizer_get_default_topnavhover_color() {
return '#444';
}
function lunatek_customizer_get_default_navborder_color() {
return '#888';
}
function lunatek_customizer_get_default_link_color() {
return '#000';
}
function lunatek_customizer_get_default_hover_color() {
return '#444';
}
add_action( 'customize_register', 'lunatek_customizer_register' );
function lunatek_customizer_register() {
/**
* Customize Background Image Control Class
* @package WordPress
* @subpackage Customize
**/
class Child_lunatek_Image_Control extends WP_Customize_Image_Control {
/**
* Constructor.
* If $args['settings'] is not defined, use the $id as the setting ID.
* @uses WP_Customize_Upload_Control::__construct()
* @param WP_Customize_Manager $manager
* @param string $id
* @param array $args
*/
public function __construct( $manager, $id, $args ) {
$this->statuses = array( '' => __( 'No Image', 'lunatek' ) );
parent::__construct( $manager, $id, $args );
$this->add_tab( 'upload-new', __( 'Upload New', 'lunatek' ), array( $this, 'tab_upload_new' ) );
$this->add_tab( 'uploaded', __( 'Uploaded', 'lunatek' ), array( $this, 'tab_uploaded' ) );
if ( $this->setting->default )
$this->add_tab( 'default', __( 'Default', 'lunatek' ), array( $this, 'tab_default_background' ) );
// Early priority to occur before $this->manager->prepare_controls();
add_action( 'customize_controls_init', array( $this, 'prepare_control' ), 5 );
}
/**
* @since 3.4.0
* @uses WP_Customize_Image_Control::print_tab_image()
*/
public function tab_default_background() {
$this->print_tab_image( $this->setting->default );
}
}
global $wp_customize;
$wp_customize->add_setting(
'lunatek_sitetitle_color',
array(
'default' => lunatek_customizer_get_default_sitetitle_color(),
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_setting(
'lunatek_headingstitles_color',
array(
'default' => lunatek_customizer_get_default_headingstitles_color(),
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_setting(
'lunatek_topnavbase_color',
array(
'default' => lunatek_customizer_get_default_topnavbase_color(),
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_setting(
'lunatek_topnavlink_color',
array(
'default' => lunatek_customizer_get_default_topnavlink_color(),
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_setting(
'lunatek_topnavhover_color',
array(
'default' => lunatek_customizer_get_default_topnavhover_color(),
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_setting(
'lunatek_navborder_color',
array(
'default' => lunatek_customizer_get_default_navborder_color(),
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_setting(
'lunatek_link_color',
array(
'default' => lunatek_customizer_get_default_link_color(),
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_setting(
'lunatek_hover_color',
array(
'default' => lunatek_customizer_get_default_hover_color(),
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'lunatek_sitetitle_color',
array(
'description' => __( 'Change the text color of the Site Title.', 'lunatek' ),
'label' => __( 'Site Title Color', 'lunatek' ),
'section' => 'colors',
'settings' => 'lunatek_sitetitle_color',
)
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'lunatek_headingstitles_color',
array(
'description' => __( 'Change the Headings & Titles color.', 'lunatek' ),
'label' => __( 'Headings & Titles Color', 'lunatek' ),
'section' => 'colors',
'settings' => 'lunatek_headingstitles_color',
)
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'lunatek_topnavbase_color',
array(
'description' => __( 'Change the Top Navigation background color.', 'lunatek' ),
'label' => __( 'Top Nav Base Color', 'lunatek' ),
'section' => 'colors',
'settings' => 'lunatek_topnavbase_color',
)
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'lunatek_topnavlink_color',
array(
'description' => __( 'Change the Top Navigation link color.', 'lunatek' ),
'label' => __( 'Top Nav Link Color', 'lunatek' ),
'section' => 'colors',
'settings' => 'lunatek_topnavlink_color',
)
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'lunatek_topnavhover_color',
array(
'description' => __( 'Change the Top Navigation hover color.', 'lunatek' ),
'label' => __( 'Top Nav Hover Color', 'lunatek' ),
'section' => 'colors',
'settings' => 'lunatek_topnavhover_color',
)
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'lunatek_navborder_color',
array(
'description' => __( 'Change the Navigation area border color.', 'lunatek' ),
'label' => __( 'Nav Border Color', 'lunatek' ),
'section' => 'colors',
'settings' => 'lunatek_navborder_color',
)
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'lunatek_link_color',
array(
'description' => __( 'Change the link color.', 'lunatek' ),
'label' => __( 'Link Color', 'lunatek' ),
'section' => 'colors',
'settings' => 'lunatek_link_color',
)
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'lunatek_hover_color',
array(
'description' => __( 'Change the hover color.', 'lunatek' ),
'label' => __( 'Hover Color', 'lunatek' ),
'section' => 'colors',
'settings' => 'lunatek_hover_color',
)
)
);
//* Blog Text Section:
$wp_customize->add_setting( 'lunatek_blog_text', array(
'default' => __( 'New on the Blog', 'lunatek' ),
'capability' => 'edit_theme_options',
'sanitize_callback' => 'wp_kses_post',
'type' => 'option',
));
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize, 'lunatek_blog_text_control', array(
'label' => __( 'Blog Section Heading Text', 'lunatek' ),
'description' => __( 'Choose the heading text you would like to display above posts on the front page.<br /><br />This text will show when displaying posts and using widgets on the front page.', 'lunatek' ),
'section' => 'lunatek_blog_section',
'settings' => 'lunatek_blog_text',
'type' => 'text',
)));
}
add_action( 'wp_enqueue_scripts', 'lunatek_css' );
function lunatek_css() {
$handle = defined( 'CHILD_THEME_NAME' ) && CHILD_THEME_NAME ? sanitize_title_with_dashes( CHILD_THEME_NAME ) : 'child-theme';
$color_sitetitle = get_theme_mod( 'lunatek_sitetitle_color', lunatek_customizer_get_default_sitetitle_color() );
$color_headingstitles = get_theme_mod( 'lunatek_headingstitles_color', lunatek_customizer_get_default_headingstitles_color() );
$color_topnavbase = get_theme_mod( 'lunatek_topnavbase_color', lunatek_customizer_get_default_topnavbase_color() );
$color_topnavlink = get_theme_mod( 'lunatek_topnavlink_color', lunatek_customizer_get_default_topnavlink_color() );
$color_topnavhover = get_theme_mod( 'lunatek_topnavhover_color', lunatek_customizer_get_default_topnavhover_color() );
$color_navborder = get_theme_mod( 'lunatek_navborder_color', lunatek_customizer_get_default_navborder_color() );
$color_link = get_theme_mod( 'lunatek_link_color', lunatek_customizer_get_default_link_color() );
$color_hover = get_theme_mod( 'lunatek_hover_color', lunatek_customizer_get_default_hover_color() );
$css = '';
$css .= ( get_header_image() != '' ) ? sprintf( '
.header-image .title-area,
.header-image .site-title > a {
min-height: %spx;
}
', $height ) : '';
$css .= ( lunatek_customizer_get_default_sitetitle_color() !== $color_sitetitle ) ? sprintf( '
.site-title,
.site-title a,
.site-description {
color: %1$s;
}
', $color_sitetitle ) : '';
$css .= ( lunatek_customizer_get_default_headingstitles_color() !== $color_headingstitles ) ? sprintf( '
h1,
h2,
h3,
h4,
h5,
h6,
.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content h6,
.archive-title,
.author-box-title,
.entry-title,
.footer-widgets .widget-title,
.page .entry-title,
.widget-title,
enews-widget .widget-title {
color: %1$s;
}
', $color_headingstitles ) : '';
$css .= ( lunatek_customizer_get_default_topnavbase_color() !== $color_topnavbase ) ? sprintf( '
.top-wrap {
background: %1$s;
}
', $color_topnavbase ) : '';
$css .= ( lunatek_customizer_get_default_topnavlink_color() !== $color_topnavlink ) ? sprintf( '
.nav-top .simple-social-icons ul li a,
.nav-top .genesis-nav-menu a {
color: %1$s !important;
}
', $color_topnavlink ) : '';
$css .= ( lunatek_customizer_get_default_topnavhover_color() !== $color_topnavhover ) ? sprintf( '
.nav-top .simple-social-icons ul li a:hover,
.nav-top .genesis-nav-menu a:hover {
color: %1$s !important;
}
', $color_topnavhover ) : '';
$css .= ( lunatek_customizer_get_default_navborder_color() !== $color_navborder ) ? sprintf( '
.site-header .wrap,
.navigation-container.fixed {
border-top: 2px solid %1$s;
border-bottom: 2px solid %1$s;
}
.sidebar .enews-widget {
border: double %1$s !important;
}
', $color_navborder ) : '';
$css .= ( lunatek_customizer_get_default_link_color() !== $color_link ) ? sprintf( '
a,
.archive-pagination.pagination a,
.entry-meta a,
.genesis-nav-menu a,
.genesis-nav-menu .menu-item,
.genesis-nav-menu .sub-menu a:hover,
.name,
.responsive-menu > .menu-item-has-children:before,
.responsive-menu-icon::before,
.responsive-menu-icon,
.site-footer a {
color: %1$s;
}
.ninja-forms-req-symbol {
color: %1$s !important;
}
', $color_link ) : '';
$css .= ( lunatek_customizer_get_default_hover_color() !== $color_hover ) ? sprintf( '
a:hover,
form.search-form input,
.description,
.genesis-nav-menu a:hover,
.genesis-nav-menu .menu-item:hover,
.genesis-nav-menu .menu-item:hover > .sub-menu,
.genesis-nav-menu li.highlight > a:hover,
.genesis_responsive_slider a:hover,
.genesis-nav-menu .sub-menu a,
.archive .content .entry:hover,
.archive .content .entry:hover a,
.archive .content .entry:hover .entry-time,
.archive .content .entry:hover .entry-content .box .count,
.entry-title a:hover,
.site-footer a:hover {
color: %1$s;
}
', $color_hover ) : '';
if ( lunatek_customizer_get_default_sitetitle_color() !== $color_sitetitle || lunatek_customizer_get_default_headingstitles_color() !== $color_headingstitles || lunatek_customizer_get_default_topnavbase_color() !== $color_topnavbase || lunatek_customizer_get_default_topnavlink_color() !== $color_topnavlink || lunatek_customizer_get_default_topnavhover_color() !== $color_topnavhover || lunatek_customizer_get_default_navborder_color() !== $color_navborder || lunatek_customizer_get_default_link_color() !== $color_link || lunatek_customizer_get_default_hover_color() !== $color_hover ) {
$css .= '
}
';
}
if( $css ){
wp_add_inline_style( $handle, $css );
}
}