<?php

/**
 * Sets the HTTP status code to 410 for 404 Not Found pages.
 *
 * This function checks if the current request resulted in a 404 error and, if so,
 * sets the HTTP status code to 410 (Gone). It should be attached to the 'template_redirect' action hook.
 */
function cwpai_set_410_for_404_pages() {
    if (is_404()) {
        status_header(410);
        nocache_headers();
    }
}

add_action('template_redirect', 'cwpai_set_410_for_404_pages');
