The function:
/**
* Retrieve post title.
*
* If the post is protected and the visitor is not an admin, then "Protected"
* will be displayed before the post title. If the post is private, then
* "Private" will be located before the post title.
*
* @since 0.71
*
* @param int $id Optional. Post ID.
* @return string
*/
function get_the_title( $id = 0 ) {
$post = &get_post($id);
$title = isset($post->post_title) ? $post->post_title : '';
$id = isset($post->ID) ? $post->ID : (int) $id;
if ( !is_admin() ) {
if ( !empty($post->post_password) ) {
$protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));
$title = sprintf($protected_title_format, $title);
} else if ( isset($post->post_status) && 'private' == $post->post_status ) {
$private_title_format = apply_filters('private_title_format', __('Private: %s'));
$title = sprintf($private_title_format, $title);
}
}
return apply_filters( 'the_title', $title, $id );
}
I don't understand what the parameter __('Protected: %s')
means in a particular line of code below. What kind of parameter is it?
$protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));
__()
is a localization function which is used to get the localized string of the English word "Protected".
%s
is a replacement parameter that is used by sprintf()
. Basically, it replaces that with the title of a blog post.
The entire __('Protected: %s')
call is passed as a parameter to the apply_filters()
function to simply format the post title. By default I don't think anything happens, but plugins may hook on the protected_title_format
filter to further manipulate the format before applying the post title on it.