本文整理汇总了PHP中WP_Error::get_error_codes方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Error::get_error_codes方法的具体用法?PHP WP_Error::get_error_codes怎么用?PHP WP_Error::get_error_codes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Error
的用法示例。
在下文中一共展示了WP_Error::get_error_codes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pmxe_wp_ajax_wpae_preview
/**
* AJAX action for preview export row
*/
function pmxe_wp_ajax_wpae_preview()
{
if (!check_ajax_referer('wp_all_export_secure', 'security', false)) {
exit(json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))));
}
if (!current_user_can(PMXE_Plugin::$capabilities)) {
exit(json_encode(array('html' => __('Security check', 'wp_all_export_plugin'))));
}
XmlExportEngine::$is_preview = true;
$custom_xml_valid = true;
ob_start();
$values = array();
parse_str($_POST['data'], $values);
$export_id = isset($_GET['id']) ? stripcslashes($_GET['id']) : 0;
$exportOptions = $values + (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + PMXE_Plugin::get_default_import_options();
$exportOptions['custom_xml_template'] = isset($_POST['custom_xml']) ? stripcslashes($_POST['custom_xml']) : '';
$exportOptions['custom_xml_template'] = str_replace('<ID>', '<id>', $exportOptions['custom_xml_template']);
$exportOptions['custom_xml_template'] = str_replace('</ID>', '</id>', $exportOptions['custom_xml_template']);
if (!empty($exportOptions['custom_xml_template'])) {
$custom_xml_template_line_count = substr_count($exportOptions['custom_xml_template'], "\n");
}
$errors = new WP_Error();
$engine = new XmlExportEngine($exportOptions, $errors);
XmlExportEngine::$exportOptions = $exportOptions;
XmlExportEngine::$is_user_export = $exportOptions['is_user_export'];
XmlExportEngine::$is_comment_export = $exportOptions['is_comment_export'];
XmlExportEngine::$exportID = $export_id;
if (in_array(XmlExportEngine::$exportOptions['xml_template_type'], array('custom', 'XmlGoogleMerchants'))) {
if (empty(XmlExportEngine::$exportOptions['custom_xml_template'])) {
$errors->add('form-validation', __('XML template is empty.', 'wp_all_export_plugin'));
}
if (!empty(XmlExportEngine::$exportOptions['custom_xml_template'])) {
$engine->init_additional_data();
$engine->init_available_data();
$result = $engine->parse_custom_xml_template();
$line_numbers = $result['line_numbers'];
if (!$errors->get_error_codes()) {
XmlExportEngine::$exportOptions = array_merge(XmlExportEngine::$exportOptions, $result);
}
$originalXmlTemplate = $exportOptions['custom_xml_template'];
libxml_use_internal_errors(true);
libxml_clear_errors();
//Add root se we make sure there is a root tag
$result['original_post_loop'] = '<root>' . $result['original_post_loop'] . '</root>';
$custom_xml_template = simplexml_load_string($result['original_post_loop']);
if ($custom_xml_template === false) {
$custom_xml_template_errors = libxml_get_errors();
libxml_clear_errors();
$custom_xml_valid = false;
// Remove one line because we added root
$line_difference = $custom_xml_template_line_count - $line_numbers - 1;
}
$exportOptions['custom_xml_template'] = str_replace("<!-- BEGIN POST LOOP -->", "<!-- BEGIN LOOP -->", $exportOptions['custom_xml_template']);
$exportOptions['custom_xml_template'] = str_replace("<!-- END POST LOOP -->", "<!-- END LOOP -->", $exportOptions['custom_xml_template']);
}
}
if (isset($_GET['show_cdata'])) {
XmlExportEngine::$exportOptions['show_cdata_in_preview'] = (bool) $_GET['show_cdata'];
} else {
XmlExportEngine::$exportOptions['show_cdata_in_preview'] = false;
}
if ($errors->get_error_codes()) {
$msgs = $errors->get_error_messages();
if (!is_array($msgs)) {
$msgs = array($msgs);
}
foreach ($msgs as $msg) {
?>
<div class="error"><p><?php
echo $msg;
?>
</p></div>
<?php
}
exit(json_encode(array('html' => ob_get_clean())));
}
if ('advanced' == $exportOptions['export_type']) {
if (XmlExportEngine::$is_user_export) {
$exportQuery = eval('return new WP_User_Query(array(' . $exportOptions['wp_query'] . ', \'offset\' => 0, \'number\' => 10));');
} elseif (XmlExportEngine::$is_comment_export) {
$exportQuery = eval('return new WP_Comment_Query(array(' . $exportOptions['wp_query'] . ', \'offset\' => 0, \'number\' => 10));');
} else {
$exportQuery = eval('return new WP_Query(array(' . $exportOptions['wp_query'] . ', \'offset\' => 0, \'posts_per_page\' => 10));');
}
} else {
XmlExportEngine::$post_types = $exportOptions['cpt'];
if (in_array('users', $exportOptions['cpt']) or in_array('shop_customer', $exportOptions['cpt'])) {
add_action('pre_user_query', 'wp_all_export_pre_user_query', 10, 1);
$exportQuery = new WP_User_Query(array('orderby' => 'ID', 'order' => 'ASC', 'number' => 10));
remove_action('pre_user_query', 'wp_all_export_pre_user_query');
} elseif (in_array('comments', $exportOptions['cpt'])) {
add_action('comments_clauses', 'wp_all_export_comments_clauses', 10, 1);
global $wp_version;
if (version_compare($wp_version, '4.2.0', '>=')) {
$exportQuery = new WP_Comment_Query(array('orderby' => 'comment_ID', 'order' => 'ASC', 'number' => 10));
} else {
$exportQuery = get_comments(array('orderby' => 'comment_ID', 'order' => 'ASC', 'number' => 10));
//.........这里部分代码省略.........
示例2: is_valid
public function is_valid()
{
$this->validate();
// make sure we've validated
$errors = $this->errors->get_error_codes();
return empty($errors);
}
示例3: get_error_messages
/**
* Retrieves a string for error messages.
*
* @since 4.6.0
* @access public
*
* @return string Error messages during an upgrade.
*/
public function get_error_messages()
{
$messages = array();
foreach ($this->errors->get_error_codes() as $error_code) {
if ($this->errors->get_error_data($error_code) && is_string($this->errors->get_error_data($error_code))) {
$messages[] = $this->errors->get_error_message($error_code) . ' ' . esc_html(strip_tags($this->errors->get_error_data($error_code)));
} else {
$messages[] = $this->errors->get_error_message($error_code);
}
}
return implode(', ', $messages);
}
示例4: get_stylesheet_directory
/**
* Returns the absolute path to the directory of a theme's "stylesheet" files.
*
* In the case of a child theme, this is the absolute path to the directory
* of the child theme's files.
*
* @since 3.4.0
* @access public
*
* @return string Absolute path of the stylesheet directory.
*/
public function get_stylesheet_directory()
{
if ($this->errors && in_array('theme_root_missing', $this->errors->get_error_codes())) {
return '';
}
return $this->theme_root . '/' . $this->stylesheet;
}
示例5: validate
function validate()
{
if (!isset($_POST['dokan_update_profile'])) {
return false;
}
if (!wp_verify_nonce($_POST['_wpnonce'], 'dokan_settings_nonce')) {
wp_die(__('Are you cheating?', 'dokan'));
}
$error = new WP_Error();
$dokan_name = sanitize_text_field($_POST['dokan_store_name']);
if (empty($dokan_name)) {
$error->add('dokan_name', __('Dokan name required', 'dokan'));
}
if (isset($_POST['setting_category'])) {
if (!is_array($_POST['setting_category']) || !count($_POST['setting_category'])) {
$error->add('dokan_type', __('Dokan type required', 'dokan'));
}
}
if (!empty($_POST['setting_paypal_email'])) {
$email = filter_var($_POST['setting_paypal_email'], FILTER_VALIDATE_EMAIL);
if (empty($email)) {
$error->add('dokan_email', __('Invalid email', 'dokan'));
}
}
if ($error->get_error_codes()) {
return $error;
}
return true;
}
示例6: options
/**
* Show opt out options page
*
*/
public function options()
{
global $wpdb;
$errors = array();
$success = false;
$opt_out_level = get_option("bbpp_thankmelater_opt_out_level", "disabled");
$opt_out_form_type = get_option("bbpp_thankmelater_opt_out_form_type", "out");
$opt_out_form_out_text = get_option("bbpp_thankmelater_opt_out_form_out_text", "1");
$opt_out_form_out_text_custom = get_option("bbpp_thankmelater_opt_out_form_out_text_custom", "");
$opt_out_form_in_text = get_option("bbpp_thankmelater_opt_out_form_in_text", "1");
$opt_out_form_in_text_custom = get_option("bbpp_thankmelater_opt_out_form_in_text_custom", "");
if ($_POST) {
check_admin_referer("bbpp_thankmelater_opt_out_options");
$data = stripslashes_deep($_POST);
$opt_out_level = isset($data["bbpp_thankmelater_opt_out_level"]) ? $data["bbpp_thankmelater_opt_out_level"] : NULL;
$opt_out_form_type = isset($data["bbpp_thankmelater_opt_out_form_type"]) ? $data["bbpp_thankmelater_opt_out_form_type"] : NULL;
$opt_out_form_out_text = isset($data["bbpp_thankmelater_opt_out_form_out_text"]) ? $data["bbpp_thankmelater_opt_out_form_out_text"] : NULL;
$opt_out_form_out_text_custom = isset($data["bbpp_thankmelater_opt_out_form_out_text_custom"]) ? $data["bbpp_thankmelater_opt_out_form_out_text_custom"] : NULL;
$opt_out_form_in_text = isset($data["bbpp_thankmelater_opt_out_form_in_text"]) ? $data["bbpp_thankmelater_opt_out_form_in_text"] : NULL;
$opt_out_form_in_text_custom = isset($data["bbpp_thankmelater_opt_out_form_in_text_custom"]) ? $data["bbpp_thankmelater_opt_out_form_in_text_custom"] : NULL;
$error = new WP_Error();
if (!in_array($opt_out_level, array("disabled", "email", "form"))) {
$error->add("opt_out_level", __("You must select an option.", "bbpp-thankmelater"));
}
if ($opt_out_level == "form") {
if (!in_array($opt_out_form_type, array("out", "in"))) {
$error->add("opt_out_form_type", __("You must select an option.", "bbpp-thankmelater"));
}
if ($opt_out_form_type == "out") {
if (!in_array($opt_out_form_out_text, array("1", "custom"))) {
$error->add("opt_out_form_out_text", __("You must select an option.", "bbpp-thankmelater"));
}
if ($opt_out_form_out_text == "custom" && empty($opt_out_form_out_text_custom)) {
$error->add("opt_out_form_out_text", __("This must not be blank.", "bbpp-thankmelater"));
}
} elseif ($opt_out_form_type == "in") {
if (!in_array($opt_out_form_in_text, array("1", "custom"))) {
$error->add("opt_out_form_in_text", __("You must select an option.", "bbpp-thankmelater"));
}
if ($opt_out_form_in_text == "custom" && empty($opt_out_form_in_text_custom)) {
$error->add("opt_out_form_in_text", __("This must not be blank.", "bbpp-thankmelater"));
}
}
}
if ($error->get_error_codes()) {
$errors[] = $error;
} else {
update_option("bbpp_thankmelater_opt_out_level", $opt_out_level);
update_option("bbpp_thankmelater_opt_out_form_type", $opt_out_form_type);
update_option("bbpp_thankmelater_opt_out_form_out_text", $opt_out_form_out_text);
update_option("bbpp_thankmelater_opt_out_form_out_text_custom", $opt_out_form_out_text_custom);
update_option("bbpp_thankmelater_opt_out_form_in_text", $opt_out_form_in_text);
update_option("bbpp_thankmelater_opt_out_form_in_text_custom", $opt_out_form_in_text_custom);
$success = true;
}
}
// get a list of the most recent opt outs
$opt_out_results = $wpdb->get_results("\r\n\t\t\tSELECT `email`, `date_gmt`\r\n\t\t\tFROM `{$wpdb->prefix}bbpp_thankmelater_opt_outs`\r\n\t\t\tORDER BY `date_gmt` DESC\r\n\t\t\tLIMIT 100\r\n\t\t");
require_once BBPP_THANKMELATER_PLUGIN_PATH . "admin/opt-out/options.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'); ?> › <?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: 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);
}
}
}
}
示例9: foreach
/**
* Retrieve notices by type. If no type is set, retrieves all enqueued notices
*
* @param string $type The notice type
* @return object A WP_Error object with all the requested notices
*/
static function get_notices($type = '')
{
$notices_by_type = new WP_Error();
foreach (self::$notices->get_error_codes() as $error) {
$error_data = self::$notices->get_error_data($error);
if ($error_data && empty($error_data['type'])) {
$error_data['type'] = 'error';
}
if ($type && $type == $error_data['type'] || !$type) {
$notices_by_type->add($error, self::$notices->get_error_message($error), $error_data);
}
}
if (!$notices_by_type->get_error_codes()) {
return false;
}
return $notices_by_type;
}
示例10: login_header
/**
* Outputs the header for the login page.
*
* @uses do_action() Calls the 'login_head' for outputting HTML in the Log In
* header.
* @uses apply_filters() Calls 'login_headerurl' for the top login link.
* @uses apply_filters() Calls 'login_headertitle' for the top login title.
* @uses apply_filters() Calls 'login_message' on the message to display in the
* header.
* @uses $error The error global, which is checked for displaying errors.
*
* @param string $title Optional. WordPress Log In Page title to display in
* <title/> element.
* @param string $message Optional. Message to display in header.
* @param WP_Error $wp_error Optional. WordPress Error Object
*/
function login_header($title = 'Log In', $message = '', $wp_error = '')
{
global $error, $is_iphone, $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";
}
}
}
示例11: install
/**
* Show opt out options page
*
*/
public function install()
{
global $wpdb;
$errors = array();
$success = false;
if ($_POST) {
check_admin_referer("bbpp_thankmelater_install");
$data = stripslashes_deep($_POST);
$error = new WP_Error();
if ($error->get_error_codes()) {
$errors[] = $error;
} else {
update_option("bbpp_thankmelater_show_install_screen", false);
// enable email tracking
$wpdb->query("\n\t\t\t\t\tUPDATE `{$wpdb->prefix}bbpp_thankmelater_messages`\n\t\t\t\t\tSET `track_opens` = 1\n\t\t\t\t");
$success = true;
return $this->done();
}
}
require_once BBPP_THANKMELATER_PLUGIN_PATH . "admin/install/install.php";
}
示例12: validate
function validate()
{
if (!isset($_POST['coupon_creation'])) {
return;
}
if (!wp_verify_nonce($_POST['coupon_nonce_field'], 'coupon_nonce')) {
wp_die(__('Are you cheating?', 'dokan'));
}
$errors = new WP_Error();
if (empty($_POST['title'])) {
$errors->add('title', __('Please enter the coupon title', 'dokan'));
}
if (empty($_POST['amount'])) {
$errors->add('amount', __('Please enter the amount', 'dokan'));
}
if (!isset($_POST['product_drop_down']) || !count($_POST['product_drop_down'])) {
$errors->add('products', __('Please specify any products', 'dokan'));
}
if ($errors->get_error_codes()) {
return $errors;
}
return true;
}
示例13: show_errors
/**
* Display any errors returned by the plugin
*/
public function show_errors()
{
if (!is_wp_error($this->errors)) {
return;
}
$codes = $this->errors->get_error_codes();
?>
<div class="error">
<p>
<?php
foreach ($codes as $code) {
?>
<?php
echo $this->errors->get_error_message($code);
?>
<br />
<?php
}
?>
</p>
</div>
<?php
}
示例14: extract
function simplelogin_header($title, $message = '', $wp_error = '', $args = '')
{
global $error;
extract($args);
if (empty($wp_error)) {
$wp_error = new WP_Error();
}
if (!empty($error)) {
$wp_error->add('error', $error);
unset($error);
}
echo $before_widget . $before_title . __($title, 'simplelogin') . $after_title . "\n";
echo '<div id="login">';
if (!empty($message)) {
echo apply_filters('login_message', $message) . "\n";
}
if ($wp_error->get_error_code()) {
$errors = '';
$messages = '';
foreach ($wp_error->get_error_codes() as $code) {
$severity = $wp_error->get_error_data($code);
foreach ($wp_error->get_error_messages($code) as $error) {
if ('message' == $severity) {
$messages .= ' ' . $error . "<br />\n";
} else {
$errors .= ' ' . $error . "<br />\n";
}
}
}
if (!empty($errors)) {
echo '<p class="error">' . apply_filters('login_errors', $errors) . "</p>\n";
}
if (!empty($messages)) {
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
}
}
}
示例15: wpmp_switcher_login_header
function wpmp_switcher_login_header($title, $message = '', $wp_error = '')
{
global $error;
if (empty($wp_error)) {
$wp_error = new WP_Error();
}
include_once 'mobile.php';
wpmp_ms_mobile_top($title);
if (!empty($message)) {
echo apply_filters('login_message', $message) . "\n";
}
if (!empty($error)) {
$wp_error->add('error', $error);
unset($error);
}
if ($wp_error->get_error_code()) {
$errors = '';
$messages = '';
foreach ($wp_error->get_error_codes() as $code) {
$severity = $wp_error->get_error_data($code);
foreach ($wp_error->get_error_messages($code) as $error) {
if ('message' == $severity) {
$messages .= ' ' . $error . "<br />\n";
} else {
$errors .= ' ' . $error . "<br />\n";
}
}
}
if (!empty($errors)) {
echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
}
if (!empty($messages)) {
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
}
}
}