当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Error::get_error_messages方法代码示例

本文整理汇总了PHP中WP_Error::get_error_messages方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Error::get_error_messages方法的具体用法?PHP WP_Error::get_error_messages怎么用?PHP WP_Error::get_error_messages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Error的用法示例。


在下文中一共展示了WP_Error::get_error_messages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: error_message

 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']);
 }
开发者ID:mimosafa,项目名称:dana-don-boom-boom-doo,代码行数:7,代码来源:dana-don-boom-boom-doo.php

示例2: appthemes_bad_method_visibility

/**
 * 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;
        }
    }
}
开发者ID:kalushta,项目名称:darom,代码行数:38,代码来源:debug.php

示例3: confirmation

 /**
  * 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;
 }
开发者ID:wp-pay-extensions,项目名称:gravityforms,代码行数:32,代码来源:Processor.php

示例4: auth

 /**
  * 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;
     }
 }
开发者ID:amimoto-ami,项目名称:c3-cloudfront-clear-cache,代码行数:38,代码来源:auth.php

示例5: array

 /**
  * 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;
 }
开发者ID:bruno-barros,项目名称:w.eloquent.light,代码行数:34,代码来源:admin.php

示例6: display_errors

 /**
  * 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>';
     }
 }
开发者ID:s-hinse,项目名称:search-and-replace,代码行数:14,代码来源:Admin.php

示例7: login_header

function login_header($title = 'Login', $message = '', $wp_error = '') {
	global $error;

	if ( empty($wp_error) )
		$wp_error = new WP_Error();
	?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
	<title><?php bloginfo('name'); ?> &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()
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:53,代码来源:wp-login.php

示例8: prepare_form_errors

 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);
         }
     }
 }
开发者ID:korobochkin,项目名称:wp-forms,代码行数:12,代码来源:WP_Form_Submission.php

示例9: importErrors

 /**
  * Merge errors from another WP_Error object into the one dedicated to this model object.
  *
  * @param  \WP_Error  $otherErrors
  */
 protected function importErrors(\WP_Error $otherErrors)
 {
     foreach ($otherErrors->get_error_codes() as $code) {
         $errors = $otherErrors->get_error_messages($code);
         $data = $otherErrors->get_error_data($code);
         for ($i = 0; $i < max(count($errors), count($data)); $i++) {
             if (array_key_exists($i, $errors)) {
                 $data = array_key_exists($i, $data) ? $data[$i] : null;
                 $this->errors->add($code, $errors[$i], $data);
             }
         }
     }
 }
开发者ID:asmbs,项目名称:wp-schedule-builder,代码行数:18,代码来源:AbstractModel.php

示例10:

 /**
  * @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());
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:17,代码来源:errors.php

示例11: handle_error_response

 /**
  * @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;
         }
     }
 }
开发者ID:drivdigital,项目名称:bring-fraktguiden-for-woocommerce,代码行数:20,代码来源:class-wp-bring-response.php

示例12: confirmation

 /**
  * 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;
 }
开发者ID:daanbakker1995,项目名称:vanteun,代码行数:50,代码来源:Processor.php

示例13: login_header

/**
 * Outputs the header for the login page.
 *
 * @uses do_action() Calls the 'login_head' for outputting HTML in the Log In
 *		header.
 * @uses apply_filters() Calls 'login_headerurl' for the top login link.
 * @uses apply_filters() Calls 'login_headertitle' for the top login title.
 * @uses apply_filters() Calls 'login_message' on the message to display in the
 *		header.
 * @uses $error The error global, which is checked for displaying errors.
 *
 * @param string $title Optional. WordPress Log In Page title to display in
 *		<title/> element.
 * @param string $message Optional. Message to display in header.
 * @param WP_Error $wp_error Optional. WordPress Error Object
 */
function login_header($title = 'Log In', $message = '', $wp_error = '')
{
    global $error, $is_iphone, $current_site;
    // Don't index any of these forms
    add_filter('pre_option_blog_public', create_function('$a', 'return 0;'));
    add_action('login_head', 'noindex');
    if (empty($wp_error)) {
        $wp_error = new WP_Error();
    }
    ?>


<div id="login">
<?php 
    $message = apply_filters('login_message', $message);
    if (!empty($message)) {
        echo $message . "\n";
    }
    // Incase a plugin uses $error rather than the $errors object
    if (!empty($error)) {
        $wp_error->add('error', $error);
        unset($error);
    }
    if ($wp_error->get_error_code()) {
        $errors = '';
        $messages = '';
        foreach ($wp_error->get_error_codes() as $code) {
            $severity = $wp_error->get_error_data($code);
            foreach ($wp_error->get_error_messages($code) as $error) {
                if ('message' == $severity) {
                    $messages .= '	' . $error . "<br />\n";
                } else {
                    $errors .= '	' . $error . "<br />\n";
                }
            }
        }
        if (!empty($errors)) {
            echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
        }
        if (!empty($messages)) {
            echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
        }
    }
}
开发者ID:jinpingv,项目名称:website_wrapper,代码行数:60,代码来源:wp-login-pj.php

示例14: admin_post

 /**
  * 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);
         }
     }
 }
开发者ID:kanakogi,项目名称:MW-WP-Form-kintone,代码行数:25,代码来源:class.admin.php

示例15: save

 /**
  * 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);
 }
开发者ID:hametuha,项目名称:2ch,代码行数:45,代码来源:Option.php


注:本文中的WP_Error::get_error_messages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。