Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:10up/convert-to-blocks into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed May 14, 2024
2 parents e048dea + bb362e4 commit 2b9a347
Show file tree
Hide file tree
Showing 17 changed files with 171 additions and 102 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-release-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version and npm cache
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install Node dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ jobs:
matrix:
core:
- {name: 'WP latest', version: 'latest', continue: false}
- {name: 'WP minimum', version: 'WordPress/WordPress#6.1', continue: false}
- {name: 'WP minimum', version: 'WordPress/WordPress#6.3', continue: false}
- {name: 'WP trunk', version: 'WordPress/WordPress#master', continue: true}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: npm install
run: npm ci
- name: Composer (optional)
run: composer install
continue-on-error: true
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Build (optional)
Expand All @@ -40,7 +40,7 @@ jobs:
run: npm run cypress:run
continue-on-error: ${{ matrix.core.continue }}
- name: Make artifacts available
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-artifact
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotorg-push-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
uses: actions/checkout@v3

- name: Setup node version
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version-file: '.nvmrc'

- name: Build
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: npm install
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
v20
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file, per [the Ke

## [Unreleased] - TBD

## [1.3.0] - 2024-05-14
### Added
- Block Catalog integration, and pagination support (props [@dsawardekar](https://github.com/dsawardekar), [@iamdharmesh](https://github.com/iamdharmesh) via [#164](https://github.com/10up/convert-to-blocks/pull/164)).

### Changed
- Adjust `enable_block_editor` method only to alter posts that support the gutenbridge (props [@stormrockwell](https://github.com/stormrockwell), [@Sidsector9](https://github.com/Sidsector9), [@jeffpaul](https://github.com/jeffpaul), [@dsawardekar](https://github.com/dsawardekar) via [#136](https://github.com/10up/convert-to-blocks/pull/136)).
- Bump WordPress "tested up to" version 6.5 (props [@QAharshalkadu](https://github.com/QAharshalkadu), [@jeffpaul](https://github.com/jeffpaul), [@Sidsector9](https://github.com/Sidsector9), [@sudip-md](https://github.com/sudip-md), [@dkotter](https://github.com/dkotter) via [#146](https://github.com/10up/convert-to-blocks/pull/146), [#161](https://github.com/10up/convert-to-blocks/pull/161)).
- Replaced [lee-dohm/no-response](https://github.com/lee-dohm/no-response) with [actions/stale](https://github.com/actions/stale) to help with closing no-response/stale issues (props [@jeffpaul](https://github.com/jeffpaul) via [#159](https://github.com/10up/convert-to-blocks/pull/159)).
- Bump Node version from 16 to 20 (props [@aaronjorbin](https://github.com/aaronjorbin), [@Sidsector9](https://github.com/Sidsector9), [@dkotter](https://github.com/dkotter) via [#160](https://github.com/10up/convert-to-blocks/pull/160)).
- Bump `actions/upload-artifact` from v3 to v4 (props [@iamdharmesh](https://github.com/iamdharmesh) via [#162](https://github.com/10up/convert-to-blocks/pull/162)).

### Security
- Bump `follow-redirects` from 1.15.2 to 1.15.4 (props [@dependabot](https://github.com/apps/dependabot), [@dkotter](https://github.com/dkotter) via [#153](https://github.com/10up/convert-to-blocks/pull/153)).
- Bump `browserify-sign` from 4.0.4 to 4.2.2 (props [@dependabot](https://github.com/apps/dependabot), [@dkotter](https://github.com/dkotter) via [#145](https://github.com/10up/convert-to-blocks/pull/145)).
- Bump `@babel/traverse` from 7.11.5 to 7.23.7 (props [@dependabot](https://github.com/apps/dependabot), [@dkotter](https://github.com/dkotter) via [#155](https://github.com/10up/convert-to-blocks/pull/155)).

## [1.2.2] - 2023-10-16
### Changed
- Bump WordPress "tested up to" version to 6.3 (props [@kmgalanakis](https://github.com/kmgalanakis), [@faisal-alvi](https://github.com/faisal-alvi), [@jeffpaul](https://github.com/jeffpaul), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#132](https://github.com/10up/convert-to-blocks/pull/132), [#134](https://github.com/10up/convert-to-blocks/pull/134)).
Expand Down Expand Up @@ -131,6 +147,7 @@ All notable changes to this project will be documented in this file, per [the Ke
- Initial release of Convert to Blocks.

[Unreleased]: https://github.com/10up/convert-to-blocks/compare/trunk...develop
[1.3.0]: https://github.com/10up/convert-to-blocks/compare/1.2.1...1.3.0
[1.2.2]: https://github.com/10up/convert-to-blocks/compare/1.2.1...1.2.2
[1.2.1]: https://github.com/10up/convert-to-blocks/compare/1.2.0...1.2.1
[1.2.0]: https://github.com/10up/convert-to-blocks/compare/1.1.1...1.2.0
Expand Down
2 changes: 1 addition & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The following individuals are responsible for curating the list of issues, respo

Thank you to all the people who have already contributed to this repository via bug reports, code, design, ideas, project management, translation, testing, etc.

[Darshan Sawardekar (@dsawardekar)](https://github.com/dsawardekar), [Taylor Lovett (@tlovett1)](https://github.com/tlovett1), [Tyler Bailey (@TylerB24890)](https://github.com/TylerB24890), [Jeffrey Paul (@jeffpaul)](https://github.com/jeffpaul), [Tung Du (@dinhtungdu)](https://github.com/dinhtungdu), [Diana Padron](https://profiles.wordpress.org/dianapadron), [Barry Ceelen (@barryceelen)](https://github.com/barryceelen), [Darin Kotter (@dkotter)](https://github.com/dkotter), [Peter Sorensen (@psorensen)](https://github.com/psorensen), [Brandon Berg (@BBerg10up)](https://github.com/BBerg10up), [Hashim Warren (@hashimwarren)](https://github.com/hashimwarren), [Jason LeMahieu (@MadtownLems)](https://github.com/MadtownLems), [Simon Carne](https://profiles.wordpress.org/scarne/), [Rodrigo Arias (@rodrigo-arias)](https://github.com/rodrigo-arias), [Gary Thayer (@gthayer)](https://github.com/gthayer), [Faisal Alvi (@faisal-alvi)](https://github.com/faisal-alvi), [Siddharth Thevaril (@Sidsector9)](https://github.com/Sidsector9), [Max Lyuchin (@cadic)](https://github.com/cadic), [Dharmesh Patel (@iamdharmesh)](https://github.com/iamdharmesh), [Mohit Dadhich (@mohitwp)](https://github.com/mohitwp), [GitHub Dependabot (@dependabot)](https://github.com/apps/dependabot), [Peter Wilson (@peterwilsoncc)](https://github.com/peterwilsoncc), [Andrew Norcross (@norcross)](https://github.com/norcross), [Quamruz Zaman (@zamanq)](https://github.com/zamanq), [Mehul Gohil (@mehul0810)](https://github.com/mehul0810), [Akshit Sethi (@akshitsethi)](https://github.com/akshitsethi), [Terrance Orletsky (@terrance-orletsky-d7)](https://github.com/terrance-orletsky-d7), [Philipp (@ouun)](https://github.com/ouun), [Sanket Parmar (@sanketio)](https://github.com/sanketio), [Konstantinos Galanakis (@kmgalanakis)](https://github.com/kmgalanakis), [Vikram Moparthy (@vikrampm1)](https://github.com/vikrampm1), [Barney Jeffries (@barneyjeffries)](https://github.com/barneyjeffries), [Ravinder Kumar (@ravinderk)](https://github.com/ravinderk), [Felipe Elia (@felipeelia)](https://github.com/felipeelia), [Dan Burzynski (@c0ntax)](https://github.com/c0ntax).
[Darshan Sawardekar (@dsawardekar)](https://github.com/dsawardekar), [Taylor Lovett (@tlovett1)](https://github.com/tlovett1), [Tyler Bailey (@TylerB24890)](https://github.com/TylerB24890), [Jeffrey Paul (@jeffpaul)](https://github.com/jeffpaul), [Tung Du (@dinhtungdu)](https://github.com/dinhtungdu), [Diana Padron](https://profiles.wordpress.org/dianapadron), [Barry Ceelen (@barryceelen)](https://github.com/barryceelen), [Darin Kotter (@dkotter)](https://github.com/dkotter), [Peter Sorensen (@psorensen)](https://github.com/psorensen), [Brandon Berg (@BBerg10up)](https://github.com/BBerg10up), [Hashim Warren (@hashimwarren)](https://github.com/hashimwarren), [Jason LeMahieu (@MadtownLems)](https://github.com/MadtownLems), [Simon Carne](https://profiles.wordpress.org/scarne/), [Rodrigo Arias (@rodrigo-arias)](https://github.com/rodrigo-arias), [Gary Thayer (@gthayer)](https://github.com/gthayer), [Faisal Alvi (@faisal-alvi)](https://github.com/faisal-alvi), [Siddharth Thevaril (@Sidsector9)](https://github.com/Sidsector9), [Max Lyuchin (@cadic)](https://github.com/cadic), [Dharmesh Patel (@iamdharmesh)](https://github.com/iamdharmesh), [Mohit Dadhich (@mohitwp)](https://github.com/mohitwp), [GitHub Dependabot (@dependabot)](https://github.com/apps/dependabot), [Peter Wilson (@peterwilsoncc)](https://github.com/peterwilsoncc), [Andrew Norcross (@norcross)](https://github.com/norcross), [Quamruz Zaman (@zamanq)](https://github.com/zamanq), [Mehul Gohil (@mehul0810)](https://github.com/mehul0810), [Akshit Sethi (@akshitsethi)](https://github.com/akshitsethi), [Terrance Orletsky (@terrance-orletsky-d7)](https://github.com/terrance-orletsky-d7), [Philipp (@ouun)](https://github.com/ouun), [Sanket Parmar (@sanketio)](https://github.com/sanketio), [Konstantinos Galanakis (@kmgalanakis)](https://github.com/kmgalanakis), [Vikram Moparthy (@vikrampm1)](https://github.com/vikrampm1), [Barney Jeffries (@barneyjeffries)](https://github.com/barneyjeffries), [Ravinder Kumar (@ravinderk)](https://github.com/ravinderk), [Felipe Elia (@felipeelia)](https://github.com/felipeelia), [Dan Burzynski (@c0ntax)](https://github.com/c0ntax), [Storm Rockwell (@stormrockwell)](https://github.com/stormrockwell), [Harshal Kadu (@QAharshalkadu)](https://github.com/QAharshalkadu), [Sudip Dadhaniya (@sudip-md)](https://github.com/sudip-md), [Aaron Jorbin (@aaronjorbin)](https://github.com/aaronjorbin).

## Libraries

Expand Down
62 changes: 58 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

> Transforms classic editor content to blocks on-the-fly.
[![Support Level](https://img.shields.io/badge/support-stable-blue.svg)](#support-level) [![Release Version](https://img.shields.io/github/release/10up/convert-to-blocks.svg)](https://github.com/10up/convert-to-blocks/releases/latest) ![WordPress tested up to version](https://img.shields.io/wordpress/plugin/tested/convert-to-blocks?label=WordPress) [![GPLv2 License](https://img.shields.io/github/license/10up/convert-to-blocks.svg)](https://github.com/10up/convert-to-blocks/blob/develop/LICENSE.md)
[![Support Level](https://img.shields.io/badge/support-stable-blue.svg)](#support-level) ![WordPress Plugin Version](https://img.shields.io/wordpress/plugin/v/convert-to-blocks?label=Latest%20Release) ![WordPress Plugin: Tested WP Version](https://img.shields.io/wordpress/plugin/tested/convert-to-blocks?label=WordPress%20tested%20up%20to) ![WordPress Plugin Required PHP Version](https://img.shields.io/wordpress/plugin/required-php/convert-to-blocks?label=Requires%20PHP) ![WordPress Plugin: Required WP Version](https://img.shields.io/wordpress/plugin/wp-version/convert-to-blocks?label=Requires%20WordPress) [![GPL-2.0-or-later License](https://img.shields.io/github/license/10up/convert-to-blocks.svg)](https://github.com/10up/convert-to-blocks/blob/develop/LICENSE.md)

[![E2E test](https://github.com/10up/convert-to-blocks/actions/workflows/cypress.yml/badge.svg)](https://github.com/10up/convert-to-blocks/actions/workflows/cypress.yml) [![Linting](https://github.com/10up/convert-to-blocks/actions/workflows/lint.yml/badge.svg)](https://github.com/10up/convert-to-blocks/actions/workflows/lint.yml) [![Dependency Review](https://github.com/10up/convert-to-blocks/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/10up/convert-to-blocks/actions/workflows/dependency-review.yml)

## Overview

Convert to Blocks is a WordPress plugin that transforms classic editor content to blocks on-the-fly. After installing Gutenberg or upgrading to WordPress 5.0+, your content will be displayed in "Classic Editor Blocks". While these blocks are completely functional and will display fine on the frontend of your website, they do not empower editors to fully make use of the block editing experience. In order to do so, your classic editor posts need to be converted to blocks. This plugin does that for you "on the fly". When an editor goes to edit a classic post, the content will be parsed into blocks. When the editor saves the post, the new structure will be saved into the database. This strategy reduces risk as you are only altering database values for content that needs to be changed.

When combined with the [Block Catalog Plugin](https://github.com/10up-block-catalog/block-catalog), Convert to Blocks can be used to bulk convert only classic editor content to blocks. This is especially useful for sites with a combination of classic and block editor content.

### Bulk migration of Classic Editor items to the Block Editor

The `wp convert-to-blocks start` [WP-CLI command](https://github.com/10up/convert-to-blocks/blob/4df0e970c51eee8d84e3edf3c6210dc10011d574/includes/ConvertToBlocks/MigrationCommand.php) that converts posts iteratively in the browser without requiring any manual input. One caveat worth mentioning is that Gutenberg is a CPU intensive application. You will want to keep your computer plugged in before doing this!
The `wp convert-to-blocks start` [WP-CLI command](https://github.com/10up/convert-to-blocks/blob/4df0e970c51eee8d84e3edf3c6210dc10011d574/includes/ConvertToBlocks/MigrationCommand.php) that converts posts iteratively in the browser without requiring any manual input. One caveat worth mentioning is that Gutenberg is a CPU intensive application. You will want to keep your computer plugged in before doing this!

![Demo of WP-CLI command](.wordpress-org/screenshot-1.gif "Example of a convert-to-blocks WP-CLI command bulk migration")

## Requirements

- PHP 8+
- WordPress 6.1+
- Inner Blocks Transforms is only supported with the Gutenberg Plugin 10.9.0+

## Installation
Expand All @@ -28,6 +28,60 @@ The `wp convert-to-blocks start` [WP-CLI command](https://github.com/10up/conver
2. Inside the repository directory, run `npm install` and then `npm run build`.
3. Inside the repository directory, run `composer install`.

## Command Line Options

```bash
NAME

wp convert-to-blocks start

DESCRIPTION

Starts a new Migration. The command prints the URL that must be opened in a browser to connect it to the WP CLI.

SYNOPSIS

wp convert-to-blocks start [--post_type=<post_type>] [--per_page=<per_page>] [--page=<page>] [--only=<only>] [--catalog] [--reset]

OPTIONS

[--post_type=<post_type>]
Optional comma delimited list of post types to migrate. Defaults to post,page

[--per_page=<per_page>]
Optional number of posts to migrate per batch. Defaults to no limit. Combine with --page to paginate.

[--page=<page>]
Optional page number to start migration from. Defaults to 1.

[--only=<only>]
Optional comma delimited list of post ids to migrate.

[--catalog]
Optional flag to only migrate classic editor tagged posts. Requires that Block
Catalog plugin is present and has been indexed.

[--reset]
Stops any currently running migration and resets the migration state.

NAME

wp convert-to-blocks stop

DESCRIPTION

Stops the currently running migration if active.

NAME

wp convert-to-blocks status

DESCRIPTION

Prints the status of the currently running migration.

```
## Frequently Asked Questions
### How Do I Know It's Working?
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "10up/convert-to-blocks",
"description": "Convert classic editor posts to blocks on the fly.",
"type": "wordpress-plugin",
"license": "GPLv2 or later",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "10up",
Expand Down
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package convert-to-blocks
*/

$plugin_version = '1.2.2';
$plugin_version = '1.3.0';

if ( file_exists( __DIR__ . '/.commit' ) ) {
// phpcs:disable
Expand Down
8 changes: 4 additions & 4 deletions convert-to-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* Plugin Name: Convert to Blocks
* Plugin URI: https://github.com/10up/convert-to-blocks
* Description: Convert classic editor posts to blocks on the fly.
* Version: 1.2.2
* Requires at least: 6.1
* Version: 1.3.0
* Requires at least: 6.3
* Requires PHP: 8.0
* Author: 10up
* Author URI: https://10up.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* License: GPL-2.0-or-later
* License URI: https://spdx.org/licenses/GPL-2.0-or-later.html
* Text Domain: convert-to-blocks
*
* @package convert-to-blocks
Expand Down
22 changes: 21 additions & 1 deletion includes/ConvertToBlocks/MigrationAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,28 @@ public function get_posts_to_update( $opts = [] ) {
$post_type = [ 'post', 'page' ];
}

$posts_per_page = $opts['per_page'] ?? -1;
$page = $opts['page'] ?? 1;

$query_params = [
'post_type' => $post_type,
'post_status' => 'publish',
'fields' => 'ids',
'posts_per_page' => -1,
'posts_per_page' => $posts_per_page,
'paged' => $page,
'ignore_sticky_posts' => true,
];

if ( ! empty( $opts['catalog'] ) ) {
$query_params['tax_query'] = [
[
'taxonomy' => BLOCK_CATALOG_TAXONOMY,
'field' => 'slug',
'terms' => [ 'core-classic' ],
],
];
}

/**
* Filter query parameters for the query to get the posts to be updated.
*
Expand All @@ -209,6 +223,12 @@ public function get_posts_to_update( $opts = [] ) {
$query = new \WP_Query( $query_params );
$posts = $query->posts;

if ( ! empty( $posts ) && defined( '\WP_CLI' ) && \WP_CLI ) {
$posts_per_page = $posts_per_page > 0 ? $posts_per_page : $query->found_posts;
$pages = ceil( $query->found_posts / $posts_per_page );
\WP_CLI::line( sprintf( 'Pagination: %d/%d of %d', $page, $pages, $query->found_posts ) );
}

return $posts;
}

Expand Down
Loading

0 comments on commit 2b9a347

Please sign in to comment.