WordPress.org

Make WordPress Core

Changeset 21140


Ignore:
Timestamp:
06/26/12 19:12:39 (3 years ago)
Author:
nacin
Message:

Deprecate wp_explain_nonce(). see #21076 for 3.4.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.4/wp-includes/functions.php

    r21119 r21140  
    18361836 * Retrieve nonce action "Are you sure" message. 
    18371837 * 
    1838  * The action is split by verb and noun. The action format is as follows: 
    1839  * verb-action_extra. The verb is before the first dash and has the format of 
    1840  * letters and no spaces and numbers. The noun is after the dash and before the 
    1841  * underscore, if an underscore exists. The noun is also only letters. 
    1842  * 
    1843  * The filter will be called for any action, which is not defined by WordPress. 
    1844  * You may use the filter for your plugin to explain nonce actions to the user, 
    1845  * when they get the "Are you sure?" message. The filter is in the format of 
    1846  * 'explain_nonce_$verb-$noun' with the $verb replaced by the found verb and the 
    1847  * $noun replaced by the found noun. The two parameters that are given to the 
    1848  * hook are the localized "Are you sure you want to do this?" message with the 
    1849  * extra text (the text after the underscore). 
     1838 * @since 2.0.4 
     1839 * @deprecated 3.4.1 
     1840 * @deprecated Use wp_nonce_ays() 
     1841 * @see wp_nonce_ays() 
     1842 * 
     1843 * @param string $action Nonce action. 
     1844 * @return string Are you sure message. 
     1845 */ 
     1846function wp_explain_nonce( $action ) { 
     1847    _deprecated_function( __FUNCTION__, '3.4', 'wp_nonce_ays()' ); 
     1848    return __( 'Are you sure you want to do this?' ); 
     1849} 
     1850 
     1851/** 
     1852 * Display "Are You Sure" message to confirm the action being taken. 
     1853 * 
     1854 * If the action has the nonce explain message, then it will be displayed along 
     1855 * with the "Are you sure?" message. 
    18501856 * 
    18511857 * @package WordPress 
     
    18531859 * @since 2.0.4 
    18541860 * 
    1855  * @param string $action Nonce action. 
    1856  * @return string Are you sure message. 
    1857  */ 
    1858 function wp_explain_nonce( $action ) { 
    1859     if ( $action !== -1 && preg_match( '/([a-z]+)-([a-z]+)(_(.+))?/', $action, $matches ) ) { 
    1860         $verb = $matches[1]; 
    1861         $noun = $matches[2]; 
    1862  
    1863         $trans = array(); 
    1864         $trans['update']['attachment'] = array( __( 'Your attempt to edit this attachment: “%s” has failed.' ), 'get_the_title' ); 
    1865  
    1866         $trans['add']['category']      = array( __( 'Your attempt to add this category has failed.' ), false ); 
    1867         $trans['delete']['category']   = array( __( 'Your attempt to delete this category: “%s” has failed.' ), 'get_cat_name' ); 
    1868         $trans['update']['category']   = array( __( 'Your attempt to edit this category: “%s” has failed.' ), 'get_cat_name' ); 
    1869  
    1870         $trans['delete']['comment']    = array( __( 'Your attempt to delete this comment: “%s” has failed.' ), 'use_id' ); 
    1871         $trans['unapprove']['comment'] = array( __( 'Your attempt to unapprove this comment: “%s” has failed.' ), 'use_id' ); 
    1872         $trans['approve']['comment']   = array( __( 'Your attempt to approve this comment: “%s” has failed.' ), 'use_id' ); 
    1873         $trans['update']['comment']    = array( __( 'Your attempt to edit this comment: “%s” has failed.' ), 'use_id' ); 
    1874         $trans['bulk']['comments']     = array( __( 'Your attempt to bulk modify comments has failed.' ), false ); 
    1875         $trans['moderate']['comments'] = array( __( 'Your attempt to moderate comments has failed.' ), false ); 
    1876  
    1877         $trans['add']['bookmark']      = array( __( 'Your attempt to add this link has failed.' ), false ); 
    1878         $trans['delete']['bookmark']   = array( __( 'Your attempt to delete this link: “%s” has failed.' ), 'use_id' ); 
    1879         $trans['update']['bookmark']   = array( __( 'Your attempt to edit this link: “%s” has failed.' ), 'use_id' ); 
    1880         $trans['bulk']['bookmarks']    = array( __( 'Your attempt to bulk modify links has failed.' ), false ); 
    1881  
    1882         $trans['add']['page']          = array( __( 'Your attempt to add this page has failed.' ), false ); 
    1883         $trans['delete']['page']       = array( __( 'Your attempt to delete this page: “%s” has failed.' ), 'get_the_title' ); 
    1884         $trans['update']['page']       = array( __( 'Your attempt to edit this page: “%s” has failed.' ), 'get_the_title' ); 
    1885  
    1886         $trans['edit']['plugin']       = array( __( 'Your attempt to edit this plugin file: “%s” has failed.' ), 'use_id' ); 
    1887         $trans['activate']['plugin']   = array( __( 'Your attempt to activate this plugin: “%s” has failed.' ), 'use_id' ); 
    1888         $trans['deactivate']['plugin'] = array( __( 'Your attempt to deactivate this plugin: “%s” has failed.' ), 'use_id' ); 
    1889         $trans['upgrade']['plugin']    = array( __( 'Your attempt to update this plugin: “%s” has failed.' ), 'use_id' ); 
    1890  
    1891         $trans['add']['post']          = array( __( 'Your attempt to add this post has failed.' ), false ); 
    1892         $trans['delete']['post']       = array( __( 'Your attempt to delete this post: “%s” has failed.' ), 'get_the_title' ); 
    1893         $trans['update']['post']       = array( __( 'Your attempt to edit this post: “%s” has failed.' ), 'get_the_title' ); 
    1894  
    1895         $trans['add']['user']          = array( __( 'Your attempt to add this user has failed.' ), false ); 
    1896         $trans['delete']['users']      = array( __( 'Your attempt to delete users has failed.' ), false ); 
    1897         $trans['bulk']['users']        = array( __( 'Your attempt to bulk modify users has failed.' ), false ); 
    1898         $trans['update']['user']       = array( __( 'Your attempt to edit this user: “%s” has failed.' ), 'get_the_author_meta', 'display_name' ); 
    1899         $trans['update']['profile']    = array( __( 'Your attempt to modify the profile for: “%s” has failed.' ), 'get_the_author_meta', 'display_name' ); 
    1900  
    1901         $trans['update']['options']    = array( __( 'Your attempt to edit your settings has failed.' ), false ); 
    1902         $trans['update']['permalink']  = array( __( 'Your attempt to change your permalink structure to: %s has failed.' ), 'use_id' ); 
    1903         $trans['edit']['file']         = array( __( 'Your attempt to edit this file: “%s” has failed.' ), 'use_id' ); 
    1904         $trans['edit']['theme']        = array( __( 'Your attempt to edit this theme file: “%s” has failed.' ), 'use_id' ); 
    1905         $trans['switch']['theme']      = array( __( 'Your attempt to switch to this theme: “%s” has failed.' ), 'use_id' ); 
    1906  
    1907         $trans['log']['out']           = array( sprintf( __( 'You are attempting to log out of %s' ), get_bloginfo( 'sitename' ) ), false ); 
    1908  
    1909         if ( isset( $trans[$verb][$noun] ) ) { 
    1910             if ( !empty( $trans[$verb][$noun][1] ) ) { 
    1911                 $lookup = $trans[$verb][$noun][1]; 
    1912                 if ( isset($trans[$verb][$noun][2]) ) 
    1913                     $lookup_value = $trans[$verb][$noun][2]; 
    1914                 $object = $matches[4]; 
    1915                 if ( 'use_id' != $lookup ) { 
    1916                     if ( isset( $lookup_value ) ) 
    1917                         $object = call_user_func( $lookup, $lookup_value, $object ); 
    1918                     else 
    1919                         $object = call_user_func( $lookup, $object ); 
    1920                 } 
    1921                 return sprintf( $trans[$verb][$noun][0], esc_html($object) ); 
    1922             } else { 
    1923                 return $trans[$verb][$noun][0]; 
    1924             } 
    1925         } 
    1926  
    1927         return apply_filters( 'explain_nonce_' . $verb . '-' . $noun, __( 'Are you sure you want to do this?' ), isset($matches[4]) ? $matches[4] : '' ); 
    1928     } else { 
    1929         return apply_filters( 'explain_nonce_' . $action, __( 'Are you sure you want to do this?' ) ); 
    1930     } 
    1931 } 
    1932  
    1933 /** 
    1934  * Display "Are You Sure" message to confirm the action being taken. 
    1935  * 
    1936  * If the action has the nonce explain message, then it will be displayed along 
    1937  * with the "Are you sure?" message. 
    1938  * 
    1939  * @package WordPress 
    1940  * @subpackage Security 
    1941  * @since 2.0.4 
    1942  * 
    19431861 * @param string $action The nonce action. 
    19441862 */ 
    19451863function wp_nonce_ays( $action ) { 
    19461864    $title = __( 'WordPress Failure Notice' ); 
    1947     $html = esc_html( wp_explain_nonce( $action ) ); 
    1948     if ( 'log-out' == $action ) 
    1949         $html .= "</p><p>" . sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_logout_url() ); 
    1950     elseif ( wp_get_referer() ) 
    1951         $html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>"; 
     1865    if ( 'log-out' == $action ) { 
     1866        $html = sprintf( __( 'You are attempting to log out of %s' ), get_bloginfo( 'name' ) ) . '</p><p>'; 
     1867        $html .= sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_logout_url() ); 
     1868    } else { 
     1869        $html = __( 'Are you sure you want to do this?' ); 
     1870        if ( wp_get_referer() ) 
     1871            $html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>"; 
     1872    } 
    19521873 
    19531874    wp_die( $html, $title, array('response' => 403) ); 
Note: See TracChangeset for help on using the changeset viewer.