_reset_front_page_settings_for_post

The timeline below displays how wordpress function _reset_front_page_settings_for_post has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Resets the page_on_front, show_on_front, and page_for_post settings when
 * a linked page is deleted or trashed.
 *
 * Also ensures the post is no longer sticky.
 *
 * @since 3.7.0
 * @access private
 *
 * @param int $post_id Post ID.
 */
function _reset_front_page_settings_for_post($post_id)
{
    $post = get_post($post_id);
    if ('page' === $post->post_type) {
        /*
         * If the page is defined in option page_on_front or post_for_posts,
         * adjust the corresponding options.
         */
        if (get_option('page_on_front') == $post->ID) {
            update_option('show_on_front', 'posts');
            update_option('page_on_front', 0);
        }
        if (get_option('page_for_posts') == $post->ID) {
            update_option('page_for_posts', 0);
        }
    }
    unstick_post($post->ID);
}

WordPress Version: 5.5

/**
 * Reset the page_on_front, show_on_front, and page_for_post settings when
 * a linked page is deleted or trashed.
 *
 * Also ensures the post is no longer sticky.
 *
 * @since 3.7.0
 * @access private
 *
 * @param int $post_id Post ID.
 */
function _reset_front_page_settings_for_post($post_id)
{
    $post = get_post($post_id);
    if ('page' === $post->post_type) {
        /*
         * If the page is defined in option page_on_front or post_for_posts,
         * adjust the corresponding options.
         */
        if (get_option('page_on_front') == $post->ID) {
            update_option('show_on_front', 'posts');
            update_option('page_on_front', 0);
        }
        if (get_option('page_for_posts') == $post->ID) {
            update_option('page_for_posts', 0);
        }
    }
    unstick_post($post->ID);
}

WordPress Version: 5.3

/**
 * Reset the page_on_front, show_on_front, and page_for_post settings when
 * a linked page is deleted or trashed.
 *
 * Also ensures the post is no longer sticky.
 *
 * @since 3.7.0
 * @access private
 *
 * @param int $post_id Post ID.
 */
function _reset_front_page_settings_for_post($post_id)
{
    $post = get_post($post_id);
    if ('page' == $post->post_type) {
        /*
         * If the page is defined in option page_on_front or post_for_posts,
         * adjust the corresponding options.
         */
        if (get_option('page_on_front') == $post->ID) {
            update_option('show_on_front', 'posts');
            update_option('page_on_front', 0);
        }
        if (get_option('page_for_posts') == $post->ID) {
            update_option('page_for_posts', 0);
        }
    }
    unstick_post($post->ID);
}

WordPress Version: 4.0

/**
 * Reset the page_on_front, show_on_front, and page_for_post settings when
 * a linked page is deleted or trashed.
 *
 * Also ensures the post is no longer sticky.
 *
 * @since 3.7.0
 * @access private
 *
 * @param int $post_id Post ID.
 */
function _reset_front_page_settings_for_post($post_id)
{
    $post = get_post($post_id);
    if ('page' == $post->post_type) {
        /*
         * If the page is defined in option page_on_front or post_for_posts,
         * adjust the corresponding options.
         */
        if (get_option('page_on_front') == $post->ID) {
            update_option('show_on_front', 'posts');
            update_option('page_on_front', 0);
        }
        if (get_option('page_for_posts') == $post->ID) {
            delete_option('page_for_posts', 0);
        }
    }
    unstick_post($post->ID);
}

WordPress Version: 3.7

/**
 * Resets the page_on_front, show_on_front, and page_for_post settings when a
 * linked page is deleted or trashed.
 *
 * Also ensures the post is no longer sticky.
 *
 * @access private
 * @since 3.7.0
 * @param $post_id
 */
function _reset_front_page_settings_for_post($post_id)
{
    $post = get_post($post_id);
    if ('page' == $post->post_type) {
        // If the page is defined in option page_on_front or post_for_posts,
        // adjust the corresponding options
        if (get_option('page_on_front') == $post->ID) {
            update_option('show_on_front', 'posts');
            update_option('page_on_front', 0);
        }
        if (get_option('page_for_posts') == $post->ID) {
            delete_option('page_for_posts', 0);
        }
    }
    unstick_post($post->ID);
}