Add missing doc blocks to formatting.php.

Rehabilitate the spacing of various doc blocks.
Standardize some return values that are adjacent to similar functions.

See #32444.


git-svn-id: https://develop.svn.wordpress.org/trunk@32590 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-05-25 02:58:00 +00:00
parent 09d6c51801
commit 928dc46a3b

View File

@ -21,7 +21,16 @@
* Code within certain html blocks are skipped.
*
* @since 0.71
* @uses $wp_cockneyreplace Array of formatted entities for certain common phrases
*
* @global array $wp_cockneyreplace Array of formatted entities for certain common phrases
* @global array $shortcode_tags
* @staticvar array $static_characters
* @staticvar array $static_replacements
* @staticvar array $dynamic_characters
* @staticvar array $dynamic_replacements
* @staticvar array $default_no_texturize_tags
* @staticvar array $default_no_texturize_shortcodes
* @staticvar bool $run_texturize
*
* @param string $text The text to be formatted
* @param bool $reset Set to true for unit testing. Translated patterns will reset.
@ -297,9 +306,7 @@ function wptexturize($text, $reset = false) {
$text = implode( '', $textarr );
// Replace each & with & unless it already looks like an entity.
$text = preg_replace('/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $text);
return $text;
return preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $text );
}
/**
@ -529,6 +536,8 @@ function _autop_newline_preservation_helper( $matches ) {
*
* @since 2.9.0
*
* @global array $shortcode_tags
*
* @param string $pee The content.
* @return string The filtered content.
*/
@ -621,10 +630,12 @@ function seems_utf8($str) {
* @since 1.2.2
* @access private
*
* @staticvar string|false $_charset
*
* @param string $string The text which is to be encoded.
* @param int $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
* @param string $charset Optional. The character encoding of the string. Default is false.
* @param boolean $double_encode Optional. Whether to encode existing html entities. Default is false.
* @param bool $double_encode Optional. Whether to encode existing html entities. Default is false.
* @return string The encoded text with HTML entities.
*/
function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
@ -702,7 +713,13 @@ function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = fals
* @since 2.8.0
*
* @param string $string The text which is to be decoded.
* @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old _wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
* @param string|int $quote_style Optional. Converts double quotes if set to ENT_COMPAT,
* both single and double if set to ENT_QUOTES or
* none if set to ENT_NOQUOTES.
* Also compatible with old _wp_specialchars() values;
* converting single quotes if set to 'single',
* double if set to 'double' or both if otherwise set.
* Default is ENT_NOQUOTES.
* @return string The decoded text without HTML entities.
*/
function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
@ -758,8 +775,11 @@ function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
*
* @since 2.8.0
*
* @staticvar bool $is_utf8
* @staticvar bool $utf8_pcre
*
* @param string $string The text which is to be checked.
* @param boolean $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
* @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
* @return string The checked text.
*/
function wp_check_invalid_utf8( $string, $strip = false ) {
@ -1372,7 +1392,7 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa
* @since 2.5.1
*
* @param string $orderby Order by clause to be validated.
* @return string|bool Returns $orderby if valid, false otherwise.
* @return string|false Returns $orderby if valid, false otherwise.
*/
function sanitize_sql_orderby( $orderby ) {
if ( preg_match( '/^\s*(([a-z0-9_]+|`[a-z0-9_]+`)(\s+(ASC|DESC))?\s*(,\s*(?=[a-z0-9_`])|$))+$/i', $orderby ) || preg_match( '/^\s*RAND\(\s*\)\s*$/i', $orderby ) ) {
@ -1676,7 +1696,7 @@ function format_to_edit( $content, $richedit = false ) {
*
* @since 0.71
*
* @param mixed $number Number to append zeros to if not greater than threshold.
* @param int $number Number to append zeros to if not greater than threshold.
* @param int $threshold Digit places number needs to be to not have zeros added.
* @return string Adds leading zeros to number if needed.
*/
@ -1785,8 +1805,7 @@ function stripslashes_deep($value) {
* @return array|string $value The encoded array (or string from the callback).
*/
function urlencode_deep( $value ) {
$value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value);
return $value;
return is_array( $value ) ? array_map( 'urlencode_deep', $value ) : urlencode( $value );
}
/**
@ -1823,9 +1842,7 @@ function antispambot( $email_address, $hex_encoding = 0 ) {
}
}
$email_no_spam_address = str_replace( '@', '@', $email_no_spam_address );
return $email_no_spam_address;
return str_replace( '@', '@', $email_no_spam_address );
}
/**
@ -1976,8 +1993,7 @@ function make_clickable( $text ) {
}
// Cleanup of accidental links within links
$r = preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
return $r;
return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
}
/**
@ -2048,8 +2064,7 @@ function wp_rel_nofollow( $text ) {
// This is a pre save filter, so text is already escaped.
$text = stripslashes($text);
$text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text);
$text = wp_slash($text);
return $text;
return wp_slash( $text );
}
/**
@ -2076,9 +2091,10 @@ function wp_rel_nofollow_callback( $matches ) {
* Looks up one smiley code in the $wpsmiliestrans global array and returns an
* `<img>` string for that smiley.
*
* @global array $wpsmiliestrans
* @since 2.8.0
*
* @global array $wpsmiliestrans
*
* @param array $matches Single match. Smiley code to convert to image.
* @return string Image string for smiley.
*/
@ -2121,7 +2137,8 @@ function translate_smiley( $matches ) {
* used in the function isn't empty.
*
* @since 0.71
* @uses $wp_smiliessearch
*
* @global string|array $wp_smiliessearch
*
* @param string $text Content to convert smilies from text.
* @return string Converted content with text smilies replaced with images.
@ -2173,7 +2190,7 @@ function convert_smilies( $text ) {
* @since 0.71
*
* @param string $email Email address to verify.
* @param boolean $deprecated Deprecated.
* @param bool $deprecated Deprecated.
* @return string|bool Either false or the valid email address.
*/
function is_email( $email, $deprecated = false ) {
@ -2271,8 +2288,7 @@ function wp_iso_descrambler($string) {
return $string;
} else {
$subject = str_replace('_', ' ', $matches[2]);
$subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject);
return $subject;
return preg_replace_callback( '#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject );
}
}
@ -3052,7 +3068,8 @@ function wp_htmledit_pre($output) {
* @since 2.8.1
* @access private
*
* @param string|array $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
* @param string|array $search The value being searched for, otherwise known as the needle.
* An array may be used to designate multiple needles.
* @param string $subject The string being searched and replaced on, otherwise known as the haystack.
* @return string The string with the replaced svalues.
*/
@ -3075,6 +3092,9 @@ function _deep_replace( $search, $subject ) {
* is preparing an array for use in an IN clause.
*
* @since 2.8.0
*
* @global wpdb $wpdb
*
* @param string|array $data Unescaped data
* @return string|array Escaped data
*/
@ -3094,7 +3114,9 @@ function esc_sql( $data ) {
*
* @param string $url The URL to be cleaned.
* @param array $protocols Optional. An array of acceptable protocols.
* Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn' if not set.
* Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto',
* 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms',
* 'rtsp', 'svn' if not set.
* @param string $_context Private. Use esc_url_raw() for database usage.
* @return string The cleaned $url after the 'clean_url' filter is applied.
*/
@ -3321,6 +3343,8 @@ function wp_make_link_relative( $link ) {
*
* @since 2.0.5
*
* @global wpdb $wpdb
*
* @param string $option The name of the option.
* @param string $value The unsanitised value.
* @return string Sanitized value.
@ -3523,9 +3547,7 @@ function sanitize_option($option, $value) {
* @param string $option The option name.
* @param string $original_value The original value passed to the function.
*/
$value = apply_filters( "sanitize_option_{$option}", $value, $option, $original_value );
return $value;
return apply_filters( "sanitize_option_{$option}", $value, $option, $original_value );
}
/**
@ -3721,7 +3743,7 @@ function wp_sprintf_l($pattern, $args) {
* @since 2.5.0
*
* @param string $str String to get the excerpt from.
* @param integer $count Maximum number of characters to take.
* @param int $count Maximum number of characters to take.
* @param string $more Optional. What to append if $str needs to be trimmed. Defaults to empty string.
* @return string The excerpt.
*/
@ -3745,6 +3767,8 @@ function wp_html_excerpt( $str, $count, $more = null ) {
*
* @since 2.7.0
*
* @global string $_links_add_base
*
* @param string $content String to search for links in.
* @param string $base The base URL to prefix to links.
* @param array $attrs The attributes which should be processed.
@ -3763,6 +3787,8 @@ function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {
* @since 2.7.0
* @access private
*
* @global string $_links_add_base
*
* @param string $m The matched link.
* @return string The processed link.
*/
@ -3787,6 +3813,8 @@ function _links_add_base($m) {
*
* @since 2.7.0
*
* @global string $_links_add_target
*
* @param string $content String to search for links in.
* @param string $target The Target to add to the links.
* @param array $tags An array of tags to apply to.
@ -3805,6 +3833,8 @@ function links_add_target( $content, $target = '_blank', $tags = array('a') ) {
* @since 2.7.0
* @access private
*
* @global string $_links_add_target
*
* @param string $m The matched link.
* @return string The processed link.
*/
@ -3840,7 +3870,7 @@ function normalize_whitespace( $str ) {
* @since 2.9.0
*
* @param string $string String containing HTML tags
* @param bool $remove_breaks optional Whether to remove left over line breaks and white space chars
* @param bool $remove_breaks Optional. Whether to remove left over line breaks and white space chars
* @return string The processed string.
*/
function wp_strip_all_tags($string, $remove_breaks = false) {
@ -3919,6 +3949,8 @@ function wp_basename( $path, $suffix = '' ) {
* Violating our coding standards for a good function name.
*
* @since 3.0.0
*
* @staticvar string|false $dblq
*/
function capital_P_dangit( $text ) {
// Simple replacement for titles
@ -4035,7 +4067,7 @@ function wp_unslash( $value ) {
* @since 3.6.0
*
* @param string $content A string which might contain a URL.
* @return string The found URL.
* @return string|false The found URL.
*/
function get_url_in_content( $content ) {
if ( empty( $content ) ) {
@ -4058,6 +4090,8 @@ function get_url_in_content( $content ) {
*
* @since 4.0.0
*
* @staticvar string $spaces
*
* @return string The spaces regexp.
*/
function wp_spaces_regexp() {
@ -4086,6 +4120,8 @@ function wp_spaces_regexp() {
* Print the important emoji-related styles.
*
* @since 4.2.0
*
* @staticvar bool $printed
*/
function print_emoji_styles() {
static $printed = false;
@ -4113,6 +4149,11 @@ img.emoji {
<?php
}
/**
*
* @global string $wp_version
* @staticvar bool $printed
*/
function print_emoji_detection_script() {
global $wp_version;
static $printed = false;