is_module() public static method

public static is_module ( $module )
コード例 #1
1
ファイル: jetpack.php プロジェクト: flasomm/Montkailash
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 
}
コード例 #2
0
 /**
  * Walks through submitted themes to make sure they are valid
  * @return bool|WP_Error
  */
 protected function validate_modules()
 {
     foreach ($this->modules as $module) {
         if (!Jetpack::is_module($module)) {
             return new WP_Error('unknown_jetpack_module', sprintf(__('Module not found: `%s`.', 'jetpack'), $module), 404);
         }
     }
     return true;
 }
コード例 #3
0
 function render_nojs_configurable()
 {
     echo '<div class="clouds-sm"></div>';
     echo '<div class="wrap configure-module">';
     $module_name = preg_replace('/[^\\da-z\\-]+/', '', $_GET['configure']);
     if (Jetpack::is_module($module_name) && current_user_can('jetpack_configure_modules')) {
         Jetpack::admin_screen_configure_module($module_name);
     } else {
         echo '<h2>' . esc_html__('Error, bad module.', 'jetpack') . '</h2>';
     }
     echo '</div><!-- /wrap -->';
 }
コード例 #4
0
ファイル: jetpack.php プロジェクト: Savantos/cow-theme
function wpcf7_jetpack_admin_notices()
{
    if (!class_exists('Jetpack') || !Jetpack::is_module('contact-form') || !in_array('contact-form', Jetpack::get_active_modules())) {
        return;
    }
    $url = 'http://contactform7.com/jetpack-overrides-contact-forms/';
    ?>
<div class="error">
<p><?php 
    echo sprintf(__('<strong>Jetpack may cause problems for other plugins in certain cases.</strong> <a href="%s" target="_blank">See how to avoid it.</a>', 'wpcf7'), $url);
    ?>
</p>
</div>
<?php 
}
コード例 #5
0
 function admin_head()
 {
     if (isset($_GET['configure']) && Jetpack::is_module($_GET['configure']) && current_user_can('manage_options')) {
         /**
          * Fires in the <head> of a particular Jetpack configuation page.
          *
          * The dynamic portion of the hook name, `$_GET['configure']`,
          * refers to the slug of module, such as 'stats', 'sso', etc.
          * A complete hook for the latter would be
          * 'jetpack_module_configuation_head_sso'.
          *
          * @since 3.0.0
          */
         do_action('jetpack_module_configuration_head_' . $_GET['configure']);
     }
 }
コード例 #6
0
ファイル: jetpack.php プロジェクト: KurtMakesWeb/CandG
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;
    }
    $url = 'http://contactform7.com/jetpack-overrides-contact-forms/';
    ?>
<div class="error">
<p><?php 
    echo sprintf(__('<strong>Jetpack may cause problems for other plugins in certain cases.</strong> <a href="%s" target="_blank">See how to avoid it.</a>', 'wpcf7'), $url);
    ?>
</p>
</div>
<?php 
}
コード例 #7
0
 /**
  * Handles the page load events for the Jetpack admin page
  */
 function admin_page_load()
 {
     $error = false;
     // Make sure we have the right body class to hook stylings for subpages off of.
     add_filter('admin_body_class', array(__CLASS__, 'add_jetpack_pagestyles'));
     if (!empty($_GET['jetpack_restate'])) {
         // Should only be used in intermediate redirects to preserve state across redirects
         Jetpack::restate();
     }
     if (isset($_GET['connect_url_redirect'])) {
         // User clicked in the iframe to link their accounts
         if (!Jetpack::is_user_connected()) {
             $connect_url = $this->build_connect_url(true, false, 'iframe');
             if (isset($_GET['notes_iframe'])) {
                 $connect_url .= '&notes_iframe';
             }
             wp_redirect($connect_url);
             exit;
         } else {
             Jetpack::state('message', 'already_authorized');
             wp_safe_redirect(Jetpack::admin_url());
             exit;
         }
     }
     if (isset($_GET['action'])) {
         switch ($_GET['action']) {
             case 'authorize':
                 if (Jetpack::is_active() && Jetpack::is_user_connected()) {
                     Jetpack::state('message', 'already_authorized');
                     wp_safe_redirect(Jetpack::admin_url());
                     exit;
                 }
                 Jetpack::log('authorize');
                 $client_server = new Jetpack_Client_Server();
                 $client_server->client_authorize();
                 exit;
             case 'register':
                 if (!current_user_can('jetpack_connect')) {
                     $error = 'cheatin';
                     break;
                 }
                 check_admin_referer('jetpack-register');
                 Jetpack::log('register');
                 Jetpack::maybe_set_version_option();
                 $registered = Jetpack::try_registration();
                 if (is_wp_error($registered)) {
                     $error = $registered->get_error_code();
                     Jetpack::state('error_description', $registered->get_error_message());
                     break;
                 }
                 $from = isset($_GET['from']) ? $_GET['from'] : false;
                 wp_redirect($this->build_connect_url(true, false, $from));
                 exit;
             case 'activate':
                 if (!current_user_can('jetpack_activate_modules')) {
                     $error = 'cheatin';
                     break;
                 }
                 $module = stripslashes($_GET['module']);
                 check_admin_referer("jetpack_activate-{$module}");
                 Jetpack::log('activate', $module);
                 Jetpack::activate_module($module);
                 // The following two lines will rarely happen, as Jetpack::activate_module normally exits at the end.
                 wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
                 exit;
             case 'activate_default_modules':
                 check_admin_referer('activate_default_modules');
                 Jetpack::log('activate_default_modules');
                 Jetpack::restate();
                 $min_version = isset($_GET['min_version']) ? $_GET['min_version'] : false;
                 $max_version = isset($_GET['max_version']) ? $_GET['max_version'] : false;
                 $other_modules = isset($_GET['other_modules']) && is_array($_GET['other_modules']) ? $_GET['other_modules'] : array();
                 Jetpack::activate_default_modules($min_version, $max_version, $other_modules);
                 wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
                 exit;
             case 'disconnect':
                 if (!current_user_can('jetpack_disconnect')) {
                     $error = 'cheatin';
                     break;
                 }
                 check_admin_referer('jetpack-disconnect');
                 Jetpack::log('disconnect');
                 Jetpack::disconnect();
                 wp_safe_redirect(Jetpack::admin_url('disconnected=true'));
                 exit;
             case 'reconnect':
                 if (!current_user_can('jetpack_reconnect')) {
                     $error = 'cheatin';
                     break;
                 }
                 check_admin_referer('jetpack-reconnect');
                 Jetpack::log('reconnect');
                 $this->disconnect();
                 wp_redirect($this->build_connect_url(true, false, 'reconnect'));
                 exit;
             case 'deactivate':
                 if (!current_user_can('jetpack_deactivate_modules')) {
                     $error = 'cheatin';
                     break;
                 }
                 $modules = stripslashes($_GET['module']);
                 check_admin_referer("jetpack_deactivate-{$modules}");
                 foreach (explode(',', $modules) as $module) {
                     Jetpack::log('deactivate', $module);
                     Jetpack::deactivate_module($module);
                     Jetpack::state('message', 'module_deactivated');
                 }
                 Jetpack::state('module', $modules);
                 wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
                 exit;
             case 'unlink':
                 $redirect = isset($_GET['redirect']) ? $_GET['redirect'] : '';
                 check_admin_referer('jetpack-unlink');
                 Jetpack::log('unlink');
                 $this->unlink_user();
                 Jetpack::state('message', 'unlinked');
                 if ('sub-unlink' == $redirect) {
                     wp_safe_redirect(admin_url());
                 } else {
                     wp_safe_redirect(Jetpack::admin_url(array('page' => $redirect)));
                 }
                 exit;
             default:
                 /**
                  * Fires when a Jetpack admin page is loaded with an unrecognized parameter.
                  *
                  * @since 2.6.0
                  *
                  * @param string sanitize_key( $_GET['action'] ) Unrecognized URL parameter.
                  */
                 do_action('jetpack_unrecognized_action', sanitize_key($_GET['action']));
         }
     }
     if (!($error = $error ? $error : Jetpack::state('error'))) {
         self::activate_new_modules(true);
     }
     switch ($error) {
         case 'cheatin':
             $this->error = __('Cheatin&#8217; uh?', 'jetpack');
             break;
         case 'access_denied':
             $this->error = sprintf(__('Would you mind telling us why you did not complete the Jetpack connection in this <a href="%s">1 question survey</a>?', 'jetpack'), 'http://jetpack.com/cancelled-connection/') . '<br /><small>' . __('A Jetpack connection is required for our free security and traffic features to work.', 'jetpack') . '</small>';
             break;
         case 'wrong_state':
             $this->error = __('You need to stay logged in to your WordPress blog while you authorize Jetpack.', 'jetpack');
             break;
         case 'invalid_client':
             // @todo re-register instead of deactivate/reactivate
             $this->error = __('We had an issue connecting Jetpack; deactivate then reactivate the Jetpack plugin, then connect again.', 'jetpack');
             break;
         case 'invalid_grant':
             $this->error = __('There was an issue connecting your Jetpack. Please click &#8220;Connect to WordPress.com&#8221; again.', 'jetpack');
             break;
         case 'site_inaccessible':
         case 'site_requires_authorization':
             $this->error = sprintf(__('Your website needs to be publicly accessible to use Jetpack: %s', 'jetpack'), "<code>{$error}</code>");
             break;
         case 'module_activation_failed':
             $module = Jetpack::state('module');
             if (!empty($module) && ($mod = Jetpack::get_module($module))) {
                 $this->error = sprintf(__('%s could not be activated because it triggered a <strong>fatal error</strong>. Perhaps there is a conflict with another plugin you have installed?', 'jetpack'), $mod['name']);
                 if (isset($this->plugins_to_deactivate[$module])) {
                     $this->error .= ' ' . sprintf(__('Do you still have the %s plugin installed?', 'jetpack'), $this->plugins_to_deactivate[$module][1]);
                 }
             } else {
                 $this->error = __('Module could not be activated because it triggered a <strong>fatal error</strong>. Perhaps there is a conflict with another plugin you have installed?', 'jetpack');
             }
             if ($php_errors = Jetpack::state('php_errors')) {
                 $this->error .= "<br />\n";
                 $this->error .= $php_errors;
             }
             break;
         case 'master_user_required':
             $module = Jetpack::state('module');
             $module_name = '';
             if (!empty($module) && ($mod = Jetpack::get_module($module))) {
                 $module_name = $mod['name'];
             }
             $master_user = Jetpack_Options::get_option('master_user');
             $master_userdata = get_userdata($master_user);
             if ($master_userdata) {
                 if (!in_array($module, Jetpack::get_active_modules())) {
                     $this->error = sprintf(__('%s was not activated.', 'jetpack'), $module_name);
                 } else {
                     $this->error = sprintf(__('%s was not deactivated.', 'jetpack'), $module_name);
                 }
                 $this->error .= '  ' . sprintf(__('This module can only be altered by %s, the user who initiated the Jetpack connection on this site.', 'jetpack'), esc_html($master_userdata->display_name));
             } else {
                 $this->error = sprintf(__('Only the user who initiated the Jetpack connection on this site can toggle %s, but that user no longer exists. This should not happen.', 'jetpack'), $module_name);
             }
             break;
         case 'not_public':
             $this->error = __('<strong>Your Jetpack has a glitch.</strong> Connecting this site with WordPress.com is not possible. This usually means your site is not publicly accessible (localhost).', 'jetpack');
             break;
         case 'wpcom_408':
         case 'wpcom_5??':
         case 'wpcom_bad_response':
         case 'wpcom_outage':
             $this->error = __('WordPress.com is currently having problems and is unable to fuel up your Jetpack.  Please try again later.', 'jetpack');
             break;
         case 'register_http_request_failed':
         case 'token_http_request_failed':
             $this->error = sprintf(__('Jetpack could not contact WordPress.com: %s.  This usually means something is incorrectly configured on your web host.', 'jetpack'), "<code>{$error}</code>");
             break;
         default:
             if (empty($error)) {
                 break;
             }
             $error = trim(substr(strip_tags($error), 0, 20));
             // no break: fall through
         // no break: fall through
         case 'no_role':
         case 'no_cap':
         case 'no_code':
         case 'no_state':
         case 'invalid_state':
         case 'invalid_request':
         case 'invalid_scope':
         case 'unsupported_response_type':
         case 'invalid_token':
         case 'no_token':
         case 'missing_secrets':
         case 'home_missing':
         case 'siteurl_missing':
         case 'gmt_offset_missing':
         case 'site_name_missing':
         case 'secret_1_missing':
         case 'secret_2_missing':
         case 'site_lang_missing':
         case 'home_malformed':
         case 'siteurl_malformed':
         case 'gmt_offset_malformed':
         case 'timezone_string_malformed':
         case 'site_name_malformed':
         case 'secret_1_malformed':
         case 'secret_2_malformed':
         case 'site_lang_malformed':
         case 'secrets_mismatch':
         case 'verify_secret_1_missing':
         case 'verify_secret_1_malformed':
         case 'verify_secrets_missing':
         case 'verify_secrets_mismatch':
             $error = esc_html($error);
             $this->error = sprintf(__('<strong>Your Jetpack has a glitch.</strong>  We&#8217;re sorry for the inconvenience. Please try again later, if the issue continues please contact support with this message: %s', 'jetpack'), "<code>{$error}</code>");
             if (!Jetpack::is_active()) {
                 $this->error .= '<br />';
                 $this->error .= sprintf(__('Try connecting again.', 'jetpack'));
             }
             break;
     }
     $message_code = Jetpack::state('message');
     $active_state = Jetpack::state('activated_modules');
     if (!empty($active_state)) {
         $available = Jetpack::get_available_modules();
         $active_state = explode(',', $active_state);
         $active_state = array_intersect($active_state, $available);
         if (count($active_state)) {
             foreach ($active_state as $mod) {
                 $this->stat('module-activated', $mod);
             }
         } else {
             $active_state = false;
         }
     }
     if (Jetpack::state('optin-manage')) {
         $activated_manage = $message_code;
         $message_code = 'jetpack-manage';
     }
     switch ($message_code) {
         case 'modules_activated':
             $this->message = sprintf(__('Welcome to <strong>Jetpack %s</strong>!', 'jetpack'), JETPACK__VERSION);
             if ($active_state) {
                 $titles = array();
                 foreach ($active_state as $mod) {
                     if ($mod_headers = Jetpack::get_module($mod)) {
                         $titles[] = '<strong>' . preg_replace('/\\s+(?![^<>]++>)/', '&nbsp;', $mod_headers['name']) . '</strong>';
                     }
                 }
                 if ($titles) {
                     $this->message .= '<br /><br />' . wp_sprintf(__('The following new modules have been activated: %l.', 'jetpack'), $titles);
                 }
             }
             if ($reactive_state = Jetpack::state('reactivated_modules')) {
                 $titles = array();
                 foreach (explode(',', $reactive_state) as $mod) {
                     if ($mod_headers = Jetpack::get_module($mod)) {
                         $titles[] = '<strong>' . preg_replace('/\\s+(?![^<>]++>)/', '&nbsp;', $mod_headers['name']) . '</strong>';
                     }
                 }
                 if ($titles) {
                     $this->message .= '<br /><br />' . wp_sprintf(__('The following modules have been updated: %l.', 'jetpack'), $titles);
                 }
             }
             $this->message .= Jetpack::jetpack_comment_notice();
             break;
         case 'jetpack-manage':
             $this->message = '<strong>' . sprintf(__('You are all set! Your site can now be managed from <a href="%s" target="_blank">wordpress.com/sites</a>.', 'jetpack'), 'https://wordpress.com/sites') . '</strong>';
             if ($activated_manage) {
                 $this->message .= '<br /><strong>' . __('Manage has been activated for you!', 'jetpack') . '</strong>';
             }
             break;
         case 'module_activated':
             if ($module = Jetpack::get_module(Jetpack::state('module'))) {
                 $this->message = sprintf(__('<strong>%s Activated!</strong> You can deactivate at any time by clicking the Deactivate link next to each module.', 'jetpack'), $module['name']);
                 $this->stat('module-activated', Jetpack::state('module'));
             }
             break;
         case 'module_deactivated':
             $modules = Jetpack::state('module');
             if (!$modules) {
                 break;
             }
             $module_names = array();
             foreach (explode(',', $modules) as $module_slug) {
                 $module = Jetpack::get_module($module_slug);
                 if ($module) {
                     $module_names[] = $module['name'];
                 }
                 $this->stat('module-deactivated', $module_slug);
             }
             if (!$module_names) {
                 break;
             }
             $this->message = wp_sprintf(_nx('<strong>%l Deactivated!</strong> You can activate it again at any time using the activate link next to each module.', '<strong>%l Deactivated!</strong> You can activate them again at any time using the activate links next to each module.', count($module_names), '%l = list of Jetpack module/feature names', 'jetpack'), $module_names);
             break;
         case 'module_configured':
             $this->message = __('<strong>Module settings were saved.</strong> ', 'jetpack');
             break;
         case 'already_authorized':
             $this->message = __('<strong>Your Jetpack is already connected.</strong> ', 'jetpack');
             break;
         case 'authorized':
             $this->message = __('<strong>You&#8217;re fueled up and ready to go, Jetpack is now active.</strong> ', 'jetpack');
             $this->message .= Jetpack::jetpack_comment_notice();
             break;
         case 'linked':
             $this->message = __('<strong>You&#8217;re fueled up and ready to go.</strong> ', 'jetpack');
             $this->message .= Jetpack::jetpack_comment_notice();
             break;
         case 'unlinked':
             $user = wp_get_current_user();
             $this->message = sprintf(__('<strong>You have unlinked your account (%s) from WordPress.com.</strong>', 'jetpack'), $user->user_login);
             break;
         case 'switch_master':
             global $current_user;
             $is_master_user = $current_user->ID == Jetpack_Options::get_option('master_user');
             $master_userdata = get_userdata(Jetpack_Options::get_option('master_user'));
             if ($is_master_user) {
                 $this->message = __('You have successfully set yourself as Jetpack’s primary user.', 'jetpack');
             } else {
                 $this->message = sprintf(_x('You have successfully set %s as Jetpack’s primary user.', '%s is a username', 'jetpack'), $master_userdata->user_login);
             }
             break;
     }
     $deactivated_plugins = Jetpack::state('deactivated_plugins');
     if (!empty($deactivated_plugins)) {
         $deactivated_plugins = explode(',', $deactivated_plugins);
         $deactivated_titles = array();
         foreach ($deactivated_plugins as $deactivated_plugin) {
             if (!isset($this->plugins_to_deactivate[$deactivated_plugin])) {
                 continue;
             }
             $deactivated_titles[] = '<strong>' . str_replace(' ', '&nbsp;', $this->plugins_to_deactivate[$deactivated_plugin][1]) . '</strong>';
         }
         if ($deactivated_titles) {
             if ($this->message) {
                 $this->message .= "<br /><br />\n";
             }
             $this->message .= wp_sprintf(_n('Jetpack contains the most recent version of the old %l plugin.', 'Jetpack contains the most recent versions of the old %l plugins.', count($deactivated_titles), 'jetpack'), $deactivated_titles);
             $this->message .= "<br />\n";
             $this->message .= _n('The old version has been deactivated and can be removed from your site.', 'The old versions have been deactivated and can be removed from your site.', count($deactivated_titles), 'jetpack');
         }
     }
     $this->privacy_checks = Jetpack::state('privacy_checks');
     if ($this->message || $this->error || $this->privacy_checks || $this->can_display_jetpack_manage_notice()) {
         add_action('jetpack_notices', array($this, 'admin_notices'));
     }
     if (isset($_GET['configure']) && Jetpack::is_module($_GET['configure']) && current_user_can('manage_options')) {
         /**
          * Fires when a module configuration page is loaded.
          * The dynamic part of the hook is the configure parameter from the URL.
          *
          * @since 1.1.0
          */
         do_action('jetpack_module_configuration_load_' . $_GET['configure']);
     }
     add_filter('jetpack_short_module_description', 'wptexturize');
 }
コード例 #8
0
    function admin_page()
    {
        global $current_user;
        $role = $this->translate_current_user_to_role();
        $is_connected = Jetpack::is_active();
        $module = false;
        ?>
		<div class="wrap" id="jetpack-settings">

			<h2 style="display: none"></h2> <!-- For WP JS message relocation -->

			<div id="jp-header"<?php 
        if ($is_connected) {
            ?>
 class="small"<?php 
        }
        ?>
>
				<div id="jp-clouds">
					<?php 
        if ($is_connected) {
            ?>
					<div id="jp-disconnect">
						<a href="<?php 
            echo wp_nonce_url(Jetpack::admin_url(array('action' => 'disconnect')), 'jetpack-disconnect');
            ?>
"><?php 
            _e('Connected to WordPress.com', 'jetpack');
            ?>
</a>
						<span><?php 
            _e('Disconnect from WordPress.com', 'jetpack');
            ?>
</span>
					</div>
					<?php 
        }
        ?>
					<h3><?php 
        _e('Jetpack by WordPress.com', 'jetpack');
        ?>
</h3>
					<?php 
        if (!$is_connected) {
            ?>
					<div id="jp-notice">
						<p><?php 
            _e('Jetpack supercharges your self-hosted WordPress site with the awesome cloud power of WordPress.com.', 'jetpack');
            ?>
</p>
					</div>
					<?php 
        }
        ?>
				</div>
			</div>

			<?php 
        do_action('jetpack_notices');
        ?>

			<?php 
        // If the connection has not been made then show the marketing text.
        ?>
			<?php 
        if (!$is_connected) {
            ?>

				<div id="jp-info">
					<a href="<?php 
            echo $this->build_connect_url();
            ?>
" class="jp-button" id="wpcom-connect"><?php 
            _e('Connect to WordPress.com', 'jetpack');
            ?>
</a>
					<p><?php 
            _e("To enable all of the Jetpack features you&#8217;ll need to connect your website to WordPress.com using the button to the right. Once you&#8217;ve made the connection you&#8217;ll activate all the delightful features below.", 'jetpack');
            ?>
</p>
				</div>

			<?php 
        }
        ?>

			<?php 
        // If we select the configure option for a module, show the configuration screen.
        if (isset($_GET['configure']) && Jetpack::is_module($_GET['configure'])) {
            $this->admin_screen_configure_module($_GET['configure']);
            // List all the available modules.
        } else {
            $this->admin_screen_list_modules();
            ?>

				<div id="survey" class="jp-survey">
					<div class="jp-survey-container">
						<div class="jp-survey-text">
							<h4><?php 
            _e('Have feedback on Jetpack?', 'jetpack');
            ?>
</h4>
							<br />
							<?php 
            _e('Answer a short survey to let us know how we&#8217;re doing and what to add in the future.', 'jetpack');
            ?>
						</div>
						<div class="jp-survey-button-container">
							<p class="submit"><?php 
            printf('<a id="jp-survey-button" class="button-primary" target="_blank" href="%1$s">%2$s</a>', 'http://jetpack.me/survey/?rel=' . JETPACK__VERSION, __('Take Survey', 'jetpack'));
            ?>
</p>
						</div>
					</div>
				</div>
				
				<?php 
            if ($is_connected && $this->current_user_is_connection_owner()) {
                ?>
					<p id="news-sub"><?php 
                _e('Checking email updates status&hellip;', 'jetpack');
                ?>
</p>
					<script type="text/javascript">
					jQuery(document).ready(function($){
						$.get( ajaxurl, { action: 'jetpack-check-news-subscription', rand: jQuery.now().toString() + Math.random().toString() }, function( data ) {
							if ( 'subscribed' == data ) {
								$( '#news-sub' ).html( '<?php 
                printf(esc_js(_x('You are currently subscribed to email updates. %s', '%s = Unsubscribe link', 'jetpack')), '<a href="#" class="jp-news-link button">' . esc_js(__('Unsubscribe', 'jetpack')) . '</a>');
                ?>
' );
							} else {
								$( '#news-sub' ).html( '<?php 
                printf(esc_js(_x('Want to receive updates about Jetpack by email? %s', '%s = Subscribe link', 'jetpack')), '<a href="#" class="jp-news-link button-primary">' . esc_js(__('Subscribe', 'jetpack')) . '</a>');
                ?>
' );
							}
							$( '.jp-news-link' ).click( function() {
								$( '#news-sub' ).append( ' <img src="<?php 
                echo esc_js(esc_url(admin_url('images/loading.gif')));
                ?>
" align="absmiddle" id="jp-news-loading" />' );
								$.get( ajaxurl, { action: 'jetpack-subscribe-to-news', rand: jQuery.now().toString() + Math.random().toString() }, function( data ) {
									if ( 'subscribed' == data ) {
										$( '#news-sub' ).text( '<?php 
                echo esc_js(__('You have been subscribed to receive email updates.', 'jetpack'));
                ?>
' );
									} else {
										$( '#news-sub' ).text( '<?php 
                echo esc_js(__('You will no longer receive email updates about Jetpack.', 'jetpack'));
                ?>
' );
									}
									$( '#jp-news-loading' ).remove();
								} );
								return false;
							} );
						} );
					} );
					</script>
				<?php 
            }
            ?>
			<?php 
        }
        ?>

			<div id="jp-footer">
				<p class="automattic"><?php 
        _e('An <span>Automattic</span> Airline', 'jetpack');
        ?>
</p>
				<p class="small">
					<a href="http://jetpack.me/" target="_blank">Jetpack <?php 
        echo esc_html(JETPACK__VERSION);
        ?>
</a> |
					<a href="http://automattic.com/privacy/" target="_blank"><?php 
        _e('Privacy Policy', 'jetpack');
        ?>
</a> |
					<a href="http://wordpress.com/tos/" target="_blank"><?php 
        _e('Terms of Service', 'jetpack');
        ?>
</a> |
					<a href="<?php 
        echo esc_url(wp_nonce_url(admin_url('admin-ajax.php?action=jetpack_debug'), 'jetpack_debug'));
        ?>
" id="jp-debug"><?php 
        _e('Debug', 'jetpack');
        ?>
</a> |
					<a href="http://jetpack.me/support/" target="_blank"><?php 
        _e('Support', 'jetpack');
        ?>
</a>
				</p>
			</div>

			<div id="jetpack-configuration" style="display:none;">
				<p><img src="<?php 
        echo esc_url(admin_url('images/wpspin_dark.gif'));
        ?>
" alt="Loading ..." /></p>
			</div>
		</div>
	<?php 
    }
コード例 #9
0
ファイル: class.jetpack.php プロジェクト: automattic/jetpack
 /**
  * Handles the page load events for the Jetpack admin page
  */
 function admin_page_load()
 {
     $error = false;
     // Make sure we have the right body class to hook stylings for subpages off of.
     add_filter('admin_body_class', array(__CLASS__, 'add_jetpack_pagestyles'));
     if (!empty($_GET['jetpack_restate'])) {
         // Should only be used in intermediate redirects to preserve state across redirects
         Jetpack::restate();
     }
     if (isset($_GET['connect_url_redirect'])) {
         // User clicked in the iframe to link their accounts
         if (!Jetpack::is_user_connected()) {
             $connect_url = $this->build_connect_url(true, false, 'iframe');
             if (isset($_GET['notes_iframe'])) {
                 $connect_url .= '&notes_iframe';
             }
             wp_redirect($connect_url);
             exit;
         } else {
             if (!isset($_GET['calypso_env'])) {
                 Jetpack::state('message', 'already_authorized');
                 wp_safe_redirect(Jetpack::admin_url());
             } else {
                 $connect_url = $this->build_connect_url(true, false, 'iframe');
                 $connect_url .= '&already_authorized=true';
                 wp_redirect($connect_url);
             }
         }
     }
     if (isset($_GET['action'])) {
         switch ($_GET['action']) {
             case 'authorize':
                 if (Jetpack::is_active() && Jetpack::is_user_connected()) {
                     Jetpack::state('message', 'already_authorized');
                     wp_safe_redirect(Jetpack::admin_url());
                     exit;
                 }
                 Jetpack::log('authorize');
                 $client_server = new Jetpack_Client_Server();
                 $client_server->client_authorize();
                 exit;
             case 'register':
                 if (!current_user_can('jetpack_connect')) {
                     $error = 'cheatin';
                     break;
                 }
                 check_admin_referer('jetpack-register');
                 Jetpack::log('register');
                 Jetpack::maybe_set_version_option();
                 $registered = Jetpack::try_registration();
                 if (is_wp_error($registered)) {
                     $error = $registered->get_error_code();
                     Jetpack::state('error', $error);
                     Jetpack::state('error', $registered->get_error_message());
                     break;
                 }
                 $from = isset($_GET['from']) ? $_GET['from'] : false;
                 wp_redirect($this->build_connect_url(true, false, $from));
                 exit;
             case 'activate':
                 if (!current_user_can('jetpack_activate_modules')) {
                     $error = 'cheatin';
                     break;
                 }
                 $module = stripslashes($_GET['module']);
                 check_admin_referer("jetpack_activate-{$module}");
                 Jetpack::log('activate', $module);
                 Jetpack::activate_module($module);
                 // The following two lines will rarely happen, as Jetpack::activate_module normally exits at the end.
                 wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
                 exit;
             case 'activate_default_modules':
                 check_admin_referer('activate_default_modules');
                 Jetpack::log('activate_default_modules');
                 Jetpack::restate();
                 $min_version = isset($_GET['min_version']) ? $_GET['min_version'] : false;
                 $max_version = isset($_GET['max_version']) ? $_GET['max_version'] : false;
                 $other_modules = isset($_GET['other_modules']) && is_array($_GET['other_modules']) ? $_GET['other_modules'] : array();
                 Jetpack::activate_default_modules($min_version, $max_version, $other_modules);
                 wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
                 exit;
             case 'disconnect':
                 if (!current_user_can('jetpack_disconnect')) {
                     $error = 'cheatin';
                     break;
                 }
                 check_admin_referer('jetpack-disconnect');
                 Jetpack::log('disconnect');
                 Jetpack::disconnect();
                 wp_safe_redirect(Jetpack::admin_url('disconnected=true'));
                 exit;
             case 'reconnect':
                 if (!current_user_can('jetpack_reconnect')) {
                     $error = 'cheatin';
                     break;
                 }
                 check_admin_referer('jetpack-reconnect');
                 Jetpack::log('reconnect');
                 $this->disconnect();
                 wp_redirect($this->build_connect_url(true, false, 'reconnect'));
                 exit;
             case 'deactivate':
                 if (!current_user_can('jetpack_deactivate_modules')) {
                     $error = 'cheatin';
                     break;
                 }
                 $modules = stripslashes($_GET['module']);
                 check_admin_referer("jetpack_deactivate-{$modules}");
                 foreach (explode(',', $modules) as $module) {
                     Jetpack::log('deactivate', $module);
                     Jetpack::deactivate_module($module);
                     Jetpack::state('message', 'module_deactivated');
                 }
                 Jetpack::state('module', $modules);
                 wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
                 exit;
             case 'unlink':
                 $redirect = isset($_GET['redirect']) ? $_GET['redirect'] : '';
                 check_admin_referer('jetpack-unlink');
                 Jetpack::log('unlink');
                 $this->unlink_user();
                 Jetpack::state('message', 'unlinked');
                 if ('sub-unlink' == $redirect) {
                     wp_safe_redirect(admin_url());
                 } else {
                     wp_safe_redirect(Jetpack::admin_url(array('page' => $redirect)));
                 }
                 exit;
             default:
                 /**
                  * Fires when a Jetpack admin page is loaded with an unrecognized parameter.
                  *
                  * @since 2.6.0
                  *
                  * @param string sanitize_key( $_GET['action'] ) Unrecognized URL parameter.
                  */
                 do_action('jetpack_unrecognized_action', sanitize_key($_GET['action']));
         }
     }
     if (!($error = $error ? $error : Jetpack::state('error'))) {
         self::activate_new_modules(true);
     }
     $message_code = Jetpack::state('message');
     if (Jetpack::state('optin-manage')) {
         $activated_manage = $message_code;
         $message_code = 'jetpack-manage';
     }
     switch ($message_code) {
         case 'jetpack-manage':
             $this->message = '<strong>' . sprintf(__('You are all set! Your site can now be managed from <a href="%s" target="_blank">wordpress.com/sites</a>.', 'jetpack'), 'https://wordpress.com/sites') . '</strong>';
             if ($activated_manage) {
                 $this->message .= '<br /><strong>' . __('Manage has been activated for you!', 'jetpack') . '</strong>';
             }
             break;
     }
     $deactivated_plugins = Jetpack::state('deactivated_plugins');
     if (!empty($deactivated_plugins)) {
         $deactivated_plugins = explode(',', $deactivated_plugins);
         $deactivated_titles = array();
         foreach ($deactivated_plugins as $deactivated_plugin) {
             if (!isset($this->plugins_to_deactivate[$deactivated_plugin])) {
                 continue;
             }
             $deactivated_titles[] = '<strong>' . str_replace(' ', '&nbsp;', $this->plugins_to_deactivate[$deactivated_plugin][1]) . '</strong>';
         }
         if ($deactivated_titles) {
             if ($this->message) {
                 $this->message .= "<br /><br />\n";
             }
             $this->message .= wp_sprintf(_n('Jetpack contains the most recent version of the old %l plugin.', 'Jetpack contains the most recent versions of the old %l plugins.', count($deactivated_titles), 'jetpack'), $deactivated_titles);
             $this->message .= "<br />\n";
             $this->message .= _n('The old version has been deactivated and can be removed from your site.', 'The old versions have been deactivated and can be removed from your site.', count($deactivated_titles), 'jetpack');
         }
     }
     $this->privacy_checks = Jetpack::state('privacy_checks');
     if ($this->message || $this->error || $this->privacy_checks || $this->can_display_jetpack_manage_notice()) {
         add_action('jetpack_notices', array($this, 'admin_notices'));
     }
     if (isset($_GET['configure']) && Jetpack::is_module($_GET['configure']) && current_user_can('manage_options')) {
         /**
          * Fires when a module configuration page is loaded.
          * The dynamic part of the hook is the configure parameter from the URL.
          *
          * @since 1.1.0
          */
         do_action('jetpack_module_configuration_load_' . $_GET['configure']);
     }
     add_filter('jetpack_short_module_description', 'wptexturize');
 }
コード例 #10
0
 function render_nojs_configurable($module_name)
 {
     $module_name = preg_replace('/[^\\da-z\\-]+/', '', $_GET['configure']);
     include_once JETPACK__PLUGIN_DIR . '_inc/header.php';
     echo '<div class="wrap configure-module">';
     if (Jetpack::is_module($module_name) && current_user_can('jetpack_configure_modules')) {
         Jetpack::admin_screen_configure_module($module_name);
     } else {
         echo '<h2>' . esc_html__('Error, bad module.', 'jetpack') . '</h2>';
     }
     echo '</div><!-- /wrap -->';
 }
コード例 #11
0
    function admin_page()
    {
        global $current_user;
        $role = $this->translate_current_user_to_role();
        $is_connected = Jetpack::is_active();
        $module = false;
        ?>
		<div class="wrap" id="jetpack-settings">

			<div id="jp-header"<?php 
        if ($is_connected) {
            ?>
 class="small"<?php 
        }
        ?>
>
				<div id="jp-clouds">
					<?php 
        if ($is_connected) {
            ?>
					<div id="jp-disconnect">
						<a href="<?php 
            echo wp_nonce_url(Jetpack::admin_url(array('action' => 'disconnect')), 'jetpack-disconnect');
            ?>
"><?php 
            _e('Connected to WordPress.com', 'jetpack');
            ?>
</a>
						<span><?php 
            _e('Disconnect from WordPress.com', 'jetpack');
            ?>
</span>
					</div>
					<?php 
        }
        ?>
					<h3><?php 
        _e('Jetpack by WordPress.com', 'jetpack');
        ?>
</h3>
					<?php 
        if (!$is_connected) {
            ?>
					<div id="jp-notice">
						<p><?php 
            _e('Jetpack supercharges your self-hosted WordPress site with the awesome cloud power of WordPress.com.', 'jetpack');
            ?>
</p>
					</div>
					<?php 
        }
        ?>
				</div>
			</div>
			
			<h2 style="display: none"></h2> <!-- For WP JS message relocation -->

			<?php 
        do_action('jetpack_notices');
        ?>

			<?php 
        // If the connection has not been made then show the marketing text.
        ?>
			<?php 
        if (!$is_connected) {
            ?>

				<div id="jp-info">
					<a href="<?php 
            echo $this->build_connect_url();
            ?>
" class="jp-button" id="wpcom-connect"><?php 
            _e('Connect to WordPress.com', 'jetpack');
            ?>
</a>
					<p><?php 
            _e("To enable all of the Jetpack features you&#8217;ll need to connect your website to WordPress.com using the button to the right. Once you&#8217;ve made the connection you&#8217;ll activate all the delightful features below.", 'jetpack');
            ?>
</p>
				</div>

			<?php 
        }
        ?>

			<?php 
        // If we select the configure option for a module, show the configuration screen.
        if (isset($_GET['configure']) && Jetpack::is_module($_GET['configure'])) {
            $this->admin_screen_configure_module($_GET['configure']);
            // List all the available modules.
        } else {
            $this->admin_screen_list_modules();
            ?>

				<?php 
            if ($is_connected) {
                ?>
					<p id="news-sub"><?php 
                _e('Checking email updates status&hellip;', 'jetpack');
                ?>
</p>
					<script type="text/javascript">
					jQuery(document).ready(function($){
						$.get( ajaxurl, { action: 'jetpack-check-news-subscription', rand: jQuery.now().toString() + Math.random().toString() }, function( data ) {
							if ( 'subscribed' == data ) {
								$( '#news-sub' ).html( '<?php 
                printf(esc_js(_x('You are currently subscribed to email updates. %s', '%s = Unsubscribe link', 'jetpack')), '<a href="#" class="jp-news-link button">' . esc_js(__('Unsubscribe', 'jetpack')) . '</a>');
                ?>
' );
							} else {
								$( '#news-sub' ).html( '<?php 
                printf(esc_js(_x('Want to receive updates about Jetpack by email? %s', '%s = Subscribe link', 'jetpack')), '<a href="#" class="jp-news-link button-primary">' . esc_js(__('Subscribe', 'jetpack')) . '</a>');
                ?>
' );
							}
							$( '.jp-news-link' ).click( function() {
								$( '#news-sub' ).append( ' <img src="<?php 
                echo esc_js(esc_url(admin_url('images/loading.gif')));
                ?>
" align="absmiddle" id="jp-news-loading" />' );
								$.get( ajaxurl, { action: 'jetpack-subscribe-to-news', rand: jQuery.now().toString() + Math.random().toString() }, function( data ) {
									if ( 'subscribed' == data ) {
										$( '#news-sub' ).text( '<?php 
                echo esc_js(__('You have been subscribed to receive email updates.', 'jetpack'));
                ?>
' );
									} else {
										$( '#news-sub' ).text( '<?php 
                echo esc_js(__('You will no longer receive email updates about Jetpack.', 'jetpack'));
                ?>
' );
									}
									$( '#jp-news-loading' ).remove();
								} );
								return false;
							} );
						} );
					} );
					</script>
				<?php 
            }
            ?>
			<?php 
        }
        ?>

			<div id="jp-footer">
				<p class="automattic"><?php 
        _e('An <span>Automattic</span> Airline', 'jetpack');
        ?>
</p>
				<p class="small">
					<a href="http://automattic.com/privacy/" target="_blank"><?php 
        _e('Privacy Policy', 'jetpack');
        ?>
</a> |
					<a href="http://wordpress.com/tos/" target="_blank"><?php 
        _e('Terms of Service', 'jetpack');
        ?>
</a> |
					<a href="" id="jp-debug"><?php 
        _e('Debug', 'jetpack');
        ?>
</a> |
					<a href="http://jetpack.me/support/" target="_blank"><?php 
        _e('Support', 'jetpack');
        ?>
</a>
				</p>
			</div>

			<div id="jetpack-configuration" style="display:none;">
				<h4>Debug</h4>
				<ul>
					<li>CLIENT_ID:  <code style="font-size: 14px;"><?php 
        echo esc_html(get_option('jetpack_id'));
        ?>
</code></li>
					<li>BLOG_TOKEN: <code style="font-size: 14px;"><?php 
        echo esc_html(get_option('jetpack_blog_token'));
        ?>
</code></li>
					<li>USER_TOKEN: <code style="font-size: 14px;"><?php 
        echo esc_html(get_option('jetpack_user_token'));
        ?>
</code></li>
					<li>CERT:       <code style="font-size: 14px;"><?php 
        echo esc_html(get_option('jetpack_fallback_no_verify_ssl_certs'));
        ?>
</code>
					<li>TIME_DIFF:  <code style="font-size: 14px;"><?php 
        echo esc_html(get_option('jetpack_time_diff'));
        ?>
</code>
				</ul>
			</div>
		</div>
	<?php 
    }
コード例 #12
0
 /**
  * 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;
     }
 }
コード例 #13
0
 /**
  * If it's a valid Jetpack module and configuration parameters have been sent, update it.
  *
  * @since 4.3.0
  *
  * @param WP_REST_Request $data {
  *     Array of parameters received by request.
  *
  *     @type string $slug Module slug.
  * }
  *
  * @return bool|WP_Error True if module was updated. Otherwise, a WP_Error instance with the corresponding error.
  */
 public function update_data($data)
 {
     // If it's null, we're trying to update many module options from different modules.
     if (is_null($data['slug'])) {
         // Value admitted by Jetpack_Core_Json_Api_Endpoints::get_updateable_data_list that will make it return all module options.
         // It will not be passed. It's just checked in this method to pass that method a string or array.
         $data['slug'] = 'any';
     } else {
         if (!Jetpack::is_module($data['slug'])) {
             return new WP_Error('not_found', esc_html__('The requested Jetpack module was not found.', 'jetpack'), array('status' => 404));
         }
         if (!Jetpack::is_module_active($data['slug'])) {
             return new WP_Error('inactive', esc_html__('The requested Jetpack module is inactive.', 'jetpack'), array('status' => 409));
         }
     }
     // Get parameters to update the module.
     $params = $data->get_json_params();
     // Exit if no parameters were passed.
     if (!is_array($params)) {
         return new WP_Error('missing_options', esc_html__('Missing options.', 'jetpack'), array('status' => 404));
     }
     // Get available module options.
     $options = Jetpack_Core_Json_Api_Endpoints::get_updateable_data_list('any' === $data['slug'] ? $params : $data['slug']);
     // Prepare to toggle module if needed
     $toggle_module = new Jetpack_Core_API_Module_Toggle_Endpoint(new Jetpack_IXR_Client());
     // Options that are invalid or failed to update.
     $invalid = array_keys(array_diff_key($params, $options));
     $not_updated = array();
     // Remove invalid options
     $params = array_intersect_key($params, $options);
     // Used if response is successful. The message can be overwritten and additional data can be added here.
     $response = array('code' => 'success', 'message' => esc_html__('The requested Jetpack data updates were successful.', 'jetpack'));
     // If there are modules to activate, activate them first so they're ready when their options are set.
     foreach ($params as $option => $value) {
         if ('modules' === $options[$option]['jp_group']) {
             // Used if there was an error. Can be overwritten with specific error messages.
             $error = '';
             // Set to true if the module toggling was successful.
             $updated = false;
             // Check if user can toggle the module.
             if ($toggle_module->can_request()) {
                 // Activate or deactivate the module according to the value passed.
                 $toggle_result = $value ? $toggle_module->activate_module($option) : $toggle_module->deactivate_module($option);
                 if (is_wp_error($toggle_result)) {
                     $error = $toggle_result->get_error_message();
                 } else {
                     $updated = true;
                 }
             } else {
                 $error = Jetpack_Core_Json_Api_Endpoints::$user_permissions_error_msg;
             }
             // The module was not toggled.
             if (!$updated) {
                 $not_updated[$option] = $error;
             }
             // Remove module from list so we don't go through it again.
             unset($params[$option]);
         }
     }
     foreach ($params as $option => $value) {
         // Used if there was an error. Can be overwritten with specific error messages.
         $error = '';
         // Set to true if the option update was successful.
         $updated = false;
         // Get option attributes, including the group it belongs to.
         $option_attrs = $options[$option];
         // If this is a module option and the related module isn't active for any reason, continue with the next one.
         if ('settings' !== $option_attrs['jp_group']) {
             if (!Jetpack::is_module($option_attrs['jp_group'])) {
                 $not_updated[$option] = esc_html__('The requested Jetpack module was not found.', 'jetpack');
                 continue;
             }
             if (!Jetpack::is_module_active($option_attrs['jp_group'])) {
                 $not_updated[$option] = esc_html__('The requested Jetpack module is inactive.', 'jetpack');
                 continue;
             }
         }
         // Properly cast value based on its type defined in endpoint accepted args.
         $value = Jetpack_Core_Json_Api_Endpoints::cast_value($value, $option_attrs);
         switch ($option) {
             case 'monitor_receive_notifications':
                 $monitor = new Jetpack_Monitor();
                 // If we got true as response, consider it done.
                 $updated = true === $monitor->update_option_receive_jetpack_monitor_notification($value);
                 break;
             case 'post_by_email_address':
                 if ('create' == $value) {
                     $result = $this->_process_post_by_email('jetpack.createPostByEmailAddress', esc_html__('Unable to create the Post by Email address. Please try again later.', 'jetpack'));
                 } elseif ('regenerate' == $value) {
                     $result = $this->_process_post_by_email('jetpack.regeneratePostByEmailAddress', esc_html__('Unable to regenerate the Post by Email address. Please try again later.', 'jetpack'));
                 } elseif ('delete' == $value) {
                     $result = $this->_process_post_by_email('jetpack.deletePostByEmailAddress', esc_html__('Unable to delete the Post by Email address. Please try again later.', 'jetpack'));
                 } else {
                     $result = false;
                 }
                 // If we got an email address (create or regenerate) or 1 (delete), consider it done.
                 if (preg_match('/[a-z0-9]+@post.wordpress.com/', $result)) {
                     $response[$option] = $result;
                     $updated = true;
                 } elseif (1 == $result) {
                     $updated = true;
                 } elseif (is_array($result) && isset($result['message'])) {
                     $error = $result['message'];
                 }
                 break;
             case 'jetpack_protect_key':
                 $protect = Jetpack_Protect_Module::instance();
                 if ('create' == $value) {
                     $result = $protect->get_protect_key();
                 } else {
                     $result = false;
                 }
                 // If we got one of Protect keys, consider it done.
                 if (preg_match('/[a-z0-9]{40,}/i', $result)) {
                     $response[$option] = $result;
                     $updated = true;
                 }
                 break;
             case 'jetpack_protect_global_whitelist':
                 $updated = jetpack_protect_save_whitelist(explode(PHP_EOL, str_replace(array(' ', ','), array('', "\n"), $value)));
                 if (is_wp_error($updated)) {
                     $error = $updated->get_error_message();
                 }
                 break;
             case 'show_headline':
             case 'show_thumbnails':
                 $grouped_options = $grouped_options_current = (array) Jetpack_Options::get_option('relatedposts');
                 $grouped_options[$option] = $value;
                 // If option value was the same, consider it done.
                 $updated = $grouped_options_current != $grouped_options ? Jetpack_Options::update_option('relatedposts', $grouped_options) : true;
                 break;
             case 'google':
             case 'bing':
             case 'pinterest':
             case 'yandex':
                 $grouped_options = $grouped_options_current = (array) get_option('verification_services_codes');
                 $grouped_options[$option] = $value;
                 // If option value was the same, consider it done.
                 $updated = $grouped_options_current != $grouped_options ? update_option('verification_services_codes', $grouped_options) : true;
                 break;
             case 'sharing_services':
                 if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
                     break;
                 }
                 $sharer = new Sharing_Service();
                 // If option value was the same, consider it done.
                 $updated = $value != $sharer->get_blog_services() ? $sharer->set_blog_services($value['visible'], $value['hidden']) : true;
                 break;
             case 'button_style':
             case 'sharing_label':
             case 'show':
                 if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
                     break;
                 }
                 $sharer = new Sharing_Service();
                 $grouped_options = $sharer->get_global_options();
                 $grouped_options[$option] = $value;
                 $updated = $sharer->set_global_options($grouped_options);
                 break;
             case 'custom':
                 if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
                     break;
                 }
                 $sharer = new Sharing_Service();
                 $updated = $sharer->new_service(stripslashes($value['sharing_name']), stripslashes($value['sharing_url']), stripslashes($value['sharing_icon']));
                 // Return new custom service
                 $response[$option] = $updated;
                 break;
             case 'sharing_delete_service':
                 if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
                     break;
                 }
                 $sharer = new Sharing_Service();
                 $updated = $sharer->delete_service($value);
                 break;
             case 'jetpack-twitter-cards-site-tag':
                 $value = trim(ltrim(strip_tags($value), '@'));
                 $updated = get_option($option) !== $value ? update_option($option, $value) : true;
                 break;
             case 'onpublish':
             case 'onupdate':
             case 'Bias Language':
             case 'Cliches':
             case 'Complex Expression':
             case 'Diacritical Marks':
             case 'Double Negative':
             case 'Hidden Verbs':
             case 'Jargon Language':
             case 'Passive voice':
             case 'Phrases to Avoid':
             case 'Redundant Expression':
             case 'guess_lang':
                 if (in_array($option, array('onpublish', 'onupdate'))) {
                     $atd_option = 'AtD_check_when';
                 } elseif ('guess_lang' == $option) {
                     $atd_option = 'AtD_guess_lang';
                     $option = 'true';
                 } else {
                     $atd_option = 'AtD_options';
                 }
                 $user_id = get_current_user_id();
                 $grouped_options_current = AtD_get_options($user_id, $atd_option);
                 unset($grouped_options_current['name']);
                 $grouped_options = $grouped_options_current;
                 if ($value && !isset($grouped_options[$option])) {
                     $grouped_options[$option] = $value;
                 } elseif (!$value && isset($grouped_options[$option])) {
                     unset($grouped_options[$option]);
                 }
                 // If option value was the same, consider it done, otherwise try to update it.
                 $options_to_save = implode(',', array_keys($grouped_options));
                 $updated = $grouped_options != $grouped_options_current ? AtD_update_setting($user_id, $atd_option, $options_to_save) : true;
                 break;
             case 'ignored_phrases':
             case 'unignore_phrase':
                 $user_id = get_current_user_id();
                 $atd_option = 'AtD_ignored_phrases';
                 $grouped_options = $grouped_options_current = explode(',', AtD_get_setting($user_id, $atd_option));
                 if ('ignored_phrases' == $option) {
                     $grouped_options = explode(',', $value);
                 } else {
                     $index = array_search($value, $grouped_options);
                     if (false !== $index) {
                         unset($grouped_options[$index]);
                         $grouped_options = array_values($grouped_options);
                     }
                 }
                 $ignored_phrases = implode(',', array_filter(array_map('strip_tags', $grouped_options)));
                 $updated = $grouped_options != $grouped_options_current ? AtD_update_setting($user_id, $atd_option, $ignored_phrases) : true;
                 break;
             case 'admin_bar':
             case 'roles':
             case 'count_roles':
             case 'blog_id':
             case 'do_not_track':
             case 'hide_smile':
             case 'version':
                 $grouped_options = $grouped_options_current = (array) get_option('stats_options');
                 $grouped_options[$option] = $value;
                 // If option value was the same, consider it done.
                 $updated = $grouped_options_current != $grouped_options ? update_option('stats_options', $grouped_options) : true;
                 break;
             case Jetpack_Core_Json_Api_Endpoints::holiday_snow_option_name():
                 $updated = get_option($option) != $value ? update_option($option, (bool) $value ? 'letitsnow' : '') : true;
                 break;
             case 'wp_mobile_featured_images':
             case 'wp_mobile_excerpt':
                 $value = 'enabled' === $value ? '1' : '0';
                 // break intentionally omitted
             // break intentionally omitted
             default:
                 // If option value was the same, consider it done.
                 $updated = get_option($option) != $value ? update_option($option, $value) : true;
                 break;
         }
         // The option was not updated.
         if (!$updated) {
             $not_updated[$option] = $error;
         }
     }
     if (empty($invalid) && empty($not_updated)) {
         // The option was updated.
         return rest_ensure_response($response);
     } else {
         $invalid_count = count($invalid);
         $not_updated_count = count($not_updated);
         $error = '';
         if ($invalid_count > 0) {
             $error = sprintf(_n('Invalid option: %s.', 'Invalid options: %s.', $invalid_count, 'jetpack'), join(', ', $invalid));
         }
         if ($not_updated_count > 0) {
             $not_updated_messages = array();
             foreach ($not_updated as $not_updated_option => $not_updated_message) {
                 if (!empty($not_updated_message)) {
                     $not_updated_messages[] = sprintf(__('Extra info for %1$s: %2$s', 'jetpack'), $not_updated_option, $not_updated_message);
                 }
             }
             if (!empty($error)) {
                 $error .= ' ';
             }
             $error .= sprintf(_n('Option not updated: %s.', 'Options not updated: %s.', $not_updated_count, 'jetpack'), join(', ', array_keys($not_updated)));
             if (!empty($not_updated_messages)) {
                 $error .= ' ' . join('. ', $not_updated_messages);
             }
         }
         // There was an error because some options were updated but others were invalid or failed to update.
         return new WP_Error('some_updated', esc_html($error), array('status' => 400));
     }
 }
コード例 #14
0
 /**
  * If it's a valid Jetpack module and configuration parameters have been sent, update it.
  *
  * @since 4.1.0
  *
  * @param WP_REST_Request $data {
  *     Array of parameters received by request.
  *
  *     @type string $slug Module slug.
  * }
  *
  * @return bool|WP_Error True if module was updated. Otherwise, a WP_Error instance with the corresponding error.
  */
 public static function update_module($data)
 {
     if (!Jetpack::is_module($data['slug'])) {
         return new WP_Error('not_found', esc_html__('The requested Jetpack module was not found.', 'jetpack'), array('status' => 404));
     }
     if (!Jetpack::is_module_active($data['slug'])) {
         return new WP_Error('inactive', esc_html__('The requested Jetpack module is inactive.', 'jetpack'), array('status' => 409));
     }
     // Get parameters to update the module.
     $param = $data->get_json_params();
     // Exit if no parameters were passed.
     if (!is_array($param)) {
         return new WP_Error('missing_option', esc_html__('Missing option.', 'jetpack'), array('status' => 404));
     }
     // Get option name and value.
     $option = key($param);
     $value = current($param);
     // Get available module options.
     $options = self::get_module_available_options();
     // If option is invalid, don't go any further.
     if (!in_array($option, array_keys($options))) {
         return new WP_Error('invalid_param', esc_html(sprintf(__('The option %s is invalid for this module.', 'jetpack'), $option)), array('status' => 404));
     }
     // Used if response is successful. The message can be overwritten and additional data can be added here.
     $response = array('code' => 'success', 'message' => esc_html__('The requested Jetpack module was updated.', 'jetpack'));
     // Used if there was an error. Can be overwritten with specific error messages.
     /* Translators: the variable is a module option name. */
     $error = sprintf(__('The option %s was not updated.', 'jetpack'), $option);
     // Set to true if the option update was successful.
     $updated = false;
     // Properly cast value based on its type defined in endpoint accepted args.
     $value = self::cast_value($value, $options[$option]);
     switch ($option) {
         case 'monitor_receive_notifications':
             $monitor = new Jetpack_Monitor();
             // If we got true as response, consider it done.
             $updated = true === $monitor->update_option_receive_jetpack_monitor_notification($value);
             break;
         case 'post_by_email_address':
             if ('create' == $value) {
                 $result = self::_process_post_by_email('jetpack.createPostByEmailAddress', esc_html__('Unable to create the Post by Email address. Please try again later.', 'jetpack'));
             } elseif ('regenerate' == $value) {
                 $result = self::_process_post_by_email('jetpack.regeneratePostByEmailAddress', esc_html__('Unable to regenerate the Post by Email address. Please try again later.', 'jetpack'));
             } elseif ('delete' == $value) {
                 $result = self::_process_post_by_email('jetpack.deletePostByEmailAddress', esc_html__('Unable to delete the Post by Email address. Please try again later.', 'jetpack'));
             } else {
                 $result = false;
             }
             // If we got an email address (create or regenerate) or 1 (delete), consider it done.
             if (preg_match('/[a-z0-9]+@post.wordpress.com/', $result)) {
                 $response[$option] = $result;
                 $updated = true;
             } elseif (1 == $result) {
                 $updated = true;
             } elseif (is_array($result) && isset($result['message'])) {
                 $error = $result['message'];
             }
             break;
         case 'jetpack_protect_key':
             $protect = Jetpack_Protect_Module::instance();
             if ('create' == $value) {
                 $result = $protect->get_protect_key();
             } else {
                 $result = false;
             }
             // If we got one of Protect keys, consider it done.
             if (preg_match('/[a-z0-9]{40,}/i', $result)) {
                 $response[$option] = $result;
                 $updated = true;
             }
             break;
         case 'jetpack_protect_global_whitelist':
             $updated = jetpack_protect_save_whitelist(explode(PHP_EOL, str_replace(' ', '', $value)));
             if (is_wp_error($updated)) {
                 $error = $updated->get_error_message();
             }
             break;
         case 'show_headline':
         case 'show_thumbnails':
             $grouped_options = $grouped_options_current = Jetpack_Options::get_option('relatedposts');
             $grouped_options[$option] = $value;
             // If option value was the same, consider it done.
             $updated = $grouped_options_current != $grouped_options ? Jetpack_Options::update_option('relatedposts', $grouped_options) : true;
             break;
         case 'google':
         case 'bing':
         case 'pinterest':
             $grouped_options = $grouped_options_current = get_option('verification_services_codes');
             $grouped_options[$option] = $value;
             // If option value was the same, consider it done.
             $updated = $grouped_options_current != $grouped_options ? update_option('verification_services_codes', $grouped_options) : true;
             break;
         case 'sharing_services':
             $sharer = new Sharing_Service();
             // If option value was the same, consider it done.
             $updated = $value != $sharer->get_blog_services() ? $sharer->set_blog_services($value['visible'], $value['hidden']) : true;
             break;
         case 'button_style':
         case 'sharing_label':
         case 'show':
             $sharer = new Sharing_Service();
             $grouped_options = $sharer->get_global_options();
             $grouped_options[$option] = $value;
             $updated = $sharer->set_global_options($grouped_options);
             break;
         case 'custom':
             $sharer = new Sharing_Service();
             $updated = $sharer->new_service(stripslashes($value['sharing_name']), stripslashes($value['sharing_url']), stripslashes($value['sharing_icon']));
             // Return new custom service
             $response[$option] = $updated;
             break;
         case 'sharing_delete_service':
             $sharer = new Sharing_Service();
             $updated = $sharer->delete_service($value);
             break;
         case 'jetpack-twitter-cards-site-tag':
             $value = trim(ltrim(strip_tags($value), '@'));
             $updated = get_option($option) !== $value ? update_option($option, $value) : true;
             break;
         case 'onpublish':
         case 'onupdate':
         case 'Bias Language':
         case 'Cliches':
         case 'Complex Expression':
         case 'Diacritical Marks':
         case 'Double Negative':
         case 'Hidden Verbs':
         case 'Jargon Language':
         case 'Passive voice':
         case 'Phrases to Avoid':
         case 'Redundant Expression':
         case 'guess_lang':
             if (in_array($option, array('onpublish', 'onupdate'))) {
                 $atd_option = 'AtD_check_when';
             } elseif ('guess_lang' == $option) {
                 $atd_option = 'AtD_guess_lang';
                 $option = 'true';
             } else {
                 $atd_option = 'AtD_options';
             }
             $user_id = get_current_user_id();
             $grouped_options_current = AtD_get_options($user_id, $atd_option);
             unset($grouped_options_current['name']);
             $grouped_options = $grouped_options_current;
             if ($value && !isset($grouped_options[$option])) {
                 $grouped_options[$option] = $value;
             } elseif (!$value && isset($grouped_options[$option])) {
                 unset($grouped_options[$option]);
             }
             // If option value was the same, consider it done, otherwise try to update it.
             $options_to_save = implode(',', array_keys($grouped_options));
             $updated = $grouped_options != $grouped_options_current ? AtD_update_setting($user_id, $atd_option, $options_to_save) : true;
             break;
         case 'ignored_phrases':
         case 'unignore_phrase':
             $user_id = get_current_user_id();
             $atd_option = 'AtD_ignored_phrases';
             $grouped_options = $grouped_options_current = explode(',', AtD_get_setting($user_id, $atd_option));
             if ('ignored_phrases' == $option) {
                 $grouped_options[] = $value;
             } else {
                 $index = array_search($value, $grouped_options);
                 if (false !== $index) {
                     unset($grouped_options[$index]);
                     $grouped_options = array_values($grouped_options);
                 }
             }
             $ignored_phrases = implode(',', array_filter(array_map('strip_tags', $grouped_options)));
             $updated = $grouped_options != $grouped_options_current ? AtD_update_setting($user_id, $atd_option, $ignored_phrases) : true;
             break;
         default:
             // If option value was the same, consider it done.
             $updated = get_option($option) != $value ? update_option($option, $value) : true;
             break;
     }
     // The option was not updated.
     if (!$updated) {
         return new WP_Error('module_option_not_updated', esc_html($error), array('status' => 400));
     }
     // The option was updated.
     return rest_ensure_response($response);
 }
 /**
  * Enqueue preview scripts.
  *
  * @since 4.5.0
  * @access public
  */
 public function enqueue_preview_scripts()
 {
     wp_enqueue_script('customize-partial-refresh-preview');
     $wp_scripts = wp_scripts();
     $wp_styles = wp_styles();
     /*
      * Core does not rebuild MediaElement.js audio and video players when DOM subtrees change.
      * The Jetpack Infinite Scroll handles this when a post-load event is triggered.
      * Ideally this should be incorporated into Core.
      *
      * Hard-coded reference to a Jetpack module's event is not relevant for #coremerge.
      */
     if (class_exists('Jetpack')) {
         $exports = array();
         $handle = 'customize-partial-jetpack-support';
         $src = $this->dir_url . 'js/plugin-support/jetpack.js';
         $deps = array('customize-partial-refresh-preview');
         $in_footer = true;
         wp_enqueue_script($handle, $src, $deps, $this->get_version(), $in_footer);
         if (Jetpack::is_module_active('infinite-scroll')) {
             $exports['infiniteScroll'] = array('themeSupport' => current_theme_supports('infinite-scroll'));
         }
         if (Jetpack::is_module('widgets')) {
             $exports['widgets'] = array('scripts' => array('google-maps' => array('src' => 'https://maps.googleapis.com/maps/api/js?sensor=false'), 'contact-info-map-js' => array('src' => plugins_url('modules/widgets/contact-info/contact-info-map.js', JETPACK__PLUGIN_FILE), 'deps' => array('jquery', 'google-maps'))), 'styles' => array('contact-info-map-css' => array('src' => plugins_url('modules/widgets/contact-info/contact-info-map.css', JETPACK__PLUGIN_FILE))));
         }
         wp_scripts()->add_data($handle, 'data', sprintf('var _customizeSelectiveRefreshJetpackExports = %s;', wp_json_encode($exports)));
     }
     add_action('wp_footer', array($this, 'export_preview_data'), 1000);
 }
コード例 #16
0
    function admin_page()
    {
        global $current_user;
        $is_connected = Jetpack::is_active();
        $user_token = Jetpack_Data::get_access_token($current_user->ID);
        $is_user_connected = $user_token && !is_wp_error($user_token);
        $is_master_user = $current_user->ID == Jetpack_Options::get_option('master_user');
        //slim// Clear annoying banners and foot prints:
        ?>
		<div class="wrap" id="jetpack-settings">

			<?php 
        if (isset($_GET['configure']) && Jetpack::is_module($_GET['configure']) && current_user_can('manage_options')) {
            $this->admin_screen_configure_module($_GET['configure']);
        } else {
            $this->admin_screen_list_modules();
        }
        ?>

			<div id="jetpack-configuration" style="display:none;">
				<p><img width="16" src="<?php 
        echo esc_url(plugins_url('_inc/images/wpspin_light-2x.gif', __FILE__));
        ?>
" alt="Loading ..." /></p>
			</div>
		</div>
	<?php 
    }
コード例 #17
0
 /**
  * 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;
     }
 }
コード例 #18
0
 function admin_head()
 {
     if (isset($_GET['configure']) && Jetpack::is_module($_GET['configure']) && current_user_can('manage_options')) {
         do_action('jetpack_module_configuration_head_' . $_GET['configure']);
     }
 }
コード例 #19
0
    /**
     * This is the old pre-3.0 admin page.  It is replaced by the Jetpack_Admin class.
     * Tentatively left here for comparison purposes.
     */
    function admin_page()
    {
        global $current_user;
        $is_connected = Jetpack::is_active();
        $user_token = Jetpack_Data::get_access_token($current_user->ID);
        $is_user_connected = $user_token && !is_wp_error($user_token);
        $is_master_user = $current_user->ID == Jetpack_Options::get_option('master_user');
        $can_reconnect_jpms = true;
        if (is_plugin_active_for_network('jetpack/jetpack.php')) {
            $jpms = Jetpack_Network::init();
            $can_reconnect_jpms = $jpms->get_option('sub-site-connection-override') ? 1 : 0;
        }
        ?>
		<div class="wrap" id="jetpack-settings">

			<div id="jp-header"<?php 
        if ($is_connected) {
            ?>
 class="small"<?php 
        }
        ?>
>
				<div id="jp-clouds">
					<?php 
        if ($is_connected && $can_reconnect_jpms) {
            ?>
					<div id="jp-disconnectors">
						<?php 
            if (current_user_can('jetpack_disconnect')) {
                ?>
						<div id="jp-disconnect" class="jp-disconnect">
							<a href="<?php 
                echo wp_nonce_url(Jetpack::admin_url('action=disconnect'), 'jetpack-disconnect');
                ?>
"><div class="deftext"><?php 
                _e('Connected to WordPress.com', 'jetpack');
                ?>
</div><div class="hovertext"><?php 
                _e('Disconnect from WordPress.com', 'jetpack');
                ?>
</div></a>
						</div>
						<?php 
            }
            ?>
						<?php 
            if ($is_user_connected && !$is_master_user) {
                ?>
						<div id="jp-unlink" class="jp-disconnect">
							<a href="<?php 
                echo wp_nonce_url(Jetpack::admin_url('action=unlink'), 'jetpack-unlink');
                ?>
"><div class="deftext"><?php 
                _e('User linked to WordPress.com', 'jetpack');
                ?>
</div><div class="hovertext"><?php 
                _e('Unlink user from WordPress.com', 'jetpack');
                ?>
</div></a>
						</div>
						<?php 
            }
            ?>
					</div>
					<?php 
        }
        ?>
					<h3><?php 
        _e('Jetpack by WordPress.com', 'jetpack');
        ?>
</h3>
					<?php 
        if (!$is_connected) {
            ?>
					<div id="jp-notice">
						<p><?php 
            _e('Jetpack supercharges your self-hosted WordPress site with the awesome cloud power of WordPress.com.', 'jetpack');
            ?>
</p>
					</div>
					<?php 
        }
        ?>
				</div>
			</div>

			<h2 style="display: none"></h2> <!-- For WP JS message relocation -->

			<?php 
        Jetpack::init()->load_view('admin/network-activated-notice.php');
        ?>

			<?php 
        do_action('jetpack_notices');
        ?>

			<?php 
        // If the connection has not been made then show the marketing text.
        if (!$can_reconnect_jpms && !$is_connected) {
            ?>
			<div id="message" class="updated jetpack-message jp-connect jp-multisite" style="display:block !important">
				<div class="jetpack-wrap-container">
					<div class="jetpack-text-container">
						<h4>
							<p><?php 
            _e('To use Jetpack please contact your WordPress administrator to connect it for you.', 'jetpack');
            ?>
</p>
						</h4>
					</div>
				</div>
			</div> <?php 
        }
        if (!Jetpack::is_development_mode() && $can_reconnect_jpms) {
            ?>
				<?php 
            if (!$is_connected) {
                $dismiss_and_deactivate_url = wp_nonce_url(Jetpack::admin_url('?page=jetpack&jetpack-notice=dismiss'), 'jetpack-deactivate');
                ?>
				<div id="message" class="updated jetpack-message jp-connect" style="display:block !important;">
					<div id="jp-dismiss" class="jetpack-close-button-container">
						<a class="jetpack-close-button" href="<?php 
                echo esc_url($dismiss_and_deactivate_url);
                ?>
"><?php 
                _e('Dismiss this notice.', 'jetpack');
                ?>
</a>
					</div>
					<div class="jetpack-wrap-container">
						<div class="jetpack-text-container">
							<h4>
								<p><?php 
                _e('To enable all of the Jetpack features you&#8217;ll need to connect your website to WordPress.com using the button to the right. Once you&#8217;ve made the connection you&#8217;ll activate all the delightful features below.', 'jetpack');
                ?>
</p>
							</h4>
						</div>
						<div class="jetpack-install-container">
							<p class="submit"><a href="<?php 
                echo $this->build_connect_url();
                ?>
" class="button-connector" id="wpcom-connect"><?php 
                _e('Connect to WordPress.com', 'jetpack');
                ?>
</a></p>
						</div>
					</div>
				</div>

				<?php 
            } else {
                ?>
					<?php 
                /* TODO: if not master user, show user disconnect button? */
                ?>
				<?php 
            }
            ?>
			<?php 
        }
        // ! Jetpack::is_development_mode()
        ?>





			<?php 
        if (Jetpack::is_active() && !Jetpack::is_development_mode() && !$is_user_connected) {
            ?>

				<div id="message" class="updated jetpack-message jp-connect" style="display:block !important;">
					<div class="jetpack-wrap-container">
						<div class="jetpack-text-container">
							<h4>
								<p><?php 
            _e('To enable all of the Jetpack features you&#8217;ll need to link your account here to your WordPress.com account using the button to the right.', 'jetpack');
            ?>
</p>
							</h4>
						</div>
						<div class="jetpack-install-container">
							<p class="submit"><a href="<?php 
            echo $this->build_connect_url();
            ?>
" class="button-connector" id="wpcom-connect"><?php 
            _e('Link account with WordPress.com', 'jetpack');
            ?>
</a></p>
						</div>
					</div>
				</div>

			<?php 
        }
        ?>




			<?php 
        if (isset($_GET['configure']) && Jetpack::is_module($_GET['configure']) && current_user_can('manage_options')) {
            $this->admin_screen_configure_module($_GET['configure']);
        } else {
            $this->admin_screen_list_modules();
        }
        ?>

			<div id="survey" class="jp-survey">
				<div class="jp-survey-container">
					<div class="jp-survey-text">
						<h4><?php 
        _e('Have feedback on Jetpack?', 'jetpack');
        ?>
</h4>
						<br />
						<?php 
        _e('Answer a short survey to let us know how we&#8217;re doing and what to add in the future.', 'jetpack');
        ?>
					</div>
					<div class="jp-survey-button-container">
						<p class="submit"><?php 
        printf('<a id="jp-survey-button" class="button-primary" target="_blank" href="%1$s">%2$s</a>', 'http://jetpack.me/survey/?rel=' . JETPACK__VERSION, __('Take Survey', 'jetpack'));
        ?>
</p>
					</div>
				</div>
			</div>

			<?php 
        if ($is_connected && $this->current_user_is_connection_owner()) {
            ?>
				<p id="news-sub"><?php 
            _e('Checking email updates status&hellip;', 'jetpack');
            ?>
</p>
				<script type="text/javascript">
				jQuery(document).ready(function($){
					$.get( ajaxurl, { action: 'jetpack-check-news-subscription', rand: jQuery.now().toString() + Math.random().toString() }, function( data ) {
						if ( 'subscribed' == data ) {
							$( '#news-sub' ).html( '<?php 
            printf(esc_js(_x('You are currently subscribed to email updates. %s', '%s = Unsubscribe link', 'jetpack')), '<a href="#" class="jp-news-link button">' . esc_js(__('Unsubscribe', 'jetpack')) . '</a>');
            ?>
' );
						} else {
							$( '#news-sub' ).html( '<?php 
            printf(esc_js(_x('Want to receive updates about Jetpack by email? %s', '%s = Subscribe link', 'jetpack')), '<a href="#" class="jp-news-link button-primary">' . esc_js(__('Subscribe', 'jetpack')) . '</a>');
            ?>
' );
						}
						$( '.jp-news-link' ).click( function() {
							$( '#news-sub' ).append( ' <img src="<?php 
            echo esc_js(esc_url(admin_url('images/loading.gif')));
            ?>
" align="absmiddle" id="jp-news-loading" />' );
							$.get( ajaxurl, { action: 'jetpack-subscribe-to-news', rand: jQuery.now().toString() + Math.random().toString() }, function( data ) {
								if ( 'subscribed' == data ) {
									$( '#news-sub' ).text( '<?php 
            echo esc_js(__('You have been subscribed to receive email updates.', 'jetpack'));
            ?>
' );
								} else {
									$( '#news-sub' ).text( '<?php 
            echo esc_js(__('You will no longer receive email updates about Jetpack.', 'jetpack'));
            ?>
' );
								}
								$( '#jp-news-loading' ).remove();
							} );
							return false;
						} );
					} );
				} );
				</script>
			<?php 
        }
        ?>

			<div id="jp-footer">
				<p class="automattic"><?php 
        _e('An <span>Automattic</span> Airline', 'jetpack');
        ?>
</p>
				<p class="small">
					<a href="http://jetpack.me/" target="_blank">Jetpack <?php 
        echo esc_html(JETPACK__VERSION);
        ?>
</a> |
					<a href="http://automattic.com/privacy/" target="_blank"><?php 
        _e('Privacy Policy', 'jetpack');
        ?>
</a> |
					<a href="http://wordpress.com/tos/" target="_blank"><?php 
        _e('Terms of Service', 'jetpack');
        ?>
</a> |
<?php 
        if (current_user_can('manage_options')) {
            ?>
					<a href="<?php 
            echo Jetpack::admin_url(array('page' => 'jetpack-debugger'));
            ?>
"><?php 
            _e('Debug', 'jetpack');
            ?>
</a> |
<?php 
        }
        ?>
					<a href="http://jetpack.me/support/" target="_blank"><?php 
        _e('Support', 'jetpack');
        ?>
</a>
				</p>
			</div>

			<div id="jetpack-configuration" style="display:none;">
				<p><img width="16" src="<?php 
        echo esc_url(plugins_url('_inc/images/wpspin_light-2x.gif', __FILE__));
        ?>
" alt="Loading ..." /></p>
			</div>
		</div>
	<?php 
    }
コード例 #20
0
 protected static function get_module($module_slug)
 {
     if (!Jetpack::is_module($module_slug)) {
         return new WP_Error('unknown_jetpack_module', sprintf(__('Module not found: `%s`.', 'jetpack'), $module_slug), 404);
     }
     return self::format_module($module_slug);
 }