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 { 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 { 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 { 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 { 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 { select } = wp.data; | |
const { getCurrentPostRevisionsCount } = select( 'core/editor' ); | |
const revisions = getCurrentPostRevisionsCount(); |
OlderNewer