Delete a Post from within the WP Block Editor.
Download from WordPress plugin repository.
You can also get the latest version from any of our release tags.
This plugin provides a quick way to delete or trash a Post from within the Block Editor. Previously, the only way to achieve this required a user to exit the article or post before deleting. Not anymore! Now, from the comfort of your Block Editor, you could easily delete the Post you're working on with ease.
clip.mov
This custom hook provides a simple way to filter the redirect URL the user is taken to after the post is trashed or deleted.
add_filter( 'tpbe_redirect_url', [ $this, 'custom_redirect_url' ] );
public function custom_redirect_url( $url ): string {
$site_url = 'https://example.com/redirect';
if ( false === strpos( $url, $site_url ) ) {
return esc_url( $site_url );
}
return $url;
}Parameters
- url
{string}By default, this will be a the redirect URL the user is taken to after a post is trashed.
This custom hook (action) provides the ability to fire events after the post is trashed on the JS side:
import { addAction } from '@wordpress/hooks';
addAction(
'tpbe.afterTrashPost',
'your-namespace',
( postId, redirectUrl ) => {
wp.data.dispatch( YOUR_STORE ).performSomeAction( postId );
}
);Parameters
- postId
{number}The trashed Post ID. - redirectUrl
{string}The Redirect URL where the user is taken after the post is trashed.
Contributions are welcome and will be fully credited. To contribute, please fork this repo and raise a PR (Pull Request) against the master branch.
You should have the following tools before proceeding to the next steps:
- Composer
- Yarn
- Docker
To enable you start development, please run:
yarn startThis should spin up a local WP env instance for you to work with at:
http://tpbe.localhost:5437You should now have a functioning local WP env to work with. To login to the wp-admin backend, please username as admin & password as password.
Awesome! - Thanks for being interested in contributing your time and code to this project!