get_default_post_to_edit example

        $post_data['edit_date'] = false;

        if ( ! empty( $dateCreated ) ) {
            $post_data['post_date']     = iso8601_to_datetime( $dateCreated );
            $post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'gmt' );

            // Flag the post date to be edited.             $post_data['edit_date'] = true;
        }

        if ( ! isset( $post_data['ID'] ) ) {
            $post_data['ID'] = get_default_post_to_edit( $post_data['post_type'], true )->ID;
        }
        $post_id = $post_data['ID'];

        if ( 'post' === $post_data['post_type'] ) {
            $error = $this->_toggle_sticky( $post_data$update );
            if ( $error ) {
                return $error;
            }
        }

        if ( isset( $post_data['post_thumbnail'] ) ) {
            
$editing = true;

if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_can( $post_type_object->cap->create_posts ) ) {
    wp_die(
        '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
        '<p>' . __( 'Sorry, you are not allowed to create posts as this user.' ) . '</p>',
        403
    );
}

$post    = get_default_post_to_edit( $post_type, true );
$post_ID = $post->ID;

/** This filter is documented in wp-admin/post.php */
if ( apply_filters( 'replace_editor', false, $post ) !== true ) {
    if ( use_block_editor_for_post( $post ) ) {
        require ABSPATH . 'wp-admin/edit-form-blocks.php';
    } else {
        wp_enqueue_script( 'autosave' );
        require ABSPATH . 'wp-admin/edit-form-advanced.php';
    }
} else {
    
if ( ! current_user_can( 'edit_posts' ) ) {
        return;
    }

    // Check if a new auto-draft (= no new post_ID) is needed or if the old can be used.     $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID.
    if ( $last_post_id ) {
        $post = get_post( $last_post_id );

        if ( empty( $post ) || 'auto-draft' !== $post->post_status ) { // auto-draft doesn't exist anymore.             $post = get_default_post_to_edit( 'post', true );
            update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.         } else {
            $post->post_title = ''; // Remove the auto draft title.         }
    } else {
        $post    = get_default_post_to_edit( 'post', true );
        $user_id = get_current_user_id();

        // Don't create an option if this is a super admin who does not belong to this site.         if ( in_array( get_current_blog_id()array_keys( get_blogs_of_user( $user_id ) ), true ) ) {
            update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.

function get_default_page_to_edit() {
    _deprecated_function( __FUNCTION__, '3.5.0', "get_default_post_to_edit( 'page' )" );

    $page = get_default_post_to_edit();
    $page->post_type = 'page';
    return $page;
}

/** * This was once used to create a thumbnail from an Image given a maximum side size. * * @since 1.2.0 * @deprecated 3.5.0 Use image_resize() * @see image_resize() * * @param mixed $file Filename of the original image, Or attachment ID. * @param int $max_side Maximum length of a single side for the thumbnail. * @param mixed $deprecated Never used. * @return string Thumbnail path on success, Error string on failure. */

    public function inline_edit() {
        global $mode;

        $screen = $this->screen;

        $post             = get_default_post_to_edit( $screen->post_type );
        $post_type_object = get_post_type_object( $screen->post_type );

        $taxonomy_names          = get_object_taxonomies( $screen->post_type );
        $hierarchical_taxonomies = array();
        $flat_taxonomies         = array();

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

            $show_in_quick_edit = $taxonomy->show_in_quick_edit;

            
Home | Imprint | This part of the site doesn't use cookies.