get_error_data example


    public function error( $errors ) {
        if ( ! $this->done_header ) {
            $this->header();
        }
        if ( is_string( $errors ) ) {
            $this->feedback( $errors );
        } elseif ( is_wp_error( $errors ) && $errors->has_errors() ) {
            foreach ( $errors->get_error_messages() as $message ) {
                if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
                    $this->feedback( $message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
                } else {
                    $this->feedback( $message );
                }
            }
        }
    }

    /** * @since 2.8.0 * @since 5.9.0 Renamed `$string` (a PHP reserved keyword) to `$feedback` for PHP 8 named parameter support. * * @param string $feedback Message data. * @param mixed ...$args Optional text replacements. */

    private function do_overwrite() {
        if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) {
            return false;
        }

        $folder = $this->result->get_error_data( 'folder_exists' );
        $folder = ltrim( substr( $folderstrlen( WP_PLUGIN_DIR ) ), '/' );

        $current_plugin_data = false;
        $all_plugins         = get_plugins();

        foreach ( $all_plugins as $plugin => $plugin_data ) {
            if ( strrpos( $plugin$folder ) !== 0 ) {
                continue;
            }

            $current_plugin_data = $plugin_data;
        }

        }

        $prepared_term = $this->prepare_item_for_database( $request );

        $term = wp_insert_term( wp_slash( $prepared_term->name )$this->taxonomy, wp_slash( (array) $prepared_term ) );
        if ( is_wp_error( $term ) ) {
            /* * If we're going to inform the client that the term already exists, * give them the identifier for future use. */
            $term_id = $term->get_error_data( 'term_exists' );
            if ( $term_id ) {
                $existing_term = get_term( $term_id$this->taxonomy );
                $term->add_data( $existing_term->term_id, 'term_exists' );
                $term->add_data(
                    array(
                        'status'  => 400,
                        'term_id' => $term_id,
                    )
                );
            }

            
header( 'Content-Type: text/plain' );
    exit;
}

/** Sets up the WordPress Environment. */
require __DIR__ . '/wp-load.php';

nocache_headers();

$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
if ( is_wp_error( $comment ) ) {
    $data = (int) $comment->get_error_data();
    if ( ! empty( $data ) ) {
        wp_die(
            '<p>' . $comment->get_error_message() . '</p>',
            __( 'Comment Submission Failure' ),
            array(
                'response'  => $data,
                'back_link' => true,
            )
        );
    } else {
        exit;
    }
            return $package; // Must be a local file.         }

        if ( empty( $package ) ) {
            return new WP_Error( 'no_package', $this->strings['no_package'] );
        }

        $this->skin->feedback( 'downloading_package', $package );

        $download_file = download_url( $package, 300, $check_signatures );

        if ( is_wp_error( $download_file ) && ! $download_file->get_error_data( 'softfail-filename' ) ) {
            return new WP_Error( 'download_failed', $this->strings['download_failed']$download_file->get_error_message() );
        }

        return $download_file;
    }

    /** * Unpacks a compressed package file. * * @since 2.8.0 * * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. * * @param string $package Full path to the package file. * @param bool $delete_package Optional. Whether to delete the package file after attempting * to unpack it. Default true. * @return string|WP_Error The path to the unpacked contents, or a WP_Error on failure. */
$args = wp_parse_args( $args$defaults );

    if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
        if ( ! empty( $message->errors ) ) {
            $errors = array();
            foreach ( (array) $message->errors as $error_code => $error_messages ) {
                foreach ( (array) $error_messages as $error_message ) {
                    $errors[] = array(
                        'code'    => $error_code,
                        'message' => $error_message,
                        'data'    => $message->get_error_data( $error_code ),
                    );
                }
            }

            $message = $errors[0]['message'];
            if ( empty( $args['code'] ) ) {
                $args['code'] = $errors[0]['code'];
            }
            if ( empty( $args['response'] ) && is_array( $errors[0]['data'] ) && ! empty( $errors[0]['data']['status'] ) ) {
                $args['response'] = $errors[0]['data']['status'];
            }
            


/** * Displays the given administration message. * * @since 2.1.0 * * @param string|WP_Error $message */
function show_message( $message ) {
    if ( is_wp_error( $message ) ) {
        if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) {
            $message = $message->get_error_message() . ': ' . $message->get_error_data();
        } else {
            $message = $message->get_error_message();
        }
    }

    echo "<p>$message</p>\n";
    wp_ob_end_flush_all();
    flush();
}

$new_category = array(
            'cat_name'             => $category['name'],
            'category_nicename'    => $category['slug'],
            'category_parent'      => $category['parent_id'],
            'category_description' => $category['description'],
        );

        $cat_id = wp_insert_category( $new_category, true );
        if ( is_wp_error( $cat_id ) ) {
            if ( 'term_exists' === $cat_id->get_error_code() ) {
                return (int) $cat_id->get_error_data();
            } else {
                return new IXR_Error( 500, __( 'Sorry, the category could not be created.' ) );
            }
        } elseif ( ! $cat_id ) {
            return new IXR_Error( 500, __( 'Sorry, the category could not be created.' ) );
        }

        /** * Fires after a new category has been successfully created via XML-RPC. * * @since 3.4.0 * * @param int $cat_id ID of the new category. * @param array $args An array of new category arguments. */


        $error_code = $result->get_error_code();

        /* * Any of these WP_Error codes are critical failures, as in they occurred after we started to copy core files. * We should not try to perform a background update again until there is a successful one-click update performed by the user. */
        $critical = false;
        if ( 'disk_full' === $error_code || str_contains( $error_code, '__copy_dir' ) ) {
            $critical = true;
        } elseif ( 'rollback_was_required' === $error_code && is_wp_error( $result->get_error_data()->rollback ) ) {
            // A rollback is only critical if it failed too.             $critical        = true;
            $rollback_result = $result->get_error_data()->rollback;
        } elseif ( str_contains( $error_code, 'do_rollback' ) ) {
            $critical = true;
        }

        if ( $critical ) {
            $critical_data = array(
                'attempted'  => $core_update->current,
                'current'    => $wp_version,
                

function wp_ajax_edit_theme_plugin_file() {
    $r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); // Validation of args is done in wp_edit_theme_plugin_file().
    if ( is_wp_error( $r ) ) {
        wp_send_json_error(
            array_merge(
                array(
                    'code'    => $r->get_error_code(),
                    'message' => $r->get_error_message(),
                ),
                (array) $r->get_error_data()
            )
        );
    } else {
        wp_send_json_success(
            array(
                'message' => __( 'File edited successfully.' ),
            )
        );
    }
}

// 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->has_errors() ) {
        $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 ) ) {
            /** * Filters the error messages displayed above the login form. * * @since 2.1.0 * * @param string $errors Login error message. */

function rest_application_password_check_errors( $result ) {
    global $wp_rest_application_password_status;

    if ( ! empty( $result ) ) {
        return $result;
    }

    if ( is_wp_error( $wp_rest_application_password_status ) ) {
        $data = $wp_rest_application_password_status->get_error_data();

        if ( ! isset( $data['status'] ) ) {
            $data['status'] = 401;
        }

        $wp_rest_application_password_status->add_data( $data );

        return $wp_rest_application_password_status;
    }

    if ( $wp_rest_application_password_status instanceof WP_User ) {
        

    public function error( $errors ) {
        if ( is_string( $errors ) && isset( $this->upgrader->strings[ $errors ] ) ) {
            $this->error = $this->upgrader->strings[ $errors ];
        }

        if ( is_wp_error( $errors ) ) {
            $messages = array();
            foreach ( $errors->get_error_messages() as $emessage ) {
                if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
                    $messages[] = $emessage . ' ' . esc_html( strip_tags( $errors->get_error_data() ) );
                } else {
                    $messages[] = $emessage;
                }
            }
            $this->error = implode( ', ', $messages );
        }
        echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
    }

    /** */
<?php _e( 'Activation Key:' ); ?></label> <br /><input type="text" name="key" id="key" value="" size="50" autofocus="autofocus" /> </p> <p class="submit"> <input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e( 'Activate' ); ?>" /> </p> </form> <?php     } else {
        if ( is_wp_error( $result ) && in_array( $result->get_error_code()$valid_error_codes, true ) ) {
            $signup = $result->get_error_data();
            ?> <h2><?php _e( 'Your account is now active!' ); ?></h2> <?php             echo '<p class="lead-in">';
            if ( '' === $signup->domain . $signup->path ) {
                printf(
                    /* translators: 1: Login URL, 2: Username, 3: User email address, 4: Lost password URL. */
                    __( 'Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.' ),
                    network_site_url( $blog_details->path . 'wp-login.php', 'login' ),
                    $signup->user_login,
                    $signup->user_email,
                    

    public function prepare_setting_validity_for_js( $validity ) {
        if ( is_wp_error( $validity ) ) {
            $notification = array();
            foreach ( $validity->errors as $error_code => $error_messages ) {
                $notification[ $error_code ] = array(
                    'message' => implode( ' ', $error_messages ),
                    'data'    => $validity->get_error_data( $error_code ),
                );
            }
            return $notification;
        } else {
            return true;
        }
    }

    /** * Handles customize_save WP Ajax request to save/update a changeset. * * @since 3.4.0 * @since 4.7.0 The semantics of this method have changed to update a changeset, optionally to also change the status and other attributes. */
Home | Imprint | This part of the site doesn't use cookies.