| @@ -51,8 +51,29 @@ | ||
| 51 | 51 | return (static::$platform === 'joomla'); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | + * Tells whether the current execution is made by the WordPress REST API framework. | |
| 56 | + * Useful to tell, for example, if the Gutenberg preview is calling the REST endpoint. | |
| 57 | + * | |
| 58 | + * @return bool | |
| 59 | + * | |
| 60 | + * @since 1.16.7 (J) - 1.6.7 (WP) | |
| 61 | + */ | |
| 62 | + public static function isWordPressRestApi() | |
| 63 | + { | |
| 64 | + $requestUri = JFactory::getApplication()->input->server->getString('REQUEST_URI', ''); | |
| 65 | + | |
| 66 | + if (static::isWordPress()) { | |
| 67 | + if (strpos($requestUri, trailingslashit(rest_get_url_prefix())) !== false || JUri::getInstance($requestUri)->hasVar('rest_route')) { | |
| 68 | + return true; | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + return false; | |
| 73 | + } | |
| 74 | + | |
| 75 | + /** | |
| 55 | 76 | * Detects the name of the platform on which we are running the software. |
| 56 | 77 | * |
| 57 | 78 | * @return void |
| 58 | 79 | */ |