Changeset 49329 for trunk/src/wp-includes/load.php
- Timestamp:
- 10/27/2020 04:42:38 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/load.php
r49163 r49329 1596 1596 function wp_is_json_request() { 1597 1597 1598 if ( isset( $_SERVER['HTTP_ACCEPT'] ) && false !== strpos( $_SERVER['HTTP_ACCEPT'], 'application/json') ) {1598 if ( isset( $_SERVER['HTTP_ACCEPT'] ) && wp_is_json_media_type( $_SERVER['HTTP_ACCEPT'] ) ) { 1599 1599 return true; 1600 1600 } 1601 1601 1602 if ( isset( $_SERVER['CONTENT_TYPE'] ) && 'application/json' === $_SERVER['CONTENT_TYPE']) {1602 if ( isset( $_SERVER['CONTENT_TYPE'] ) && wp_is_json_media_type( $_SERVER['CONTENT_TYPE'] ) ) { 1603 1603 return true; 1604 1604 } … … 1634 1634 return $jsonp_enabled; 1635 1635 1636 } 1637 1638 /** 1639 * Checks whether a string is a valid JSON Media Type. 1640 * 1641 * @since 5.6.0 1642 * 1643 * @param string $media_type A Media Type string to check. 1644 * @return bool True if string is a valid JSON Media Type. 1645 */ 1646 function wp_is_json_media_type( $media_type ) { 1647 static $cache = array(); 1648 1649 if ( ! isset( $cache[ $media_type ] ) ) { 1650 $cache[ $media_type ] = (bool) preg_match( '/(^|\s|,)application\/([\w!#\$&-\^\.\+]+\+)?json(\+oembed)?($|\s|;|,)/i', $media_type ); 1651 } 1652 1653 return $cache[ $media_type ]; 1636 1654 } 1637 1655
Note: See TracChangeset
for help on using the changeset viewer.