コード例 #1
0
ファイル: network-settings.php プロジェクト: kanei/vantuch.cz
 />
					<label for="sub-site-override"><?php 
_e('Allow individual site administrators to manage their own connections (connect and disconnect) to <a href="//wordpress.com">WordPress.com</a>', 'jetpack');
?>
</label>
				</td>
			</tr>

			<tr valign="top">
				<th scope="row"><label for="sub-site-override"><?php 
_e('Protect whitelist', 'jetpack');
?>
</label></th>
				<td>
					<p><strong><?php 
printf(__('Your current IP: %s', 'jetpack'), jetpack_protect_get_ip());
?>
</strong></p>
					<textarea name="global-whitelist" style="width: 100%;" rows="8"><?php 
echo implode(PHP_EOL, $jetpack_protect_whitelist['global']);
?>
</textarea> <br />
					<label for="global-whitelist"><?php 
_e('IPv4 and IPv6 are acceptable. <br />To specify a range, enter the low value and high value separated by a dash. Example: 12.12.12.1-12.12.12.100', 'jetpack');
?>
</label>
				</td>
			</tr>
<?php 
/* Remove the toggles for 2.9, re-evaluate how they're done and added for a 3.0 release. They don't feel quite right yet.
			<tr>
コード例 #2
0
ファイル: protect.php プロジェクト: dtekcth/datateknologer.se
 /**
  * Calls over to the api using wp_remote_post
  *
  * @param string $action 'check_ip', 'check_key', or 'failed_attempt'
  * @param array  $request Any custom data to post to the api
  *
  * @return array
  */
 function protect_call($action = 'check_ip', $request = array())
 {
     global $wp_version, $wpdb, $current_user;
     $api_key = get_site_option('jetpack_protect_key');
     $user_agent = "WordPress/{$wp_version} | Jetpack/" . constant('JETPACK__VERSION');
     $request['action'] = $action;
     $request['ip'] = jetpack_protect_get_ip();
     $request['host'] = $this->get_local_host();
     $request['headers'] = json_encode($this->get_headers());
     $request['jetpack_version'] = constant('JETPACK__VERSION');
     $request['wordpress_version'] = strval($wp_version);
     $request['api_key'] = $api_key;
     $request['multisite'] = "0";
     if (is_multisite()) {
         $request['multisite'] = get_blog_count();
     }
     $args = array('body' => $request, 'user-agent' => $user_agent, 'httpversion' => '1.0', 'timeout' => 15);
     $response_json = wp_remote_post($this->get_api_host(), $args);
     $this->last_response_raw = $response_json;
     $headers = $this->get_headers();
     $header_hash = md5(json_encode($headers));
     $transient_name = 'jpp_li_' . $header_hash;
     $this->delete_transient($transient_name);
     if (is_array($response_json)) {
         $response = json_decode($response_json['body'], true);
     }
     if (isset($response['blocked_attempts']) && $response['blocked_attempts']) {
         update_site_option('jetpack_protect_blocked_attempts', $response['blocked_attempts']);
     }
     if (isset($response['status']) && !isset($response['error'])) {
         $response['expire'] = time() + $response['seconds_remaining'];
         $this->set_transient($transient_name, $response, $response['seconds_remaining']);
         $this->delete_transient('brute_use_math');
     } else {
         // Fallback to Math Captcha if no response from API host
         $this->set_transient('brute_use_math', 1, 600);
         $response['status'] = 'ok';
         $response['math'] = true;
     }
     if (isset($response['error'])) {
         update_site_option('jetpack_protect_error', $response['error']);
     } else {
         delete_site_option('jetpack_protect_error');
     }
     return $response;
 }
コード例 #3
0
 function page_admin_scripts()
 {
     if ($this->is_redirecting) {
         return;
         // No need for scripts on a fallback page
     }
     $is_dev_mode = Jetpack::is_development_mode();
     // Enqueue jp.js and localize it
     wp_enqueue_script('react-plugin', plugins_url('_inc/build/admin.js', JETPACK__PLUGIN_FILE), array(), JETPACK__VERSION, true);
     if (!$is_dev_mode) {
         // Required for Analytics
         wp_enqueue_script('jp-tracks', '//stats.wp.com/w.js', array(), gmdate('YW'), true);
     }
     $localeSlug = explode('_', get_locale());
     $localeSlug = $localeSlug[0];
     // Collecting roles that can view site stats
     $stats_roles = array();
     $enabled_roles = function_exists('stats_get_option') ? stats_get_option('roles') : array('administrator');
     foreach (get_editable_roles() as $slug => $role) {
         $stats_roles[$slug] = array('name' => translate_user_role($role['name']), 'canView' => is_array($enabled_roles) ? in_array($slug, $enabled_roles, true) : false);
     }
     $response = rest_do_request(new WP_REST_Request('GET', '/jetpack/v4/module/all'));
     $modules = $response->get_data();
     // Preparing translated fields for JSON encoding by transforming all HTML entities to
     // respective characters.
     foreach ($modules as $slug => $data) {
         $modules[$slug]['name'] = html_entity_decode($data['name']);
         $modules[$slug]['description'] = html_entity_decode($data['description']);
         $modules[$slug]['short_description'] = html_entity_decode($data['short_description']);
         $modules[$slug]['long_description'] = html_entity_decode($data['long_description']);
     }
     // Add objects to be passed to the initial state of the app
     wp_localize_script('react-plugin', 'Initial_State', array('WP_API_root' => esc_url_raw(rest_url()), 'WP_API_nonce' => wp_create_nonce('wp_rest'), 'pluginBaseUrl' => plugins_url('', JETPACK__PLUGIN_FILE), 'connectionStatus' => array('isActive' => Jetpack::is_active(), 'isStaging' => Jetpack::is_staging_site(), 'devMode' => array('isActive' => $is_dev_mode, 'constant' => defined('JETPACK_DEV_DEBUG') && JETPACK_DEV_DEBUG, 'url' => site_url() && false === strpos(site_url(), '.'), 'filter' => apply_filters('jetpack_development_mode', false)), 'isPublic' => '1' == get_option('blog_public'), 'isInIdentityCrisis' => Jetpack::validate_sync_error_idc_option()), 'dismissedNotices' => $this->get_dismissed_jetpack_notices(), 'isDevVersion' => Jetpack::is_development_version(), 'currentVersion' => JETPACK__VERSION, 'happinessGravIds' => jetpack_get_happiness_gravatar_ids(), 'getModules' => $modules, 'showJumpstart' => jetpack_show_jumpstart(), 'rawUrl' => Jetpack::build_raw_urls(get_home_url()), 'adminUrl' => esc_url(admin_url()), 'stats' => array('data' => array('general' => false, 'day' => false, 'week' => false, 'month' => false), 'roles' => $stats_roles), 'settingNames' => array('jetpack_holiday_snow_enabled' => function_exists('jetpack_holiday_snow_option_name') ? jetpack_holiday_snow_option_name() : false), 'userData' => array('currentUser' => jetpack_current_user_data()), 'locale' => $this->get_i18n_data(), 'localeSlug' => $localeSlug, 'jetpackStateNotices' => array('messageCode' => Jetpack::state('message'), 'errorCode' => Jetpack::state('error'), 'errorDescription' => Jetpack::state('error_description')), 'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(), 'currentIp' => function_exists('jetpack_protect_get_ip') ? jetpack_protect_get_ip() : false));
 }