Changeset 54952
- Timestamp:
- 12/09/2022 12:22:14 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pluggable.php
r54920 r54952 1290 1290 * `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce' 1291 1291 * (in that order). Default false. 1292 * @param bool $ die Optional. Whether to dieearly when the nonce cannot be verified.1292 * @param bool $stop Optional. Whether to stop early when the nonce cannot be verified. 1293 1293 * Default true. 1294 1294 * @return int|false 1 if the nonce is valid and generated between 0-12 hours ago, … … 1296 1296 * False if the nonce is invalid. 1297 1297 */ 1298 function check_ajax_referer( $action = -1, $query_arg = false, $ die= true ) {1298 function check_ajax_referer( $action = -1, $query_arg = false, $stop = true ) { 1299 1299 if ( -1 == $action ) { 1300 1300 _doing_it_wrong( __FUNCTION__, __( 'You should specify an action to be verified by using the first parameter.' ), '4.7.0' ); … … 1324 1324 do_action( 'check_ajax_referer', $action, $result ); 1325 1325 1326 if ( $ die&& false === $result ) {1326 if ( $stop && false === $result ) { 1327 1327 if ( wp_doing_ajax() ) { 1328 1328 wp_die( -1, 403 ); … … 1520 1520 * @param int $status The HTTP response status code to use. 1521 1521 */ 1522 $location = wp_validate_redirect( $location, apply_filters( 'wp_safe_redirect_fallback', admin_url(), $status ) ); 1522 $fallback_url = apply_filters( 'wp_safe_redirect_fallback', admin_url(), $status ); 1523 1524 $location = wp_validate_redirect( $location, $fallback_url ); 1523 1525 1524 1526 return wp_redirect( $location, $status, $x_redirect_by ); … … 1534 1536 * list. 1535 1537 * 1536 * If the host is not allowed, then the redirect is to $ defaultsupplied.1538 * If the host is not allowed, then the redirect is to $fallback_url supplied. 1537 1539 * 1538 1540 * @since 2.8.1 1539 1541 * 1540 * @param string $location The redirect to validate.1541 * @param string $ defaultThe value to return if $location is not allowed.1542 * @return string redirect-sanitized URL.1543 */ 1544 function wp_validate_redirect( $location, $ default= '' ) {1542 * @param string $location The redirect to validate. 1543 * @param string $fallback_url The value to return if $location is not allowed. 1544 * @return string Redirect-sanitized URL. 1545 */ 1546 function wp_validate_redirect( $location, $fallback_url = '' ) { 1545 1547 $location = wp_sanitize_redirect( trim( $location, " \t\n\r\0\x08\x0B" ) ); 1546 1548 // Browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'. … … 1558 1560 // Give up if malformed URL. 1559 1561 if ( false === $lp ) { 1560 return $ default;1562 return $fallback_url; 1561 1563 } 1562 1564 1563 1565 // Allow only 'http' and 'https' schemes. No 'data:', etc. 1564 1566 if ( isset( $lp['scheme'] ) && ! ( 'http' === $lp['scheme'] || 'https' === $lp['scheme'] ) ) { 1565 return $ default;1567 return $fallback_url; 1566 1568 } 1567 1569 … … 1578 1580 // This catches URLs like https:host.com for which parse_url() does not set the host field. 1579 1581 if ( ! isset( $lp['host'] ) && ( isset( $lp['scheme'] ) || isset( $lp['user'] ) || isset( $lp['pass'] ) || isset( $lp['port'] ) ) ) { 1580 return $ default;1582 return $fallback_url; 1581 1583 } 1582 1584 … … 1584 1586 foreach ( array( 'user', 'pass', 'host' ) as $component ) { 1585 1587 if ( isset( $lp[ $component ] ) && strpbrk( $lp[ $component ], ':/?#@' ) ) { 1586 return $ default;1588 return $fallback_url; 1587 1589 } 1588 1590 } … … 1601 1603 1602 1604 if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts, true ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) { 1603 $location = $ default;1605 $location = $fallback_url; 1604 1606 } 1605 1607 … … 2747 2749 * @since 4.2.0 Optional `$args` parameter added. 2748 2750 * 2749 * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,2750 * user email, WP_User object, WP_Post object, or WP_Comment object.2751 * @param int $size Optional. Height and width of the avatar image file in pixels. Default 96.2752 * @param string $default 2753 * (return a 404 instead of a default image), 'retro' (8bit), 'monsterid'2754 * (monster), 'wavatar' (cartoon face), 'indenticon' (the "quilt"),2755 * 'mystery', 'mm', or 'mysteryman' (The Oyster Man), 'blank' (transparent GIF),2756 * or 'gravatar_default' (the Gravatar logo). Default is the value of the2757 * 'avatar_default' option, with a fallback of 'mystery'.2758 * @param string $alt Optional. Alternative text to use in img tag. Default empty.2751 * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash, 2752 * user email, WP_User object, WP_Post object, or WP_Comment object. 2753 * @param int $size Optional. Height and width of the avatar image file in pixels. Default 96. 2754 * @param string $default_value Optional. URL for the default image or a default type. Accepts '404' 2755 * (return a 404 instead of a default image), 'retro' (8bit), 'monsterid' 2756 * (monster), 'wavatar' (cartoon face), 'indenticon' (the "quilt"), 2757 * 'mystery', 'mm', or 'mysteryman' (The Oyster Man), 'blank' (transparent GIF), 2758 * or 'gravatar_default' (the Gravatar logo). Default is the value of the 2759 * 'avatar_default' option, with a fallback of 'mystery'. 2760 * @param string $alt Optional. Alternative text to use in img tag. Default empty. 2759 2761 * @param array $args { 2760 2762 * Optional. Extra arguments to retrieve the avatar. … … 2777 2779 * @return string|false `<img>` tag for the user's avatar. False on failure. 2778 2780 */ 2779 function get_avatar( $id_or_email, $size = 96, $default = '', $alt = '', $args = null ) {2781 function get_avatar( $id_or_email, $size = 96, $default_value = '', $alt = '', $args = null ) { 2780 2782 $defaults = array( 2781 2783 // get_avatar_data() args. … … 2804 2806 2805 2807 $args['size'] = (int) $size; 2806 $args['default'] = $default ;2808 $args['default'] = $default_value; 2807 2809 $args['alt'] = $alt; 2808 2810 … … 2908 2910 * @since 4.2.0 The `$args` parameter was added. 2909 2911 * 2910 * @param string $avatar HTML for the user's avatar.2911 * @param mixed $id_or_email The avatar to retrieve. Accepts a user_id, Gravatar MD5 hash,2912 * user email, WP_User object, WP_Post object, or WP_Comment object.2913 * @param int $size Square avatar width and height in pixels to retrieve.2914 * @param string $default 2915 * 'wavatar', 'indenticon', 'mystery', 'mm', 'mysteryman', 'blank', or 'gravatar_default'.2916 * @param string $alt Alternative text to use in the avatar image tag.2917 * @param array $args Arguments passed to get_avatar_data(), after processing.2912 * @param string $avatar HTML for the user's avatar. 2913 * @param mixed $id_or_email The avatar to retrieve. Accepts a user_id, Gravatar MD5 hash, 2914 * user email, WP_User object, WP_Post object, or WP_Comment object. 2915 * @param int $size Square avatar width and height in pixels to retrieve. 2916 * @param string $default_value URL for the default image or a default type. Accepts '404', 'retro', 'monsterid', 2917 * 'wavatar', 'indenticon', 'mystery', 'mm', 'mysteryman', 'blank', or 'gravatar_default'. 2918 * @param string $alt Alternative text to use in the avatar image tag. 2919 * @param array $args Arguments passed to get_avatar_data(), after processing. 2918 2920 */ 2919 2921 return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args ); -
trunk/tests/phpunit/tests/pluggable/signatures.php
r54872 r54952 174 174 'action' => -1, 175 175 'query_arg' => false, 176 ' die'=> true,176 'stop' => true, 177 177 ), 178 178 'wp_redirect' => array( … … 190 190 'wp_validate_redirect' => array( 191 191 'location', 192 ' default' => '',192 'fallback_url' => '', 193 193 ), 194 194 'wp_notify_postauthor' => array( … … 232 232 'get_avatar' => array( 233 233 'id_or_email', 234 'size' => 96,235 'default ' => '',236 'alt' => '',237 'args' => null,234 'size' => 96, 235 'default_value' => '', 236 'alt' => '', 237 'args' => null, 238 238 ), 239 239 'wp_text_diff' => array(
Note: See TracChangeset
for help on using the changeset viewer.