/**
* Load module data from module file. Headers differ from WordPress
* plugin headers to avoid them being identified as standalone
* plugins on the WordPress plugins page.
*/
public static function get_module($module)
{
$headers = array('name' => 'Module Name', 'description' => 'Module Description', 'jumpstart_desc' => 'Jumpstart Description', 'sort' => 'Sort Order', 'recommendation_order' => 'Recommendation Order', 'introduced' => 'First Introduced', 'changed' => 'Major Changes In', 'deactivate' => 'Deactivate', 'free' => 'Free', 'requires_connection' => 'Requires Connection', 'auto_activate' => 'Auto Activate', 'module_tags' => 'Module Tags', 'feature' => 'Feature', 'additional_search_queries' => 'Additional Search Queries');
$file = Jetpack::get_module_path(Jetpack::get_module_slug($module));
$mod = Jetpack::get_file_data($file, $headers);
if (empty($mod['name'])) {
return false;
}
$mod['sort'] = empty($mod['sort']) ? 10 : (int) $mod['sort'];
$mod['recommendation_order'] = empty($mod['recommendation_order']) ? 20 : (int) $mod['recommendation_order'];
$mod['deactivate'] = empty($mod['deactivate']);
$mod['free'] = empty($mod['free']);
$mod['requires_connection'] = !empty($mod['requires_connection']) && 'No' == $mod['requires_connection'] ? false : true;
if (empty($mod['auto_activate']) || !in_array(strtolower($mod['auto_activate']), array('yes', 'no', 'public'))) {
$mod['auto_activate'] = 'No';
} else {
$mod['auto_activate'] = (string) $mod['auto_activate'];
}
if ($mod['module_tags']) {
$mod['module_tags'] = explode(',', $mod['module_tags']);
$mod['module_tags'] = array_map('trim', $mod['module_tags']);
$mod['module_tags'] = array_map(array(__CLASS__, 'translate_module_tag'), $mod['module_tags']);
} else {
$mod['module_tags'] = array(self::translate_module_tag('Other'));
}
if ($mod['feature']) {
$mod['feature'] = explode(',', $mod['feature']);
$mod['feature'] = array_map('trim', $mod['feature']);
} else {
$mod['feature'] = array(self::translate_module_tag('Other'));
}
/**
* Filters the feature array on a module.
*
* This filter allows you to control where each module is filtered: Recommended,
* Jumpstart, and the default "Other" listing.
*
* @since 3.5.0
*
* @param array $mod['feature'] The areas to feature this module:
* 'Jumpstart' adds to the "Jumpstart" option to activate many modules at once.
* 'Recommended' shows on the main Jetpack admin screen.
* 'Other' should be the default if no other value is in the array.
* @param string $module The slug of the module, e.g. sharedaddy.
* @param array $mod All the currently assembled module data.
*/
$mod['feature'] = apply_filters('jetpack_module_feature', $mod['feature'], $module, $mod);
/**
* Filter the returned data about a module.
*
* This filter allows overriding any info about Jetpack modules. It is dangerous,
* so please be careful.
*
* @since 3.6.0
*
* @param array $mod The details of the requested module.
* @param string $module The slug of the module, e.g. sharedaddy
* @param string $file The path to the module source file.
*/
return apply_filters('jetpack_get_module', $mod, $module, $file);
}