This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { select } = wp.data; | |
| const { getCurrentPostRevisionsCount } = select( 'core/editor' ); | |
| const revisions = getCurrentPostRevisionsCount(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { select } = wp.data; | |
| const { getAuthors } = select( 'core' ); | |
| const { getEditedPostAttribute } = select( 'core/editor' ); | |
| const authorID = getEditedPostAttribute( 'author' ); | |
| const { name } = getAuthors().find(a => a.id === authorID); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { dispatch } = wp.data; | |
| const { editPost } = dispatch( 'core/editor' ); | |
| const NOW = new Date(); | |
| const ONE_DAY_IN_MS = 24 * 60 * 60 * 1000; | |
| const TOMORROW = new Date( NOW.getTime() + ONE_DAY_IN_MS ); | |
| const schedulePost = date => editPost( { date } ); | |
| schedulePost( TOMORROW ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { dispatch } = wp.data; | |
| const { editPost, savePost } = dispatch( 'core/editor' ); | |
| const setStatusToDraft = ( async () => { | |
| await editPost( { status: 'draft' } ); | |
| await savePost(); | |
| } )(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { select } = wp.data; | |
| const { getBlockCount } = select( 'core/editor' ); | |
| const hasBlocks = () => !! getBlockCount(); | |
| hasBlocks(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { select } = wp.data; | |
| const { count } = wp.wordcount; | |
| const { getEditedPostAttribute } = select( 'core/editor' ); | |
| const content = getEditedPostAttribute( 'content' ); | |
| const countWords = count( content, 'words' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { select } = wp.data; | |
| const { hasUploadPermissions } = select( 'core' ); | |
| const canUpload = hasUploadPermissions(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { select } = wp.data; | |
| const { getEditorSettings } = select( 'core/editor' ); | |
| const { maxUploadFileSize } = getEditorSettings(); | |
| const maxMB = Number( maxUploadFileSize / Math.pow( 1024, 2 ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const POST_ID = 25; | |
| const { select } = wp.data; | |
| const { getEntityRecords } = select( 'core' ); | |
| const [ postDetails ] = getEntityRecords( 'postType', 'post', { include: POST_ID } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { select } = wp.data; | |
| const { getTaxonomies } = select( 'core' ); | |
| const taxonomies = getTaxonomies(); |
NewerOlder