PluginProbe ʕ •ᴥ•ʔ
Simple Author Box / 2.52
Simple Author Box v2.52
trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.9 2.0 2.0.1 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.11 2.3.12 2.3.15 2.3.16 2.3.2 2.3.20 2.3.21 2.3.22 2.4 2.41 2.42 2.45 2.46 2.47 2.48 2.49 2.50 2.51 2.52 2.54 2.55 2.56 2.57 2.59 2.60
simple-author-box / assets / src / js / components / inspector.js
simple-author-box / assets / src / js / components Last commit date
edit.js 3 years ago inspector.js 7 years ago
inspector.js
67 lines
1 /**
2 * WordPress dependencies
3 */
4 const { __ } = wp.i18n;
5 const { Component, Fragment } = wp.element;
6 const { InspectorControls } = wp.editor;
7 const { SelectControl, PanelBody } = wp.components;
8
9
10 /**
11 * Inspector controls
12 */
13 export default class Inspector extends Component {
14
15 constructor( props ) {
16 super( ...arguments );
17 }
18
19 onAuthorSelect( authorID ) {
20
21 this.props.setAttributes( {
22 status: 'loading',
23 } );
24
25 this.props.changeAuthor( authorID );
26 }
27
28 render() {
29
30 const {
31 attributes,
32 setAttributes
33 } = this.props;
34
35 const {
36 authorID,
37 } = attributes;
38
39 let authors = sabVars.authors;
40 authors.forEach(function(author) {
41 author.value = author.ID;
42 author.label = author.display_name;
43 });
44
45 let isEditor = false;
46 if( sabVars.currentUserRoles.indexOf("administrator") != -1 || sabVars.currentUserRoles.indexOf("editor") != -1 ) {
47 isEditor = true;
48 }
49
50 return (
51 <Fragment>
52 <InspectorControls>
53 { isEditor && (
54 <PanelBody title={ __( 'Author Settings' ) } initialOpen={ true }>
55 <SelectControl
56 label={ __( 'Select author' ) }
57 value={ authorID }
58 options={ authors }
59 onChange={ ( value ) => this.onAuthorSelect( value ) }
60 />
61 </PanelBody>
62 ) }
63 </InspectorControls>
64 </Fragment>
65 );
66 }
67 }