$object_id, 'post_content' => (string) ( $undo['content'] ?? '' ), ) ); break; case 'content_refresh': wp_update_post( array( 'ID' => $object_id, 'post_content' => (string) ( $undo['content'] ?? '' ), ) ); AI_SEO_Tools_SEO::set_title( $object_id, (string) ( $undo['title'] ?? '' ) ); AI_SEO_Tools_SEO::set_description( $object_id, (string) ( $undo['desc'] ?? '' ) ); delete_transient( 'ai_seo_meta_stats' ); break; default: return new WP_Error( 'unknown_type', __( 'That kind of change cannot be reverted automatically.', 'ai-seo-tools' ) ); } AI_SEO_Tools_Log::mark_undone( $log_id ); return true; } public function ajax_undo(): void { AI_SEO_Tools_Ajax::verify( 'edit_posts' ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- verify() ran above. $log_id = isset( $_POST['log_id'] ) ? absint( wp_unslash( $_POST['log_id'] ) ) : 0; $result = self::revert( $log_id ); if ( is_wp_error( $result ) ) { wp_send_json_error( array( 'message' => $result->get_error_message() ), 400 ); } wp_send_json_success( array( 'message' => __( 'Reverted.', 'ai-seo-tools' ) ) ); } } }