home/beautybuzzbeyond/public_html/wp-includes/template.php000064400000057132147177000460020177 0ustar00has_archive ) { return ''; } return get_archive_template(); } /** * Retrieves path of author template in current or parent template. * * The hierarchy for this template looks like: * * 1. author-{nicename}.php * 2. author-{id}.php * 3. author.php * * An example of this is: * * 1. author-john.php * 2. author-1.php * 3. author.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'author'. * * @since 1.5.0 * * @see get_query_template() * * @return string Full path to author template file. */ function get_author_template() { $author = get_queried_object(); $templates = array(); if ( $author instanceof WP_User ) { $templates[] = "author-{$author->user_nicename}.php"; $templates[] = "author-{$author->ID}.php"; } $templates[] = 'author.php'; return get_query_template( 'author', $templates ); } /** * Retrieves path of category template in current or parent template. * * The hierarchy for this template looks like: * * 1. category-{slug}.php * 2. category-{id}.php * 3. category.php * * An example of this is: * * 1. category-news.php * 2. category-2.php * 3. category.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'category'. * * @since 1.5.0 * @since 4.7.0 The decoded form of `category-{slug}.php` was added to the top of the * template hierarchy when the category slug contains multibyte characters. * * @see get_query_template() * * @return string Full path to category template file. */ function get_category_template() { $category = get_queried_object(); $templates = array(); if ( ! empty( $category->slug ) ) { $slug_decoded = urldecode( $category->slug ); if ( $slug_decoded !== $category->slug ) { $templates[] = "category-{$slug_decoded}.php"; } $templates[] = "category-{$category->slug}.php"; $templates[] = "category-{$category->term_id}.php"; } $templates[] = 'category.php'; return get_query_template( 'category', $templates ); } /** * Retrieves path of tag template in current or parent template. * * The hierarchy for this template looks like: * * 1. tag-{slug}.php * 2. tag-{id}.php * 3. tag.php * * An example of this is: * * 1. tag-wordpress.php * 2. tag-3.php * 3. tag.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'tag'. * * @since 2.3.0 * @since 4.7.0 The decoded form of `tag-{slug}.php` was added to the top of the * template hierarchy when the tag slug contains multibyte characters. * * @see get_query_template() * * @return string Full path to tag template file. */ function get_tag_template() { $tag = get_queried_object(); $templates = array(); if ( ! empty( $tag->slug ) ) { $slug_decoded = urldecode( $tag->slug ); if ( $slug_decoded !== $tag->slug ) { $templates[] = "tag-{$slug_decoded}.php"; } $templates[] = "tag-{$tag->slug}.php"; $templates[] = "tag-{$tag->term_id}.php"; } $templates[] = 'tag.php'; return get_query_template( 'tag', $templates ); } /** * Retrieves path of custom taxonomy term template in current or parent template. * * The hierarchy for this template looks like: * * 1. taxonomy-{taxonomy_slug}-{term_slug}.php * 2. taxonomy-{taxonomy_slug}.php * 3. taxonomy.php * * An example of this is: * * 1. taxonomy-location-texas.php * 2. taxonomy-location.php * 3. taxonomy.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'taxonomy'. * * @since 2.5.0 * @since 4.7.0 The decoded form of `taxonomy-{taxonomy_slug}-{term_slug}.php` was added to the top of the * template hierarchy when the term slug contains multibyte characters. * * @see get_query_template() * * @return string Full path to custom taxonomy term template file. */ function get_taxonomy_template() { $term = get_queried_object(); $templates = array(); if ( ! empty( $term->slug ) ) { $taxonomy = $term->taxonomy; $slug_decoded = urldecode( $term->slug ); if ( $slug_decoded !== $term->slug ) { $templates[] = "taxonomy-$taxonomy-{$slug_decoded}.php"; } $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; $templates[] = "taxonomy-$taxonomy.php"; } $templates[] = 'taxonomy.php'; return get_query_template( 'taxonomy', $templates ); } /** * Retrieves path of date template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'date'. * * @since 1.5.0 * * @see get_query_template() * * @return string Full path to date template file. */ function get_date_template() { return get_query_template( 'date' ); } /** * Retrieves path of home template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'home'. * * @since 1.5.0 * * @see get_query_template() * * @return string Full path to home template file. */ function get_home_template() { $templates = array( 'home.php', 'index.php' ); return get_query_template( 'home', $templates ); } /** * Retrieves path of front page template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'frontpage'. * * @since 3.0.0 * * @see get_query_template() * * @return string Full path to front page template file. */ function get_front_page_template() { $templates = array( 'front-page.php' ); return get_query_template( 'frontpage', $templates ); } /** * Retrieves path of Privacy Policy page template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'privacypolicy'. * * @since 5.2.0 * * @see get_query_template() * * @return string Full path to privacy policy template file. */ function get_privacy_policy_template() { $templates = array( 'privacy-policy.php' ); return get_query_template( 'privacypolicy', $templates ); } /** * Retrieves path of page template in current or parent template. * * Note: For block themes, use locate_block_template() function instead. * * The hierarchy for this template looks like: * * 1. {Page Template}.php * 2. page-{page_name}.php * 3. page-{id}.php * 4. page.php * * An example of this is: * * 1. page-templates/full-width.php * 2. page-about.php * 3. page-4.php * 4. page.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'page'. * * @since 1.5.0 * @since 4.7.0 The decoded form of `page-{page_name}.php` was added to the top of the * template hierarchy when the page name contains multibyte characters. * * @see get_query_template() * * @return string Full path to page template file. */ function get_page_template() { $id = get_queried_object_id(); $template = get_page_template_slug(); $pagename = get_query_var( 'pagename' ); if ( ! $pagename && $id ) { /* * If a static page is set as the front page, $pagename will not be set. * Retrieve it from the queried object. */ $post = get_queried_object(); if ( $post ) { $pagename = $post->post_name; } } $templates = array(); if ( $template && 0 === validate_file( $template ) ) { $templates[] = $template; } if ( $pagename ) { $pagename_decoded = urldecode( $pagename ); if ( $pagename_decoded !== $pagename ) { $templates[] = "page-{$pagename_decoded}.php"; } $templates[] = "page-{$pagename}.php"; } if ( $id ) { $templates[] = "page-{$id}.php"; } $templates[] = 'page.php'; return get_query_template( 'page', $templates ); } /** * Retrieves path of search template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'search'. * * @since 1.5.0 * * @see get_query_template() * * @return string Full path to search template file. */ function get_search_template() { return get_query_template( 'search' ); } /** * Retrieves path of single template in current or parent template. Applies to single Posts, * single Attachments, and single custom post types. * * The hierarchy for this template looks like: * * 1. {Post Type Template}.php * 2. single-{post_type}-{post_name}.php * 3. single-{post_type}.php * 4. single.php * * An example of this is: * * 1. templates/full-width.php * 2. single-post-hello-world.php * 3. single-post.php * 4. single.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'single'. * * @since 1.5.0 * @since 4.4.0 `single-{post_type}-{post_name}.php` was added to the top of the template hierarchy. * @since 4.7.0 The decoded form of `single-{post_type}-{post_name}.php` was added to the top of the * template hierarchy when the post name contains multibyte characters. * @since 4.7.0 `{Post Type Template}.php` was added to the top of the template hierarchy. * * @see get_query_template() * * @return string Full path to single template file. */ function get_single_template() { $object = get_queried_object(); $templates = array(); if ( ! empty( $object->post_type ) ) { $template = get_page_template_slug( $object ); if ( $template && 0 === validate_file( $template ) ) { $templates[] = $template; } $name_decoded = urldecode( $object->post_name ); if ( $name_decoded !== $object->post_name ) { $templates[] = "single-{$object->post_type}-{$name_decoded}.php"; } $templates[] = "single-{$object->post_type}-{$object->post_name}.php"; $templates[] = "single-{$object->post_type}.php"; } $templates[] = 'single.php'; return get_query_template( 'single', $templates ); } /** * Retrieves an embed template path in the current or parent template. * * The hierarchy for this template looks like: * * 1. embed-{post_type}-{post_format}.php * 2. embed-{post_type}.php * 3. embed.php * * An example of this is: * * 1. embed-post-audio.php * 2. embed-post.php * 3. embed.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'embed'. * * @since 4.5.0 * * @see get_query_template() * * @return string Full path to embed template file. */ function get_embed_template() { $object = get_queried_object(); $templates = array(); if ( ! empty( $object->post_type ) ) { $post_format = get_post_format( $object ); if ( $post_format ) { $templates[] = "embed-{$object->post_type}-{$post_format}.php"; } $templates[] = "embed-{$object->post_type}.php"; } $templates[] = 'embed.php'; return get_query_template( 'embed', $templates ); } /** * Retrieves the path of the singular template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'singular'. * * @since 4.3.0 * * @see get_query_template() * * @return string Full path to singular template file */ function get_singular_template() { return get_query_template( 'singular' ); } /** * Retrieves path of attachment template in current or parent template. * * The hierarchy for this template looks like: * * 1. {mime_type}-{sub_type}.php * 2. {sub_type}.php * 3. {mime_type}.php * 4. attachment.php * * An example of this is: * * 1. image-jpeg.php * 2. jpeg.php * 3. image.php * 4. attachment.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'attachment'. * * @since 2.0.0 * @since 4.3.0 The order of the mime type logic was reversed so the hierarchy is more logical. * * @see get_query_template() * * @return string Full path to attachment template file. */ function get_attachment_template() { $attachment = get_queried_object(); $templates = array(); if ( $attachment ) { if ( str_contains( $attachment->post_mime_type, '/' ) ) { list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); } else { list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); } if ( ! empty( $subtype ) ) { $templates[] = "{$type}-{$subtype}.php"; $templates[] = "{$subtype}.php"; } $templates[] = "{$type}.php"; } $templates[] = 'attachment.php'; return get_query_template( 'attachment', $templates ); } /** * Set up the globals used for template loading. * * @since 6.5.0 * * @global string $wp_stylesheet_path Path to current theme's stylesheet directory. * @global string $wp_template_path Path to current theme's template directory. */ function wp_set_template_globals() { global $wp_stylesheet_path, $wp_template_path; $wp_stylesheet_path = get_stylesheet_directory(); $wp_template_path = get_template_directory(); } /** * Retrieves the name of the highest priority template file that exists. * * Searches in the stylesheet directory before the template directory and * wp-includes/theme-compat so that themes which inherit from a parent theme * can just overload one file. * * @since 2.7.0 * @since 5.5.0 The `$args` parameter was added. * * @global string $wp_stylesheet_path Path to current theme's stylesheet directory. * @global string $wp_template_path Path to current theme's template directory. * * @param string|array $template_names Template file(s) to search for, in order. * @param bool $load If true the template file will be loaded if it is found. * @param bool $load_once Whether to require_once or require. Has no effect if `$load` is false. * Default true. * @param array $args Optional. Additional arguments passed to the template. * Default empty array. * @return string The template filename if one is located. */ function locate_template( $template_names, $load = false, $load_once = true, $args = array() ) { global $wp_stylesheet_path, $wp_template_path; if ( ! isset( $wp_stylesheet_path ) || ! isset( $wp_template_path ) ) { wp_set_template_globals(); } $is_child_theme = is_child_theme(); $located = ''; foreach ( (array) $template_names as $template_name ) { if ( ! $template_name ) { continue; } if ( file_exists( $wp_stylesheet_path . '/' . $template_name ) ) { $located = $wp_stylesheet_path . '/' . $template_name; break; } elseif ( $is_child_theme && file_exists( $wp_template_path . '/' . $template_name ) ) { $located = $wp_template_path . '/' . $template_name; break; } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) { $located = ABSPATH . WPINC . '/theme-compat/' . $template_name; break; } } if ( $load && '' !== $located ) { load_template( $located, $load_once, $args ); } return $located; } /** * Requires the template file with WordPress environment. * * The globals are set up for the template file to ensure that the WordPress * environment is available from within the function. The query variables are * also available. * * @since 1.5.0 * @since 5.5.0 The `$args` parameter was added. * * @global array $posts * @global WP_Post $post Global post object. * @global bool $wp_did_header * @global WP_Query $wp_query WordPress Query object. * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * @global wpdb $wpdb WordPress database abstraction object. * @global string $wp_version * @global WP $wp Current WordPress environment instance. * @global int $id * @global WP_Comment $comment Global comment object. * @global int $user_ID * * @param string $_template_file Path to template file. * @param bool $load_once Whether to require_once or require. Default true. * @param array $args Optional. Additional arguments passed to the template. * Default empty array. */ function load_template( $_template_file, $load_once = true, $args = array() ) { global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; if ( is_array( $wp_query->query_vars ) ) { /* * This use of extract() cannot be removed. There are many possible ways that * templates could depend on variables that it creates existing, and no way to * detect and deprecate it. * * Passing the EXTR_SKIP flag is the safest option, ensuring globals and * function variables cannot be overwritten. */ // phpcs:ignore WordPress.PHP.DontExtract.extract_extract extract( $wp_query->query_vars, EXTR_SKIP ); } if ( isset( $s ) ) { $s = esc_attr( $s ); } /** * Fires before a template file is loaded. * * @since 6.1.0 * * @param string $_template_file The full path to the template file. * @param bool $load_once Whether to require_once or require. * @param array $args Additional arguments passed to the template. */ do_action( 'wp_before_load_template', $_template_file, $load_once, $args ); if ( $load_once ) { require_once $_template_file; } else { require $_template_file; } /** * Fires after a template file is loaded. * * @since 6.1.0 * * @param string $_template_file The full path to the template file. * @param bool $load_once Whether to require_once or require. * @param array $args Additional arguments passed to the template. */ do_action( 'wp_after_load_template', $_template_file, $load_once, $args ); } home/beautybuzzbeyond/public_html/old/wp-includes/template.php000064400000057132147177415600020763 0ustar00has_archive ) { return ''; } return get_archive_template(); } /** * Retrieves path of author template in current or parent template. * * The hierarchy for this template looks like: * * 1. author-{nicename}.php * 2. author-{id}.php * 3. author.php * * An example of this is: * * 1. author-john.php * 2. author-1.php * 3. author.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'author'. * * @since 1.5.0 * * @see get_query_template() * * @return string Full path to author template file. */ function get_author_template() { $author = get_queried_object(); $templates = array(); if ( $author instanceof WP_User ) { $templates[] = "author-{$author->user_nicename}.php"; $templates[] = "author-{$author->ID}.php"; } $templates[] = 'author.php'; return get_query_template( 'author', $templates ); } /** * Retrieves path of category template in current or parent template. * * The hierarchy for this template looks like: * * 1. category-{slug}.php * 2. category-{id}.php * 3. category.php * * An example of this is: * * 1. category-news.php * 2. category-2.php * 3. category.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'category'. * * @since 1.5.0 * @since 4.7.0 The decoded form of `category-{slug}.php` was added to the top of the * template hierarchy when the category slug contains multibyte characters. * * @see get_query_template() * * @return string Full path to category template file. */ function get_category_template() { $category = get_queried_object(); $templates = array(); if ( ! empty( $category->slug ) ) { $slug_decoded = urldecode( $category->slug ); if ( $slug_decoded !== $category->slug ) { $templates[] = "category-{$slug_decoded}.php"; } $templates[] = "category-{$category->slug}.php"; $templates[] = "category-{$category->term_id}.php"; } $templates[] = 'category.php'; return get_query_template( 'category', $templates ); } /** * Retrieves path of tag template in current or parent template. * * The hierarchy for this template looks like: * * 1. tag-{slug}.php * 2. tag-{id}.php * 3. tag.php * * An example of this is: * * 1. tag-wordpress.php * 2. tag-3.php * 3. tag.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'tag'. * * @since 2.3.0 * @since 4.7.0 The decoded form of `tag-{slug}.php` was added to the top of the * template hierarchy when the tag slug contains multibyte characters. * * @see get_query_template() * * @return string Full path to tag template file. */ function get_tag_template() { $tag = get_queried_object(); $templates = array(); if ( ! empty( $tag->slug ) ) { $slug_decoded = urldecode( $tag->slug ); if ( $slug_decoded !== $tag->slug ) { $templates[] = "tag-{$slug_decoded}.php"; } $templates[] = "tag-{$tag->slug}.php"; $templates[] = "tag-{$tag->term_id}.php"; } $templates[] = 'tag.php'; return get_query_template( 'tag', $templates ); } /** * Retrieves path of custom taxonomy term template in current or parent template. * * The hierarchy for this template looks like: * * 1. taxonomy-{taxonomy_slug}-{term_slug}.php * 2. taxonomy-{taxonomy_slug}.php * 3. taxonomy.php * * An example of this is: * * 1. taxonomy-location-texas.php * 2. taxonomy-location.php * 3. taxonomy.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'taxonomy'. * * @since 2.5.0 * @since 4.7.0 The decoded form of `taxonomy-{taxonomy_slug}-{term_slug}.php` was added to the top of the * template hierarchy when the term slug contains multibyte characters. * * @see get_query_template() * * @return string Full path to custom taxonomy term template file. */ function get_taxonomy_template() { $term = get_queried_object(); $templates = array(); if ( ! empty( $term->slug ) ) { $taxonomy = $term->taxonomy; $slug_decoded = urldecode( $term->slug ); if ( $slug_decoded !== $term->slug ) { $templates[] = "taxonomy-$taxonomy-{$slug_decoded}.php"; } $templates[] = "taxonomy-$taxonomy-{$term->slug}.php"; $templates[] = "taxonomy-$taxonomy.php"; } $templates[] = 'taxonomy.php'; return get_query_template( 'taxonomy', $templates ); } /** * Retrieves path of date template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'date'. * * @since 1.5.0 * * @see get_query_template() * * @return string Full path to date template file. */ function get_date_template() { return get_query_template( 'date' ); } /** * Retrieves path of home template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'home'. * * @since 1.5.0 * * @see get_query_template() * * @return string Full path to home template file. */ function get_home_template() { $templates = array( 'home.php', 'index.php' ); return get_query_template( 'home', $templates ); } /** * Retrieves path of front page template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'frontpage'. * * @since 3.0.0 * * @see get_query_template() * * @return string Full path to front page template file. */ function get_front_page_template() { $templates = array( 'front-page.php' ); return get_query_template( 'frontpage', $templates ); } /** * Retrieves path of Privacy Policy page template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'privacypolicy'. * * @since 5.2.0 * * @see get_query_template() * * @return string Full path to privacy policy template file. */ function get_privacy_policy_template() { $templates = array( 'privacy-policy.php' ); return get_query_template( 'privacypolicy', $templates ); } /** * Retrieves path of page template in current or parent template. * * Note: For block themes, use locate_block_template() function instead. * * The hierarchy for this template looks like: * * 1. {Page Template}.php * 2. page-{page_name}.php * 3. page-{id}.php * 4. page.php * * An example of this is: * * 1. page-templates/full-width.php * 2. page-about.php * 3. page-4.php * 4. page.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'page'. * * @since 1.5.0 * @since 4.7.0 The decoded form of `page-{page_name}.php` was added to the top of the * template hierarchy when the page name contains multibyte characters. * * @see get_query_template() * * @return string Full path to page template file. */ function get_page_template() { $id = get_queried_object_id(); $template = get_page_template_slug(); $pagename = get_query_var( 'pagename' ); if ( ! $pagename && $id ) { /* * If a static page is set as the front page, $pagename will not be set. * Retrieve it from the queried object. */ $post = get_queried_object(); if ( $post ) { $pagename = $post->post_name; } } $templates = array(); if ( $template && 0 === validate_file( $template ) ) { $templates[] = $template; } if ( $pagename ) { $pagename_decoded = urldecode( $pagename ); if ( $pagename_decoded !== $pagename ) { $templates[] = "page-{$pagename_decoded}.php"; } $templates[] = "page-{$pagename}.php"; } if ( $id ) { $templates[] = "page-{$id}.php"; } $templates[] = 'page.php'; return get_query_template( 'page', $templates ); } /** * Retrieves path of search template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'search'. * * @since 1.5.0 * * @see get_query_template() * * @return string Full path to search template file. */ function get_search_template() { return get_query_template( 'search' ); } /** * Retrieves path of single template in current or parent template. Applies to single Posts, * single Attachments, and single custom post types. * * The hierarchy for this template looks like: * * 1. {Post Type Template}.php * 2. single-{post_type}-{post_name}.php * 3. single-{post_type}.php * 4. single.php * * An example of this is: * * 1. templates/full-width.php * 2. single-post-hello-world.php * 3. single-post.php * 4. single.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'single'. * * @since 1.5.0 * @since 4.4.0 `single-{post_type}-{post_name}.php` was added to the top of the template hierarchy. * @since 4.7.0 The decoded form of `single-{post_type}-{post_name}.php` was added to the top of the * template hierarchy when the post name contains multibyte characters. * @since 4.7.0 `{Post Type Template}.php` was added to the top of the template hierarchy. * * @see get_query_template() * * @return string Full path to single template file. */ function get_single_template() { $object = get_queried_object(); $templates = array(); if ( ! empty( $object->post_type ) ) { $template = get_page_template_slug( $object ); if ( $template && 0 === validate_file( $template ) ) { $templates[] = $template; } $name_decoded = urldecode( $object->post_name ); if ( $name_decoded !== $object->post_name ) { $templates[] = "single-{$object->post_type}-{$name_decoded}.php"; } $templates[] = "single-{$object->post_type}-{$object->post_name}.php"; $templates[] = "single-{$object->post_type}.php"; } $templates[] = 'single.php'; return get_query_template( 'single', $templates ); } /** * Retrieves an embed template path in the current or parent template. * * The hierarchy for this template looks like: * * 1. embed-{post_type}-{post_format}.php * 2. embed-{post_type}.php * 3. embed.php * * An example of this is: * * 1. embed-post-audio.php * 2. embed-post.php * 3. embed.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'embed'. * * @since 4.5.0 * * @see get_query_template() * * @return string Full path to embed template file. */ function get_embed_template() { $object = get_queried_object(); $templates = array(); if ( ! empty( $object->post_type ) ) { $post_format = get_post_format( $object ); if ( $post_format ) { $templates[] = "embed-{$object->post_type}-{$post_format}.php"; } $templates[] = "embed-{$object->post_type}.php"; } $templates[] = 'embed.php'; return get_query_template( 'embed', $templates ); } /** * Retrieves the path of the singular template in current or parent template. * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'singular'. * * @since 4.3.0 * * @see get_query_template() * * @return string Full path to singular template file */ function get_singular_template() { return get_query_template( 'singular' ); } /** * Retrieves path of attachment template in current or parent template. * * The hierarchy for this template looks like: * * 1. {mime_type}-{sub_type}.php * 2. {sub_type}.php * 3. {mime_type}.php * 4. attachment.php * * An example of this is: * * 1. image-jpeg.php * 2. jpeg.php * 3. image.php * 4. attachment.php * * The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'} * and {@see '$type_template'} dynamic hooks, where `$type` is 'attachment'. * * @since 2.0.0 * @since 4.3.0 The order of the mime type logic was reversed so the hierarchy is more logical. * * @see get_query_template() * * @return string Full path to attachment template file. */ function get_attachment_template() { $attachment = get_queried_object(); $templates = array(); if ( $attachment ) { if ( str_contains( $attachment->post_mime_type, '/' ) ) { list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); } else { list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); } if ( ! empty( $subtype ) ) { $templates[] = "{$type}-{$subtype}.php"; $templates[] = "{$subtype}.php"; } $templates[] = "{$type}.php"; } $templates[] = 'attachment.php'; return get_query_template( 'attachment', $templates ); } /** * Set up the globals used for template loading. * * @since 6.5.0 * * @global string $wp_stylesheet_path Path to current theme's stylesheet directory. * @global string $wp_template_path Path to current theme's template directory. */ function wp_set_template_globals() { global $wp_stylesheet_path, $wp_template_path; $wp_stylesheet_path = get_stylesheet_directory(); $wp_template_path = get_template_directory(); } /** * Retrieves the name of the highest priority template file that exists. * * Searches in the stylesheet directory before the template directory and * wp-includes/theme-compat so that themes which inherit from a parent theme * can just overload one file. * * @since 2.7.0 * @since 5.5.0 The `$args` parameter was added. * * @global string $wp_stylesheet_path Path to current theme's stylesheet directory. * @global string $wp_template_path Path to current theme's template directory. * * @param string|array $template_names Template file(s) to search for, in order. * @param bool $load If true the template file will be loaded if it is found. * @param bool $load_once Whether to require_once or require. Has no effect if `$load` is false. * Default true. * @param array $args Optional. Additional arguments passed to the template. * Default empty array. * @return string The template filename if one is located. */ function locate_template( $template_names, $load = false, $load_once = true, $args = array() ) { global $wp_stylesheet_path, $wp_template_path; if ( ! isset( $wp_stylesheet_path ) || ! isset( $wp_template_path ) ) { wp_set_template_globals(); } $is_child_theme = is_child_theme(); $located = ''; foreach ( (array) $template_names as $template_name ) { if ( ! $template_name ) { continue; } if ( file_exists( $wp_stylesheet_path . '/' . $template_name ) ) { $located = $wp_stylesheet_path . '/' . $template_name; break; } elseif ( $is_child_theme && file_exists( $wp_template_path . '/' . $template_name ) ) { $located = $wp_template_path . '/' . $template_name; break; } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) { $located = ABSPATH . WPINC . '/theme-compat/' . $template_name; break; } } if ( $load && '' !== $located ) { load_template( $located, $load_once, $args ); } return $located; } /** * Requires the template file with WordPress environment. * * The globals are set up for the template file to ensure that the WordPress * environment is available from within the function. The query variables are * also available. * * @since 1.5.0 * @since 5.5.0 The `$args` parameter was added. * * @global array $posts * @global WP_Post $post Global post object. * @global bool $wp_did_header * @global WP_Query $wp_query WordPress Query object. * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * @global wpdb $wpdb WordPress database abstraction object. * @global string $wp_version * @global WP $wp Current WordPress environment instance. * @global int $id * @global WP_Comment $comment Global comment object. * @global int $user_ID * * @param string $_template_file Path to template file. * @param bool $load_once Whether to require_once or require. Default true. * @param array $args Optional. Additional arguments passed to the template. * Default empty array. */ function load_template( $_template_file, $load_once = true, $args = array() ) { global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; if ( is_array( $wp_query->query_vars ) ) { /* * This use of extract() cannot be removed. There are many possible ways that * templates could depend on variables that it creates existing, and no way to * detect and deprecate it. * * Passing the EXTR_SKIP flag is the safest option, ensuring globals and * function variables cannot be overwritten. */ // phpcs:ignore WordPress.PHP.DontExtract.extract_extract extract( $wp_query->query_vars, EXTR_SKIP ); } if ( isset( $s ) ) { $s = esc_attr( $s ); } /** * Fires before a template file is loaded. * * @since 6.1.0 * * @param string $_template_file The full path to the template file. * @param bool $load_once Whether to require_once or require. * @param array $args Additional arguments passed to the template. */ do_action( 'wp_before_load_template', $_template_file, $load_once, $args ); if ( $load_once ) { require_once $_template_file; } else { require $_template_file; } /** * Fires after a template file is loaded. * * @since 6.1.0 * * @param string $_template_file The full path to the template file. * @param bool $load_once Whether to require_once or require. * @param array $args Additional arguments passed to the template. */ do_action( 'wp_after_load_template', $_template_file, $load_once, $args ); } home/beautybuzzbeyond/public_html/wp-admin/includes/template.php000060400000300502147177417300021260 0ustar00 'category', 'descendants_and_self' => $descendants_and_self, 'selected_cats' => $selected_cats, 'popular_cats' => $popular_cats, 'walker' => $walker, 'checked_ontop' => $checked_ontop, ) ); } /** * Outputs an unordered list of checkbox input elements labelled with term names. * * Taxonomy-independent version of wp_category_checklist(). * * @since 3.0.0 * @since 4.4.0 Introduced the `$echo` argument. * * @param int $post_id Optional. Post ID. Default 0. * @param array|string $args { * Optional. Array or string of arguments for generating a terms checklist. Default empty array. * * @type int $descendants_and_self ID of the category to output along with its descendants. * Default 0. * @type int[] $selected_cats Array of category IDs to mark as checked. Default false. * @type int[] $popular_cats Array of category IDs to receive the "popular-category" class. * Default false. * @type Walker $walker Walker object to use to build the output. Default empty which * results in a Walker_Category_Checklist instance being used. * @type string $taxonomy Taxonomy to generate the checklist for. Default 'category'. * @type bool $checked_ontop Whether to move checked items out of the hierarchy and to * the top of the list. Default true. * @type bool $echo Whether to echo the generated markup. False to return the markup instead * of echoing it. Default true. * } * @return string HTML list of input elements. */ function wp_terms_checklist( $post_id = 0, $args = array() ) { $defaults = array( 'descendants_and_self' => 0, 'selected_cats' => false, 'popular_cats' => false, 'walker' => null, 'taxonomy' => 'category', 'checked_ontop' => true, 'echo' => true, ); /** * Filters the taxonomy terms checklist arguments. * * @since 3.4.0 * * @see wp_terms_checklist() * * @param array|string $args An array or string of arguments. * @param int $post_id The post ID. */ $params = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); $parsed_args = wp_parse_args( $params, $defaults ); if ( empty( $parsed_args['walker'] ) || ! ( $parsed_args['walker'] instanceof Walker ) ) { $walker = new Walker_Category_Checklist(); } else { $walker = $parsed_args['walker']; } $taxonomy = $parsed_args['taxonomy']; $descendants_and_self = (int) $parsed_args['descendants_and_self']; $args = array( 'taxonomy' => $taxonomy ); $tax = get_taxonomy( $taxonomy ); $args['disabled'] = ! current_user_can( $tax->cap->assign_terms ); $args['list_only'] = ! empty( $parsed_args['list_only'] ); if ( is_array( $parsed_args['selected_cats'] ) ) { $args['selected_cats'] = array_map( 'intval', $parsed_args['selected_cats'] ); } elseif ( $post_id ) { $args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) ); } else { $args['selected_cats'] = array(); } if ( is_array( $parsed_args['popular_cats'] ) ) { $args['popular_cats'] = array_map( 'intval', $parsed_args['popular_cats'] ); } else { $args['popular_cats'] = get_terms( array( 'taxonomy' => $taxonomy, 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false, ) ); } if ( $descendants_and_self ) { $categories = (array) get_terms( array( 'taxonomy' => $taxonomy, 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0, ) ); $self = get_term( $descendants_and_self, $taxonomy ); array_unshift( $categories, $self ); } else { $categories = (array) get_terms( array( 'taxonomy' => $taxonomy, 'get' => 'all', ) ); } $output = ''; if ( $parsed_args['checked_ontop'] ) { /* * Post-process $categories rather than adding an exclude to the get_terms() query * to keep the query the same across all posts (for any query cache). */ $checked_categories = array(); $keys = array_keys( $categories ); foreach ( $keys as $k ) { if ( in_array( $categories[ $k ]->term_id, $args['selected_cats'], true ) ) { $checked_categories[] = $categories[ $k ]; unset( $categories[ $k ] ); } } // Put checked categories on top. $output .= $walker->walk( $checked_categories, 0, $args ); } // Then the rest of them. $output .= $walker->walk( $categories, 0, $args ); if ( $parsed_args['echo'] ) { echo $output; } return $output; } /** * Retrieves a list of the most popular terms from the specified taxonomy. * * If the `$display` argument is true then the elements for a list of checkbox * `` elements labelled with the names of the selected terms is output. * If the `$post_ID` global is not empty then the terms associated with that * post will be marked as checked. * * @since 2.5.0 * * @param string $taxonomy Taxonomy to retrieve terms from. * @param int $default_term Optional. Not used. * @param int $number Optional. Number of terms to retrieve. Default 10. * @param bool $display Optional. Whether to display the list as well. Default true. * @return int[] Array of popular term IDs. */ function wp_popular_terms_checklist( $taxonomy, $default_term = 0, $number = 10, $display = true ) { $post = get_post(); if ( $post && $post->ID ) { $checked_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); } else { $checked_terms = array(); } $terms = get_terms( array( 'taxonomy' => $taxonomy, 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false, ) ); $tax = get_taxonomy( $taxonomy ); $popular_ids = array(); foreach ( (array) $terms as $term ) { $popular_ids[] = $term->term_id; if ( ! $display ) { // Hack for Ajax use. continue; } $id = "popular-$taxonomy-$term->term_id"; $checked = in_array( $term->term_id, $checked_terms, true ) ? 'checked="checked"' : ''; ?> 'link_category', 'orderby' => 'name', 'hide_empty' => 0, ) ); if ( empty( $categories ) ) { return; } foreach ( $categories as $category ) { $cat_id = $category->term_id; /** This filter is documented in wp-includes/category-template.php */ $name = esc_html( apply_filters( 'the_category', $category->name, '', '' ) ); $checked = in_array( $cat_id, $checked_categories, true ) ? ' checked="checked"' : ''; echo ''; } } /** * Adds hidden fields with the data for use in the inline editor for posts and pages. * * @since 2.7.0 * * @param WP_Post $post Post object. */ function get_inline_data( $post ) { $post_type_object = get_post_type_object( $post->post_type ); if ( ! current_user_can( 'edit_post', $post->ID ) ) { return; } $title = esc_textarea( trim( $post->post_title ) ); echo ' '; } /** * Outputs the in-line comment reply-to form in the Comments list table. * * @since 2.7.0 * * @global WP_List_Table $wp_list_table * * @param int $position Optional. The value of the 'position' input field. Default 1. * @param bool $checkbox Optional. The value of the 'checkbox' input field. Default false. * @param string $mode Optional. If set to 'single', will use WP_Post_Comments_List_Table, * otherwise WP_Comments_List_Table. Default 'single'. * @param bool $table_row Optional. Whether to use a table instead of a div element. Default true. */ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) { global $wp_list_table; /** * Filters the in-line comment reply-to form output in the Comments * list table. * * Returning a non-empty value here will short-circuit display * of the in-line comment-reply form in the Comments list table, * echoing the returned value instead. * * @since 2.7.0 * * @see wp_comment_reply() * * @param string $content The reply-to form content. * @param array $args An array of default args. */ $content = apply_filters( 'wp_comment_reply', '', array( 'position' => $position, 'checkbox' => $checkbox, 'mode' => $mode, ) ); if ( ! empty( $content ) ) { echo $content; return; } if ( ! $wp_list_table ) { if ( 'single' === $mode ) { $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' ); } else { $wp_list_table = _get_list_table( 'WP_Comments_List_Table' ); } } ?>
' . _x( 'Name', 'meta name' ) . ' ' . __( 'Value' ) . ' '; // TBODY needed for list-manipulation JS. return; } $count = 0; ?>
. $entry['meta_id'] = (int) $entry['meta_id']; $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); $r .= "\n\t"; $r .= "\n\t\t"; $r .= "\n\t\t
"; $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) ); $r .= "\n\t\t"; $r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) ); $r .= '
'; $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); $r .= ''; $r .= "\n\t\t\n\t"; return $r; } /** * Prints the form in the Custom Fields meta box. * * @since 1.2.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @param WP_Post $post Optional. The post being edited. */ function meta_form( $post = null ) { global $wpdb; $post = get_post( $post ); /** * Filters values for the meta key dropdown in the Custom Fields meta box. * * Returning a non-null value will effectively short-circuit and avoid a * potentially expensive query against postmeta. * * @since 4.4.0 * * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null. * @param WP_Post $post The current post object. */ $keys = apply_filters( 'postmeta_form_keys', null, $post ); if ( null === $keys ) { /** * Filters the number of custom fields to retrieve for the drop-down * in the Custom Fields meta box. * * @since 2.1.0 * * @param int $limit Number of custom fields to retrieve. Default 30. */ $limit = apply_filters( 'postmeta_form_limit', 30 ); $keys = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_key FROM $wpdb->postmeta WHERE meta_key NOT BETWEEN '_' AND '_z' HAVING meta_key NOT LIKE %s ORDER BY meta_key LIMIT %d", $wpdb->esc_like( '_' ) . '%', $limit ) ); } if ( $keys ) { natcasesort( $keys ); } ?>

'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta', ) ); ?>
post_status, array( 'draft', 'pending' ), true ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' === $post->post_date_gmt ) ); } $tab_index_attribute = ''; if ( (int) $tab_index > 0 ) { $tab_index_attribute = " tabindex=\"$tab_index\""; } // @todo Remove this? // echo '
'; $post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date; $jj = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' ); $mm = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' ); $aa = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : current_time( 'Y' ); $hh = ( $edit ) ? mysql2date( 'H', $post_date, false ) : current_time( 'H' ); $mn = ( $edit ) ? mysql2date( 'i', $post_date, false ) : current_time( 'i' ); $ss = ( $edit ) ? mysql2date( 's', $post_date, false ) : current_time( 's' ); $cur_jj = current_time( 'd' ); $cur_mm = current_time( 'm' ); $cur_aa = current_time( 'Y' ); $cur_hh = current_time( 'H' ); $cur_mn = current_time( 'i' ); $month = ''; $day = ''; $year = ''; $hour = ''; $minute = ''; echo '
'; /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */ printf( __( '%1$s %2$s, %3$s at %4$s:%5$s' ), $month, $day, $year, $hour, $minute ); echo '
'; if ( $multi ) { return; } echo "\n\n"; $map = array( 'mm' => array( $mm, $cur_mm ), 'jj' => array( $jj, $cur_jj ), 'aa' => array( $aa, $cur_aa ), 'hh' => array( $hh, $cur_hh ), 'mn' => array( $mn, $cur_mn ), ); foreach ( $map as $timeunit => $value ) { list( $unit, $curr ) = $value; echo '' . "\n"; $cur_timeunit = 'cur_' . $timeunit; echo '' . "\n"; } ?>

" . esc_html( $template ) . ''; } } /** * Prints out option HTML elements for the page parents drop-down. * * @since 1.5.0 * @since 4.4.0 `$post` argument was added. * * @global wpdb $wpdb WordPress database abstraction object. * * @param int $default_page Optional. The default page ID to be pre-selected. Default 0. * @param int $parent_page Optional. The parent page ID. Default 0. * @param int $level Optional. Page depth level. Default 0. * @param int|WP_Post $post Post ID or WP_Post object. * @return void|false Void on success, false if the page has no children. */ function parent_dropdown( $default_page = 0, $parent_page = 0, $level = 0, $post = null ) { global $wpdb; $post = get_post( $post ); $items = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent_page ) ); if ( $items ) { foreach ( $items as $item ) { // A page cannot be its own parent. if ( $post && $post->ID && (int) $item->ID === $post->ID ) { continue; } $pad = str_repeat( ' ', $level * 3 ); $selected = selected( $default_page, $item->ID, false ); echo "\n\t'; parent_dropdown( $default_page, $item->ID, $level + 1 ); } } else { return false; } } /** * Prints out option HTML elements for role selectors. * * @since 2.1.0 * * @param string $selected Slug for the role that should be already selected. */ function wp_dropdown_roles( $selected = '' ) { $r = ''; $editable_roles = array_reverse( get_editable_roles() ); foreach ( $editable_roles as $role => $details ) { $name = translate_user_role( $details['name'] ); // Preselect specified role. if ( $selected === $role ) { $r .= "\n\t"; } else { $r .= "\n\t"; } } echo $r; } /** * Outputs the form used by the importers to accept the data to be imported. * * @since 2.0.0 * * @param string $action The action attribute for the form. */ function wp_import_upload_form( $action ) { /** * Filters the maximum allowed upload size for import files. * * @since 2.3.0 * * @see wp_max_upload_size() * * @param int $max_upload_size Allowed upload size. Default 1 MB. */ $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); $size = size_format( $bytes ); $upload_dir = wp_upload_dir(); if ( ! empty( $upload_dir['error'] ) ) : $upload_directory_error = '

' . __( 'Before you can upload your import file, you will need to fix the following error:' ) . '

'; $upload_directory_error .= '

' . $upload_dir['error'] . '

'; wp_admin_notice( $upload_directory_error, array( 'additional_classes' => array( 'error' ), 'paragraph_wrap' => false, ) ); else : ?>

%s (%s)', __( 'Choose a file from your computer:' ), /* translators: %s: Maximum allowed file size. */ sprintf( __( 'Maximum size: %s' ), $size ) ); ?>

id ) ) { return; } $page = $screen->id; if ( ! isset( $wp_meta_boxes ) ) { $wp_meta_boxes = array(); } if ( ! isset( $wp_meta_boxes[ $page ] ) ) { $wp_meta_boxes[ $page ] = array(); } if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { $wp_meta_boxes[ $page ][ $context ] = array(); } foreach ( array_keys( $wp_meta_boxes[ $page ] ) as $a_context ) { foreach ( array( 'high', 'core', 'default', 'low' ) as $a_priority ) { if ( ! isset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) ) { continue; } // If a core box was previously removed, don't add. if ( ( 'core' === $priority || 'sorted' === $priority ) && false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) { return; } // If a core box was previously added by a plugin, don't add. if ( 'core' === $priority ) { /* * If the box was added with default priority, give it core priority * to maintain sort order. */ if ( 'default' === $a_priority ) { $wp_meta_boxes[ $page ][ $a_context ]['core'][ $id ] = $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ]; unset( $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ] ); } return; } // If no priority given and ID already present, use existing priority. if ( empty( $priority ) ) { $priority = $a_priority; /* * Else, if we're adding to the sorted priority, we don't know the title * or callback. Grab them from the previously added context/priority. */ } elseif ( 'sorted' === $priority ) { $title = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['title']; $callback = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback']; $callback_args = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['args']; } // An ID can be in only one priority and one context. if ( $priority !== $a_priority || $context !== $a_context ) { unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ); } } } if ( empty( $priority ) ) { $priority = 'low'; } if ( ! isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { $wp_meta_boxes[ $page ][ $context ][ $priority ] = array(); } $wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = array( 'id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args, ); } /** * Renders a "fake" meta box with an information message, * shown on the block editor, when an incompatible meta box is found. * * @since 5.0.0 * * @param mixed $data_object The data object being rendered on this screen. * @param array $box { * Custom formats meta box arguments. * * @type string $id Meta box 'id' attribute. * @type string $title Meta box title. * @type callable $old_callback The original callback for this meta box. * @type array $args Extra meta box arguments. * } */ function do_block_editor_incompatible_meta_box( $data_object, $box ) { $plugin = _get_plugin_from_callback( $box['old_callback'] ); $plugins = get_plugins(); echo '

'; if ( $plugin ) { /* translators: %s: The name of the plugin that generated this meta box. */ printf( __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), "{$plugin['Name']}" ); } else { _e( 'This meta box is not compatible with the block editor.' ); } echo '

'; if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) { if ( current_user_can( 'install_plugins' ) ) { $install_url = wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ); echo '

'; /* translators: %s: A link to install the Classic Editor plugin. */ printf( __( 'Please install the Classic Editor plugin to use this meta box.' ), esc_url( $install_url ) ); echo '

'; } } elseif ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) { if ( current_user_can( 'activate_plugins' ) ) { $activate_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php' ), 'activate-plugin_classic-editor/classic-editor.php' ); echo '

'; /* translators: %s: A link to activate the Classic Editor plugin. */ printf( __( 'Please activate the Classic Editor plugin to use this meta box.' ), esc_url( $activate_url ) ); echo '

'; } } elseif ( $data_object instanceof WP_Post ) { $edit_url = add_query_arg( array( 'classic-editor' => '', 'classic-editor__forget' => '', ), get_edit_post_link( $data_object ) ); echo '

'; /* translators: %s: A link to use the Classic Editor plugin. */ printf( __( 'Please open the classic editor to use this meta box.' ), esc_url( $edit_url ) ); echo '

'; } } /** * Internal helper function to find the plugin from a meta box callback. * * @since 5.0.0 * * @access private * * @param callable $callback The callback function to check. * @return array|null The plugin that the callback belongs to, or null if it doesn't belong to a plugin. */ function _get_plugin_from_callback( $callback ) { try { if ( is_array( $callback ) ) { $reflection = new ReflectionMethod( $callback[0], $callback[1] ); } elseif ( is_string( $callback ) && str_contains( $callback, '::' ) ) { $reflection = new ReflectionMethod( $callback ); } else { $reflection = new ReflectionFunction( $callback ); } } catch ( ReflectionException $exception ) { // We could not properly reflect on the callable, so we abort here. return null; } // Don't show an error if it's an internal PHP function. if ( ! $reflection->isInternal() ) { // Only show errors if the meta box was registered by a plugin. $filename = wp_normalize_path( $reflection->getFileName() ); $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); if ( str_starts_with( $filename, $plugin_dir ) ) { $filename = str_replace( $plugin_dir, '', $filename ); $filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename ); $plugins = get_plugins(); foreach ( $plugins as $name => $plugin ) { if ( str_starts_with( $name, $filename ) ) { return $plugin; } } } } return null; } /** * Meta-Box template function. * * @since 2.5.0 * * @global array $wp_meta_boxes Global meta box state. * * @param string|WP_Screen $screen The screen identifier. If you have used add_menu_page() or * add_submenu_page() to create a new screen (and hence screen_id) * make sure your menu slug conforms to the limits of sanitize_key() * otherwise the 'screen' menu may not correctly render on your page. * @param string $context The screen context for which to display meta boxes. * @param mixed $data_object Gets passed to the meta box callback function as the first parameter. * Often this is the object that's the focus of the current screen, * for example a `WP_Post` or `WP_Comment` object. * @return int Number of meta_boxes. */ function do_meta_boxes( $screen, $context, $data_object ) { global $wp_meta_boxes; static $already_sorted = false; if ( empty( $screen ) ) { $screen = get_current_screen(); } elseif ( is_string( $screen ) ) { $screen = convert_to_screen( $screen ); } $page = $screen->id; $hidden = get_hidden_meta_boxes( $screen ); printf( '
', esc_attr( $context ) ); /* * Grab the ones the user has manually sorted. * Pull them out of their previous context/priority and into the one the user chose. */ $sorted = get_user_option( "meta-box-order_$page" ); if ( ! $already_sorted && $sorted ) { foreach ( $sorted as $box_context => $ids ) { foreach ( explode( ',', $ids ) as $id ) { if ( $id && 'dashboard_browser_nag' !== $id ) { add_meta_box( $id, null, null, $screen, $box_context, 'sorted' ); } } } } $already_sorted = true; $i = 0; if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) { foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { if ( false === $box || ! $box['title'] ) { continue; } $block_compatible = true; if ( is_array( $box['args'] ) ) { // If a meta box is just here for back compat, don't show it in the block editor. if ( $screen->is_block_editor() && isset( $box['args']['__back_compat_meta_box'] ) && $box['args']['__back_compat_meta_box'] ) { continue; } if ( isset( $box['args']['__block_editor_compatible_meta_box'] ) ) { $block_compatible = (bool) $box['args']['__block_editor_compatible_meta_box']; unset( $box['args']['__block_editor_compatible_meta_box'] ); } // If the meta box is declared as incompatible with the block editor, override the callback function. if ( ! $block_compatible && $screen->is_block_editor() ) { $box['old_callback'] = $box['callback']; $box['callback'] = 'do_block_editor_incompatible_meta_box'; } if ( isset( $box['args']['__back_compat_meta_box'] ) ) { $block_compatible = $block_compatible || (bool) $box['args']['__back_compat_meta_box']; unset( $box['args']['__back_compat_meta_box'] ); } } ++$i; // get_hidden_meta_boxes() doesn't apply in the block editor. $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : ''; echo '
' . "\n"; echo '
'; echo '

'; if ( 'dashboard_php_nag' === $box['id'] ) { echo ''; echo '' . /* translators: Hidden accessibility text. */ __( 'Warning:' ) . ' '; } echo $box['title']; echo "

\n"; if ( 'dashboard_browser_nag' !== $box['id'] ) { $widget_title = $box['title']; if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) { $widget_title = $box['args']['__widget_basename']; // Do not pass this parameter to the user callback function. unset( $box['args']['__widget_basename'] ); } echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; } echo '
'; echo '
' . "\n"; if ( WP_DEBUG && ! $block_compatible && 'edit' === $screen->parent_base && ! $screen->is_block_editor() && ! isset( $_GET['meta-box-loader'] ) ) { $plugin = _get_plugin_from_callback( $box['callback'] ); if ( $plugin ) { $meta_box_not_compatible_message = sprintf( /* translators: %s: The name of the plugin that generated this meta box. */ __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), "{$plugin['Name']}" ); wp_admin_notice( $meta_box_not_compatible_message, array( 'additional_classes' => array( 'error', 'inline' ), ) ); } } call_user_func( $box['callback'], $data_object, $box ); echo "
\n"; echo "
\n"; } } } } echo '
'; return $i; } /** * Removes a meta box from one or more screens. * * @since 2.6.0 * @since 4.4.0 The `$screen` parameter now accepts an array of screen IDs. * * @global array $wp_meta_boxes Global meta box state. * * @param string $id Meta box ID (used in the 'id' attribute for the meta box). * @param string|array|WP_Screen $screen The screen or screens on which the meta box is shown (such as a * post type, 'link', or 'comment'). Accepts a single screen ID, * WP_Screen object, or array of screen IDs. * @param string $context The context within the screen where the box is set to display. * Contexts vary from screen to screen. Post edit screen contexts * include 'normal', 'side', and 'advanced'. Comments screen contexts * include 'normal' and 'side'. Menus meta boxes (accordion sections) * all use the 'side' context. */ function remove_meta_box( $id, $screen, $context ) { global $wp_meta_boxes; if ( empty( $screen ) ) { $screen = get_current_screen(); } elseif ( is_string( $screen ) ) { $screen = convert_to_screen( $screen ); } elseif ( is_array( $screen ) ) { foreach ( $screen as $single_screen ) { remove_meta_box( $id, $single_screen, $context ); } } if ( ! isset( $screen->id ) ) { return; } $page = $screen->id; if ( ! isset( $wp_meta_boxes ) ) { $wp_meta_boxes = array(); } if ( ! isset( $wp_meta_boxes[ $page ] ) ) { $wp_meta_boxes[ $page ] = array(); } if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { $wp_meta_boxes[ $page ][ $context ] = array(); } foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { $wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false; } } /** * Meta Box Accordion Template Function. * * Largely made up of abstracted code from do_meta_boxes(), this * function serves to build meta boxes as list items for display as * a collapsible accordion. * * @since 3.6.0 * * @uses global $wp_meta_boxes Used to retrieve registered meta boxes. * * @param string|object $screen The screen identifier. * @param string $context The screen context for which to display accordion sections. * @param mixed $data_object Gets passed to the section callback function as the first parameter. * @return int Number of meta boxes as accordion sections. */ function do_accordion_sections( $screen, $context, $data_object ) { global $wp_meta_boxes; wp_enqueue_script( 'accordion' ); if ( empty( $screen ) ) { $screen = get_current_screen(); } elseif ( is_string( $screen ) ) { $screen = convert_to_screen( $screen ); } $page = $screen->id; $hidden = get_hidden_meta_boxes( $screen ); ?>
$id, 'title' => $title, 'callback' => $callback, 'before_section' => '', 'after_section' => '', 'section_class' => '', ); $section = wp_parse_args( $args, $defaults ); if ( 'misc' === $page ) { _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( /* translators: %s: misc */ __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) ); $page = 'general'; } if ( 'privacy' === $page ) { _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( /* translators: %s: privacy */ __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) ); $page = 'reading'; } $wp_settings_sections[ $page ][ $id ] = $section; } /** * Adds a new field to a section of a settings page. * * Part of the Settings API. Use this to define a settings field that will show * as part of a settings section inside a settings page. The fields are shown using * do_settings_fields() in do_settings_sections(). * * The $callback argument should be the name of a function that echoes out the * HTML input tags for this setting field. Use get_option() to retrieve existing * values to show. * * @since 2.7.0 * @since 4.2.0 The `$class` argument was added. * * @global array $wp_settings_fields Storage array of settings fields and info about their pages/sections. * * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags. * @param string $title Formatted title of the field. Shown as the label for the field * during output. * @param callable $callback Function that fills the field with the desired form inputs. The * function should echo its output. * @param string $page The slug-name of the settings page on which to show the section * (general, reading, writing, ...). * @param string $section Optional. The slug-name of the section of the settings page * in which to show the box. Default 'default'. * @param array $args { * Optional. Extra arguments that get passed to the callback function. * * @type string $label_for When supplied, the setting title will be wrapped * in a `