这是错误:
对/home/content/54/11786754/html/wp includes/class wp customize control中的非对象调用成员函数check\\u capabilities()。php在线161
这是我在函数中的代码。php
function lmao_customizer_register($wp_customize) {
$wp_customize->add_section(\'lmao_colors\', array(
\'title\' => __(\'colors\', \'lmao\'),
\'description\' => \'modify the theme colors\'
));
$wp_customize->add_setting(\'background_color\', array(
\'default\' => \'#fff\',
\'type\' => \'option\'
));
$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, \'background_color\', array(
\'label\' => __(\'Edit Background Color\', \'lmao\'),
\'section\' => \'lmao_colors\',
\'settings\' => \'background_color\'
) ));
$wp_customize->add_setting(\'link_color\', array(
\'default\' => \'#fff\',
\'type\' => \'option\'
));
$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, \'link_color\', array(
\'label\' => __(\'Edit link Color\', \'lmao\'),
\'section\' => \'lmao_colors\',
\'settings\' => \'link_color\'
) ));
$wp_customize->add_setting(\'link_background_color\', array(
\'default\' => \'#fff\',
\'type\' => \'option\'
));
$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, \'link_background_color\', array(
\'label\' => __(\'Edit link background Color\', \'lmao\'),
\'section\' => \'lmao_colors\',
\'settings\' => \'link_background_color\'
) ));
$wp_customize->add_setting(\'link_background_color_hover\', array(
\'default\' => \'#fff\',
\'type\' => \'option\'
));
$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, \'link_background_color_hover\', array(
\'label\' => __(\'Edit link background hover Color\', \'lmao\'),
\'section\' => \'lmao_colors\',
\'settings\' => \'link_background_color_hover\'
) ));
//start image settings
$wp_customize->add_section(\'lmao_images\', array(
\'title\' => __(\'Images\', \'lmao\'),
\'description\' => \'modify the theme images\'
));
$wp_customize->add_setting(\'main_image\', array(
\'default\' => \'http://hottraxstudioproductions.com/rawr/wp-content/uploads/2014/04/radio-logo.jpg\',
\'type\' => \'option\'
));
$wp_customize->add_control( new WP_Customize_image_Control($wp_customize, \'main_image\', array(
\'label\' => __(\'Edit main image\', \'lmao\'),
\'section\' => \'lmao_images\',
\'settings\' => \'main_image\'
) ));
//start copyright settings
$wp_customize->add_section(\'lmao_copyright\', array(
\'title\' => __(\'Copyright_Details\', \'lmao\'),
\'description\' => \'Edit copyright info\'
));
$wp_customize->add_setting(\'Copyright_Details\', array(
\'default\' => \'Copyright\',
\'type\' => \'option\'
));
$wp_customize->add_control(\'Copyright_Details\', array(
\'label\' => __(\'Edit copyright info\', \'lmao\'),
\'section\' => \'lmao_copyright\',
\'settings\' => \'copyright_details\'
));
}
function lmao_css_customizer() {
?>
<style type="text/css">
body { background-color: #<?php echo get_theme_mod(\'background_color\'); ? >;}
nav ul li a {
color: <?php echo get_theme_mod(\'link_color\'); ?>;
background-color: <?php echo get_theme_mod(\'link_background_color\'); ?>;
}
nav ul li a:hover {
background-color: <?php echo get_theme_mod(\'link_background_color_hover\'); ?>;
}
</style>
<?php
}
add_action(\'wp_head\', \'lmao_css_customizer\');
add_action(\'customize_register\', \'LMAO_customizer_register\');
如果您需要更多信息,请告诉我。。。
SO网友:starryVere
我对Wordpress开发还比较陌生,但这段代码不应该在customizer中。php,在“inc”文件夹中(在活动主题的文件夹中)?
此外,我知道抄本上说,这段特定的代码只是用于实时预览,但在我的一个项目中添加了它之后,它似乎解决了我的问题。因此,您可能需要为添加到customizer\\u register函数中的每个部分包含这些get命令。例如,在代码的第一位之前,请尝试包括:
function lmao_customize_register( $wp_customize ) {
$wp_customize->get_setting( \'lmao_colors\' )->transport=\'postMessage\';
}
add_action( \'customize_register\', \'testing_customize_register\' );
然后您将从添加节开始
function lmao_customizer_register($wp_customize) {
$wp_customize->add_section(\'lmao_colors\', array(
\'title\' => __(\'colors\', \'lmao\'),
\'description\' => \'modify the theme colors\'
));
$wp_customize->add_setting(\'background_color\', array(
\'default\' => \'#fff\',
\'type\' => \'option\'
));
$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, \'background_color\', array(
\'label\' => __(\'Edit Background Color\', \'lmao\'),
\'section\' => \'lmao_colors\',
\'settings\' => \'background_color\'
) ));
}
我希望这会有所帮助。如果不是,我很抱歉,就像我说的,我自己还是新手,但我想试着回答一下,因为你似乎已经有一段时间没有回复这个问题了。
祝你好运!