he WP REST API. * * @return string[] */ public function getSecurityPlugins() { $result = []; $plugins = get_option('active_plugins'); // @codeCoverageIgnoreStart if (!\defined('PHPUNIT_FILE')) { require_once ABSPATH . '/wp-admin/includes/plugin.php'; } // @codeCoverageIgnoreEnd foreach ($plugins as $pluginFile) { foreach (self::SECURITY_PLUGINS_BLOCKING_REST_API as $slug) { if (\strpos($pluginFile, $slug, 0) === 0) { $result[] = get_plugin_data(\constant('WP_PLUGIN_DIR') . '/' . $pluginFile)['Name']; } } } return $result; } /** * Get the wp-json URL for a defined REST service. * * @param string $instance The plugin class instance, so we can determine the slug from * @param string $namespace The prefix for REST service * @param string $endpoint The path appended to the prefix * @return string Example: https://wordpress.org/wp-json */ public static function getUrl($instance, $namespace = null, $endpoint = '') { $path = ($namespace === null ? \MatthiasWeb\RealMediaLibrary\Vendor\MatthiasWeb\Utils\Service::getNamespace($instance) : $namespace) . '/' . $endpoint; return rest_url($path); } /** * Get the default namespace of this plugin generated from the slug. * * @param mixed $instance The plugin class instance, so we can determine the slug from * @param string $version The version used for this namespace * @return string */ public static function getNamespace($instance, $version = 'v1') { $slug = $instance->getPluginConstant( \MatthiasWeb\RealMediaLibrary\Vendor\MatthiasWeb\Utils\Constants::PLUGIN_CONST_SLUG ); $slug = \preg_replace('/-(lite|pro)$/', '', $slug); return $slug . '/' . $version; } /** * Get the (backend) API URL for the current running environment for another container. * * @param string $serviceName E.g. commerce * @codeCoverageIgnore Ignored due to the fact that it depends on too much server variables */ public static function getExternalContainerUrl($serviceName) { $host = 'devowl.io'; // In our development / review environment we always have prefixed our WordPress container as `wordpress.` subdomain if (\defined('DEVOWL_WP_DEV') && \constant('DEVOWL_WP_DEV')) { $host = \parse_url(site_url(), \PHP_URL_HOST); $host = \substr($host, \strlen('WordPress.')); } // Internal hook return apply_filters( 'DevOwl/Utils/Service/ExternalContainerUrl', \sprintf('https://%s.%s', $serviceName, $host), $serviceName, $host ); } /** * Get a new instance of Service. * * @param PluginReceiver $core * @return Service * @codeCoverageIgnore Instance getter */ public static function instance($core) { return new \MatthiasWeb\RealMediaLibrary\Vendor\MatthiasWeb\Utils\Service($core); } }