Full Site Editing - Version 2.0

Version Description

  • Rename directories from "full-site-editing*" to "editing-toolkit*" (https://github.com/Automattic/wp-calypso/pull/44501)
  • Update/premium content loading assets code cleanup (https://github.com/Automattic/wp-calypso/pull/45052)
  • FSE: Add Newspack assets unit tests (https://github.com/Automattic/wp-calypso/pull/43218)
Download this release

Release Info

Developer Copons
Plugin Icon wp plugin Full Site Editing
Version 2.0
Comparing to
See all releases

Code changes from version 1.22 to 2.0

block-inserter-modifications/index.php CHANGED
@@ -23,7 +23,7 @@ function enqueue_script( $filename, $in_footer = false ) {
23
  if ( ! file_exists( $asset_path ) ) {
24
  throw new RuntimeException(
25
  'Asset file not found: ' . $asset_path . '. ' .
26
- 'Please see https://github.com/Automattic/wp-calypso/blob/HEAD/apps/full-site-editing/README.md#build-system ' .
27
  'for more information about the Full Site Editing build system.'
28
  );
29
  }
23
  if ( ! file_exists( $asset_path ) ) {
24
  throw new RuntimeException(
25
  'Asset file not found: ' . $asset_path . '. ' .
26
+ 'Please see https://github.com/Automattic/wp-calypso/blob/HEAD/apps/editing-toolkit/README.md#build-system ' .
27
  'for more information about the Full Site Editing build system.'
28
  );
29
  }
full-site-editing-plugin.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: WordPress.com Editing Toolkit
4
  * Description: Enhances your page creation workflow within the Block Editor.
5
- * Version: 1.22
6
  * Author: Automattic
7
  * Author URI: https://automattic.com/wordpress-plugins/
8
  * License: GPLv2 or later
@@ -35,7 +35,7 @@ namespace A8C\FSE;
35
  *
36
  * @var string
37
  */
38
- define( 'PLUGIN_VERSION', '1.22' );
39
 
40
  // Always include these helper files for dotcom FSE.
41
  require_once __DIR__ . '/dotcom-fse/helpers.php';
@@ -181,7 +181,7 @@ function enqueue_coblocks_gallery_scripts() {
181
  // This happens in the Customizer because we try very hard not to load things and we get a fatal
182
  // https://github.com/Automattic/wp-calypso/issues/36680.
183
  if ( ! class_exists( '\A8C\FSE\WP_Template' ) ) {
184
- require_once __DIR__ . '/full-site-editing/templates/class-wp-template.php';
185
  }
186
  $template = new WP_Template();
187
  $header = $template->get_template_content( 'header' );
2
  /**
3
  * Plugin Name: WordPress.com Editing Toolkit
4
  * Description: Enhances your page creation workflow within the Block Editor.
5
+ * Version: 2.0
6
  * Author: Automattic
7
  * Author URI: https://automattic.com/wordpress-plugins/
8
  * License: GPLv2 or later
35
  *
36
  * @var string
37
  */
38
+ define( 'PLUGIN_VERSION', '2.0' );
39
 
40
  // Always include these helper files for dotcom FSE.
41
  require_once __DIR__ . '/dotcom-fse/helpers.php';
181
  // This happens in the Customizer because we try very hard not to load things and we get a fatal
182
  // https://github.com/Automattic/wp-calypso/issues/36680.
183
  if ( ! class_exists( '\A8C\FSE\WP_Template' ) ) {
184
+ require_once __DIR__ . '/dotcom-fse/templates/class-wp-template.php';
185
  }
186
  $template = new WP_Template();
187
  $header = $template->get_template_content( 'header' );
global-styles/README.md CHANGED
@@ -4,22 +4,22 @@ This plugin creates a new sidebar for the block editor through which the users c
4
 
5
  - [How to develop and build the plugin](#how-to-develop-and-build-the-plugin)
6
  - [How it works and how themes can use it](#how-it-works-and-how-themes-can-use-it)
7
- - [Fallbacks for browsers without support for CSS custom properties](#fallbacks-for-browsers-without-support-for-css-custom-properties)
8
- - [How to add a "Theme Default" option to the font list](#how-to-add-a-theme-default-option-to-the-font-list)
9
- - [How to use a fallback stylesheet (experimental)](#how-to-use-a-fallback-stylesheet-experimental)
10
  - [Existing hooks](#existing-hooks)
11
- - [jetpack_global_styles_data_set_get_data filter](#jetpack_global_styles_data_set_get_data-filter)
12
- - [jetpack_global_styles_data_set_save_data filter](#jetpack_global_styles_data_set_save_data-filter)
13
- - [jetpack_global_styles_permission_check_additional filter](#jetpack_global_styles_permission_check_additional-filter)
14
- - [jetpack_global_styles_settings](#jetpack_global_styles_settings)
15
  - [FAQ](#faq)
16
- - [Which fonts are available?](#which-fonts-are-available)
17
- - [What will happen when the user changes to another theme that supports GlobalStyles?](#what-will-happen-when-the-user-changes-to-another-theme-that-supports-globalstyles)
18
- - [What will happen when the user changes to a theme that doesn't support Global Styles or the plugin is deactivated?](#what-will-happen-when-the-user-changes-to-a-theme-that-doesnt-support-global-styles-or-the-plugin-is-deactivated)
19
 
20
  ## How to develop and build the plugin
21
 
22
- Refer to instructions in the top-level [Full Site Editing](https://github.com/automattic/wp-calypso/tree/HEAD/apps/full-site-editing) directory.
23
 
24
  ## How it works and how themes can use it
25
 
@@ -88,7 +88,10 @@ body {
88
 
89
  h1 {
90
  font-family: sans-serif; // Fallback for browsers without support.
91
- font-family: var( --font-headings, sans-serif ); // Variable and fallback for browsers with support.
 
 
 
92
  }
93
  ```
94
 
4
 
5
  - [How to develop and build the plugin](#how-to-develop-and-build-the-plugin)
6
  - [How it works and how themes can use it](#how-it-works-and-how-themes-can-use-it)
7
+ * [Fallbacks for browsers without support for CSS custom properties](#fallbacks-for-browsers-without-support-for-css-custom-properties)
8
+ * [How to add a "Theme Default" option to the font list](#how-to-add-a-theme-default-option-to-the-font-list)
9
+ * [How to use a fallback stylesheet (experimental)](#how-to-use-a-fallback-stylesheet-experimental)
10
  - [Existing hooks](#existing-hooks)
11
+ * [jetpack_global_styles_data_set_get_data filter](#jetpack_global_styles_data_set_get_data-filter)
12
+ * [jetpack_global_styles_data_set_save_data filter](#jetpack_global_styles_data_set_save_data-filter)
13
+ * [jetpack_global_styles_permission_check_additional filter](#jetpack_global_styles_permission_check_additional-filter)
14
+ * [jetpack_global_styles_settings](#jetpack_global_styles_settings)
15
  - [FAQ](#faq)
16
+ * [Which fonts are available?](#which-fonts-are-available)
17
+ * [What will happen when the user changes to another theme that supports GlobalStyles?](#what-will-happen-when-the-user-changes-to-another-theme-that-supports-globalstyles)
18
+ * [What will happen when the user changes to a theme that doesn't support Global Styles or the plugin is deactivated?](#what-will-happen-when-the-user-changes-to-a-theme-that-doesnt-support-global-styles-or-the-plugin-is-deactivated)
19
 
20
  ## How to develop and build the plugin
21
 
22
+ Refer to instructions in the top-level [Editing Toolkit](https://github.com/automattic/wp-calypso/tree/HEAD/apps/editing-toolkit) directory.
23
 
24
  ## How it works and how themes can use it
25
 
88
 
89
  h1 {
90
  font-family: sans-serif; // Fallback for browsers without support.
91
+ font-family: var(
92
+ --font-headings,
93
+ sans-serif
94
+ ); // Variable and fallback for browsers with support.
95
  }
96
  ```
97
 
newspack-blocks/README.md CHANGED
@@ -33,7 +33,7 @@ You can see that `synced-newspack-blocks` is being synced with the Newspack Bloc
33
 
34
  Once your changes land on the Newspack side, coordinate with the team (over issues/PRs) to [make a new release](https://github.com/Automattic/newspack-blocks/releases) and once you have the release ID, you can pull the code into here.
35
 
36
- While being in `apps/full-site-editing/` directory, you can run:
37
 
38
  ```
39
  yarn run sync:newspack-blocks --release=1.0.0-alpha.17
33
 
34
  Once your changes land on the Newspack side, coordinate with the team (over issues/PRs) to [make a new release](https://github.com/Automattic/newspack-blocks/releases) and once you have the release ID, you can pull the code into here.
35
 
36
+ While being in `apps/editing-toolkit/` directory, you can run:
37
 
38
  ```
39
  yarn run sync:newspack-blocks --release=1.0.0-alpha.17
newspack-blocks/index.php CHANGED
@@ -10,7 +10,7 @@ namespace A8C\FSE;
10
  define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
11
  define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
12
 
13
- // Autogenerated by apps/full-site-editing/bin/sync-newspack-blocks.sh.
14
  define( 'NEWSPACK_BLOCKS__VERSION', 'v1.7.0' );
15
  // End autogenerated area.
16
 
10
  define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
11
  define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
12
 
13
+ // Autogenerated by apps/editing-toolkit/bin/sync-newspack-blocks.sh.
14
  define( 'NEWSPACK_BLOCKS__VERSION', 'v1.7.0' );
15
  // End autogenerated area.
16
 
phpunit/bootstrap.php CHANGED
@@ -12,7 +12,6 @@ require_once dirname( dirname( __FILE__ ) ) . '/vendor/autoload.php';
12
 
13
  $_tests_dir = getenv( 'WP_PHPUNIT__DIR' );
14
 
15
-
16
  if ( ! $_tests_dir ) {
17
  throw new Exception( 'Could not find the WordPress test lib.' );
18
  }
@@ -27,7 +26,7 @@ function _manually_load_plugin() {
27
  update_option(
28
  'active_plugins',
29
  array(
30
- 'full-site-editing-plugin/full-site-editing-plugin.php',
31
  )
32
  );
33
  }
@@ -59,3 +58,6 @@ require $_tests_dir . '/includes/bootstrap.php';
59
 
60
  // Use existing behavior for wp_die during actual test execution.
61
  remove_filter( 'wp_die_handler', 'fail_if_died' );
 
 
 
12
 
13
  $_tests_dir = getenv( 'WP_PHPUNIT__DIR' );
14
 
 
15
  if ( ! $_tests_dir ) {
16
  throw new Exception( 'Could not find the WordPress test lib.' );
17
  }
26
  update_option(
27
  'active_plugins',
28
  array(
29
+ 'editing-toolkit-plugin/full-site-editing-plugin.php',
30
  )
31
  );
32
  }
58
 
59
  // Use existing behavior for wp_die during actual test execution.
60
  remove_filter( 'wp_die_handler', 'fail_if_died' );
61
+
62
+ // Don't let deprecation notices cause tests to fail.
63
+ PHPUnit\Framework\Error\Deprecated::$enabled = false;
phpunit/class-newspack-test.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Newspack Tests file.
4
+ *
5
+ * @package full-site-editing-plugin
6
+ */
7
+
8
+ namespace A8C\FSE;
9
+
10
+ use PHPUnit\Framework\TestCase;
11
+
12
+ /**
13
+ * Class NewsPack_Test.
14
+ */
15
+ class NewsPack_Test extends TestCase {
16
+
17
+ /**
18
+ * Tests that required block assets are enqueued.
19
+ */
20
+ public function test_carousel_assets_enqueued() {
21
+ ob_start();
22
+ newspack_blocks_render_block_carousel(
23
+ array(
24
+ 'postsToShow' => 3,
25
+ )
26
+ );
27
+ ob_end_flush();
28
+
29
+ $this->assertTrue( wp_script_is( 'carousel-block-view' ) );
30
+ $this->assertTrue( wp_style_is( 'carousel-block-view' ) );
31
+ }
32
+
33
+ /**
34
+ * Tests that required block assets are enqueued.
35
+ */
36
+ public function test_blog_posts_assets_enqueued() {
37
+ ob_start();
38
+ newspack_blocks_render_block_homepage_articles(
39
+ array(
40
+ 'customTextColor' => '',
41
+ 'postsToShow' => 3,
42
+ 'showCaption' => false,
43
+ 'showCategory' => false,
44
+ 'showImage' => false,
45
+ 'specificMode' => 0,
46
+ 'textColor' => '',
47
+ )
48
+ );
49
+ ob_end_flush();
50
+
51
+ $this->assertTrue( wp_script_is( 'blog-posts-block-view' ) );
52
+ $this->assertTrue( wp_style_is( 'blog-posts-block-view' ) );
53
+ }
54
+ }
premium-content/premium-content.php CHANGED
@@ -31,14 +31,29 @@ define( 'PREMIUM_CONTENT__PLUGIN_DIR', __DIR__ );
31
  /**
32
  * Register blocks and load block translations. If not done on init, the render
33
  * callbacks of the dynamic blocks won't be executed in the front-end.
 
34
  *
35
  * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/
36
  * @see https://github.com/Automattic/wp-calypso/pull/44825
 
37
  * @return void
38
  */
39
  function premium_content_block_init() {
40
  register_blocks();
41
  load_translations();
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
 
44
  /**
@@ -48,14 +63,11 @@ function premium_content_block_init() {
48
  * @return void
49
  */
50
  function premium_content_block_enqueue_block_editor_assets() {
51
- $script_asset = get_script_asset();
52
-
53
- $index_js = 'dist/premium-content.js';
54
  wp_register_script(
55
  'premium-content-editor',
56
- PREMIUM_CONTENT__URL_PATH . '/' . $index_js,
57
- $script_asset['dependencies'],
58
- $script_asset['version'],
59
  false
60
  );
61
 
@@ -76,7 +88,13 @@ function premium_content_block_enqueue_block_editor_assets() {
76
  * @return void
77
  */
78
  function premium_content_block_enqueue_block_assets() {
79
- $script_asset = get_script_asset();
 
 
 
 
 
 
80
 
81
  $style_css = 'style.css';
82
  wp_register_style(
@@ -85,38 +103,8 @@ function premium_content_block_enqueue_block_assets() {
85
  array(),
86
  filemtime( PREMIUM_CONTENT__PLUGIN_DIR . '/' . $style_css )
87
  );
88
-
89
- wp_register_script(
90
- 'premium-content-frontend',
91
- PREMIUM_CONTENT__URL_PATH . '/view.js',
92
- array(),
93
- $script_asset['version'],
94
- false
95
- );
96
-
97
- }
98
-
99
-
100
- /**
101
- * Helper; Get the 'script_asset'
102
- * Used by enqueue_block_assets and enqueue_block_editor_assets
103
- *
104
- * @throws RuntimeException If block assets files are not found.
105
- * @return mixed
106
- */
107
- function get_script_asset() {
108
- $dir = PREMIUM_CONTENT__PLUGIN_DIR;
109
- $script_asset_path = "$dir/dist/premium-content.asset.php";
110
- if ( ! file_exists( $script_asset_path ) ) {
111
- throw new RuntimeException(
112
- 'You need to run `npm start` or `npm run build` for the "create-block/premium-content" block first.'
113
- );
114
- }
115
- $script_asset = include $script_asset_path;
116
- return $script_asset;
117
  }
118
 
119
-
120
  /**
121
  * Load block translation.
122
  */
@@ -428,10 +416,9 @@ function premium_content_default_service( $service ) {
428
  return new Unconfigured_Subscription_Service();
429
  }
430
 
431
- add_action( 'init', 'A8C\FSE\Earn\PremiumContent\premium_content_paywall_initialize', 9 );
432
-
433
  add_action( 'init', 'A8C\FSE\Earn\PremiumContent\premium_content_block_init' );
434
  add_action( 'enqueue_block_editor_assets', 'A8C\FSE\Earn\PremiumContent\premium_content_block_enqueue_block_editor_assets' );
435
  add_action( 'enqueue_block_assets', 'A8C\FSE\Earn\PremiumContent\premium_content_block_enqueue_block_assets' );
436
 
 
437
  add_filter( PAYWALL_FILTER, 'A8C\FSE\Earn\PremiumContent\premium_content_default_service' );
31
  /**
32
  * Register blocks and load block translations. If not done on init, the render
33
  * callbacks of the dynamic blocks won't be executed in the front-end.
34
+ * Defines asset $dependencies and $version
35
  *
36
  * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/
37
  * @see https://github.com/Automattic/wp-calypso/pull/44825
38
+ * @throws RuntimeException If block assets files are not found.
39
  * @return void
40
  */
41
  function premium_content_block_init() {
42
  register_blocks();
43
  load_translations();
44
+
45
+ $asset_path = PREMIUM_CONTENT__PLUGIN_DIR . '/dist/premium-content.asset.php';
46
+ if ( ! file_exists( $asset_path ) ) {
47
+ throw new RuntimeException(
48
+ 'You need to run `npm start` or `npm run build` for the "create-block/premium-content" block first.'
49
+ );
50
+ }
51
+ $asset = include $asset_path;
52
+ $dependencies = isset( $asset['dependencies'] ) ? $asset['dependencies'] : array();
53
+ $version = isset( $asset['version'] ) ? $asset['version'] : filemtime( $asset_path );
54
+
55
+ define( 'PREMIUM_CONTENT__ASSET_DEPENDENCIES', $dependencies );
56
+ define( 'PREMIUM_CONTENT__ASSET_VERSION', $version );
57
  }
58
 
59
  /**
63
  * @return void
64
  */
65
  function premium_content_block_enqueue_block_editor_assets() {
 
 
 
66
  wp_register_script(
67
  'premium-content-editor',
68
+ PREMIUM_CONTENT__URL_PATH . '/dist/premium-content.js',
69
+ PREMIUM_CONTENT__ASSET_DEPENDENCIES,
70
+ PREMIUM_CONTENT__ASSET_VERSION,
71
  false
72
  );
73
 
88
  * @return void
89
  */
90
  function premium_content_block_enqueue_block_assets() {
91
+ wp_register_script(
92
+ 'premium-content-frontend',
93
+ PREMIUM_CONTENT__URL_PATH . '/view.js',
94
+ array(),
95
+ PREMIUM_CONTENT__ASSET_VERSION,
96
+ false
97
+ );
98
 
99
  $style_css = 'style.css';
100
  wp_register_style(
103
  array(),
104
  filemtime( PREMIUM_CONTENT__PLUGIN_DIR . '/' . $style_css )
105
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
 
 
108
  /**
109
  * Load block translation.
110
  */
416
  return new Unconfigured_Subscription_Service();
417
  }
418
 
 
 
419
  add_action( 'init', 'A8C\FSE\Earn\PremiumContent\premium_content_block_init' );
420
  add_action( 'enqueue_block_editor_assets', 'A8C\FSE\Earn\PremiumContent\premium_content_block_enqueue_block_editor_assets' );
421
  add_action( 'enqueue_block_assets', 'A8C\FSE\Earn\PremiumContent\premium_content_block_enqueue_block_assets' );
422
 
423
+ add_action( 'init', 'A8C\FSE\Earn\PremiumContent\premium_content_paywall_initialize', 9 );
424
  add_filter( PAYWALL_FILTER, 'A8C\FSE\Earn\PremiumContent\premium_content_default_service' );
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: alexislloyd, allancole, automattic, bartkalisz, codebykat, copons,
3
  Tags: block, blocks, editor, gutenberg, page
4
  Requires at least: 5.0
5
  Tested up to: 5.4
6
- Stable tag: 1.22
7
  Requires PHP: 5.6.20
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -40,6 +40,11 @@ This plugin is experimental, so we don't provide any support for it outside of w
40
 
41
  == Changelog ==
42
 
 
 
 
 
 
43
  = 1.22 =
44
  * Premium Content: load assets using proper hook (https://github.com/Automattic/wp-calypso/pull/44825)
45
  * EditingToolkit > GlobalStyles: Add new Google fonts (https://github.com/Automattic/wp-calypso/pull/44750)
3
  Tags: block, blocks, editor, gutenberg, page
4
  Requires at least: 5.0
5
  Tested up to: 5.4
6
+ Stable tag: 2.0
7
  Requires PHP: 5.6.20
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
40
 
41
  == Changelog ==
42
 
43
+ = 2.0 =
44
+ * Rename directories from "full-site-editing*" to "editing-toolkit*" (https://github.com/Automattic/wp-calypso/pull/44501)
45
+ * Update/premium content loading assets code cleanup (https://github.com/Automattic/wp-calypso/pull/45052)
46
+ * FSE: Add Newspack assets unit tests (https://github.com/Automattic/wp-calypso/pull/43218)
47
+
48
  = 1.22 =
49
  * Premium Content: load assets using proper hook (https://github.com/Automattic/wp-calypso/pull/44825)
50
  * EditingToolkit > GlobalStyles: Add new Google fonts (https://github.com/Automattic/wp-calypso/pull/44750)