Skip to content

Commit

Permalink
2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ned Zimmerman committed Jan 7, 2020
1 parent 0be9d88 commit 7b2f7de
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Changelog #
## 2.2.0 ##

**Minor Changes**

* Switch to GitHub Actions: #96
* Use Sage 10 editor config: #98
* Bump @wordpress/eslint-plugin from 3.2.0 to 3.3.0: #100
* Bump @wordpress/scripts from 6.0.0 to 6.1.1: #101
* Add support for custom authors: #102

## 2.1.0 ##

**Minor Changes**
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@platform-coop-toolkit/pcc-framework",
"version": "2.1.0",
"version": "2.2.0",
"description": "Utilities, custom post types and blocks for the Platform Cooperativism Consortium website.",
"author": "OCAD University",
"license": "BSD-3-Clause",
Expand Down
2 changes: 1 addition & 1 deletion pcc-framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Domain Path: /languages
* License: BSD 3-Clause "New" License
* License URI: https://opensource.org/licenses/BSD-3-Clause
* Version: 2.1.0
* Version: 2.2.0
*
* @package PCCFramework
*/
Expand Down
12 changes: 11 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ License: BSD 3-Clause "New" License
License URI: https://opensource.org/licenses/BSD-3-Clause
Requires at least: 5.3
Tested up to: 5.3
Stable tag: 2.1.0
Stable tag: 2.2.0

[![License](https://badgen.net/github/license/platform-coop-toolkit/pcc-framework)](https://github.com/platform-coop-toolkit/pcc-framework/blob/master/LICENSE.md) [![Status](https://badgen.net/github/status/platform-coop-toolkit/pcc-framework)](https://circleci.com/gh/platform-coop-toolkit/pcc-framework/tree/master) [![GitHub Release](https://badgen.net/github/release/platform-coop-toolkit/pcc-framework)](https://github.com/platform-coop-toolkit/pcc-framework/releases/latest)

Expand Down Expand Up @@ -42,6 +42,16 @@ Custom Taxonomies:
None yet.

== Changelog ==
= 2.2.0 =

**Minor Changes**

* Switch to GitHub Actions: #96
* Use Sage 10 editor config: #98
* Bump @wordpress/eslint-plugin from 3.2.0 to 3.3.0: #100
* Bump @wordpress/scripts from 6.0.0 to 6.1.1: #101
* Add support for custom authors: #102

= 2.1.0 =

**Minor Changes**
Expand Down
84 changes: 84 additions & 0 deletions src/sidebar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { registerPlugin } from '@wordpress/plugins';
import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-post';
import { __ } from '@wordpress/i18n';
import { SelectControl } from '@wordpress/components';
import { withDispatch, withSelect } from '@wordpress/data';
import { Component, Fragment, compose } from '@wordpress/element';

class AuthorshipPlugin extends Component {
render() {
// Nested object destructuring.
const {
meta: {
pcc_post_authors: postAuthors,
} = {},
updateMeta,
} = this.props;

const authors = [
{
value: '',
label: 'Use default author',
},
{
value: '1567',
label: 'Danny Spitzberg',
},
{
value: '742',
label: 'Trebor Scholz',
},
];

return (
<Fragment>
<PluginSidebarMoreMenuItem
target="pcc-authorship-sidebar"
>
{ __( 'Authorship', 'pcc-framework' ) }
</PluginSidebarMoreMenuItem>
<PluginSidebar
name="pcc-authorship-sidebar"
title={ __( 'Authorship', 'pcc-framework' ) }
>
<SelectControl
value={ postAuthors }
options={ authors }
onChange={ ( value ) => updateMeta( { pcc_post_authors: value || '' } ) }
/>
</PluginSidebar>
</Fragment>
);
}
}

// Fetch the post meta.
const applyWithSelect = withSelect( ( select ) => {
const { getEditedPostAttribute } = select( 'core/editor' );

return {
meta: getEditedPostAttribute( 'meta' ),
};
} );

// Provide method to update post meta.
const applyWithDispatch = withDispatch( ( dispatch, { meta } ) => {
const { editPost } = dispatch( 'core/editor' );

return {
updateMeta( newMeta ) {
editPost( { meta: { ...meta, ...newMeta } } ); // Important: Old and new meta need to be merged in a non-mutating way!
},
};
} );

// Combine the higher-order components.
const render = compose( [
applyWithSelect,
applyWithDispatch,
] )( AuthorshipPlugin );

registerPlugin( 'pcc-sidebar', {
icon: 'edit',
render,
} );

0 comments on commit 7b2f7de

Please sign in to comment.