• syhc

    (@syhc)


    Right now, I have modified the PPP plugin to limit the post types that the PPP will work with by adding a filter. It would be nice if the plugin support such a filter so I do not have to modify the plugin.

    For those who are wondering how I did it:

    public static function post_submitbox_misc_actions() {
        $post_types = get_post_types(
            array(
                'public' => true,
            )
        );
        $post_types = apply_filters('ppp_post_types', $post_types);
        ...
    public static function enqueue_script( $hook_suffix ) {
        if ( ! in_array( $hook_suffix, array( 'post.php', 'post-new.php' ), true ) ) {
            return;
        }
    
        if ( ! in_array(get_current_screen()->post_type, apply_filters('ppp_post_types', []))  ) {
            return;
        } elseif ( get_current_screen()->is_block_editor() ) {
            ...

    For the enqueue_script version, it might been better to pass the post types into Gutenberg block.

  • The topic ‘Feature: Limit Post Types’ is closed to new replies.