public function error_message()
 {
     foreach ($this->e->get_error_messages() as $message) {
         add_settings_error('dana-don-boom-boom-doo-requirement', 'plugin_requirement', $message, 'error');
     }
     add_action('admin_notices', [$this, 'show_error']);
 }
Example #2
0
/**
 * Prints warning about any hooked method with bad visibility (that are either protected or private)
 * @return void
 */
function appthemes_bad_method_visibility()
{
    global $wp_filter;
    $arguments = func_get_args();
    $tag = array_shift($arguments);
    $errors = new WP_Error();
    if (!isset($wp_filter[$tag])) {
        return;
    }
    foreach ($wp_filter[$tag] as $prioritized_callbacks) {
        foreach ($prioritized_callbacks as $callback) {
            $function = $callback['function'];
            if (is_array($function)) {
                try {
                    $method = new ReflectionMethod($function[0], $function[1]);
                    if ($method->isPrivate() || $method->isProtected()) {
                        $class = get_class($function[0]);
                        if (!$class) {
                            $class = $function[0];
                        }
                        $errors->add('visiblity', $class . '::' . $function[1] . ' was hooked into "' . $tag . '", but is either protected or private.');
                    }
                } catch (Exception $e) {
                    // Failure to replicate method. Might be magic method. Fail silently
                }
            }
        }
    }
    if ($errors->get_error_messages()) {
        foreach ($errors->get_error_messages() as $message) {
            echo $message;
        }
    }
}
 /**
  * Confirmation
  *
  * @see http://www.gravityhelp.com/documentation/page/Gform_confirmation
  */
 public function confirmation($confirmation, $form, $lead, $ajax)
 {
     if ($this->is_processing($form) && $this->gateway && $this->payment && $this->payment->get_amount() > 0) {
         if (is_wp_error($this->error)) {
             $html = '';
             $html .= '<ul>';
             $html .= '<li>' . Pronamic_WP_Pay_Plugin::get_default_error_message() . '</li>';
             foreach ($this->error->get_error_messages() as $message) {
                 $html .= '<li>' . $message . '</li>';
             }
             $html .= '</ul>';
             $confirmation = $html;
         } else {
             $confirmation = array('redirect' => $this->payment->get_pay_redirect_url());
         }
         if ((headers_sent() || $ajax) && is_array($confirmation) && isset($confirmation['redirect'])) {
             $url = $confirmation['redirect'];
             // Using esc_js() and esc_url() on the URL is causing problems, the & in the URL is modified to &amp; or &#038;
             $confirmation = sprintf('<script>function gformRedirect(){document.location.href = %s;}', json_encode($url));
             if (!$ajax) {
                 $confirmation .= 'gformRedirect();';
             }
             $confirmation .= '</script>';
         }
     }
     return $confirmation;
 }
 /**
  * Authenication for Amazon CloudFront
  *
  * @return boolean | WP_Error
  * @since 4.0.0
  * @access public
  */
 public function auth($options)
 {
     if (!isset($options['distribution_id']) || !$options['distribution_id']) {
         return new WP_Error('C3 Notice', "CloudFront Distribution ID is not defined.");
     }
     if (c3_is_later_than_php_55()) {
         $sdk = C3_Client_V3::get_instance();
     } else {
         $sdk = C3_Client_V2::get_instance();
         //@TODO: for php ~5.4, do not Authenication now.
         return true;
     }
     $cf_client = $sdk->create_cloudfront_client($options);
     if (is_wp_error($cf_client)) {
         return $cf_client;
     }
     try {
         $result = $cf_client->getDistribution(array('Id' => $options['distribution_id']));
         return true;
     } catch (Exception $e) {
         if ('NoSuchDistribution' === $e->getAwsErrorCode()) {
             $e = new WP_Error('C3 Auth Error', "Can not find CloudFront Distribution ID: {$options['distribution_id']} is not found.");
         } elseif ('InvalidClientTokenId' == $e->getAwsErrorCode()) {
             $e = new WP_Error('C3 Auth Error', "AWS AWS Access Key or AWS Secret Key is invalid.");
         } else {
             $e = new WP_Error('C3 Auth Error', $e->getMessage());
         }
         error_log($e->get_error_messages(), 0);
         return $e;
     }
 }
Example #5
0
 /**
  * Perform processing of the rebuild_form, sent by user
  *
  * @param str $form_url - URL of the page to display request form
  * @return true on success, false in case of wrong credentials, WP_Error in case of error
  **/
 function process_form($form_url)
 {
     check_ajax_referer('advads_ab_form_nonce', 'security');
     global $wp_filesystem;
     //fields that should be preserved across screens (when ftp/ssh login screen appears)
     $preserved_form_fields = array('advads_ab_form_submit', 'advads_ab_assign_new_folder', 'security', '_wp_http_referer');
     //leave this empty to perform test for 'direct' writing
     $method = '';
     //target folder
     $context = $this->upload_dir['basedir'];
     //page url with nonce value
     $form_url = wp_nonce_url($form_url, 'advads_ab_form_nonce', 'security');
     if (!$this->filesystem_init($form_url, $method, $context, $preserved_form_fields)) {
         return false;
         //stop further processing when request form is displaying
     }
     // at this point we do not need ftp/ssh credentials anymore
     $form_post_fields = array_intersect_key($_POST, array_flip(array('advads_ab_assign_new_folder')));
     $this->create_dummy_plugin($form_post_fields);
     if ($error_messages = $this->error_messages->get_error_messages()) {
         foreach ($error_messages as $error_message) {
             error_log(__METHOD__ . ': ' . $error_message);
         }
         return $this->error_messages;
         // WP_Error object
     }
     return true;
 }
Example #6
0
 /**
  * Echoes the content of the $errors array as formatted HTML if it contains error messages.
  */
 protected function display_errors()
 {
     $messages = $this->errors->get_error_messages();
     if (count($messages) > 0) {
         echo '<div class="error notice is-dismissible"><strong>' . esc_html__('Errors:', 'search-and-replace') . '</strong><ul>';
         foreach ($messages as $error) {
             echo '<li>' . esc_html($error) . '</li>';
         }
         echo '</ul></div>';
     }
 }
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()
 protected function prepare_form_errors(WP_Form_Component $component)
 {
     $errors = $this->errors->get_error_messages($component->get_name());
     foreach ($errors as $e) {
         $component->set_error($e);
     }
     if ($component instanceof WP_Form_Aggregate) {
         foreach ($component->get_children() as $child) {
             $this->prepare_form_errors($child);
         }
     }
 }
 /**
  * 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);
             }
         }
     }
 }
 /**
  * @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());
 }
 /**
  * @return array
  */
 protected function handle_error_response()
 {
     $this->handle_response();
     if (is_wp_error($this->response)) {
         foreach ($this->response->get_error_messages() as $message) {
             $this->errors[] = "WP_Error: " . $message;
         }
     }
     // Add HTTP code name
     $class = new ReflectionClass(__CLASS__);
     foreach ($class->getConstants() as $key => $val) {
         if ($val == $this->status_code) {
             $this->errors[] = 'HTTP ' . $val . ': ' . $key;
             break;
         }
     }
 }
Example #12
0
 /**
  * Confirmation
  *
  * @see http://www.gravityhelp.com/documentation/page/Gform_confirmation
  */
 public function confirmation($confirmation, $form, $lead, $ajax)
 {
     if ($this->is_processing($form) && $this->gateway && $this->payment && $this->payment->get_amount() > 0) {
         if (is_wp_error($this->error)) {
             $html = '';
             $html .= '<ul>';
             $html .= '<li>' . Pronamic_WP_Pay_Plugin::get_default_error_message() . '</li>';
             foreach ($this->error->get_error_messages() as $message) {
                 $html .= '<li>' . $message . '</li>';
             }
             $html .= '</ul>';
             $confirmation = $html;
         } else {
             if ($this->gateway->is_http_redirect()) {
                 // Redirect user to the issuer
                 $confirmation = array('redirect' => $this->payment->get_action_url());
             }
             if ($this->gateway->is_html_form()) {
                 $auto_submit = true;
                 if ($ajax) {
                     // On AJAX enabled forms we can't auto submit, this will auto submit in a hidden iframe
                     $auto_submit = false;
                 }
                 // HTML
                 $html = '';
                 $html .= '<div id="gforms_confirmation_message">';
                 $html .= GFCommon::replace_variables($form['confirmation']['message'], $form, $lead, false, true, true);
                 $html .= $this->gateway->get_form_html($this->payment, $auto_submit);
                 $html .= '</div>';
                 // Extend the confirmation with the iDEAL form
                 $confirmation = $html;
             }
         }
         if ((headers_sent() || $ajax) && is_array($confirmation) && isset($confirmation['redirect'])) {
             $url = $confirmation['redirect'];
             // Using esc_js() and esc_url() on the URL is causing problems, the & in the URL is modified to &amp; or &#038;
             $confirmation = sprintf('<script>function gformRedirect(){document.location.href = %s;}', json_encode($url));
             if (!$ajax) {
                 $confirmation .= 'gformRedirect();';
             }
             $confirmation .= '</script>';
         }
     }
     return $confirmation;
 }
Example #13
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";
        }
    }
}
 /**
  * POST時
  */
 public function admin_post()
 {
     if (isset($_POST['_wpnonce']) && $_POST['_wpnonce']) {
         $errors = new WP_Error();
         $updates = new WP_Error();
         if (check_admin_referer('mw-form-kintone', '_wpnonce')) {
             $options = get_option(MWFK_PLUGIN_NAME);
             $options['subdomain'] = esc_html($_POST['subdomain']);
             $options['user_ID'] = esc_html($_POST['user_ID']);
             $options['user_password'] = esc_html($_POST['user_password']);
             $options['api_token'] = esc_html($_POST['api_token']);
             $options['app_ID'] = esc_html($_POST['app_ID']);
             $options['mwform_formkey'] = esc_html($_POST['mwform_formkey']);
             update_option(MWFK_PLUGIN_NAME, $options);
             $updates->add('update', '保存しました');
             set_transient('mwfk-updates', $updates->get_error_messages(), 1);
         } else {
             $errors->add('error', 'エラーです');
             set_transient('mwfk-errors', $errors->get_error_messages(), 1);
         }
     }
 }
Example #15
0
 /**
  * Update option
  *
  * @param array $option
  *
  * @return bool|\WP_Error
  */
 public function save($option)
 {
     $option = (array) $option;
     // Validating
     $error = new \WP_Error();
     foreach ($this->default_options as $key => $val) {
         if (!isset($option[$key])) {
             $error->add(400, sprintf(__('%s is not specified.', '2ch'), $key));
         }
     }
     if ($error->get_error_messages()) {
         return $error;
     }
     if (!is_numeric($option['post_as'])) {
         $error->add(400, __('User ID is wrong format.', '2ch'));
     }
     $new_value = array();
     foreach ($this->default_options as $key => $val) {
         switch ($key) {
             case 'editable_post_types':
                 $new_value[$key] = (array) $option[$key];
                 break;
             case 'post_as':
                 $new_value[$key] = (int) $option[$key];
                 break;
             case 'create_post_type':
             case 'require_moderation':
             case 'show_form_automatically':
             case 'use_trip':
                 $new_value[$key] = (bool) $option[$key];
                 break;
             default:
                 $new_value[$key] = (string) $option[$key];
                 break;
         }
     }
     return update_option($this->option_key, $new_value);
 }
Example #16
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 #17
0
 function admin_init()
 {
     /**
      * テストテーマのOn/Offを設定
      */
     if (isset($_POST['_wpnonce']) && $_POST['_wpnonce']) {
         $errors = new WP_Error();
         $updates = new WP_Error();
         if (check_admin_referer('wp-theme-test', '_wpnonce')) {
             //オプションを設定
             $theme = esc_html($_POST['theme']);
             foreach ($_POST['capabilities'] as $key => $value) {
                 $capabilities[] = esc_html($value);
             }
             $parameter = esc_html($_POST['parameter']);
             $ip_list = esc_html($_POST['ip_list']);
             $options = get_option(WPTT_PLUGIN_NAME);
             $options['theme'] = $theme;
             $options['capabilities'] = $capabilities;
             $options['parameter'] = $parameter;
             $options['ip_list'] = $ip_list;
             //On/Off設定
             if (esc_html($_POST['status']) == 1) {
                 $options['status'] = 1;
             } else {
                 $options['status'] = 0;
             }
             update_option(WPTT_PLUGIN_NAME, $options);
             $updates->add('update', $this->_('Saved'));
             set_transient('wptt-updates', $updates->get_error_messages(), 1);
             // wp_safe_redirect( menu_page_url( WPTT_PLUGIN_NAME, false ) );
         } else {
             $errors->add('error', $this->_('An invalid value has been sent'));
             set_transient('wptt-errors', $errors->get_error_messages(), 1);
         }
     }
 }
Example #18
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 #19
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";
        }
    }
}
 /**
  * Save the password/account details and redirect back to the my account page.
  */
 public static function save_account_details()
 {
     if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
         return;
     }
     if (empty($_POST['action']) || 'save_account_details' !== $_POST['action'] || empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'save_account_details')) {
         return;
     }
     $errors = new WP_Error();
     $user = new stdClass();
     $user->ID = (int) get_current_user_id();
     $current_user = get_user_by('id', $user->ID);
     if ($user->ID <= 0) {
         return;
     }
     $account_first_name = !empty($_POST['account_first_name']) ? wc_clean($_POST['account_first_name']) : '';
     $account_last_name = !empty($_POST['account_last_name']) ? wc_clean($_POST['account_last_name']) : '';
     $account_email = !empty($_POST['account_email']) ? wc_clean($_POST['account_email']) : '';
     $pass_cur = !empty($_POST['password_current']) ? $_POST['password_current'] : '';
     $pass1 = !empty($_POST['password_1']) ? $_POST['password_1'] : '';
     $pass2 = !empty($_POST['password_2']) ? $_POST['password_2'] : '';
     $save_pass = true;
     $user->first_name = $account_first_name;
     $user->last_name = $account_last_name;
     // Prevent emails being displayed, or leave alone.
     $user->display_name = is_email($current_user->display_name) ? $user->first_name : $current_user->display_name;
     // Handle required fields
     $required_fields = apply_filters('woocommerce_save_account_details_required_fields', array('account_first_name' => __('First name', 'woocommerce'), 'account_last_name' => __('Last name', 'woocommerce'), 'account_email' => __('Email address', 'woocommerce')));
     foreach ($required_fields as $field_key => $field_name) {
         if (empty($_POST[$field_key])) {
             wc_add_notice(sprintf(__('%s is a required field.', 'woocommerce'), '<strong>' . esc_html($field_name) . '</strong>'), 'error');
         }
     }
     if ($account_email) {
         $account_email = sanitize_email($account_email);
         if (!is_email($account_email)) {
             wc_add_notice(__('Please provide a valid email address.', 'woocommerce'), 'error');
         } elseif (email_exists($account_email) && $account_email !== $current_user->user_email) {
             wc_add_notice(__('This email address is already registered.', 'woocommerce'), 'error');
         }
         $user->user_email = $account_email;
     }
     if (!empty($pass_cur) && empty($pass1) && empty($pass2)) {
         wc_add_notice(__('Please fill out all password fields.', 'woocommerce'), 'error');
         $save_pass = false;
     } elseif (!empty($pass1) && empty($pass_cur)) {
         wc_add_notice(__('Please enter your current password.', 'woocommerce'), 'error');
         $save_pass = false;
     } elseif (!empty($pass1) && empty($pass2)) {
         wc_add_notice(__('Please re-enter your password.', 'woocommerce'), 'error');
         $save_pass = false;
     } elseif ((!empty($pass1) || !empty($pass2)) && $pass1 !== $pass2) {
         wc_add_notice(__('New passwords do not match.', 'woocommerce'), 'error');
         $save_pass = false;
     } elseif (!empty($pass1) && !wp_check_password($pass_cur, $current_user->user_pass, $current_user->ID)) {
         wc_add_notice(__('Your current password is incorrect.', 'woocommerce'), 'error');
         $save_pass = false;
     }
     if ($pass1 && $save_pass) {
         $user->user_pass = $pass1;
     }
     // Allow plugins to return their own errors.
     do_action_ref_array('woocommerce_save_account_details_errors', array(&$errors, &$user));
     if ($errors->get_error_messages()) {
         foreach ($errors->get_error_messages() as $error) {
             wc_add_notice($error, 'error');
         }
     }
     if (wc_notice_count('error') === 0) {
         wp_update_user($user);
         wc_add_notice(__('Account details changed successfully.', 'woocommerce'));
         do_action('woocommerce_save_account_details', $user->ID);
         wp_safe_redirect(wc_get_page_permalink('myaccount'));
         exit;
     }
 }
 /**
  * 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;
 }
Example #22
0
 /**
  * Read the image paths from an attachment's meta data and process each image
  * with wp_smushit().
  *
  * This method also adds a `wp_smushit` meta key for use in the media library.
  * Called after `wp_generate_attachment_metadata` is completed.
  *
  * @param $meta
  * @param null $ID
  *
  * @return mixed
  */
 function resize_from_meta_data($meta, $ID = null)
 {
     //Flag to check, if original size image should be smushed or not
     $original = get_option(WP_SMUSH_PREFIX . 'original');
     $smush_full = $this->is_pro() && $original == 1 ? true : false;
     $errors = new WP_Error();
     $stats = array("stats" => array_merge($this->_get_size_signature(), array('api_version' => -1, 'lossy' => -1)), 'sizes' => array());
     $size_before = $size_after = $compression = $total_time = $bytes_saved = 0;
     if ($ID && wp_attachment_is_image($ID) === false) {
         return $meta;
     }
     //File path and URL for original image
     $attachment_file_path = get_attached_file($ID);
     // If images has other registered size, smush them first
     if (!empty($meta['sizes'])) {
         //if smush original is set to false, otherwise smush
         //Check for large size, we will set a flag to leave the original untouched
         if (!$smush_full) {
             if (array_key_exists('large', $meta['sizes'])) {
                 $smush_full = false;
             } else {
                 $smush_full = true;
             }
         }
         foreach ($meta['sizes'] as $size_key => $size_data) {
             // We take the original image. The 'sizes' will all match the same URL and
             // path. So just get the dirname and replace the filename.
             $attachment_file_path_size = trailingslashit(dirname($attachment_file_path)) . $size_data['file'];
             //Store details for each size key
             $response = $this->do_smushit($attachment_file_path_size);
             if (is_wp_error($response)) {
                 return $response;
             }
             if (!empty($response['data'])) {
                 $stats['sizes'][$size_key] = (object) $this->_array_fill_placeholders($this->_get_size_signature(), (array) $response['data']);
             }
             //Total Stats, store all data in bytes
             if (isset($response['data'])) {
                 list($size_before, $size_after, $total_time, $compression, $bytes_saved) = $this->_update_stats_data($response['data'], $size_before, $size_after, $total_time, $bytes_saved);
             } else {
                 $errors->add("image_size_error" . $size_key, sprintf(__("Size '%s' not processed correctly", 'wp-smushit'), $size_key));
             }
             if (empty($stats['stats']['api_version']) || $stats['stats']['api_version'] == -1) {
                 $stats['stats']['api_version'] = $response['data']->api_version;
                 $stats['stats']['lossy'] = $response['data']->lossy;
             }
         }
     }
     //If original size is supposed to be smushed
     if ($smush_full) {
         $full_image_response = $this->do_smushit($attachment_file_path);
         if (is_wp_error($full_image_response)) {
             return $full_image_response;
         }
         if (!empty($full_image_response['data'])) {
             $stats['sizes']['full'] = (object) $this->_array_fill_placeholders($this->_get_size_signature(), (array) $full_image_response['data']);
         } else {
             $errors->add("image_size_error", __("Size 'full' not processed correctly", 'wp-smushit'));
         }
         //Update stats
         if (isset($full_image_response['data'])) {
             list($size_before, $size_after, $total_time, $compression, $bytes_saved) = $this->_update_stats_data($full_image_response['data'], $size_before, $size_after, $total_time, $bytes_saved);
         } else {
             $errors->add("image_size_error", __("Size 'full' not processed correctly", 'wp-smushit'));
         }
         //Api version and lossy, for some images, full image i skipped and for other images only full exists
         //so have to add code again
         if (empty($stats['stats']['api_version']) || $stats['stats']['api_version'] == -1) {
             $stats['stats']['api_version'] = $full_image_response['data']->api_version;
             $stats['stats']['lossy'] = $full_image_response['data']->lossy;
         }
     }
     $has_errors = (bool) count($errors->get_error_messages());
     list($stats['stats']['size_before'], $stats['stats']['size_after'], $stats['stats']['time'], $stats['stats']['percent'], $stats['stats']['bytes']) = array($size_before, $size_after, $total_time, $compression, $bytes_saved);
     //Set smush status for all the images, store it in wp-smpro-smush-data
     if (!$has_errors) {
         $existing_stats = get_post_meta($ID, self::SMUSHED_META_KEY, true);
         if (!empty($existing_stats)) {
             //Update total bytes saved, and compression percent
             $stats['stats']['bytes'] = isset($existing_stats['stats']['bytes']) ? $existing_stats['stats']['bytes'] + $stats['stats']['bytes'] : $stats['stats']['bytes'];
             $stats['stats']['percent'] = isset($existing_stats['stats']['percent']) ? $existing_stats['stats']['percent'] + $stats['stats']['percent'] : $stats['stats']['percent'];
             //Update stats for each size
             if (isset($existing_stats['sizes']) && !empty($stats['sizes'])) {
                 foreach ($existing_stats['sizes'] as $size_name => $size_stats) {
                     //if stats for a particular size doesn't exists
                     if (empty($stats['sizes'][$size_name])) {
                         $stats['sizes'][$size_name] = $existing_stats['sizes'][$size_name];
                     } else {
                         //Update compression percent and bytes saved for each size
                         $stats['sizes'][$size_name]->bytes = $stats['sizes'][$size_name]->bytes + $existing_stats['sizes'][$size_name]->bytes;
                         $stats['sizes'][$size_name]->percent = $stats['sizes'][$size_name]->percent + $existing_stats['sizes'][$size_name]->percent;
                     }
                 }
             }
         }
         update_post_meta($ID, self::SMUSHED_META_KEY, $stats);
     }
     return $meta;
 }
/**
 * 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";
        }
    }
}
 /**
  * Receives a WP_Error object and adds the error messages to our array. 
  *
  * @param 	WP_Error 	$error
  * @return  void
  * @access  public
  * @since   1.0.0
  */
 public function add_errors_from_wp_error(WP_Error $error)
 {
     $this->add_notices($error->get_error_messages(), 'error');
 }
 /**
  * Read the image paths from an attachment's meta data and process each image
  * with wp_smushit().
  *
  * This method also adds a `wp_smushit` meta key for use in the media library.
  * Called after `wp_generate_attachment_metadata` is completed.
  *
  * @param $meta
  * @param null $ID
  *
  * @return mixed
  */
 function resize_from_meta_data($image)
 {
     global $WpSmush;
     $errors = new WP_Error();
     $stats = array("stats" => array_merge($WpSmush->_get_size_signature(), array('api_version' => -1, 'lossy' => -1)), 'sizes' => array());
     $size_before = $size_after = $compression = $total_time = $bytes_saved = 0;
     // Registry Object for NextGen Gallery
     $registry = C_Component_Registry::get_instance();
     //Gallery Storage Object
     $storage = $registry->get_utility('I_Gallery_Storage');
     //File path and URL for original image
     // get an array of sizes available for the $image
     $sizes = $storage->get_image_sizes();
     // If images has other registered size, smush them first
     if (!empty($sizes)) {
         if (class_exists('finfo')) {
             $finfo = new finfo(FILEINFO_MIME_TYPE);
         } else {
             $finfo = false;
         }
         foreach ($sizes as $size) {
             //Skip Full size, if smush original is not checked
             if ('full' == $size && !$WpSmush->smush_original) {
                 continue;
             }
             // We take the original image. Get the absolute path using the storage object
             $attachment_file_path_size = $storage->get_image_abspath($image, $size);
             if ($finfo) {
                 $ext = file_exists($attachment_file_path_size) ? $finfo->file($attachment_file_path_size) : '';
             } elseif (function_exists('mime_content_type')) {
                 $ext = mime_content_type($attachment_file_path_size);
             } else {
                 $ext = false;
             }
             if ($ext) {
                 $valid_mime = array_search($ext, array('jpg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif'), true);
                 if (false === $valid_mime) {
                     continue;
                 }
             }
             /**
              * Allows to skip a image from smushing
              *
              * @param bool , Smush image or not
              * @$size string, Size of image being smushed
              */
             $smush_image = apply_filters('wp_smush_nextgen_image', true, $size);
             if (!$smush_image) {
                 continue;
             }
             //Store details for each size key
             $response = $WpSmush->do_smushit($attachment_file_path_size, $image->pid, 'nextgen');
             if (is_wp_error($response)) {
                 return $response;
             }
             //If there are no stats
             if (empty($response['data'])) {
                 continue;
             }
             //If the image size grew after smushing, skip it
             if ($response['data']->after_size > $response['data']->before_size) {
                 continue;
             }
             $stats['sizes'][$size] = (object) $WpSmush->_array_fill_placeholders($WpSmush->_get_size_signature(), (array) $response['data']);
             //Total Stats, store all data in bytes
             list($size_before, $size_after, $total_time, $compression, $bytes_saved) = $WpSmush->_update_stats_data($response['data'], $size_before, $size_after, $total_time, $bytes_saved);
             if (empty($stats['stats']['api_version']) || $stats['stats']['api_version'] == -1) {
                 $stats['stats']['api_version'] = $response['data']->api_version;
                 $stats['stats']['lossy'] = $response['data']->lossy;
                 $stats['stats']['keep_exif'] = !empty($response['data']->keep_exif) ? $response['data']->keep_exif : 0;
             }
         }
     }
     $has_errors = (bool) count($errors->get_error_messages());
     list($stats['stats']['size_before'], $stats['stats']['size_after'], $stats['stats']['time'], $stats['stats']['percent'], $stats['stats']['bytes']) = array($size_before, $size_after, $total_time, $compression, $bytes_saved);
     //Set smush status for all the images, store it in wp-smpro-smush-data
     if (!$has_errors) {
         $existing_stats = !empty($image->meta_data) && !empty($image->meta_data['wp_smush']) ? $image->meta_data['wp_smush'] : '';
         if (!empty($existing_stats)) {
             $e_size_before = !empty($existing_stats['stats']['size_before']) ? $existing_stats['stats']['size_before'] : '';
             $e_size_after = isset($existing_stats['stats']['size_after']) ? $existing_stats['stats']['size_after'] : '';
             //Store Original size before
             $stats['stats']['size_before'] = !empty($e_size_before) && $e_size_before > $stats['stats']['size_before'] ? $e_size_before : $stats['stats']['size_before'];
             if ($size_after == 0 || empty($stats['stats']['size_after']) || $stats['stats']['size_after'] == $stats['stats']['size_before']) {
                 $stats['stats']['size_after'] = $e_size_after < $stats['stats']['size_before'] ? $e_size_after : $stats['stats']['size_before'];
             }
             //Update total bytes saved, and compression percent
             $stats['stats']['bytes'] = isset($existing_stats['stats']['bytes']) ? $existing_stats['stats']['bytes'] + $stats['stats']['bytes'] : $stats['stats']['bytes'];
             $stats['stats']['percent'] = $WpSmush->calculate_percentage((object) $stats['stats'], (object) $existing_stats['stats']);
             //Update stats for each size
             if (!empty($existing_stats['sizes']) && !empty($stats['sizes'])) {
                 foreach ($existing_stats['sizes'] as $size_name => $size_stats) {
                     //if stats for a particular size doesn't exists
                     if (empty($stats['sizes']) || empty($stats['sizes'][$size_name])) {
                         $stats = empty($stats) ? array() : $stats;
                         if (empty($stats['sizes'])) {
                             $stats['sizes'] = array();
                         }
                         $stats['sizes'][$size_name] = $existing_stats['sizes'][$size_name];
                     } else {
                         $existing_stats_size = (object) $existing_stats['sizes'][$size_name];
                         //store the original image size
                         $stats['sizes'][$size_name]->size_before = !empty($existing_stats_size->size_before) && $existing_stats_size->size_before > $stats['sizes'][$size_name]->size_before ? $existing_stats_size->size_before : $stats['sizes'][$size_name]->size_before;
                         //Update compression percent and bytes saved for each size
                         $stats['sizes'][$size_name]->bytes = $stats['sizes'][$size_name]->bytes + $existing_stats_size->bytes;
                         //Calculate percentage
                         $stats['sizes'][$size_name]->percent = $WpSmush->calculate_percentage($stats['sizes'][$size_name], $existing_stats_size);
                     }
                 }
             }
         }
         //If there was any compression and there was no error in smushing
         if (isset($stats['stats']['bytes']) && $stats['stats']['bytes'] >= 0 && !$has_errors) {
             /**
              * Runs if the image smushing was successful
              *
              * @param int    $ID   Image Id
              *
              * @param array $stats Smush Stats for the image
              *
              */
             do_action('wp_smush_image_optimised_nextgen', $image->pid, $stats);
         }
         $image->meta_data['wp_smush'] = $stats;
         nggdb::update_image_meta($image->pid, $image->meta_data);
         //Allows To get the stats for each image, after the image is smushed
         do_action('wp_smush_nextgen_image_stats', $image->pid, $stats);
     }
     return $image->meta_data['wp_smush'];
 }
/**
 * Save the password and redirect back to the my account page.
 *
 * @access public
 */
function woocommerce_save_password()
{
    global $woocommerce;
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    if (empty($_POST['action']) || 'change_password' !== $_POST['action']) {
        return;
    }
    $woocommerce->verify_nonce('change_password');
    $update = true;
    $errors = new WP_Error();
    $user = new stdClass();
    $user->ID = (int) get_current_user_id();
    if ($user->ID <= 0) {
        return;
    }
    $_POST = array_map('woocommerce_clean', $_POST);
    $pass1 = !empty($_POST['password_1']) ? $_POST['password_1'] : '';
    $pass2 = !empty($_POST['password_2']) ? $_POST['password_2'] : '';
    $user->user_pass = $pass1;
    if (empty($pass1) || empty($pass2)) {
        $woocommerce->add_error(__('Please enter your password.', 'woocommerce'));
    }
    if ($pass1 !== $pass2) {
        $woocommerce->add_error(__('Passwords do not match.', 'woocommerce'));
    }
    // Allow plugins to return their own errors.
    do_action_ref_array('user_profile_update_errors', array(&$errors, $update, &$user));
    if ($errors->get_error_messages()) {
        foreach ($errors->get_error_messages() as $error) {
            $woocommerce->add_error($error);
        }
    }
    if ($woocommerce->error_count() == 0) {
        wp_update_user($user);
        $woocommerce->add_message(__('Password changed successfully.', 'woocommerce'));
        do_action('woocommerce_customer_change_password', $user->ID);
        wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
        exit;
    }
}
Example #27
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 #28
0
/**
*
*
*/
function lost_password_reset()
{
    global $wpdb, $current_site, $wp_hasher;
    $errors = new WP_Error();
    $user_data = get_user_by('email', trim($_POST['user-email']));
    if (empty($user_data)) {
        $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
    }
    do_action('lostpassword_post');
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
    }
    if ($errors->get_error_code()) {
        echo implode('<br/>', $errors->get_error_messages());
        exit;
    }
    $user_info = $user_data;
    $user_login = $user_info->user_login;
    $user_email = $user_info->user_email;
    //url para onde ele encaminha a validação do link por email, é preciso alterar.
    $validate_url = get_bloginfo('url') . '/' . lost_password_page;
    if ($user_info) {
        /*
         * Daqui para a frente eu fiz com base na função original do wordpress.
         */
        // Generate something random for a password reset key.
        $key = wp_generate_password(20, false);
        /**
         * Fires when a password reset key is generated.
         *
         * @since 2.5.0
         *
         * @param string $user_login The username for the user.
         * @param string $key        The generated password reset key.
         */
        do_action('retrieve_password_key', $user_login, $key);
        // Now insert the key, hashed, into the DB.
        if (empty($wp_hasher)) {
            require_once ABSPATH . 'wp-includes/class-phpass.php';
            $wp_hasher = new PasswordHash(8, true);
        }
        $hashed = $wp_hasher->HashPassword($key);
        $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user_login));
        $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n";
        $message .= network_home_url('/') . "\r\n\r\n";
        $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
        $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n";
        $message .= __('To reset your password, visit the following address:') . "\r\n\r\n";
        $url = network_site_url("wp-login.php?action=rp&key={$key}&login="******"<a href=\"{$url}\" target=\"_blank\">{$url}</a>\r\n";
        if (is_multisite()) {
            $blogname = $GLOBALS['current_site']->site_name;
        } else {
            // The blogname option is escaped with esc_html on the way into the database in sanitize_option
            // we want to reverse this for the plain text arena of emails.
            $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
        }
        $title = sprintf(__('[%s] Password Reset'), $blogname);
        /**
         * Filter the subject of the password reset email.
         *
         * @since 2.8.0
         *
         * @param string $title Default email title.
         */
        $title = apply_filters('retrieve_password_title', $title);
        /**
         * Filter the message body of the password reset mail.
         *
         * @since 2.8.0
         *
         * @param string $message Default mail message.
         * @param string $key     The activation key.
         */
        $message = apply_filters('retrieve_password_message', $message, $key);
        add_filter('wp_mail_content_type', create_function('', 'return "text/html"; '));
        if ($message && !wp_mail($user_email, $title, $message)) {
            wp_die(__('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.'));
        }
        /*
         * Fim do ctrl+c do wordpress
         */
        echo _x('Foi enviada uma mensagem para seu email com uma chave de validação e os próximos passos para recuperar sua senha', 'custom-lost-password', 'redelivre');
        return true;
    } else {
        echo _x('Nenhum usuário encontrado com este email', 'custom-lost-password', 'redelivre');
        return false;
    }
}
 private function printError(WP_Error $error)
 {
     foreach ($error->get_error_codes() as $code) {
         foreach ($error->get_error_messages($code) as $message) {
             if (!empty($message)) {
                 $this->printNotice($message . "\n<br>Error code: <code>" . htmlentities($code) . '</code>', 'error');
             }
         }
     }
 }
 /**
  * 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;
 }