function render_hebrew_calendar($atts) { // Set default attributes and merge with user-provided attributes $atts = shortcode_atts(array( 'year' => date('Y'), 'month' => date('n') ), $atts); $current_month = isset($_GET['mymonth']) ? intval($_GET['mymonth']) : intval($atts['month']); $current_year = isset($_GET['myyear']) ? intval($_GET['myyear']) : intval($atts['year']); $today = date('Y-m-d'); // Convert the first day of the month to JD $jd_first_day = gregoriantojd($current_month, 1, $current_year); $hebrew_first_date = jdtojewish($jd_first_day, true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH); $hebrew_first_date = iconv('WINDOWS-1255', 'UTF-8', $hebrew_first_date); list($hebrew_first_day, $hebrew_first_month, $hebrew_first_year) = explode(' ', $hebrew_first_date); // Get the last day of the month $jd_last_day = gregoriantojd($current_month, cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year), $current_year); $hebrew_last_date = jdtojewish($jd_last_day, true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH); $hebrew_last_date = iconv('WINDOWS-1255', 'UTF-8', $hebrew_last_date); list($hebrew_last_day, $hebrew_last_month, $hebrew_last_year) = explode(' ', $hebrew_last_date); // Determine the Hebrew months and year to display $display_hebrew_months = $hebrew_first_month == $hebrew_last_month ? $hebrew_first_month : $hebrew_first_month . ' - ' . $hebrew_last_month; $display_hebrew_year = $hebrew_first_year; // Translate Gregorian month and year to Hebrew $gregorian_months_hebrew = array( 'January' => 'ינואר', 'February' => 'פברואר', 'March' => 'מרץ', 'April' => 'אפריל', 'May' => 'מאי', 'June' => 'יוני', 'July' => 'יולי', 'August' => 'אוגוסט', 'September' => 'ספטמבר', 'October' => 'אוקטובר', 'November' => 'נובמבר', 'December' => 'דצמבר' ); $gregorian_month_name = date('F', mktime(0, 0, 0, $current_month, 10)); $gregorian_month_name_hebrew = $gregorian_months_hebrew[$gregorian_month_name]; $hebrewDate = jdtojewish(gregoriantojd(1, 1, $current_year), true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH); $hebrewDateParts = explode(' ', $hebrewDate); $hebrewYear = end($hebrewDateParts); $hebrew_year_full = iconv('WINDOWS-1255', 'UTF-8', $hebrewYear); // יצירת התוכן של תגית h2 $h2_content = $display_hebrew_months . ' ' . $hebrew_year_full . ' / ' . $gregorian_month_name_hebrew . ' ' . $current_year; global $title_he_date; $title_he_date = $h2_content; $output = '
'; $output .= '

' . esc_html($h2_content) . '

'; // שינוי ה-TITLE של העמוד add_filter('title', function() use ($h2_content) { return esc_html($h2_content); }); $prev_month = $current_month - 1; $next_month = $current_month + 1; $prev_year = $current_year; $next_year = $current_year; if ($prev_month < 1) { $prev_month = 12; $prev_year--; } if ($next_month > 12) { $next_month = 1; $next_year++; } $prev_url = add_query_arg(array('mymonth' => $prev_month, 'myyear' => $prev_year), get_permalink()); $next_url = add_query_arg(array('mymonth' => $next_month, 'myyear' => $next_year), get_permalink()); $original_url = get_permalink(); // Add month and year select options (Gregorian) $output .= '
'; $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; $output .= '
'; $output .= 'חודש קודם'; $output .= 'היום'; $output .= 'חודש הבא'; $output .= '
'; // Create the calendar table $output .= ''; $output .= ''; // Find the first day of the week for the first day of the month $jd_first_day_of_week = jddayofweek($jd_first_day, 0); $day_of_week = $jd_first_day_of_week; $output .= ''; // Pad the first week with empty cells if the month does not start on Sunday for ($i = 0; $day_of_week > 0 && $i < $day_of_week; $i++) { $output .= ''; } // Populate the days of the month $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year); for ($day = 1; $day <= $days_in_month; $day++, $day_of_week++) { if ($day_of_week == 7) { $day_of_week = 0; $output .= ''; } $jd = gregoriantojd($current_month, $day, $current_year); $hebrew_date = jdtojewish($jd, true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH); $hebrew_date = iconv('WINDOWS-1255', 'UTF-8', $hebrew_date); list($hebrew_day, $hebrew_month) = explode(' ', $hebrew_date); $class = ($day_of_week == 5 || $day_of_week == 6) ? 'shabbat' : ''; $gregorian_date = jdtogregorian($jd); $gregorian_date_formatted = date('Y-m-d', strtotime($gregorian_date)); $day_class = ($today == $gregorian_date_formatted) ? 'today' : ''; $output .= ''; } // Pad the last week with empty cells if needed for (; $day_of_week < 7; $day_of_week++) { $output .= ''; } $output .= ''; $output .= '
ראשוןשנישלישירביעיחמישישישישבת
'; $output .= $hebrew_day . ' ' . $hebrew_month . '
' . date('d/m/y', strtotime($gregorian_date)); $output .= '
'; $output .= '
'; $output .= '
'; $output .= '
'; $output .= '
'; return $output; } // Function to add Yoast custom variables function add_yoast_custom_vars() { global $title_he_date; if (!empty($title_he_date)) { // Add custom variable to Yoast wpseo_register_var_replacement('%%title_he_date%%', function() use ($title_he_date) { return $title_he_date; }, 'advanced', 'The custom Hebrew date title'); } } add_action('wp', 'add_yoast_custom_vars'); ?>