function hocwp_setup_theme_wp_hook()
{
    if (is_404()) {
        $redirect_404 = (bool) hocwp_option_get_value('reading', 'redirect_404');
        $post_type = hocwp_get_method_value('post_type', 'get');
        $p = hocwp_get_method_value('p', 'get');
        if ($redirect_404 || !empty($post_type) && hocwp_id_number_valid($p)) {
            hocwp_redirect_home();
        }
    } else {
        if (is_singular()) {
            $post_status = get_post_status();
            if ('future' == $post_status && !current_user_can('manage_options')) {
                hocwp_redirect_home();
            }
            $trending = hocwp_theme_get_reading_options('trending');
            if ((bool) $trending) {
                do_action('hocwp_add_trending_post', get_the_ID(), 'view');
            }
        }
        if (is_user_logged_in()) {
            if (is_page_template('page-templates/register.php') || is_page_template('page-templates/login.php')) {
                wp_redirect(get_edit_profile_url());
                exit;
            }
        } else {
            if (is_page_template('page-templates/register.php')) {
                if (hocwp_users_can_register()) {
                    hocwp_execute_register();
                } else {
                    $page = hocwp_get_page_by_template('page-templates/login.php');
                    if (is_a($page, 'WP_Post')) {
                        wp_redirect(get_permalink($page));
                        exit;
                    }
                    hocwp_redirect_home();
                }
            } else {
                if (hocwp_is_login_page()) {
                    $page = hocwp_get_pages_by_template('page-templates/login.php', array('output' => 'object'));
                    if (is_a($page, 'WP_Post')) {
                        wp_redirect(get_permalink($page));
                        exit;
                    }
                } elseif (is_page_template('page-templates/favorite-posts.php')) {
                    wp_redirect(wp_login_url());
                    exit;
                }
            }
        }
    }
    $enlarge_thumbnail = (bool) hocwp_theme_get_reading_options('enlarge_thumbnail');
    if ($enlarge_thumbnail) {
        add_filter('hocwp_enlarge_post_thumbnail_on_mobile', '__return_true');
    }
    $action = hocwp_get_method_value('action', 'get');
    switch ($action) {
        case 'verify_subscription':
            $key = hocwp_get_method_value('key', 'get');
            if (!empty($key)) {
                $args = array('post_type' => 'hocwp_subscriber', 'posts_per_page' => 1);
                $query = hocwp_get_post_by_meta('subscriber_active_key', $key, $args);
                if ($query->have_posts()) {
                    $obj = array_shift($query->posts);
                    update_post_meta($obj->ID, 'subscriber_verified', 1);
                    $name = hocwp_get_post_meta('subscriber_name', $obj->ID);
                    $email = hocwp_get_post_meta('subscriber_email', $obj->ID);
                    $args = array('email' => $email, 'name' => $name);
                    hocwp_add_to_newsletter_list($args);
                } else {
                    hocwp_redirect_home();
                }
            }
            break;
    }
}
function hocwp_classifieds_get_saved_posts_page()
{
    $result = hocwp_get_option_page('saved_posts_page', 'tin-da-luu', 'hocwp-theme-setting', 'page-templates/saved-posts.php');
    if (!is_a($result, 'WP_Post')) {
        $result = hocwp_get_page_by_template('page-templates/favorite-posts.php');
    }
    return apply_filters('hocwp_classifieds_get_saved_posts_page', $result);
}