This topic contains 4 replies, has 2 voices, and was last updated by  Anh Tran 1 year, 10 months ago.

  • Creator
    Topic
  • #5411
    Resolved
    carassius
    Participant

    Would be good to be able to disable default WordPress functions such as editor, thumbnails, excerpt etc

    ACF has this functionality and would be great to have it included, especially using the builder as you could have them as checkboxes

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #5422

    Anh Tran
    Keymaster

    Does this belong to the post type object itself? I think it’s easy to do it with the remove_post_type_support function (https://developer.wordpress.org/reference/functions/remove_post_type_support/).

    #5425

    carassius
    Participant

    Yes, but conditional

    Eg: this is the function I wrote that determines the home page and then removes the editor with the remove_post_type_support

    /*
    * Hide editor on home page
    * Since v1.0.0
    */
    function homepage_hide_editor() {
        
        // Determine which admin screen we are in
        $screen = get_current_screen();
        // Ensures we are currently editing
        if ( $screen->base != 'post' ) {
            
            // If not editing then escape function
            return;
            
        } else {
            
            // Get the home page ID
            $frontpage_id = get_option('page_on_front');
            
            // Get current post ID
            $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
            // Checks current post ID matches home page ID
            if($post_id == $frontpage_id){
                
                // Removes editor from home page
                remove_post_type_support('page', 'editor');
                
            }
            
        }
        
    }
    add_action( 'current_screen', 'homepage_hide_editor' );
    #5426

    carassius
    Participant

    I would like to see something like this perhaps

    
    $meta_boxes[] = array(
        'title'      => __( 'Include/Exclude', 'wcd-tradie' ),
        'post_types' => 'page',
            
        // Which page to show on
        'include' => array(
            'slug'            => array( 'home' ),
        ),
            
        // What fields to remove from page
        'exclude' => array(
            'type'            => array( 'editor', 'thumbnail', 'revisions' ),
        ),
            
        'fields'     => array(
                
            array(
                'id'   => 'text',
                'name' => __( 'Text', 'language' ),
                'type' => 'text',
                'std'  => __( 'A Text Field', 'language' ),
            ),
            
        ),
    );
    
    #5449

    Anh Tran
    Keymaster

    OK, I got it. It’s actually beyond the scope of the plugin. Include/exclude here means for meta boxes and what you want seems to be for post elements. I will think about this and if it’s not hard to implement, I will do it.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.