rtlink( 0, 'query' );
if ( empty( $shortlink ) )
return;
echo "\n";
}
/**
* Sends a Link: rel=shortlink header if a shortlink is defined for the current page.
*
* Attached to the {@see 'wp'} action.
*
* @since 3.0.0
*/
function wp_shortlink_header() {
if ( headers_sent() )
return;
$shortlink = wp_get_shortlink(0, 'query');
if ( empty($shortlink) )
return;
header('Link: <' . $shortlink . '>; rel=shortlink', false);
}
/**
* Displays the shortlink for a post.
*
* Must be called from inside "The Loop"
*
* Call like the_shortlink( __( 'Shortlinkage FTW' ) )
*
* @since 3.0.0
*
* @param string $text Optional The link text or HTML to be displayed. Defaults to 'This is the short link.'
* @param string $title Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized post title.
* @param string $before Optional HTML to display before the link. Default empty.
* @param string $after Optional HTML to display after the link. Default empty.
*/
function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {
$post = get_post();
if ( empty( $text ) )
$text = __('This is the short link.');
if ( empty( $title ) )
$title = the_title_attribute( array( 'echo' => false ) );
$shortlink = wp_get_shortlink( $post->ID );
if ( !empty( $shortlink ) ) {
$link = '' . $text . '';
/**
* Filters the short link anchor tag for a post.
*
* @since 3.0.0
*
* @param string $link Shortlink anchor tag.
* @param string $shortlink Shortlink URL.
* @param string $text Shortlink's text.
* @param string $title Shortlink's title attribute.
*/
$link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title );
echo $before, $link, $after;
}
}
/**
* Retrieves the avatar URL.
*
* @since 4.2.0
*
* @param mixed $id_or_email The Gravatar to retrieve a URL for. Accepts a user_id, gravatar md5 hash,
* user email, WP_User object, WP_Post object, or WP_Comment object.
* @param array $args {
* Optional. Arguments to return instead of the default arguments.
*
* @type int $size Height and width of the avatar in pixels. Default 96.
* @type string $default URL for the default image or a default type. Accepts '404' (return
* a 404 instead of a default image), 'retro' (8bit), 'monsterid' (monster),
* 'wavatar' (cartoon face), 'indenticon' (the "quilt"), 'mystery', 'mm',
* or 'mysteryman' (The Oyster Man), 'blank' (transparent GIF), or
* 'gravatar_default' (the Gravatar logo). Default is the value of the
* 'avatar_default' option, with a fallback of 'mystery'.
* @type bool $force_default Whether to always show the default image, never the Gravatar. Default false.
* @type string $rating What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
* judged in that order. Default is the value of the 'avatar_rating' option.
* @type string $scheme URL scheme to use. See set_url_scheme() for accepted values.
* Default null.
* @type array $processed_args When the function returns, the value will be the processed/sanitized $args
* plus a "found_avatar" guess. Pass as a reference. Default null.
* }
* @return false|string The URL of the avatar we found, or false if we couldn't find an avatar.
*/
function get_avatar_url( $id_or_email, $args = null ) {
$args = get_avatar_data( $id_or_email, $args );
return $args['url'];
}
/**
* Retrieves default data about the avatar.
*
* @since 4.2.0
*
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
* user email, WP_User object, WP_Post object, or WP_Comment object.
* @param array $args {
* Optional. Arguments to return instead of the default arguments.
*
* @type int $size Height and width of the avatar image file in pixels. Default 96.
* @type int $height Display height of the avatar in pixels. Defaults to $size.
* @type int $width Display width of the avatar in pixels. Defaults to $size.
* @type string $default URL for the default image or a default type. Accepts '404' (return
* a 404 instead of a default image), 'retro' (8bit), 'monsterid' (monster),
* 'wavatar' (cartoon face), 'indenticon' (the "quilt"), 'mystery', 'mm',
* or 'mysteryman' (The Oyster Man), 'blank' (transparent GIF), or
* 'gravatar_default' (the Gravatar logo). Default is the value of the
* 'avatar_default' option, with a fallback of 'mystery'.
* @type bool $force_default Whether to always show the default image, never the Gravatar. Default false.
* @type string $rating What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
* judged in that order. Default is the value of the 'avatar_rating' option.
* @type string $scheme URL scheme to use. See set_url_scheme() for accepted values.
* Default null.
* @type array $processed_args When the function returns, the value will be the processed/sanitized $args
* plus a "found_avatar" guess. Pass as a reference. Default null.
* @type string $extra_attr HTML attributes to insert in the IMG element. Is not sanitized. Default empty.
* }
* @return array $processed_args {
* Along with the arguments passed in `$args`, this will contain a couple of extra arguments.
*
* @type bool $found_avatar True if we were able to find an avatar for this user,
* false or not set if we couldn't.
* @type string $url The URL of the avatar we found.
* }
*/
function get_avatar_data( $id_or_email, $args = null ) {
$args = wp_parse_args( $args, array(
'size' => 96,
'height' => null,
'width' => null,
'default' => get_option( 'avatar_default', 'mystery' ),
'force_default' => false,
'rating' => get_option( 'avatar_rating' ),
'scheme' => null,
'processed_args' => null, // if used, should be a reference
'extra_attr' => '',
) );
if ( is_numeric( $args['size'] ) ) {
$args['size'] = absint( $args['size'] );
if ( ! $args['size'] ) {
$args['size'] = 96;
}
} else {
$args['size'] = 96;
}
if ( is_numeric( $args['height'] ) ) {
$args['height'] = absint( $args['height'] );
if ( ! $args['height'] ) {
$args['height'] = $args['size'];
}
} else {
$args['height'] = $args['size'];
}
if ( is_numeric( $args['width'] ) ) {
$args['width'] = absint( $args['width'] );
if ( ! $args['width'] ) {
$args['width'] = $args['size'];
}
} else {
$args['width'] = $args['size'];
}
if ( empty( $args['default'] ) ) {
$args['default'] = get_option( 'avatar_default', 'mystery' );
}
switch ( $args['default'] ) {
case 'mm' :
case 'mystery' :
case 'mysteryman' :
$args['default'] = 'mm';
break;
case 'gravatar_default' :
$args['default'] = false;
break;
}
$args['force_default'] = (bool) $args['force_default'];
$args['rating'] = strtolower( $args['rating'] );
$args['found_avatar'] = false;
/**
* Filters whether to retrieve the avatar URL early.
*
* Passing a non-null value in the 'url' member of the return array will
* effectively short circuit get_avatar_data(), passing the value through
* the {@see 'get_avatar_data'} filter and returning early.
*
* @since 4.2.0
*
* @param array $args Arguments passed to get_avatar_data(), after processing.
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
* user email, WP_User object, WP_Post object, or WP_Comment object.
*/
$args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
if ( isset( $args['url'] ) && ! is_null( $args['url'] ) ) {
/** This filter is documented in wp-includes/link-template.php */
return apply_filters( 'get_avatar_data', $args, $id_or_email );
}
$email_hash = '';
$user = $email = false;
if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
$id_or_email = get_comment( $id_or_email );
}
// Process the user identifier.
if ( is_numeric( $id_or_email ) ) {
$user = get_user_by( 'id', absint( $id_or_email ) );
} elseif ( is_string( $id_or_email ) ) {
if ( strpos( $id_or_email, '@md5.gravatar.com' ) ) {
// md5 hash
list( $email_hash ) = explode( '@', $id_or_email );
} else {
// email address
$email = $id_or_email;
}
} elseif ( $id_or_email instanceof WP_User ) {
// User Object
$user = $id_or_email;
} elseif ( $id_or_email instanceof WP_Post ) {
// Post Object
$user = get_user_by( 'id', (int) $id_or_email->post_author );
} elseif ( $id_or_email instanceof WP_Comment ) {
/**
* Filters the list of allowed comment types for retrieving avatars.
*
* @since 3.0.0
*
* @param array $types An array of content types. Default only contains 'comment'.
*/
$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
$args['url'] = false;
/** This filter is documented in wp-includes/link-template.php */
return apply_filters( 'get_avatar_data', $args, $id_or_email );
}
if ( ! empty( $id_or_email->user_id ) ) {
$user = get_user_by( 'id', (int) $id_or_email->user_id );
}
if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
$email = $id_or_email->comment_author_email;
}
}
if ( ! $email_hash ) {
if ( $user ) {
$email = $user->user_email;
}
if ( $email ) {
$email_hash = md5( strtolower( trim( $email ) ) );
}
}
if ( $email_hash ) {
$args['found_avatar'] = true;
$gravatar_server = hexdec( $email_hash[0] ) % 3;
} else {
$gravatar_server = rand( 0, 2 );
}
$url_args = array(
's' => $args['size'],
'd' => $args['default'],
'f' => $args['force_default'] ? 'y' : false,
'r' => $args['rating'],
);
if ( is_ssl() ) {
$url = 'https://secure.gravatar.com/avatar/' . $email_hash;
} else {
$url = sprintf( 'http://%d.gravatar.com/avatar/%s', $gravatar_server, $email_hash );
}
$url = add_query_arg(
rawurlencode_deep( array_filter( $url_args ) ),
set_url_scheme( $url, $args['scheme'] )
);
/**
* Filters the avatar URL.
*
* @since 4.2.0
*
* @param string $url The URL of the avatar.
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
* user email, WP_User object, WP_Post object, or WP_Comment object.
* @param array $args Arguments passed to get_avatar_data(), after processing.
*/
$args['url'] = apply_filters( 'get_avatar_url', $url, $id_or_email, $args );
/**
* Filters the avatar data.
*
* @since 4.2.0
*
* @param array $args Arguments passed to get_avatar_data(), after processing.
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
* user email, WP_User object, WP_Post object, or WP_Comment object.
*/
return apply_filters( 'get_avatar_data', $args, $id_or_email );
}
/**
* Retrieves the URL of a file in the theme.
*
* Searches in the stylesheet directory before the template directory so themes
* which inherit from a parent theme can just override one file.
*
* @since 4.7.0
*
* @param string $file Optional. File to search for in the stylesheet directory.
* @return string The URL of the file.
*/
function get_theme_file_uri( $file = '' ) {
$file = ltrim( $file, '/' );
if ( empty( $file ) ) {
$url = get_stylesheet_directory_uri();
} elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$url = get_stylesheet_directory_uri() . '/' . $file;
} else {
$url = get_template_directory_uri() . '/' . $file;
}
/**
* Filters the URL to a file in the theme.
*
* @since 4.7.0
*
* @param string $url The file URL.
* @param string $file The requested file to search for.
*/
return apply_filters( 'theme_file_uri', $url, $file );
}
/**
* Retrieves the URL of a file in the parent theme.
*
* @since 4.7.0
*
* @param string $file Optional. File to return the URL for in the template directory.
* @return string The URL of the file.
*/
function get_parent_theme_file_uri( $file = '' ) {
$file = ltrim( $file, '/' );
if ( empty( $file ) ) {
$url = get_template_directory_uri();
} else {
$url = get_template_directory_uri() . '/' . $file;
}
/**
* Filters the URL to a file in the parent theme.
*
* @since 4.7.0
*
* @param string $url The file URL.
* @param string $file The requested file to search for.
*/
return apply_filters( 'parent_theme_file_uri', $url, $file );
}
/**
* Retrieves the path of a file in the theme.
*
* Searches in the stylesheet directory before the template directory so themes
* which inherit from a parent theme can just override one file.
*
* @since 4.7.0
*
* @param string $file Optional. File to search for in the stylesheet directory.
* @return string The path of the file.
*/
function get_theme_file_path( $file = '' ) {
$file = ltrim( $file, '/' );
if ( empty( $file ) ) {
$path = get_stylesheet_directory();
} elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$path = get_stylesheet_directory() . '/' . $file;
} else {
$path = get_template_directory() . '/' . $file;
}
/**
* Filters the path to a file in the theme.
*
* @since 4.7.0
*
* @param string $path The file path.
* @param string $file The requested file to search for.
*/
return apply_filters( 'theme_file_path', $path, $file );
}
/**
* Retrieves the path of a file in the parent theme.
*
* @since 4.7.0
*
* @param string $file Optional. File to return the path for in the template directory.
* @return string The path of the file.
*/
function get_parent_theme_file_path( $file = '' ) {
$file = ltrim( $file, '/' );
if ( empty( $file ) ) {
$path = get_template_directory();
} else {
$path = get_template_directory() . '/' . $file;
}
/**
* Filters the path to a file in the parent theme.
*
* @since 4.7.0
*
* @param string $path The file path.
* @param string $file The requested file to search for.
*/
return apply_filters( 'parent_theme_file_path', $path, $file );
}
/**
* Retrieves the URL to the privacy policy page.
*
* @since 4.9.6
*
* @return string The URL to the privacy policy page. Empty string if it doesn't exist.
*/
function get_privacy_policy_url() {
$url = '';
$policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
if ( ! empty( $policy_page_id ) && get_post_status( $policy_page_id ) === 'publish' ) {
$url = (string) get_permalink( $policy_page_id );
}
/**
* Filters the URL of the privacy policy page.
*
* @since 4.9.6
*
* @param string $url The URL to the privacy policy page. Empty string
* if it doesn't exist.
* @param int $policy_page_id The ID of privacy policy page.
*/
return apply_filters( 'privacy_policy_url', $url, $policy_page_id );
}
/**
* Displays the privacy policy link with formatting, when applicable.
*
* @since 4.9.6
*
* @param string $before Optional. Display before privacy policy link. Default empty.
* @param string $after Optional. Display after privacy policy link. Default empty.
*/
function the_privacy_policy_link( $before = '', $after = '' ) {
echo get_the_privacy_policy_link( $before, $after );
}
/**
* Returns the privacy policy link with formatting, when applicable.
*
* @since 4.9.6
*
* @param string $before Optional. Display before privacy policy link. Default empty.
* @param string $after Optional. Display after privacy policy link. Default empty.
*
* @return string Markup for the link and surrounding elements. Empty string if it
* doesn't exist.
*/
function get_the_privacy_policy_link( $before = '', $after = '' ) {
$link = '';
$privacy_policy_url = get_privacy_policy_url();
$policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
$page_title = ( $policy_page_id ) ? get_the_title( $policy_page_id ) : '';
if ( $privacy_policy_url && $page_title ) {
$link = sprintf(
'%s',
esc_url( $privacy_policy_url ),
esc_html( $page_title )
);
}
/**
* Filters the privacy policy link.
*
* @since 4.9.6
*
* @param string $link The privacy policy link. Empty string if it
* doesn't exist.
* @param string $privacy_policy_url The URL of the privacy policy. Empty string
* if it doesn't exist.
*/
$link = apply_filters( 'the_privacy_policy_link', $link, $privacy_policy_url );
if ( $link ) {
return $before . $link . $after;
}
return '';
}
on' => $theme->get('Version'),
'Template' => $theme->get('Template'),
'Status' => $theme->get('Status'),
'Tags' => $theme->get('Tags'),
'Title' => $theme->get('Name'),
'AuthorName' => $theme->get('Author'),
);
foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) {
if ( ! isset( $theme_data[ $extra_header ] ) )
$theme_data[ $extra_header ] = $theme->get( $extra_header );
}
return $theme_data;
}
/**
* Alias of update_post_cache().
*
* @see update_post_cache() Posts and pages are the same, alias is intentional
*
* @since 1.5.1
* @deprecated 3.4.0 Use update_post_cache()
* @see update_post_cache()
*
* @param array $pages list of page objects
*/
function update_page_cache( &$pages ) {
_deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' );
update_post_cache( $pages );
}
/**
* Will clean the page in the cache.
*
* Clean (read: delete) page from cache that matches $id. Will also clean cache
* associated with 'all_page_ids' and 'get_pages'.
*
* @since 2.0.0
* @deprecated 3.4.0 Use clean_post_cache
* @see clean_post_cache()
*
* @param int $id Page ID to clean
*/
function clean_page_cache( $id ) {
_deprecated_function( __FUNCTION__, '3.4.0', 'clean_post_cache()' );
clean_post_cache( $id );
}
/**
* Retrieve nonce action "Are you sure" message.
*
* Deprecated in 3.4.1 and 3.5.0. Backported to 3.3.3.
*
* @since 2.0.4
* @deprecated 3.4.1 Use wp_nonce_ays()
* @see wp_nonce_ays()
*
* @param string $action Nonce action.
* @return string Are you sure message.
*/
function wp_explain_nonce( $action ) {
_deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' );
return __( 'Are you sure you want to do this?' );
}
/**
* Display "sticky" CSS class, if a post is sticky.
*
* @since 2.7.0
* @deprecated 3.5.0 Use post_class()
* @see post_class()
*
* @param int $post_id An optional post ID.
*/
function sticky_class( $post_id = null ) {
_deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' );
if ( is_sticky( $post_id ) )
echo ' sticky';
}
/**
* Retrieve post ancestors.
*
* This is no longer needed as WP_Post lazy-loads the ancestors
* property with get_post_ancestors().
*
* @since 2.3.4
* @deprecated 3.5.0 Use get_post_ancestors()
* @see get_post_ancestors()
*
* @param WP_Post $post Post object, passed by reference (unused).
*/
function _get_post_ancestors( &$post ) {
_deprecated_function( __FUNCTION__, '3.5.0' );
}
/**
* Load an image from a string, if PHP supports it.
*
* @since 2.1.0
* @deprecated 3.5.0 Use wp_get_image_editor()
* @see wp_get_image_editor()
*
* @param string $file Filename of the image to load.
* @return resource The resulting image resource on success, Error string on failure.
*/
function wp_load_image( $file ) {
_deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' );
if ( is_numeric( $file ) )
$file = get_attached_file( $file );
if ( ! is_file( $file ) ) {
/* translators: %s: file name */
return sprintf( __( 'File “%s” doesn’t exist?' ), $file );
}
if ( ! function_exists('imagecreatefromstring') )
return __('The GD image library is not installed.');
// Set artificially high because GD uses uncompressed images in memory.
wp_raise_memory_limit( 'image' );
$image = imagecreatefromstring( file_get_contents( $file ) );
if ( ! is_resource( $image ) ) {
/* translators: %s: file name */
return sprintf( __( 'File “%s” is not an image.' ), $file );
}
return $image;
}
/**
* Scale down an image to fit a particular size and save a new copy of the image.
*
* The PNG transparency will be preserved using the function, as well as the
* image type. If the file going in is PNG, then the resized image is going to
* be PNG. The only supported image types are PNG, GIF, and JPEG.
*
* Some functionality requires API to exist, so some PHP version may lose out
* support. This is not the fault of WordPress (where functionality is
* downgraded, not actual defects), but of your PHP version.
*
* @since 2.5.0
* @deprecated 3.5.0 Use wp_get_image_editor()
* @see wp_get_image_editor()
*
* @param string $file Image file path.
* @param int $max_w Maximum width to resize to.
* @param int $max_h Maximum height to resize to.
* @param bool $crop Optional. Whether to crop image or resize.
* @param string $suffix Optional. File suffix.
* @param string $dest_path Optional. New image file path.
* @param int $jpeg_quality Optional, default is 90. Image quality percentage.
* @return mixed WP_Error on failure. String with new destination path.
*/
function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
_deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' );
$editor = wp_get_image_editor( $file );
if ( is_wp_error( $editor ) )
return $editor;
$editor->set_quality( $jpeg_quality );
$resized = $editor->resize( $max_w, $max_h, $crop );
if ( is_wp_error( $resized ) )
return $resized;
$dest_file = $editor->generate_filename( $suffix, $dest_path );
$saved = $editor->save( $dest_file );
if ( is_wp_error( $saved ) )
return $saved;
return $dest_file;
}
/**
* Retrieve a single post, based on post ID.
*
* Has categories in 'post_category' property or key. Has tags in 'tags_input'
* property or key.
*
* @since 1.0.0
* @deprecated 3.5.0 Use get_post()
* @see get_post()
*
* @param int $postid Post ID.
* @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
* @return WP_Post|null Post object or array holding post contents and information
*/
function wp_get_single_post( $postid = 0, $mode = OBJECT ) {
_deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' );
return get_post( $postid, $mode );
}
/**
* Check that the user login name and password is correct.
*
* @since 0.71
* @deprecated 3.5.0 Use wp_authenticate()
* @see wp_authenticate()
*
* @param string $user_login User name.
* @param string $user_pass User password.
* @return bool False if does not authenticate, true if username and password authenticates.
*/
function user_pass_ok($user_login, $user_pass) {
_deprecated_function( __FUNCTION__, '3.5.0', 'wp_authenticate()' );
$user = wp_authenticate( $user_login, $user_pass );
if ( is_wp_error( $user ) )
return false;
return true;
}
/**
* Callback formerly fired on the save_post hook. No longer needed.
*
* @since 2.3.0
* @deprecated 3.5.0
*/
function _save_post_hook() {}
/**
* Check if the installed version of GD supports particular image type
*
* @since 2.9.0
* @deprecated 3.5.0 Use wp_image_editor_supports()
* @see wp_image_editor_supports()
*
* @param string $mime_type
* @return bool
*/
function gd_edit_image_support($mime_type) {
_deprecated_function( __FUNCTION__, '3.5.0', 'wp_image_editor_supports()' );
if ( function_exists('imagetypes') ) {
switch( $mime_type ) {
case 'image/jpeg':
return (imagetypes() & IMG_JPG) != 0;
case 'image/png':
return (imagetypes() & IMG_PNG) != 0;
case 'image/gif':
return (imagetypes() & IMG_GIF) != 0;
}
} else {
switch( $mime_type ) {
case 'image/jpeg':
return function_exists('imagecreatefromjpeg');
case 'image/png':
return function_exists('imagecreatefrompng');
case 'image/gif':
return function_exists('imagecreatefromgif');
}
}
return false;
}
/**
* Converts an integer byte value to a shorthand byte value.
*
* @since 2.3.0
* @deprecated 3.6.0 Use size_format()
* @see size_format()
*
* @param int $bytes An integer byte value.
* @return string A shorthand byte value.
*/
function wp_convert_bytes_to_hr( $bytes ) {
_deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' );
$units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' );
$log = log( $bytes, KB_IN_BYTES );
$power = (int) $log;
$size = pow( KB_IN_BYTES, $log - $power );
if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) {
$unit = $units[ $power ];
} else {
$size = $bytes;
$unit = $units[0];
}
return $size . $unit;
}
/**
* Formerly used internally to tidy up the search terms.
*
* @since 2.9.0
* @access private
* @deprecated 3.7.0
*
* @param string $t Search terms to "tidy", e.g. trim.
* @return string Trimmed search terms.
*/
function _search_terms_tidy( $t ) {
_deprecated_function( __FUNCTION__, '3.7.0' );
return trim( $t, "\"'\n\r " );
}
/**
* Determine if TinyMCE is available.
*
* Checks to see if the user has deleted the tinymce files to slim down
* their WordPress installation.
*
* @since 2.1.0
* @deprecated 3.9.0
*
* @return bool Whether TinyMCE exists.
*/
function rich_edit_exists() {
global $wp_rich_edit_exists;
_deprecated_function( __FUNCTION__, '3.9.0' );
if ( ! isset( $wp_rich_edit_exists ) )
$wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' );
return $wp_rich_edit_exists;
}
/**
* Old callback for tag link tooltips.
*
* @since 2.7.0
* @access private
* @deprecated 3.9.0
*
* @param int $count Number of topics.
* @return int Number of topics.
*/
function default_topic_count_text( $count ) {
return $count;
}
/**
* Formerly used to escape strings before inserting into the DB.
*
* Has not performed this function for many, many years. Use wpdb::prepare() instead.
*
* @since 0.71
* @deprecated 3.9.0
*
* @param string $content The text to format.
* @return string The very same text.
*/
function format_to_post( $content ) {
_deprecated_function( __FUNCTION__, '3.9.0' );
return $content;
}
/**
* Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described.
*
* @since 2.5.0
* @deprecated 4.0.0 Use wpdb::esc_like()
* @see wpdb::esc_like()
*
* @param string $text The text to be escaped.
* @return string text, safe for inclusion in LIKE query.
*/
function like_escape($text) {
_deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' );
return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text );
}
/**
* Determines if the URL can be accessed over SSL.
*
* Determines if the URL can be accessed over SSL by using the WordPress HTTP API to access
* the URL using https as the scheme.
*
* @since 2.5.0
* @deprecated 4.0.0
*
* @param string $url The URL to test.
* @return bool Whether SSL access is available.
*/
function url_is_accessable_via_ssl( $url ) {
_deprecated_function( __FUNCTION__, '4.0.0' );
$response = wp_remote_get( set_url_scheme( $url, 'https' ) );
if ( !is_wp_error( $response ) ) {
$status = wp_remote_retrieve_response_code( $response );
if ( 200 == $status || 401 == $status ) {
return true;
}
}
return false;
}
/**
* Start preview theme output buffer.
*
* Will only perform task if the user has permissions and template and preview
* query variables exist.
*
* @since 2.6.0
* @deprecated 4.3.0
*/
function preview_theme() {
_deprecated_function( __FUNCTION__, '4.3.0' );
}
/**
* Private function to modify the current template when previewing a theme
*
* @since 2.9.0
* @deprecated 4.3.0
* @access private
*
* @return string
*/
function _preview_theme_template_filter() {
_deprecated_function( __FUNCTION__, '4.3.0' );
return '';
}
/**
* Private function to modify the current stylesheet when previewing a theme
*
* @since 2.9.0
* @deprecated 4.3.0
* @access private
*
* @return string
*/
function _preview_theme_stylesheet_filter() {
_deprecated_function( __FUNCTION__, '4.3.0' );
return '';
}
/**
* Callback function for ob_start() to capture all links in the theme.
*
* @since 2.6.0
* @deprecated 4.3.0
* @access private
*
* @param string $content
* @return string
*/
function preview_theme_ob_filter( $content ) {
_deprecated_function( __FUNCTION__, '4.3.0' );
return $content;
}
/**
* Manipulates preview theme links in order to control and maintain location.
*
* Callback function for preg_replace_callback() to accept and filter matches.
*
* @since 2.6.0
* @deprecated 4.3.0
* @access private
*
* @param array $matches
* @return string
*/
function preview_theme_ob_filter_callback( $matches ) {
_deprecated_function( __FUNCTION__, '4.3.0' );
return '';
}
/**
* Formats text for the rich text editor.
*
* The {@see 'richedit_pre'} filter is applied here. If $text is empty the filter will
* be applied to an empty string.
*
* @since 2.0.0
* @deprecated 4.3.0 Use format_for_editor()
* @see format_for_editor()
*
* @param string $text The text to be formatted.
* @return string The formatted text after filter is applied.
*/
function wp_richedit_pre($text) {
_deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' );
if ( empty( $text ) ) {
/**
* Filters text returned for the rich text editor.
*
* This filter is first evaluated, and the value returned, if an empty string
* is passed to wp_richedit_pre(). If an empty string is passed, it results
* in a break tag and line feed.
*
* If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre()
* return after being formatted.
*
* @since 2.0.0
* @deprecated 4.3.0
*
* @param string $output Text for the rich text editor.
*/
return apply_filters( 'richedit_pre', '' );
}
$output = convert_chars($text);
$output = wpautop($output);
$output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) );
/** This filter is documented in wp-includes/deprecated.php */
return apply_filters( 'richedit_pre', $output );
}
/**
* Formats text for the HTML editor.
*
* Unless $output is empty it will pass through htmlspecialchars before the
* {@see 'htmledit_pre'} filter is applied.
*
* @since 2.5.0
* @deprecated 4.3.0 Use format_for_editor()
* @see format_for_editor()
*
* @param string $output The text to be formatted.
* @return string Formatted text after filter applied.
*/
function wp_htmledit_pre($output) {
_deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' );
if ( !empty($output) )
$output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > &
/**
* Filters the text before it is formatted for the HTML editor.
*
* @since 2.5.0
* @deprecated 4.3.0
*
* @param string $output The HTML-formatted text.
*/
return apply_filters( 'htmledit_pre', $output );
}
/**
* Retrieve permalink from post ID.
*
* @since 1.0.0
* @deprecated 4.4.0 Use get_permalink()
* @see get_permalink()
*
* @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
* @return string|false
*/
function post_permalink( $post_id = 0 ) {
_deprecated_function( __FUNCTION__, '4.4.0', 'get_permalink()' );
return get_permalink( $post_id );
}
/**
* Perform a HTTP HEAD or GET request.
*
* If $file_path is a writable filename, this will do a GET request and write
* the file to that path.
*
* @since 2.5.0
* @deprecated 4.4.0 Use WP_Http
* @see WP_Http
*
* @param string $url URL to fetch.
* @param string|bool $file_path Optional. File path to write request to. Default false.
* @param int $red Optional. The number of Redirects followed, Upon 5 being hit,
* returns false. Default 1.
* @return bool|string False on failure and string of headers if HEAD request.
*/
function wp_get_http( $url, $file_path = false, $red = 1 ) {
_deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' );
@set_time_limit( 60 );
if ( $red > 5 )
return false;
$options = array();
$options['redirection'] = 5;
if ( false == $file_path )
$options['method'] = 'HEAD';
else
$options['method'] = 'GET';
$response = wp_safe_remote_request( $url, $options );
if ( is_wp_error( $response ) )
return false;
$headers = wp_remote_retrieve_headers( $response );
$headers['response'] = wp_remote_retrieve_response_code( $response );
// WP_HTTP no longer follows redirects for HEAD requests.
if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) {
return wp_get_http( $headers['location'], $file_path, ++$red );
}
if ( false == $file_path )
return $headers;
// GET request - write it to the supplied filename
$out_fp = fopen($file_path, 'w');
if ( !$out_fp )
return $headers;
fwrite( $out_fp, wp_remote_retrieve_body( $response ) );
fclose($out_fp);
clearstatcache();
return $headers;
}
/**
* Whether SSL login should be forced.
*
* @since 2.6.0
* @deprecated 4.4.0 Use force_ssl_admin()
* @see force_ssl_admin()
*
* @param string|bool $force Optional Whether to force SSL login. Default null.
* @return bool True if forced, false if not forced.
*/
function force_ssl_login( $force = null ) {
_deprecated_function( __FUNCTION__, '4.4.0', 'force_ssl_admin()' );
return force_ssl_admin( $force );
}
/**
* Retrieve path of comment popup template in current or parent template.
*
* @since 1.5.0
* @deprecated 4.5.0
*
* @return string Full path to comments popup template file.
*/
function get_comments_popup_template() {
_deprecated_function( __FUNCTION__, '4.5.0' );
return '';
}
/**
* Whether the current URL is within the comments popup window.
*
* @since 1.5.0
* @deprecated 4.5.0
*
* @return bool
*/
function is_comments_popup() {
_deprecated_function( __FUNCTION__, '4.5.0' );
return false;
}
/**
* Display the JS popup script to show a comment.
*
* @since 0.71
* @deprecated 4.5.0
*/
function comments_popup_script() {
_deprecated_function( __FUNCTION__, '4.5.0' );
}
/**
* Adds element attributes to open links in new windows.
*
* @since 0.71
* @deprecated 4.5.0
*
* @param string $text Content to replace links to open in a new window.
* @return string Content that has filtered links.
*/
function popuplinks( $text ) {
_deprecated_function( __FUNCTION__, '4.5.0' );
$text = preg_replace('//i', "", $text);
return $text;
}
/**
* The Google Video embed handler callback.
*
* Deprecated function that previously assisted in turning Google Video URLs
* into embeds but that service has since been shut down.
*
* @since 2.9.0
* @deprecated 4.6.0
*
* @return string An empty string.
*/
function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) {
_deprecated_function( __FUNCTION__, '4.6.0' );
return '';
}
/**
* Retrieve path of paged template in current or parent template.
*
* @since 1.5.0
* @deprecated 4.7.0 The paged.php template is no longer part of the theme template hierarchy.
*
* @return string Full path to paged template file.
*/
function get_paged_template() {
_deprecated_function( __FUNCTION__, '4.7.0' );
return get_query_template( 'paged' );
}
/**
* Removes the HTML JavaScript entities found in early versions of Netscape 4.
*
* Previously, this function was pulled in from the original
* import of kses and removed a specific vulnerability only
* existent in early version of Netscape 4. However, this
* vulnerability never affected any other browsers and can
* be considered safe for the modern web.
*
* The regular expression which sanitized this vulnerability
* has been removed in consideration of the performance and
* energy demands it placed, now merely passing through its
* input to the return.
*
* @since 1.0.0
* @deprecated 4.7.0 Officially dropped security support for Netscape 4.
*
* @param string $string
* @return string
*/
function wp_kses_js_entities( $string ) {
_deprecated_function( __FUNCTION__, '4.7.0' );
return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $string );
}
/**
* Sort categories by ID.
*
* Used by usort() as a callback, should not be used directly. Can actually be
* used to sort any term object.
*
* @since 2.3.0
* @deprecated 4.7.0 Use wp_list_sort()
* @access private
*
* @param object $a
* @param object $b
* @return int
*/
function _usort_terms_by_ID( $a, $b ) {
_deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' );
if ( $a->term_id > $b->term_id )
return 1;
elseif ( $a->term_id < $b->term_id )
return -1;
else
return 0;
}
/**
* Sort categories by name.
*
* Used by usort() as a callback, should not be used directly. Can actually be
* used to sort any term object.
*
* @since 2.3.0
* @deprecated 4.7.0 Use wp_list_sort()
* @access private
*
* @param object $a
* @param object $b
* @return int
*/
function _usort_terms_by_name( $a, $b ) {
_deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' );
return strcmp( $a->name, $b->name );
}
/**
* Sort menu items by the desired key.
*
* @since 3.0.0
* @deprecated 4.7.0 Use wp_list_sort()
* @access private
*
* @global string $_menu_item_sort_prop
*
* @param object $a The first object to compare
* @param object $b The second object to compare
* @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b.
*/
function _sort_nav_menu_items( $a, $b ) {
global $_menu_item_sort_prop;
_deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' );
if ( empty( $_menu_item_sort_prop ) )
return 0;
if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) )
return 0;
$_a = (int) $a->$_menu_item_sort_prop;
$_b = (int) $b->$_menu_item_sort_prop;
if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop )
return 0;
elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop )
return $_a < $_b ? -1 : 1;
else
return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
}
/**
* Retrieves the Press This bookmarklet link.
*
* @since 2.6.0
* @deprecated 4.9.0
*
*/
function get_shortcut_link() {
_deprecated_function( __FUNCTION__, '4.9.0' );
$link = '';
/**
* Filters the Press This bookmarklet link.
*
* @since 2.6.0
* @deprecated 4.9.0
*
* @param string $link The Press This bookmarklet link.
*/
return apply_filters( 'shortcut_link', $link );
}
/**
* Ajax handler for saving a post from Press This.
*
* @since 4.2.0
* @deprecated 4.9.0
*/
function wp_ajax_press_this_save_post() {
_deprecated_function( __FUNCTION__, '4.9.0' );
if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' );
$wp_press_this = new WP_Press_This_Plugin();
$wp_press_this->save_post();
} else {
wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
}
}
/**
* Ajax handler for creating new category from Press This.
*
* @since 4.2.0
* @deprecated 4.9.0
*/
function wp_ajax_press_this_add_category() {
_deprecated_function( __FUNCTION__, '4.9.0' );
if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' );
$wp_press_this = new WP_Press_This_Plugin();
$wp_press_this->add_category();
} else {
wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
}
}
/**
* Filter the SQL clauses of an attachment query to include filenames.
*
* @since 4.7.0
* @deprecated 6.0.3
* @access private
*
* @param array $clauses An array including WHERE, GROUP BY, JOIN, ORDER BY,
* DISTINCT, fields (SELECT), and LIMITS clauses.
* @return array The unmodified clauses.
*/
function _filter_query_attachment_filenames( $clauses ) {
_deprecated_function( __FUNCTION__, '6.0.3', 'add_filter( "wp_allow_query_attachment_by_filename", "__return_true" )');
remove_filter( 'posts_clauses', __FUNCTION__ );
return $clauses;
}