get_error_code example

 else {
        $result = wpmu_activate_signup( $key );
    }
}

if ( null === $result && isset( $_COOKIE[ $activate_cookie ] ) ) {
    $key    = $_COOKIE[ $activate_cookie ];
    $result = wpmu_activate_signup( $key );
    setcookie( $activate_cookie, ' ', time() - YEAR_IN_SECONDS, $activate_path, COOKIE_DOMAIN, is_ssl(), true );
}

if ( null === $result || ( is_wp_error( $result ) && 'invalid_key' === $result->get_error_code() ) ) {
    status_header( 404 );
} elseif ( is_wp_error( $result ) ) {
    $error_code = $result->get_error_code();

    if ( ! in_array( $error_code$valid_error_codes, true ) ) {
        status_header( 400 );
    }
}

nocache_headers();


        $provider = apply_filters( 'oembed_fetch_url', $provider$url$args );

        foreach ( array( 'json', 'xml' ) as $format ) {
            $result = $this->_fetch_with_format( $provider$format );
            if ( is_wp_error( $result ) && 'not-implemented' === $result->get_error_code() ) {
                continue;
            }

            return ( $result && ! is_wp_error( $result ) ) ? $result : false;
        }

        return false;
    }

    /** * Fetches result from an oEmbed provider for a specific format and complete provider URL * * @since 3.0.0 * * @param string $provider_url_with_args URL to the provider with full arguments list (url, maxheight, etc.) * @param string $format Format to use. * @return object|false|WP_Error The result in the form of an object on success, false on failure. */
if ( null == $user ) {
            /* * TODO: What should the error message be? (Or would these even happen?) * Only needed if all authentication handlers fail to return anything. */
            $user = new WP_Error( 'authentication_failed', __( '<strong>Error:</strong> Invalid username, email address or incorrect password.' ) );
        }

        $ignore_codes = array( 'empty_username', 'empty_password' );

        if ( is_wp_error( $user ) && ! in_array( $user->get_error_code()$ignore_codes, true ) ) {
            $error = $user;

            /** * Fires after a user login has failed. * * @since 2.5.0 * @since 4.5.0 The value of `$username` can now be an email address. * @since 5.4.0 The `$error` parameter was added. * * @param string $username Username or email address. * @param WP_Error $error A WP_Error object with the authentication failure details. */
if ( 'custom' === $template->source ) {
            $update = true;
            $result = wp_update_post( wp_slash( (array) $changes ), false );
        } else {
            $update      = false;
            $post_before = null;
            $result      = wp_insert_post( wp_slash( (array) $changes ), false );
        }

        if ( is_wp_error( $result ) ) {
            if ( 'db_update_error' === $result->get_error_code() ) {
                $result->add_data( array( 'status' => 500 ) );
            } else {
                $result->add_data( array( 'status' => 400 ) );
            }
            return $result;
        }

        $template      = get_block_template( $request['id']$this->post_type );
        $fields_update = $this->update_additional_fields_for_object( $template$request );
        if ( is_wp_error( $fields_update ) ) {
            return $fields_update;
        }


            if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) {
                wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s) );
                exit;
            }

            check_admin_referer( 'activate-plugin_' . $plugin );

            $result = activate_plugin( $pluginself_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) )is_network_admin() );
            if ( is_wp_error( $result ) ) {
                if ( 'unexpected_output' === $result->get_error_code() ) {
                    $redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s);
                    wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin )$redirect ) );
                    exit;
                } else {
                    wp_die( $result );
                }
            }

            if ( ! is_network_admin() ) {
                $recent = (array) get_option( 'recently_activated' );
                unset( $recent[ $plugin ] );
                

            }
        } else {
            // Insert or update menu.             $menu_data              = wp_array_slice_assoc( $value, array( 'description', 'parent' ) );
            $menu_data['menu-name'] = $value['name'];

            $menu_id              = $is_placeholder ? 0 : $this->term_id;
            $r                    = wp_update_nav_menu_object( $menu_idwp_slash( $menu_data ) );
            $original_name        = $menu_data['menu-name'];
            $name_conflict_suffix = 1;
            while ( is_wp_error( $r ) && 'menu_exists' === $r->get_error_code() ) {
                $name_conflict_suffix += 1;
                /* translators: 1: Original menu name, 2: Duplicate count. */
                $menu_data['menu-name'] = sprintf( __( '%1$s (%2$d)' )$original_name$name_conflict_suffix );
                $r                      = wp_update_nav_menu_object( $menu_idwp_slash( $menu_data ) );
            }

            if ( is_wp_error( $r ) ) {
                $this->update_status = 'error';
                $this->update_error  = $r;
            } else {
                if ( $is_placeholder ) {
                    
$stylesheet = $theme;
} else {
    $stylesheet = get_stylesheet();
}

$theme = wp_get_theme( $stylesheet );

if ( ! $theme->exists() ) {
    wp_die( __( 'The requested theme does not exist.' ) );
}

if ( $theme->errors() && 'theme_no_stylesheet' === $theme->errors()->get_error_code() ) {
    wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() );
}

$allowed_files = array();
$style_files   = array();

$file_types = wp_get_theme_file_editable_extensions( $theme );

foreach ( $file_types as $type ) {
    switch ( $type ) {
        case 'php':
            
?> <div class="wrap"> <h1><?php echo esc_html( $title ); ?></h1> <?php if ( isset( $_GET['a'] ) ) : ?> <div id="message" class="updated notice is-dismissible"> <p><?php _e( 'File edited successfully.' ); ?></p> </div> <?php elseif ( is_wp_error( $edit_error ) ) : ?> <div id="message" class="notice notice-error"> <p><?php _e( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ); ?></p> <pre><?php echo esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); ?></pre> </div> <?php endif; ?> <div class="fileedit-sub"> <div class="alignleft"> <h2> <?php     if ( is_plugin_active( $plugin ) ) {
        if ( is_writable( $real_file ) ) {
            /* translators: %s: Plugin file name. */
            printf( __( 'Editing %s (active)' ), '<strong>' . esc_html( $file ) . '</strong>' );
        }
// Unzip package to working directory.         $result = unzip_file( $package$working_dir );

        // Once extracted, delete the package if required.         if ( $delete_package ) {
            unlink( $package );
        }

        if ( is_wp_error( $result ) ) {
            $wp_filesystem->delete( $working_dir, true );
            if ( 'incompatible_archive' === $result->get_error_code() ) {
                return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive']$result->get_error_data() );
            }
            return $result;
        }

        return $working_dir;
    }

    /** * Flattens the results of WP_Filesystem_Base::dirlist() for iterating over. * * @since 4.9.0 * @access protected * * @param array $nested_files Array of files as returned by WP_Filesystem_Base::dirlist(). * @param string $path Relative path to prepend to child nodes. Optional. * @return array A flattened array of the $nested_files specified. */


    $blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id$metaget_current_network_id() );

    // TODO: What to do if we create a user but cannot create a blog?     if ( is_wp_error( $blog_id ) ) {
        /* * If blog is taken, that means a previous attempt to activate this blog * failed in between creating the blog and setting the activation flag. * Let's just set the active flag and instruct the user to reset their password. */
        if ( 'blog_taken' === $blog_id->get_error_code() ) {
            $blog_id->add_data( $signup );
            $wpdb->update(
                $wpdb->signups,
                array(
                    'active'    => 1,
                    'activated' => $now,
                ),
                array( 'activation_key' => $key )
            );
        }
        return $blog_id;
    }

    public function hide_process_failed( $wp_error ) {
        if (
            'upload' === $this->type &&
            '' === $this->overwrite &&
            $wp_error->get_error_code() === 'folder_exists'
        ) {
            return true;
        }

        return false;
    }

    /** * Performs an action following a single theme install. * * @since 2.8.0 */
check_admin_referer( 'install-network-1' );

    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    // Create network tables.     install_network();
    $base              = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH );
    $subdomain_install = allow_subdomain_install() ? ! empty( $_POST['subdomain_install'] ) : false;
    if ( ! network_domain_check() ) {
        $result = populate_network( 1, get_clean_basedomain()sanitize_email( $_POST['email'] )wp_unslash( $_POST['sitename'] )$base$subdomain_install );
        if ( is_wp_error( $result ) ) {
            if ( 1 === count( $result->get_error_codes() ) && 'no_wildcard_dns' === $result->get_error_code() ) {
                network_step2( $result );
            } else {
                network_step1( $result );
            }
        } else {
            network_step2();
        }
    } else {
        network_step2();
    }
} elseif ( is_multisite() || network_domain_check() ) {
    
$value = explode( "\n", $value );
                $value = array_filter( array_map( 'trim', $value ) );
                $value = array_unique( $value );
                $value = implode( "\n", $value );
            }
            break;
    }

    if ( null !== $error ) {
        if ( '' === $error && is_wp_error( $value ) ) {
            /* translators: 1: Option name, 2: Error code. */
            $error = sprintf( __( 'Could not sanitize the %1$s option. Error code: %2$s' )$option$value->get_error_code() );
        }

        $value = get_option( $option );
        if ( function_exists( 'add_settings_error' ) ) {
            add_settings_error( $option, "invalid_{$option}", $error );
        }
    }

    /** * Filters an option value following sanitization. * * @since 2.3.0 * @since 4.3.0 Added the `$original_value` parameter. * * @param string $value The sanitized option value. * @param string $option The option name. * @param string $original_value The original value passed to the function. */
<?php } ?> <?php if ( $can_install ) { ?> <td></td> <?php } ?> </tr> <?php foreach ( $broken_themes as $broken_theme ) : ?> <tr> <td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td> <td><?php echo $broken_theme->errors()->get_error_message(); ?></td> <?php             if ( $can_resume ) {
                if ( 'theme_paused' === $broken_theme->errors()->get_error_code() ) {
                    $stylesheet = $broken_theme->get_stylesheet();
                    $resume_url = add_query_arg(
                        array(
                            'action'     => 'resume',
                            'stylesheet' => urlencode( $stylesheet ),
                        ),
                        admin_url( 'themes.php' )
                    );
                    $resume_url = wp_nonce_url( $resume_url, 'resume-theme_' . $stylesheet );
                    ?> <td><a href="<?php echo esc_url( $resume_url ); ?>" class="button resume-theme"><?php _e( 'Resume' ); ?></a></td>
$attachment->post_mime_type = $type;
        $attachment->guid           = $url;

        if ( empty( $attachment->post_title ) ) {
            $attachment->post_title = preg_replace( '/\.[^.]+$/', '', wp_basename( $file ) );
        }

        // $post_parent is inherited from $attachment['post_parent'].         $id = wp_insert_attachment( wp_slash( (array) $attachment )$file, 0, true, false );

        if ( is_wp_error( $id ) ) {
            if ( 'db_update_error' === $id->get_error_code() ) {
                $id->add_data( array( 'status' => 500 ) );
            } else {
                $id->add_data( array( 'status' => 400 ) );
            }

            return $id;
        }

        $attachment = get_post( $id );

        /** * Fires after a single attachment is created or updated via the REST API. * * @since 4.7.0 * * @param WP_Post $attachment Inserted or updated attachment * object. * @param WP_REST_Request $request The request sent to the API. * @param bool $creating True when creating an attachment, false when updating. */
Home | Imprint | This part of the site doesn't use cookies.