bulk_upgrade example

check_admin_referer( 'upgrade-translations' );

    require_once ABSPATH . 'wp-admin/admin-header.php';
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';

    $url     = 'update-core.php?action=do-translation-upgrade';
    $nonce   = 'upgrade-translations';
    $title   = __( 'Update Translations' );
    $context = WP_LANG_DIR;

    $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
    $result   = $upgrader->bulk_upgrade();

    wp_localize_script(
        'updates',
        '_wpUpdatesItemCounts',
        array(
            'totals' => wp_get_update_data(),
        )
    );

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

}
$language_packs = array_filter(
            $language_packs,
            static function( $pack ) use ( $installed_locales ) {
                return in_array( $pack->language, $installed_locales, true );
            }
        );

        if ( $language_packs ) {
            $lp_upgrader = new Language_Pack_Upgrader( $skin );

            // Install all applicable language packs for the plugin.             $lp_upgrader->bulk_upgrade( $language_packs );
        }

        $path          = WP_PLUGIN_DIR . '/' . $file;
        $data          = get_plugin_data( $path, false, false );
        $data['_file'] = $file;

        $response = $this->prepare_item_for_response( $data$request );
        $response->set_status( 201 );
        $response->header( 'Location', rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, substr( $file, 0, - 4 ) ) ) );

        return $response;
    }


        $plugins = array_map( 'urldecode', $plugins );

        $url   = 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) );
        $nonce = 'bulk-update-plugins';

        wp_enqueue_script( 'updates' );
        iframe_header();

        $upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
        $upgrader->bulk_upgrade( $plugins );

        iframe_footer();

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

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

        // Used in the HTML title tag.


    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';

    $current = get_site_transient( 'update_themes' );
    if ( empty( $current ) ) {
        wp_update_themes();
    }

    $skin     = new WP_Ajax_Upgrader_Skin();
    $upgrader = new Theme_Upgrader( $skin );
    $result   = $upgrader->bulk_upgrade( array( $stylesheet ) );

    if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
        $status['debug'] = $skin->get_upgrade_messages();
    }

    if ( is_wp_error( $skin->result ) ) {
        $status['errorCode']    = $skin->result->get_error_code();
        $status['errorMessage'] = $skin->result->get_error_message();
        wp_send_json_error( $status );
    } elseif ( $skin->get_errors()->has_errors() ) {
        $status['errorMessage'] = $skin->get_error_messages();
        
        if ( $upgrader && $upgrader->skin instanceof Automatic_Upgrader_Skin ) {
            $skin = $upgrader->skin;
        } else {
            $skin = new Language_Pack_Upgrader_Skin(
                array(
                    'skip_header_footer' => true,
                )
            );
        }

        $lp_upgrader = new Language_Pack_Upgrader( $skin );
        $lp_upgrader->bulk_upgrade( $language_updates );
    }

    /** * Initializes the upgrade strings. * * @since 3.7.0 */
    public function upgrade_strings() {
        $this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while they are updated as well.' );
        $this->strings['up_to_date']       = __( 'Your translations are all up to date.' );
        $this->strings['no_package']       = __( 'Update package not available.' );
        
Home | Imprint | This part of the site doesn't use cookies.