本文整理汇总了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']);
}
示例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;
}
}
}
示例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 & or &
$confirmation = sprintf('<script>function gformRedirect(){document.location.href = %s;}', json_encode($url));
if (!$ajax) {
$confirmation .= 'gformRedirect();';
}
$confirmation .= '</script>';
}
}
return $confirmation;
}
示例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;
}
}
示例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;
}
示例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>';
}
}
示例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'); ?> › <?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()
示例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);
}
}
}
示例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);
}
}
}
}
示例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());
}
示例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;
}
}
}
示例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 & or &
$confirmation = sprintf('<script>function gformRedirect(){document.location.href = %s;}', json_encode($url));
if (!$ajax) {
$confirmation .= 'gformRedirect();';
}
$confirmation .= '</script>';
}
}
return $confirmation;
}
示例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";
}
}
}
示例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);
}
}
}
示例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);
}