Core_Upgrader example


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 */

    public function update( $type$item ) {
        $skin = new Automatic_Upgrader_Skin();

        switch ( $type ) {
            case 'core':
                // The Core upgrader doesn't use the Upgrader's skin during the actual main part of the upgrade, instead, firing a filter.                 add_filter( 'update_feedback', array( $skin, 'feedback' ) );
                $upgrader = new Core_Upgrader( $skin );
                $context  = ABSPATH;
                break;
            case 'plugin':
                $upgrader = new Plugin_Upgrader( $skin );
                $context  = WP_PLUGIN_DIR; // We don't support custom Plugin directories, or updates for WPMU_PLUGIN_DIR.                 break;
            case 'theme':
                $upgrader = new Theme_Upgrader( $skin );
                $context  = get_theme_root( $item->theme );
                break;
            case 'translation':
                

        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.