post_type_supports example

if ( ! wp_check_post_lock( $post->ID ) ) {
            $active_post_lock = wp_set_post_lock( $post->ID );

            if ( 'attachment' !== $post_type ) {
                wp_enqueue_script( 'autosave' );
            }
        }

        $post = get_post( $post_id, OBJECT, 'edit' );

        if ( post_type_supports( $post_type, 'comments' ) ) {
            wp_enqueue_script( 'admin-comments' );
            enqueue_comment_hotkeys_js();
        }

        require ABSPATH . 'wp-admin/edit-form-advanced.php';

        break;

    case 'editattachment':
        check_admin_referer( 'update-post_' . $post_id );

        
if ( $thumb_url ) {
            $thumb_url = $thumb_url[0];
        }
    }

    $post            = get_post( $attachment_id );
    $current_post_id = ! empty( $_GET['post_id'] ) ? (int) $_GET['post_id'] : 0;

    $default_args = array(
        'errors'     => null,
        'send'       => $current_post_id ? post_type_supports( get_post_type( $current_post_id ), 'editor' ) : true,
        'delete'     => true,
        'toggle'     => true,
        'show_title' => true,
    );

    $parsed_args = wp_parse_args( $args$default_args );

    /** * Filters the arguments used to retrieve an image for the edit image form. * * @since 3.1.0 * * @see get_media_item * * @param array $parsed_args An array of arguments. */
add_action( 'admin_footer', '_admin_notice_post_locked' );
    }

    unset( $check_users );
}

wp_enqueue_script( 'post' );

$_wp_editor_expand   = false;
$_content_editor_dfw = false;

if ( post_type_supports( $post_type, 'editor' )
    && ! wp_is_mobile()
    && ! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) )
) {
    /** * Filters whether to enable the 'expand' functionality in the post editor. * * @since 4.0.0 * @since 4.1.0 Added the `$post_type` parameter. * * @param bool $expand Whether to enable the 'expand' functionality. Default true. * @param string $post_type Post type. */


/* * Assign initial edits, if applicable. These are not initially assigned to the persisted post, * but should be included in its save payload. */
$initial_edits = array();
$is_new_post   = false;
if ( 'auto-draft' === $post->post_status ) {
    $is_new_post = true;
    // Override "(Auto Draft)" new post default title with empty string, or filtered value.     if ( post_type_supports( $post->post_type, 'title' ) ) {
        $initial_edits['title'] = $post->post_title;
    }

    if ( post_type_supports( $post->post_type, 'editor' ) ) {
        $initial_edits['content'] = $post->post_content;
    }

    if ( post_type_supports( $post->post_type, 'excerpt' ) ) {
        $initial_edits['excerpt'] = $post->post_excerpt;
    }
}



if ( ! function_exists( 'twenty_twenty_one_posted_by' ) ) {
    /** * Prints HTML with meta information about theme author. * * @since Twenty Twenty-One 1.0 * * @return void */
    function twenty_twenty_one_posted_by() {
        if ( ! get_the_author_meta( 'description' ) && post_type_supports( get_post_type(), 'author' ) ) {
            echo '<span class="byline">';
            printf(
                /* translators: %s: Author name. */
                esc_html__( 'By %s', 'twentytwentyone' ),
                '<a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author">' . esc_html( get_the_author() ) . '</a>'
            );
            echo '</span>';
        }
    }
}


    public function prepare_item( $id, array $fields ) {
        $post = get_post( $id );

        $data = array();

        if ( in_array( WP_REST_Search_Controller::PROP_ID, $fields, true ) ) {
            $data[ WP_REST_Search_Controller::PROP_ID ] = (int) $post->ID;
        }

        if ( in_array( WP_REST_Search_Controller::PROP_TITLE, $fields, true ) ) {
            if ( post_type_supports( $post->post_type, 'title' ) ) {
                add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
                $data[ WP_REST_Search_Controller::PROP_TITLE ] = get_the_title( $post->ID );
                remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
            } else {
                $data[ WP_REST_Search_Controller::PROP_TITLE ] = '';
            }
        }

        if ( in_array( WP_REST_Search_Controller::PROP_URL, $fields, true ) ) {
            $data[ WP_REST_Search_Controller::PROP_URL ] = get_permalink( $post->ID );
        }

        
function wp_save_post_revision( $post_id ) {
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
        return;
    }

    $post = get_post( $post_id );

    if ( ! $post ) {
        return;
    }

    if ( ! post_type_supports( $post->post_type, 'revisions' ) ) {
        return;
    }

    if ( 'auto-draft' === $post->post_status ) {
        return;
    }

    if ( ! wp_revisions_enabled( $post ) ) {
        return;
    }

    


    $ptype = get_post_type_object( $post_data['post_type'] );
    if ( ! current_user_can( 'edit_post', $post_id ) ) {
        if ( 'page' === $post_data['post_type'] ) {
            wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
        } else {
            wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
        }
    }

    if ( post_type_supports( $ptype->name, 'revisions' ) ) {
        $revisions = wp_get_post_revisions(
            $post_id,
            array(
                'order'          => 'ASC',
                'posts_per_page' => 1,
            )
        );
        $revision  = current( $revisions );

        // Check if the revisions have been upgraded.         if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) {
            

    protected function prepare_links( $id ) {
        $base = sprintf( '%s/%s', $this->namespace, $this->rest_base );

        $links = array(
            'self' => array(
                'href' => rest_url( trailingslashit( $base ) . $id ),
            ),
        );

        if ( post_type_supports( $this->post_type, 'revisions' ) ) {
            $revisions                = wp_get_latest_revision_id_and_total_count( $id );
            $revisions_count          = ! is_wp_error( $revisions ) ? $revisions['count'] : 0;
            $revisions_base           = sprintf( '/%s/%d/revisions', $base$id );
            $links['version-history'] = array(
                'href'  => rest_url( $revisions_base ),
                'count' => $revisions_count,
            );
        }

        return $links;
    }

    
$post_excerpt = $postarr['post_excerpt'];

    if ( isset( $postarr['post_name'] ) ) {
        $post_name = $postarr['post_name'];
    } elseif ( $update ) {
        // For an update, don't modify the post_name if it wasn't supplied as an argument.         $post_name = $post_before->post_name;
    }

    $maybe_empty = 'attachment' !== $post_type
        && ! $post_content && ! $post_title && ! $post_excerpt
        && post_type_supports( $post_type, 'editor' )
        && post_type_supports( $post_type, 'title' )
        && post_type_supports( $post_type, 'excerpt' );

    /** * Filters whether the post should be considered "empty". * * The post is considered "empty" if both: * 1. The post type supports the title, editor, and excerpt fields * 2. The title, editor, and excerpt fields are all empty * * Returning a truthy value from the filter will effectively short-circuit * the new post being inserted and return 0. If $wp_error is true, a WP_Error * will be returned instead. * * @since 3.3.0 * * @param bool $maybe_empty Whether the post should be considered "empty". * @param array $postarr Array of post data. */
return new WP_Error(
                'rest_forbidden_orderby',
                __( 'Sorry, you are not allowed to order users by this parameter.' ),
                array( 'status' => rest_authorization_required_code() )
            );
        }

        if ( 'authors' === $request['who'] ) {
            $types = get_post_types( array( 'show_in_rest' => true ), 'objects' );

            foreach ( $types as $type ) {
                if ( post_type_supports( $type->name, 'author' )
                    && current_user_can( $type->cap->edit_posts ) ) {
                    return true;
                }
            }

            return new WP_Error(
                'rest_forbidden_who',
                __( 'Sorry, you are not allowed to query users by this parameter.' ),
                array( 'status' => rest_authorization_required_code() )
            );
        }

        

    public function get_columns() {
        $post_type = $this->screen->post_type;

        $posts_columns = array();

        $posts_columns['cb'] = '<input type="checkbox" />';

        /* translators: Posts screen column name. */
        $posts_columns['title'] = _x( 'Title', 'column name' );

        if ( post_type_supports( $post_type, 'author' ) ) {
            $posts_columns['author'] = __( 'Author' );
        }

        $taxonomies = get_object_taxonomies( $post_type, 'objects' );
        $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );

        /** * Filters the taxonomy columns in the Posts list table. * * The dynamic portion of the hook name, `$post_type`, refers to the post * type slug. * * Possible hook names include: * * - `manage_taxonomies_for_post_columns` * - `manage_taxonomies_for_page_columns` * * @since 3.5.0 * * @param string[] $taxonomies Array of taxonomy names to show columns for. * @param string $post_type The post type. */

function get_post_format( $post = null ) {
    $post = get_post( $post );

    if ( ! $post ) {
        return false;
    }

    if ( ! post_type_supports( $post->post_type, 'post-formats' ) ) {
        return false;
    }

    $_format = get_the_terms( $post->ID, 'post_format' );

    if ( empty( $_format ) ) {
        return false;
    }

    $format = reset( $_format );

    
 . mysql2date( 'H', $post->post_date, false ) . '</div> <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div> <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div> <div class="post_password">' . esc_html( $post->post_password ) . '</div>';

    if ( $post_type_object->hierarchical ) {
        echo '<div class="post_parent">' . $post->post_parent . '</div>';
    }

    echo '<div class="page_template">' . ( $post->page_template ? esc_html( $post->page_template ) : 'default' ) . '</div>';

    if ( post_type_supports( $post->post_type, 'page-attributes' ) ) {
        echo '<div class="menu_order">' . $post->menu_order . '</div>';
    }

    $taxonomy_names = get_object_taxonomies( $post->post_type );

    foreach ( $taxonomy_names as $taxonomy_name ) {
        $taxonomy = get_taxonomy( $taxonomy_name );

        if ( ! $taxonomy->show_in_quick_edit ) {
            continue;
        }

        
return new IXR_Error( 401, __( 'Invalid comment status.' ) );
        }

        $post_id = '';
        if ( isset( $struct['post_id'] ) ) {
            $post_id = absint( $struct['post_id'] );
        }

        $post_type = '';
        if ( isset( $struct['post_type'] ) ) {
            $post_type_object = get_post_type_object( $struct['post_type'] );
            if ( ! $post_type_object || ! post_type_supports( $post_type_object->name, 'comments' ) ) {
                return new IXR_Error( 404, __( 'Invalid post type.' ) );
            }
            $post_type = $struct['post_type'];
        }

        $offset = 0;
        if ( isset( $struct['offset'] ) ) {
            $offset = absint( $struct['offset'] );
        }

        $number = 10;
        
Home | Imprint | This part of the site doesn't use cookies.