| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
import { __ } from '@wordpress/i18n'; |
| 5 |
import { compose } from '@wordpress/compose'; |
| 6 |
import { withSelect, withDispatch } from '@wordpress/data'; |
| 7 |
import { Fragment } from '@wordpress/element'; |
| 8 |
|
| 9 |
export function OpenSidebar( { openSidebar, wrapper = Fragment } ) { |
| 10 |
const Wrapper = wrapper; |
| 11 |
|
| 12 |
return ( |
| 13 |
<Wrapper> |
| 14 |
<p style={ { marginBottom: 0, paddingBottom: 0 } }> |
| 15 |
{ __( 'Open the', 'speechkit' ) }{ ' ' } |
| 16 |
<a |
| 17 |
href="#beyondwords-plugin-sidebar" |
| 18 |
onClick={ () => { |
| 19 |
openSidebar(); |
| 20 |
} } |
| 21 |
> |
| 22 |
{ __( 'BeyondWords sidebar', 'speechkit' ) } |
| 23 |
</a>{ ' ' } |
| 24 |
{ __( 'for additional options and features.', 'speechkit' ) } |
| 25 |
</p> |
| 26 |
</Wrapper> |
| 27 |
); |
| 28 |
} |
| 29 |
|
| 30 |
export default compose( [ |
| 31 |
withSelect( ( select ) => { |
| 32 |
const { getEditedPostAttribute } = select( 'core/editor' ); |
| 33 |
|
| 34 |
return { |
| 35 |
src: getEditedPostAttribute( 'meta' )._speechkit_link, |
| 36 |
}; |
| 37 |
} ), |
| 38 |
withDispatch( ( dispatch ) => { |
| 39 |
const { openGeneralSidebar } = dispatch( 'core/edit-post' ); |
| 40 |
return { |
| 41 |
openSidebar: () => { |
| 42 |
openGeneralSidebar( |
| 43 |
'beyondwords-plugin-sidebar/plugin-sidebar' |
| 44 |
); |
| 45 |
}, |
| 46 |
}; |
| 47 |
} ), |
| 48 |
] )( OpenSidebar ); |
| 49 |
|