[ Index ]

PHP Cross Reference of BackPress

title

Body

[close]

/includes/ -> functions.formatting.php (summary)

Main BackPress Formatting API.based on wp-includes/formatting.php Handles many functions for formatting output. Excluded functions are indicated in comments

File Size: 2274 lines (75 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 51 functions

  wptexturize()
  _wptexturize_pushpop_element()
  clean_pre()
  seems_utf8()
  _wp_specialchars()
  wp_specialchars_decode()
  wp_check_invalid_utf8()
  utf8_uri_encode()
  remove_accents()
  sanitize_user()
  sanitize_key()
  sanitize_title()
  sanitize_title_with_dashes()
  force_balance_tags()
  format_to_edit()
  zeroise()
  backslashit()
  trailingslashit()
  untrailingslashit()
  stripslashes_deep()
  rawurlencode_deep()
  urlencode_deep()
  _make_url_clickable_cb()
  _make_web_ftp_clickable_cb()
  _make_email_clickable_cb()
  make_clickable()
  _split_str_by_whitespace()
  is_email()
  sanitize_email()
  ent2ncr()
  _deep_replace()
  esc_sql()
  clean_url()
  esc_url()
  esc_url_raw()
  esc_js()
  js_escape()
  esc_html()
  wp_specialchars()
  esc_attr()
  esc_textarea()
  attribute_escape()
  like_escape()
  wp_parse_str()
  wp_pre_kses_less_than()
  wp_pre_kses_less_than_callback()
  wp_html_excerpt()
  wp_strip_all_tags()
  sanitize_text_field()
  wp_basename()
  sanitize_mime_type()

Functions
Functions that are not part of a class:

wptexturize($text)   X-Ref
Replaces common plain text characters into formatted entities

As an example,
<code>
'cause today's effort makes it worth tomorrow's "holiday"...
</code>
Becomes:
<code>
&#8217;cause today&#8217;s effort makes it worth tomorrow&#8217;s &#8220;holiday&#8221;&#8230;
</code>
Code within certain html blocks are skipped.

return: string The string replaced with html entities
param: string $text The text to be formatted
since: 0.71

_wptexturize_pushpop_element($text, &$stack, $disabled_elements, $opening = '<', $closing = '>')   X-Ref
Search for disabled element tags. Push element to stack on tag open and pop
on tag close. Assumes first character of $text is tag opening.

return: object
param: string $text Text to check. First character is assumed to be $opening
param: array $stack Array used as stack of opened tag elements
param: string $disabled_elements Tags to match against formatted as regexp sub-expression
param: string $opening Tag opening character, assumed to be 1 character long
param: string $opening Tag closing  character
since: 2.9.0

clean_pre($matches)   X-Ref
Accepts matches array from preg_replace_callback in wpautop() or a string.

Ensures that the contents of a <<pre>>...<</pre>> HTML block are not
converted into paragraphs or line-breaks.

return: string The pre block without paragraph/line-break conversion.
param: array|string $matches The array or string
since: 1.2.0

seems_utf8($str)   X-Ref
Checks to see if a string is utf8 encoded.

NOTE: This function checks for 5-Byte sequences, UTF8
has Bytes Sequences with a maximum length of 4.

return: bool True if $str fits a UTF-8 model, false otherwise.
author: bmorel at ssi dot fr (modified)
param: string $str The string to be checked
since: 1.2.1

_wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false )   X-Ref
Converts a number of special characters into their HTML entities.

Specifically deals with: &, <, >, ", and '.

$quote_style can be set to ENT_COMPAT to encode " to
&quot;, or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded.

return: string The encoded text with HTML entities.
param: string $string The text which is to be encoded.
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 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.
since: 1.2.2

wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES )   X-Ref
Converts a number of HTML entities into their special characters.

Specifically deals with: &, <, >, ", and '.

$quote_style can be set to ENT_COMPAT to decode " entities,
or ENT_QUOTES to do both " and '. Default is ENT_NOQUOTES where no quotes are decoded.

return: string The decoded text without HTML entities.
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.
since: 2.8

wp_check_invalid_utf8( $string, $strip = false )   X-Ref
Checks for invalid UTF8 in a string.

return: string The checked text.
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.
since: 2.8

utf8_uri_encode( $utf8_string, $length = 0 )   X-Ref
Encode the Unicode values to be used in the URI.

return: string String with Unicode encoded for URI.
param: string $utf8_string
param: int $length Max length of the string
since: 1.5.0

remove_accents($string)   X-Ref
Converts all accent characters to ASCII characters.

If there are no accent characters, then the string given is just returned.

return: string Filtered string with replaced "nice" characters.
param: string $string Text that might have accent characters
since: 1.2.1

sanitize_user( $username, $strict = false )   X-Ref
Sanitize username stripping out unsafe characters.

Removes tags, octets, entities, and if strict is enabled, will only keep
alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
raw username (the username in the parameter), and the value of $strict as
parameters for the 'sanitize_user' filter.

return: string The sanitized username, after passing through filters.
param: string $username The username to be sanitized.
param: bool $strict If set limits $username to specific characters. Default false.
since: 2.0.0

sanitize_key( $key )   X-Ref
Sanitize a string key.

Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed.

return: string Sanitized key
param: string $key String key
since: 3.0.0

sanitize_title($title, $fallback_title = '', $context = 'save')   X-Ref
Sanitizes title or use fallback title.

Specifically, HTML and PHP tags are stripped. Further actions can be added
via the plugin API. If $title is empty and $fallback_title is set, the latter
will be used.

return: string The sanitized string.
param: string $title The string to be sanitized.
param: string $fallback_title Optional. A title to use if $title is empty.
param: string $context Optional. The operation for which the string is sanitized
since: 1.0.0

sanitize_title_with_dashes($title, $raw_title = '', $context = 'display')   X-Ref
Sanitizes title, replacing whitespace and a few other characters with dashes.

Limits the output to alphanumeric characters, underscore (_) and dash (-).
Whitespace becomes a dash.

return: string The sanitized title.
param: string $title The title to be sanitized.
param: string $raw_title Optional. Not used.
param: string $context Optional. The operation for which the string is sanitized.
since: 1.2.0

force_balance_tags( $text )   X-Ref
Balances tags of string using a modified stack.

return: string Balanced text.
author: Leonard Lin <leonard@acm.org>
param: string $text Text to be balanced.
since: 2.0.4

format_to_edit( $content, $richedit = false )   X-Ref
Acts on text which is about to be edited.

The $content is run through esc_textarea(), which uses htmlspecialchars()
to convert special characters to HTML entities. If $richedit is set to true,
it is simply a holder for the 'format_to_edit' filter.

return: string The text after the filter (and possibly htmlspecialchars()) has been run.
param: string $content The text about to be edited.
param: bool $richedit Whether the $content should not pass through htmlspecialchars(). Default false (meaning it will be passed).
since: 0.71

zeroise($number, $threshold)   X-Ref
Add leading zeros when necessary.

If you set the threshold to '4' and the number is '10', then you will get
back '0010'. If you set the threshold to '4' and the number is '5000', then you
will get back '5000'.

Uses sprintf to append the amount of zeros based on the $threshold parameter
and the size of the number. If the number is large enough, then no zeros will
be appended.

return: string Adds leading zeros to number if needed.
param: mixed $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.
since: 0.71

backslashit($string)   X-Ref
Adds backslashes before letters and before a number at the start of a string.

return: string String with backslashes inserted.
param: string $string Value to which backslashes will be added.
since: 0.71

trailingslashit($string)   X-Ref
Appends a trailing slash.

Will remove trailing slash if it exists already before adding a trailing
slash. This prevents double slashing a string or path.

The primary use of this is for paths and thus should be used for paths. It is
not restricted to paths and offers no specific path support.

return: string String with trailing slash added.
param: string $string What to add the trailing slash to.
since: 1.2.0

untrailingslashit($string)   X-Ref
Removes trailing slash if it exists.

The primary use of this is for paths and thus should be used for paths. It is
not restricted to paths and offers no specific path support.

return: string String without the trailing slash.
param: string $string What to remove the trailing slash from.
since: 2.2.0

stripslashes_deep($value)   X-Ref
Navigates through an array and removes slashes from the values.

If an array is passed, the array_map() function causes a callback to pass the
value back to the function. The slashes from this value will removed.

return: array|string Stripped array (or string in the callback).
param: array|string $value The array or string to be stripped.
since: 2.0.0

rawurlencode_deep( $value )   X-Ref
Navigates through an array and raw encodes the values to be used in a URL.

return: array|string $value The encoded array (or string from the callback).
param: array|string $value The array or string to be encoded.
since: 3.4.0

urlencode_deep($value)   X-Ref
Navigates through an array and encodes the values to be used in a URL.

Uses a callback to pass the value of the array back to the function as a
string.

return: array|string $value The encoded array (or string from the callback).
param: array|string $value The array or string to be encoded.
since: 2.2.0

_make_url_clickable_cb($matches)   X-Ref
Callback to convert URI match to HTML A element.

This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
make_clickable()}.

return: string HTML A element with URI address.
param: array $matches Single Regex Match.
since: 2.3.2

_make_web_ftp_clickable_cb($matches)   X-Ref
Callback to convert URL match to HTML A element.

This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
make_clickable()}.

return: string HTML A element with URL address.
param: array $matches Single Regex Match.
since: 2.3.2

_make_email_clickable_cb($matches)   X-Ref
Callback to convert email address match to HTML A element.

This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
make_clickable()}.

return: string HTML A element with email address.
param: array $matches Single Regex Match.
since: 2.3.2

make_clickable( $text )   X-Ref
Convert plaintext URI to HTML links.

Converts URI, www and ftp, and email addresses. Finishes by fixing links
within links.

return: string Content with converted URIs.
param: string $text Content to convert URIs.
since: 0.71

_split_str_by_whitespace( $string, $goal )   X-Ref
Breaks a string into chunks by splitting at whitespace characters.
The length of each returned chunk is as close to the specified length goal as possible,
with the caveat that each chunk includes its trailing delimiter.
Chunks longer than the goal are guaranteed to not have any inner whitespace.

Joining the returned chunks with empty delimiters reconstructs the input string losslessly.

Input string must have no null characters (or eventual transformations on output chunks must not care about null characters)

<code>
_split_str_by_whitespace( "1234 67890 1234 67890a cd 1234   890 123456789 1234567890a    45678   1 3 5 7 90 ", 10 ) ==
array (
0 => '1234 67890 ',  // 11 characters: Perfect split
1 => '1234 ',        //  5 characters: '1234 67890a' was too long
2 => '67890a cd ',   // 10 characters: '67890a cd 1234' was too long
3 => '1234   890 ',  // 11 characters: Perfect split
4 => '123456789 ',   // 10 characters: '123456789 1234567890a' was too long
5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split
6 => '   45678   ',  // 11 characters: Perfect split
7 => '1 3 5 7 9',    //  9 characters: End of $string
);
</code>

return: array Numeric array of chunks.
param: string $string The string to split
param: int $goal   The desired chunk length.
since: 3.4.0

is_email( $email, $deprecated = false )   X-Ref
Verifies that an email is valid.

Does not grok i18n domains. Not RFC compliant.

return: string|bool Either false or the valid email address.
param: string $email Email address to verify.
param: boolean $deprecated Deprecated.
since: 0.71

sanitize_email( $email )   X-Ref
Strips out all characters that are not allowable in an email.

return: string Filtered email address.
param: string $email Email address to filter.
since: 1.5.0

ent2ncr($text)   X-Ref
Converts named entities into numbered entities.

return: string Text with converted entities.
param: string $text The text within which entities will be converted.
since: 1.5.1

_deep_replace($search, $subject)   X-Ref
Perform a deep string replace operation to ensure the values in $search are no longer present

Repeats the replacement operation until it no longer replaces anything so as to remove "nested" values
e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that
str_replace would return

return: string The processed string
param: string|array $search
param: string $subject
since: 2.8.1

esc_sql( $sql )   X-Ref
Escapes data for use in a MySQL query

This is just a handy shortcut for $bpdb->escape(), for completeness' sake

return: string The cleaned $sql
param: string $sql Unescaped SQL data
since: 2.8.0

clean_url( $url, $protocols = null, $context = 'display' )   X-Ref
Checks and cleans a URL.

A number of characters are removed from the URL. If the URL is for displaying
(the default behaviour) ampersands are also replaced. The 'clean_url' filter
is applied to the returned cleaned URL.

return: string The cleaned $url after the 'clean_url' filter is applied.
param: string $url The URL to be cleaned.
param: array $protocols Optional. An array of acceptable protocols.
param: string $context Optional. How the URL will be used. Default is 'display'.
since: 1.2.0

esc_url( $url, $protocols = null, $_context = 'display' )   X-Ref
Checks and cleans a URL.

A number of characters are removed from the URL. If the URL is for displaying
(the default behaviour) ampersands are also replaced. The 'clean_url' filter
is applied to the returned cleaned URL.

return: string The cleaned $url after the 'clean_url' filter is applied.
param: string $url The URL to be cleaned.
param: array $protocols Optional. An array of acceptable protocols.
param: string $_context Private. Use esc_url_raw() for database usage.
since: 2.8.0

esc_url_raw( $url, $protocols = null )   X-Ref
Performs esc_url() for database usage.

return: string The cleaned URL.
param: string $url The URL to be cleaned.
param: array $protocols An array of acceptable protocols.
since: 2.8.0

esc_js( $text )   X-Ref
Escape single quotes, htmlspecialchar " < > &, and fix line endings.

Escapes text strings for echoing in JS, both inline (for example in onclick="...")
and inside <script> tag. Note that the strings have to be in single quotes.
The filter 'js_escape' is also applied here.

return: string Escaped text.
param: string $text The text to be escaped.
since: 2.8.0

js_escape( $text )   X-Ref
Escape single quotes, specialchar double quotes, and fix line endings.

The filter 'js_escape' is also applied by esc_js()

return: string Escaped text.
param: string $text The text to be escaped.
since: 2.0.4

esc_html( $text )   X-Ref
Escaping for HTML blocks.

return: string
param: string $text
since: 2.8.0

wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false )   X-Ref
Escaping for HTML blocks


esc_attr( $text )   X-Ref
Escaping for HTML attributes.

return: string
param: string $text
since: 2.8.0

esc_textarea( $text )   X-Ref
Escaping for textarea values.

return: string
param: string $text
since: 3.1

attribute_escape( $text )   X-Ref
Escaping for HTML attributes.

return: string
param: string $text
since: 2.0.6

like_escape($text)   X-Ref
Escapes text for SQL LIKE special characters % and _.

return: string text, safe for inclusion in LIKE query.
param: string $text The text to be escaped.
since: 2.5.0

wp_parse_str( $string, &$array )   X-Ref
Parses a string into variables to be stored in an array.

Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes if
{@link http://www.php.net/magic_quotes magic_quotes_gpc} is on.

param: string $string The string to be parsed.
param: array $array Variables will be stored in this array.
since: 2.2.1

wp_pre_kses_less_than( $text )   X-Ref
Convert lone less than signs.

KSES already converts lone greater than signs.

return: string Converted text.
param: string $text Text to be converted.
since: 2.3.0

wp_pre_kses_less_than_callback( $matches )   X-Ref
Callback function used by preg_replace.

return: string The text returned after esc_html if needed.
param: array $matches Populated by matches to preg_replace.
since: 2.3.0

wp_html_excerpt( $str, $count )   X-Ref
Safely extracts not more than the first $count characters from html string.

UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT*
be counted as one character. For example &amp; will be counted as 4, &lt; as
3, etc.

return: string The excerpt.
param: integer $str String to get the excerpt from.
param: integer $count Maximum number of characters to take.
since: 2.5.0

wp_strip_all_tags($string, $remove_breaks = false)   X-Ref
Properly strip all HTML tags including script and style

return: string The processed string.
param: string $string String containing HTML tags
param: bool $remove_breaks optional Whether to remove left over line breaks and white space chars
since: 2.9.0

sanitize_text_field($str)   X-Ref
Sanitize a string from user input or from the db

check for invalid UTF-8,
Convert single < characters to entity,
strip all tags,
remove line breaks, tabs and extra white space,
strip octets.

return: string
param: string $str
since: 2.9.0

wp_basename( $path, $suffix = '' )   X-Ref
i18n friendly version of basename()

return: string
param: string $path A path.
param: string $suffix If the filename ends in suffix this will also be cut off.
since: 3.1.0

sanitize_mime_type( $mime_type )   X-Ref
Sanitize a mime type

return: string Sanitized mime type
param: string $mime_type Mime type
since: 3.1.3



Generated: Mon Apr 22 01:01:51 2019 Cross-referenced by PHPXref 0.7.1