Changeset 1738590 for jetpack/trunk/class.jetpack.php
- Timestamp:
- 09/29/2017 07:04:55 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
jetpack/trunk/class.jetpack.php
r1736680 r1738590 1655 1655 */ 1656 1656 public static function load_modules() { 1657 if ( ! self::is_active() && !self::is_development_mode() ) { 1658 if ( ! is_multisite() || ! get_site_option( 'jetpack_protect_active' ) ) { 1659 return; 1660 } 1657 if ( 1658 ! self::is_active() 1659 && ! self::is_development_mode() 1660 && ( 1661 ! is_multisite() 1662 || ! get_site_option( 'jetpack_protect_active' ) 1663 ) 1664 ) { 1665 return; 1661 1666 } 1662 1667 … … 1735 1740 1736 1741 // Load module-specific code that is needed even when a module isn't active. Loaded here because code contained therein may need actions such as setup_theme. 1737 if ( Jetpack::is_active() || Jetpack::is_development_mode() ) 1738 require_once( JETPACK__PLUGIN_DIR . 'modules/module-extras.php' ); 1742 require_once( JETPACK__PLUGIN_DIR . 'modules/module-extras.php' ); 1739 1743 } 1740 1744 … … 5253 5257 $jpUser = get_user_by( 'email', $jpo->onboarding->jpUser ); 5254 5258 if ( is_a( $jpUser, 'WP_User' ) ) { 5255 $token_type = 'user'; 5256 $token->external_user_id = $jpUser->ID; 5259 wp_set_current_user( $jpUser->ID ); 5260 $user_can = is_multisite() 5261 ? current_user_can_for_blog( get_current_blog_id(), 'manage_options' ) 5262 : current_user_can( 'manage_options' ); 5263 if ( $user_can ) { 5264 $token_type = 'user'; 5265 $token->external_user_id = $jpUser->ID; 5266 } 5257 5267 } 5258 5268 } … … 6020 6030 * Checks whether the sync_error_idc option is valid or not, and if not, will do cleanup. 6021 6031 * 6032 6033 6034 6022 6035 * @return bool 6023 6036 */ … … 6043 6056 // Is the site opted in and does the stored sync_error_idc option match what we now generate? 6044 6057 $sync_error = Jetpack_Options::get_option( 'sync_error_idc' ); 6045 $local_options = self::get_sync_error_idc_option();6046 6058 if ( $idc_allowed && $sync_error && self::sync_idc_optin() ) { 6059 6047 6060 if ( $sync_error['home'] === $local_options['home'] && $sync_error['siteurl'] === $local_options['siteurl'] ) { 6048 6061 $is_valid = true; … … 6092 6105 * 6093 6106 * @since 4.4.0 6107 6094 6108 * 6095 6109 * @param array $response … … 6097 6111 */ 6098 6112 public static function get_sync_error_idc_option( $response = array() ) { 6099 require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-functions.php'; 6100 $local_options = array( 6101 'home' => Jetpack_Sync_Functions::home_url(), 6102 'siteurl' => Jetpack_Sync_Functions::site_url(), 6103 ); 6104 6105 $options = array_merge( $local_options, $response ); 6106 6107 $returned_values = array(); 6108 foreach( $options as $key => $option ) { 6109 if ( 'error_code' === $key ) { 6110 $returned_values[ $key ] = $option; 6111 continue; 6112 } 6113 6114 if ( is_wp_error( $normalized_url = self::normalize_url_protocol_agnostic( $option ) ) ) { 6115 continue; 6116 } 6117 6118 $returned_values[ $key ] = $normalized_url; 6113 $returned_values = get_transient( 'jetpack_idc_option' ); 6114 if ( false === $returned_values ) { 6115 require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-functions.php'; 6116 $local_options = array( 6117 'home' => Jetpack_Sync_Functions::home_url(), 6118 'siteurl' => Jetpack_Sync_Functions::site_url(), 6119 ); 6120 6121 $options = array_merge( $local_options, $response ); 6122 6123 $returned_values = array(); 6124 foreach( $options as $key => $option ) { 6125 if ( 'error_code' === $key ) { 6126 $returned_values[ $key ] = $option; 6127 continue; 6128 } 6129 6130 if ( is_wp_error( $normalized_url = self::normalize_url_protocol_agnostic( $option ) ) ) { 6131 continue; 6132 } 6133 6134 $returned_values[ $key ] = $normalized_url; 6135 } 6136 6137 set_transient( 'jetpack_idc_option', $returned_values, MINUTE_IN_SECONDS ); 6119 6138 } 6120 6139 … … 6728 6747 if ( self::is_active() ) { 6729 6748 add_action( 'jetpack_dashboard_widget', array( __CLASS__, 'dashboard_widget_footer' ), 999 ); 6730 $widget_title = __( 'Site Stats', 'jetpack' );6731 6749 } 6732 6750 … … 6734 6752 wp_add_dashboard_widget( 6735 6753 'jetpack_summary_widget', 6736 $widget_title,6754 , 6737 6755 array( __CLASS__, 'dashboard_widget' ) 6738 6756 );
Note: See TracChangeset
for help on using the changeset viewer.