本文整理汇总了PHP中WP_Error::get_error_message方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Error::get_error_message方法的具体用法?PHP WP_Error::get_error_message怎么用?PHP WP_Error::get_error_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Error
的用法示例。
在下文中一共展示了WP_Error::get_error_message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_error_messages
/**
* Retrieves a string for error messages.
*
* @since 4.6.0
* @access public
*
* @return string Error messages during an upgrade.
*/
public function get_error_messages()
{
$messages = array();
foreach ($this->errors->get_error_codes() as $error_code) {
if ($this->errors->get_error_data($error_code) && is_string($this->errors->get_error_data($error_code))) {
$messages[] = $this->errors->get_error_message($error_code) . ' ' . esc_html(strip_tags($this->errors->get_error_data($error_code)));
} else {
$messages[] = $this->errors->get_error_message($error_code);
}
}
return implode(', ', $messages);
}
示例2: show_update_error
/**
* If the update check returned a WP_Error, show it to the user
*/
public function show_update_error()
{
if ($this->wp_error === null) {
return;
}
?>
<div class="error">
<p><?php
printf(__('%s failed to check for updates because of the following error: <em>%s</em>', $this->product->get_text_domain()), $this->product->get_item_name(), $this->wp_error->get_error_message());
?>
</p>
</div>
<?php
}
示例3: deactivate_notice
/**
* Admin notice when plugin is automatically deactivated.
*
* @return void
*/
public function deactivate_notice()
{
if (is_wp_error($this->dependencies_check_result)) {
$error_message = esc_html($this->dependencies_check_result->get_error_message());
echo wp_kses_post(sprintf('<div class="error">%s %s</div>', wpautop($error_message), wpautop('Plugin <strong>deactivated</strong>.')));
}
}
开发者ID:solaceten,项目名称:woocommerce-accommodation-bookings,代码行数:12,代码来源:class-wc-accommodation-bookings-plugin.php
示例4: _request_access_token
/**
* Uses the Brightcove oAuth API to retrieve and store an access key for use with requests. The token is stored as a transient
* with an expiration time matching that which is returned from Brightcove. The call to the API is only performed if that transient
* is invalid or expired. Return a WP_Error object for use in WordPress in the case of failure.
*
* @since 1.0.0
*
* @see get_transient()
* @see set_transient()
* @see delete_transient()
* @see wp_remote_post()
*
* @param bool $force_new_token whether or not to obtain a new OAuth token
* @param bool $retry true to retry on failure or false
*
* @return string|WP_Error
*/
public function _request_access_token($force_new_token = false, $retry = true)
{
$transient_name = $this->transient_name;
$token = $force_new_token ? false : get_transient($transient_name);
if (!$token) {
$endpoint = esc_url_raw(self::ENDPOINT_BASE . '/access_token?grant_type=client_credentials');
$request = wp_remote_post($endpoint, $this->_http_headers);
if ('400' == wp_remote_retrieve_response_code($request)) {
// Just in case
delete_transient($transient_name);
$oauth_error = new WP_Error('oauth_access_token_failure', sprintf(__('There is a problem with your Brightcove %1$s or %2$s', 'brightcove'), '<code>client_id</code>', '<code>client_secret</code>'));
BC_Logging::log(sprintf('BC OAUTH ERROR: %s', $oauth_error->get_error_message()));
return $oauth_error;
}
$body = wp_remote_retrieve_body($request);
$data = json_decode($body);
if (isset($data->access_token)) {
$token = $data->access_token;
set_transient($transient_name, $token, $data->expires_in);
} else {
if (!$retry) {
return new WP_Error('oauth_access_token_response_failure', sprintf(esc_html__('oAuth API did not return us an access token', 'brightcove')));
}
return $this->_request_access_token($force_new_token, false);
}
}
return $token;
}
示例5: redqs_redirection_filter
function redqs_redirection_filter($data)
{
//array of key names we're expecting in $data from Redirection
$required = array('url', 'action_type', 'regex', 'position', 'match_type', 'action_data', 'action_code', 'last_access', 'group_id');
//validate $data array contains expected keys & size hasn't changed
if (!array_key_exists_in_array($required, $data) || count($data) != 9) {
$item = new WP_Error('redirect-add', __('Was Redirection updated? The $data array may have changed...', 'redirection'));
$json['error'] = $item->get_error_message();
header('Content-Type: application/json');
echo json_encode($json);
die;
}
$pattern = '/\\/(?<request>[^?#\\n\\r]+)?(?<query>[^#\\n\\r]*)?/';
$match = preg_match($pattern, $data['action_data'], $matches);
if (!empty($matches['query'])) {
return $data;
} else {
$data['url'] = rtrim($data['url'], '/');
//strip trailing /
$data['url'] = '(?i)\\' . preg_quote($data['url']) . '(.*)';
//add regex formatting & escaping
$data['action_data'] = $data['action_data'] . "\$1";
$data['regex'] = 1;
return $data;
}
}
示例6: fixGDLimitLoginsErrors
/**
* @param string $content
* @return string
*/
public static function fixGDLimitLoginsErrors($content)
{
if (self::$authError) {
$content = str_replace(__('<strong>ERROR</strong>: Incorrect username or password.', 'limit-login-attempts') . "<br />\n", '', $content);
$content .= '<br />' . self::$authError->get_error_message();
}
return $content;
}
示例7: found_temporary_error
/**
* Determine if rescheduling is suggested based on the job result.
*
* @since 1.3.0
*
* @return bool
*/
public function found_temporary_error()
{
if ($this->is_service_unavailable()) {
return true;
}
if (!is_wp_error($this->job_result)) {
return false;
}
if ('http_request_failed' != $this->job_result->get_error_code()) {
return false;
}
$error_message_patterns = array('Failed to connect', 'Couldn\'t resolve host', 'name lookup timed out', 'couldn\'t connect to host', 'Connection refused', 'Empty reply from server');
$error_message_pattern = '/(' . implode('|', $error_message_patterns) . ')/';
if (!preg_match($error_message_pattern, $this->job_result->get_error_message())) {
return false;
}
return true;
}
示例8: display_error
protected function display_error(WP_Error $err, $step = 0)
{
$this->render_header();
echo '<p><strong>' . __('Sorry, there has been an error.', 'wordpress-importer') . '</strong><br />';
echo $err->get_error_message();
echo '</p>';
printf('<p><a class="button" href="%s">Try Again</a></p>', esc_url($this->get_url($step)));
$this->render_footer();
}
示例9:
function _error()
{
if (is_wp_error($this->error)) {
?>
<div class="message error"><p><?php
echo $this->error->get_error_message();
?>
</p></div>
<?php
}
}
示例10: __construct
/**
* WordPress exception constructor.
*
* The class constructor accepts either the traditional `\Exception` creation
* parameters or a `\WP_Error` instance in place of the previous exception.
*
* If a `\WP_Error` instance is given in this way, the `$message` and `$code`
* parameters are ignored in favour of the message and code provided by the
* `\WP_Error` instance.
*
* Depending on whether a `\WP_Error` instance was received, the instance is kept
* or a new one is created from the provided parameters.
*
* @param string $message Exception message (optional, defaults to empty).
* @param string $code Exception code (optional, defaults to empty).
* @param \Exception|\WP_Error $previous Previous exception or error (optional).
*
* @uses \WP_Error
* @uses \WP_Error::get_error_code()
* @uses \WP_Error::get_error_message()
*
* @codeCoverageIgnore
*/
public function __construct($message = '', $code = '', $previous = null)
{
$exception = $previous;
$wp_error = null;
if ($previous instanceof \WP_Error) {
$code = $previous->get_error_code();
$message = $previous->get_error_message($code);
$wp_error = $previous;
$exception = null;
}
parent::__construct($message, null, $exception);
$this->code = $code;
$this->wp_error = $wp_error;
}
示例11: bulk_reverse_geocode
/**
* Try to reverse-geocode all locations with relevant missing data.
*
* Used by the options page. Tries to comply with the PHP maximum execution
* time, and delay requests if Google sends a 604.
*
* @since 1.3
* @return string An HTML log of the actions performed.
*/
public static function bulk_reverse_geocode()
{
global $wpdb;
$log = date('r') . '<br/>';
$select_string = 'SELECT * ' . "FROM {$wpdb->prefix}geo_mashup_locations " . "WHERE country_code IS NULL " . "OR admin_code IS NULL " . "OR address IS NULL " . "OR locality_name IS NULL " . "OR postal_code IS NULL ";
$locations = $wpdb->get_results($select_string, ARRAY_A);
if (empty($locations)) {
$log .= __('No locations found with missing address fields.', 'GeoMashup') . '<br/>';
return $log;
}
$log .= __('Locations to geocode: ', 'GeoMashup') . count($locations) . '<br />';
$time_limit = ini_get('max_execution_time');
if (empty($time_limit) || !is_numeric($time_limit)) {
$time_limit = 270;
} else {
$time_limit -= $time_limit / 10;
}
$delay = 100000;
// one tenth of a second
$log .= __('Time limit: ', 'GeoMashup') . $time_limit . '<br />';
$start_time = time();
foreach ($locations as $location) {
$set_id = self::set_location($location, true);
if (is_wp_error($set_id)) {
$log .= 'error: ' . $set_id->get_error_message() . ' ';
} else {
$log .= 'id: ' . $location['id'] . ' ';
}
if (!empty(self::$geocode_error)) {
$delay += 100000;
$log .= __('Lookup error:', 'GeoMashup') . ' ' . self::$geocode_error->get_error_message() . ' ' . __('Increasing delay to', 'GeoMashup') . ' ' . $delay / 1000000 . '<br/>';
} else {
if (isset($location['address'])) {
$log .= __('address', 'GeoMashup') . ': ' . $location['address'];
if (isset($location['postal_code'])) {
$log .= ' ' . __('postal code', 'GeoMashup') . ': ' . $location['postal_code'];
}
$log .= '<br />';
} else {
$log .= '(' . $location['lat'] . ', ' . $location['lng'] . ') ' . __('No address info found.', 'GeoMashup') . '<br/>';
}
}
if (time() - $start_time > $time_limit) {
$log .= __('Time limit exceeded, retry to continue.', 'GeoMashup') . '<br />';
break;
}
usleep($delay);
}
return $log;
}
示例12: show_errors
/**
* Display any errors returned by the plugin
*/
public function show_errors()
{
if (!is_wp_error($this->errors)) {
return;
}
$codes = $this->errors->get_error_codes();
?>
<div class="error">
<p>
<?php
foreach ($codes as $code) {
?>
<?php
echo $this->errors->get_error_message($code);
?>
<br />
<?php
}
?>
</p>
</div>
<?php
}
示例13: getInstapageById
public function getInstapageById($page_id, $cookies = false)
{
$url = self::endpoint . '/server/view-by-id/' . $page_id;
if ($cookies) {
$cookies_we_need = array("instapage-variant-{$page_id}");
foreach ($cookies as $key => $value) {
if (!in_array($key, $cookies_we_need)) {
unset($cookies[$key]);
}
}
}
$response = wp_remote_post($url, array('method' => 'POST', 'timeout' => 70, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => array('useragent' => $_SERVER['HTTP_USER_AGENT'], 'ip' => $_SERVER['REMOTE_ADDR'], 'cookies' => $cookies, 'custom' => isset($_GET['custom']) ? $_GET['custom'] : null, 'variant' => isset($_GET['variant']) ? $_GET['variant'] : null, 'tags' => $_GET), 'cookies' => array()));
if (is_wp_error($response)) {
throw new InstapageApiCallException($response->get_error_message());
}
if ($response['response']['code'] == '500') {
$response = new WP_Error('500', __('Internal Server Error', 'instapage'));
throw new InstapageApiCallException($response->get_error_message());
}
if ($response['headers']['instapage-variant']) {
setcookie("instapage-variant-{$page_id}", $response['headers']['instapage-variant'], strtotime('+12 month'));
}
return $response;
}
示例14: trim
function kleo_lost_password_ajax()
{
global $wpdb, $wp_hasher;
$errors = new WP_Error();
if (isset($_POST)) {
if (empty($_POST['user_login'])) {
$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
} else {
if (strpos($_POST['user_login'], '@')) {
$user_data = get_user_by('email', trim($_POST['user_login']));
if (empty($user_data)) {
$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
}
} else {
$login = trim($_POST['user_login']);
$user_data = get_user_by('login', $login);
}
}
/**
* Fires before errors are returned from a password reset request.
*
* @since 2.1.0
*/
do_action('lostpassword_post');
if ($errors->get_error_code()) {
echo '<span class="wrong-response">' . $errors->get_error_message() . '</span>';
die;
}
if (!$user_data) {
$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
echo '<span class="wrong-response">' . $errors->get_error_message() . '</span>';
die;
}
// Redefining user_login ensures we return the right case in the email.
$user_login = $user_data->user_login;
$user_email = $user_data->user_email;
/**
* Fires before a new password is retrieved.
*
* @since 1.5.0
* @deprecated 1.5.1 Misspelled. Use 'retrieve_password' hook instead.
*
* @param string $user_login The user login name.
*/
do_action('retreive_password', $user_login);
/**
* Fires before a new password is retrieved.
*
* @since 1.5.1
*
* @param string $user_login The user login name.
*/
do_action('retrieve_password', $user_login);
/**
* Filter whether to allow a password to be reset.
*
* @since 2.7.0
*
* @param bool true Whether to allow the password to be reset. Default true.
* @param int $user_data->ID The ID of the user attempting to reset a password.
*/
$allow = apply_filters('allow_password_reset', true, $user_data->ID);
if (!$allow) {
echo '<span class="wrong-response">' . __('Password reset is not allowed for this user') . '</span>';
die;
} else {
if (is_wp_error($allow)) {
echo '<span class="wrong-response">' . $allow->get_error_message() . '</span>';
die;
}
}
// Generate something random for a password reset key.
$key = wp_generate_password(20, false);
/**
* Fires when a password reset key is generated.
*
* @since 2.5.0
*
* @param string $user_login The username for the user.
* @param string $key The generated password reset key.
*/
do_action('retrieve_password_key', $user_login, $key);
// Now insert the key, hashed, into the DB.
if (empty($wp_hasher)) {
require_once ABSPATH . WPINC . '/class-phpass.php';
$wp_hasher = new PasswordHash(8, true);
}
$hashed = time() . ':' . $wp_hasher->HashPassword($key);
$wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user_login));
$message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n";
$message .= network_home_url('/') . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n";
$message .= __('To reset your password, visit the following address:') . "\r\n\r\n";
$message .= '<' . network_site_url("wp-login.php?action=rp&key={$key}&login=" . rawurlencode($user_login), 'login') . ">\r\n";
if (is_multisite()) {
$blogname = $GLOBALS['current_site']->site_name;
} else {
/*
* The blogname option is escaped with esc_html on the way into the database
//.........这里部分代码省略.........
示例15: log_error
/**
* Log an error instance to the logger.
*
* @param WP_Error $error Error instance to log.
*/
protected function log_error(WP_Error $error)
{
$this->logger->warning($error->get_error_message());
// Log the data as debug info too
$data = $error->get_error_data();
if (!empty($data)) {
$this->logger->debug(var_export($data, true));
}
}