| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
import { compose } from '@wordpress/compose'; |
| 5 |
import { withSelect } from '@wordpress/data'; |
| 6 |
|
| 7 |
export function DisplayPlayerCheck( { hasDisplayPlayerAction, children } ) { |
| 8 |
if ( ! hasDisplayPlayerAction ) { |
| 9 |
return null; |
| 10 |
} |
| 11 |
|
| 12 |
return children; |
| 13 |
} |
| 14 |
|
| 15 |
export default compose( [ |
| 16 |
withSelect( ( select ) => { |
| 17 |
const { getEditedPostAttribute } = select( 'core/editor' ); |
| 18 |
|
| 19 |
const beyondwordsContentId = |
| 20 |
getEditedPostAttribute( 'meta' ).beyondwords_content_id; |
| 21 |
const beyondwordsPodcastId = |
| 22 |
getEditedPostAttribute( 'meta' ).beyondwords_podcast_id; |
| 23 |
const speechkitPodcastId = |
| 24 |
getEditedPostAttribute( 'meta' ).speechkit_podcast_id; |
| 25 |
|
| 26 |
return { |
| 27 |
hasDisplayPlayerAction: |
| 28 |
!! beyondwordsContentId || |
| 29 |
!! beyondwordsPodcastId || |
| 30 |
!! speechkitPodcastId, |
| 31 |
}; |
| 32 |
} ), |
| 33 |
] )( DisplayPlayerCheck ); |
| 34 |
|