IP : 18.220.62.173Hostname : server86.web-hosting.comKernel : Linux server86.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64Disable Function : None :) OS : Linux
PATH:
/
home/
servlmvm/
.trash/
../
www/
wp-includes/
post-template.php/
/
<?php /** * WordPress Post Template Functions. * * Gets content for the current post in the loop. * * @package WordPress * @subpackage Template */
/** * Displays the ID of the current item in the WordPress Loop. * * @since 0.71 */ function the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid echo get_the_ID(); }
/** * Retrieves the ID of the current item in the WordPress Loop. * * @since 2.1.0 * * @return int|false The ID of the current item in the WordPress Loop. False if $post is not set. */ function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid $post = get_post(); return ! empty( $post ) ? $post->ID : false; }
/** * Displays or retrieves the current post title with optional markup. * * @since 0.71 * * @param string $before Optional. Markup to prepend to the title. Default empty. * @param string $after Optional. Markup to append to the title. Default empty. * @param bool $display Optional. Whether to echo or return the title. Default true for echo. * @return void|string Void if `$display` argument is true or the title is empty, * current post title if `$display` is false. */ function the_title( $before = '', $after = '', $display = true ) { $title = get_the_title();
/** * Sanitizes the current title when retrieving or displaying. * * Works like the_title(), except the parameters can be in a string or * an array. See the function for what can be override in the $args parameter. * * The title before it is displayed will have the tags stripped and esc_attr() * before it is passed to the user or displayed. The default as with the_title(), * is to display the title. * * @since 2.3.0 * * @param string|array $args { * Title attribute arguments. Optional. * * @type string $before Markup to prepend to the title. Default empty. * @type string $after Markup to append to the title. Default empty. * @type bool $echo Whether to echo or return the title. Default true for echo. * @type WP_Post $post Current post object to retrieve the title for. * } * @return void|string Void if 'echo' argument is true, the title attribute if 'echo' is false. */ function the_title_attribute( $args = '' ) { $defaults = array( 'before' => '', 'after' => '', 'echo' => true, 'post' => get_post(), ); $parsed_args = wp_parse_args( $args, $defaults );
/** * Retrieves the post title. * * If the post is protected and the visitor is not an admin, then "Protected" * will be inserted before the post title. If the post is private, then * "Private" will be inserted before the post title. * * @since 0.71 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @return string */ function get_the_title( $post = 0 ) { $post = get_post( $post );
/** * Filters the text prepended to the post title for protected posts. * * The filter is only applied on the front end. * * @since 2.8.0 * * @param string $prepend Text displayed before the post title. * Default 'Protected: %s'. * @param WP_Post $post Current post object. */ $protected_title_format = apply_filters( 'protected_title_format', $prepend, $post );
/** * Filters the text prepended to the post title of private posts. * * The filter is only applied on the front end. * * @since 2.8.0 * * @param string $prepend Text displayed before the post title. * Default 'Private: %s'. * @param WP_Post $post Current post object. */ $private_title_format = apply_filters( 'private_title_format', $prepend, $post );
/** * Filters the post title. * * @since 0.71 * * @param string $post_title The post title. * @param int $post_id The post ID. */ return apply_filters( 'the_title', $post_title, $post_id ); }
/** * Displays the Post Global Unique Identifier (guid). * * The guid will appear to be a link, but should not be used as a link to the * post. The reason you should not use it as a link, is because of moving the * blog across domains. * * URL is escaped to make it XML-safe. * * @since 1.5.0 * * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post. */ function the_guid( $post = 0 ) { $post = get_post( $post );
/** * Filters the escaped Global Unique Identifier (guid) of the post. * * @since 4.2.0 * * @see get_the_guid() * * @param string $post_guid Escaped Global Unique Identifier (guid) of the post. * @param int $post_id The post ID. */ echo apply_filters( 'the_guid', $post_guid, $post_id ); }
/** * Retrieves the Post Global Unique Identifier (guid). * * The guid will appear to be a link, but should not be used as an link to the * post. The reason you should not use it as a link, is because of moving the * blog across domains. * * @since 1.5.0 * * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post. * @return string */ function get_the_guid( $post = 0 ) { $post = get_post( $post );
/** * Filters the Global Unique Identifier (guid) of the post. * * @since 1.5.0 * * @param string $post_guid Global Unique Identifier (guid) of the post. * @param int $post_id The post ID. */ return apply_filters( 'get_the_guid', $post_guid, $post_id ); }
/** * Displays the post content. * * @since 0.71 * * @param string $more_link_text Optional. Content for when there is more text. * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default false. */ function the_content( $more_link_text = null, $strip_teaser = false ) { $content = get_the_content( $more_link_text, $strip_teaser );
/** * Filters the post content. * * @since 0.71 * * @param string $content Content of the current post. */ $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]>', $content ); echo $content; }
/** * Retrieves the post content. * * @since 0.71 * @since 5.2.0 Added the `$post` parameter. * * @global int $page Page number of a single post/page. * @global int $more Boolean indicator for whether single post/page is being viewed. * @global bool $preview Whether post/page is in preview mode. * @global array $pages Array of all pages in post/page. Each array element contains * part of the content separated by the `<!--nextpage-->` tag. * @global int $multipage Boolean indicator for whether multiple pages are in play. * * @param string $more_link_text Optional. Content for when there is more text. * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default false. * @param WP_Post|object|int $post Optional. WP_Post instance or Post ID/object. Default null. * @return string */ function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) { global $page, $more, $preview, $pages, $multipage;
/* * Use the globals if the $post parameter was not specified, * but only after they have been set up in setup_postdata(). */ if ( null === $post && did_action( 'the_post' ) ) { $elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' ); } else { $elements = generate_postdata( $_post ); }
// If post password required and it doesn't match the cookie. if ( post_password_required( $_post ) ) { return get_the_password_form( $_post ); }
// If the requested page doesn't exist. if ( $elements['page'] > count( $elements['pages'] ) ) { // Give them the highest numbered page that DOES exist. $elements['page'] = count( $elements['pages'] ); }
$page_no = $elements['page']; $content = $elements['pages'][ $page_no - 1 ]; if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) { if ( has_block( 'more', $content ) ) { // Remove the core/more block delimiters. They will be left over after $content is split up. $content = preg_replace( '/<!-- \/?wp:more(.*?) -->/', '', $content ); }
if ( post_password_required( $post ) ) { return __( 'There is no excerpt because this is a protected post.' ); }
/** * Filters the retrieved post excerpt. * * @since 1.2.0 * @since 4.5.0 Introduced the `$post` parameter. * * @param string $post_excerpt The post excerpt. * @param WP_Post $post Post object. */ return apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ); }
/** * Determines whether the post has a custom excerpt. * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ * Conditional Tags} article in the Theme Developer Handbook. * * @since 2.3.0 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @return bool True if the post has a custom excerpt, false otherwise. */ function has_excerpt( $post = 0 ) { $post = get_post( $post ); return ( ! empty( $post->post_excerpt ) ); }
/** * Displays the classes for the post container element. * * @since 2.7.0 * * @param string|string[] $css_class Optional. One or more classes to add to the class list. * Default empty. * @param int|WP_Post $post Optional. Post ID or post object. Defaults to the global `$post`. */ function post_class( $css_class = '', $post = null ) { // Separates classes with a single space, collates classes for post DIV. echo 'class="' . esc_attr( implode( ' ', get_post_class( $css_class, $post ) ) ) . '"'; }
/** * Retrieves an array of the class names for the post container element. * * The class names are many: * * - If the post has a post thumbnail, `has-post-thumbnail` is added as a class. * - If the post is sticky, then the `sticky` class name is added. * - The class `hentry` is always added to each post. * - For each taxonomy that the post belongs to, a class will be added of the format * `{$taxonomy}-{$slug}`, e.g. `category-foo` or `my_custom_taxonomy-bar`. * The `post_tag` taxonomy is a special case; the class has the `tag-` prefix * instead of `post_tag-`. * * All class names are passed through the filter, {@see 'post_class'}, followed by * `$css_class` parameter value, with the post ID as the last parameter. * * @since 2.7.0 * @since 4.2.0 Custom taxonomy class names were added. * * @param string|string[] $css_class Optional. Space-separated string or array of class names * to add to the class list. Default empty. * @param int|WP_Post $post Optional. Post ID or post object. * @return string[] Array of class names. */ function get_post_class( $css_class = '', $post = null ) { $post = get_post( $post );
$classes = array();
if ( $css_class ) { if ( ! is_array( $css_class ) ) { $css_class = preg_split( '#\s+#', $css_class ); } $classes = array_map( 'esc_attr', $css_class ); } else { // Ensure that we always coerce class to being an array. $css_class = array(); }
// hentry for hAtom compliance. $classes[] = 'hentry';
// All public taxonomies. $taxonomies = get_taxonomies( array( 'public' => true ) );
/** * Filters the taxonomies to generate classes for each individual term. * * Default is all public taxonomies registered to the post type. * * @since 6.1.0 * * @param string[] $taxonomies List of all taxonomy names to generate classes for. * @param int $post_id The post ID. * @param string[] $classes An array of post class names. * @param string[] $css_class An array of additional class names added to the post. */ $taxonomies = apply_filters( 'post_class_taxonomies', $taxonomies, $post->ID, $classes, $css_class );
foreach ( (array) $taxonomies as $taxonomy ) { if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) { foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) { if ( empty( $term->slug ) ) { continue; }
/** * Filters the list of CSS class names for the current post. * * @since 2.7.0 * * @param string[] $classes An array of post class names. * @param string[] $css_class An array of additional class names added to the post. * @param int $post_id The post ID. */ $classes = apply_filters( 'post_class', $classes, $css_class, $post->ID );
return array_unique( $classes ); }
/** * Displays the class names for the body element. * * @since 2.8.0 * * @param string|string[] $css_class Optional. Space-separated string or array of class names * to add to the class list. Default empty. */ function body_class( $css_class = '' ) { // Separates class names with a single space, collates class names for body element. echo 'class="' . esc_attr( implode( ' ', get_body_class( $css_class ) ) ) . '"'; }
/** * Retrieves an array of the class names for the body element. * * @since 2.8.0 * * @global WP_Query $wp_query WordPress Query object. * * @param string|string[] $css_class Optional. Space-separated string or array of class names * to add to the class list. Default empty. * @return string[] Array of class names. */ function get_body_class( $css_class = '' ) { global $wp_query;
$classes = array();
if ( is_rtl() ) { $classes[] = 'rtl'; }
if ( is_front_page() ) { $classes[] = 'home'; } if ( is_home() ) { $classes[] = 'blog'; } if ( is_privacy_policy() ) { $classes[] = 'privacy-policy'; } if ( is_archive() ) { $classes[] = 'archive'; } if ( is_date() ) { $classes[] = 'date'; } if ( is_search() ) { $classes[] = 'search'; $classes[] = $wp_query->posts ? 'search-results' : 'search-no-results'; } if ( is_paged() ) { $classes[] = 'paged'; } if ( is_attachment() ) { $classes[] = 'attachment'; } if ( is_404() ) { $classes[] = 'error404'; }
if ( ! empty( $css_class ) ) { if ( ! is_array( $css_class ) ) { $css_class = preg_split( '#\s+#', $css_class ); } $classes = array_merge( $classes, $css_class ); } else { // Ensure that we always coerce class to being an array. $css_class = array(); }
$classes = array_map( 'esc_attr', $classes );
/** * Filters the list of CSS body class names for the current post or page. * * @since 2.8.0 * * @param string[] $classes An array of body class names. * @param string[] $css_class An array of additional class names added to the body. */ $classes = apply_filters( 'body_class', $classes, $css_class );
return array_unique( $classes ); }
/** * Determines whether the post requires password and whether a correct password has been provided. * * @since 2.7.0 * * @param int|WP_Post|null $post An optional post. Global $post used if not provided. * @return bool false if a password is not required or the correct password cookie is present, true otherwise. */ function post_password_required( $post = null ) { $post = get_post( $post );
if ( empty( $post->post_password ) ) { /** This filter is documented in wp-includes/post-template.php */ return apply_filters( 'post_password_required', false, $post ); }
if ( ! isset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) ) { /** This filter is documented in wp-includes/post-template.php */ return apply_filters( 'post_password_required', true, $post ); }
/** * Filters whether a post requires the user to supply a password. * * @since 4.7.0 * * @param bool $required Whether the user needs to supply a password. True if password has not been * provided or is incorrect, false if password has been supplied or is not required. * @param WP_Post $post Post object. */ return apply_filters( 'post_password_required', $required, $post ); }
// // Page Template Functions for usage in Themes. //
/** * The formatted output of a list of pages. * * Displays page links for paginated posts (i.e. including the `<!--nextpage-->` * Quicktag one or more times). This tag must be within The Loop. * * @since 1.2.0 * @since 5.1.0 Added the `aria_current` argument. * * @global int $page * @global int $numpages * @global int $multipage * @global int $more * * @param string|array $args { * Optional. Array or string of default arguments. * * @type string $before HTML or text to prepend to each link. Default is `<p> Pages:`. * @type string $after HTML or text to append to each link. Default is `</p>`. * @type string $link_before HTML or text to prepend to each link, inside the `<a>` tag. * Also prepended to the current item, which is not linked. Default empty. * @type string $link_after HTML or text to append to each Pages link inside the `<a>` tag. * Also appended to the current item, which is not linked. Default empty. * @type string $aria_current The value for the aria-current attribute. Possible values are 'page', * 'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'. * @type string $next_or_number Indicates whether page numbers should be used. Valid values are number * and next. Default is 'number'. * @type string $separator Text between pagination links. Default is ' '. * @type string $nextpagelink Link text for the next page link, if available. Default is 'Next Page'. * @type string $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'. * @type string $pagelink Format string for page numbers. The % in the parameter string will be * replaced with the page number, so 'Page %' generates "Page 1", "Page 2", etc. * Defaults to '%', just the page number. * @type int|bool $echo Whether to echo or not. Accepts 1|true or 0|false. Default 1|true. * } * @return string Formatted output in HTML. */ function wp_link_pages( $args = '' ) { global $page, $numpages, $multipage, $more;
/** * Filters the arguments used in retrieving page links for paginated posts. * * @since 3.0.0 * * @param array $parsed_args An array of page link arguments. See wp_link_pages() * for information on accepted arguments. */ $parsed_args = apply_filters( 'wp_link_pages_args', $parsed_args );
/** * Filters the HTML output of individual page number links. * * @since 3.6.0 * * @param string $link The page number HTML output. * @param int $i Page number for paginated posts' page links. */ $link = apply_filters( 'wp_link_pages_link', $link, $i );
/** This filter is documented in wp-includes/post-template.php */ $output .= apply_filters( 'wp_link_pages_link', $link, $prev ); } $next = $page + 1; if ( $next <= $numpages ) { if ( $prev ) { $output .= $parsed_args['separator']; } $link = _wp_link_page( $next ) . $parsed_args['link_before'] . $parsed_args['nextpagelink'] . $parsed_args['link_after'] . '</a>';
/** This filter is documented in wp-includes/post-template.php */ $output .= apply_filters( 'wp_link_pages_link', $link, $next ); } $output .= $parsed_args['after']; } }
/** * Filters the HTML output of page links for paginated posts. * * @since 3.6.0 * * @param string $output HTML output of paginated posts' page links. * @param array|string $args An array or query string of arguments. See wp_link_pages() * for information on accepted arguments. */ $html = apply_filters( 'wp_link_pages', $output, $args );
/** * Retrieves post custom meta data field. * * @since 1.5.0 * * @param string $key Meta data key name. * @return array|string|false Array of values, or single value if only one element exists. * False if the key does not exist. */ function post_custom( $key = '' ) { $custom = get_post_custom();
$html = sprintf( "<li><span class='post-meta-key'>%s</span> %s</li>\n", /* translators: %s: Post custom field name. */ esc_html( sprintf( _x( '%s:', 'Post custom field name' ), $key ) ), esc_html( $value ) );
/** * Filters the HTML output of the li element in the post custom fields list. * * @since 2.2.0 * * @param string $html The HTML output for the li element. * @param string $key Meta key. * @param string $value Meta value. */ $li_html .= apply_filters( 'the_meta_key', $html, $key, $value ); }
/** * Retrieves or displays a list of pages as a dropdown (select list). * * @since 2.1.0 * @since 4.2.0 The `$value_field` argument was added. * @since 4.3.0 The `$class` argument was added. * * @see get_pages() * * @param array|string $args { * Optional. Array or string of arguments to generate a page dropdown. See get_pages() for additional arguments. * * @type int $depth Maximum depth. Default 0. * @type int $child_of Page ID to retrieve child pages of. Default 0. * @type int|string $selected Value of the option that should be selected. Default 0. * @type bool|int $echo Whether to echo or return the generated markup. Accepts 0, 1, * or their bool equivalents. Default 1. * @type string $name Value for the 'name' attribute of the select element. * Default 'page_id'. * @type string $id Value for the 'id' attribute of the select element. * @type string $class Value for the 'class' attribute of the select element. Default: none. * Defaults to the value of `$name`. * @type string $show_option_none Text to display for showing no pages. Default empty (does not display). * @type string $show_option_no_change Text to display for "no change" option. Default empty (does not display). * @type string $option_none_value Value to use when no page is selected. Default empty. * @type string $value_field Post field used to populate the 'value' attribute of the option * elements. Accepts any valid post field. Default 'ID'. * } * @return string HTML dropdown list of pages. */ function wp_dropdown_pages( $args = '' ) { $defaults = array( 'depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', 'value_field' => 'ID', );
$parsed_args = wp_parse_args( $args, $defaults );
$pages = get_pages( $parsed_args ); $output = ''; // Back-compat with old system where both id and name were based on $name argument. if ( empty( $parsed_args['id'] ) ) { $parsed_args['id'] = $parsed_args['name']; }
/** * Filters the HTML output of a list of pages as a dropdown. * * @since 2.1.0 * @since 4.4.0 `$parsed_args` and `$pages` added as arguments. * * @param string $output HTML output for dropdown list of pages. * @param array $parsed_args The parsed arguments array. See wp_dropdown_pages() * for information on accepted arguments. * @param WP_Post[] $pages Array of the page objects. */ $html = apply_filters( 'wp_dropdown_pages', $output, $parsed_args, $pages );
if ( $parsed_args['echo'] ) { echo $html; }
return $html; }
/** * Retrieves or displays a list of pages (or hierarchical post type items) in list (li) format. * * @since 1.5.0 * @since 4.7.0 Added the `item_spacing` argument. * * @see get_pages() * * @global WP_Query $wp_query WordPress Query object. * * @param array|string $args { * Optional. Array or string of arguments to generate a list of pages. See get_pages() for additional arguments. * * @type int $child_of Display only the sub-pages of a single page by ID. Default 0 (all pages). * @type string $authors Comma-separated list of author IDs. Default empty (all authors). * @type string $date_format PHP date format to use for the listed pages. Relies on the 'show_date' parameter. * Default is the value of 'date_format' option. * @type int $depth Number of levels in the hierarchy of pages to include in the generated list. * Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to * the given n depth). Default 0. * @type bool $echo Whether or not to echo the list of pages. Default true. * @type string $exclude Comma-separated list of page IDs to exclude. Default empty. * @type array $include Comma-separated list of page IDs to include. Default empty. * @type string $link_after Text or HTML to follow the page link label. Default null. * @type string $link_before Text or HTML to precede the page link label. Default null. * @type string $post_type Post type to query for. Default 'page'. * @type string|array $post_status Comma-separated list or array of post statuses to include. Default 'publish'. * @type string $show_date Whether to display the page publish or modified date for each page. Accepts * 'modified' or any other value. An empty value hides the date. Default empty. * @type string $sort_column Comma-separated list of column names to sort the pages by. Accepts 'post_author', * 'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt', * 'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'. * @type string $title_li List heading. Passing a null or empty value will result in no heading, and the list * will not be wrapped with unordered list `<ul>` tags. Default 'Pages'. * @type string $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'. * Default 'preserve'. * @type Walker $walker Walker instance to use for listing pages. Default empty which results in a * Walker_Page instance being used. * } * @return void|string Void if 'echo' argument is true, HTML list of pages if 'echo' is false. */ function wp_list_pages( $args = '' ) { $defaults = array( 'depth' => 0, 'show_date' => '', 'date_format' => get_option( 'date_format' ), 'child_of' => 0, 'exclude' => '', 'title_li' => __( 'Pages' ), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '', );
$parsed_args = wp_parse_args( $args, $defaults );
if ( ! in_array( $parsed_args['item_spacing'], array( 'preserve', 'discard' ), true ) ) { // Invalid value, fall back to default. $parsed_args['item_spacing'] = $defaults['item_spacing']; }
// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array). $exclude_array = ( $parsed_args['exclude'] ) ? explode( ',', $parsed_args['exclude'] ) : array();
/** * Filters the array of pages to exclude from the pages list. * * @since 2.1.0 * * @param string[] $exclude_array An array of page IDs to exclude. */ $parsed_args['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) );
if ( $parsed_args['title_li'] ) { $output .= '</ul></li>'; } }
/** * Filters the HTML output of the pages to list. * * @since 1.5.1 * @since 4.4.0 `$pages` added as arguments. * * @see wp_list_pages() * * @param string $output HTML output of the pages list. * @param array $parsed_args An array of page-listing arguments. See wp_list_pages() * for information on accepted arguments. * @param WP_Post[] $pages Array of the page objects. */ $html = apply_filters( 'wp_list_pages', $output, $parsed_args, $pages );
/** * Displays or retrieves a list of pages with an optional home link. * * The arguments are listed below and part of the arguments are for wp_list_pages() function. * Check that function for more info on those arguments. * * @since 2.7.0 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments. * @since 4.7.0 Added the `item_spacing` argument. * * @param array|string $args { * Optional. Array or string of arguments to generate a page menu. See wp_list_pages() for additional arguments. * * @type string $sort_column How to sort the list of pages. Accepts post column names. * Default 'menu_order, post_title'. * @type string $menu_id ID for the div containing the page list. Default is empty string. * @type string $menu_class Class to use for the element containing the page list. Default 'menu'. * @type string $container Element to use for the element containing the page list. Default 'div'. * @type bool $echo Whether to echo the list or return it. Accepts true (echo) or false (return). * Default true. * @type int|bool|string $show_home Whether to display the link to the home page. Can just enter the text * you'd like shown for the home link. 1|true defaults to 'Home'. * @type string $link_before The HTML or text to prepend to $show_home text. Default empty. * @type string $link_after The HTML or text to append to $show_home text. Default empty. * @type string $before The HTML or text to prepend to the menu. Default is '<ul>'. * @type string $after The HTML or text to append to the menu. Default is '</ul>'. * @type string $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' * or 'discard'. Default 'discard'. * @type Walker $walker Walker instance to use for listing pages. Default empty which results in a * Walker_Page instance being used. * } * @return void|string Void if 'echo' argument is true, HTML menu if 'echo' is false. */ function wp_page_menu( $args = array() ) { $defaults = array( 'sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'item_spacing' => 'discard', 'walker' => '', ); $args = wp_parse_args( $args, $defaults );
if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) { // Invalid value, fall back to default. $args['item_spacing'] = $defaults['item_spacing']; }
/** * Filters the arguments used to generate a page-based menu. * * @since 2.7.0 * * @see wp_page_menu() * * @param array $args An array of page menu arguments. See wp_page_menu() * for information on accepted arguments. */ $args = apply_filters( 'wp_page_menu_args', $args );
$menu = '';
$list_args = $args;
// Show Home in the menu. if ( ! empty( $args['show_home'] ) ) { if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) { $text = __( 'Home' ); } else { $text = $args['show_home']; } $class = ''; if ( is_front_page() && ! is_paged() ) { $class = 'class="current_page_item"'; } $menu .= '<li ' . $class . '><a href="' . esc_url( home_url( '/' ) ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>'; // If the front page is a page, add it to the exclude list. if ( 'page' === get_option( 'show_on_front' ) ) { if ( ! empty( $list_args['exclude'] ) ) { $list_args['exclude'] .= ','; } else { $list_args['exclude'] = ''; } $list_args['exclude'] .= get_option( 'page_on_front' ); } }
/** * Filters the HTML output of a page-based menu. * * @since 2.7.0 * * @see wp_page_menu() * * @param string $menu The HTML output. * @param array $args An array of arguments. See wp_page_menu() * for information on accepted arguments. */ $menu = apply_filters( 'wp_page_menu', $menu, $args );
/** * Retrieves HTML dropdown (select) content for page list. * * @since 2.1.0 * @since 5.3.0 Formalized the existing `...$args` parameter by adding it * to the function signature. * * @uses Walker_PageDropdown to create HTML dropdown content. * @see Walker_PageDropdown::walk() for parameters and return description. * * @param mixed ...$args Elements array, maximum hierarchical depth and optional additional arguments. * @return string */ function walk_page_dropdown_tree( ...$args ) { if ( empty( $args[2]['walker'] ) ) { // The user's options are the third parameter. $walker = new Walker_PageDropdown(); } else { /** * @var Walker $walker */ $walker = $args[2]['walker']; }
return $walker->walk( ...$args ); }
// // Attachments. //
/** * Displays an attachment page link using an image or icon. * * @since 2.0.0 * * @param int|WP_Post $post Optional. Post ID or post object. * @param bool $fullsize Optional. Whether to use full size. Default false. * @param bool $deprecated Deprecated. Not used. * @param bool $permalink Optional. Whether to include permalink. Default false. */ function the_attachment_link( $post = 0, $fullsize = false, $deprecated = false, $permalink = false ) { if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '2.5.0' ); }
/** * Retrieves an attachment page link using an image or icon, if possible. * * @since 2.5.0 * @since 4.4.0 The `$post` parameter can now accept either a post ID or `WP_Post` object. * * @param int|WP_Post $post Optional. Post ID or post object. * @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array * of width and height values in pixels (in that order). Default 'thumbnail'. * @param bool $permalink Optional. Whether to add permalink to image. Default false. * @param bool $icon Optional. Whether the attachment is an icon. Default false. * @param string|false $text Optional. Link text to use. Activated by passing a string, false otherwise. * Default false. * @param array|string $attr Optional. Array or string of attributes. Default empty. * @return string HTML content. */ function wp_get_attachment_link( $post = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) { $_post = get_post( $post );
/** * Filters the list of attachment link attributes. * * @since 6.2.0 * * @param array $attributes An array of attributes for the link markup, * keyed on the attribute name. * @param int $id Post ID. */ $attributes = apply_filters( 'wp_get_attachment_link_attributes', array( 'href' => $url ), $_post->ID );
/** * Filters a retrieved attachment page link. * * @since 2.7.0 * @since 5.1.0 Added the `$attr` parameter. * * @param string $link_html The page link HTML output. * @param int|WP_Post $post Post ID or object. Can be 0 for the current global post. * @param string|int[] $size Requested image size. Can be any registered image size name, or * an array of width and height values in pixels (in that order). * @param bool $permalink Whether to add permalink to image. Default false. * @param bool $icon Whether to include an icon. * @param string|false $text If string, will be link text. * @param array|string $attr Array or string of attributes. */ return apply_filters( 'wp_get_attachment_link', $link_html, $post, $size, $permalink, $icon, $text, $attr ); }
/** * Wraps attachment in paragraph tag before content. * * @since 2.0.0 * * @param string $content * @return string */ function prepend_attachment( $content ) { $post = get_post();
if ( wp_attachment_is( 'video', $post ) ) { $meta = wp_get_attachment_metadata( get_the_ID() ); $atts = array( 'src' => wp_get_attachment_url() ); if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) { $atts['width'] = (int) $meta['width']; $atts['height'] = (int) $meta['height']; } if ( has_post_thumbnail() ) { $atts['poster'] = wp_get_attachment_url( get_post_thumbnail_id() ); } $p = wp_video_shortcode( $atts ); } elseif ( wp_attachment_is( 'audio', $post ) ) { $p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) ); } else { $p = '<p class="attachment">'; // Show the medium sized image representation of the attachment if available, and link to the raw file. $p .= wp_get_attachment_link( 0, 'medium', false ); $p .= '</p>'; }
/** * Filters the attachment markup to be prepended to the post content. * * @since 2.0.0 * * @see prepend_attachment() * * @param string $p The attachment HTML output. */ $p = apply_filters( 'prepend_attachment', $p );
return "$p\n$content"; }
// // Misc. //
/** * Retrieves protected post password form content. * * @since 1.0.0 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @return string HTML content for password form for password protected post. */ function get_the_password_form( $post = 0 ) { $post = get_post( $post ); $field_id = 'pwbox-' . ( empty( $post->ID ) ? wp_rand() : $post->ID ); $invalid_password = ''; $invalid_password_html = ''; $aria = ''; $class = ''; $redirect_field = '';
// If the referrer is the same as the current request, the user has entered an invalid password. if ( ! empty( $post->ID ) && wp_get_raw_referer() === get_permalink( $post->ID ) && isset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) ) { /** * Filters the invalid password message shown on password-protected posts. * The filter is only applied if the post is password protected. * * @since 6.8.0 * * @param string $text The message shown to users when entering an invalid password. * @param WP_Post $post Post object. */ $invalid_password = apply_filters( 'the_password_form_incorrect_password', __( 'Invalid password.' ), $post ); $invalid_password_html = '<div class="post-password-form-invalid-password" role="alert"><p id="error-' . $field_id . '">' . $invalid_password . '</p></div>'; $aria = ' aria-describedby="error-' . $field_id . '"'; $class = ' password-form-error'; }
/** * Filters the HTML output for the protected post password form. * * If modifying the password field, please note that the WordPress database schema * limits the password field to 255 characters regardless of the value of the * `minlength` or `maxlength` attributes or other validation that may be added to * the input. * * @since 2.7.0 * @since 5.8.0 Added the `$post` parameter. * @since 6.8.0 Added the `$invalid_password` parameter. * * @param string $output The password form HTML output. * @param WP_Post $post Post object. * @param string $invalid_password The invalid password message. */ return apply_filters( 'the_password_form', $output, $post, $invalid_password ); }
/** * Determines whether the current post uses a page template. * * This template tag allows you to determine if you are in a page template. * You can optionally provide a template filename or array of template filenames * and then the check will be specific to that template. * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ * Conditional Tags} article in the Theme Developer Handbook. * * @since 2.5.0 * @since 4.2.0 The `$template` parameter was changed to also accept an array of page templates. * @since 4.7.0 Now works with any post type, not just pages. * * @param string|string[] $template The specific template filename or array of templates to match. * @return bool True on success, false on failure. */ function is_page_template( $template = '' ) { if ( ! is_singular() ) { return false; }
/** * Gets the specific template filename for a given post. * * @since 3.4.0 * @since 4.7.0 Now works with any post type, not just pages. * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @return string|false Page template filename. Returns an empty string when the default page template * is in use. Returns false if the post does not exist. */ function get_page_template_slug( $post = null ) { $post = get_post( $post );
/** * Filters the formatted author and date for a revision. * * @since 4.4.0 * * @param string $revision_date_author The formatted string. * @param WP_Post $revision The revision object. * @param bool $link Whether to link to the revisions page, as passed into * wp_post_revision_title_expanded(). */ return apply_filters( 'wp_post_revision_title_expanded', $revision_date_author, $revision, $link ); }
/** * Displays a list of a post's revisions. * * Can output either a UL with edit links or a TABLE with diff interface, and * restore action links. * * @since 2.6.0 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @param string $type 'all' (default), 'revision' or 'autosave' */ function wp_list_post_revisions( $post = 0, $type = 'all' ) { $post = get_post( $post );
if ( ! $post ) { return; }
// $args array with (parent, format, right, left, type) deprecated since 3.6. if ( is_array( $type ) ) { $type = ! empty( $type['type'] ) ? $type['type'] : $type; _deprecated_argument( __FUNCTION__, '3.6.0' ); }
/** * Retrieves the parent post object for the given post. * * @since 5.7.0 * * @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post. * @return WP_Post|null Parent post object, or null if there isn't one. */ function get_post_parent( $post = null ) { $wp_post = get_post( $post ); return ! empty( $wp_post->post_parent ) ? get_post( $wp_post->post_parent ) : null; }
/** * Returns whether the given post has a parent post. * * @since 5.7.0 * * @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post. * @return bool Whether the post has a parent post. */ function has_post_parent( $post = null ) { return (bool) get_post_parent( $post ); }