【问题标题】:Wordpress Removing Parent Customizer settings in Child themeWordpress 删除子主题中的父定制器设置
【发布时间】: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 );

但是,这也不起作用!

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    我觉得这可以帮助你...

    改变

    function remove_custom( $wp_customize ) {
      remove_action( 'customize_register', array( $this, 'color_customizer' ) );
    }
    add_action( 'customize_register', 'remove_custom', 1000 );
    

    function remove_custom( $wp_customize ) {
      remove_action( 'customize_register', array( $this, 'color_customizer' ) );
    }
    add_action( 'after_setup_theme', 'remove_custom', 0 );
    

    【讨论】:

    猜你喜欢
    • 2014-11-29
    • 1970-01-01
    • 2019-07-17
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-18
    相关资源
    最近更新 更多