[Resolved] How do I remove Page Header Settings from selected CPT's and Taxonomies?

Home Forums Support [Resolved] How do I remove Page Header Settings from selected CPT's and Taxonomies?

Home Forums Support How do I remove Page Header Settings from selected CPT's and Taxonomies?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #449861
    ninjajay

    I’m just wondering if there is a way that I can disable the page header settings from appearing on selected custom taxonomy and post type admin pages?

    In another plugin I use (Restrict Content Pro) I can use a filter to stop the plugin’s settings from appearing selected taxonomies. The way it works in RCP is the filter is passed an array of taxonomies, from there I just remove the taxonomies from the array where I don’t want the settings to appear.

    Here is what it looks like in RCP:

    
    function exclude_taxonomies_from_rcp( $taxonomies ) {
        return array_diff( $taxonomies, [ 'team', 'season', 'opposition', 'sponsorship-level' ] ) ;
    }
    add_filter( 'rcp_get_restricted_taxonomies', 'exclude_taxonomies_from_rcp', 20 );
    
    #449925
    Tom
    Lead Developer
    Lead Developer

    Hey Jay,

    Just so I understand, you want to remove the Page Header select dropdown from inside specific taxonomy edit/add pages and from the “Layout” metabox?

    Let me know 🙂

    #450014
    ninjajay

    Yes that’s exactly right, custom taxonomies and post types. The only reason I enabled the page header functionality on this site is because I wanted control over the featured image placement.

    #450500
    Tom
    Lead Developer
    Lead Developer

    Featured images are all handled by the Blog module now in Customize > Layout > Blog.

    Page Headers only apply when there’s page header content involved.

    Either way, you should be able to do this:

    add_action( 'init', 'tu_remove_page_header_tax', 20 );
    function tu_remove_page_header_tax() {
        $taxonomies = array( 'one-taxonomy-id', 'another-id' );
        foreach ( $taxonomies  as $taxonomy ) {
            remove_action( $taxonomy . '_add_form_fields', 'generate_page_header_tax_new_ph_field' );
            remove_action( $taxonomy . '_edit_form_fields', 'generate_page_header_tax_edit_ph_field' );
            remove_action( 'edit_' . $taxonomy,   'generate_page_header_tax_save_ph' );
            remove_action( 'create_' . $taxonomy, 'generate_page_header_tax_save_ph' );
        }
    
        $post_types = array( 'one-post-type-id', 'another-one' );
        if ( in_array( get_post_type(), $post_types ) ) {
            remove_action( 'generate_layout_meta_box_menu_item', 'generate_premium_page_header_menu_item' );
        }
    }
    #452585
    ninjajay

    Thanks so much for the support Tom I’ve disabled the page header add-on. But, it’s great to have the code, I can think of multiple use cases where I’d like to disable the page header settings on CPT’s and Taxonomies.

    #452638
    Tom
    Lead Developer
    Lead Developer

    Glad I could help! 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.