get_post_types example

 else {
            $include = false;
        }

        $blog_id = 0;
        if ( isset( $qv['blog_id'] ) ) {
            $blog_id = absint( $qv['blog_id'] );
        }

        if ( $qv['has_published_posts'] && $blog_id ) {
            if ( true === $qv['has_published_posts'] ) {
                $post_types = get_post_types( array( 'public' => true ) );
            } else {
                $post_types = (array) $qv['has_published_posts'];
            }

            foreach ( $post_types as &$post_type ) {
                $post_type = $wpdb->prepare( '%s', $post_type );
            }

            $posts_table        = $wpdb->get_blog_prefix( $blog_id ) . 'posts';
            $this->query_where .= " AND $wpdb->users.ID IN ( SELECT DISTINCT $posts_table.post_author FROM $posts_table WHERE $posts_table.post_status = 'publish' AND $posts_table.post_type IN ( " . implode( ', ', $post_types ) . ' ) )';
        }

        

function wp_edit_posts_query( $q = false ) {
    if ( false === $q ) {
        $q = $_GET;
    }
    $q['m']     = isset( $q['m'] ) ? (int) $q['m'] : 0;
    $q['cat']   = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
    $post_stati = get_post_stati();

    if ( isset( $q['post_type'] ) && in_array( $q['post_type']get_post_types(), true ) ) {
        $post_type = $q['post_type'];
    } else {
        $post_type = 'post';
    }

    $avail_post_stati = get_available_post_statuses( $post_type );
    $post_status      = '';
    $perm             = '';

    if ( isset( $q['post_status'] ) && in_array( $q['post_status']$post_stati, true ) ) {
        $post_status = $q['post_status'];
        


    /** * Returns the public post types, which excludes nav_items and similar types. * Attachments are also excluded. This includes custom post types with public = true. * * @since 5.5.0 * * @return WP_Post_Type[] Array of registered post type objects keyed by their name. */
    public function get_object_subtypes() {
        $post_types = get_post_types( array( 'public' => true ), 'objects' );
        unset( $post_types['attachment'] );

        $post_types = array_filter( $post_types, 'is_post_type_viewable' );

        /** * Filters the list of post object sub types available within the sitemap. * * @since 5.5.0 * * @param WP_Post_Type[] $post_types Array of registered post type objects keyed by their name. */
        
header( 'Content-Disposition: attachment; filename=' . $filename );
    header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );

    if ( 'all' !== $args['content'] && post_type_exists( $args['content'] ) ) {
        $ptype = get_post_type_object( $args['content'] );
        if ( ! $ptype->can_export ) {
            $args['content'] = 'post';
        }

        $where = $wpdb->prepare( "{$wpdb->posts}.post_type = %s", $args['content'] );
    } else {
        $post_types = get_post_types( array( 'can_export' => true ) );
        $esses      = array_fill( 0, count( $post_types ), '%s' );

        // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare         $where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types );
    }

    if ( $args['status'] && ( 'post' === $args['content'] || 'page' === $args['content'] ) ) {
        $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_status = %s", $args['status'] );
    } else {
        $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'";
    }

    
'menu-top menu-icon-comments',
        'menu-comments',
        'dashicons-admin-comments',
    );
    unset( $awaiting_mod );
}

$submenu['edit-comments.php'][0] = array( __( 'All Comments' ), 'edit_posts', 'edit-comments.php' );

$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group.
$types   = (array) get_post_types(
    array(
        'show_ui'      => true,
        '_builtin'     => false,
        'show_in_menu' => true,
    )
);
$builtin = array( 'post', 'page' );
foreach ( array_merge( $builtin$types ) as $ptype ) {
    $ptype_obj = get_post_type_object( $ptype );
    // Check if it should be a submenu.     if ( true !== $ptype_obj->show_in_menu ) {
        
/** * Checks whether a given request has permission to read types. * * @since 4.7.0 * * @param WP_REST_Request $request Full details about the request. * @return true|WP_Error True if the request has read access, WP_Error object otherwise. */
    public function get_items_permissions_check( $request ) {
        if ( 'edit' === $request['context'] ) {
            $types = get_post_types( array( 'show_in_rest' => true ), 'objects' );

            foreach ( $types as $type ) {
                if ( current_user_can( $type->cap->edit_posts ) ) {
                    return true;
                }
            }

            return new WP_Error(
                'rest_cannot_view',
                __( 'Sorry, you are not allowed to edit posts in this post type.' ),
                array( 'status' => rest_authorization_required_code() )
            );

    protected function check_read_active_theme_permission() {
        if ( current_user_can( 'edit_posts' ) ) {
            return true;
        }

        foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
            if ( current_user_can( $post_type->cap->edit_posts ) ) {
                return true;
            }
        }

        return new WP_Error(
            'rest_cannot_view_active_theme',
            __( 'Sorry, you are not allowed to view the active theme.' ),
            array( 'status' => rest_authorization_required_code() )
        );
    }

    
do_action( 'do_all_pings' );
}

/** * Performs all pingbacks. * * @since 5.6.0 */
function do_all_pingbacks() {
    $pings = get_posts(
        array(
            'post_type'        => get_post_types(),
            'suppress_filters' => false,
            'nopaging'         => true,
            'meta_key'         => '_pingme',
            'fields'           => 'ids',
        )
    );

    foreach ( $pings as $ping ) {
        delete_post_meta( $ping, '_pingme' );
        pingback( null, $ping );
    }
}
require_once __DIR__ . '/admin.php';

/** * @global string $typenow The post type of the current screen. */
global $typenow;

if ( ! $typenow ) {
    wp_die( __( 'Invalid post type.' ) );
}

if ( ! in_array( $typenowget_post_types( array( 'show_ui' => true ) ), true ) ) {
    wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
}

if ( 'attachment' === $typenow ) {
    if ( wp_redirect( admin_url( 'upload.php' ) ) ) {
        exit;
    }
}

/** * @global string $post_type * @global WP_Post_Type $post_type_object */
$user = wp_get_current_user();
    update_user_meta( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes );
}

/** * Creates meta boxes for any post type menu item.. * * @since 3.0.0 */
function wp_nav_menu_post_type_meta_boxes() {
    $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );

    if ( ! $post_types ) {
        return;
    }

    foreach ( $post_types as $post_type ) {
        /** * Filters whether a menu items meta box will be added for the current * object type. * * If a falsey value is returned instead of an object, the menu items * meta box for the current meta box object will not be added. * * @since 3.0.0 * * @param WP_Post_Type|false $post_type The current object to add a menu items * meta box for. */


                    $post_templates[ $type ][ $file ] = _cleanup_header_comment( $header[1] );
                }
            }

            $this->cache_add( 'post_templates', $post_templates );
        }

        if ( current_theme_supports( 'block-templates' ) ) {
            $block_templates = get_block_templates( array(), 'wp_template' );
            foreach ( get_post_types( array( 'public' => true ) ) as $type ) {
                foreach ( $block_templates as $block_template ) {
                    if ( ! $block_template->is_custom ) {
                        continue;
                    }

                    if ( isset( $block_template->post_types ) && ! in_array( $type$block_template->post_types, true ) ) {
                        continue;
                    }

                    $post_templates[ $type ][ $block_template->slug ] = $block_template->title;
                }
            }
&& str_contains( $struct, '%minute%' )
                        && str_contains( $struct, '%second%' ) )
                ) {
                    $post = true;
                    if ( str_contains( $struct, '%pagename%' ) ) {
                        $page = true;
                    }
                }

                if ( ! $post ) {
                    // For custom post types, we need to add on endpoints as well.                     foreach ( get_post_types( array( '_builtin' => false ) ) as $ptype ) {
                        if ( str_contains( $struct, "%$ptype%" ) ) {
                            $post = true;

                            // This is for page style attachment URLs.                             $page = is_post_type_hierarchical( $ptype );
                            break;
                        }
                    }
                }

                // If creating rules for a permalink, do all the endpoints like attachments etc.
$sample = false;
    }

    if ( empty( $post->ID ) ) {
        return false;
    }

    if ( 'page' === $post->post_type ) {
        return get_page_link( $post$leavename$sample );
    } elseif ( 'attachment' === $post->post_type ) {
        return get_attachment_link( $post$leavename );
    } elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ), true ) ) {
        return get_post_permalink( $post$leavename$sample );
    }

    $permalink = get_option( 'permalink_structure' );

    /** * Filters the permalink structure for a post before token replacement occurs. * * Only applies to posts with post_type of 'post'. * * @since 3.0.0 * * @param string $permalink The site's permalink structure. * @param WP_Post $post The post in question. * @param bool $leavename Whether to keep the post name. */

    public function get_items_permissions_check( $request ) {
        if ( current_user_can( 'edit_posts' ) ) {
            return true;
        }

        foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
            if ( current_user_can( $post_type->cap->edit_posts ) ) {
                return true;
            }
        }

        return new WP_Error(
            'rest_cannot_view',
            __( 'Sorry, you are not allowed to view the registered block patterns.' ),
            array( 'status' => rest_authorization_required_code() )
        );
    }

    
if ( empty( $taxonomy ) ) {
            $taxonomy = 'post_tag';
        }

        if ( ! taxonomy_exists( $taxonomy ) ) {
            wp_die( __( 'Invalid taxonomy.' ) );
        }

        $tax = get_taxonomy( $taxonomy );

        // @todo Still needed? Maybe just the show_ui part.         if ( empty( $post_type ) || ! in_array( $post_typeget_post_types( array( 'show_ui' => true ) ), true ) ) {
            $post_type = 'post';
        }

    }

    /** * @return bool */
    public function ajax_user_can() {
        return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms );
    }

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