本文整理汇总了PHP中WP_Error::get_error_data方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Error::get_error_data方法的具体用法?PHP WP_Error::get_error_data怎么用?PHP WP_Error::get_error_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Error
的用法示例。
在下文中一共展示了WP_Error::get_error_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_service_unavailable
/**
* Whether the job result indicates that the service is unavailable and will return.
*
* @since 1.4.10
*
* @return boolean
*/
protected function is_service_unavailable()
{
$data = is_wp_error($this->job_result) ? $this->job_result->get_error_data() : $this->job_result;
if (!is_array($data)) {
return false;
}
if (!isset($data['response']['code'])) {
return false;
}
return 503 == $data['response']['code'];
}
示例2: 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);
}
示例3:
/**
* @ticket 28092
*/
function test_remove_error()
{
$error = new WP_Error();
$error->add('foo', 'This is the first error message', 'some error data');
$error->add('foo', 'This is the second error message');
$error->add('bar', 'This is another error');
$error->remove('foo');
// Check the error has been removed.
$this->assertEmpty($error->get_error_data('foo'));
$this->assertEmpty($error->get_error_messages('foo'));
// The 'bar' error should now be the 'first' error retrieved.
$this->assertEquals('bar', $error->get_error_code());
$this->assertEmpty($error->get_error_data());
}
示例4: fourtwo_ppe_validateComplexPassword
/**
* validate complex password
*
* @author Joe Sexton <joe.@webtipblog.com>
* @param WP_Error $errors
* @param stdClass $userData
* @return WP_Error
*/
function fourtwo_ppe_validateComplexPassword($errors)
{
$password = isset($_POST['pass1']) && trim($_POST['pass1']) ? $_POST['pass1'] : null;
// no password or already has password error
if (empty($password) || $errors->get_error_data('pass')) {
return $errors;
}
$pass = fourtwo_ppe_isStrongPassword($password);
// validate
if (!$pass['length']) {
$errors->add('pass', '<strong>ERROR</strong>: Your password must contain at least eight (8) characters.');
}
if (!$pass['num']) {
$errors->add('pass', '<strong>ERROR</strong>: Your password must contain at least one (1) number.');
}
if (!$pass['alpha']) {
$errors->add('pass', '<strong>ERROR</strong>: Your password must contain at least one (1) letter.');
}
if (!$pass['upper']) {
$errors->add('pass', '<strong>ERROR</strong>: Your password must contain at least one (1) uppercase letter.');
}
if (!$pass['lower']) {
$errors->add('pass', '<strong>ERROR</strong>: Your password must contain at least one (1) lowercase letter.');
}
if (!$pass['special']) {
$errors->add('pass', '<strong>ERROR</strong>: Your password must contain at least one (1) special character.');
}
return $errors;
}
开发者ID:42Web,项目名称:FourTwo-Password-Policy-Enforcement,代码行数:37,代码来源:fourtwo-password-policy-enforcement.php
示例5: login_header
function login_header($title = 'Login', $message = '', $wp_error = '') {
global $error;
if ( empty($wp_error) )
$wp_error = new WP_Error();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<title><?php bloginfo('name'); ?> › <?php echo $title; ?></title>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<?php
wp_admin_css( 'css/login' );
wp_admin_css( 'css/colors-fresh' );
?>
<script type="text/javascript">
function focusit() {
document.getElementById('user_login').focus();
}
window.onload = focusit;
</script>
<?php do_action('login_head'); ?>
</head>
<body class="login">
<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', __('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1>
<?php
if ( !empty( $message ) ) echo apply_filters('login_message', $message) . "\n";
// Incase a plugin uses $error rather than the $errors object
if ( !empty( $error ) ) {
$wp_error->add('error', $error);
unset($error);
}
if ( $wp_error->get_error_code() ) {
$errors = '';
$messages = '';
foreach ( $wp_error->get_error_codes() as $code ) {
$severity = $wp_error->get_error_data($code);
foreach ( $wp_error->get_error_messages($code) as $error ) {
if ( 'message' == $severity )
$messages .= ' ' . $error . "<br />\n";
else
$errors .= ' ' . $error . "<br />\n";
}
}
if ( !empty($errors) )
echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
if ( !empty($messages) )
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
}
} // End of login_header()
示例6: importErrors
/**
* Merge errors from another WP_Error object into the one dedicated to this model object.
*
* @param \WP_Error $otherErrors
*/
protected function importErrors(\WP_Error $otherErrors)
{
foreach ($otherErrors->get_error_codes() as $code) {
$errors = $otherErrors->get_error_messages($code);
$data = $otherErrors->get_error_data($code);
for ($i = 0; $i < max(count($errors), count($data)); $i++) {
if (array_key_exists($i, $errors)) {
$data = array_key_exists($i, $data) ? $data[$i] : null;
$this->errors->add($code, $errors[$i], $data);
}
}
}
}
示例7: login_header
/**
* Outputs the header for the login page.
*
* @uses do_action() Calls the 'login_head' for outputting HTML in the Log In
* header.
* @uses apply_filters() Calls 'login_headerurl' for the top login link.
* @uses apply_filters() Calls 'login_headertitle' for the top login title.
* @uses apply_filters() Calls 'login_message' on the message to display in the
* header.
* @uses $error The error global, which is checked for displaying errors.
*
* @param string $title Optional. WordPress Log In Page title to display in
* <title/> element.
* @param string $message Optional. Message to display in header.
* @param WP_Error $wp_error Optional. WordPress Error Object
*/
function login_header($title = 'Log In', $message = '', $wp_error = '')
{
global $error, $is_iphone, $current_site;
// Don't index any of these forms
add_filter('pre_option_blog_public', create_function('$a', 'return 0;'));
add_action('login_head', 'noindex');
if (empty($wp_error)) {
$wp_error = new WP_Error();
}
?>
<div id="login">
<?php
$message = apply_filters('login_message', $message);
if (!empty($message)) {
echo $message . "\n";
}
// Incase a plugin uses $error rather than the $errors object
if (!empty($error)) {
$wp_error->add('error', $error);
unset($error);
}
if ($wp_error->get_error_code()) {
$errors = '';
$messages = '';
foreach ($wp_error->get_error_codes() as $code) {
$severity = $wp_error->get_error_data($code);
foreach ($wp_error->get_error_messages($code) as $error) {
if ('message' == $severity) {
$messages .= ' ' . $error . "<br />\n";
} else {
$errors .= ' ' . $error . "<br />\n";
}
}
}
if (!empty($errors)) {
echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
}
if (!empty($messages)) {
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
}
}
}
示例8: extract
function simplelogin_header($title, $message = '', $wp_error = '', $args = '')
{
global $error;
extract($args);
if (empty($wp_error)) {
$wp_error = new WP_Error();
}
if (!empty($error)) {
$wp_error->add('error', $error);
unset($error);
}
echo $before_widget . $before_title . __($title, 'simplelogin') . $after_title . "\n";
echo '<div id="login">';
if (!empty($message)) {
echo apply_filters('login_message', $message) . "\n";
}
if ($wp_error->get_error_code()) {
$errors = '';
$messages = '';
foreach ($wp_error->get_error_codes() as $code) {
$severity = $wp_error->get_error_data($code);
foreach ($wp_error->get_error_messages($code) as $error) {
if ('message' == $severity) {
$messages .= ' ' . $error . "<br />\n";
} else {
$errors .= ' ' . $error . "<br />\n";
}
}
}
if (!empty($errors)) {
echo '<p class="error">' . apply_filters('login_errors', $errors) . "</p>\n";
}
if (!empty($messages)) {
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
}
}
}
示例9: wpmp_switcher_login_header
function wpmp_switcher_login_header($title, $message = '', $wp_error = '')
{
global $error;
if (empty($wp_error)) {
$wp_error = new WP_Error();
}
include_once 'mobile.php';
wpmp_ms_mobile_top($title);
if (!empty($message)) {
echo apply_filters('login_message', $message) . "\n";
}
if (!empty($error)) {
$wp_error->add('error', $error);
unset($error);
}
if ($wp_error->get_error_code()) {
$errors = '';
$messages = '';
foreach ($wp_error->get_error_codes() as $code) {
$severity = $wp_error->get_error_data($code);
foreach ($wp_error->get_error_messages($code) as $error) {
if ('message' == $severity) {
$messages .= ' ' . $error . "<br />\n";
} else {
$errors .= ' ' . $error . "<br />\n";
}
}
}
if (!empty($errors)) {
echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
}
if (!empty($messages)) {
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
}
}
}
示例10: login_header
/**
* Outputs the header for the login page.
*
* @uses do_action() Calls the 'login_head' for outputting HTML in the Log In
* header.
* @uses apply_filters() Calls 'login_headerurl' for the top login link.
* @uses apply_filters() Calls 'login_headertitle' for the top login title.
* @uses apply_filters() Calls 'login_message' on the message to display in the
* header.
* @uses $error The error global, which is checked for displaying errors.
*
* @param string $title Optional. WordPress Log In Page title to display in
* <title/> element.
* @param string $message Optional. Message to display in header.
* @param WP_Error $wp_error Optional. WordPress Error Object
*/
function login_header($title = 'Log In', $message = '', $wp_error = '') {
global $error, $is_iphone, $interim_login, $current_site;
// Don't index any of these forms
add_filter( 'pre_option_blog_public', '__return_zero' );
add_action( 'login_head', 'noindex' );
if ( empty($wp_error) )
$wp_error = new WP_Error();
// Shake it!
$shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' );
$shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) )
add_action( 'login_head', 'wp_shake_js', 12 );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<title><?php bloginfo('name'); ?> › <?php echo $title; ?></title>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<?php
wp_admin_css( 'login', true );
wp_admin_css( 'colors-fresh', true );
if ( $is_iphone ) { ?>
<meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" />
<style type="text/css" media="screen">
form { margin-left: 0px; }
#login { margin-top: 20px; }
</style>
<?php
} elseif ( isset($interim_login) && $interim_login ) { ?>
<style type="text/css" media="all">
.login #login { margin: 20px auto; }
</style>
<?php
}
do_action('login_head'); ?>
</head>
<body class="login">
<?php if ( !is_multisite() ) { ?>
<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', __('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1>
<?php } else { ?>
<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', network_home_url() ); ?>" title="<?php echo apply_filters('login_headertitle', $current_site->site_name ); ?>"><span class="hide"><?php bloginfo('name'); ?></span></a></h1>
<?php }
$message = apply_filters('login_message', $message);
if ( !empty( $message ) ) echo $message . "\n";
// Incase a plugin uses $error rather than the $errors object
if ( !empty( $error ) ) {
$wp_error->add('error', $error);
unset($error);
}
if ( $wp_error->get_error_code() ) {
$errors = '';
$messages = '';
foreach ( $wp_error->get_error_codes() as $code ) {
$severity = $wp_error->get_error_data($code);
foreach ( $wp_error->get_error_messages($code) as $error ) {
if ( 'message' == $severity )
$messages .= ' ' . $error . "<br />\n";
else
$errors .= ' ' . $error . "<br />\n";
}
}
if ( !empty($errors) )
echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
if ( !empty($messages) )
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
}
} // End of login_header()
示例11: get_wp_error_string
/**
* Retrieve all information of a WP_Error object as a string.
*
* @since 1.4.0
*
* @param WP_Error $wp_error A WP_Error object.
* @return string All error codes, messages, and data of the WP_Error.
*/
protected function get_wp_error_string($wp_error)
{
$error_strings = array();
$error_codes = $wp_error->get_error_codes();
// Reverse order to get latest errors first.
$error_codes = array_reverse($error_codes);
foreach ($error_codes as $error_code) {
$error_strings[$error_code] = $error_code;
$error_messages = $wp_error->get_error_messages($error_code);
$error_messages = implode(', ', $error_messages);
if (!empty($error_messages)) {
$error_strings[$error_code] .= " ({$error_messages})";
}
$error_data = $wp_error->get_error_data($error_code);
if (!is_null($error_data)) {
$error_strings[$error_code] .= " [{$error_data}]";
}
}
return implode(";\n", $error_strings);
}
示例12: 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));
}
}
示例13: report_error
/**
* 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;
}
示例14: log
/**
* 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();
}
}
}
示例15: prepare_errors_for_response
/**
* Prepare a WP_Error for sending to JS.
*
* @param \WP_Error $error Error.
* @return array
*/
public function prepare_errors_for_response(\WP_Error $error)
{
$exported_errors = array();
foreach ($error->errors as $code => $messages) {
$exported_errors[$code] = array('message' => join(' ', $messages), 'data' => $error->get_error_data($code));
}
return $exported_errors;
}