【发布时间】:2017-01-31 22:02:43
【问题描述】:
在我的父主题 functions.php 文件中添加了一些定制器设置,如下所示:
class Ichi_Customizer extends Youxi_Customize_Manager {
/**
* Constructor
*/
public function __construct() {
parent::__construct();
add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) );
add_action( 'customize_register', array( $this, 'color_customizer' ) );
add_action( 'customize_register', array( $this, 'general_customizer' ) );
add_action( 'customize_register', array( $this, 'social_customizer' ) );
add_action( 'customize_register', array( $this, 'typography_customizer' ) );
我想在我的子主题中删除其中的一些,而不编辑我的父functions.php。我试图从我的 子主题 functions.php 中删除定制器设置,如下所示:
// Remove settings from parent theme customizer
function remove_custom( $wp_customize ) {
remove_action( 'customize_register', array( $this, 'color_customizer' ) );
}
add_action( 'customize_register', 'remove_custom', 1000 );
这不会删除所需的定制器设置。我错过了什么?
更新
一直在尝试这种替代方法,像这样覆盖整个父函数:
add_action( 'after_setup_theme', function() {
class Ichi_Customizer extends Youxi_Customize_Manager {
/**
* Constructor
*/
public function __construct() {
parent::__construct();
remove_action( 'customize_register', array( $this, 'color_customizer' ) );
}
}
$GLOBALS[ 'youxi_customize_manager' ] = new Ichi_Customizer();
}, 42 );
但是,这也不起作用!
【问题讨论】: