@@ -11,101 +11,63 @@ import { __ } from '@wordpress/i18n';
1111/**
1212 * Hide updated date
1313 */
14- const PostStatusExtensions = ( { meta, postType, updateMetaValue } ) => {
15- if ( ! meta ) {
14+ const PostStatusExtensions = ( { meta, postType, updateMetaValue } ) => {
15+ if ( ! meta ) {
1616 return null ;
1717 }
18- const {
19- newspack_hide_page_title,
20- newspack_hide_updated_date,
21- newspack_show_updated_date,
22- newspack_show_share_buttons,
23- } = meta ;
24- const {
25- hide_date = [ ] ,
26- show_date = [ ] ,
27- hide_title = [ ] ,
28- show_share_buttons = [ ] ,
29- } = window . newspack_post_meta_post_types ;
30- const hideDate = 0 <= hide_date . indexOf ( postType ) ;
31- const showDate = 0 <= show_date . indexOf ( postType ) ;
32- const hideTitle = 0 <= hide_title . indexOf ( postType ) ;
33- const showShareButtons = 0 <= show_share_buttons . indexOf ( postType ) ;
18+ const { newspack_hide_page_title, newspack_hide_updated_date, newspack_show_updated_date, newspack_show_share_buttons } = meta ;
19+ const { hide_date = [ ] , show_date = [ ] , hide_title = [ ] , show_share_buttons = [ ] } = window . newspack_post_meta_post_types ;
20+ const hideDate = 0 <= hide_date . indexOf ( postType ) ;
21+ const showDate = 0 <= show_date . indexOf ( postType ) ;
22+ const hideTitle = 0 <= hide_title . indexOf ( postType ) ;
23+ const showShareButtons = 0 <= show_share_buttons . indexOf ( postType ) ;
3424
35- if ( ! hideDate && ! showDate && ! hideTitle && ! showShareButtons ) {
25+ if ( ! hideDate && ! showDate && ! hideTitle && ! showShareButtons ) {
3626 return null ;
3727 }
3828
3929 return (
4030 < PluginPostStatusInfo className = "newspack__post-meta-toggles" >
41- { hideDate && (
31+ { hideDate && (
4232 < div >
43- < label htmlFor = "hide_updated_date" >
44- { __ ( 'Hide last updated date' , 'newspack-theme' ) }
45- </ label >
33+ < label htmlFor = "hide_updated_date" > { __ ( 'Hide last updated date' , 'newspack-theme' ) } </ label >
4634 < FormToggle
47- checked = { newspack_hide_updated_date }
48- onChange = { ( ) =>
49- updateMetaValue (
50- 'newspack_hide_updated_date' ,
51- ! newspack_hide_updated_date
52- )
53- }
35+ checked = { newspack_hide_updated_date }
36+ onChange = { ( ) => updateMetaValue ( 'newspack_hide_updated_date' , ! newspack_hide_updated_date ) }
5437 id = "hide_updated_date"
5538 />
5639 </ div >
57- ) }
58- { showDate && (
40+ ) }
41+ { showDate && (
5942 < div >
60- < label htmlFor = "show_updated_date" >
61- { __ ( 'Show last updated date' , 'newspack-theme' ) }
62- </ label >
43+ < label htmlFor = "show_updated_date" > { __ ( 'Show last updated date' , 'newspack-theme' ) } </ label >
6344 < FormToggle
64- checked = { newspack_show_updated_date }
65- onChange = { ( ) =>
66- updateMetaValue (
67- 'newspack_show_updated_date' ,
68- ! newspack_show_updated_date
69- )
70- }
45+ checked = { newspack_show_updated_date }
46+ onChange = { ( ) => updateMetaValue ( 'newspack_show_updated_date' , ! newspack_show_updated_date ) }
7147 id = "show_updated_date"
7248 />
7349 </ div >
74- ) }
75- { hideTitle && 'page' === postType && (
50+ ) }
51+ { hideTitle && 'page' === postType && (
7652 < div >
77- < label htmlFor = "hide_page_title" >
78- { __ ( 'Hide page title' , 'newspack-theme' ) }
79- </ label >
53+ < label htmlFor = "hide_page_title" > { __ ( 'Hide page title' , 'newspack-theme' ) } </ label >
8054 < FormToggle
81- checked = { newspack_hide_page_title }
82- onChange = { ( ) =>
83- updateMetaValue (
84- 'newspack_hide_page_title' ,
85- ! newspack_hide_page_title
86- )
87- }
55+ checked = { newspack_hide_page_title }
56+ onChange = { ( ) => updateMetaValue ( 'newspack_hide_page_title' , ! newspack_hide_page_title ) }
8857 id = "hide_page_title"
8958 />
9059 </ div >
91- ) }
92- { showShareButtons && 'page' === postType && (
60+ ) }
61+ { showShareButtons && 'page' === postType && (
9362 < div >
94- < label htmlFor = "newspack_show_share_buttons" >
95- { __ ( 'Show Jetpack share buttons' , 'newspack-theme' ) }
96- </ label >
63+ < label htmlFor = "newspack_show_share_buttons" > { __ ( 'Show Jetpack share buttons' , 'newspack-theme' ) } </ label >
9764 < FormToggle
98- checked = { newspack_show_share_buttons }
99- onChange = { ( ) =>
100- updateMetaValue (
101- 'newspack_show_share_buttons' ,
102- ! newspack_show_share_buttons
103- )
104- }
65+ checked = { newspack_show_share_buttons }
66+ onChange = { ( ) => updateMetaValue ( 'newspack_show_share_buttons' , ! newspack_show_share_buttons ) }
10567 id = "hide_page_title"
10668 />
10769 </ div >
108- ) }
70+ ) }
10971 </ PluginPostStatusInfo >
11072 ) ;
11173} ;
@@ -114,27 +76,23 @@ const PostStatusExtensions = ({ meta, postType, updateMetaValue }) => {
11476 * Map state to props
11577 */
11678const mapStateToProps = select => {
117- const { getCurrentPostType, getEditedPostAttribute } =
118- select ( 'core/editor' ) ;
79+ const { getCurrentPostType, getEditedPostAttribute } = select ( 'core/editor' ) ;
11980 return {
120- meta : getEditedPostAttribute ( 'meta' ) ,
81+ meta : getEditedPostAttribute ( 'meta' ) ,
12182 postType : getCurrentPostType ( ) ,
12283 } ;
12384} ;
12485
12586const mapDispatchToProps = dispatch => {
126- const { editPost } = dispatch ( 'core/editor' ) ;
87+ const { editPost } = dispatch ( 'core/editor' ) ;
12788 return {
128- updateMetaValue : ( key , value ) => editPost ( { meta : { [ key ] : value } } ) ,
89+ updateMetaValue : ( key , value ) => editPost ( { meta : { [ key ] : value } } ) ,
12990 } ;
13091} ;
13192
13293/**
13394 * Register plugins
13495 */
135- const postStatusSidebar = compose ( [
136- withSelect ( mapStateToProps ) ,
137- withDispatch ( mapDispatchToProps ) ,
138- ] ) ( PostStatusExtensions ) ;
96+ const postStatusSidebar = compose ( [ withSelect ( mapStateToProps ) , withDispatch ( mapDispatchToProps ) ] ) ( PostStatusExtensions ) ;
13997
140- registerPlugin ( 'post-status-sidebar' , { render : postStatusSidebar } ) ;
98+ registerPlugin ( 'post-status-sidebar' , { render : postStatusSidebar } ) ;
0 commit comments