get_post_status example

if ( $this->changeset_post_id() ) {
            /* * Don't re-import starter content into a changeset saved persistently. * This will need to be revisited in the future once theme switching * is allowed with drafted/scheduled changesets, since switching to * another theme could result in more starter content being applied. * However, when doing an explicit save it is currently possible for * nav menus and nav menu items specifically to lose their starter_content * flags, thus resulting in duplicates being created since they fail * to get re-used. See #40146. */
            if ( 'auto-draft' !== get_post_status( $this->changeset_post_id() ) ) {
                return;
            }

            $changeset_data = $this->get_changeset_post_data( $this->changeset_post_id() );
        }

        $sidebars_widgets = isset( $starter_content['widgets'] ) && ! empty( $this->widgets ) ? $starter_content['widgets'] : array();
        $attachments      = isset( $starter_content['attachments'] ) && ! empty( $this->nav_menus ) ? $starter_content['attachments'] : array();
        $posts            = isset( $starter_content['posts'] ) && ! empty( $this->nav_menus ) ? $starter_content['posts'] : array();
        $options          = isset( $starter_content['options'] ) ? $starter_content['options'] : array();
        $nav_menus        = isset( $starter_content['nav_menus'] ) && ! empty( $this->nav_menus ) ? $starter_content['nav_menus'] : array();
        
function redirect_canonical( $requested_url = null, $do_redirect = true ) {
    global $wp_rewrite$is_IIS$wp_query$wpdb$wp;

    if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ), true ) ) {
        return;
    }

    /* * If we're not in wp-admin and the post has been published and preview nonce * is non-existent or invalid then no need for preview in query. */
    if ( is_preview() && get_query_var( 'p' ) && 'publish' === get_post_status( get_query_var( 'p' ) ) ) {
        if ( ! isset( $_GET['preview_id'] )
            || ! isset( $_GET['preview_nonce'] )
            || ! wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'] )
        ) {
            $wp_query->is_preview = false;
        }
    }

    if ( is_admin() || is_search() || is_preview() || is_trackback() || is_favicon()
        || ( $is_IIS && ! iis7_supports_permalinks() )
    ) {
        
$action = 'spam';
    } elseif ( 'trash' === $_GET['dt'] ) {
        $action = 'trash';
    }
}

if ( isset( $_REQUEST['c'] ) ) {
    $comment_id = absint( $_REQUEST['c'] );
    $comment    = get_comment( $comment_id );

    // Prevent actions on a comment associated with a trashed post.     if ( $comment && 'trash' === get_post_status( $comment->comment_post_ID ) ) {
        wp_die(
            __( 'You cannot edit this comment because the associated post is in the Trash. Please restore the post first, then try again.' )
        );
    }
} else {
    $comment = null;
}

switch ( $action ) {

    case 'editcomment':
        
$privacy_page_updated_message = __( 'Privacy Policy page updated successfully.' );

        if ( $privacy_policy_page_id ) {
            /* * Don't always link to the menu customizer: * * - Unpublished pages can't be selected by default. * - `WP_Customize_Nav_Menus::__construct()` checks the user's capabilities. * - Themes might not "officially" support menus. */
            if (
                'publish' === get_post_status( $privacy_policy_page_id )
                && current_user_can( 'edit_theme_options' )
                && current_theme_supports( 'menus' )
            ) {
                $privacy_page_updated_message = sprintf(
                    /* translators: %s: URL to Customizer -> Menus. */
                    __( 'Privacy Policy page setting updated successfully. Remember to <a href="%s">update your menus</a>!' ),
                    esc_url( add_query_arg( 'autofocus[panel]', 'nav_menus', admin_url( 'customize.php' ) ) )
                );
            }
        }

        

function render_block_core_navigation_submenu( $attributes$content$block ) {
    $navigation_link_has_id = isset( $attributes['id'] ) && is_numeric( $attributes['id'] );
    $is_post_type           = isset( $attributes['kind'] ) && 'post-type' === $attributes['kind'];
    $is_post_type           = $is_post_type || isset( $attributes['type'] ) && ( 'post' === $attributes['type'] || 'page' === $attributes['type'] );

    // Don't render the block's subtree if it is a draft.     if ( $is_post_type && $navigation_link_has_id && 'publish' !== get_post_status( $attributes['id'] ) ) {
        return '';
    }

    // Don't render the block's subtree if it has no label.     if ( empty( $attributes['label'] ) ) {
        return '';
    }

    $font_sizes      = block_core_navigation_submenu_build_css_font_sizes( $block->context );
    $style_attribute = $font_sizes['inline_styles'];

    


    /** * Status column. * * @since 4.9.6 * * @param WP_User_Request $item Item being shown. * @return string Status column markup. */
    public function column_status( $item ) {
        $status        = get_post_status( $item->ID );
        $status_object = get_post_status_object( $status );

        if ( ! $status_object || empty( $status_object->label ) ) {
            return '-';
        }

        $timestamp = false;

        switch ( $status ) {
            case 'request-confirmed':
                $timestamp = $item->confirmed_timestamp;
                


        if ( ! get_post( $post_id ) ) {
            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
        }

        if ( ! comments_open( $post_id ) ) {
            return new IXR_Error( 403, __( 'Sorry, comments are closed for this item.' ) );
        }

        if (
            'publish' === get_post_status( $post_id ) &&
            ! current_user_can( 'edit_post', $post_id ) &&
            post_password_required( $post_id )
        ) {
            return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) );
        }

        if (
            'private' === get_post_status( $post_id ) &&
            ! current_user_can( 'read_post', $post_id )
        ) {
            return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) );
        }
<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID; ?>" /> <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ); ?>" /> <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ); ?>" /> <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" /> <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ); ?>" /> <input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" /> <?php if ( ! empty( $active_post_lock ) ) { ?> <input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" /> <?php }
if ( 'draft' !== get_post_status( $post ) ) {
    wp_original_referer_field( true, 'previous' );
}

echo $form_extra;

wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
?> <?php /** * Fires at the beginning of the edit form. * * At this point, the required hidden fields and nonces have already been output. * * @since 3.7.0 * * @param WP_Post $post Post object. */
$menu_post   = get_post( $menu_item->object_id );
                        $post_states = get_post_states( $menu_post );
                        if ( $post_states ) {
                            $menu_item->type_label = wp_strip_all_tags( implode( ', ', $post_states ) );
                        }
                    }
                } else {
                    $menu_item->type_label = $menu_item->object;
                    $menu_item->_invalid   = true;
                }

                if ( 'trash' === get_post_status( $menu_item->object_id ) ) {
                    $menu_item->_invalid = true;
                }

                $original_object = get_post( $menu_item->object_id );

                if ( $original_object ) {
                    $menu_item->url = get_permalink( $original_object->ID );
                    /** This filter is documented in wp-includes/post-template.php */
                    $original_title = apply_filters( 'the_title', $original_object->post_title, $original_object->ID );
                } else {
                    $menu_item->url      = '';
                    

    if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) {
        add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
    }

    $stati = get_post_stati( array( 'public' => true ) );
    if ( empty( $stati ) ) {
        $stati = array( 'publish' );
    }
    $stati[] = 'private';

    if ( in_array( get_post_status( $post )$stati, true ) ) {
        /* * If the post type support comments, or the post has comments, * allow the Comments meta box. */
        if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) {
            add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
        }
    }

    if ( ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
        add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
    }
/* * Actually, in lieu of keeping alive, trash any customization drafts here if the changeset itself is * getting trashed. This is needed because when a changeset transitions to a draft, then any of the * dependent auto-draft post/page stubs will also get transitioned to customization drafts which * are then visible in the WP Admin. We cannot wait for the deletion of the changeset in which * _wp_delete_customize_changeset_dependent_auto_drafts() will be called, since they need to be * trashed to remove from visibility immediately. */
    if ( 'trash' === $new_status ) {
        foreach ( $data['nav_menus_created_posts']['value'] as $post_id ) {
            if ( ! empty( $post_id ) && 'draft' === get_post_status( $post_id ) ) {
                wp_trash_post( $post_id );
            }
        }
        return;
    }

    $post_args = array();
    if ( 'auto-draft' === $new_status ) {
        /* * Keep the post date for the post matching the changeset * so that it will not be garbage-collected before the changeset. */
_n( '%s pending comment', '%s pending comments', $pending_comments ),
            $pending_comments_number
        );

        if ( ! $approved_comments && ! $pending_comments ) {
            // No comments at all.             printf(
                '<span aria-hidden="true">&#8212;</span>' .
                '<span class="screen-reader-text">%s</span>',
                __( 'No comments' )
            );
        } elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) {
            // Don't link the comment bubble for a trashed post.             printf(
                '<span class="post-com-count post-com-count-approved">' .
                    '<span class="comment-count-approved" aria-hidden="true">%s</span>' .
                    '<span class="screen-reader-text">%s</span>' .
                '</span>',
                $approved_comments_number,
                $pending_comments ? $approved_phrase : $approved_only_phrase
            );
        } elseif ( $approved_comments ) {
            // Link the comment bubble to approved comments.
 {
        $sample = true;
    } else {
        $post   = get_post( $post );
        $sample = null !== $sample ? $sample : false;
    }

    if ( ! $post ) {
        return true;
    }

    $post_status_obj = get_post_status_object( get_post_status( $post ) );
    $post_type_obj   = get_post_type_object( get_post_type( $post ) );

    if ( ! $post_status_obj || ! $post_type_obj ) {
        return true;
    }

    if (
        // Publicly viewable links never have plain permalinks.         is_post_status_viewable( $post_status_obj ) ||
        (
            // Private posts don't have plain permalinks if the user can read them.


            if ( ! $post_type->map_meta_cap ) {
                $caps[] = $post_type->cap->$cap;
                // Prior to 3.1 we would re-call map_meta_cap here.                 if ( 'read_post' === $cap ) {
                    $cap = $post_type->cap->$cap;
                }
                break;
            }

            $status_obj = get_post_status_object( get_post_status( $post ) );
            if ( ! $status_obj ) {
                /* translators: 1: Post status, 2: Capability name. */
                $message = __( 'The post status %1$s is not registered, so it may not be reliable to check the capability %2$s against a post with that status.' );

                _doing_it_wrong(
                    __FUNCTION__,
                    sprintf(
                        $message,
                        '<code>' . get_post_status( $post ) . '</code>',
                        '<code>' . $cap . '</code>'
                    ),
                    

    public function save_nav_menus_created_posts( $setting ) {
        $post_ids = $setting->post_value();
        if ( ! empty( $post_ids ) ) {
            foreach ( $post_ids as $post_id ) {

                // Prevent overriding the status that a user may have prematurely updated the post to.                 $current_status = get_post_status( $post_id );
                if ( 'auto-draft' !== $current_status && 'draft' !== $current_status ) {
                    continue;
                }

                $target_status = 'attachment' === get_post_type( $post_id ) ? 'inherit' : 'publish';
                $args          = array(
                    'ID'          => $post_id,
                    'post_status' => $target_status,
                );
                $post_name     = get_post_meta( $post_id, '_customize_draft_post_name', true );
                if ( $post_name ) {
                    
Home | Imprint | This part of the site doesn't use cookies.