本文整理汇总了PHP中Jetpack::get_module方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::get_module方法的具体用法?PHP Jetpack::get_module怎么用?PHP Jetpack::get_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::get_module方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: format_module
protected static function format_module($module_slug)
{
$module_data = Jetpack::get_module($module_slug);
$module = array();
$module['id'] = $module_slug;
$module['active'] = Jetpack::is_module_active($module_slug);
$module['name'] = $module_data['name'];
$module['short_description'] = $module_data['description'];
$module['sort'] = $module_data['sort'];
$module['introduced'] = $module_data['introduced'];
$module['changed'] = $module_data['changed'];
$module['free'] = $module_data['free'];
$module['module_tags'] = $module_data['module_tags'];
// Fetch the HTML formatted long description
ob_start();
if (Jetpack::is_active() && has_action('jetpack_module_more_info_connected_' . $module_slug)) {
/** This action is documented in class.jetpack-modules-list-table.php */
do_action('jetpack_module_more_info_connected_' . $module_slug);
} else {
/** This action is documented in class.jetpack-modules-list-table.php */
do_action('jetpack_module_more_info_' . $module_slug);
}
$module['description'] = ob_get_clean();
return $module;
}
示例2: array
function get_modules()
{
include_once JETPACK__PLUGIN_DIR . 'modules/module-info.php';
$available_modules = $this->jetpack->get_available_modules();
$active_modules = $this->jetpack->get_active_modules();
$modules = array();
$jetpack_active = Jetpack::is_active() || Jetpack::is_development_mode();
foreach ($available_modules as $module) {
if ($module_array = $this->jetpack->get_module($module)) {
$short_desc = apply_filters('jetpack_short_module_description', $module_array['description'], $module);
// Fix: correct multibyte strings truncate with checking for mbstring extension
$short_desc_trunc = function_exists('mb_strlen') ? mb_strlen($short_desc) > 143 ? mb_substr($short_desc, 0, 140) . '...' : $short_desc : (strlen($short_desc) > 143 ? substr($short_desc, 0, 140) . '...' : $short_desc);
$module_array['module'] = $module;
$module_array['activated'] = $jetpack_active ? in_array($module, $active_modules) : false;
$module_array['deactivate_nonce'] = wp_create_nonce('jetpack_deactivate-' . $module);
$module_array['activate_nonce'] = wp_create_nonce('jetpack_activate-' . $module);
$module_array['available'] = self::is_module_available($module_array);
$module_array['short_description'] = $short_desc_trunc;
$module_array['configure_url'] = Jetpack::module_configuration_url($module);
ob_start();
do_action('jetpack_learn_more_button_' . $module);
$module_array['learn_more_button'] = ob_get_clean();
ob_start();
if (Jetpack::is_active() && has_action('jetpack_module_more_info_connected_' . $module)) {
do_action('jetpack_module_more_info_connected_' . $module);
} else {
do_action('jetpack_module_more_info_' . $module);
}
$module_array['long_description'] = ob_get_clean();
$module_array['configurable'] = false;
if (current_user_can('manage_options') && apply_filters('jetpack_module_configurable_' . $module, false)) {
$module_array['configurable'] = sprintf('<a href="%1$s">%2$s</a>', esc_url(Jetpack::module_configuration_url($module)), __('Configure', 'jetpack'));
}
$modules[$module] = $module_array;
}
}
uasort($modules, array($this->jetpack, 'sort_modules'));
if (!Jetpack::is_active()) {
uasort($modules, array(__CLASS__, 'sort_requires_connection_last'));
}
return $modules;
}
示例3: admin_screen_list_modules
function admin_screen_list_modules()
{
require_once JETPACK__PLUGIN_DIR . 'modules/module-info.php';
$jetpack_connected = true;
if (!Jetpack::is_active()) {
$jetpack_connected = false;
}
?>
<div class="module-container">
<?php
$avail_raw = Jetpack::get_available_modules();
$available = array();
$active = Jetpack::get_active_modules();
$counter = 0;
foreach ((array) $avail_raw as $module) {
if ($plugin = Jetpack::get_module($module)) {
$plugin['module'] = $module;
$available[] = $plugin;
}
}
unset($avail_raw);
usort($available, array('Jetpack', 'sort_modules'));
$jetpack_version = Jetpack_Options::get_option('version');
if ($jetpack_version) {
list($jetpack_version, $jetpack_version_time) = explode(':', $jetpack_version);
} else {
$jetpack_version = 0;
$jetpack_version_time = 0;
}
$jetpack_old_version = Jetpack_Options::get_option('old_version');
if ($jetpack_old_version) {
list($jetpack_old_version) = explode(':', $jetpack_old_version);
} else {
$jetpack_old_version = 0;
}
$now = time();
foreach ((array) $available as $module_data) {
$module = $module_data['module'];
$activated = in_array($module, $active);
if ($activated) {
$css = 'active';
$toggle = __('Deactivate', 'jetpack');
$toggle_url = wp_nonce_url(Jetpack::admin_url(array('page' => 'jetpack', 'action' => 'deactivate', 'module' => $module)), "jetpack_deactivate-{$module}");
} else {
$css = 'inactive';
$toggle = __('Activate', 'jetpack');
$toggle_url = wp_nonce_url(Jetpack::admin_url(array('page' => 'jetpack', 'action' => 'activate', 'module' => $module)), "jetpack_activate-{$module}");
}
if ($counter % 4 == 0) {
$classes = $css . ' jetpack-newline';
$counter = 0;
} else {
$classes = $css;
}
$free_text = esc_html($module_data['free'] ? __('Free', 'jetpack') : __('Purchase', 'jetpack'));
$free_text = apply_filters('jetpack_module_free_text_' . $module, $free_text);
$badge_text = $free_text;
if (!$jetpack_connected && !Jetpack::is_development_mode()) {
$classes = 'x disabled';
} elseif ($jetpack_version_time + 604800 > $now) {
// 1 week
if (version_compare($module_data['introduced'], $jetpack_old_version, '>')) {
$badge_text = esc_html__('New', 'jetpack');
$classes .= ' jetpack-new-module';
} elseif (isset($module_data['changed']) && version_compare($module_data['changed'], $jetpack_old_version, '>')) {
$badge_text = esc_html__('Updated', 'jetpack');
$classes .= ' jetpack-updated-module';
} else {
$badge_text = $free_text;
}
}
?>
<div class="jetpack-module jetpack-<?php
echo $classes;
?>
" id="<?php
echo $module;
?>
">
<h3><?php
echo esc_html($module_data['name']);
?>
</h3>
<div class="jetpack-module-description">
<div class="module-image">
<p><span class="module-image-badge"><?php
echo $badge_text;
?>
</span><span class="module-image-free" style="display: none"><?php
echo $free_text;
?>
</span></p>
</div>
<p><?php
echo apply_filters('jetpack_short_module_description', $module_data['description'], $module);
?>
</p>
</div>
//.........这里部分代码省略.........
示例4: module
/**
* Manage Jetpack Modules
*
* ## OPTIONS
*
* list : View all available modules, and their status.
* activate all : Activate all modules
* deactivate all: Deactivate all modules
*
* activate <module_slug> : Activate a module.
* deactivate <module_slug> : Deactivate a module.
* toggle <module_slug> : Toggle a module on or off.
*
* ## EXAMPLES
*
* wp jetpack module list
* wp jetpack module activate stats
* wp jetpack module deactivate stats
* wp jetpack module toggle stats
*
* wp jetpack module activate all
* wp jetpack module deactivate all
*
* @synopsis <list|activate|deactivate|toggle> [<module_name>]
*/
public function module($args, $assoc_args)
{
$action = isset($args[0]) ? $args[0] : 'list';
if (!in_array($action, array('list', 'activate', 'deactivate', 'toggle'))) {
WP_CLI::error(sprintf(__('%s is not a valid command.', 'jetpack'), $action));
}
if (in_array($action, array('activate', 'deactivate', 'toggle'))) {
if (isset($args[1])) {
$module_slug = $args[1];
if ('all' !== $module_slug && !Jetpack::is_module($module_slug)) {
WP_CLI::error(sprintf(__('%s is not a valid module.', 'jetpack'), $module_slug));
}
if ('toggle' == $action) {
$action = Jetpack::is_module_active($module_slug) ? 'deactivate' : 'activate';
}
// Bulk actions
if ('all' == $args[1]) {
$action = 'deactivate' == $action ? 'deactivate_all' : 'activate_all';
}
// VaultPress needs to be handled elsewhere.
if (in_array($action, array('activate', 'deactivate', 'toggle')) && 'vaultpress' == $args[1]) {
WP_CLI::error(sprintf(_x('Please visit %s to configure your VaultPress subscription.', '%s is a website', 'jetpack'), esc_url('https://vaultpress.com/jetpack/')));
}
} else {
WP_CLI::line(__('Please specify a valid module.', 'jetpack'));
$action = 'list';
}
}
switch ($action) {
case 'list':
WP_CLI::line(__('Available Modules:', 'jetpack'));
$modules = Jetpack::get_available_modules();
sort($modules);
foreach ($modules as $module_slug) {
if ('vaultpress' == $module_slug) {
continue;
}
$active = Jetpack::is_module_active($module_slug) ? __('Active', 'jetpack') : __('Inactive', 'jetpack');
WP_CLI::line("\t" . str_pad($module_slug, 24) . $active);
}
break;
case 'activate':
$module = Jetpack::get_module($module_slug);
Jetpack::log('activate', $module_slug);
Jetpack::activate_module($module_slug, false, false);
WP_CLI::success(sprintf(__('%s has been activated.', 'jetpack'), $module['name']));
break;
case 'activate_all':
$modules = Jetpack::get_available_modules();
Jetpack::update_active_modules($modules);
WP_CLI::success(__('All modules activated!', 'jetpack'));
break;
case 'deactivate':
$module = Jetpack::get_module($module_slug);
Jetpack::log('deactivate', $module_slug);
Jetpack::deactivate_module($module_slug);
WP_CLI::success(sprintf(__('%s has been deactivated.', 'jetpack'), $module['name']));
break;
case 'deactivate_all':
Jetpack::delete_active_modules();
WP_CLI::success(__('All modules deactivated!', 'jetpack'));
break;
case 'toggle':
// Will never happen, should have been handled above and changed to activate or deactivate.
break;
}
}
示例5: module
/**
* Manage Jetpack Modules
*
* ## OPTIONS
*
* list: View all available modules, and their status.
*
* activate <module_slug>: Activate a module.
*
* deactivate <module_slug>: Deactivate a module.
*
* toggle <module_slug>: Toggle a module on or off.
*
* ## EXAMPLES
*
* wp jetpack module list
* wp jetpack module activate stats
* wp jetpack module deactivate stats
* wp jetpack module toggle stats
*
* @synopsis [list|activate|deactivate|toggle [<module_name>]]
*/
public function module($args, $assoc_args)
{
$action = isset($args[0]) ? $args[0] : 'list';
if (!in_array($action, array('list', 'activate', 'deactivate', 'toggle'))) {
WP_CLI::error(sprintf(__('%s is not a valid command.', 'jetpack'), $action));
}
if (in_array($action, array('activate', 'deactivate', 'toggle'))) {
if (isset($args[1])) {
$module_slug = $args[1];
if (!Jetpack::is_module($module_slug)) {
WP_CLI::error(sprintf(__('%s is not a valid module.', 'jetpack'), $module_slug));
}
if ('toggle' == $action) {
$action = Jetpack::is_module_active($module_slug) ? 'deactivate' : 'activate';
}
} else {
WP_CLI::line(__('Please specify a valid module.', 'jetpack'));
$action = 'list';
}
}
switch ($action) {
case 'list':
WP_CLI::line(__('Available Modules:', 'jetpack'));
$modules = Jetpack::get_available_modules();
sort($modules);
foreach ($modules as $module_slug) {
$active = Jetpack::is_module_active($module_slug) ? __('Active', 'jetpack') : __('Inactive', 'jetpack');
WP_CLI::line("\t" . str_pad($module_slug, 24) . $active);
}
break;
case 'activate':
$module = Jetpack::get_module($module_slug);
Jetpack::log('activate', $module_slug);
Jetpack::activate_module($module_slug, false);
WP_CLI::success(sprintf(__('%s has been activated.', 'jetpack'), $module['name']));
break;
case 'deactivate':
$module = Jetpack::get_module($module_slug);
Jetpack::log('deactivate', $module_slug);
Jetpack::deactivate_module($module_slug);
WP_CLI::success(sprintf(__('%s has been deactivated.', 'jetpack'), $module['name']));
break;
case 'toggle':
// Will never happen, should have been handled above and changed to activate or deactivate.
break;
}
}
示例6: display_activate_module_link
/**
* Display link to activate the module to see the settings screen.
* @param string $module_id
* @return null
*/
public static function display_activate_module_link($module_id)
{
$info = Jetpack::get_module($module_id);
$extra = '';
$activate_url = wp_nonce_url(Jetpack::admin_url(array('page' => 'jetpack', 'action' => 'activate', 'module' => $module_id)), "jetpack_activate-{$module_id}");
?>
<div class="wrap configure-module">
<div id="jp-settings-screen">
<?php
if ($module_id == 'json-api') {
$info['name'] = esc_html__('Activate Site Management and JSON API', 'jetpack');
$activate_url = Jetpack::init()->opt_in_jetpack_manage_url();
$info['description'] = sprintf(__('Manage your multiple Jetpack sites from our centralized dashboard at wordpress.com/sites. <a href="%s" target="_blank">Learn more</a>.', 'jetpack'), 'http://jetpack.com/support/site-management');
// $extra = __( 'To use Site Management, you need to first activate JSON API to allow remote management of your site. ', 'jetpack' );
}
?>
<h3><?php
echo esc_html($info['name']);
?>
</h3>
<div class="narrow">
<p><?php
echo $info['description'];
?>
</p>
<?php
if ($extra) {
?>
<p><?php
echo esc_html($extra);
?>
</p>
<?php
}
?>
<p>
<?php
if (wp_get_referer()) {
printf(__('<a class="button-primary" href="%s">Activate Now</a> or <a href="%s" >return to previous page</a>.', 'jetpack'), $activate_url, wp_get_referer());
} else {
printf(__('<a class="button-primary" href="%s">Activate Now</a>', 'jetpack'), $activate_url);
}
?>
</p>
</div>
</div>
</div>
<?php
}
示例7: render_network_admin_settings_page
public function render_network_admin_settings_page()
{
$this->network_admin_page_header();
$options = wp_parse_args(get_site_option($this->settings_name), $this->setting_defaults);
$modules = array();
$module_slugs = Jetpack::get_available_modules();
foreach ($module_slugs as $slug) {
$module = Jetpack::get_module($slug);
$module['module'] = $slug;
$modules[] = $module;
}
usort($modules, array('Jetpack', 'sort_modules'));
if (!isset($options['modules'])) {
$options['modules'] = $modules;
}
$data = array('modules' => $modules, 'options' => $options, 'jetpack_protect_whitelist' => jetpack_protect_format_whitelist());
Jetpack::init()->load_view('admin/network-settings.php', $data);
$this->network_admin_page_footer();
}
示例8: callback_jetpack_log_entry
/**
* Track Jetpack log entries
* Includes:
* - Activation/Deactivation of modules
* - Registration/Disconnection of blogs
* - Authorization/unlinking of users
*
* @param array $entry
*/
public function callback_jetpack_log_entry(array $entry)
{
if (isset($entry['code'])) {
$method = $entry['code'];
} else {
return;
}
if (isset($entry['data'])) {
$data = $entry['data'];
} else {
$data = null;
}
$context = null;
$action = null;
$meta = array();
if (in_array($method, array('activate', 'deactivate')) && !is_null($data)) {
$module_slug = $data;
$module = \Jetpack::get_module($module_slug);
$module_name = $module['name'];
$context = 'modules';
$action = $method . 'd';
$meta = compact('module_slug');
$message = sprintf(__('%1$s module %2$s', 'stream'), $module_name, 'activated' === $action ? esc_html__('activated', 'stream') : esc_html__('deactivated', 'stream'));
} elseif (in_array($method, array('authorize', 'unlink')) && !is_null($data)) {
$user_id = intval($data);
if (empty($user_id)) {
$user_id = get_current_user_id();
}
$user = new \WP_User($user_id);
$user_email = $user->user_email;
$user_login = $user->user_login;
$context = 'users';
$action = $method;
$meta = compact('user_id', 'user_email', 'user_login');
$message = sprintf(__('%1$s\'s account %2$s %3$s Jetpack', 'stream'), $user->display_name, 'unlink' === $action ? esc_html__('unlinked', 'stream') : esc_html__('linked', 'stream'), 'unlink' === $action ? esc_html__('from', 'stream') : esc_html__('to', 'stream'));
} elseif (in_array($method, array('register', 'disconnect', 'subsiteregister', 'subsitedisconnect'))) {
$context = 'blogs';
$action = str_replace('subsite', '', $method);
$is_multisite = 0 === strpos($method, 'subsite');
$blog_id = $is_multisite ? isset($_GET['site_id']) ? intval(wp_unslash($_GET['site_id'])) : null : get_current_blog_id();
// phpcs: input var okay
if (empty($blog_id)) {
return;
}
if (!$is_multisite) {
$message = sprintf(__('Site %s Jetpack', 'stream'), 'register' === $action ? esc_html__('connected to', 'stream') : esc_html__('disconnected from', 'stream'));
} else {
$blog_details = get_blog_details(array('blog_id' => $blog_id));
$blog_name = $blog_details->blogname;
$meta += compact('blog_id', 'blog_name');
$message = sprintf(__('"%1$s" blog %2$s Jetpack', 'stream'), $blog_name, 'register' === $action ? esc_html__('connected to', 'stream') : esc_html__('disconnected from', 'stream'));
}
}
if (empty($message)) {
return;
}
$this->log($message, $meta, null, $context, $action);
}
示例9: show_notices_update_settings
/**
* Shows a notice message to users after they save Module config settings
* @param string $module_id
* @return null
*/
function show_notices_update_settings($module_id)
{
$state = Jetpack::state('message');
switch ($state) {
case 'module_activated':
if ($module = Jetpack::get_module(Jetpack::state('module'))) {
$message = sprintf(__('<strong>%s Activated!</strong> You can change the setting of it here.', 'jetpack'), $module['name']);
}
break;
case 'module_configured':
$message = __('<strong>Module settings were saved.</strong> ', 'jetpack');
break;
case 'no_message':
break;
}
if (isset($message)) {
?>
<div id="message" class="jetpack-message">
<div class="squeezer">
<h2><?php
echo wp_kses($message, array('strong' => array(), 'a' => array('href' => true), 'br' => true));
?>
</h2>
<?php
/**
* Fires within the displayed message when a feature configuation is updated.
*
* This is a dynamic hook with `$module_id` being the slug of the module being updated.
*
* @since 3.4.0
*/
do_action('jetpack_notices_update_settings_' . $module_id);
?>
</div>
</div>
<?php
}
add_action('jetpack_notices', array(Jetpack::init(), 'admin_notices'));
}
示例10: jumpstart_activate
/**
* Activates a series of valid Jetpack modules and initializes some options.
*
* @since 4.3.0
*
* @param WP_REST_Request $data {
* Array of parameters received by request.
* }
*
* @return bool|WP_Error True if Jumpstart succeeded. Otherwise, a WP_Error instance with the corresponding error.
*/
public static function jumpstart_activate($data)
{
$modules = Jetpack::get_available_modules();
$activate_modules = array();
foreach ($modules as $module) {
$module_info = Jetpack::get_module($module);
if (isset($module_info['feature']) && is_array($module_info['feature']) && in_array('Jumpstart', $module_info['feature'])) {
$activate_modules[] = $module;
}
}
// Collect success/error messages like modules that are properly activated.
$result = array('activated_modules' => array(), 'failed_modules' => array());
// Update the jumpstart option
if ('new_connection' === Jetpack_Options::get_option('jumpstart')) {
$result['jumpstart_activated'] = Jetpack_Options::update_option('jumpstart', 'jumpstart_activated');
}
// Check for possible conflicting plugins
$module_slugs_filtered = Jetpack::init()->filter_default_modules($activate_modules);
foreach ($module_slugs_filtered as $module_slug) {
Jetpack::log('activate', $module_slug);
if (Jetpack::activate_module($module_slug, false, false)) {
$result['activated_modules'][] = $module_slug;
} else {
$result['failed_modules'][] = $module_slug;
}
}
// Set the default sharing buttons and set to display on posts if none have been set.
$sharing_services = get_option('sharing-services');
$sharing_options = get_option('sharing-options');
if (empty($sharing_services['visible'])) {
// Default buttons to set
$visible = array('twitter', 'facebook', 'google-plus-1');
$hidden = array();
// Set some sharing settings
$sharing = new Sharing_Service();
$sharing_options['global'] = array('button_style' => 'icon', 'sharing_label' => $sharing->default_sharing_label, 'open_links' => 'same', 'show' => array('post'), 'custom' => isset($sharing_options['global']['custom']) ? $sharing_options['global']['custom'] : array());
$result['sharing_options'] = update_option('sharing-options', $sharing_options);
$result['sharing_services'] = update_option('sharing-services', array('visible' => $visible, 'hidden' => $hidden));
}
// If all Jumpstart modules were activated
if (empty($result['failed_modules'])) {
return rest_ensure_response(array('code' => 'success', 'message' => esc_html__('Jumpstart done.', 'jetpack'), 'data' => $result));
}
return new WP_Error('jumpstart_failed', esc_html(sprintf(_n('Jumpstart failed activating this module: %s.', 'Jumpstart failed activating these modules: %s.', count($result['failed_modules']), 'jetpack'), join(', ', $result['failed_modules']))), array('status' => 400));
}
示例11: array
function get_modules()
{
include_once JETPACK__PLUGIN_DIR . 'modules/module-info.php';
$available_modules = $this->jetpack->get_available_modules();
$active_modules = $this->jetpack->get_active_modules();
$modules = array();
$jetpack_active = Jetpack::is_active() || Jetpack::is_development_mode();
foreach ($available_modules as $module) {
if ($module_array = $this->jetpack->get_module($module)) {
$short_desc = apply_filters('jetpack_short_module_description', $module_array['description'], $module);
// Fix: correct multibyte strings truncate with checking for mbstring extension
$short_desc_trunc = function_exists('mb_strlen') ? mb_strlen($short_desc) > 143 ? mb_substr($short_desc, 0, 140) . '...' : $short_desc : (strlen($short_desc) > 143 ? substr($short_desc, 0, 140) . '...' : $short_desc);
$module_array['module'] = $module;
$module_array['activated'] = $jetpack_active ? in_array($module, $active_modules) : false;
$module_array['deactivate_nonce'] = wp_create_nonce('jetpack_deactivate-' . $module);
$module_array['activate_nonce'] = wp_create_nonce('jetpack_activate-' . $module);
$module_array['available'] = self::is_module_available($module_array);
$module_array['short_description'] = $short_desc_trunc;
$module_array['configure_url'] = Jetpack::module_configuration_url($module);
ob_start();
do_action('jetpack_learn_more_button_' . $module);
$module_array['learn_more_button'] = ob_get_clean();
ob_start();
if (Jetpack::is_active() && has_action('jetpack_module_more_info_connected_' . $module)) {
do_action('jetpack_module_more_info_connected_' . $module);
} else {
do_action('jetpack_module_more_info_' . $module);
}
/**
* Filter the long description of a module.
*
* @since 3.5.0
*
* @param string ob_get_clean() The module long description.
* @param string $module The module name.
*/
$module_array['long_description'] = apply_filters('jetpack_long_module_description', ob_get_clean(), $module);
ob_start();
/**
* Filter the search terms for a module
*
* Search terms are be typically added to a module in module-info.php.
*
* Use syntax:
* function jetpack_$module_search_terms( $terms ) {
* $terms = _x( 'term 1, term 2', 'search terms', 'jetpack' );
* return $terms;
* }
* add_filter( 'jetpack_search_terms_$module', 'jetpack_$module_search_terms' );
*
* @since 3.5.0
* @param string The search terms (comma separated)
*/
echo apply_filters('jetpack_search_terms_' . $module, '');
$module_array['search_terms'] = ob_get_clean();
$module_array['configurable'] = false;
if (current_user_can('manage_options') && apply_filters('jetpack_module_configurable_' . $module, false)) {
$module_array['configurable'] = sprintf('<a href="%1$s">%2$s</a>', esc_url(Jetpack::module_configuration_url($module)), __('Configure', 'jetpack'));
}
$modules[$module] = $module_array;
}
}
uasort($modules, array($this->jetpack, 'sort_modules'));
if (!Jetpack::is_active()) {
uasort($modules, array(__CLASS__, 'sort_requires_connection_last'));
}
return $modules;
}
示例12: render_network_admin_settings_page
public function render_network_admin_settings_page()
{
$this->network_admin_page_header();
$options = wp_parse_args(get_site_option($this->settings_name), $this->setting_defaults);
$modules = array();
$module_slugs = Jetpack::get_available_modules();
foreach ($module_slugs as $slug) {
$module = Jetpack::get_module($slug);
$module['module'] = $slug;
$modules[] = $module;
}
usort($modules, array('Jetpack', 'sort_modules'));
if (!isset($options['modules'])) {
$options['modules'] = $modules;
}
require 'views/admin/network-settings.php';
$this->network_admin_page_footer();
}
示例13: get_module
/**
* Get information about a specific and valid Jetpack module.
*
* @since 4.3.0
*
* @param WP_REST_Request $data {
* Array of parameters received by request.
*
* @type string $slug Module slug.
* }
*
* @return mixed|void|WP_Error
*/
public function get_module($data)
{
if (Jetpack::is_module($data['slug'])) {
$module = Jetpack::get_module($data['slug']);
$module['options'] = Jetpack_Core_Json_Api_Endpoints::prepare_options_for_response($data['slug']);
if (isset($module['requires_connection']) && $module['requires_connection'] && Jetpack::is_development_mode()) {
$module['activated'] = false;
}
$i18n = jetpack_get_module_i18n($data['slug']);
if (isset($module['name'])) {
$module['name'] = $i18n['name'];
}
if (isset($module['description'])) {
$module['description'] = $i18n['description'];
$module['short_description'] = $i18n['description'];
}
return Jetpack_Core_Json_Api_Endpoints::prepare_modules_for_response($module);
}
return new WP_Error('not_found', esc_html__('The requested Jetpack module was not found.', 'jetpack'), array('status' => 404));
}
示例14: get_available_modules
/**
* Return Jetpack available modules
* @since 0.1
* @return array
*/
private function get_available_modules()
{
if (null === self::$modules) {
if (class_exists('Jetpack')) {
//remove_filter( 'jetpack_get_available_modules', array($this, 'blacklist') ); // remove filter useless here because of bug in Jetpack
$modules = array();
foreach (Jetpack::get_available_modules() as $slug) {
$module = Jetpack::get_module($slug);
if ($module) {
$modules[$slug] = $module;
}
}
self::$modules = $modules;
//add_filter( 'jetpack_get_available_modules', array($this, 'blacklist') );
} else {
self::$modules = self::$known_modules;
}
}
return self::$modules;
}
示例15: admin_screen_list_modules
function admin_screen_list_modules()
{
require_once dirname(__FILE__) . '/modules/module-info.php';
$jetpack_connected = true;
if (!Jetpack::is_active()) {
$jetpack_connected = false;
}
?>
<div class="module-container">
<?php
$avail_raw = Jetpack::get_available_modules();
$available = array();
$active = Jetpack::get_active_modules();
$counter = 0;
foreach ((array) $avail_raw as $module) {
if ($plugin = Jetpack::get_module($module)) {
$plugin['module'] = $module;
$available[] = $plugin;
}
}
unset($avail_raw);
usort($available, array('Jetpack', 'sort_modules'));
foreach ((array) $available as $module_data) {
$module = $module_data['module'];
if (in_array($module, $active)) {
$css = 'active';
$toggle = __('Deactivate', 'jetpack');
$toggle_url = wp_nonce_url(Jetpack::admin_url(array('action' => 'deactivate', 'module' => $module)), "jetpack_deactivate-{$module}");
} else {
$css = 'inactive';
$toggle = __('Activate', 'jetpack');
$toggle_url = wp_nonce_url(Jetpack::admin_url(array('action' => 'activate', 'module' => $module)), "jetpack_activate-{$module}");
}
$file = Jetpack::get_module_path($module);
$png = str_replace('.php', '.png', $file);
if (is_readable(dirname(__FILE__) . '/_inc/images/icons/' . basename($png))) {
$module_img = plugins_url(basename(dirname(__FILE__)) . '/_inc/images/icons/' . basename($png));
} else {
$module_img = plugins_url(basename(dirname(__FILE__)) . '/_inc/images/module-blank.png');
}
if ($counter % 4 == 0) {
$classes = $css . ' jetpack-newline';
$counter = 0;
} else {
$classes = $css;
}
if (!$jetpack_connected) {
$classes = 'x disabled';
}
?>
<div class="jetpack-module jetpack-<?php
echo $classes;
?>
" id="<?php
echo $module;
?>
">
<h3><?php
echo $module_data['name'];
?>
</h3>
<div class="jetpack-module-description">
<div class="module-image">
<img src="<?php
echo esc_url($module_img);
?>
" align="right" width="71" height="45" />
<p><?php
_e('Free', 'jetpack');
?>
</p>
</div>
<p><?php
echo apply_filters('jetpack_short_module_description_' . $module, $module_data['description']);
?>
</p>
</div>
<div class="jetpack-module-actions">
<?php
if ($jetpack_connected) {
$activated = in_array($module, $active);
?>
<?php
if (!$activated) {
?>
<a href="<?php
echo esc_url($toggle_url);
?>
" class="jetpack-toggle-button<?php
echo 'inactive' == $css ? ' button-primary' : ' button';
?>
"><?php
echo $toggle;
?>
</a>
<?php
}
?>
//.........这里部分代码省略.........