/** * The plugin loader. */ function wp_requirements_example_plugin_loader() { if (class_exists('WP_Requirements')) { $my_requirements = array('php' => array('version' => '5.3', 'extensions' => array('mbstring', 'curl')), 'mysql' => array('version' => '5.6'), 'wordpress' => array('version' => '4.6', 'plugins' => array('wpglobus/wpglobus.php' => '1.6.1', 'wpglobus-plus/wpglobus-plus.php' => true), 'theme' => array('my-theme' => '1.5')), 'params' => array('requirements_details_url' => '//google.com', 'version_compare_operator' => '>=', 'not_valid_actions' => array('deactivate', 'admin_notice'), 'show_valid_results' => true)); // If the second parameter is omitted, will look for a `wp-requirements.json` file. $requirements = new WP_Requirements(__FILE__, $my_requirements); if (!$requirements->valid()) { $requirements->process_failure(); return; } } }
/** * Shortcut to construct the object and process the failure actions. * * @param string $the__file__ Pass `__FILE__` from the loader. * @param array $requirements The array of requirements. * * @return bool True if requirements met. */ public static function validate($the__file__, array $requirements = array()) { $_wpr = new WP_Requirements($the__file__, $requirements); $is_valid = $_wpr->valid(); if (!$is_valid) { $_wpr->process_failure(); } return $is_valid; }