/* Plugin Name: Panchang Festival Finder Description: AstrologyAPI से पंचांग त्योहार लाने वाला शॉर्टकोड प्लगइन। Version: 1.2 Author: Amit Patel */ // ===== 1. SETTINGS PAGE ===== add_action('admin_menu', 'pff_add_admin_menu'); add_action('admin_init', 'pff_settings_init'); function pff_add_admin_menu() { add_options_page('Panchang Festival Settings', 'Panchang Festival', 'manage_options', 'panchang_festival', 'pff_options_page'); } function pff_settings_init() { register_setting('pff_settings', 'pff_options'); add_settings_section('pff_section', 'API Credentials', null, 'pff_settings'); add_settings_field('pff_user_id', 'User ID', 'pff_user_id_render', 'pff_settings', 'pff_section'); add_settings_field('pff_api_key', 'API Key', 'pff_api_key_render', 'pff_settings', 'pff_section'); } function pff_user_id_render() { $options = get_option('pff_options'); echo ""; } function pff_api_key_render() { $options = get_option('pff_options'); echo ""; } function pff_options_page() { echo '

Panchang Festival Settings

'; settings_fields('pff_settings'); do_settings_sections('pff_settings'); submit_button(); echo '
'; } // ===== 2. API CALL FUNCTION ===== function pff_get_festivals($day, $month, $year, $hour, $min, $lat, $lon, $tzone) { $options = get_option('pff_options'); $user_id = $options['pff_user_id']; $api_key = $options['pff_api_key']; if (!$user_id || !$api_key) return 'API credentials missing!'; $url = 'https://json.astrologyapi.com/v1/panchang_festival'; $args = array( 'headers' => array( 'Authorization' => 'Basic ' . base64_encode("$user_id:$api_key"), 'Content-Type' => 'application/json' ), 'body' => json_encode(array( 'day' => $day, 'month' => $month, 'year' => $year, 'hour' => $hour, 'min' => $min, 'lat' => $lat, 'lon' => $lon, 'tzone' => $tzone )) ); $response = wp_remote_post($url, $args); if (is_wp_error($response)) return 'API Error: ' . $response->get_error_message(); $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); return !empty($data['festivals']) ? $data['festivals'] : []; } // ===== 3. TODAY FESTIVAL SHORTCODE ===== add_shortcode('festival_today', 'pff_show_today_festival'); function pff_show_today_festival() { date_default_timezone_set('Asia/Kolkata'); $day = date('j'); $month = date('n'); $year = date('Y'); $hour = date('G'); $min = date('i'); $lat = 25.3176; $lon = 82.9739; $tzone = 5.5; $festivals = pff_get_festivals($day, $month, $year, $hour, $min, $lat, $lon, $tzone); $festivals_list = is_array($festivals) && !empty($festivals) ? implode(', ', $festivals) : 'कोई त्योहार नहीं मिला'; return "
आज के प्रमुख पर्व: $festivals_list
"; } // ===== 4. UPCOMING 5 FESTIVALS SHORTCODE ===== add_shortcode('upcoming_festivals', 'pff_show_upcoming_festivals'); function pff_show_upcoming_festivals() { date_default_timezone_set('Asia/Kolkata'); $lat = 25.3176; $lon = 82.9739; $tzone = 5.5; $today = new DateTime(); $all_festivals = []; $unique_festivals = []; for ($i = 0; $i < 60 && count($all_festivals) < 5; $i++) { $date = clone $today; $date->modify("+{$i} day"); $day = (int)$date->format('j'); $month = (int)$date->format('n'); $year = (int)$date->format('Y'); $hour = (int)$date->format('G'); $min = (int)$date->format('i'); $festivals = pff_get_festivals($day, $month, $year, $hour, $min, $lat, $lon, $tzone); if (is_array($festivals) && !empty($festivals)) { foreach ($festivals as $fest) { if (!in_array($fest, $unique_festivals)) { $unique_festivals[] = $fest; $all_festivals[] = array( 'name' => $fest, 'date' => $date->format('d-m-Y'), 'day' => $date->format('l') ); if (count($all_festivals) >= 5) break; } } } } if (empty($all_festivals)) return '
कोई आगामी त्योहार नहीं मिला।
'; $output = '
'; foreach ($all_festivals as $festival) { $output .= "
"; $output .= "त्योहार: {$festival['name']}
"; $output .= "दिन: {$festival['day']}
"; $output .= "तारीख: {$festival['date']}"; $output .= "
"; } $output .= '
'; return $output; } // ===== 5. THIS WEEK FESTIVALS SHORTCODE ===== add_shortcode('is_saptah_festival', 'pff_show_week_festivals'); function pff_show_week_festivals() { date_default_timezone_set('Asia/Kolkata'); $lat = 25.3176; $lon = 82.9739; $tzone = 5.5; $today = new DateTime(); $week_start = clone $today; $week_start->modify('monday this week'); $festivals_in_week = []; $unique_festivals = []; for ($i = 0; $i < 7; $i++) { $date = clone $week_start; $date->modify("+{$i} day"); $day = (int)$date->format('j'); $month = (int)$date->format('n'); $year = (int)$date->format('Y'); $hour = (int)$date->format('G'); $min = (int)$date->format('i'); $festivals = pff_get_festivals($day, $month, $year, $hour, $min, $lat, $lon, $tzone); if (is_array($festivals) && !empty($festivals)) { foreach ($festivals as $fest) { if (!in_array($fest, $unique_festivals)) { $unique_festivals[] = $fest; $festivals_in_week[] = array( 'name' => $fest, 'date' => $date->format('d-m-Y'), 'day' => $date->format('l') ); } } } } if (empty($festivals_in_week)) return '
इस सप्ताह कोई त्योहार नहीं मिला।
'; $output = '
'; foreach ($festivals_in_week as $festival) { $output .= "
"; $output .= "त्योहार: {$festival['name']}
"; $output .= "दिन: {$festival['day']}
"; $output .= "तारीख: {$festival['date']}"; $output .= "
"; } $output .= '
'; return $output; }
Warning: Cannot modify header information - headers already sent by (output started at /home/u796100598/domains/gaongiraw.in/public_html/wp-content/plugins/panchang-festival-finder/panchang-festival-finder.php:1) in /home/u796100598/domains/gaongiraw.in/public_html/wp-includes/pluggable.php on line 1435

Warning: Cannot modify header information - headers already sent by (output started at /home/u796100598/domains/gaongiraw.in/public_html/wp-content/plugins/panchang-festival-finder/panchang-festival-finder.php:1) in /home/u796100598/domains/gaongiraw.in/public_html/wp-includes/pluggable.php on line 1438