本文整理汇总了PHP中WP_Http::get方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Http::get方法的具体用法?PHP WP_Http::get怎么用?PHP WP_Http::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Http
的用法示例。
在下文中一共展示了WP_Http::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testReturnsResultOfPassingWpDataToFactoryCreate
public function testReturnsResultOfPassingWpDataToFactoryCreate()
{
$wpData = ['response' => ['code' => 201]];
$this->wpHttp->get('uri', [])->willReturn($wpData);
$this->factory->create($wpData)->shouldBeCalled();
$this->request->get('uri');
}
示例2: provide_coordinates_for_address
/**
* @param string|array $address
*/
public function provide_coordinates_for_address($address)
{
if (is_array($address)) {
$address = implode(', ', array_filter(array_map('trim', $address)));
}
$address = trim($address);
if ($location = $this->get_resolved($address)) {
return $location;
}
$base_request_url = trailingslashit($this->get_google_api_base()) . $this->get_google_api_json_format();
$url = esc_url(add_query_arg(array('address' => $address), $base_request_url));
$response = $this->http->get($url);
if (is_wp_error($response)) {
return false;
}
$decoded = json_decode($response['body'], true);
if (empty($decoded['status']) || 'OK' !== $decoded['status']) {
return false;
}
if (empty($decoded['results'][0]['place_id']) || empty($decoded['results'][0]['geometry']['location']['lat']) || empty($decoded['results'][0]['geometry']['location']['lng'])) {
return false;
}
$location = $decoded['results'][0]['geometry']['location'];
$updated_transient = array_merge($this->get_transient(), array($address => $location));
set_transient(self::$transient_name, $updated_transient);
$this->transient = $updated_transient;
return $location;
}
示例3: getFeed
/**
* Gets an instagram feed
*
* @param string $username Username
* @param integer $limit Number of images to return
* @return array
*/
protected function getFeed($username = null, $limit = 5)
{
if (empty($username)) {
return array();
}
$results = get_transient('InstagramWidget::getFeed');
if ($results === false) {
$request = new WP_Http();
$response = $request->get("http://ink361.com/feed/user/{$username}");
$results = array();
if (!is_a($response, 'WP_Error')) {
try {
$resultsXml = new SimpleXMLElement($response['body']);
foreach ($resultsXml->channel[0]->item as $node) {
// ink361 sends <a href="ink361.com"><img src="image.jpg"></a>
try {
$imageNode = new DOMDocument();
$imageNode->loadHTML($node->description);
$img = $imageNode->getElementsByTagName('img');
$results[] = $img->item(0)->getAttribute('src');
if (count($results) == $limit) {
break;
}
} catch (Exception $e) {
}
}
set_transient('InstagramWidget::getFeed', $results, HOUR_IN_SECONDS);
} catch (Exception $e) {
}
}
}
return $results;
}
示例4: from_remote
private function from_remote()
{
$data = array();
$url = 'https://api.wpengine.com/1.2/?method=disk-usage&account_name=' . PWP_NAME . '&wpe_apikey=' . WPE_APIKEY . '&blog_id=all';
$http = new WP_Http();
$msg = $http->get($url);
if (!is_a($msg, 'WP_Error') && isset($msg['body'])) {
$data = json_decode($msg['body'], TRUE);
}
return $data;
}
示例5: _download_framework
/**
* {@inheritdoc}
* @internal
*/
public function _download_framework($version, $wp_filesystem_download_directory)
{
/** @var WP_Filesystem_Base $wp_filesystem */
global $wp_filesystem;
$user_slash_repo = fw()->manifest->get($this->manifest_key);
$http = new WP_Http();
$response = $http->get('https://api.github.com/repos/' . $user_slash_repo . '/releases');
unset($http);
if (wp_remote_retrieve_response_code($response) !== 200) {
return new WP_Error('fw_ext_update_github_framework_download_releases_failed', __('Failed to access Github repository releases.', 'fw'));
}
$releases = json_decode($response['body'], true);
unset($response);
if (empty($releases)) {
return new WP_Error('fw_ext_update_github_framework_download_no_releases', __('Github repository has no releases.', 'fw'));
}
$release = false;
foreach ($releases as $_release) {
if ($_release['tag_name'] === $version) {
$release = $_release;
}
}
if (empty($release)) {
return new WP_Error('fw_ext_update_github_framework_download_not_existing_release', sprintf(__('Requested version (release) for download does not exists "%s".', 'fw'), $version));
}
$http = new WP_Http();
$response = $http->request($release['zipball_url'], array('timeout' => $this->download_timeout));
unset($http);
if (wp_remote_retrieve_response_code($response) !== 200) {
return new WP_Error('fw_ext_update_github_framework_download_failed', __('Failed to download framework zip.', 'fw'));
}
$zip_path = $wp_filesystem_download_directory . '/temp.zip';
// save zip to file
$wp_filesystem->put_contents($zip_path, $response['body']);
unset($response);
unzip_file(FW_WP_Filesystem::filesystem_path_to_real_path($zip_path), $wp_filesystem_download_directory);
// remove zip file
$wp_filesystem->delete($zip_path, false, 'f');
$unzipped_dir = $wp_filesystem->dirlist($wp_filesystem_download_directory);
$unzipped_dir = $wp_filesystem_download_directory . '/' . key($unzipped_dir);
return $unzipped_dir;
}
示例6: download
/**
* Download an extension
*
* global $wp_filesystem; must me initialized
*
* @param string $extension_name
* @param array $data Extension data from the "available extensions" array
* @return string|WP_Error WP Filesystem path to the downloaded directory
*/
private function download($extension_name, $data)
{
$wp_error_id = 'fw_extension_download';
if (empty($data['download'])) {
return new WP_Error($wp_error_id, sprintf(__('Extension "%s" has no download sources.', 'fw'), $this->get_extension_title($extension_name)));
}
/** @var WP_Filesystem_Base $wp_filesystem */
global $wp_filesystem;
$wp_fs_tmp_dir = FW_WP_Filesystem::real_path_to_filesystem_path($this->get_tmp_dir());
if ($wp_filesystem->exists($wp_fs_tmp_dir)) {
// just in case it already exists, clear everything, it may contain old files
if (!$wp_filesystem->rmdir($wp_fs_tmp_dir, true)) {
return new WP_Error($wp_error_id, sprintf(__('Cannot remove temporary directory: %s', 'fw'), $wp_fs_tmp_dir));
}
}
if (!FW_WP_Filesystem::mkdir_recursive($wp_fs_tmp_dir)) {
return new WP_Error($wp_error_id, sprintf(__('Cannot create temporary directory: %s', 'fw'), $wp_fs_tmp_dir));
}
foreach ($data['download'] as $source => $source_data) {
switch ($source) {
case 'github':
if (empty($source_data['user_repo'])) {
return new WP_Error($wp_error_id, sprintf(__('"%s" extension github source "user_repo" parameter is required', 'fw'), $this->get_extension_title($extension_name)));
}
$transient_name = 'fw_ext_mngr_gh_dl';
$transient_ttl = HOUR_IN_SECONDS;
$cache = get_site_transient($transient_name);
if ($cache === false) {
$cache = array();
}
if (isset($cache[$source_data['user_repo']])) {
$download_link = $cache[$source_data['user_repo']]['zipball_url'];
} else {
$http = new WP_Http();
$response = $http->get(apply_filters('fw_github_api_url', 'https://api.github.com') . '/repos/' . $source_data['user_repo'] . '/releases/latest');
unset($http);
$response_code = intval(wp_remote_retrieve_response_code($response));
if ($response_code !== 200) {
if ($response_code === 403) {
$json_response = json_decode($response['body'], true);
if ($json_response) {
return new WP_Error($wp_error_id, __('Github error:', 'fw') . ' ' . $json_response['message']);
}
} elseif ($response_code) {
return new WP_Error($wp_error_id, sprintf(__('Failed to access Github repository "%s" releases. (Response code: %d)', 'fw'), $source_data['user_repo'], $response_code));
} elseif (is_wp_error($response)) {
return new WP_Error($wp_error_id, sprintf(__('Failed to access Github repository "%s" releases. (%s)', 'fw'), $source_data['user_repo'], $response->get_error_message()));
} else {
return new WP_Error($wp_error_id, sprintf(__('Failed to access Github repository "%s" releases.', 'fw'), $source_data['user_repo']));
}
}
$release = json_decode($response['body'], true);
unset($response);
if (empty($release)) {
return new WP_Error($wp_error_id, sprintf(__('"%s" extension github repository "%s" has no releases.', 'fw'), $this->get_extension_title($extension_name), $source_data['user_repo']));
}
$cache[$source_data['user_repo']] = array('zipball_url' => 'https://github.com/' . $source_data['user_repo'] . '/archive/' . $release['tag_name'] . '.zip', 'tag_name' => $release['tag_name']);
set_site_transient($transient_name, $cache, $transient_ttl);
$download_link = $cache[$source_data['user_repo']]['zipball_url'];
unset($release);
}
$http = new WP_Http();
$response = $http->request($download_link, array('timeout' => $this->download_timeout));
unset($http);
if (($response_code = intval(wp_remote_retrieve_response_code($response))) !== 200) {
if ($response_code) {
return new WP_Error($wp_error_id, sprintf(__('Cannot download the "%s" extension zip. (Response code: %d)', 'fw'), $this->get_extension_title($extension_name), $response_code));
} elseif (is_wp_error($response)) {
return new WP_Error($wp_error_id, sprintf(__('Cannot download the "%s" extension zip. %s', 'fw'), $this->get_extension_title($extension_name), $response->get_error_message()));
} else {
return new WP_Error($wp_error_id, sprintf(__('Cannot download the "%s" extension zip.', 'fw'), $this->get_extension_title($extension_name)));
}
}
$zip_path = $wp_fs_tmp_dir . '/temp.zip';
// save zip to file
if (!$wp_filesystem->put_contents($zip_path, $response['body'])) {
return new WP_Error($wp_error_id, sprintf(__('Cannot save the "%s" extension zip.', 'fw'), $this->get_extension_title($extension_name)));
}
unset($response);
$unzip_result = unzip_file(FW_WP_Filesystem::filesystem_path_to_real_path($zip_path), $wp_fs_tmp_dir);
if (is_wp_error($unzip_result)) {
return $unzip_result;
}
// remove zip file
if (!$wp_filesystem->delete($zip_path, false, 'f')) {
return new WP_Error($wp_error_id, sprintf(__('Cannot remove the "%s" extension downloaded zip.', 'fw'), $this->get_extension_title($extension_name)));
}
$unzipped_dir_files = $wp_filesystem->dirlist($wp_fs_tmp_dir);
if (!$unzipped_dir_files) {
return new WP_Error($wp_error_id, __('Cannot access the unzipped directory files.', 'fw'));
}
//.........这里部分代码省略.........
示例7: ml_check_pb_keys
function ml_check_pb_keys()
{
$headers = array('X-PUSHBOTS-APPID' => get_option('ml_pb_app_id'), 'X-PUSHBOTS-SECRET' => get_option('ml_pb_secret_key'), 'Content-Type' => 'application/json', 'Content-Length' => 0);
$url = 'https://api.pushbots.com/analytics';
$request = new WP_Http();
$result = $request->get($url, array('timeout' => 10, 'headers' => $headers, 'sslverify' => false));
return isset($result['response']['code']) && $result['response']['code'] == 200;
}
示例8: fpp_acquire_page_access_token
function fpp_acquire_page_access_token($page_id, $profile_access_token)
{
$request = new WP_Http();
$api_url = 'https://graph.facebook.com/me/accounts?access_token=' . urlencode($profile_access_token);
$response = $request->get($api_url, array('timeout' => FPP_REQUEST_TIMEOUT, 'sslverify' => fpp_get_ssl_verify()));
if (array_key_exists('errors', $response)) {
throw new FacebookUnreachableException(!empty($response->errors) ? array_pop(array_pop($response->errors)) : '');
}
$json_response = json_decode($response['body']);
if (!is_object($json_response) || !property_exists($json_response, 'data')) {
throw new FacebookUnexpectedErrorException(__('Can\'t access Facebook user account information.', FPP_TEXT_DOMAIN));
}
foreach ($json_response->data as $account) {
if ($account->id == $page_id) {
if (!property_exists($account, 'access_token')) {
throw new FacebookUnexpectedErrorException(__('Some or all access permissions for your page are missing.', FPP_TEXT_DOMAIN));
}
$page_access_token = $account->access_token;
break;
}
}
if (!isset($page_access_token)) {
throw new FacebookErrorException(__('Your Facebook user account data contains no page with the given ID. You have to be administrator of the given page.', FPP_TEXT_DOMAIN));
}
return $page_access_token;
}
示例9: run
public function run()
{
if (!$this->is_config_update_disabled()) {
$response = $this->http->get(ICL_REMOTE_WPML_CONFIG_FILES_INDEX . 'wpml-config/config-index.json');
if (!is_wp_error($response) && $response['response']['code'] == 200) {
$arr = json_decode($response['body']);
if (isset($arr->plugins) && isset($arr->themes)) {
update_option('wpml_config_index', $arr);
update_option('wpml_config_index_updated', time());
$config_files = maybe_unserialize(get_option('wpml_config_files_arr'));
$config_files_for_themes = array();
$deleted_configs_for_themes = array();
$config_files_for_plugins = array();
$deleted_configs_for_plugins = array();
if ($config_files) {
if (isset($config_files->themes)) {
$config_files_for_themes = $config_files->themes;
$deleted_configs_for_themes = $config_files->themes;
}
if (isset($config_files->plugins)) {
$config_files_for_plugins = $config_files->plugins;
$deleted_configs_for_plugins = $config_files->plugins;
}
}
foreach ($arr->themes as $theme) {
if ($this->sitepress->get_wp_api()->get_theme_name() == $theme->name && (!isset($config_files_for_themes[$theme->name]) || md5($config_files_for_themes[$theme->name]) != $theme->hash)) {
$response = $this->http->get(ICL_REMOTE_WPML_CONFIG_FILES_INDEX . $theme->path);
if ($response['response']['code'] == 200) {
$config_files_for_themes[$theme->name] = $response['body'];
}
}
}
foreach ($deleted_configs_for_themes as $key => $deleted_config) {
unset($config_files_for_themes[$key]);
}
$active_plugins = $this->sitepress->get_wp_api()->get_plugins();
$active_plugins_names = array();
foreach ($active_plugins as $active_plugin) {
$active_plugins_names[] = $active_plugin['Name'];
}
foreach ($arr->plugins as $plugin) {
if (in_array($plugin->name, $active_plugins_names) && (!isset($config_files_for_plugins[$plugin->name]) || md5($config_files_for_plugins[$plugin->name]) != $plugin->hash)) {
$response = $this->http->get(ICL_REMOTE_WPML_CONFIG_FILES_INDEX . $plugin->path);
if (!is_wp_error($response) && $response['response']['code'] == 200) {
$config_files_for_plugins[$plugin->name] = $response['body'];
}
}
}
foreach ($deleted_configs_for_plugins as $key => $deleted_config) {
unset($config_files_for_plugins[$key]);
}
if (!isset($config_files) || !$config_files) {
$config_files = new stdClass();
}
$config_files->themes = $config_files_for_themes;
$config_files->plugins = $config_files_for_plugins;
update_option('wpml_config_files_arr', $config_files);
return true;
}
}
}
return false;
}
示例10: time
function update_wpml_config_index_event()
{
$wp_http_class = new WP_Http();
$response = $wp_http_class->get(ICL_REMOTE_WPML_CONFIG_FILES_INDEX . 'wpml-config/config-index.json');
if (!is_wp_error($response) && $response['response']['code'] == 200) {
$arr = json_decode($response['body']);
if (isset($arr->plugins) && isset($arr->themes)) {
update_option('wpml_config_index', $arr);
update_option('wpml_config_index_updated', time());
$config_files_arr = maybe_unserialize(get_option('wpml_config_files_arr'));
if ($config_files_arr) {
$config_files_themes_arr = $config_files_arr->themes;
$config_files_plugins_arr = $config_files_arr->plugins;
} else {
$config_files_themes_arr = array();
$config_files_plugins_arr = array();
}
$wp_http_class = new WP_Http();
$theme_data = wp_get_theme();
foreach ($arr->themes as $theme) {
if ($theme_data->get('Name') == $theme->name && (!isset($config_files_themes_arr[$theme->name]) || md5($config_files_themes_arr[$theme->name]) != $theme->hash)) {
$response = $wp_http_class->get(ICL_REMOTE_WPML_CONFIG_FILES_INDEX . $theme->path);
if ($response['response']['code'] == 200) {
$config_files_themes_arr[$theme->name] = $response['body'];
}
}
}
if (!function_exists('get_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$active_plugins = get_plugins();
foreach ($active_plugins as $active_plugin) {
$active_plugins_names[] = $active_plugin['Name'];
}
foreach ($arr->plugins as $plugin) {
if (in_array($plugin->name, $active_plugins_names) && (!isset($config_files_plugins_arr[$plugin->name]) || md5($config_files_plugins_arr[$plugin->name]) != $plugin->hash)) {
$response = $wp_http_class->get(ICL_REMOTE_WPML_CONFIG_FILES_INDEX . $plugin->path);
if (!is_wp_error($response) && $response['response']['code'] == 200) {
$config_files_plugins_arr[$plugin->name] = $response['body'];
}
}
}
if (!isset($config_files_arr) || !$config_files_arr) {
$config_files_arr = new stdClass();
}
$config_files_arr->themes = $config_files_themes_arr;
$config_files_arr->plugins = $config_files_plugins_arr;
update_option('wpml_config_files_arr', $config_files_arr);
return true;
}
}
return false;
}
示例11: ml_registered_devices_count
function ml_registered_devices_count()
{
$request = new WP_Http();
$headers = array('X-PUSHBOTS-APPID' => get_option('ml_pb_app_id'), 'X-PUSHBOTS-SECRET' => get_option('ml_pb_secret_key'), 'platform' => 0);
$url = MOBILOUD_PB_URL . '/deviceToken/count';
$result = $request->get($url, array('timeout' => 10, 'headers' => $headers, 'sslverify' => false));
$iosCount = null;
if ($result instanceof WP_Error) {
$iosCount = null;
} elseif (isset($result['body'])) {
$responseJson = json_decode($result['body']);
$iosCount = isset($responseJson->count) ? $responseJson->count : 0;
}
$request = new WP_Http();
$headers = array('X-PUSHBOTS-APPID' => get_option('ml_pb_app_id'), 'X-PUSHBOTS-SECRET' => get_option('ml_pb_secret_key'), 'platform' => 1);
$url = MOBILOUD_PB_URL . '/deviceToken/count';
$result = $request->get($url, array('timeout' => 10, 'headers' => $headers, 'sslverify' => false));
$androidCount = null;
if ($result instanceof WP_Error) {
$androidCount = null;
} elseif (isset($result['body'])) {
$responseJson = json_decode($result['body']);
$androidCount = isset($responseJson->count) ? $responseJson->count : 0;
}
return array('ios' => $iosCount, 'android' => $androidCount);
}
示例12: nospamuser_check
function nospamuser_check($type, $data)
{
$settings = bb_get_option('nospamuser-settings');
if (!$settings) {
bb_update_option('nospamuser-settings', $settings = array('days' => 30, 'min_occur' => 5, 'max_occur' => 10, 'api_key' => '', 'recaptcha_mode' => 'aggressive', 'recapthca_pub' => '', 'recaptcha_priv' => '', 'stats_public' => 0));
}
if (!is_array($result = bb_get_transient('nospamuser-' . $type . '-' . md5($data)))) {
$wp_http = new WP_Http();
$response = $wp_http->get('http://www.stopforumspam.com/api?' . urlencode($type) . '=' . urlencode($data), array('user-agent' => apply_filters('http_headers_useragent', backpress_get_option('wp_http_version')) . NOSPAMUSER_AGENT));
$response = $response['body'];
if (strpos($response, '<response success="true">') === false) {
return;
}
if (strpos($response, '<appears>no</appears>') !== false) {
$result = array(0, 0);
} else {
preg_match('/<lastseen>([^<>]+)<\\/lastseen>/', $response, $matches);
$result = array((int) substr($response, strpos($response, '<frequency>') + 11), strtotime($matches[1]));
}
bb_set_transient('nospamuser-' . $type . '-' . md5($data), $result, 604800);
}
if ($result == array(0, 0)) {
// Even if the settings are set incorrectly, non-spammers shouldn't be blocked.
return;
}
if ($result[0] >= $settings['min_occur'] && $result[1] >= time() - $settings['days'] * 86400 || $result[0] >= $settings['max_occur'] && $settings['recaptcha_mode'] == 'aggressive') {
if ($result[0] >= $settings['max_occur'] && $settings['recaptcha_mode'] == 'adaptive') {
nospamuser_block($type, $data, true);
} elseif ($settings['recaptcha_mode'] == 'aggressive' || !$settings['recaptcha_pub'] || !$settings['recaptcha_priv']) {
nospamuser_block($type, $data, true);
} else {
nospamuser_block($type, $data, false);
}
}
}
示例13: download
/**
* @param string $user_slash_repo Github 'user/repo'
* @param string $version Requested version to download
* @param string $wp_filesystem_download_directory Allocated temporary empty directory
* @param string $title Used in messages
*
* @return string|WP_Error Path to the downloaded directory
*/
private function download($user_slash_repo, $version, $wp_filesystem_download_directory, $title)
{
$http = new WP_Http();
$response = $http->get($this->get_github_api_url('/repos/' . $user_slash_repo . '/releases/tags/' . $version));
unset($http);
$response_code = intval(wp_remote_retrieve_response_code($response));
if ($response_code !== 200) {
if ($response_code === 403) {
$json_response = json_decode($response['body'], true);
if ($json_response) {
return new WP_Error('fw_ext_update_github_download_releases_failed', __('Github error:', 'fw') . ' ' . $json_response['message']);
}
}
if ($response_code) {
return new WP_Error('fw_ext_update_github_download_releases_failed', sprintf(__('Failed to access Github repository "%s" releases. (Response code: %d)', 'fw'), $user_slash_repo, $response_code));
} else {
return new WP_Error('fw_ext_update_github_download_releases_failed', sprintf(__('Failed to access Github repository "%s" releases.', 'fw'), $user_slash_repo));
}
}
$release = json_decode($response['body'], true);
unset($response);
if (empty($release)) {
return new WP_Error('fw_ext_update_github_download_no_release', sprintf(__('%s github repository "%s" does not have the "%s" release.', 'fw'), $title, $user_slash_repo, $version));
}
$http = new WP_Http();
$response = $http->request('https://github.com/' . $user_slash_repo . '/archive/' . $release['tag_name'] . '.zip', array('timeout' => $this->download_timeout));
unset($http);
if (intval(wp_remote_retrieve_response_code($response)) !== 200) {
return new WP_Error('fw_ext_update_github_download_failed', sprintf(__('Cannot download %s zip.', 'fw'), $title));
}
/** @var WP_Filesystem_Base $wp_filesystem */
global $wp_filesystem;
$zip_path = $wp_filesystem_download_directory . '/temp.zip';
// save zip to file
if (!$wp_filesystem->put_contents($zip_path, $response['body'])) {
return new WP_Error('fw_ext_update_github_save_download_failed', sprintf(__('Cannot save %s zip.', 'fw'), $title));
}
unset($response);
$unzip_result = unzip_file(FW_WP_Filesystem::filesystem_path_to_real_path($zip_path), $wp_filesystem_download_directory);
if (is_wp_error($unzip_result)) {
return $unzip_result;
}
// remove zip file
if (!$wp_filesystem->delete($zip_path, false, 'f')) {
return new WP_Error('fw_ext_update_github_remove_downloaded_zip_failed', sprintf(__('Cannot remove %s zip.', 'fw'), $title));
}
$unzipped_dir_files = $wp_filesystem->dirlist($wp_filesystem_download_directory);
if (!$unzipped_dir_files) {
return new WP_Error('fw_ext_update_github_unzipped_dir_fail', __('Cannot access the unzipped directory files.', 'fw'));
}
/**
* get first found directory
* (if everything worked well, there should be only one directory)
*/
foreach ($unzipped_dir_files as $file) {
if ($file['type'] == 'd') {
return $wp_filesystem_download_directory . '/' . $file['name'];
}
}
return new WP_Error('fw_ext_update_github_unzipped_dir_not_found', sprintf(__('The unzipped %s directory not found.', 'fw'), $title));
}
示例14: opensso_get_name
function opensso_get_name($ssotoken)
{
$url = OPENSSO_ATTRIBUTES . '?subjectid=' . urlencode($ssotoken);
$http = new WP_Http();
$response = $http->get($url, array('headers' => $headers));
if ($response['response']['code'] != 200) {
return null;
}
// Need to parse name/value pairs, to get value for WordPress username attribute
$lines = explode("\n", $response['body']);
reset($lines);
foreach ($lines as $line) {
if ($line == 'userdetails.attribute.name=' . OPENSSO_WORDPRESS_USERNAME_ATTRIBUTE) {
// 'current' line holds attribute value
// 28 points to character after 'userdetails.attribute.value='
$name = substr(current($lines), 28);
break;
}
}
return $name;
}
示例15: RAND
if ($current_state != $new_state) {
$this->set_rand_enabled($new_state);
$message = "ORDER BY RAND() support is now <b>" . ($new_state ? 'enabled' : 'disabled') . "</b>.";
}
// HTML post-processing
$result = $this->set_regex_html_post_process_text($fv_regex_html_post_process);
if ($result !== TRUE) {
$error = "<b>Error in HTML replacement regex:</b><br>{$result}<br>(Maybe you forgot the beginning and ending characters?)";
}
}
// Fix file permissions
if (wpe_param('file-perms')) {
check_admin_referer(PWP_NAME . '-config');
$url = "https://api.wpengine.com/1.2/?method=file-permissions&account_name=" . PWP_NAME . "&wpe_apikey=" . WPE_APIKEY;
$http = new WP_Http();
$msg = $http->get($url);
if (is_a($msg, 'WP_Error')) {
return false;
}
if (!isset($msg['body'])) {
return false;
}
$data = json_decode($msg['body'], true);
$message = @$data['message'];
}
// Process purging all caches
if (wpe_param('purge-all')) {
check_admin_referer(PWP_NAME . '-config');
// check_admin_referer(PWP_NAME.'-config'); DO NOT CHECK because it's OK to just hit it from anywhere, and in fact we do.
WpeCommon::purge_memcached();
WpeCommon::clear_maxcdn_cache();