Jetpack::get_active_modules PHP Method

get_active_modules() public static method

Get a list of activated modules as an array of module slugs.
public static get_active_modules ( )
    public static function get_active_modules()
    {
        $active = Jetpack_Options::get_option('active_modules');
        if (!is_array($active)) {
            $active = array();
        }
        if (class_exists('VaultPress') || function_exists('vaultpress_contact_service')) {
            $active[] = 'vaultpress';
        } else {
            $active = array_diff($active, array('vaultpress'));
        }
        // If this plan supports videopress, force activate module
        if (Jetpack::active_plan_supports('videopress')) {
            $active[] = 'videopress';
        } else {
            $active = array_diff($active, array('videopress'));
        }
        //If protect is active on the main site of a multisite, it should be active on all sites.
        if (!in_array('protect', $active) && is_multisite() && get_site_option('jetpack_protect_active')) {
            $active[] = 'protect';
        }
        return array_unique($active);
    }

Usage Example

示例#1
1
function wpcf7_jetpack_admin_notices()
{
    global $wpdb;
    if (!class_exists('Jetpack') || !Jetpack::is_module('contact-form') || !in_array('contact-form', Jetpack::get_active_modules())) {
        return;
    }
    $q = "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_old_cf7_unit_id'";
    if (!$wpdb->get_var($q)) {
        return;
    }
    $desc_link = wpcf7_link(__('http://contactform7.com/jetpack-overrides-contact-forms/', 'contact-form-7'), __('Jetpack Overrides Contact Forms', 'contact-form-7'));
    ?>
<div class="notice notice-warning">
<p><?php 
    echo sprintf(esc_html(__('Jetpack may cause problems for other plugins in certain cases. For more details, see %s.', 'contact-form-7')), $desc_link);
    ?>
</p>
</div>
<?php 
}
All Usage Examples Of Jetpack::get_active_modules
Jetpack