Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f757cc1
Pretty much a full reset
braican Jan 17, 2023
b92523c
Rename
braican Jan 17, 2023
c00028a
Improve readme
braican Jan 19, 2023
87cd830
Local dev
braican Jan 19, 2023
e08559a
Start building
braican Jan 19, 2023
112dc15
More deps
braican Jan 19, 2023
200c0b6
Prevent unnecessary rules
braican Jan 19, 2023
314ea33
Pull over author taxonomy
braican Jan 19, 2023
28a3dc3
Set up config
braican Jan 20, 2023
fa6a434
Some docs
braican Jan 20, 2023
2b37b45
Better way to hide default author panel
braican Jan 23, 2023
1da5ce9
Cleanup
braican Jan 23, 2023
971df4e
Docs, cleanup
braican Jan 23, 2023
f280b49
Article topper
braican Jan 24, 2023
0835b71
Readme
braican Jan 24, 2023
2df34a9
More docs
braican Jan 24, 2023
967aef5
Attachment credits
braican Jan 24, 2023
1d7ebab
Pull in the block stuff
braican Jan 26, 2023
0736215
Remove button in favor of theme.json
braican Jan 27, 2023
cbe34c1
Little refactor for config
braican Jan 30, 2023
65248d2
Some readme
braican Jan 30, 2023
e2be0ab
More docs
braican Jan 30, 2023
d18da8e
Node version
braican Jan 31, 2023
ff4978e
Remove docker stuff
braican Jan 31, 2023
766ea9d
Account for missing options
braican Feb 2, 2023
af1cf44
Wholesale rename the bylines panel
braican Feb 2, 2023
e204cb9
Use the right indexof
braican Feb 2, 2023
c9fb7ae
Update a few styles
braican Feb 3, 2023
e7ef32f
Remove style picker from core/image block
Feb 15, 2023
0e4fc39
Remove style picker from core/button block
Feb 15, 2023
f2b2f5e
Revert "Remove style picker from core/button block"
Feb 15, 2023
0533098
Fix keys
braican Feb 15, 2023
6c080d9
Fix sass division
braican Feb 15, 2023
300af21
Update per packagist recs
braican Feb 16, 2023
679bbe1
Ignore on zip downloads
braican Feb 17, 2023
e8571bc
Test building assets
braican Feb 17, 2023
a356508
Remove workflows, add build
braican Feb 17, 2023
1027c28
Add husky for git hooks
braican Feb 17, 2023
3af667b
Use pre-push instead
braican Feb 17, 2023
2d322bf
Build assets
braican Feb 17, 2023
ac6b85a
Remove husky
braican Feb 17, 2023
56641f8
Try a build asset step
braican Feb 17, 2023
ec6f4de
Attach to PR branch
braican Feb 17, 2023
a752fad
Build production assets (from GitHub Actions)
braican Feb 17, 2023
9be1e36
Remove hard-coded block style names in favor of array
Feb 21, 2023
4d98001
Add documentation to image registerFormatType
Feb 21, 2023
b38b124
Adjust comment
Feb 21, 2023
3255662
Add enable_block_styles as configuration option
Feb 21, 2023
1579b84
Add autoloader
braican Feb 22, 2023
c795b83
Little syntax updates
braican Feb 22, 2023
89a3f6b
Linting
braican Feb 23, 2023
30e71a2
Cleanup
braican Feb 23, 2023
24c7049
Readme
braican Feb 23, 2023
f75bd89
Merge pull request #3 from Upstatement/v2-remove-image-style-panel
braican Feb 23, 2023
0e91ffc
Merge pull request #4 from Upstatement/v2-ci
braican Feb 23, 2023
b3783c3
Build production assets (from GitHub Actions)
braican Feb 23, 2023
55c08fa
Linting in github actions
braican Feb 23, 2023
ca13944
Build production assets (from GitHub Actions)
braican Feb 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ A WordPress plugin for enhancing the editorial experience, including some common
- [What This Plugin Does](#what-this-plugin-does)
- [Blocks](#blocks)
- [Editor Plugins](#editor-plugins)
- [Core Enhancements](#core-enhancements)
- [Theme Configuration](#theme-configuration)
- [Theme API](#theme-api)
- [Troubleshooting](#troubleshooting)
Expand All @@ -15,7 +16,7 @@ A WordPress plugin for enhancing the editorial experience, including some common

## What This Plugin Does

The purpose of this plugin is to tailor the Gutenberg editor experience to be better suited to editors using their WordPress theme. Features added as a part of this plugin fall into two categories: block modifications and editor plugins.
The purpose of this plugin is to tailor the Gutenberg editor experience to be better suited to editors using their WordPress theme and to add functionality common to many websites. Features added as a part of this plugin fall into three categories: block modifications, editor plugins, and core enhancements. This plugin also exposes some global functions that can be used in theme templates.

### Blocks

Expand Down Expand Up @@ -51,6 +52,10 @@ The Authors panel allows editors to assign multiple authors to the author byline

These authors also serve as taxonomies for your articles, so archive pages full of an author's own content are auto-generated on your behalf.

### Core Enhancements

- Adds a `Credit` field to attachment posts.

### Template functions

This plugin exposes a few functions that can be used to retrieve relevant values handled by the plugin. See the [Theme API](#theme-api) section for information about the available functions.
Expand Down Expand Up @@ -80,6 +85,7 @@ return array(
'table',
'video',
),
'enable_block_styles' => array(),
);
```

Expand Down Expand Up @@ -129,6 +135,14 @@ array(

A list of blocks that are extended by the plugin. To disable the extension of a certain block, exclude it from this array.

#### `enable_block_styles`

**Allowed types:** `array`

**Default value:** `array()`

WordPress core includes style options for some core blocks. This plugin removes those style options by default, but this parameter can be used to re-enable the core style options for specific blocks. The following blocks have core styles that can be re-enabled via this parameter: `button`, `image`, `quote`, `separator`, `table`.

## Theme API

There are a few globally-available functions that can be used by your theme to retrieve data defined by this plugin's functionality. These functions are defined in the `Template.php` file at the root of the plugin directory, and exist under the `Upstatement\Editorial` namespace.
Expand Down
3 changes: 3 additions & 0 deletions includes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class Config {
'table',
'video',
),

// Enable core block styles.
'enable_block_styles' => array(),
);

/**
Expand Down
18 changes: 9 additions & 9 deletions includes/Meta/AttachmentCredit.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class AttachmentCredit {
*/
private $attachment_fields = array(
array(
'id' => 'credit',
'label' => 'Credit',
'input' => 'text',
'helps' => 'Provide credit to the creator',
'id' => 'credit',
'label' => 'Credit',
'input' => 'text',
'helps' => 'Provide credit to the creator',
'single' => true,
)
),
);

/**
Expand All @@ -35,7 +35,7 @@ public static function register() {
$attachment_credit = new self();

add_filter( 'attachment_fields_to_edit', array( $attachment_credit, 'register_edit_fields' ), 10, 2 );
add_filter( 'attachment_fields_to_save', array( $attachment_credit, 'handle_save_fields'), 10, 2 );
add_filter( 'attachment_fields_to_save', array( $attachment_credit, 'handle_save_fields' ), 10, 2 );

add_action( 'rest_api_init', array( $attachment_credit, 'register_rest_fields' ) );
}
Expand Down Expand Up @@ -72,7 +72,7 @@ public function register_edit_fields( $fields, $post ) {
* @param array $post Array of post data.
* @param array $attachment Attachment metadata.
*
* @return void
* @return array
*/
public function handle_save_fields( $post, $attachment ) {
foreach ( $this->attachment_fields as $field ) {
Expand All @@ -93,12 +93,12 @@ public function handle_save_fields( $post, $attachment ) {
* @return void
*/
public function register_rest_fields() {
foreach ($this->attachment_fields as $field) {
foreach ( $this->attachment_fields as $field ) {
register_rest_field(
'attachment',
$field['id'],
array(
'get_callback' => function($object) use ($field) {
'get_callback' => function( $object ) use ( $field ) {
return get_post_meta( $object['id'], $field['id'], $field['single'] );
},
'update_callback' => null,
Expand Down
50 changes: 33 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,43 @@ import { Cover, File, Gallery, ImageLayout, RelatedArticles, Table, Video } from
});
});

domReady(() => {
// Remove quote style panel
unregisterBlockStyle('core/quote', 'default');
unregisterBlockStyle('core/quote', 'plain');
// ========================
// General editor

// Remove separator style panel
unregisterBlockStyle('core/separator', 'default');
unregisterBlockStyle('core/separator', 'wide');
unregisterBlockStyle('core/separator', 'dots');
domReady(() => {
/**
* Unregister all block styles and variations on core blocks by default, with
* optional overrides provided in configuration. This prevents unnecessary
* options for content editors and gives designers a blank slate when
* implementing core blocks.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/
*/
const activeEnableBlockStyles = window.ups_editorial?.enable_block_styles;
['button', 'image', 'quote', 'separator', 'table']
.filter(
blockName => !activeEnableBlockStyles || activeEnableBlockStyles.indexOf(blockName) === -1,
)
.forEach(blockName =>
wp.blocks
.getBlockType(`core/${blockName}`)
.styles.forEach(({ name: styleName }) =>
unregisterBlockStyle(`core/${blockName}`, styleName),
),
);

// Remove table style panel
unregisterBlockStyle('core/table', 'regular');
unregisterBlockStyle('core/table', 'stripes');
/**
* Unregister core Embed block variations.
*/
getBlockVariations('core/embed').forEach(variation => {
unregisterBlockVariation('core/embed', variation.name);
});

// Updating format type
/**
* Add custom class to inline images added to rich text content. This gives
* theme designers a selector target for inline image styles.
*/
const image = unregisterFormatType('core/image');
image.className = 'wp-rich-text-inline-image';
registerFormatType('core/image', image);

// Unregister all the Embed block variations.
getBlockVariations('core/embed').forEach(variation => {
unregisterBlockVariation('core/embed', variation.name);
});
});