Changeset 21133
- Timestamp:
- 06/26/2012 06:10:07 AM (12 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/deprecated.php
r21050 r21133 3157 3157 clean_post_cache( $id ); 3158 3158 } 3159 3160 /** 3161 * Retrieve nonce action "Are you sure" message. 3162 * 3163 * @since 2.0.4 3164 * @deprecated 3.5.0 3165 * @deprecated Use wp_nonce_ays() 3166 * @see wp_nonce_ays() 3167 * 3168 * @param string $action Nonce action. 3169 * @return string Are you sure message. 3170 */ 3171 function wp_explain_nonce( $action ) { 3172 _deprecated_function( __FUNCTION__, '3.4', 'wp_nonce_ays()' ); 3173 return __( 'Are you sure you want to do this?' ); 3174 } -
trunk/wp-includes/functions.php
r21113 r21133 1834 1834 1835 1835 /** 1836 * Retrieve nonce action "Are you sure" message. 1837 * 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). 1836 * Display "Are You Sure" message to confirm the action being taken. 1837 * 1838 * If the action has the nonce explain message, then it will be displayed along 1839 * with the "Are you sure?" message. 1850 1840 * 1851 1841 * @package WordPress … … 1853 1843 * @since 2.0.4 1854 1844 * 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 else1919 $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 along1937 * with the "Are you sure?" message.1938 *1939 * @package WordPress1940 * @subpackage Security1941 * @since 2.0.41942 *1943 1845 * @param string $action The nonce action. 1944 1846 */ 1945 1847 function wp_nonce_ays( $action ) { 1946 1848 $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>"; 1849 if ( 'log-out' == $action ) { 1850 $html = sprintf( __( 'You are attempting to log out of %s' ), get_bloginfo( 'name' ) ) . '</p><p>'; 1851 $html .= sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_logout_url() ); 1852 } else { 1853 $html = __( 'Are you sure you want to do this?' ); 1854 if ( wp_get_referer() ) 1855 $html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>"; 1856 } 1952 1857 1953 1858 wp_die( $html, $title, array('response' => 403) );
Note: See TracChangeset
for help on using the changeset viewer.