Edit File by line
/home/zeestwma/ceyloniy.../wp-inclu...
File: post-template.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WordPress Post Template Functions.
[2] Fix | Delete
*
[3] Fix | Delete
* Gets content for the current post in the loop.
[4] Fix | Delete
*
[5] Fix | Delete
* @package WordPress
[6] Fix | Delete
* @subpackage Template
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Displays the ID of the current item in the WordPress Loop.
[11] Fix | Delete
*
[12] Fix | Delete
* @since 0.71
[13] Fix | Delete
*/
[14] Fix | Delete
function the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[15] Fix | Delete
echo get_the_ID();
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Retrieves the ID of the current item in the WordPress Loop.
[20] Fix | Delete
*
[21] Fix | Delete
* @since 2.1.0
[22] Fix | Delete
*
[23] Fix | Delete
* @return int|false The ID of the current item in the WordPress Loop. False if $post is not set.
[24] Fix | Delete
*/
[25] Fix | Delete
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[26] Fix | Delete
$post = get_post();
[27] Fix | Delete
return ! empty( $post ) ? $post->ID : false;
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Displays or retrieves the current post title with optional markup.
[32] Fix | Delete
*
[33] Fix | Delete
* @since 0.71
[34] Fix | Delete
*
[35] Fix | Delete
* @param string $before Optional. Markup to prepend to the title. Default empty.
[36] Fix | Delete
* @param string $after Optional. Markup to append to the title. Default empty.
[37] Fix | Delete
* @param bool $display Optional. Whether to echo or return the title. Default true for echo.
[38] Fix | Delete
* @return void|string Void if `$display` argument is true or the title is empty,
[39] Fix | Delete
* current post title if `$display` is false.
[40] Fix | Delete
*/
[41] Fix | Delete
function the_title( $before = '', $after = '', $display = true ) {
[42] Fix | Delete
$title = get_the_title();
[43] Fix | Delete
[44] Fix | Delete
if ( strlen( $title ) === 0 ) {
[45] Fix | Delete
return;
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
$title = $before . $title . $after;
[49] Fix | Delete
[50] Fix | Delete
if ( $display ) {
[51] Fix | Delete
echo $title;
[52] Fix | Delete
} else {
[53] Fix | Delete
return $title;
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Sanitizes the current title when retrieving or displaying.
[59] Fix | Delete
*
[60] Fix | Delete
* Works like the_title(), except the parameters can be in a string or
[61] Fix | Delete
* an array. See the function for what can be override in the $args parameter.
[62] Fix | Delete
*
[63] Fix | Delete
* The title before it is displayed will have the tags stripped and esc_attr()
[64] Fix | Delete
* before it is passed to the user or displayed. The default as with the_title(),
[65] Fix | Delete
* is to display the title.
[66] Fix | Delete
*
[67] Fix | Delete
* @since 2.3.0
[68] Fix | Delete
*
[69] Fix | Delete
* @param string|array $args {
[70] Fix | Delete
* Title attribute arguments. Optional.
[71] Fix | Delete
*
[72] Fix | Delete
* @type string $before Markup to prepend to the title. Default empty.
[73] Fix | Delete
* @type string $after Markup to append to the title. Default empty.
[74] Fix | Delete
* @type bool $echo Whether to echo or return the title. Default true for echo.
[75] Fix | Delete
* @type WP_Post $post Current post object to retrieve the title for.
[76] Fix | Delete
* }
[77] Fix | Delete
* @return void|string Void if 'echo' argument is true, the title attribute if 'echo' is false.
[78] Fix | Delete
*/
[79] Fix | Delete
function the_title_attribute( $args = '' ) {
[80] Fix | Delete
$defaults = array(
[81] Fix | Delete
'before' => '',
[82] Fix | Delete
'after' => '',
[83] Fix | Delete
'echo' => true,
[84] Fix | Delete
'post' => get_post(),
[85] Fix | Delete
);
[86] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[87] Fix | Delete
[88] Fix | Delete
$title = get_the_title( $parsed_args['post'] );
[89] Fix | Delete
[90] Fix | Delete
if ( strlen( $title ) === 0 ) {
[91] Fix | Delete
return;
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
$title = $parsed_args['before'] . $title . $parsed_args['after'];
[95] Fix | Delete
$title = esc_attr( strip_tags( $title ) );
[96] Fix | Delete
[97] Fix | Delete
if ( $parsed_args['echo'] ) {
[98] Fix | Delete
echo $title;
[99] Fix | Delete
} else {
[100] Fix | Delete
return $title;
[101] Fix | Delete
}
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Retrieves the post title.
[106] Fix | Delete
*
[107] Fix | Delete
* If the post is protected and the visitor is not an admin, then "Protected"
[108] Fix | Delete
* will be inserted before the post title. If the post is private, then
[109] Fix | Delete
* "Private" will be inserted before the post title.
[110] Fix | Delete
*
[111] Fix | Delete
* @since 0.71
[112] Fix | Delete
*
[113] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
[114] Fix | Delete
* @return string
[115] Fix | Delete
*/
[116] Fix | Delete
function get_the_title( $post = 0 ) {
[117] Fix | Delete
$post = get_post( $post );
[118] Fix | Delete
[119] Fix | Delete
$post_title = isset( $post->post_title ) ? $post->post_title : '';
[120] Fix | Delete
$post_id = isset( $post->ID ) ? $post->ID : 0;
[121] Fix | Delete
[122] Fix | Delete
if ( ! is_admin() ) {
[123] Fix | Delete
if ( ! empty( $post->post_password ) ) {
[124] Fix | Delete
[125] Fix | Delete
/* translators: %s: Protected post title. */
[126] Fix | Delete
$prepend = __( 'Protected: %s' );
[127] Fix | Delete
[128] Fix | Delete
/**
[129] Fix | Delete
* Filters the text prepended to the post title for protected posts.
[130] Fix | Delete
*
[131] Fix | Delete
* The filter is only applied on the front end.
[132] Fix | Delete
*
[133] Fix | Delete
* @since 2.8.0
[134] Fix | Delete
*
[135] Fix | Delete
* @param string $prepend Text displayed before the post title.
[136] Fix | Delete
* Default 'Protected: %s'.
[137] Fix | Delete
* @param WP_Post $post Current post object.
[138] Fix | Delete
*/
[139] Fix | Delete
$protected_title_format = apply_filters( 'protected_title_format', $prepend, $post );
[140] Fix | Delete
[141] Fix | Delete
$post_title = sprintf( $protected_title_format, $post_title );
[142] Fix | Delete
} elseif ( isset( $post->post_status ) && 'private' === $post->post_status ) {
[143] Fix | Delete
[144] Fix | Delete
/* translators: %s: Private post title. */
[145] Fix | Delete
$prepend = __( 'Private: %s' );
[146] Fix | Delete
[147] Fix | Delete
/**
[148] Fix | Delete
* Filters the text prepended to the post title of private posts.
[149] Fix | Delete
*
[150] Fix | Delete
* The filter is only applied on the front end.
[151] Fix | Delete
*
[152] Fix | Delete
* @since 2.8.0
[153] Fix | Delete
*
[154] Fix | Delete
* @param string $prepend Text displayed before the post title.
[155] Fix | Delete
* Default 'Private: %s'.
[156] Fix | Delete
* @param WP_Post $post Current post object.
[157] Fix | Delete
*/
[158] Fix | Delete
$private_title_format = apply_filters( 'private_title_format', $prepend, $post );
[159] Fix | Delete
[160] Fix | Delete
$post_title = sprintf( $private_title_format, $post_title );
[161] Fix | Delete
}
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
/**
[165] Fix | Delete
* Filters the post title.
[166] Fix | Delete
*
[167] Fix | Delete
* @since 0.71
[168] Fix | Delete
*
[169] Fix | Delete
* @param string $post_title The post title.
[170] Fix | Delete
* @param int $post_id The post ID.
[171] Fix | Delete
*/
[172] Fix | Delete
return apply_filters( 'the_title', $post_title, $post_id );
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
/**
[176] Fix | Delete
* Displays the Post Global Unique Identifier (guid).
[177] Fix | Delete
*
[178] Fix | Delete
* The guid will appear to be a link, but should not be used as a link to the
[179] Fix | Delete
* post. The reason you should not use it as a link, is because of moving the
[180] Fix | Delete
* blog across domains.
[181] Fix | Delete
*
[182] Fix | Delete
* URL is escaped to make it XML-safe.
[183] Fix | Delete
*
[184] Fix | Delete
* @since 1.5.0
[185] Fix | Delete
*
[186] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or post object. Default is global $post.
[187] Fix | Delete
*/
[188] Fix | Delete
function the_guid( $post = 0 ) {
[189] Fix | Delete
$post = get_post( $post );
[190] Fix | Delete
[191] Fix | Delete
$post_guid = isset( $post->guid ) ? get_the_guid( $post ) : '';
[192] Fix | Delete
$post_id = isset( $post->ID ) ? $post->ID : 0;
[193] Fix | Delete
[194] Fix | Delete
/**
[195] Fix | Delete
* Filters the escaped Global Unique Identifier (guid) of the post.
[196] Fix | Delete
*
[197] Fix | Delete
* @since 4.2.0
[198] Fix | Delete
*
[199] Fix | Delete
* @see get_the_guid()
[200] Fix | Delete
*
[201] Fix | Delete
* @param string $post_guid Escaped Global Unique Identifier (guid) of the post.
[202] Fix | Delete
* @param int $post_id The post ID.
[203] Fix | Delete
*/
[204] Fix | Delete
echo apply_filters( 'the_guid', $post_guid, $post_id );
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
/**
[208] Fix | Delete
* Retrieves the Post Global Unique Identifier (guid).
[209] Fix | Delete
*
[210] Fix | Delete
* The guid will appear to be a link, but should not be used as an link to the
[211] Fix | Delete
* post. The reason you should not use it as a link, is because of moving the
[212] Fix | Delete
* blog across domains.
[213] Fix | Delete
*
[214] Fix | Delete
* @since 1.5.0
[215] Fix | Delete
*
[216] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or post object. Default is global $post.
[217] Fix | Delete
* @return string
[218] Fix | Delete
*/
[219] Fix | Delete
function get_the_guid( $post = 0 ) {
[220] Fix | Delete
$post = get_post( $post );
[221] Fix | Delete
[222] Fix | Delete
$post_guid = isset( $post->guid ) ? $post->guid : '';
[223] Fix | Delete
$post_id = isset( $post->ID ) ? $post->ID : 0;
[224] Fix | Delete
[225] Fix | Delete
/**
[226] Fix | Delete
* Filters the Global Unique Identifier (guid) of the post.
[227] Fix | Delete
*
[228] Fix | Delete
* @since 1.5.0
[229] Fix | Delete
*
[230] Fix | Delete
* @param string $post_guid Global Unique Identifier (guid) of the post.
[231] Fix | Delete
* @param int $post_id The post ID.
[232] Fix | Delete
*/
[233] Fix | Delete
return apply_filters( 'get_the_guid', $post_guid, $post_id );
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
/**
[237] Fix | Delete
* Displays the post content.
[238] Fix | Delete
*
[239] Fix | Delete
* @since 0.71
[240] Fix | Delete
*
[241] Fix | Delete
* @param string $more_link_text Optional. Content for when there is more text.
[242] Fix | Delete
* @param bool $strip_teaser Optional. Strip teaser content before the more text. Default false.
[243] Fix | Delete
*/
[244] Fix | Delete
function the_content( $more_link_text = null, $strip_teaser = false ) {
[245] Fix | Delete
$content = get_the_content( $more_link_text, $strip_teaser );
[246] Fix | Delete
[247] Fix | Delete
/**
[248] Fix | Delete
* Filters the post content.
[249] Fix | Delete
*
[250] Fix | Delete
* @since 0.71
[251] Fix | Delete
*
[252] Fix | Delete
* @param string $content Content of the current post.
[253] Fix | Delete
*/
[254] Fix | Delete
$content = apply_filters( 'the_content', $content );
[255] Fix | Delete
$content = str_replace( ']]>', ']]&gt;', $content );
[256] Fix | Delete
echo $content;
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
/**
[260] Fix | Delete
* Retrieves the post content.
[261] Fix | Delete
*
[262] Fix | Delete
* @since 0.71
[263] Fix | Delete
* @since 5.2.0 Added the `$post` parameter.
[264] Fix | Delete
*
[265] Fix | Delete
* @global int $page Page number of a single post/page.
[266] Fix | Delete
* @global int $more Boolean indicator for whether single post/page is being viewed.
[267] Fix | Delete
* @global bool $preview Whether post/page is in preview mode.
[268] Fix | Delete
* @global array $pages Array of all pages in post/page. Each array element contains
[269] Fix | Delete
* part of the content separated by the `<!--nextpage-->` tag.
[270] Fix | Delete
* @global int $multipage Boolean indicator for whether multiple pages are in play.
[271] Fix | Delete
*
[272] Fix | Delete
* @param string $more_link_text Optional. Content for when there is more text.
[273] Fix | Delete
* @param bool $strip_teaser Optional. Strip teaser content before the more text. Default false.
[274] Fix | Delete
* @param WP_Post|object|int $post Optional. WP_Post instance or Post ID/object. Default null.
[275] Fix | Delete
* @return string
[276] Fix | Delete
*/
[277] Fix | Delete
function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) {
[278] Fix | Delete
global $page, $more, $preview, $pages, $multipage;
[279] Fix | Delete
[280] Fix | Delete
$_post = get_post( $post );
[281] Fix | Delete
[282] Fix | Delete
if ( ! ( $_post instanceof WP_Post ) ) {
[283] Fix | Delete
return '';
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
/*
[287] Fix | Delete
* Use the globals if the $post parameter was not specified,
[288] Fix | Delete
* but only after they have been set up in setup_postdata().
[289] Fix | Delete
*/
[290] Fix | Delete
if ( null === $post && did_action( 'the_post' ) ) {
[291] Fix | Delete
$elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' );
[292] Fix | Delete
} else {
[293] Fix | Delete
$elements = generate_postdata( $_post );
[294] Fix | Delete
}
[295] Fix | Delete
[296] Fix | Delete
if ( null === $more_link_text ) {
[297] Fix | Delete
$more_link_text = sprintf(
[298] Fix | Delete
'<span aria-label="%1$s">%2$s</span>',
[299] Fix | Delete
sprintf(
[300] Fix | Delete
/* translators: %s: Post title. */
[301] Fix | Delete
__( 'Continue reading %s' ),
[302] Fix | Delete
the_title_attribute(
[303] Fix | Delete
array(
[304] Fix | Delete
'echo' => false,
[305] Fix | Delete
'post' => $_post,
[306] Fix | Delete
)
[307] Fix | Delete
)
[308] Fix | Delete
),
[309] Fix | Delete
__( '(more&hellip;)' )
[310] Fix | Delete
);
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
$output = '';
[314] Fix | Delete
$has_teaser = false;
[315] Fix | Delete
[316] Fix | Delete
// If post password required and it doesn't match the cookie.
[317] Fix | Delete
if ( post_password_required( $_post ) ) {
[318] Fix | Delete
return get_the_password_form( $_post );
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
// If the requested page doesn't exist.
[322] Fix | Delete
if ( $elements['page'] > count( $elements['pages'] ) ) {
[323] Fix | Delete
// Give them the highest numbered page that DOES exist.
[324] Fix | Delete
$elements['page'] = count( $elements['pages'] );
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
$page_no = $elements['page'];
[328] Fix | Delete
$content = $elements['pages'][ $page_no - 1 ];
[329] Fix | Delete
if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
[330] Fix | Delete
if ( has_block( 'more', $content ) ) {
[331] Fix | Delete
// Remove the core/more block delimiters. They will be left over after $content is split up.
[332] Fix | Delete
$content = preg_replace( '/<!-- \/?wp:more(.*?) -->/', '', $content );
[333] Fix | Delete
}
[334] Fix | Delete
[335] Fix | Delete
$content = explode( $matches[0], $content, 2 );
[336] Fix | Delete
[337] Fix | Delete
if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) ) {
[338] Fix | Delete
$more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) );
[339] Fix | Delete
}
[340] Fix | Delete
[341] Fix | Delete
$has_teaser = true;
[342] Fix | Delete
} else {
[343] Fix | Delete
$content = array( $content );
[344] Fix | Delete
}
[345] Fix | Delete
[346] Fix | Delete
if ( str_contains( $_post->post_content, '<!--noteaser-->' )
[347] Fix | Delete
&& ( ! $elements['multipage'] || 1 === $elements['page'] )
[348] Fix | Delete
) {
[349] Fix | Delete
$strip_teaser = true;
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
$teaser = $content[0];
[353] Fix | Delete
[354] Fix | Delete
if ( $elements['more'] && $strip_teaser && $has_teaser ) {
[355] Fix | Delete
$teaser = '';
[356] Fix | Delete
}
[357] Fix | Delete
[358] Fix | Delete
$output .= $teaser;
[359] Fix | Delete
[360] Fix | Delete
if ( count( $content ) > 1 ) {
[361] Fix | Delete
if ( $elements['more'] ) {
[362] Fix | Delete
$output .= '<span id="more-' . $_post->ID . '"></span>' . $content[1];
[363] Fix | Delete
} else {
[364] Fix | Delete
if ( ! empty( $more_link_text ) ) {
[365] Fix | Delete
[366] Fix | Delete
/**
[367] Fix | Delete
* Filters the Read More link text.
[368] Fix | Delete
*
[369] Fix | Delete
* @since 2.8.0
[370] Fix | Delete
*
[371] Fix | Delete
* @param string $more_link_element Read More link element.
[372] Fix | Delete
* @param string $more_link_text Read More text.
[373] Fix | Delete
*/
[374] Fix | Delete
$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink( $_post ) . "#more-{$_post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
[375] Fix | Delete
}
[376] Fix | Delete
$output = force_balance_tags( $output );
[377] Fix | Delete
}
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
return $output;
[381] Fix | Delete
}
[382] Fix | Delete
[383] Fix | Delete
/**
[384] Fix | Delete
* Displays the post excerpt.
[385] Fix | Delete
*
[386] Fix | Delete
* @since 0.71
[387] Fix | Delete
*/
[388] Fix | Delete
function the_excerpt() {
[389] Fix | Delete
[390] Fix | Delete
/**
[391] Fix | Delete
* Filters the displayed post excerpt.
[392] Fix | Delete
*
[393] Fix | Delete
* @since 0.71
[394] Fix | Delete
*
[395] Fix | Delete
* @see get_the_excerpt()
[396] Fix | Delete
*
[397] Fix | Delete
* @param string $post_excerpt The post excerpt.
[398] Fix | Delete
*/
[399] Fix | Delete
echo apply_filters( 'the_excerpt', get_the_excerpt() );
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
/**
[403] Fix | Delete
* Retrieves the post excerpt.
[404] Fix | Delete
*
[405] Fix | Delete
* @since 0.71
[406] Fix | Delete
* @since 4.5.0 Introduced the `$post` parameter.
[407] Fix | Delete
*
[408] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
[409] Fix | Delete
* @return string Post excerpt.
[410] Fix | Delete
*/
[411] Fix | Delete
function get_the_excerpt( $post = null ) {
[412] Fix | Delete
if ( is_bool( $post ) ) {
[413] Fix | Delete
_deprecated_argument( __FUNCTION__, '2.3.0' );
[414] Fix | Delete
}
[415] Fix | Delete
[416] Fix | Delete
$post = get_post( $post );
[417] Fix | Delete
if ( empty( $post ) ) {
[418] Fix | Delete
return '';
[419] Fix | Delete
}
[420] Fix | Delete
[421] Fix | Delete
if ( post_password_required( $post ) ) {
[422] Fix | Delete
return __( 'There is no excerpt because this is a protected post.' );
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
/**
[426] Fix | Delete
* Filters the retrieved post excerpt.
[427] Fix | Delete
*
[428] Fix | Delete
* @since 1.2.0
[429] Fix | Delete
* @since 4.5.0 Introduced the `$post` parameter.
[430] Fix | Delete
*
[431] Fix | Delete
* @param string $post_excerpt The post excerpt.
[432] Fix | Delete
* @param WP_Post $post Post object.
[433] Fix | Delete
*/
[434] Fix | Delete
return apply_filters( 'get_the_excerpt', $post->post_excerpt, $post );
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
/**
[438] Fix | Delete
* Determines whether the post has a custom excerpt.
[439] Fix | Delete
*
[440] Fix | Delete
* For more information on this and similar theme functions, check out
[441] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[442] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[443] Fix | Delete
*
[444] Fix | Delete
* @since 2.3.0
[445] Fix | Delete
*
[446] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
[447] Fix | Delete
* @return bool True if the post has a custom excerpt, false otherwise.
[448] Fix | Delete
*/
[449] Fix | Delete
function has_excerpt( $post = 0 ) {
[450] Fix | Delete
$post = get_post( $post );
[451] Fix | Delete
return ( ! empty( $post->post_excerpt ) );
[452] Fix | Delete
}
[453] Fix | Delete
[454] Fix | Delete
/**
[455] Fix | Delete
* Displays the classes for the post container element.
[456] Fix | Delete
*
[457] Fix | Delete
* @since 2.7.0
[458] Fix | Delete
*
[459] Fix | Delete
* @param string|string[] $css_class Optional. One or more classes to add to the class list.
[460] Fix | Delete
* Default empty.
[461] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or post object. Defaults to the global `$post`.
[462] Fix | Delete
*/
[463] Fix | Delete
function post_class( $css_class = '', $post = null ) {
[464] Fix | Delete
// Separates classes with a single space, collates classes for post DIV.
[465] Fix | Delete
echo 'class="' . esc_attr( implode( ' ', get_post_class( $css_class, $post ) ) ) . '"';
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
/**
[469] Fix | Delete
* Retrieves an array of the class names for the post container element.
[470] Fix | Delete
*
[471] Fix | Delete
* The class names are many:
[472] Fix | Delete
*
[473] Fix | Delete
* - If the post has a post thumbnail, `has-post-thumbnail` is added as a class.
[474] Fix | Delete
* - If the post is sticky, then the `sticky` class name is added.
[475] Fix | Delete
* - The class `hentry` is always added to each post.
[476] Fix | Delete
* - For each taxonomy that the post belongs to, a class will be added of the format
[477] Fix | Delete
* `{$taxonomy}-{$slug}`, e.g. `category-foo` or `my_custom_taxonomy-bar`.
[478] Fix | Delete
* The `post_tag` taxonomy is a special case; the class has the `tag-` prefix
[479] Fix | Delete
* instead of `post_tag-`.
[480] Fix | Delete
*
[481] Fix | Delete
* All class names are passed through the filter, {@see 'post_class'}, followed by
[482] Fix | Delete
* `$css_class` parameter value, with the post ID as the last parameter.
[483] Fix | Delete
*
[484] Fix | Delete
* @since 2.7.0
[485] Fix | Delete
* @since 4.2.0 Custom taxonomy class names were added.
[486] Fix | Delete
*
[487] Fix | Delete
* @param string|string[] $css_class Optional. Space-separated string or array of class names
[488] Fix | Delete
* to add to the class list. Default empty.
[489] Fix | Delete
* @param int|WP_Post $post Optional. Post ID or post object.
[490] Fix | Delete
* @return string[] Array of class names.
[491] Fix | Delete
*/
[492] Fix | Delete
function get_post_class( $css_class = '', $post = null ) {
[493] Fix | Delete
$post = get_post( $post );
[494] Fix | Delete
[495] Fix | Delete
$classes = array();
[496] Fix | Delete
[497] Fix | Delete
if ( $css_class ) {
[498] Fix | Delete
if ( ! is_array( $css_class ) ) {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function