-
Notifications
You must be signed in to change notification settings - Fork 4k
/
index.js
43 lines (37 loc) · 1.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* External dependencies
*/
import { connect } from 'react-redux';
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { FormToggle, withInstanceId } from '@wordpress/components';
/**
* Internal Dependencies
*/
import { getEditedPostAttribute } from '../../store/selectors';
import { editPost } from '../../store/actions';
function PostPingbacks( { pingStatus = 'open', instanceId, ...props } ) {
const onTogglePingback = () => props.editPost( { ping_status: pingStatus === 'open' ? 'closed' : 'open' } );
const pingbacksToggleId = 'allow-pingbacks-toggle-' + instanceId;
return [
<label key="label" htmlFor={ pingbacksToggleId }>{ __( 'Allow Pingbacks & Trackbacks' ) }</label>,
<FormToggle
key="toggle"
checked={ pingStatus === 'open' }
onChange={ onTogglePingback }
id={ pingbacksToggleId }
/>,
];
}
export default connect(
( state ) => {
return {
pingStatus: getEditedPostAttribute( state, 'ping_status' ),
};
},
{
editPost,
}
)( withInstanceId( PostPingbacks ) );