summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2019-05-22 01:01:36 -0400
committerYury German <blueknight@gentoo.org>2019-05-22 01:01:36 -0400
commit0914c92da22824025992c368c745546e41fbeb84 (patch)
tree965f6adf3b725e56d559fe4a93eff02281499dcc /plugins/jetpack/extensions/blocks/likes/likes-checkbox.js
parentDeleting plugins for update (diff)
downloadblogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.tar.gz
blogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.tar.bz2
blogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.zip
Adding Plugins
Updating the following akismet.4.1.2, google-authenticator.0.52, jetpack.7.3.1 Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/extensions/blocks/likes/likes-checkbox.js')
-rw-r--r--plugins/jetpack/extensions/blocks/likes/likes-checkbox.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/jetpack/extensions/blocks/likes/likes-checkbox.js b/plugins/jetpack/extensions/blocks/likes/likes-checkbox.js
new file mode 100644
index 00000000..f8bf0736
--- /dev/null
+++ b/plugins/jetpack/extensions/blocks/likes/likes-checkbox.js
@@ -0,0 +1,45 @@
+/**
+ * External dependencies
+ */
+import { __ } from '@wordpress/i18n';
+import { CheckboxControl } from '@wordpress/components';
+import { compose } from '@wordpress/compose';
+import { PostTypeSupportCheck } from '@wordpress/editor';
+import { withDispatch, withSelect } from '@wordpress/data';
+
+/**
+ * Internal dependencies
+ */
+import JetpackLikesAndSharingPanel from '../../shared/jetpack-likes-and-sharing-panel';
+
+const LikesCheckbox = ( { areLikesEnabled, editPost } ) => (
+ <PostTypeSupportCheck supportKeys="jetpack-post-likes">
+ <JetpackLikesAndSharingPanel>
+ <CheckboxControl
+ label={ __( 'Show likes.', 'jetpack' ) }
+ checked={ areLikesEnabled }
+ onChange={ value => {
+ editPost( { jetpack_likes_enabled: value } );
+ } }
+ />
+ </JetpackLikesAndSharingPanel>
+ </PostTypeSupportCheck>
+);
+
+// Fetch the post meta.
+const applyWithSelect = withSelect( select => {
+ const { getEditedPostAttribute } = select( 'core/editor' );
+ const areLikesEnabled = getEditedPostAttribute( 'jetpack_likes_enabled' );
+
+ return { areLikesEnabled };
+} );
+
+// Provide method to update post meta.
+const applyWithDispatch = withDispatch( dispatch => {
+ const { editPost } = dispatch( 'core/editor' );
+
+ return { editPost };
+} );
+
+// Combine the higher-order components.
+export default compose( [ applyWithSelect, applyWithDispatch ] )( LikesCheckbox );