在主题操作之后运行插件操作(初始化,自定义分类法)

时间:2019-06-01 17:41:02

标签: wordpress wordpress-theming

我正在开发WordPress插件,以将元字段添加到分类法中。它将它们添加到类别和标签,但不添加主题注册的自定义分类法。似乎插件操作在注册分类法的主题操作之前运行。

我尝试将插件的优先级设置为高于或降低主题,这没有用。

在插件类中:

add_action( 'init', [ $this, 'registerTaxonomies' ], 1000 );
//...
public function registerTaxonomies() {

    $taxonomies = get_taxonomies( [
        'public'       => true,
        'show_in_menu' => true,
    ], 'objects' );
    foreach ( $taxonomies as $taxonomy ) {
        add_action( $taxonomy->name . '_add_form_fields', [ $this, 'taxonomyAdd' ], 100, 2 );
        add_action( $taxonomy->name . '_edit_form_fields', [ $this, 'taxonomyEdit' ], 100, 2 );
        add_action( 'created_' . $taxonomy->name, [ $this, 'taxonomySave' ], 100, 2 );
        add_action( 'edited_' . $taxonomy->name, [ $this, 'taxonomyUpdate' ], 100, 2 );
        add_filter( 'manage_edit-' . $taxonomy->name . '_columns', [ $this, 'taxonomyColumns' ] );
        add_filter( 'manage_' . $taxonomy->name . '_custom_column', [
            $this,
            'taxonomyColumnContent'
        ], 100, 3 );
    }

}

在主题functions.php中:

add_action( 'init', 'rehabtheme_register_post_types', 10 );
add_action( 'init', 'rehabtheme_register_post_types', 10 );

结果是,对于自定义分类法,附加到初始化操作的代码没有执行,我没有在表单中注入自定义元字段。

0 个答案:

没有答案