















// Dhyan dijiye: Yahan priority '5' lagayi hai taaki ye sabse pehle run ho
add_action( 'publish_future_post', 'inject_push_meta_before_perfecty', 5, 1 );

function inject_push_meta_before_perfecty( $post_id ) {
    $post = get_post( $post_id );
    
    // Yahan apne parsed jobs ke post type check kar lijiye
    $allowed_post_types = array( 'post', 'job_listing', 'jobs' ); 

    if ( in_array( $post->post_type, $allowed_post_types ) ) {
        
        // 1. TIME CHECK LOGIC (11:00 PM to 6:00 AM)
        // wp_date('G') WordPress ki timezone settings ke hisaab se 24-hour format (0-23) me time deta hai
        $current_hour = (int) wp_date( 'G' ); 
        
        // Agar time raat 11 baje (23) ya usse zyada hai, YA subah 6 baje (6) se kam hai
        if ( $current_hour >= 23 || $current_hour < 6 ) {
            // Isko explicitly 0 set kar rahe hain taaki push bilkul na jaye
            update_post_meta( $post_id, '_perfecty_push_send_on_publish', 0 );
            
            // Yahan se function return ho jayega, matlab niche ka 'counter' logic run nahi hoga (so no count)
            return; 
        }

        // 2. COUNTER LOGIC (Send 1, Skip 2)
        // Database se current counter nikalenge (agar pehli baar chal raha hai to 0 aayega)
        $counter = (int) get_option( 'workvapor_push_skip_counter', 0 );
        $counter++; // Naya post aaya, to counter ko 1 badha diya

        if ( $counter === 1 ) {
            // Pehla post: Isme push bhejna hai
            update_post_meta( $post_id, '_perfecty_push_send_on_publish', 1 );
        } else {
            // Dusra aur teesra post: Push skip karna hai
            update_post_meta( $post_id, '_perfecty_push_send_on_publish', 0 );
        }

        // Agar counter 3 ho gaya hai (1 sent + 2 skipped), to usko waapas 0 kar do
        if ( $counter >= 3 ) {
            $counter = 0;
        }

        // Database me naya count save kar do taaki agle post me yaad rahe
        update_option( 'workvapor_push_skip_counter', $counter );
    }
}


















<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://workvapor.in/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://workvapor.in/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://workvapor.in/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://workvapor.in/wp-sitemap-posts-jobs_india-1.xml</loc></sitemap><sitemap><loc>https://workvapor.in/wp-sitemap-posts-jobs-1.xml</loc></sitemap><sitemap><loc>https://workvapor.in/wp-sitemap-posts-jobs-2.xml</loc></sitemap><sitemap><loc>https://workvapor.in/wp-sitemap-posts-web-story-1.xml</loc></sitemap><sitemap><loc>https://workvapor.in/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://workvapor.in/wp-sitemap-taxonomies-jobs_category-1.xml</loc></sitemap><sitemap><loc>https://workvapor.in/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
