permissions_helper = $permissions_helper; $this->register_hooks(); } /** * Registers the hooks. * * @return void */ public function register_hooks() { \add_action( 'admin_notices', [ $this, 'add_admin_notice' ] ); \add_action( 'enqueue_block_editor_assets', [ $this, 'add_block_editor_notice' ], 11 ); } /** * Generates the translated text for the notice. * * @return string The translated text for the notice. */ public function get_notice_text() { return \__( 'The original post has been edited in the meantime. If you click "Republish", this rewritten post will replace the original post.', 'duplicate-post' ); } /** * Shows a notice on the Classic editor. * * @return void */ public function add_admin_notice() { if ( ! $this->permissions_helper->is_classic_editor() ) { return; } $post = \get_post(); if ( ! $post instanceof WP_Post ) { return; } if ( $this->permissions_helper->has_original_changed( $post ) ) { print '
' . \esc_html( $this->get_notice_text() ) . '