Make WordPress Core

Changeset 13096


Ignore:
Timestamp:
02/13/2010 07:28:19 AM (15 years ago)
Author:
nacin
Message:

Deprecate old l10n and sanitization APIs. Deprecate ngettext() for _n(), ngettext_noop() for _n_noop(), translate_with_context() for _x(). Deprecate sanitize_url for esc_url_raw, js_escape for esc_js, wp_specialchars for esc_html, attribute_escape for esc_attr. See #11388

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/deprecated.php

    r13093 r13096  
    18631863function _c( $text, $domain = 'default' ) {
    18641864    _deprecated_function( __FUNCTION__, '2.9', '_x()' );
    1865     return translate_with_context( $text, $domain );
     1865    return before_last_bar( translate( $text, $domain ) );
     1866}
     1867
     1868/**
     1869 * Translates $text like translate(), but assumes that the text
     1870 * contains a context after its last vertical bar.
     1871 *
     1872 * @since 2.5
     1873 * @uses translate()
     1874 * @deprecated 3.0.0
     1875 * @deprecated Use _x()
     1876 * @see _x()
     1877 *
     1878 * @param string $text Text to translate
     1879 * @param string $domain Domain to retrieve the translated text
     1880 * @return string Translated text
     1881 */
     1882function translate_with_context( $text, $domain = 'default' ) {
     1883    _deprecated_function( __FUNCTION__, '2.9', '_x()' );
     1884    return before_last_bar( translate( $text, $domain ) );
    18661885}
    18671886
     
    18811900    _deprecated_function( __FUNCTION__, '2.9', '_nx()' );
    18821901    return before_last_bar( _n( $single, $plural, $number, $domain ) );
     1902}
     1903
     1904/**
     1905 * Retrieve the plural or single form based on the amount.
     1906 *
     1907 * @since 1.2.0
     1908 * @deprecated 2.8.0
     1909 * @deprecated Use _n()
     1910 * @see _n()
     1911 */
     1912function __ngettext() {
     1913    _deprecated_function( __FUNCTION__, '2.8', '_n()' );
     1914    $args = func_get_args();
     1915    return call_user_func_array('_n', $args);
     1916}
     1917
     1918/**
     1919 * Register plural strings in POT file, but don't translate them.
     1920 *
     1921 * @since 2.5
     1922 * @deprecated 2.8.0
     1923 * @deprecated Use _n_noop()
     1924 * @see _n_noop()
     1925 */
     1926function __ngettext_noop() {
     1927    _deprecated_function( __FUNCTION__, '2.8', '_n_noop()' );
     1928    $args = func_get_args();
     1929    return call_user_func_array('_n_noop', $args);
     1930
    18831931}
    18841932
     
    20752123}
    20762124
     2125/**
     2126 * Performs esc_url() for database or redirect usage.
     2127 *
     2128 * @since 2.3.1
     2129 * @deprecated 2.8.0
     2130 * @deprecated Use esc_url_raw()
     2131 * @see esc_url_raw()
     2132 *
     2133 * @param string $url The URL to be cleaned.
     2134 * @param array $protocols An array of acceptable protocols.
     2135 * @return string The cleaned URL.
     2136 */
     2137function sanitize_url( $url, $protocols = null ) {
     2138    _deprecated_function( __FUNCTION__, '2.8', 'esc_url_raw()' );
     2139    return clean_url( $url, $protocols, 'db' );
     2140}
     2141
     2142/**
     2143 * Escape single quotes, specialchar double quotes, and fix line endings.
     2144 *
     2145 * The filter 'js_escape' is also applied by esc_js()
     2146 *
     2147 * @since 2.0.4
     2148 * @deprecated 2.8.0
     2149 * @deprecated Use esc_js()
     2150 * @see esc_js()
     2151 *
     2152 * @param string $text The text to be escaped.
     2153 * @return string Escaped text.
     2154 */
     2155function js_escape( $text ) {
     2156    _deprecated_function( __FUNCTION__, '2.8', 'esc_js()' );
     2157    return esc_js( $text );
     2158}
     2159
     2160/**
     2161 * Escaping for HTML blocks.
     2162 *
     2163 * @deprecated 2.8.0
     2164 * @deprecated Use esc_html()
     2165 * @see esc_html()
     2166 */
     2167function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
     2168    _deprecated_function( __FUNCTION__, '2.8', 'esc_html()' );
     2169    if ( func_num_args() > 1 ) { // Maintain backwards compat for people passing additional args
     2170        $args = func_get_args();
     2171        return call_user_func_array( '_wp_specialchars', $args );
     2172    } else {
     2173        return esc_html( $string );
     2174    }
     2175}
     2176
     2177
     2178/**
     2179 * Escaping for HTML attributes.
     2180 *
     2181 * @since 2.0.6
     2182 * @deprecated 2.8.0
     2183 * @deprecated Use esc_attr()
     2184 * @see esc_attr()
     2185 *
     2186 * @param string $text
     2187 * @return string
     2188 */
     2189function attribute_escape( $text ) {
     2190    _deprecated_function( __FUNCTION__, '2.8', 'esc_attr()' );
     2191    return esc_attr( $text );
     2192}
     2193
    20772194?>
  • trunk/wp-includes/formatting.php

    r13089 r13096  
    13991399}
    14001400
    1401 
    14021401/**
    14031402 * Convert one smiley code to the icon graphic file equivalent.
     
    14291428    return " <img src='$srcurl' alt='$smiley_masked' class='wp-smiley' /> ";
    14301429}
    1431 
    14321430
    14331431/**
     
    22272225}
    22282226
    2229 
    22302227/**
    22312228 * Checks and cleans a URL.
     
    22622259 */
    22632260function esc_url_raw( $url, $protocols = null ) {
    2264     return clean_url( $url, $protocols, 'db' );
    2265 }
    2266 
    2267 /**
    2268  * Performs esc_url() for database or redirect usage.
    2269  *
    2270  * @see esc_url()
    2271  * @deprecated 2.8.0
    2272  *
    2273  * @since 2.3.1
    2274  *
    2275  * @param string $url The URL to be cleaned.
    2276  * @param array $protocols An array of acceptable protocols.
    2277  * @return string The cleaned URL.
    2278  */
    2279 function sanitize_url( $url, $protocols = null ) {
    22802261    return clean_url( $url, $protocols, 'db' );
    22812262}
     
    23192300
    23202301/**
    2321  * Escape single quotes, specialchar double quotes, and fix line endings.
    2322  *
    2323  * The filter 'js_escape' is also applied by esc_js()
    2324  *
    2325  * @since 2.0.4
    2326  *
    2327  * @deprecated 2.8.0
    2328  * @see esc_js()
    2329  *
    2330  * @param string $text The text to be escaped.
    2331  * @return string Escaped text.
    2332  */
    2333 function js_escape( $text ) {
    2334     return esc_js( $text );
    2335 }
    2336 
    2337 /**
    23382302 * Escaping for HTML blocks.
    23392303 *
     
    23502314
    23512315/**
    2352  * Escaping for HTML blocks
    2353  * @deprecated 2.8.0
    2354  * @see esc_html()
    2355  */
    2356 function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
    2357     if ( func_num_args() > 1 ) { // Maintain backwards compat for people passing additional args
    2358         $args = func_get_args();
    2359         return call_user_func_array( '_wp_specialchars', $args );
    2360     } else {
    2361         return esc_html( $string );
    2362     }
    2363 }
    2364 
    2365 /**
    23662316 * Escaping for HTML attributes.
    23672317 *
     
    23752325    $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
    23762326    return apply_filters( 'attribute_escape', $safe_text, $text );
    2377 }
    2378 
    2379 /**
    2380  * Escaping for HTML attributes.
    2381  *
    2382  * @since 2.0.6
    2383  *
    2384  * @deprecated 2.8.0
    2385  * @see esc_attr()
    2386  *
    2387  * @param string $text
    2388  * @return string
    2389  */
    2390 function attribute_escape( $text ) {
    2391     return esc_attr( $text );
    23922327}
    23932328
  • trunk/wp-includes/l10n.php

    r12988 r13096  
    7878}
    7979
    80 /**
    81  * Translates $text like translate(), but assumes that the text
    82  * contains a context after its last vertical bar.
    83  *
    84  * @since 2.5
    85  * @uses translate()
    86  *
    87  * @param string $text Text to translate
    88  * @param string $domain Domain to retrieve the translated text
    89  * @return string Translated text
    90  */
    91 function translate_with_context( $text, $domain = 'default' ) {
    92     return before_last_bar( translate( $text, $domain ) );
    93 }
    94 
    9580function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
    9681    $translations = &get_translations_for_domain( $domain );
     
    193178 *
    194179 * By including the context in the pot file translators can translate the two
    195  * string differently
    196  *
    197  * @since 2.8
     180 * string differently.
     181 *
     182 * @since 2.8.0
    198183 *
    199184 * @param string $text Text to translate
     
    202187 * @return string Translated context string without pipe
    203188 */
    204 
    205189function _x( $single, $context, $domain = 'default' ) {
    206190    return translate_with_gettext_context( $single, $context, $domain );
     
    213197function esc_html_x( $single, $context, $domain = 'default' ) {
    214198    return esc_html( translate_with_gettext_context( $single, $context, $domain ) );
    215 }
    216 
    217 function __ngettext() {
    218     _deprecated_function( __FUNCTION__, '2.8', '_n()' );
    219     $args = func_get_args();
    220     return call_user_func_array('_n', $args);
    221199}
    222200
     
    232210 * type will be a string.
    233211 *
    234  * @since 1.2.0
     212 * @since 2.8.0
    235213 * @uses $l10n Gets list of domain translated string (gettext_reader) objects
    236214 * @uses apply_filters() Calls 'ngettext' hook on domains text returned,
     
    260238    $translation = $translations->translate_plural( $single, $plural, $number, $context );
    261239    return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain );
    262 }
    263 
    264 /**
    265  * @deprecated Use _n_noop()
    266  */
    267 function __ngettext_noop() {
    268     _deprecated_function( __FUNCTION__, '2.8', '_n_noop()' );
    269     $args = func_get_args();
    270     return call_user_func_array('_n_noop', $args);
    271 
    272240}
    273241
     
    305273}
    306274
    307 
    308275/**
    309276 * Loads a MO file into the domain $domain.
Note: See TracChangeset for help on using the changeset viewer.