Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

A real v1 #1

Merged
merged 58 commits into from
Feb 23, 2023
Merged

A real v1 #1

merged 58 commits into from
Feb 23, 2023

Conversation

braican
Copy link
Member

@braican braican commented Jan 23, 2023

This PR refactors and updates the ups-editorial plugin (previously, ups-blocks) to account for recent core updates and best practices. It also removes dependencies on any WordPress theme (most notably the WP Starter Kit) so as to fully function like a standalone plugin.

The changes introduced in this plugin correlate to many changes introduced to the WP Starter Kit in that repo's v2.

This plugin offers the following features:

  • Extends a number of blocks, primarily to limit the block's customization options available to editors. These blocks include the Cover, File, Gallery, Image Layout, Related Articles, Table, and Video blocks.
  • Adds two editor plugins that create new panels in the Gutenberg sidebar:
    • The Article Topper Panel allows an editor to control article topper metadata.
    • The Bylines Panel improves an editor's ability to manage a post's authors by offering an interface to add multiple ordered authors, driven by a custom ups_author taxonomy registered by the plugin.
  • Exposes template functions that can be used to access data registered by the plugin.
  • Allows plugin functionality to be configured (including the ability to enable and disable specific features) via a config file that can be added to the root of the active theme directory. This file should have the filename ups-editorial.php and simply return an array of relevant configuration values (see the README in this branch for documentation on the specific configuration values).

Changes from the previous version

  • Refactors the plugin's structure and namespacing, including a more organized approach to the features defined in PHP vs. those defined in JS.

  • Removes the custom ups/image block. As WordPress continued to improve their editor experience and update their core blocks, the customizations intended by the ups/image block became antiquated as core image block functionality became more configurable.

    I could see a world where the updates intended by this custom block are useful, but I'd like for any functionality introduced by a future potential ups/image block to be very intentional and backed by established requirements.

  • Simplifies how JavaScript and stylesheets are built and loaded. Previously, there were a number of disparate JavaScript files and scss partials floating around, hooked into a custom webpack config file. This update removes the custom webpack config by routing all JavaScript functionality through a singular src/index.js file, which is how the wp-scripts package expects the code to be organized.

How to test

  1. Download the code in the v2 branch of this repo and add it to an existing WordPress installation. (The plugin should work for any WordPress installation running the latest version of the Gutenberg editor, but the v2 branch of Upstatement's WP Starter Kit is a good blank slate to test against.)

  2. In the plugin's directory, run npm install to install dev dependencies, then run npm run build to compile the production assets. You'll also need to run composer install to generate the autoloader (this will also install some dev dependencies like linters). Note that the intention is for this plugin to be pulled into a WordPress environment via composer, so release versions of this package will be shipped with compiled assets and any relevant dependencies all ready to go. This configuration is happening in a separate PR - this one is primarily about the specific functionality of the plugin.

  3. Activate the plugin.

  4. If your theme has a ups-editorial.php config file, delete it. This will ensure that all plugin functionality is active.

  5. Confirm that an Authors taxonomy exists for your posts. Confirm that the bylines functionality works as expected (it should continue to work as it did before):

    • You should be able to add author taxonomy terms via the taxonomy's regular admin page (/wp-admin/edit-tags.php?taxonomy=ups_authors)
    • You should be able to search for and select individual author terms in the Authors panel when editing a post. You should also be able to reorder and delete the author terms added via this panel.
    • You should be able to update the authors via the quick edit menu on the main posts admin screen.
  6. Confirm that the Article Topper panel in the editor works as expected. You should be able to add topper content and switch between the different article topper variations.

  7. Confirm that the Cover, File, Gallery, Image Layout, Related Articles, Table, and Video blocks all work as expected and have the expected customizations (they should continue to work in the same way as before). Note that the Image Layout and Related Articles blocks are not core blocks and need to be defined in your theme - these are defined in the WP Starter Kit. Future work on this plugin may include a better way to handle these non-core blocks.

  8. Confirm that the template methods work in your theme. See the Theme API section of the README for this branch for documentation on which template methods are available.

@braican braican changed the title V2 v2 Jan 30, 2023
@braican braican requested review from ALJ and bchiang7 January 31, 2023 00:02
@braican braican marked this pull request as ready for review January 31, 2023 00:02
@bchiang7
Copy link

bchiang7 commented Jan 31, 2023

Nice work! Hit a few snags while testing...

Added the plugin to the v2 branch of WSK, but getting this error on npm run build

error log
➜ npm run build
Found existing alias for "npm run build". You should use: "build"

> @upstatement/ups-editorial-wp-plugin@2.0.0 build
> wp-scripts build

[webpack-cli] HookWebpackError: Not supported
    at makeWebpackError (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/HookWebpackError.js:48:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3060:12
    at eval (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:48:1)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:510:26
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/copy-webpack-plugin/dist/index.js:708:13
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
-- inner error --
Error: Not supported
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/copy-webpack-plugin/dist/index.js:704:13
    at fn (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:509:9)
    at Hook.eval [as callAsync] (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:46:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/Hook.js:18:14)
    at cont (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3057:34)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3105:10
    at symbolIterator (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3485:9)
    at done (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3527:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2830:7
    at done (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2865:11)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2818:7
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:4657:18
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/HookWebpackError.js:68:3
    at Hook.eval [as callAsync] (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at Cache.store (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:107:20)
    at ItemCacheFacade.store (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/CacheFacade.js:137:15)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:4654:25
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:93:5
    at Hook.eval [as callAsync] (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at Cache.get (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:75:18)
    at ItemCacheFacade.get (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/CacheFacade.js:111:15)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:4563:22
    at arrayEach (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2405:9)
    at Object.each (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2846:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:4552:14
    at symbolIterator (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3482:9)
    at timesSync (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2297:7)
    at Object.eachLimit (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3463:5)
    at Compilation.createChunkAssets (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:4529:12)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3100:14
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3280:6
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2818:7
    at done (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3522:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3243:8
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3352:32
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/HookWebpackError.js:68:3
    at Hook.eval [as callAsync] (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at Cache.store (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:107:20)
    at ItemCacheFacade.store (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/CacheFacade.js:137:15)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3352:11
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:93:5
    at Hook.eval [as callAsync] (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at Cache.get (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:75:18)
    at ItemCacheFacade.get (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/CacheFacade.js:111:15)
    at Compilation._codeGenerationModule (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3322:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3229:11
    at arrayIterator (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3467:9)
    at done (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3527:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3243:8
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3352:32
caused by plugins in Compilation.hooks.processAssets
Error: Not supported
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/copy-webpack-plugin/dist/index.js:704:13
    at fn (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:509:9)
    at Hook.eval [as callAsync] (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:46:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/Hook.js:18:14)
    at cont (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3057:34)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3105:10
    at symbolIterator (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3485:9)
    at done (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3527:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2830:7
    at done (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2865:11)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2818:7
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:4657:18
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/HookWebpackError.js:68:3
    at Hook.eval [as callAsync] (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at Cache.store (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:107:20)
    at ItemCacheFacade.store (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/CacheFacade.js:137:15)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:4654:25
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:93:5
    at Hook.eval [as callAsync] (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at Cache.get (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:75:18)
    at ItemCacheFacade.get (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/CacheFacade.js:111:15)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:4563:22
    at arrayEach (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2405:9)
    at Object.each (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2846:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:4552:14
    at symbolIterator (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3482:9)
    at timesSync (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2297:7)
    at Object.eachLimit (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3463:5)
    at Compilation.createChunkAssets (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:4529:12)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3100:14
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3280:6
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:2818:7
    at done (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3522:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3243:8
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3352:32
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/HookWebpackError.js:68:3
    at Hook.eval [as callAsync] (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at Cache.store (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:107:20)
    at ItemCacheFacade.store (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/CacheFacade.js:137:15)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3352:11
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:93:5
    at Hook.eval [as callAsync] (eval at create (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at Cache.get (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Cache.js:75:18)
    at ItemCacheFacade.get (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/CacheFacade.js:111:15)
    at Compilation._codeGenerationModule (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3322:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3229:11
    at arrayIterator (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3467:9)
    at done (/Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/neo-async/async.js:3527:9)
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3243:8
    at /Users/brittanychiang/Documents/work/editorial-starter-wp-theme/plugins/ups-editorial-wp-plugin/node_modules/webpack/lib/Compilation.js:3352:32

@bchiang7
Copy link

bchiang7 commented Jan 31, 2023

Should we update the node version in the .nvmrc to match WSK? v18.13.0?

Update: npm run build is working for me using node v18.13.0

@bchiang7
Copy link

Noticed the docker config in the plugin — do you think it's really necessary for testing? I think it might be overkill especially if we usually just copy paste the whole repo into a WP project's plugins directory. npm link might be sufficient for local dev

Copy link

@bchiang7 bchiang7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link

@ALJ ALJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! Everything works as advertised! Take a look at my comment/question about configuration standards, in case that sparks any ideas for you! 🙇

* @return void
*/
public static function register() {
Config::read();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered other ways of defining configuration for the connection between plugin and theme? I ask because WordPress has the add_theme_support and get_theme_support functions to somewhat standardize the activation of feature flags.

For example, I can imagine a system where WSK does something like:

add_theme_support( 'ups-editorial-author-panel' );

And, Ups Editorial Plugin reads that with:

if ( get_theme_support( 'ups-editorial-author-panel' ) ) {
	Taxonomy\Author::register();
}

The advantage is it keeps the "standard WP way" that might feel more friendly to others. The potential disadvantage is it introduces WP's weirdness, like it might run afoul of WP hook sequence firing; I haven't tested this in depth to know the extent of the potential problems.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to consider alternative ways to implement config but I also want to see how this is used and get a sense from other devs how they would like to manage feature flagging. As for my thinking behind the config files...

Ideally themes would individually remove features rather than need to add them, so I'm not sure that the add_theme_support() paradigm would work. We may be able to invert this and have themes use disable_theme_support(), but we'd have to look into that a bit.

A similar pattern I did consider was using hooks to handle feature support:

Theme code

add_filter( 'ups_editorial_author_panel', '__return_false' );

Plugin

if ( apply_filters( 'ups_editorial_author_panel', true ) ) {
    Taxonomy\Author::register();
}

Ultimately while that is the pattern I see most commonly around enabling/disabling plugin features and is effectively the standard way that WordPress handles this type of thing, I don't love that method: it requires namespaced filter names, which can get cumbersome; I'm never confident on the best place for this code to get added to a theme; and it just isn't that clear as to what it's doing (it took me years to understand that the __return_false callback is a global function in core).

I like the simplicity of a singular config file that is scoped to a specific application that defines settings for that application - it's one of the ideas that I pulled over from how Craft CMS handles things. While it's not necessarily a standard WordPress pattern, it's simple enough to be understood by theme developers and robust enough where we can continue adding to it easily without having to create a bunch of individual filters for the plugin.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the simplicity of a singular config file that is scoped to a specific application that defines settings for that application

That sounds good enough for me! It was helpful to hear your thinking around it, and that you did consider some other WP-native ways, too.

@braican braican merged commit d96319d into main Feb 23, 2023
@braican braican deleted the v2 branch February 23, 2023 01:35
@braican braican changed the title v2 A real v1 Feb 23, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants