// Post Type registration.
* Creates the initial post types when 'init' action is fired.
function create_initial_post_types() {
'name_admin_bar' => _x( 'Post', 'add new from admin bar' ),
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
'capability_type' => 'post',
'menu_icon' => 'dashicons-admin-post',
'delete_with_user' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
'rest_controller_class' => 'WP_REST_Posts_Controller',
'name_admin_bar' => _x( 'Page', 'add new from admin bar' ),
'publicly_queryable' => false,
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
'capability_type' => 'page',
'menu_icon' => 'dashicons-admin-page',
'delete_with_user' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),
'rest_controller_class' => 'WP_REST_Posts_Controller',
'name' => _x( 'Media', 'post type general name' ),
'name_admin_bar' => _x( 'Media', 'add new from admin bar' ),
'add_new' => _x( 'Add New', 'add new media' ),
'edit_item' => __( 'Edit Media' ),
'view_item' => __( 'View Attachment Page' ),
'attributes' => __( 'Attachment Attributes' ),
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
'capability_type' => 'post',
'create_posts' => 'upload_files',
'menu_icon' => 'dashicons-admin-media',
'show_in_nav_menus' => false,
'delete_with_user' => true,
'supports' => array( 'title', 'author', 'comments' ),
'rest_controller_class' => 'WP_REST_Attachments_Controller',
add_post_type_support( 'attachment:audio', 'thumbnail' );
add_post_type_support( 'attachment:video', 'thumbnail' );
'name' => __( 'Revisions' ),
'singular_name' => __( 'Revision' ),
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'_edit_link' => 'revision.php?revision=%d', /* internal use only. don't use this when registering your own post type. */
'capability_type' => 'post',
'delete_with_user' => true,
'supports' => array( 'author' ),
'name' => __( 'Navigation Menu Items' ),
'singular_name' => __( 'Navigation Menu Item' ),
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'delete_with_user' => false,
'name' => __( 'Custom CSS' ),
'singular_name' => __( 'Custom CSS' ),
'delete_with_user' => false,
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'supports' => array( 'title', 'revisions' ),
'delete_posts' => 'edit_theme_options',
'delete_post' => 'edit_theme_options',
'delete_published_posts' => 'edit_theme_options',
'delete_private_posts' => 'edit_theme_options',
'delete_others_posts' => 'edit_theme_options',
'edit_post' => 'edit_css',
'edit_posts' => 'edit_css',
'edit_others_posts' => 'edit_css',
'edit_published_posts' => 'edit_css',
'read_private_posts' => 'read',
'publish_posts' => 'edit_theme_options',
'name' => _x( 'Changesets', 'post type general name' ),
'singular_name' => _x( 'Changeset', 'post type singular name' ),
'menu_name' => _x( 'Changesets', 'admin menu' ),
'name_admin_bar' => _x( 'Changeset', 'add new on admin bar' ),
'add_new' => _x( 'Add New', 'Customize Changeset' ),
'add_new_item' => __( 'Add New Changeset' ),
'new_item' => __( 'New Changeset' ),
'edit_item' => __( 'Edit Changeset' ),
'view_item' => __( 'View Changeset' ),
'all_items' => __( 'All Changesets' ),
'search_items' => __( 'Search Changesets' ),
'not_found' => __( 'No changesets found.' ),
'not_found_in_trash' => __( 'No changesets found in Trash.' ),
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'delete_with_user' => false,
'supports' => array( 'title', 'author' ),
'capability_type' => 'customize_changeset',
'create_posts' => 'customize',
'delete_others_posts' => 'customize',
'delete_post' => 'customize',
'delete_posts' => 'customize',
'delete_private_posts' => 'customize',
'delete_published_posts' => 'customize',
'edit_others_posts' => 'customize',
'edit_post' => 'customize',
'edit_posts' => 'customize',
'edit_private_posts' => 'customize',
'edit_published_posts' => 'do_not_allow',
'publish_posts' => 'customize',
'read_post' => 'customize',
'read_private_posts' => 'customize',
'name' => __( 'oEmbed Responses' ),
'singular_name' => __( 'oEmbed Response' ),
'delete_with_user' => false,
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'name' => __( 'User Requests' ),
'singular_name' => __( 'User Request' ),
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'delete_with_user' => false,
'name' => _x( 'Reusable Blocks', 'post type general name' ),
'singular_name' => _x( 'Reusable Block', 'post type singular name' ),
'menu_name' => _x( 'Reusable Blocks', 'admin menu' ),
'name_admin_bar' => _x( 'Reusable Block', 'add new on admin bar' ),
'add_new' => _x( 'Add New', 'Reusable Block' ),
'add_new_item' => __( 'Add New Reusable Block' ),
'new_item' => __( 'New Reusable Block' ),
'edit_item' => __( 'Edit Reusable Block' ),
'view_item' => __( 'View Reusable Block' ),
'all_items' => __( 'All Reusable Blocks' ),
'search_items' => __( 'Search Reusable Blocks' ),
'not_found' => __( 'No reusable blocks found.' ),
'not_found_in_trash' => __( 'No reusable blocks found in Trash.' ),
'filter_items_list' => __( 'Filter reusable blocks list' ),
'items_list_navigation' => __( 'Reusable Blocks list navigation' ),
'items_list' => __( 'Reusable Blocks list' ),
'item_published' => __( 'Reusable Block published.' ),
'item_published_privately' => __( 'Reusable Block published privately.' ),
'item_reverted_to_draft' => __( 'Reusable Block reverted to draft.' ),
'item_scheduled' => __( 'Reusable Block scheduled.' ),
'item_updated' => __( 'Reusable Block updated.' ),
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'rest_controller_class' => 'WP_REST_Blocks_Controller',
'capability_type' => 'block',
// You need to be able to edit posts, in order to read blocks in their raw form.
// You need to be able to publish posts, in order to create blocks.
'create_posts' => 'publish_posts',
'edit_posts' => 'edit_posts',
'edit_published_posts' => 'edit_published_posts',
'delete_published_posts' => 'delete_published_posts',
'edit_others_posts' => 'edit_others_posts',
'delete_others_posts' => 'delete_others_posts',
'label' => _x( 'Published', 'post status' ),
'_builtin' => true, /* internal use only. */
/* translators: %s: Number of published posts. */
'label_count' => _n_noop(
'Published <span class="count">(%s)</span>',
'Published <span class="count">(%s)</span>'
'label' => _x( 'Scheduled', 'post status' ),
'_builtin' => true, /* internal use only. */
/* translators: %s: Number of scheduled posts. */
'label_count' => _n_noop(
'Scheduled <span class="count">(%s)</span>',
'Scheduled <span class="count">(%s)</span>'
'label' => _x( 'Draft', 'post status' ),
'_builtin' => true, /* internal use only. */
/* translators: %s: Number of draft posts. */
'label_count' => _n_noop(
'Draft <span class="count">(%s)</span>',
'Drafts <span class="count">(%s)</span>'
'label' => _x( 'Pending', 'post status' ),
'_builtin' => true, /* internal use only. */
/* translators: %s: Number of pending posts. */
'label_count' => _n_noop(
'Pending <span class="count">(%s)</span>',
'Pending <span class="count">(%s)</span>'
'label' => _x( 'Private', 'post status' ),
'_builtin' => true, /* internal use only. */
/* translators: %s: Number of private posts. */
'label_count' => _n_noop(
'Private <span class="count">(%s)</span>',
'Private <span class="count">(%s)</span>'
'label' => _x( 'Trash', 'post status' ),
'_builtin' => true, /* internal use only. */
/* translators: %s: Number of trashed posts. */
'label_count' => _n_noop(
'Trash <span class="count">(%s)</span>',
'Trash <span class="count">(%s)</span>'
'show_in_admin_status_list' => true,
'_builtin' => true, /* internal use only. */
'_builtin' => true, /* internal use only. */
'exclude_from_search' => false,
'label' => _x( 'Pending', 'request status' ),
'_builtin' => true, /* internal use only. */
/* translators: %s: Number of pending requests. */
'label_count' => _n_noop(
'Pending <span class="count">(%s)</span>',
'Pending <span class="count">(%s)</span>'
'exclude_from_search' => false,
'label' => _x( 'Confirmed', 'request status' ),
'_builtin' => true, /* internal use only. */
/* translators: %s: Number of confirmed requests. */
'label_count' => _n_noop(
'Confirmed <span class="count">(%s)</span>',
'Confirmed <span class="count">(%s)</span>'
'exclude_from_search' => false,
'label' => _x( 'Failed', 'request status' ),
'_builtin' => true, /* internal use only. */
/* translators: %s: Number of failed requests. */
'label_count' => _n_noop(
'Failed <span class="count">(%s)</span>',
'Failed <span class="count">(%s)</span>'
'exclude_from_search' => false,
'label' => _x( 'Completed', 'request status' ),
'_builtin' => true, /* internal use only. */
/* translators: %s: Number of completed requests. */
'label_count' => _n_noop(
'Completed <span class="count">(%s)</span>',
'Completed <span class="count">(%s)</span>'
'exclude_from_search' => false,
* Retrieve attached file path based on attachment ID.
* By default the path will go through the 'get_attached_file' filter, but
* passing a true to the $unfiltered argument of get_attached_file() will
* return the file path unfiltered.
* The function works by getting the single post meta name, named
* '_wp_attached_file' and returning it. This is a convenience function to
* prevent looking up the meta name and provide a mechanism for sending the
* attached filename through a filter.
* @param int $attachment_id Attachment ID.
* @param bool $unfiltered Optional. Whether to apply filters. Default false.
* @return string|false The file path to where the attached file should be, false otherwise.
function get_attached_file( $attachment_id, $unfiltered = false ) {
$file = get_post_meta( $attachment_id, '_wp_attached_file', true );