upgrade example

        $title        = __( 'Update Plugin' );
        $parent_file  = 'plugins.php';
        $submenu_file = 'plugins.php';

        wp_enqueue_script( 'updates' );
        require_once ABSPATH . 'wp-admin/admin-header.php';

        $nonce = 'upgrade-plugin_' . $plugin;
        $url   = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );

        $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ) );
        $upgrader->upgrade( $plugin );

        require_once ABSPATH . 'wp-admin/admin-footer.php';

    } elseif ( 'activate-plugin' === $action ) {
        if ( ! current_user_can( 'update_plugins' ) ) {
            wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) );
        }

        check_admin_referer( 'activate-plugin_' . $plugin );
        if ( ! isset( $_GET['failure'] ) && ! isset( $_GET['success'] ) ) {
            wp_redirect( admin_url( 'update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce'] ) );
            
$try_rollback = true;
                }
            }

            if ( $try_rollback ) {
                /** This filter is documented in wp-admin/includes/update-core.php */
                apply_filters( 'update_feedback', $result );

                /** This filter is documented in wp-admin/includes/update-core.php */
                apply_filters( 'update_feedback', $this->strings['start_rollback'] );

                $rollback_result = $this->upgrade( $currentarray_merge( $parsed_args, array( 'do_rollback' => true ) ) );

                $original_result = $result;
                $result          = new WP_Error(
                    'rollback_was_required',
                    $this->strings['rollback_was_required'],
                    (object) array(
                        'update'   => $original_result,
                        'rollback' => $rollback_result,
                    )
                );
            }
        }

function wp_update_core($current$feedback = '') {
    _deprecated_function( __FUNCTION__, '3.7.0', 'new Core_Upgrader();' );

    if ( !empty($feedback) )
        add_filter('update_feedback', $feedback);

    require ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $upgrader = new Core_Upgrader();
    return $upgrader->upgrade($current);

}

/** * This was once used to kick-off the Plugin Updater. * * Deprecated in favor of instantating a Plugin_Upgrader instance directly, * and calling the 'upgrade' method. * Unused since 2.8.0. * * @since 2.5.0 * @deprecated 3.7.0 Use Plugin_Upgrader * @see Plugin_Upgrader */
/* translators: 1: Project name (plugin, theme, or WordPress), 2: Language. */
                $skin->feedback( sprintf( __( 'Updating translations for %1$s (%2$s)…' )$language_item_name$item->language ) );
                break;
        }

        $allow_relaxed_file_ownership = false;
        if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) {
            $allow_relaxed_file_ownership = true;
        }

        // Boom, this site's about to get a whole new splash of paint!         $upgrade_result = $upgrader->upgrade(
            $upgrader_item,
            array(
                'clear_update_cache'           => false,
                // Always use partial builds if possible for core updates.                 'pre_check_md5'                => false,
                // Only available for core updates.                 'attempt_rollback'             => true,
                // Allow relaxed file ownership in some scenarios.                 'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
            )
        );

        


    if ( empty( $translation_to_load ) ) {
        return false;
    }
    $translation = (object) $translation;

    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $skin              = new Automatic_Upgrader_Skin();
    $upgrader          = new Language_Pack_Upgrader( $skin );
    $translation->type = 'core';
    $result            = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) );

    if ( ! $result || is_wp_error( $result ) ) {
        return false;
    }

    return $translation->language;
}

/** * Check if WordPress has access to the filesystem without asking for * credentials. * * @since 4.0.0 * * @return bool Returns true on success, false on failure. */
echo '</div>';
        return;
    }

    if ( $reinstall ) {
        $update->response = 'reinstall';
    }

    add_filter( 'update_feedback', 'show_message' );

    $upgrader = new Core_Upgrader();
    $result   = $upgrader->upgrade(
        $update,
        array(
            'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
        )
    );

    if ( is_wp_error( $result ) ) {
        show_message( $result );
        if ( 'up_to_date' !== $result->get_error_code() && 'locked' !== $result->get_error_code() ) {
            show_message( __( 'Installation failed.' ) );
        }
        
Home | Imprint | This part of the site doesn't use cookies.