/gp-includes/backpress/functions.formatting.php

Description

From WP wp-includes/formatting.php

Missing functions are indicated in comments

Functions
attribute_escape (line 1787)

Escaping for HTML attributes.

string attribute_escape (string $text)
  • string $text
backslashit (line 893)

Adds backslashes before letters and before a number at the start of a string.

  • return: String with backslashes inserted.
  • since: 0.71
string backslashit (string $string)
  • string $string: Value to which backslashes will be added.
clean_pre (line 167)

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: The pre block without paragraph/line-break conversion.
  • since: 1.2.0
string clean_pre (array|string $matches)
  • array|string $matches: The array or string
clean_url (line 1545)

Checks and cleans a URL.

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

  • return: The cleaned $url after the 'cleaned_url' filter is applied.
  • since: 1.2.0
  • uses: wp_kses_bad_protocol() - To only permit protocols in the URL set via $protocols or the common ones set in the function.
string clean_url (string $url, [array $protocols = null], [string $context = 'display'])
  • string $url: The URL to be cleaned.
  • 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.
  • string $context: Optional. How the URL will be used. Default is 'display'.
ent2ncr (line 1259)

Converts named entities into numbered entities.

  • return: Text with converted entities.
  • since: 1.5.1
string ent2ncr (string $text)
  • string $text: The text within which entities will be converted.
esc_attr (line 1753)

Escaping for HTML attributes.

  • since: 2.8.0
string esc_attr (string $text)
  • string $text
esc_html (line 1720)

Escaping for HTML blocks.

string esc_html (string $text)
  • string $text
esc_js (line 1682)

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: Escaped text.
  • since: 2.8.0
string esc_js (string $text)
  • string $text: The text to be escaped.
esc_sql (line 1619)

Escapes data for use in a MySQL query

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

  • return: The cleaned $sql
  • since: 2.8.0
string esc_sql (string $sql)
  • string $sql: Unescaped SQL data
esc_textarea (line 1769)

Escaping for textarea values.

  • since: 3.1
string esc_textarea (string $text)
  • string $text
esc_url (line 1643)

Checks and cleans a URL.

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

  • return: The cleaned $url after the 'cleaned_url' filter is applied.
  • since: 2.8.0
  • usedby: esc_url()
  • uses: esc_url()
  • uses: wp_kses_bad_protocol() - To only permit protocols in the URL set via $protocols or the common ones set in the function.
string esc_url (string $url, [array $protocols = null])
  • string $url: The URL to be cleaned.
  • array $protocols: Optional. An array of acceptable protocols. Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set.
esc_url_raw (line 1661)

Performs esc_url() for database usage.

string esc_url_raw (string $url, [array $protocols = null])
  • string $url: The URL to be cleaned.
  • array $protocols: An array of acceptable protocols.
force_balance_tags (line 737)

Balances tags of string using a modified stack.

  • return: Balanced text.
  • author: Leonard Lin <leonard@acm.org>
  • version: 1.1
  • copyright: November 4, 2001
  • todo: Make better - change loop condition to $text in 1.2
  • since: 2.0.4
  • license: GPL
string force_balance_tags (string $text)
  • string $text: Text to be balanced.
format_to_edit (line 851)

Acts on text which is about to be edited.

Unless $richedit is set, it is simply a holder for the 'format_to_edit' filter. If $richedit is set true htmlspecialchars() will be run on the content, converting special characters to HTMl entities.

  • return: The text after the filter (and possibly htmlspecialchars()) has been run.
  • since: 0.71
string format_to_edit (string $content, [bool $richedit = false])
  • string $content: The text about to be edited.
  • bool $richedit: Whether or not the $content should pass through htmlspecialchars(). Default false.
is_email (line 1093)

Verifies that an email is valid.

Does not grok i18n domains. Not RFC compliant.

  • return: Either false or the valid email address.
  • since: 0.71
string|bool is_email (string $email, [boolean $check_dns = false])
  • string $email: Email address to verify.
  • boolean $check_dns: Whether to check the DNS for the domain using checkdnsrr().
js_escape (line 1706)

Escape single quotes, specialchar double quotes, and fix line endings.

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

  • return: Escaped text.
  • see: esc_js()
  • deprecated: 2.8.0
  • since: 2.0.4
string js_escape (string $text)
  • string $text: The text to be escaped.
like_escape (line 1803)

Escapes text for SQL LIKE special characters % and _.

  • return: text, safe for inclusion in LIKE query.
  • since: 2.5.0
string like_escape (string $text)
  • string $text: The text to be escaped.
make_clickable (line 1063)

Convert plaintext URI to HTML links.

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

  • return: Content with converted URIs.
  • since: 0.71
string make_clickable (string $ret)
  • string $ret: Content to convert URIs.
remove_accents (line 474)

Converts all accent characters to ASCII characters.

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

  • return: Filtered string with replaced "nice" characters.
  • since: 1.2.1
string remove_accents (string $string)
  • string $string: Text that might have accent characters
sanitize_email (line 1172)

Strips out all characters that are not allowable in an email.

  • return: Filtered email address.
  • since: 1.5.0
string sanitize_email (string $email)
  • string $email: Email address to filter.
sanitize_text_field (line 1932)

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 whitre space, strip octets.

  • since: 2.9
string sanitize_text_field (string $str)
  • string $str
sanitize_title (line 658)

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: The sanitized string.
  • since: 1.0.0
string sanitize_title (string $title, [string $fallback_title = ''])
  • string $title: The string to be sanitized.
  • string $fallback_title: Optional. A title to use if $title is empty.
sanitize_title_with_dashes (line 682)

Sanitizes title, replacing whitespace with dashes.

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

  • return: The sanitized title.
  • since: 1.2.0
string sanitize_title_with_dashes (string $title)
  • string $title: The title to be sanitized.
sanitize_user (line 626)

Sanitize username stripping out unsafe characters.

If $strict is true, only alphanumeric characters (as well as _, space, ., -,

  • return: The sanitized username, after passing through filters.
  • since: 2.0.0
  • uses: apply_filters() - Calls 'sanitize_user' hook on username, raw username, and $strict parameter.
string sanitize_user (string $username, [bool $strict = false])
  • string $username: The username to be sanitized.
  • bool $strict: If set limits $username to specific characters. Default false.
seems_utf8 (line 196)

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: True if $str fits a UTF-8 model, false otherwise.
  • author: bmorel at ssi dot fr (modified)
  • since: 1.2.1
bool seems_utf8 (string $str)
  • string $str: The string to be checked
stripslashes_deep (line 952)

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: Stripped array (or string in the callback).
  • since: 2.0.0
array|string stripslashes_deep (array|string $value)
  • array|string $value: The array or string to be striped.
trailingslashit (line 916)

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 with trailing slash added.
  • since: 1.2.0
  • uses: untrailingslashit() - Unslashes string if it was slashed already.
string trailingslashit (string $string)
  • string $string: What to add the trailing slash to.
untrailingslashit (line 933)

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 without the trailing slash.
  • since: 2.2.0
  • usedby: trailingslashit() - Unslashes string if it was slashed already.
string untrailingslashit (string $string)
  • string $string: What to remove the trailing slash from.
urlencode_deep (line 970)

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: The encoded array (or string from the callback).
  • since: 2.2.0
array|string urlencode_deep (array|string $value)
  • array|string $value: The array or string to be encoded.
utf8_uri_encode (line 421)

Encode the Unicode values to be used in the URI.

  • return: String with Unicode encoded for URI.
  • since: 1.5.0
string utf8_uri_encode (string $utf8_string, [int $length = 0])
  • string $utf8_string
  • int $length: Max length of the string
wptexturize (line 38)

Replaces common plain text characters into formatted entities

As an example,

  1.  'cause today's effort makes it worth tomorrows "holiday"...
Becomes:
  1.  &#8217;cause today&#8217;s effort makes it worth tomorrow&#8217;s &#8220;holiday&#8221;&#8230;
Code within certain html blocks are skipped.

  • return: The string replaced with html entities
  • since: 0.71
  • uses: $wp_cockneyreplace - Array of formatted entities for certain common phrases
string wptexturize (string $text)
  • string $text: The text to be formatted
wp_check_invalid_utf8 (line 371)

Checks for invalid UTF8 in a string.

  • return: The checked text.
  • since: 2.8
string wp_check_invalid_utf8 (string $string, [boolean $strip = false])
  • string $string: The text which is to be checked.
  • boolean $strip: Optional. Whether to attempt to strip out invalid UTF8. Default is false.
wp_html_excerpt (line 1881)

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: The excerpt.
  • since: 2.5.0
string wp_html_excerpt (integer $str, integer $count)
  • integer $str: String to get the excerpt from.
  • integer $count: Maximum number of characters to take.
wp_parse_str (line 1824)

Parses a string into variables to be stored in an array.

Uses parse_str() and stripslashes if magic_quotes_gpc is on.

void wp_parse_str (string $string,  &$array, array $array)
  • string $string: The string to be parsed.
  • array $array: Variables will be stored in this array.
  • &$array
wp_pre_kses_less_than (line 1844)

Convert lone less than signs.

KSES already converts lone greater than signs.

string wp_pre_kses_less_than (string $text)
  • string $text: Text to be converted.
wp_pre_kses_less_than_callback (line 1858)

Callback function used by preg_replace.

  • return: The text returned after esc_html if needed.
  • since: 2.3.0
  • usedby: wp_pre_kses_less_than() - in the callback function.
  • uses: esc_html() - to format the $matches text.
string wp_pre_kses_less_than_callback (array $matches)
  • array $matches: Populated by matches to preg_replace.
wp_specialchars (line 1734)

Escaping for HTML blocks

void wp_specialchars ( $string, [ $quote_style = ENT_NOQUOTES], [ $charset = false], [ $double_encode = false])
  • $string
  • $quote_style
  • $charset
  • $double_encode
wp_specialchars_decode (line 312)

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: The decoded text without HTML entities.
  • since: 2.8
string wp_specialchars_decode (string $string, [mixed $quote_style = ENT_NOQUOTES])
  • string $string: The text which is to be decoded.
  • 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.
wp_strip_all_tags (line 1906)

Properly strip all HTML tags including script and style

  • return: The processed string.
  • since: 2.9.0
string wp_strip_all_tags (string $string, [bool $remove_breaks = false])
  • string $string: String containing HTML tags
  • bool $remove_breaks: optional Whether to remove left over line breaks and white space chars
zeroise (line 879)

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 number 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: Adds leading zeros to number if needed.
  • since: 0.71
string zeroise (mixed $number, int $threshold)
  • mixed $number: Number to append zeros to if not greater than threshold.
  • int $threshold: Digit places number needs to be to not have zeros added.
_wp_specialchars (line 235)

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: The encoded text with HTML entities.
  • since: 1.2.2
string _wp_specialchars (string $string, [mixed $quote_style = ENT_NOQUOTES], [string $charset = false], [boolean $double_encode = false])
  • string $string: The text which is to be encoded.
  • 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.
  • string $charset: Optional. The character encoding of the string. Default is false.
  • boolean $double_encode: Optional. Whether or not to encode existing html entities. Default is false.

Documentation generated on Fri, 18 May 2012 01:45:56 +0100 by phpDocumentor 1.4.3