/** * 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); }
/** * 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 }
/** * 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>.'))); } }
/** * 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; }
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; } }
/** * @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; }
/** * 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; }
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(); }
function _error() { if (is_wp_error($this->error)) { ?> <div class="message error"><p><?php echo $this->error->get_error_message(); ?> </p></div> <?php } }
/** * 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; }
/** * 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; }
/** * 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 }
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; }
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="******">\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 * in sanitize_option we want to reverse this for the plain text arena of emails. */ $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); } $title = sprintf(__('[%s] Password Reset'), $blogname); /** * Filter the subject of the password reset email. * * @since 2.8.0 * * @param string $title Default email title. */ $title = apply_filters('retrieve_password_title', $title); /** * Filter the message body of the password reset mail. * * @since 2.8.0 * * @param string $message Default mail message. * @param string $key The activation key. */ $message = apply_filters('retrieve_password_message', $message, $key); if ($message && !wp_mail($user_email, wp_specialchars_decode($title), $message)) { echo '<span class="wrong-response">' . __("Failure!", 'kleo_framework'); echo __('The e-mail could not be sent.'); echo "</span>"; die; } else { echo '<span class="good-response">' . __("Email successfully sent!", 'kleo_framework') . "</span>"; die; } } die; }
/** * 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)); } }
<?php $mail_format = isset($mail['mail_format']) ? $mail['mail_format'] : 'html'; ?> <td> <select style="width: 158px;" id="wpem_mail_format" name="mail[mail_format]"> <option <?php selected($mail_format, 'html', 1); ?> value="html">HTML</option> <option <?php selected($mail_format, 'plaintext', 1); ?> value="plaintext">Plain text</option> </select> <?php if ($errmsg = $errors->get_error_message('mail_format')) { ?> <p class="error ui-state-highlight ui-corner-all"> <span style="float: left; margin-right: .3em;" class="ui-icon ui-icon-info"></span><?php echo $errmsg; ?> </p> <?php } ?> </td> </tr> <tr> <th>From Name</th> <td> <?php
/** * Validate the default user registration form. * * @param WP_Error $errors * @param WP_Post $object * @return WP_Error */ public static function register_form_validate($errors, $object) { $user = wp_get_current_user(); if (0 == $user->ID) { // Username. if (!empty($_POST['account_username'])) { if (!validate_username($_POST['account_username'])) { $errors->add('invalid_username', __('Please check if you entered your username correctly.', 'ibeducator')); } } else { $errors->add('account_info_empty', __('Please enter your username and email.', 'ibeducator')); } // Email. if (!empty($_POST['account_email'])) { if (!is_email($_POST['account_email'])) { $errors->add('invalid_email', __('Please check if you entered your email correctly.', 'ibeducator')); } } elseif (!$errors->get_error_message('account_info_empty')) { $errors->add('account_info_empty', __('Please enter your username and email.', 'ibeducator')); } } if (ib_edu_collect_billing_data($object)) { // First Name. if (empty($_POST['billing_first_name'])) { $errors->add('billing_first_name_empty', __('Please enter your first name.', 'ibeducator')); } // Last Name. if (empty($_POST['billing_last_name'])) { $errors->add('billing_last_name_empty', __('Please enter your last name.', 'ibeducator')); } // Address. if (empty($_POST['billing_address'])) { $errors->add('billing_address_empty', __('Please enter your billing address.', 'ibeducator')); } // Address Line 2. if (empty($_POST['billing_city'])) { $errors->add('billing_city_empty', __('Please enter your billing city.', 'ibeducator')); } // State / Province. if (empty($_POST['billing_state'])) { $errors->add('billing_state_empty', __('Please enter your billing state / province.', 'ibeducator')); } // Postcode / Zip. if (empty($_POST['billing_postcode'])) { $errors->add('billing_postcode_empty', __('Please enter your billing postcode / zip.', 'ibeducator')); } // Country. if (empty($_POST['billing_country'])) { $errors->add('billing_country_empty', __('Please select your billing country.', 'ibeducator')); } } return $errors; }
/** * Redirect to the application URL with errors returned in the Authorization * Code grant. * * @since 1.0.0 * * @param WP_Error $error Error. */ protected function report_error(WP_Error $error) { $url = $this->get_application_url(array('error' => $error->get_error_code(), 'error_description' => urlencode($error->get_error_message()), 'error_uri' => urlencode($error->get_error_data('error_uri')))); wp_safe_redirect($url); exit; }
/** * Handler for 'register_post' action. Intercepts potential 'email_exists' * error and sets flags for later use, pertaining to if multiple accounts are * authorized for the email address and/or if the email has exceeded its * allocated number of accounts. * * @param string $user_login User login. * @param string $user_email User email address. * @param WP_Error $errors Error object. * @param int $user_id Optional. ID of existing user, if updating a user. */ public function register_post($user_login, $user_email, $errors, $user_id = null) { $options = $this->get_options(); $allow_multiple_accounts = $options['allow_for_everyone'] || in_array($user_email, $options['emails']); if ($errors->get_error_message('email_exists') && $allow_multiple_accounts) { if ($this->has_exceeded_limit($user_email, $user_id)) { $this->exceeded_limit = true; } else { $this->allow_multiple_accounts = true; } } }
/** * Returns HTML partial that contains password-reset form. * Based on WordPress core code from wp-login.php * * @since 1.0.0 * * @return string */ private function reset_form() { static $Reset_Result = null; if (null === $Reset_Result) { lib3()->array->equip_get('login', 'key'); lib3()->array->equip_post('pass1', 'pass2'); $rp_login = wp_unslash($_GET['login']); $rp_key = wp_unslash($_GET['key']); $err_msg = new WP_Error(); $fatal_error = false; lib3()->array->strip_slashes($_POST, 'pass1', 'pass2'); $pass1 = $_POST['pass1']; $pass2 = $_POST['pass2']; // Get the user object and validate the key. if ($rp_login && $rp_key) { $user = check_password_reset_key($rp_key, $rp_login); } else { $user = false; } if (!$user || is_wp_error($user)) { // If the user was not found then show an error message. if ($user && 'expired_key' == $user->get_error_code()) { $fatal_error = true; $err_msg->add('password_expired_key', __('Sorry, this reset-key is not valid anymore. Please request a new reset email and try again.', 'membership2')); } else { $fatal_error = true; $err_msg->add('password_invalid_key', __('Sorry, we did not find a valid reset-key. Please request a new reset email and try again.', 'membership2')); } } else { // If the user provided a new password, then check it now. if ($pass1 && $pass1 != $pass2) { $pass1 = false; $err_msg->add('password_reset_mismatch', __('The passwords do not match, try again.', 'membership2')); } } if ($fatal_error && count($err_msg->errors)) { $url = esc_url_raw(add_query_arg(array('show' => 'lostpass'), remove_query_arg(array('action', 'key', 'login')))); $Reset_Result = sprintf('[ms-note type="warning"]%s[/ms-note]<a href="%s">%s</a>', $err_msg->get_error_message(), $url, __('Request a new password-reset key', 'membership2')); } elseif ($pass1) { // This action is documented in wp-login.php do_action('validate_password_reset', $err_msg, $user); reset_password($user, $_POST['pass1']); // All done! Show success message and link to login form $url = esc_url_raw(remove_query_arg(array('action', 'key', 'login'))); $Reset_Result = sprintf('[ms-note type="info"]%s[/ms-note]<a href="%s">%s</a>', __('Your Password has been reset.', 'membership2'), $url, __('Login with your new password', 'membership2')); } else { // This action is documented in wp-login.php do_action('validate_password_reset', $err_msg, $user); wp_enqueue_script('utils'); wp_enqueue_script('user-profile'); ob_start(); if (count($err_msg->errors)) { printf('[ms-note type="warning"]%s[/ms-note]', implode('<br>', $err_msg->get_error_messages())); } ?> <form name="resetpassform" id="resetpassform" action="" method="post" autocomplete="off" class="ms-form"> <input type="hidden" id="user_login" value="<?php echo esc_attr($rp_login); ?> " autocomplete="off"/> <p class="user-pass1-wrap"> <label for="pass1"><?php _e('New password'); ?> </label><br /> <div class="wp-pwd"> <span class="password-input-wrapper"> <input type="password" data-reveal="1" data-pw="<?php echo esc_attr(wp_generate_password(16)); ?> " name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" aria-describedby="pass-strength-result" /> </span> <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e('Strength indicator'); ?> </div> </div> </p> <p class="user-pass2-wrap"> <label for="pass2"><?php _e('Confirm new password'); ?> </label><br /> <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" /> </p> <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?> </p> <br class="clear"/> <?php // This action is documented in wp-login.php do_action('resetpass_form', $user); ?> <p class="submit"> <input type="hidden" name="rp_key" value="<?php echo esc_attr($rp_key); ?> " /> <button type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large"> <?php _e('Reset Password', 'membership2'); ?> </button> </p> </form> <?php $html = ob_get_clean(); $Reset_Result = apply_filters('ms_compact_code', $html); } $Reset_Result = do_shortcode($Reset_Result); } return $Reset_Result; }
/** * Register a notice when authentication failed. * * @since 0.1.0 * * @param WP_Error $request WP_Error object * * @return bool Failed connection. */ public function oops_error_message($request) { $message = ' <h4>' . $request->get_error_message() . '</h4> <h4>' . $request->get_error_code() . '</h4> <xmp>Error Data: ' . print_r($request->get_error_data(), true) . '</xmp> <p><a class="button-secondary" href="' . add_query_arg('dismiss_errrors', 1) . '">' . __('Dismiss Errors', 'wds-rest-connect-ui') . '</a></p> '; $this->register_notice($message); return false; }
public function CheckDriveApp() { if (!$this->canconnect) { $this->AdminNotice(true); return false; } $authorize = true; $authorizebutton = "<input id='authorizeDrive_button' type='button' value='" . __('(Re) Authorize the Plugin!', 'useyourdrive') . "' class='button-primary'/>"; $revokebutton = "<input id='revokeDrive_button' type='button' value='" . __('Revoke authorization', 'useyourdrive') . "' class='button-secondary'/> "; $appInfo = $this->UseyourDrive->setAppConfig('force'); if (is_wp_error($appInfo)) { echo "<div id='message' class='error'><p>" . $appInfo->get_error_message() . "</p></div>"; return false; } /* are we coming from Google API auth page? */ if (!empty($_GET['code'])) { $createToken = $this->UseyourDrive->createToken(); if (is_wp_error($createToken)) { echo "<div id='message' class='error'><p>" . $createToken->get_error_message() . '</p><p>' . $authorizebutton . "</p></div>"; } else { $page = isset($_GET["page"]) ? '?page=' . $_GET["page"] : ''; $location = get_admin_url(null, 'admin.php' . $page); echo "<script type='text/javascript'>window.location.href = '" . $location . "';</script>"; } } $authUrl = $this->UseyourDrive->startWebAuth(); $hasToken = $this->UseyourDrive->loadToken(); if (!empty($_GET['error']) && $_GET['error'] === 'access_denied') { $this->UseyourDrive->revokeToken(); $hasToken = new WP_Error('broke', __("The plugin isn't yet authorized to use your Google Drive! Please (re)-authorize the plugin", 'useyourdrive')); } if (is_wp_error($hasToken)) { echo "<div id='message' class='error'><p>" . $hasToken->get_error_message() . '</p><p>' . $authorizebutton . "</p></div>"; } else { $client = $this->UseyourDrive->startClient(); $accountInfo = $this->UseyourDrive->getAccountInfo(); if ($accountInfo === false) { $error = new WP_Error('broke', __("Plugin isn't linked to your Google Drive anymore... Please Reauthorize!", 'useyourdrive')); echo "<div id='message' class='error'><p>" . $error->get_error_message() . '</p><p>' . $authorizebutton . "</p></div>"; } else { if (is_wp_error($accountInfo)) { $error = $accountInfo; echo "<div id='message' class='error'><p>" . $error->get_error_message() . '</p><p>' . $authorizebutton . "</p></div>"; } else { $user = $accountInfo->getName(); $email = $accountInfo->getEmail(); $driveInfo = $this->UseyourDrive->getDriveInfo(); if (is_wp_error($driveInfo)) { $error = $driveInfo; echo "<div id='message' class='error'><p><strong>{$user} ({$email})</strong></p><p><i>" . $error->get_error_message() . "</i></p><p>" . __('Use-your-Drive can\'t access your Google Drive as the Google Drive App isn\'t properly configurated.', 'useyourdrive') . " Please use <a href='https://cloud.google.com/console' target='_blank'>Google Developers Console</a> to activate the <strong>Drive API</strong> (not SDK) for your project. You can find this setting under 'APIs & auth'.</p><p>" . $revokebutton . "</p></div>"; } else { $storage = UseyourDrive_bytesToSize1024($driveInfo->getQuotaBytesUsed()) . '/' . UseyourDrive_bytesToSize1024($driveInfo->getQuotaBytesTotal()); $authorize = false; echo "<div id='message' class='updated'><p>" . __('Use-your-Drive is succesfully authorized and linked with your Google account:', 'useyourdrive') . "<br/><strong>{$user} ({$email} - {$storage})</strong></p><p>" . $revokebutton . $authorizebutton . "</p></div>"; } } } } ?> <script type="text/javascript" > jQuery(document).ready(function ($) { $('#authorizeDrive_button').click(function () { window.location = '<?php echo $authUrl; ?> '; }); $('#revokeDrive_button').click(function () { $.ajax({type: "POST", url: '<?php echo admin_url('admin-ajax.php'); ?> ', data: { action: 'useyourdrive-revoke' }, success: function (response) { location.reload(true) }, dataType: 'json' }); }); }); </script> <?php }
/** * Output the input fields for the blog creation form. * * @param string $blogname Optional. The default blog name (path or domain). * @param string $blog_title Optional. The default blog title. * @param string|WP_Error $errors Optional. The WP_Error object returned by a previous * submission attempt. */ function bp_blogs_signup_blog($blogname = '', $blog_title = '', $errors = '') { global $current_site; // Blog name if (!is_subdomain_install()) { echo '<label for="blogname">' . __('Site Name:', 'buddypress') . '</label>'; } else { echo '<label for="blogname">' . __('Site Domain:', 'buddypress') . '</label>'; } if ($errmsg = $errors->get_error_message('blogname')) { ?> <p class="error"><?php echo $errmsg; ?> </p> <?php } if (!is_subdomain_install()) { echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span> <input name="blogname" type="text" id="blogname" value="' . $blogname . '" maxlength="63" /><br />'; } else { echo '<input name="blogname" type="text" id="blogname" value="' . $blogname . '" maxlength="63" ' . bp_get_form_field_attributes('blogname') . '/> <span class="suffix_address">.' . bp_blogs_get_subdomain_base() . '</span><br />'; } if (!is_user_logged_in()) { print '(<strong>' . __('Your address will be ', 'buddypress'); if (!is_subdomain_install()) { print $current_site->domain . $current_site->path . __('blogname', 'buddypress'); } else { print __('domain.', 'buddypress') . $current_site->domain . $current_site->path; } echo '.</strong> ' . __('Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)', 'buddypress') . '</p>'; } // Blog Title ?> <label for="blog_title"><?php _e('Site Title:', 'buddypress'); ?> </label> <?php if ($errmsg = $errors->get_error_message('blog_title')) { ?> <p class="error"><?php echo $errmsg; ?> </p> <?php } echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_html($blog_title, 1) . '" /></p>'; ?> <p> <label for="blog_public_on"><?php _e('Privacy:', 'buddypress'); ?> </label> <?php _e('I would like my site to appear in search engines, and in public listings around this network.', 'buddypress'); ?> <label class="checkbox" for="blog_public_on"> <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if (!isset($_POST['blog_public']) || '1' == $_POST['blog_public']) { ?> checked="checked"<?php } ?> /> <strong><?php _e('Yes', 'buddypress'); ?> </strong> </label> <label class="checkbox" for="blog_public_off"> <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if (isset($_POST['blog_public']) && '0' == $_POST['blog_public']) { ?> checked="checked"<?php } ?> /> <strong><?php _e('No', 'buddypress'); ?> </strong> </label> </p> <?php /** * Fires at the end of all of the default input fields for blog creation form. * * @since BuddyPress (1.0.0) * * @param WP_Error $errors WP_Error object if any present. */ do_action('signup_blogform', $errors); }
/** * Shortcut to add a WP_Error to the log. * * @since 1.3.0 * * @param WP_Error $error * @return WP_Error */ public static function add_wp_error(WP_Error $error) { return self::add_error($error->get_error_code(), $error->get_error_message(), $error->get_error_data()); }
/** * Display the coming soon page */ function render_comingsoon_page() { extract(seed_csp4_get_settings()); if (!isset($status)) { $err = new WP_Error('error', __("Please enter your settings.", 'coming-soon')); echo $err->get_error_message(); exit; } if (empty($_GET['cs_preview'])) { $_GET['cs_preview'] = false; } // Check if Preview $is_preview = false; if (isset($_GET['cs_preview']) && $_GET['cs_preview'] == 'true') { $is_preview = true; } // Exit if a custom login page if (empty($disable_default_excluded_urls)) { if (preg_match("/login|admin|dashboard|account/i", $_SERVER['REQUEST_URI']) > 0 && $is_preview == false) { return false; } } // Check if user is logged in. if ($is_preview === false) { if (is_user_logged_in()) { return false; } } // Finally check if we should show the coming soon page. $this->comingsoon_rendered = true; // set headers if ($status == '2') { header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); header('Retry-After: 86400'); // retry in a day $csp4_maintenance_file = WP_CONTENT_DIR . "/maintenance.php"; if (!empty($enable_maintenance_php) and file_exists($csp4_maintenance_file)) { include_once $csp4_maintenance_file; exit; } } // render template tags $template = $this->get_default_template(); require_once SEED_CSP4_PLUGIN_PATH . '/themes/default/functions.php'; $template_tags = array('{Title}' => seed_csp4_title(), '{MetaDescription}' => seed_csp4_metadescription(), '{Privacy}' => seed_csp4_privacy(), '{Favicon}' => seed_csp4_favicon(), '{CustomCSS}' => seed_csp4_customcss(), '{Head}' => seed_csp4_head(), '{Footer}' => seed_csp4_footer(), '{Logo}' => seed_csp4_logo(), '{Headline}' => seed_csp4_headline(), '{Description}' => seed_csp4_description(), '{Credit}' => seed_csp4_credit()); echo strtr($template, $template_tags); exit; }
/** * Prepare the bucket error before returning to JS * * @param WP_Error $object * @param bool $single Are we dealing with a single bucket? * * @return array */ function prepare_bucket_error($object, $single = true) { if ('Access Denied' === $object->get_error_message()) { // If the bucket error is access denied, show our notice message $out = array('error' => $this->get_access_denied_notice_message($single)); } else { $out = array('error' => $object->get_error_message()); } return $out; }
/** * Echo a JSON error message, set a HTTP status, and exit * * @since 1.0 * @param WP_Error $error error code of HTTP status int. error message echoed in JSON */ public static function reject_message(WP_Error $error) { status_header($error->get_error_code()); wp_send_json(array('error' => $error->get_error_message())); }
/** * Trigger an error if the quantity for a capped ticket is exceeded. * * @param int $product_id */ protected function cart_flag_capped_stock_error($product_id) { $error = new WP_Error(); $ticket_name = get_the_title($product_id); $message = sprintf(__('Sorry, there is insufficient stock to fulfill your order with respect to %s', 'event-tickets-plus'), '<i>' . $ticket_name . '</i>'); /** * Error message generated when an insufficiency of stock for a capped-sales ticket * is discovered during validation of cart item quantities. * * @param string $message * @param int $product_ud */ $message = apply_filters('tribe_tickets_plus_edd_global_stock_cart_error', $message, $product_id); $error->add('out-of-capped-stock-' . $product_id, $message); edd_set_error('insufficient_stock_capped_' . $product_id, $error->get_error_message()); }
/** * Upgrade the core of WordPress. * * This will create a .maintenance file at the base of the WordPress directory * to ensure that people can not access the web site, when the files are being * copied to their locations. * * The files in the {@link $_old_files} list will be removed and the new files * copied from the zip file after the database is upgraded. * * The files in the {@link $_new_bundled_files} list will be added to the installation * if the version is greater than or equal to the old version being upgraded. * * The steps for the upgrader for after the new release is downloaded and * unzipped is: * 1. Test unzipped location for select files to ensure that unzipped worked. * 2. Create the .maintenance file in current WordPress base. * 3. Copy new WordPress directory over old WordPress files. * 4. Upgrade WordPress to new version. * 4.1. Copy all files/folders other than wp-content * 4.2. Copy any language files to WP_LANG_DIR (which may differ from WP_CONTENT_DIR * 4.3. Copy any new bundled themes/plugins to their respective locations * 5. Delete new WordPress directory path. * 6. Delete .maintenance file. * 7. Remove old files. * 8. Delete 'update_core' option. * * There are several areas of failure. For instance if PHP times out before step * 6, then you will not be able to access any portion of your site. Also, since * the upgrade will not continue where it left off, you will not be able to * automatically remove old files and remove the 'update_core' option. This * isn't that bad. * * If the copy of the new WordPress over the old fails, then the worse is that * the new WordPress directory will remain. * * If it is assumed that every file will be copied over, including plugins and * themes, then if you edit the default theme, you should rename it, so that * your changes remain. * * @since 2.7.0 * * @global WP_Filesystem_Base $wp_filesystem * @global array $_old_files * @global array $_new_bundled_files * @global wpdb $wpdb * @global string $wp_version * @global string $required_php_version * @global string $required_mysql_version * * @param string $from New release unzipped path. * @param string $to Path to old WordPress installation. * @return WP_Error|null WP_Error on failure, null on success. */ function update_core($from, $to) { global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb; @set_time_limit(300); /** * Filter feedback messages displayed during the core update process. * * The filter is first evaluated after the zip file for the latest version * has been downloaded and unzipped. It is evaluated five more times during * the process: * * 1. Before WordPress begins the core upgrade process. * 2. Before Maintenance Mode is enabled. * 3. Before WordPress begins copying over the necessary files. * 4. Before Maintenance Mode is disabled. * 5. Before the database is upgraded. * * @since 2.5.0 * * @param string $feedback The core update feedback messages. */ apply_filters('update_feedback', __('Verifying the unpacked files…')); // Sanity check the unzipped distribution. $distro = ''; $roots = array('/wordpress/', '/wordpress-mu/'); foreach ($roots as $root) { if ($wp_filesystem->exists($from . $root . 'readme.html') && $wp_filesystem->exists($from . $root . 'wp-includes/version.php')) { $distro = $root; break; } } if (!$distro) { $wp_filesystem->delete($from, true); return new WP_Error('insane_distro', __('The update could not be unpacked')); } /** * Import $wp_version, $required_php_version, and $required_mysql_version from the new version * $wp_filesystem->wp_content_dir() returned unslashed pre-2.8 * * @global string $wp_version * @global string $required_php_version * @global string $required_mysql_version */ global $wp_version, $required_php_version, $required_mysql_version; $versions_file = trailingslashit($wp_filesystem->wp_content_dir()) . 'upgrade/version-current.php'; if (!$wp_filesystem->copy($from . $distro . 'wp-includes/version.php', $versions_file)) { $wp_filesystem->delete($from, true); return new WP_Error('copy_failed_for_version_file', __('The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.'), 'wp-includes/version.php'); } $wp_filesystem->chmod($versions_file, FS_CHMOD_FILE); require WP_CONTENT_DIR . '/upgrade/version-current.php'; $wp_filesystem->delete($versions_file); $php_version = phpversion(); $mysql_version = $wpdb->db_version(); $old_wp_version = $wp_version; // The version of WordPress we're updating from $development_build = false !== strpos($old_wp_version . $wp_version, '-'); // a dash in the version indicates a Development release $php_compat = version_compare($php_version, $required_php_version, '>='); if (file_exists(WP_CONTENT_DIR . '/db.php') && empty($wpdb->is_mysql)) { $mysql_compat = true; } else { $mysql_compat = version_compare($mysql_version, $required_mysql_version, '>='); } if (!$mysql_compat || !$php_compat) { $wp_filesystem->delete($from, true); } if (!$mysql_compat && !$php_compat) { return new WP_Error('php_mysql_not_compatible', sprintf(__('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version)); } elseif (!$php_compat) { return new WP_Error('php_not_compatible', sprintf(__('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version)); } elseif (!$mysql_compat) { return new WP_Error('mysql_not_compatible', sprintf(__('The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version)); } /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters('update_feedback', __('Preparing to install the latest version…')); // Don't copy wp-content, we'll deal with that below // We also copy version.php last so failed updates report their old version $skip = array('wp-content', 'wp-includes/version.php'); $check_is_writable = array(); // Check to see which files don't really need updating - only available for 3.7 and higher if (function_exists('get_core_checksums')) { // Find the local version of the working directory $working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename($from) . $distro; $checksums = get_core_checksums($wp_version, isset($wp_local_package) ? $wp_local_package : 'en_US'); if (is_array($checksums) && isset($checksums[$wp_version])) { $checksums = $checksums[$wp_version]; } // Compat code for 3.7-beta2 if (is_array($checksums)) { foreach ($checksums as $file => $checksum) { if ('wp-content' == substr($file, 0, 10)) { continue; } if (!file_exists(ABSPATH . $file)) { continue; } if (!file_exists($working_dir_local . $file)) { continue; } if (md5_file(ABSPATH . $file) === $checksum) { $skip[] = $file; } else { $check_is_writable[$file] = ABSPATH . $file; } } } } // If we're using the direct method, we can predict write failures that are due to permissions. if ($check_is_writable && 'direct' === $wp_filesystem->method) { $files_writable = array_filter($check_is_writable, array($wp_filesystem, 'is_writable')); if ($files_writable !== $check_is_writable) { $files_not_writable = array_diff_key($check_is_writable, $files_writable); foreach ($files_not_writable as $relative_file_not_writable => $file_not_writable) { // If the writable check failed, chmod file to 0644 and try again, same as copy_dir(). $wp_filesystem->chmod($file_not_writable, FS_CHMOD_FILE); if ($wp_filesystem->is_writable($file_not_writable)) { unset($files_not_writable[$relative_file_not_writable]); } } // Store package-relative paths (the key) of non-writable files in the WP_Error object. $error_data = version_compare($old_wp_version, '3.7-beta2', '>') ? array_keys($files_not_writable) : ''; if ($files_not_writable) { return new WP_Error('files_not_writable', __('The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.'), implode(', ', $error_data)); } } } /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters('update_feedback', __('Enabling Maintenance mode…')); // Create maintenance file to signal that we are upgrading $maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; $maintenance_file = $to . '.maintenance'; $wp_filesystem->delete($maintenance_file); $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE); /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters('update_feedback', __('Copying the required files…')); // Copy new versions of WP files into place. $result = _copy_dir($from . $distro, $to, $skip); if (is_wp_error($result)) { $result = new WP_Error($result->get_error_code(), $result->get_error_message(), substr($result->get_error_data(), strlen($to))); } // Since we know the core files have copied over, we can now copy the version file if (!is_wp_error($result)) { if (!$wp_filesystem->copy($from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true)) { $wp_filesystem->delete($from, true); $result = new WP_Error('copy_failed_for_version_file', __('The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.'), 'wp-includes/version.php'); } $wp_filesystem->chmod($to . 'wp-includes/version.php', FS_CHMOD_FILE); } // Check to make sure everything copied correctly, ignoring the contents of wp-content $skip = array('wp-content'); $failed = array(); if (isset($checksums) && is_array($checksums)) { foreach ($checksums as $file => $checksum) { if ('wp-content' == substr($file, 0, 10)) { continue; } if (!file_exists($working_dir_local . $file)) { continue; } if (file_exists(ABSPATH . $file) && md5_file(ABSPATH . $file) == $checksum) { $skip[] = $file; } else { $failed[] = $file; } } } // Some files didn't copy properly if (!empty($failed)) { $total_size = 0; foreach ($failed as $file) { if (file_exists($working_dir_local . $file)) { $total_size += filesize($working_dir_local . $file); } } // If we don't have enough free space, it isn't worth trying again. // Unlikely to be hit due to the check in unzip_file(). $available_space = @disk_free_space(ABSPATH); if ($available_space && $total_size >= $available_space) { $result = new WP_Error('disk_full', __('There is not enough free disk space to complete the update.')); } else { $result = _copy_dir($from . $distro, $to, $skip); if (is_wp_error($result)) { $result = new WP_Error($result->get_error_code() . '_retry', $result->get_error_message(), substr($result->get_error_data(), strlen($to))); } } } // Custom Content Directory needs updating now. // Copy Languages if (!is_wp_error($result) && $wp_filesystem->is_dir($from . $distro . 'wp-content/languages')) { if (WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir(WP_LANG_DIR)) { $lang_dir = WP_LANG_DIR; } else { $lang_dir = WP_CONTENT_DIR . '/languages'; } if (!@is_dir($lang_dir) && 0 === strpos($lang_dir, ABSPATH)) { // Check the language directory exists first $wp_filesystem->mkdir($to . str_replace(ABSPATH, '', $lang_dir), FS_CHMOD_DIR); // If it's within the ABSPATH we can handle it here, otherwise they're out of luck. clearstatcache(); // for FTP, Need to clear the stat cache } if (@is_dir($lang_dir)) { $wp_lang_dir = $wp_filesystem->find_folder($lang_dir); if ($wp_lang_dir) { $result = copy_dir($from . $distro . 'wp-content/languages/', $wp_lang_dir); if (is_wp_error($result)) { $result = new WP_Error($result->get_error_code() . '_languages', $result->get_error_message(), substr($result->get_error_data(), strlen($wp_lang_dir))); } } } } /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters('update_feedback', __('Disabling Maintenance mode…')); // Remove maintenance file, we're done with potential site-breaking changes $wp_filesystem->delete($maintenance_file); // 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users, preventing installation of Twenty Twelve. if ('3.5' == $old_wp_version) { if (is_dir(WP_CONTENT_DIR . '/themes/twentytwelve') && !file_exists(WP_CONTENT_DIR . '/themes/twentytwelve/style.css')) { $wp_filesystem->delete($wp_filesystem->wp_themes_dir() . 'twentytwelve/'); } } // Copy New bundled plugins & themes // This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue. // $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated if (!is_wp_error($result) && (!defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || !CORE_UPGRADE_SKIP_NEW_BUNDLED)) { foreach ((array) $_new_bundled_files as $file => $introduced_version) { // If a $development_build or if $introduced version is greater than what the site was previously running if ($development_build || version_compare($introduced_version, $old_wp_version, '>')) { $directory = '/' == $file[strlen($file) - 1]; list($type, $filename) = explode('/', $file, 2); // Check to see if the bundled items exist before attempting to copy them if (!$wp_filesystem->exists($from . $distro . 'wp-content/' . $file)) { continue; } if ('plugins' == $type) { $dest = $wp_filesystem->wp_plugins_dir(); } elseif ('themes' == $type) { $dest = trailingslashit($wp_filesystem->wp_themes_dir()); } else { continue; } if (!$directory) { if (!$development_build && $wp_filesystem->exists($dest . $filename)) { continue; } if (!$wp_filesystem->copy($from . $distro . 'wp-content/' . $file, $dest . $filename, FS_CHMOD_FILE)) { $result = new WP_Error("copy_failed_for_new_bundled_{$type}", __('Could not copy file.'), $dest . $filename); } } else { if (!$development_build && $wp_filesystem->is_dir($dest . $filename)) { continue; } $wp_filesystem->mkdir($dest . $filename, FS_CHMOD_DIR); $_result = copy_dir($from . $distro . 'wp-content/' . $file, $dest . $filename); // If a error occurs partway through this final step, keep the error flowing through, but keep process going. if (is_wp_error($_result)) { if (!is_wp_error($result)) { $result = new WP_Error(); } $result->add($_result->get_error_code() . "_{$type}", $_result->get_error_message(), substr($_result->get_error_data(), strlen($dest))); } } } } //end foreach } // Handle $result error from the above blocks if (is_wp_error($result)) { $wp_filesystem->delete($from, true); return $result; } // Remove old files foreach ($_old_files as $old_file) { $old_file = $to . $old_file; if (!$wp_filesystem->exists($old_file)) { continue; } $wp_filesystem->delete($old_file, true); } // Remove any Genericons example.html's from the filesystem _upgrade_422_remove_genericons(); // Upgrade DB with separate request /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters('update_feedback', __('Upgrading database…')); $db_upgrade_url = admin_url('upgrade.php?step=upgrade_db'); wp_remote_post($db_upgrade_url, array('timeout' => 60)); // Clear the cache to prevent an update_option() from saving a stale db_version to the cache wp_cache_flush(); // (Not all cache backends listen to 'flush') wp_cache_delete('alloptions', 'options'); // Remove working directory $wp_filesystem->delete($from, true); // Force refresh of update information if (function_exists('delete_site_transient')) { delete_site_transient('update_core'); } else { delete_option('update_core'); } /** * Fires after WordPress core has been successfully updated. * * @since 3.3.0 * * @param string $wp_version The current WordPress version. */ do_action('_core_updated_successfully', $wp_version); // Clear the option that blocks auto updates after failures, now that we've been successful. if (function_exists('delete_site_option')) { delete_site_option('auto_core_update_failed'); } return $wp_version; }
/** * Log a message about the syncing process. * * @param WP_Error $error While the message may not be an "error" per se, * this uses WP_Error to keep organized. */ public function log(WP_Error $error) { if (defined('WP_CLI') && WP_CLI) { $method = $error->get_error_code(); if (!in_array($method, array('success', 'warning', 'error'))) { $method = 'line'; } $message = $error->get_error_data() ? $error->get_error_message() . "; Data: " . json_encode($error->get_error_data()) : $error->get_error_message(); call_user_func(array('WP_CLI', $method), $message); $this->data['messages'][$error->get_error_code()][] = $message; } else { $this->data['messages'][$error->get_error_code()][] = $error->get_error_message(); set_transient($this->error_transient, true); if (!$this->data['running']) { $this->save(); } } }