<?php

/**
 *
 * @link              https://www.adatosystems.com/zmanim-wp/
 * @since             1.0.0
 * @package           zmanim_wpa
 *
 * @wordpress-plugin
 * Plugin Name: Zmanim WP Zmanim WP Plus
 * Plugin URI:        https://www.adatosystems.com/zmanim-wp/
 * Description:       Choose from a variety of shitot (opinions), use shortcodes (with options) to display those times in posts, pages, and widgets. With gratitude to Eliyahu Hershfeld, Zachary Weixelbaum, and Elyahu Jacobi.
 * Version:           2.7.2
 * Author:            Leon Adato
 * Author URI:        https://adatosystems.com/
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       zmanim-wp
 */
// If this file is called directly, abort.
if ( !defined( 'WPINC' ) ) {
    die;
}

use PhpZmanim\Zmanim;
use Carbon\Carbon;
use PhpZmanim\HebrewCalendar\JewishCalendar;
use PhpZmanim\HebrewCalendar\JewishDate;
use PhpZmanim\HebrewCalendar\TefilaRules;
use PhpZmanim\HebrewCalendar\Parsha;

if ( !defined( 'ABSPATH' ) ) {
    exit;
}

require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/zmanim-wp-functions.php';

// Call zmanim_wp_menu function to load plugin menu in dashboard
add_action( 'admin_menu', 'zmanim_wp_menu' );
// Create WordPress admin menu
function zmanim_wp_menu() {
    add_menu_page(
        'Zmanim WP Main Options',
        //page title
        'Zmanim WP',
        //menu title
        'manage_options',
        //capability
        'zmanim_wp',
        //menu slug
        'zmanim_wp_page',
        //callback function
        'dashicons-clock',
        //icon
        4
    );
    //position
    add_submenu_page(
        'zmanim_wp',
        // Parent slug
        'Standard Times',
        // Page title
        'Standard Times',
        // Submenu title
        'manage_options',
        // Capability required
        'zmanim_wp_std_times',
        // Submenu slug
        'zmanim_wp_add_std'
    );
    add_submenu_page(
        'zmanim_wp',
        'Early Shabbat Options',
        'Early Shabbat Options',
        'manage_options',
        'zmanim_wp_early_shabbat',
        'zmanim_wp_add_early_shabbat'
    );
    add_submenu_page(
        'zmanim_wp',
        'Secondary Times',
        'Secondary Times',
        'manage_options',
        'zmanim_wp_secondary',
        'zmanim_wp_add_secondary'
    );
    add_submenu_page(
        'zmanim_wp',
        'Full Year Display',
        'Full Year Display',
        'manage_options',
        'zmanim_wp_full_year',
        'zmanim_wp_add_full_year'
    );
    add_submenu_page(
        'zmanim_wp',
        'Transliterations',
        'Transliterations',
        'manage_options',
        'zmanim_wp_transliterations',
        'zmanim_wp_add_transliterations'
    );
    add_submenu_page(
        'zmanim_wp',
        'About zmanim-wp',
        'About zmanim-wp',
        'manage_options',
        'zmanim_wp_about',
        'zmanim_wp_add_about'
    );
    // Create additional options pages
    add_action( 'admin_init', 'zmanim_wp_update_general' );
    add_action( 'admin_init', 'zmanim_wp_update_std' );
    add_action( 'admin_init', 'zmanim_wp_update_early' );
    add_action( 'admin_init', 'zmanim_wp_update_secondary' );
    add_action( 'admin_init', 'zmanim_wp_update_fullyear' );
    add_action( 'admin_init', 'zmanim_wp_update_transliterations' );
    # Nothing on the About page to update
}

// Create function to register plugin settings in the database
function zmanim_wp_update_general() {
    $settings = array(
        'wpkz_tzone',
        'wpkz_lat',
        'wpkz_long',
        'wpkz_location'
    );
    foreach ( $settings as $setting ) {
        register_setting( 'zmanim_wp-settings_general', $setting, array(
            'type'              => 'string',
            'sanitize_callback' => 'sanitize_text_field',
        ) );
    }
# special sanitize for molad, chodesh, and announcements to allow html
    register_setting( 'zmanim_wp-settings_general', 'wpkz_molad', array(
        'type'              => 'string',
        'sanitize_callback' => 'wp_kses_post',
    ) );

    register_setting( 'zmanim_wp-settings_general', 'wpkz_chodesh', array(
        'type'              => 'string',
        'sanitize_callback' => 'wp_kses_post',
    ) );

    register_setting( 'zmanim_wp-settings_general', 'wpkz_announcement1', array(
        'type'              => 'string',
        'sanitize_callback' => 'wp_kses_post',
    ) );
    register_setting( 'zmanim_wp-settings_general', 'wpkz_announcement2', array(
        'type'              => 'string',
        'sanitize_callback' => 'wp_kses_post',
    ) );
    register_setting( 'zmanim_wp-settings_general', 'wpkz_announcement3', array(
        'type'              => 'string',
        'sanitize_callback' => 'wp_kses_post',
    ) );
    register_setting( 'zmanim_wp-settings_general', 'wpkz_announcement4', array(
        'type'              => 'string',
        'sanitize_callback' => 'wp_kses_post',
    ) );
}

function zmanim_wp_update_std() {
    $settings = array(
        'wpkz_candles',
        'wpkz_alot',
        'wpkz_tzait',
        'wpkz_tzait2',
        'wpkz_shaah',
        'wpkz_misheyakir',
        'wpkz_shema',
        'wpkz_shema2',
        'wpkz_tefilla',
        'wpkz_tefilla2',
        'wpkz_chatzot',
        'wpkz_gedola',
        'wpkz_ketana',
        'wpkz_plag',
        'wpkz_plag2',
        'wpkz_bain'
    );
    foreach ( $settings as $setting ) {
        register_setting( 'zmanim_wp-settings_std', $setting, array(
            'type'              => 'string',
            'sanitize_callback' => 'sanitize_text_field',
        ) );
    }
}

function zmanim_wp_update_early() {
    $settings = array(
        'wpkz_early_eng_start_month',
        'wpkz_early_eng_start_day',
        'wpkz_early_eng_end_month',
        'wpkz_early_eng_end_day',
        'wpkz_early_heb_start_month',
        'wpkz_early_heb_start_day',
        'wpkz_early_heb_end_month',
        'wpkz_early_heb_end_day',
        'wpkz_early_plagtime',
        'wpkz_early_shkiatime',
        'wpkz_early_dst',
        'wpkz_early_1',
        'wpkz_early_2',
        'wpkz_early_3',
        'wpkz_early_4',
        'wpkz_early_5',
        'wpkz_early_6',
        'wpkz_early_7',
        'wpkz_early_8',
        'wpkz_early_9',
        'wpkz_early_10',
        'wpkz_reg_1',
        'wpkz_reg_2',
        'wpkz_reg_3',
        'wpkz_reg_4',
        'wpkz_reg_5',
        'wpkz_reg_6',
        'wpkz_reg_7',
        'wpkz_reg_8',
        'wpkz_reg_9',
        'wpkz_reg_10',
        'wpkz_early_reminder_1',
        'wpkz_early_reminder_2',
        'wpkz_early_reminder_3',
        'wpkz_early_reminder_4',
        'wpkz_early_reminder_5',
        'wpkz_early_reminder_6',
        'wpkz_early_reminder_7',
        'wpkz_early_reminder_8',
        'wpkz_early_reminder_9',
        'wpkz_early_reminder_10'
    );
    foreach ( $settings as $setting ) {
        register_setting( 'zmanim_wp-settings_early', $setting, array(
            'type'              => 'string',
            'sanitize_callback' => 'sanitize_text_field',
        ) );
    }
    # end foreach
}

#end zmanim_wp_update_early

function zmanim_wp_update_secondary() {
    $settings = array(
        'wpkz_second_eng_start_month',
        'wpkz_second_eng_start_day',
        'wpkz_second_eng_end_month',
        'wpkz_second_eng_end_day',
        'wpkz_second_heb_start_month',
        'wpkz_second_heb_start_day',
        'wpkz_second_heb_end_month',
        'wpkz_second_heb_end_day',
        'wpkz_second_plagtime',
        'wpkz_second_shkiatime',
        'wpkz_second_dst',
        'wpkz_second_1',
        'wpkz_second_2',
        'wpkz_second_3',
        'wpkz_second_4',
        'wpkz_second_reg_1',
        'wpkz_second_reg_2',
        'wpkz_second_reg_3',
        'wpkz_second_reg_4',
        'wpkz_second_reminder_1',
        'wpkz_second_reminder_2',
        'wpkz_second_reminder_3',
        'wpkz_second_reminder_4'
    );
    foreach ( $settings as $setting ) {
        register_setting( 'zmanim_wp-settings_second', $setting, array(
            'type'              => 'string',
            'sanitize_callback' => 'sanitize_text_field',
        ) );
    }
}
#end zmanim_wp_update_secondary

function zmanim_wp_sanitize_text_array( $input ) {
    if ( !is_array( $input ) ) return [];
    return array_map( 'sanitize_text_field', $input );
}

function zmanim_wp_update_transliterations() {
    register_setting( 'zmanim_wp-settings_translit', 'wpkz_nusach', [
        'type'              => 'string',
        'sanitize_callback' => 'sanitize_text_field',
    ] );
    $settings = [ 'wpkz_parsha_names', 'wpkz_month_names', 'wpkz_holiday_names' ];
    foreach ( $settings as $setting ) {
        register_setting( 'zmanim_wp-settings_translit', $setting, [
            'sanitize_callback' => 'zmanim_wp_sanitize_text_array',
        ] );
    }
}
#end zmanim_wp_update_transliterations

function zmanim_wp_update_fullyear() {
    $settings = array(
        'wpkz_fullyear_start',
        'wpkz_fullyear_cadence',
        'wpkz_fullyear_weekday',
        'wpkz_fullyear_hebyear',
        'wpkz_fullyear_engyear',
        'wpkz_yearly_col1_title',
        'wpkz_yearly_col2_title',
        'wpkz_yearly_col3_title',
        'wpkz_yearly_col4_title',
        'wpkz_yearly_col5_title',
        'wpkz_yearly_col6_title',
        'wpkz_yearly_col7_title',
        'wpkz_yearly_col8_title',
        'wpkz_yearly_col9_title',
        'wpkz_yearly_col10_title',
        'wpkz_yearly_col1',
        'wpkz_yearly_col2',
        'wpkz_yearly_col3',
        'wpkz_yearly_col4',
        'wpkz_yearly_col5',
        'wpkz_yearly_col6',
        'wpkz_yearly_col7',
        'wpkz_yearly_col8',
        'wpkz_yearly_col9',
        'wpkz_yearly_col10'
    );
    foreach ( $settings as $setting ) {
        register_setting( 'zmanim_wp-settings_fullyear', $setting, array(
            'type'              => 'string',
            'sanitize_callback' => 'sanitize_text_field',
        ) );
    }
    #end foreach
}

# end zmanim_wp_update_fullyear
function zmanim_wp_page() {
    // Create the actual Main page
    ?>
  <h1>Zmanim WP Main Options</h1>
  <H2>Current Information</H2>
  <P>
    Date: <?php 
    echo esc_html( gmdate( 'Y-m-d' ) );
    ?><br />
    Location (lat/long): <?php 
    echo esc_html( do_shortcode( "[zman_location]" ) . ": " . do_shortcode( "[zman_lat]" ) . ", " . do_shortcode( "[zman_long]" ) );
    ?><br />
    Time Zone: <?php 
    echo esc_html( do_shortcode( "[zman_tzone]" ) );
    ?><br />
    Sunrise: <?php 
    echo esc_html( do_shortcode( '[zman_sunrise format="h:i:s a"]' ) );
    ?><br />
    Sunset: <?php 
    echo esc_html( do_shortcode( '[zman_sunset format="h:i:s a"]' ) );
    ?><br />
  </P><hr />

  <form method="post" action="options.php">
    <?php 
    settings_fields( 'zmanim_wp-settings_general' );
    ?>
    <?php 
    do_settings_sections( 'zmanim_wp-settings_general' );
    ?>
    <table class="form-table">
       <tr><td>Enter your Time Zone: </td>
        <td><input name="wpkz_tzone" value="<?php 
    echo esc_html( do_shortcode( "[zman_tzone]" ) );
    ?>"/>
        <br/>This must be in the correct <a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">IANA Time Zone format</a>
      </td></tr>

      <tr><td>Enter your location in latitude and longitude: </td>
        <td>LAT: <input name="wpkz_lat" value="<?php 
    echo esc_html( get_option( 'wpkz_lat' ) );
    ?>"/>
            LONG: <input name="wpkz_long" value="<?php 
    echo esc_html( get_option( 'wpkz_long' ) );
    ?>"/>
      </td></tr>

      <tr><td>Give this location a name: </td>
        <td>Location Name: <input name="wpkz_location" value="<?php 
    echo esc_html( get_option( 'wpkz_location' ) );
    ?>"/>
      </td></tr>
      <tr><td>Molad Text: </td>
        <td>Give the text that will appear in front of the molad calculation. HTML tags are permitted.: <input name="wpkz_molad" value="<?php 
    echo esc_html( get_option( 'wpkz_molad' ) );
    ?>"/>
      </td></tr>
      <tr><td>Rosh Chodesh Text: </td>
        <td>Give the text that will appear in front of the Rosh Chodesh calculation. HTML tags are permitted: 
            <input name="wpkz_chodesh" value="<?php echo esc_html( get_option( 'wpkz_chodesh' ) ); ?>"/>
      </td></tr>
      <tr><td>Announcement 1 Text: </td>
        <td>This text will appear wherever you use the zman_announcement1 shortcode. HTML tags are permitted: 
            <textarea name="wpkz_announcement1" rows="10" cols="50" maxlength="5000"><?php echo esc_html(get_option('wpkz_announcement1'));?></textarea>
      </td></tr>      
      <tr><td>Announcement 2 Text: </td>
        <td>This text will appear wherever you use the zman_announcement2 shortcode. HTML tags are permitted: 
            <textarea name="wpkz_announcement2" rows="10" cols="50" maxlength="5000"><?php echo esc_html(get_option('wpkz_announcement2'));?></textarea>
      </td></tr>      
      <tr><td>Announcement 3 Text: </td>
        <td>This text will appear wherever you use the zman_announcement3 shortcode. HTML tags are permitted: 
            <textarea name="wpkz_announcement3" rows="10" cols="50" maxlength="5000"><?php echo esc_html(get_option('wpkz_announcement3'));?></textarea>
      </td></tr>      
      <tr><td>Announcement 4 Text: </td>
        <td>This text will appear wherever you use the zman_announcement4 shortcode. HTML tags are permitted: 
            <textarea name="wpkz_announcement4" rows="10" cols="50" maxlength="5000"><?php echo esc_html(get_option('wpkz_announcement4'));?></textarea>
      </td></tr>      
    </table>
  <?php 
    submit_button();
    ?>
  </form>
<?php 
}

//End zmanim_wp_page
// Callback function for 'Standard Times' submenu
function zmanim_wp_add_std() {
    $selectionAlot = get_option( 'wpkz_alot' );
    $selectionMish = get_option( 'wpkz_misheyakir' );
    $selectionShaah = get_option( 'wpkz_shaah' );
    $selectionShema = get_option( 'wpkz_shema' );
    $selectionShema2 = get_option( 'wpkz_shema2' );
    $selectionTefilla = get_option( 'wpkz_tefilla' );
    $selectionTefilla2 = get_option( 'wpkz_tefilla2' );
    $selectionChatzot = get_option( 'wpkz_chatzot' );
    $selectionGedola = get_option( 'wpkz_gedola' );
    $selectionKetana = get_option( 'wpkz_ketana' );
    $selectionPlag = get_option( 'wpkz_plag' );
    $selectionPlag2 = get_option( 'wpkz_plag2' );
    $selectionBain = get_option( 'wpkz_bain' );
    $selectionTzait = get_option( 'wpkz_tzait' );
    $selectionTzait2 = get_option( 'wpkz_tzait2' );
    $candlesdefault = esc_html( get_option( 'wpkz_candles' ) );
    if ( !$candlesdefault ) {
        update_option( 'wpkz_candles', 18 );
    }
    // Create the standard times page
    ?>
  <h1>Standard Zmanim WP Settings</h1>
  <form method="post" action="options.php">
    <?php 
    settings_fields( 'zmanim_wp-settings_std' );
    ?>
    <?php 
    do_settings_sections( 'zmanim_wp-settings_std' );
    ?>
    <table class="form-table">
      <tr><td>Candle offset (in minutes): </td>
        <td><input type="number" name="wpkz_candles" pattern="[0-6][" maxlength="2" value="<?php 
    echo esc_html( get_option( 'wpkz_candles' ) );
    ?>"/>
          <br /> Sunset: <?php 
    echo esc_html( do_shortcode( '[zman_sunset format="h:i:s a"]' ) );
    ?>
          <br/>Candle time: <?php 
    echo esc_html( do_shortcode( "[zman_candles]" ) );
    ?>
        </td></tr>
      <tr>
        <td>Alot Hashachar:</td>
        <td>
          <select id="wpkz_alot" name="wpkz_alot" value="<?php 
    echo esc_html( $selectionAlot );
    ?>">
            <?php 
    $alotOptions = array(
        "alosHashachar",
        "alos72",
        "alos60",
        "alos72Zmanis",
        "alos96",
        "alos90Zmanis",
        "alos96Zmanis",
        "alos90",
        "alos120",
        "alos120Zmanis",
        "alos26Degrees",
        "alos18Degrees",
        "alos19Degrees",
        "alos19Point8Degrees",
        "alos16Point1Degrees",
        "alosBaalHatanya"
    );
    sort( $alotOptions );
    foreach ( $alotOptions as $option ) {
        ?>
              <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionAlot );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
              <?php 
    }
    ?>
          </select>
          <br />Alot today based on your selection: <?php 
    echo esc_html( do_shortcode( "[zman_alot]" ) );
    ?>
        </td>
      </tr>

      <tr><td>Misheyakir: </td>
        <td><select id="wpkz_misheyakir" name="wpkz_misheyakir" value="">
         <?php 
    $mish_options = array(
        "misheyakir11Point5Degrees",
        "misheyakir11Degrees",
        "misheyakir10Point2Degrees",
        "misheyakir7Point65Degrees",
        "misheyakir9Point5Degrees"
    );
    sort( $mish_options );
    foreach ( $mish_options as $option ) {
        ?>
        <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionMish );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
        <?php 
    }
    ?>
    </select>
        <br />Misheyakir today based on your selection: <?php 
    echo esc_html( do_shortcode( "[zman_misheyakir]" ) );
    ?>
      </td></tr>

      <tr>
      <td>Sha'ah Zmanim:</td>
      <td>
        <select id="wpkz_shaah" name="wpkz_shaah" value="<?php 
    echo esc_html( $selectionShaah );
    ?>">
          <?php 
    $shaahOptions = [
        "shaahZmanis19Point8Degrees",
        "shaahZmanis18Degrees",
        "shaahZmanis26Degrees",
        "shaahZmanis16Point1Degrees",
        "shaahZmanis60Minutes",
        "shaahZmanis72Minutes",
        "shaahZmanis72MinutesZmanis",
        "shaahZmanis90Minutes",
        "shaahZmanis90MinutesZmanis",
        "shaahZmanis96MinutesZmanis",
        "shaahZmanisAteretTorah",
        "shaahZmanisAlos16Point1ToTzais3Point8",
        "shaahZmanisAlos16Point1ToTzais3Point7",
        "shaahZmanis96Minutes",
        "shaahZmanis120Minutes",
        "shaahZmanis120MinutesZmanis",
        "shaahZmanisBaalHatanya",
        "shaahZmanisGra",
        "shaahZmanisMGA"
    ];
    sort( $shaahOptions );
    foreach ( $shaahOptions as $option ) {
        ?>
            <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionShaah );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
            <?php 
    }
    ?>
        </select>
        <br />Sha'ah today based on your selection: <?php 
    echo esc_html( do_shortcode( "[zman_shaah]" ) );
    ?>
      </td>
    </tr>

      <tr>
      <td>Sof Zman Kria Shema:</td>
      <td>
        <select id="wpkz_shema" name="wpkz_shema" value="<?php 
    echo esc_html( $selectionShema );
    ?>">
          <?php 
    $shemaOptions = [
        "sofZmanShmaMGA",
        "sofZmanShmaGra",
        "sofZmanShmaMGA19Point8Degrees",
        "sofZmanShmaMGA16Point1Degrees",
        "sofZmanShmaMGA18Degrees",
        "sofZmanShmaMGA72Minutes",
        "sofZmanShmaMGA72MinutesZmanis",
        "sofZmanShmaMGA90Minutes",
        "sofZmanShmaMGA90MinutesZmanis",
        "sofZmanShmaMGA96Minutes",
        "sofZmanShmaMGA96MinutesZmanis",
        "sofZmanShma3HoursBeforeChatzos",
        "sofZmanShmaMGA120Minutes",
        "sofZmanShmaAlos16Point1ToSunset",
        "sofZmanShmaAlos16Point1ToTzaisGeonim7Point083Degrees",
        "sofZmanShmaKolEliyahu",
        "sofZmanShmaAteretTorah",
        "sofZmanShmaFixedLocal",
        "sofZmanShmaBaalHatanya",
        "sofZmanShmaMGA18DegreesToFixedLocalChatzos",
        "sofZmanShmaMGA16Point1DegreesToFixedLocalChatzos",
        "sofZmanShmaMGA90MinutesToFixedLocalChatzos",
        "sofZmanShmaMGA72MinutesToFixedLocalChatzos",
        "sofZmanShmaGRASunriseToFixedLocalChatzos"
    ];
    sort( $shemaOptions );
    foreach ( $shemaOptions as $option ) {
        ?>
            <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionShema );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
            <?php 
    }
    ?>
        </select>
        <br />Shema today based on your selection: <?php
    echo esc_html( do_shortcode( "[zman_shema]" ) );
    ?>
      </td>
    </tr>

    <tr>
      <td>Sof Zman Kria Shema (2):</td>
      <td>
        <select id="wpkz_shema2" name="wpkz_shema2" value="<?php
    echo esc_html( $selectionShema2 );
    ?>">
          <?php
    $shema2Options = [
        "sofZmanShmaMGA",
        "sofZmanShmaGra",
        "sofZmanShmaMGA19Point8Degrees",
        "sofZmanShmaMGA16Point1Degrees",
        "sofZmanShmaMGA18Degrees",
        "sofZmanShmaMGA72Minutes",
        "sofZmanShmaMGA72MinutesZmanis",
        "sofZmanShmaMGA90Minutes",
        "sofZmanShmaMGA90MinutesZmanis",
        "sofZmanShmaMGA96Minutes",
        "sofZmanShmaMGA96MinutesZmanis",
        "sofZmanShma3HoursBeforeChatzos",
        "sofZmanShmaMGA120Minutes",
        "sofZmanShmaAlos16Point1ToSunset",
        "sofZmanShmaAlos16Point1ToTzaisGeonim7Point083Degrees",
        "sofZmanShmaKolEliyahu",
        "sofZmanShmaAteretTorah",
        "sofZmanShmaFixedLocal",
        "sofZmanShmaBaalHatanya",
        "sofZmanShmaMGA18DegreesToFixedLocalChatzos",
        "sofZmanShmaMGA16Point1DegreesToFixedLocalChatzos",
        "sofZmanShmaMGA90MinutesToFixedLocalChatzos",
        "sofZmanShmaMGA72MinutesToFixedLocalChatzos",
        "sofZmanShmaGRASunriseToFixedLocalChatzos"
    ];
    sort( $shema2Options );
    foreach ( $shema2Options as $option ) {
        ?>
            <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionShema2 );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
            <?php
    }
    ?>
        </select>
        <br />Shema (2) today based on your selection: <?php
    echo esc_html( do_shortcode( "[zman_shema2]" ) );
    ?>
      </td>
    </tr>

    <tr>
      <td>Sof Zman Tefilla:</td>
      <td>
        <select id="wpkz_tefilla" name="wpkz_tefilla" value="<?php 
    echo esc_html( $selectionTefilla );
    ?>">
          <?php 
    $tefillaOptions = [
        "sofZmanTfilaMGA",
        "sofZmanTfilaGra",
        "sofZmanTfilaMGA19Point8Degrees",
        "sofZmanTfilaMGA16Point1Degrees",
        "sofZmanTfilaMGA18Degrees",
        "sofZmanTfilaMGA72Minutes",
        "sofZmanTfilaMGA72MinutesZmanis",
        "sofZmanTfilaMGA90Minutes",
        "sofZmanTfilaMGA90MinutesZmanis",
        "sofZmanTfilaMGA96Minutes",
        "sofZmanTfilaMGA96MinutesZmanis",
        "sofZmanTfilaMGA120Minutes",
        "sofZmanTfila2HoursBeforeChatzos",
        "sofZmanTfilahAteretTorah",
        "sofZmanTfilaFixedLocal",
        "sofZmanTfilaBaalHatanya",
        "sofZmanTfilaGRASunriseToFixedLocalChatzos"
    ];
    sort( $tefillaOptions );
    foreach ( $tefillaOptions as $option ) {
        ?>
            <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionTefilla );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
            <?php 
    }
    ?>
        </select>
        <br />Sof Zman Tefilla today based on your selection: <?php
    echo esc_html( do_shortcode( "[zman_tefilla]" ) );
    ?>
      </td>
    </tr>

    <tr>
      <td>Sof Zman Tefilla (2):</td>
      <td>
        <select id="wpkz_tefilla2" name="wpkz_tefilla2" value="<?php
    echo esc_html( $selectionTefilla2 );
    ?>">
          <?php
    $tefilla2Options = [
        "sofZmanTfilaMGA",
        "sofZmanTfilaGra",
        "sofZmanTfilaMGA19Point8Degrees",
        "sofZmanTfilaMGA16Point1Degrees",
        "sofZmanTfilaMGA18Degrees",
        "sofZmanTfilaMGA72Minutes",
        "sofZmanTfilaMGA72MinutesZmanis",
        "sofZmanTfilaMGA90Minutes",
        "sofZmanTfilaMGA90MinutesZmanis",
        "sofZmanTfilaMGA96Minutes",
        "sofZmanTfilaMGA96MinutesZmanis",
        "sofZmanTfilaMGA120Minutes",
        "sofZmanTfila2HoursBeforeChatzos",
        "sofZmanTfilahAteretTorah",
        "sofZmanTfilaFixedLocal",
        "sofZmanTfilaBaalHatanya",
        "sofZmanTfilaGRASunriseToFixedLocalChatzos"
    ];
    sort( $tefilla2Options );
    foreach ( $tefilla2Options as $option ) {
        ?>
            <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionTefilla2 );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
            <?php
    }
    ?>
        </select>
        <br />Sof Zman Tefilla (2) today based on your selection: <?php
    echo esc_html( do_shortcode( "[zman_tefilla2]" ) );
    ?>
      </td>
    </tr>

     <tr>
        <td>Chatzot:</td>
        <td>
          <select id="wpkz_chatzot" name="wpkz_chatzot" value="<?php 
    echo esc_html( $selectionChatzot );
    ?>">
            <?php 
    $chatzotOptions = array(
        "chatzos",
        "chatzosAsHalfDay",
        "fixedLocalChatzos"
    );
    sort( $chatzotOptions );
    foreach ( $chatzotOptions as $option ) {
        ?>
              <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionChatzot );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
              <?php 
    }
    ?>
          </select>
          <br />Chatzot today based on your selection: <?php 
    echo esc_html( do_shortcode( "[zman_chatzot]" ) );
    ?>
        </td>
      </tr>

    <tr>
      <td>Mincha Gedola:</td>
      <td>
        <select id="wpkz_gedola" name="wpkz_gedola" value="<?php 
    echo esc_html( $selectionGedola );
    ?>">
          <?php 
    $gedolaOptions = [
        "minchaGedola",
        "minchaGedola30Minutes",
        "minchaGedola72Minutes",
        "minchaGedola16Point1Degrees",
        "minchaGedolaAhavatShalom",
        "minchaGedolaGreaterThan30",
        "minchaGedolaAteretTorah",
        "minchaGedolaBaalHatanya",
        "minchaGedolaBaalHatanyaGreaterThan30",
        "minchaGedolaGRAFixedLocalChatzos30Minutes"
    ];
    sort( $gedolaOptions );
    foreach ( $gedolaOptions as $option ) {
        ?>
            <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionGedola );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
            <?php 
    }
    ?>
        </select>
        <br />Mincha Gedola today based on your selection: <?php 
    echo esc_html( do_shortcode( "[zman_gedola]" ) );
    ?>
      </td>
    </tr>

    <tr>
      <td>Mincha Ketana:</td>
      <td>
        <select id="wpkz_ketana" name="wpkz_ketana" value="<?php 
    echo esc_html( $selectionKetana );
    ?>">
          <?php 
    $ketanaOptions = [
        "minchaKetana",
        "minchaKetana16Point1Degrees",
        "minchaKetanaAhavatShalom",
        "minchaKetana72Minutes",
        "minchaKetanaAteretTorah",
        "minchaKetanaBaalHatanya",
        "minchaKetanaGRAFixedLocalChatzosToSunset",
        "samuchLeMinchaKetanaGRA",
        "samuchLeMinchaKetana16Point1Degrees",
        "samuchLeMinchaKetana72Minutes"
    ];
    sort( $ketanaOptions );
    foreach ( $ketanaOptions as $option ) {
        ?>
            <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionKetana );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
            <?php 
    }
    ?>
        </select>
        <br />Mincha Ketana today based on your selection: <?php 
    echo esc_html( do_shortcode( "[zman_ketana]" ) );
    ?>
      </td>
    </tr>

    <tr>
      <td>Plag HaMincha:</td>
      <td>
        <select id="wpkz_plag" name="wpkz_plag" value="<?php 
    echo esc_html( $selectionPlag );
    ?>">
          <?php 
    $plagOptions = [
        "plagHamincha",
        "plagHamincha120MinutesZmanis",
        "plagHamincha120Minutes",
        "plagHamincha60Minutes",
        "plagHamincha72Minutes",
        "plagHamincha90Minutes",
        "plagHamincha96Minutes",
        "plagHamincha96MinutesZmanis",
        "plagHamincha90MinutesZmanis",
        "plagHamincha72MinutesZmanis",
        "plagHamincha16Point1Degrees",
        "plagHamincha19Point8Degrees",
        "plagHamincha26Degrees",
        "plagHamincha18Degrees",
        "plagAlosToSunset",
        "plagAlos16Point1ToTzaisGeonim7Point083Degrees",
        "plagAhavatShalom",
        "plagHaminchaAteretTorah",
        "plagHaminchaBaalHatanya",
        "plagHaminchaGRAFixedLocalChatzosToSunset"
    ];
    sort( $plagOptions );
    foreach ( $plagOptions as $option ) {
        ?>
            <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionPlag );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
            <?php 
    }
    ?>
        </select>
        <br />Plag HaMincha today based on your selection: <?php
    echo esc_html( do_shortcode( "[zman_plag]" ) );
    ?>
      </td>
    </tr>

    <tr>
      <td>Plag HaMincha (2):</td>
      <td>
        <select id="wpkz_plag2" name="wpkz_plag2" value="<?php
    echo esc_html( $selectionPlag2 );
    ?>">
          <?php
    $plag2Options = [
        "plagHamincha",
        "plagHamincha120MinutesZmanis",
        "plagHamincha120Minutes",
        "plagHamincha60Minutes",
        "plagHamincha72Minutes",
        "plagHamincha90Minutes",
        "plagHamincha96Minutes",
        "plagHamincha96MinutesZmanis",
        "plagHamincha90MinutesZmanis",
        "plagHamincha72MinutesZmanis",
        "plagHamincha16Point1Degrees",
        "plagHamincha19Point8Degrees",
        "plagHamincha26Degrees",
        "plagHamincha18Degrees",
        "plagAlosToSunset",
        "plagAlos16Point1ToTzaisGeonim7Point083Degrees",
        "plagAhavatShalom",
        "plagHaminchaAteretTorah",
        "plagHaminchaBaalHatanya",
        "plagHaminchaGRAFixedLocalChatzosToSunset"
    ];
    sort( $plag2Options );
    foreach ( $plag2Options as $option ) {
        ?>
            <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionPlag2 );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
            <?php
    }
    ?>
        </select>
        <br />Plag HaMincha (2) today based on your selection: <?php
    echo esc_html( do_shortcode( "[zman_plag2]" ) );
    ?>
      </td>
    </tr>

    <tr>
      <td>Start of Bain HaShmashot:</td>
      <td>
        <select id="wpkz_bain" name="wpkz_bain" value="<?php 
    echo esc_html( $selectionBain );
    ?>">
          <?php 
    $bainOptions = [
        "bainHashmashosRT13Point24Degrees",
        "bainHashmashosRT58Point5Minutes",
        "bainHashmashosRT13Point5MinutesBefore7Point083Degrees",
        "bainHashmashosRT2Stars",
        "bainHashmashosYereim18Minutes",
        "bainHashmashosYereim3Point05Degrees",
        "bainHashmashosYereim16Point875Minutes",
        "bainHashmashosYereim2Point8Degrees",
        "bainHashmashosYereim13Point5Minutes",
        "bainHashmashosYereim2Point1Degrees"
    ];
    sort( $bainOptions );
    foreach ( $bainOptions as $option ) {
        ?>
            <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionBain );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
            <?php 
    }
    ?>
        </select>
        <br />Bain HaShmashot today based on your selection: <?php 
    echo esc_html( do_shortcode( "[zman_bain]" ) );
    ?>
      </td>
    </tr>

<tr>
  <td>Tzait HaKochavim:</td>
  <td>
    <select id="wpkz_tzait" name="wpkz_tzait" value="<?php 
    echo esc_html( $selectionTzait );
    ?>">
      <?php 
    $tzaitOptions = [
        "tzais",
        "tzais72",
        "tzaisGeonim3Point7Degrees",
        "tzaisGeonim3Point8Degrees",
        "tzaisGeonim5Point95Degrees",
        "tzaisGeonim3Point65Degrees",
        "tzaisGeonim3Point676Degrees",
        "tzaisGeonim4Point61Degrees",
        "tzaisGeonim4Point37Degrees",
        "tzaisGeonim5Point88Degrees",
        "tzaisGeonim4Point8Degrees",
        "tzaisGeonim6Point45Degrees",
        "tzaisGeonim7Point083Degrees",
        "tzaisGeonim7Point67Degrees",
        "tzaisGeonim8Point5Degrees",
        "tzaisGeonim9Point3Degrees",
        "tzaisGeonim9Point75Degrees",
        "tzais60",
        "tzaisAteretTorah",
        "tzais72Zmanis",
        "tzais90Zmanis",
        "tzais96Zmanis",
        "tzais90",
        "tzais120",
        "tzais120Zmanis",
        "tzais16Point1Degrees",
        "tzais26Degrees",
        "tzais18Degrees",
        "tzais19Point8Degrees",
        "tzais96",
        "tzaisBaalHatanya",
        "tzais50"
    ];
    sort( $tzaitOptions );
    foreach ( $tzaitOptions as $option ) {
        ?>
        <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionTzait );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
        <?php 
    }
    ?>
    </select>
    <br />Tzait HaKochavim today based on your selection: <?php
    echo esc_html( do_shortcode( "[zman_tzait]" ) );
    ?>
  </td>
</tr>

<tr>
  <td>Tzait HaKochavim (2):</td>
  <td>
    <select id="wpkz_tzait2" name="wpkz_tzait2" value="<?php
    echo esc_html( $selectionTzait2 );
    ?>">
      <?php
    $tzait2Options = [
        "tzais",
        "tzais72",
        "tzaisGeonim3Point7Degrees",
        "tzaisGeonim3Point8Degrees",
        "tzaisGeonim5Point95Degrees",
        "tzaisGeonim3Point65Degrees",
        "tzaisGeonim3Point676Degrees",
        "tzaisGeonim4Point61Degrees",
        "tzaisGeonim4Point37Degrees",
        "tzaisGeonim5Point88Degrees",
        "tzaisGeonim4Point8Degrees",
        "tzaisGeonim6Point45Degrees",
        "tzaisGeonim7Point083Degrees",
        "tzaisGeonim7Point67Degrees",
        "tzaisGeonim8Point5Degrees",
        "tzaisGeonim9Point3Degrees",
        "tzaisGeonim9Point75Degrees",
        "tzais60",
        "tzaisAteretTorah",
        "tzais72Zmanis",
        "tzais90Zmanis",
        "tzais96Zmanis",
        "tzais90",
        "tzais120",
        "tzais120Zmanis",
        "tzais16Point1Degrees",
        "tzais26Degrees",
        "tzais18Degrees",
        "tzais19Point8Degrees",
        "tzais96",
        "tzaisBaalHatanya",
        "tzais50"
    ];
    sort( $tzait2Options );
    foreach ( $tzait2Options as $option ) {
        ?>
        <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionTzait2 );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
        <?php
    }
    ?>
    </select>
    <br />Tzait HaKochavim (2) today based on your selection: <?php
    echo esc_html( do_shortcode( "[zman_tzait2]" ) );
    ?>
  </td>
</tr>

    </table>
  <?php
    submit_button();
    ?>
  </form>

<?php 
}

//end zmanim_wp_add_std
// Callback function for the 'Early Shabbat Options' submenu
function zmanim_wp_add_early_shabbat() {
    // functions and such go here
    $selectionEngStartMonth = get_option( 'wpkz_early_eng_start_month' );
    $selectionEngStartDay = get_option( 'wpkz_early_eng_start_day' );
    $selectionEngEndMonth = get_option( 'wpkz_early_eng_end_month' );
    $selectionEngEndDay = get_option( 'wpkz_early_eng_end_day' );
    $selectionHebStartMonth = get_option( 'wpkz_early_heb_start_month' );
    $selectionHebStartDay = get_option( 'wpkz_early_heb_start_day' );
    $selectionHebEndMonth = get_option( 'wpkz_early_heb_end_month' );
    $selectionHebEndDay = get_option( 'wpkz_early_heb_end_day' );
    $EngDayOptions = [
        '',
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29,
        30,
        31
    ];
    $EngMonthOptions = [
        '',
        "01-January",
        "02-February",
        "03-March",
        "04-April",
        "05-May",
        "06-June",
        "07-July",
        "08-August",
        "09-September",
        "10-October",
        "11-November",
        "12-December"
    ];
    $HebDayOptions = [
        '',
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        16,
        17,
        18,
        19,
        20,
        21,
        22,
        23,
        24,
        25,
        26,
        27,
        28,
        29
    ];
    $HebMonthOptions = [
        '',
        "01-Nisan",
        "02-Iyar",
        "03-Sivan",
        "04-Tammuz",
        "05-Av",
        "06-Elul",
        "07-Tishrei",
        "08-Heshvan",
        "09-Kislev",
        "10-Tevet",
        "11-Shevat",
        "12-Adar 1",
        "13-Adar 2"
    ];
    ?>
<!-- HTML page stuff goes here -->
<h1>Early Shabbat Options</h1>
<form method="post" action="options.php">
  <?php 
    settings_fields( 'zmanim_wp-settings_early' );
    ?>
  <?php 
    do_settings_sections( 'zmanim_wp-settings_early' );
    ?>

  <H2>Beginning and End of Early Shabbat</H2>
  <P>Check the items that indicate the beginning and end of early Shabbat. If you select more than one, Zmanim WP will start Shabbat when they are ALL true, and end it when ANY are false.</P>

  <P>You can select one or more of the rules to identify when early Shabbat begins and ends. For example: You might want early Shabbat to occur after the end of Passover (21 Nisan) AND after Daylight Savings Time has started (the 2nd Sunday in March). Then you want to stop listing early Shabbat after Sukkot is over (21 Tishrei), but only if Daylight Savings Time is also over (the 1st Sunday in November). </P>

  <H3>English Date</H3>
  <P>When the date is between:&nbsp;
      <select id="eng_start_month" name="wpkz_early_eng_start_month" value="<?php 
    echo esc_html( $selectionEngStartMonth );
    ?>">
        <?php 
    foreach ( $EngMonthOptions as $option ) {
        ?>
          <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionEngStartMonth );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
          <?php 
    }
    ?>
      </select>
      <select id="eng_start_day" name="wpkz_early_eng_start_day" value="<?php 
    echo esc_html( $selectionEngStartDay );
    ?>">
        <?php 
    foreach ( $EngDayOptions as $option ) {
        ?>
          <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionEngStartDay );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
          <?php 
    }
    ?>
      </select>
  &nbsp;and&nbsp;
      <select id="eng_end_month" name="wpkz_early_eng_end_month" value="<?php 
    echo esc_html( $selectionEngEndMonth );
    ?>">
        <?php 
    foreach ( $EngMonthOptions as $option ) {
        ?>
          <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionEngEndMonth );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
          <?php 
    }
    ?>
      </select>
      <select id="eng_end_day" name="wpkz_early_eng_end_day" value="<?php 
    echo esc_html( $selectionEngEndDay );
    ?>">
        <?php 
    foreach ( $EngDayOptions as $option ) {
        ?>
          <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionEngEndDay );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
          <?php 
    }
    ?>
      </select>
    </P>
  
  <H3>Hebrew Date</H3>
  <P>Hebrerw Date: When the date is between:&nbsp;
      <select id="heb_start_month" name="wpkz_early_heb_start_month" value="<?php 
    echo esc_html( $selectionHebStartMonth );
    ?>">
        <?php 
    foreach ( $HebMonthOptions as $option ) {
        ?>
          <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionHebStartMonth );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
          <?php 
    }
    ?>
      </select>
      <select id="heb_start_day" name="wpkz_early_heb_start_day" value="<?php 
    echo esc_html( $selectionHebStartDay );
    ?>">
        <?php 
    foreach ( $HebDayOptions as $option ) {
        ?>
          <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionHebStartDay );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
          <?php 
    }
    ?>
      </select>
  &nbsp;and&nbsp;
      <select id="heb_end_month" name="wpkz_early_heb_end_month" value="<?php 
    echo esc_html( $selectionHebEndMonth );
    ?>">
        <?php 
    foreach ( $HebMonthOptions as $option ) {
        ?>
          <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionHebEndMonth );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
          <?php 
    }
    ?>
      </select>
      <select id="heb_end_day" name="wpkz_early_heb_end_day" value="<?php 
    echo esc_html( $selectionHebEndDay );
    ?>">
        <?php 
    foreach ( $HebDayOptions as $option ) {
        ?>
          <option value="<?php 
        echo esc_html( esc_attr( $option ) );
        ?>" <?php 
        selected( $option, $selectionHebEndDay );
        ?>><?php 
        echo esc_html( esc_html( $option ) );
        ?></option>  
          <?php 
    }
    ?>
      </select>
    </P>

  <H3>Plag HaMincha</H3>
  <P>Plag haMincha: when Plag haMincha is after: 
    <input type="time" id="plagtime" name="wpkz_early_plagtime" value="<?php 
    echo esc_html( get_option( 'wpkz_early_plagtime' ) );
    ?>"/>
  </P>

  <H3>Shkia (Sunset)</H3>
  <P>Shkia: when shkia is after: 
      <input type="time" id="shkiatime" name="wpkz_early_shkiatime" value="<?php 
    echo esc_html( get_option( 'wpkz_early_shkiatime' ) );
    ?>"/>
  </P>

  <H3>Daylight Savings Time</H3>
  <P>Use early Shabbat times during DST (From the 2nd Sunday in March until the 1st Sunday in November)<BR>
    <label for="wpkz_early_dst">Switch to early time during DST:</label>
    <input type="checkbox" id="wpkz_early_dst" name="wpkz_early_dst" value="1" <?php 
    checked( '1', get_option( 'wpkz_early_dst' ) );
    ?>/>
  </P>

  <HR>
  <H2>Early Shabbat Shortcodes</H2>
  <P>In the spaces below, use Zmanim WP shortcodes (the same as you would use on a page, post, or widget) to set up columns each of the early / regular Shabbat combinations. As a reminder, those shortcodes include:<BR>
    [zman_zmandate], [zman_candles], [zman_parsha], [zman_sunrise], [zman_sunset], [zman_alot], [zman_misheyakir], [zman_shema], [zman_chatzot], [zman_plag], [zman_tzait]</P>

  <P>Note that you need to give the shortcode EXACTLy the way you'd use it on a post, page, or widget. Examples:</P>
  <UL>
    <LI> - [zman_plag offset-20 date="Friday"] - 20 minutes before plag for the Friday of the week when the page is being viewed.</LI>
    <LI> - [zman_sunset date="saturday"] - sunset (shkia) for Saturday of that week.</LI>
  </UL>

  <table border="1" width="80%">
     <tr><td>Shortcode</td><td>What is this for?</td><td>Early Calculation</td><td>Regular Calculation</td></tr>
     <tr>
      <td>[zman_early_shabbat_1]</td>
      <td><input name="wpkz_early_reminder_1" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_reminder_1' ) ) );
    ?>"/></td>
      <td><input name="wpkz_early_1" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_1' ) ) );
    ?>"/></td>
      <td><input name="wpkz_reg_1" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_reg_1' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td>[zman_early_shabbat_2]</td>
      <td><input name="wpkz_early_reminder_2" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_reminder_2' ) ) );
    ?>"/></td>
      <td><input name="wpkz_early_2" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_2' ) ) );
    ?>"/></td>
      <td><input name="wpkz_reg_2" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_reg_2' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td>[zman_early_shabbat_3]</td>
      <td><input name="wpkz_early_reminder_3" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_reminder_3' ) ) );
    ?>"/></td>
      <td><input name="wpkz_early_3" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_3' ) ) );
    ?>"/></td>
      <td><input name="wpkz_reg_3" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_reg_3' ) ) );
    ?>"/></td>
    </tr>
      <td>[zman_early_shabbat_4]</td>
      <td><input name="wpkz_early_reminder_4" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_reminder_4' ) ) );
    ?>"/></td>
      <td><input name="wpkz_early_4" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_4' ) ) );
    ?>"/></td>
      <td><input name="wpkz_reg_4" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_reg_4' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td>[zman_early_shabbat_5]</td>
      <td><input name="wpkz_early_reminder_5" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_reminder_5' ) ) );
    ?>"/></td>
      <td><input name="wpkz_early_5" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_5' ) ) );
    ?>"/></td>
      <td><input name="wpkz_reg_5" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_reg_5' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td>[zman_early_shabbat_6]</td>
      <td><input name="wpkz_early_reminder_6" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_reminder_6' ) ) );
    ?>"/></td>
      <td><input name="wpkz_early_6" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_6' ) ) );
    ?>"/></td>
      <td><input name="wpkz_reg_6" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_reg_6' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td>[zman_early_shabbat_7]</td>
      <td><input name="wpkz_early_reminder_7" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_reminder_7' ) ) );
    ?>"/></td>
      <td><input name="wpkz_early_7" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_7' ) ) );
    ?>"/></td>
      <td><input name="wpkz_reg_7" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_reg_7' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td>[zman_early_shabbat_8]</td>
      <td><input name="wpkz_early_reminder_8" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_reminder_8' ) ) );
    ?>"/></td>
      <td><input name="wpkz_early_8" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_8' ) ) );
    ?>"/></td>
      <td><input name="wpkz_reg_8" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_reg_8' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td><div>[zman_early_shabbat_9]</div></td>
      <td><input name="wpkz_early_reminder_9" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_reminder_9' ) ) );
    ?>"/></td>
      <td><input name="wpkz_early_9" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_9' ) ) );
    ?>"/></td>
      <td><input name="wpkz_reg_9" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_reg_9' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td>[zman_early_shabbat_10]</td>
      <td><input name="wpkz_early_reminder_10" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_reminder_10' ) ) );
    ?>"/></td>
      <td><input name="wpkz_early_10" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_early_10' ) ) );
    ?>"/></td>
      <td><input name="wpkz_reg_10" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_reg_10' ) ) );
    ?>"/></td>
    </tr>
  </table>
<?php 
    submit_button();
    ?>
</form>
<!-- end HTML page stuff -->

<P>Current output:</P>
<?php 
    echo "[zman_early_shabbat_1]: " . do_shortcode( '[zman_early_shabbat_1 date="friday"]' ) . "<BR>";
    echo "[zman_early_shabbat_2]: " . do_shortcode( '[zman_early_shabbat_2 date="friday"]' ) . "<BR>";
    echo "[zman_early_shabbat_3]: " . do_shortcode( '[zman_early_shabbat_3 date="friday"]' ) . "<BR>";
    echo "[zman_early_shabbat_4]: " . do_shortcode( '[zman_early_shabbat_4 date="friday"]' ) . "<BR>";
    echo "[zman_early_shabbat_5]: " . do_shortcode( '[zman_early_shabbat_5 date="friday"]' ) . "<BR>";
    echo "[zman_early_shabbat_6]: " . do_shortcode( '[zman_early_shabbat_6 date="friday"]' ) . "<BR>";
    echo "[zman_early_shabbat_7]: " . do_shortcode( '[zman_early_shabbat_7 date="friday"]' ) . "<BR>";
    echo "[zman_early_shabbat_8]: " . do_shortcode( '[zman_early_shabbat_8 date="friday"]' ) . "<BR>";
    echo "[zman_early_shabbat_9]: " . do_shortcode( '[zman_early_shabbat_9 date="friday"]' ) . "<BR>";
    echo "[zman_early_shabbat_10]: " . do_shortcode( '[zman_early_shabbat_10 date="friday"]' ) . "<BR>";
}

//end zmanim_wp_add_early_shabbat

// Callback function for the 'Secondary Times' submenu
function zmanim_wp_add_secondary() {
    $selectionEngStartMonth = get_option( 'wpkz_second_eng_start_month' );
    $selectionEngStartDay = get_option( 'wpkz_second_eng_start_day' );
    $selectionEngEndMonth = get_option( 'wpkz_second_eng_end_month' );
    $selectionEngEndDay = get_option( 'wpkz_second_eng_end_day' );
    $selectionHebStartMonth = get_option( 'wpkz_second_heb_start_month' );
    $selectionHebStartDay = get_option( 'wpkz_second_heb_start_day' );
    $selectionHebEndMonth = get_option( 'wpkz_second_heb_end_month' );
    $selectionHebEndDay = get_option( 'wpkz_second_heb_end_day' );
    $EngDayOptions = [
        '',
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
        11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
        21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
    ];
    $EngMonthOptions = [
        '',
        "01-January", "02-February", "03-March", "04-April",
        "05-May", "06-June", "07-July", "08-August",
        "09-September", "10-October", "11-November", "12-December"
    ];
    $HebDayOptions = [
        '',
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
        11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
        21, 22, 23, 24, 25, 26, 27, 28, 29
    ];
    $HebMonthOptions = [
        '',
        "01-Nisan", "02-Iyar", "03-Sivan", "04-Tammuz",
        "05-Av", "06-Elul", "07-Tishrei", "08-Heshvan",
        "09-Kislev", "10-Tevet", "11-Shevat", "12-Adar 1", "13-Adar 2"
    ];
    ?>
<!-- HTML page stuff goes here -->
<h1>Secondary Times Options</h1>
<form method="post" action="options.php">
  <?php
    settings_fields( 'zmanim_wp-settings_second' );
    ?>
  <?php
    do_settings_sections( 'zmanim_wp-settings_second' );
    ?>

  <H2>Beginning and End of Secondary Zmanim</H2>
  <P>Check the items that indicate the beginning and end of secondary zmanim. If you select more than one, Zmanim WP will activate secondary zmanim when they are ALL true, and end it when ANY are false.</P>

  <P>You can select one or more of the rules to identify when secondary zmanim begins and ends.</P>

  <H3>English Date</H3>
  <P>When the date is between:&nbsp;
      <select id="second_eng_start_month" name="wpkz_second_eng_start_month" value="<?php
    echo esc_html( $selectionEngStartMonth );
    ?>">
        <?php
    foreach ( $EngMonthOptions as $option ) {
        ?>
          <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionEngStartMonth );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
          <?php
    }
    ?>
      </select>
      <select id="second_eng_start_day" name="wpkz_second_eng_start_day" value="<?php
    echo esc_html( $selectionEngStartDay );
    ?>">
        <?php
    foreach ( $EngDayOptions as $option ) {
        ?>
          <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionEngStartDay );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
          <?php
    }
    ?>
      </select>
  &nbsp;and&nbsp;
      <select id="second_eng_end_month" name="wpkz_second_eng_end_month" value="<?php
    echo esc_html( $selectionEngEndMonth );
    ?>">
        <?php
    foreach ( $EngMonthOptions as $option ) {
        ?>
          <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionEngEndMonth );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
          <?php
    }
    ?>
      </select>
      <select id="second_eng_end_day" name="wpkz_second_eng_end_day" value="<?php
    echo esc_html( $selectionEngEndDay );
    ?>">
        <?php
    foreach ( $EngDayOptions as $option ) {
        ?>
          <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionEngEndDay );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
          <?php
    }
    ?>
      </select>
    </P>

  <H3>Hebrew Date</H3>
  <P>Hebrew Date: When the date is between:&nbsp;
      <select id="second_heb_start_month" name="wpkz_second_heb_start_month" value="<?php
    echo esc_html( $selectionHebStartMonth );
    ?>">
        <?php
    foreach ( $HebMonthOptions as $option ) {
        ?>
          <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionHebStartMonth );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
          <?php
    }
    ?>
      </select>
      <select id="second_heb_start_day" name="wpkz_second_heb_start_day" value="<?php
    echo esc_html( $selectionHebStartDay );
    ?>">
        <?php
    foreach ( $HebDayOptions as $option ) {
        ?>
          <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionHebStartDay );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
          <?php
    }
    ?>
      </select>
  &nbsp;and&nbsp;
      <select id="second_heb_end_month" name="wpkz_second_heb_end_month" value="<?php
    echo esc_html( $selectionHebEndMonth );
    ?>">
        <?php
    foreach ( $HebMonthOptions as $option ) {
        ?>
          <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionHebEndMonth );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
          <?php
    }
    ?>
      </select>
      <select id="second_heb_end_day" name="wpkz_second_heb_end_day" value="<?php
    echo esc_html( $selectionHebEndDay );
    ?>">
        <?php
    foreach ( $HebDayOptions as $option ) {
        ?>
          <option value="<?php
        echo esc_html( esc_attr( $option ) );
        ?>" <?php
        selected( $option, $selectionHebEndDay );
        ?>><?php
        echo esc_html( esc_html( $option ) );
        ?></option>
          <?php
    }
    ?>
      </select>
    </P>

  <H3>Plag HaMincha</H3>
  <P>Plag haMincha: when Plag haMincha is after:
    <input type="time" id="second_plagtime" name="wpkz_second_plagtime" value="<?php
    echo esc_html( get_option( 'wpkz_second_plagtime' ) );
    ?>"/>
  </P>

  <H3>Shkia (Sunset)</H3>
  <P>Shkia: when shkia is after:
      <input type="time" id="second_shkiatime" name="wpkz_second_shkiatime" value="<?php
    echo esc_html( get_option( 'wpkz_second_shkiatime' ) );
    ?>"/>
  </P>

  <H3>Daylight Savings Time</H3>
  <P>Use secondary zmanim during DST (From the 2nd Sunday in March until the 1st Sunday in November)<BR>
    <label for="wpkz_second_dst">Switch to secondary zmanim during DST:</label>
    <input type="checkbox" id="wpkz_second_dst" name="wpkz_second_dst" value="1" <?php
    checked( '1', get_option( 'wpkz_second_dst' ) );
    ?>/>
  </P>

  <HR>
  <H2>Secondary Zmanim Shortcodes</H2>
  <P>In the spaces below, use Zmanim WP shortcodes (the same as you would use on a page, post, or widget) to set up columns for each of the secondary / regular zmanim combinations. As a reminder, those shortcodes include:<BR>
    [zman_zmandate], [zman_candles], [zman_parsha], [zman_sunrise], [zman_sunset], [zman_alot], [zman_misheyakir], [zman_shema], [zman_chatzot], [zman_plag], [zman_tzait]</P>

  <P>Note that you need to give the shortcode EXACTLY the way you'd use it on a post, page, or widget. Examples:</P>
  <UL>
    <LI> - [zman_plag offset=-20 date="friday"] - would give 20 minutes before plag haMincha for Friday that week</LI>
    <LI> - [zman_sunset date="saturday"] - sunset (shkia) for Saturday of that week.</LI>
  </UL>

  <table border="1" width="80%">
     <tr><td>Shortcode</td><td>What is this for?</td><td>Secondary Calculation</td><td>Regular Calculation</td></tr>
     <tr>
      <td>[zman_secondary_zmanim_1]</td>
      <td><input name="wpkz_second_reminder_1" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_reminder_1' ) ) );
    ?>"/></td>
      <td><input name="wpkz_second_1" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_1' ) ) );
    ?>"/></td>
      <td><input name="wpkz_second_reg_1" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_reg_1' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td>[zman_secondary_zmanim_2]</td>
      <td><input name="wpkz_second_reminder_2" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_reminder_2' ) ) );
    ?>"/></td>
      <td><input name="wpkz_second_2" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_2' ) ) );
    ?>"/></td>
      <td><input name="wpkz_second_reg_2" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_reg_2' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td>[zman_secondary_zmanim_3]</td>
      <td><input name="wpkz_second_reminder_3" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_reminder_3' ) ) );
    ?>"/></td>
      <td><input name="wpkz_second_3" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_3' ) ) );
    ?>"/></td>
      <td><input name="wpkz_second_reg_3" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_reg_3' ) ) );
    ?>"/></td>
    </tr>
    <tr>
      <td>[zman_secondary_zmanim_4]</td>
      <td><input name="wpkz_second_reminder_4" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_reminder_4' ) ) );
    ?>"/></td>
      <td><input name="wpkz_second_4" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_4' ) ) );
    ?>"/></td>
      <td><input name="wpkz_second_reg_4" value="<?php
    echo esc_html( htmlentities( get_option( 'wpkz_second_reg_4' ) ) );
    ?>"/></td>
    </tr>
  </table>
<?php
    submit_button();
    ?>
</form>
<!-- end HTML page stuff -->

<P>Current output:</P>
<?php
    echo "[zman_secondary_zmanim_1]: " . do_shortcode( '[zman_secondary_zmanim_1 date="friday"]' ) . "<BR>";
    echo "[zman_secondary_zmanim_2]: " . do_shortcode( '[zman_secondary_zmanim_2 date="friday"]' ) . "<BR>";
    echo "[zman_secondary_zmanim_3]: " . do_shortcode( '[zman_secondary_zmanim_3 date="friday"]' ) . "<BR>";
    echo "[zman_secondary_zmanim_4]: " . do_shortcode( '[zman_secondary_zmanim_4 date="friday"]' ) . "<BR>";
}
//end zmanim_wp_add_secondary

// Callback function for the 'Transliterations' submenu
function zmanim_wp_add_transliterations() {
    [ $parshaDefaults, $monthDefaults, $holidayDefaults ] = zmanim_wp_transliteration_defaults();

    $customParsha   = get_option( 'wpkz_parsha_names', [] );
    $customMonths   = get_option( 'wpkz_month_names', [] );
    $customHolidays = get_option( 'wpkz_holiday_names', [] );
    if ( !is_array( $customParsha ) )   $customParsha   = [];
    if ( !is_array( $customMonths ) )   $customMonths   = [];
    if ( !is_array( $customHolidays ) ) $customHolidays = [];

    // Human-readable parsha labels derived from the key name
    $parshaLabel = function( $key ) {
        return ucwords( strtolower( str_replace( '_', ' ', $key ) ) );
    };

    // Human-readable month labels (1-indexed names)
    $monthLabels = [
        'Nissan (1)', 'Iyar (2)', 'Sivan (3)', 'Tammuz (4)',
        'Av (5)', 'Elul (6)', 'Tishrei (7)', 'Cheshvan (8)',
        'Kislev (9)', 'Teves (10)', 'Shevat (11)',
        'Adar (12)', 'Adar II (13)', 'Adar I (14)',
    ];
    ?>
<h1>Transliterations</h1>
<p>Customize the transliterated names used for parshas, months, and holidays.
   Leave any field blank to use the built-in default shown as placeholder text.</p>
<form method="post" action="options.php">
  <?php
    settings_fields( 'zmanim_wp-settings_translit' );
    do_settings_sections( 'zmanim_wp-settings_translit' );
  ?>

  <table class="form-table">
    <tr>
      <td><label for="wpkz_nusach">Check to use alternate transliterations:</label></td>
      <td><input type="checkbox" id="wpkz_nusach" name="wpkz_nusach" value="1" <?php
    checked( '1', get_option( 'wpkz_nusach' ) );
    ?>/></td>
    </tr>
  </table>

  <h2>Parsha Names</h2>
  <table class="form-table widefat striped" style="width:auto">
    <thead><tr><th>Parsha</th><th>Default</th><th>Custom Value</th></tr></thead>
    <tbody>
    <?php foreach ( $parshaDefaults as $key => $default ) :
        if ( $key === 'NONE' ) continue;
        $current = isset( $customParsha[$key] ) ? $customParsha[$key] : '';
    ?>
      <tr>
        <td><?php echo esc_html( $parshaLabel( $key ) ); ?></td>
        <td><em><?php echo esc_html( $default ); ?></em></td>
        <td><input type="text" name="wpkz_parsha_names[<?php echo esc_attr( $key ); ?>]"
             value="<?php echo esc_attr( $current ); ?>"
             placeholder="<?php echo esc_attr( $default ); ?>" size="30" /></td>
      </tr>
    <?php endforeach; ?>
    </tbody>
  </table>

  <h2>Month Names</h2>
  <table class="form-table widefat striped" style="width:auto">
    <thead><tr><th>Month</th><th>Default</th><th>Custom Value</th></tr></thead>
    <tbody>
    <?php foreach ( $monthDefaults as $i => $default ) :
        $current = isset( $customMonths[$i] ) ? $customMonths[$i] : '';
        $label   = isset( $monthLabels[$i] ) ? $monthLabels[$i] : $default;
    ?>
      <tr>
        <td><?php echo esc_html( $label ); ?></td>
        <td><em><?php echo esc_html( $default ); ?></em></td>
        <td><input type="text" name="wpkz_month_names[<?php echo esc_attr( $i ); ?>]"
             value="<?php echo esc_attr( $current ); ?>"
             placeholder="<?php echo esc_attr( $default ); ?>" size="30" /></td>
      </tr>
    <?php endforeach; ?>
    </tbody>
  </table>

  <h2>Holiday Names</h2>
  <table class="form-table widefat striped" style="width:auto">
    <thead><tr><th>#</th><th>Default</th><th>Custom Value</th></tr></thead>
    <tbody>
    <?php foreach ( $holidayDefaults as $i => $default ) :
        $current = isset( $customHolidays[$i] ) ? $customHolidays[$i] : '';
    ?>
      <tr>
        <td><?php echo esc_html( $i ); ?></td>
        <td><em><?php echo esc_html( $default ); ?></em></td>
        <td><input type="text" name="wpkz_holiday_names[<?php echo esc_attr( $i ); ?>]"
             value="<?php echo esc_attr( $current ); ?>"
             placeholder="<?php echo esc_attr( $default ); ?>" size="40" /></td>
      </tr>
    <?php endforeach; ?>
    </tbody>
  </table>

  <?php submit_button(); ?>
</form>
<?php
}
//end zmanim_wp_add_transliterations

// Callback function for the 'Full Year Display' submenu
function zmanim_wp_add_full_year() {
    // functions and such go here
    ?>
<!-- HTML page stuff goes here -->
<h1>Full Year Display Options</h1>
  <form method="post" action="options.php">
  <?php 
    settings_fields( 'zmanim_wp-settings_fullyear' );
    ?>
  <?php 
    do_settings_sections( 'zmanim_wp-settings_fullyear' );
    ?>
  <H2>Starting Date:</H2>
  <P>First, select the starting date and year (leave blank for the current year) for your full year display:</P>
  <P>
      <input type="radio" id="fullyear_start_jan1" name="wpkz_fullyear_start" value="jan1" <?php 
    checked( 'jan1', get_option( 'wpkz_fullyear_start' ) );
    ?> /> 
      <label for="fullyear_start_jan1">Start January 1</label>
      <input name="wpkz_fullyear_engyear" value="<?php 
    echo esc_html( get_option( 'wpkz_fullyear_engyear' ) );
    ?>"/>

      <input type="radio" id="fullyear_start_tish1" name="wpkz_fullyear_start" value="tish1" <?php 
    checked( 'tish1', get_option( 'wpkz_fullyear_start' ) );
    ?> /> 
      <label for="fullyear_start_tish1">Start 1 Tishrei</label>
      <input name="wpkz_fullyear_hebyear" value="<?php 
    echo esc_html( get_option( 'wpkz_fullyear_hebyear' ) );
    ?>"/>

  </P>

  <H2>Weeky or Daily?</H2>
  <P>Next, indicate whether you want the output to give times each day, or each week.</P> 
  <P>If you choose "Weekly", then also select the day of the week to use for time calculations.</P>

  <P>
      <input type="radio" id="fullyear_daily" name="wpkz_fullyear_cadence" value="daily" <?php 
    checked( 'daily', get_option( 'wpkz_fullyear_cadence' ) );
    ?> /> 
      <label for="fullyear_daily">Daily</label>
      <input type="radio" id="fullyear_start_cadence" name="wpkz_fullyear_cadence" value="weekly" <?php 
    checked( 'weekly', get_option( 'wpkz_fullyear_cadence' ) );
    ?> /> 
      <label for="fullyear_weekly">Weekly</label>
  </P>

  <P>
      <input type="radio" id="Sunday" name="wpkz_fullyear_weekday" value="Sunday" <?php 
    checked( 'Sunday', get_option( 'wpkz_fullyear_weekday' ) );
    ?> /> 
      <label for="Sunday">Sunday</label>
      <input type="radio" id="Monday" name="wpkz_fullyear_weekday" value="Monday" <?php 
    checked( 'Monday', get_option( 'wpkz_fullyear_weekday' ) );
    ?> /> 
      <label for="Sunday">Monday</label>
      <input type="radio" id="Tuesday" name="wpkz_fullyear_weekday" value="Tuesday" <?php 
    checked( 'Tuesday', get_option( 'wpkz_fullyear_weekday' ) );
    ?> /> 
      <label for="Sunday">Tuesday</label>
      <input type="radio" id="Wednesday" name="wpkz_fullyear_weekday" value="Wednesday" <?php 
    checked( 'Wednesday', get_option( 'wpkz_fullyear_weekday' ) );
    ?> /> 
      <label for="Sunday">Wednesday</label>
      <input type="radio" id="Thursday" name="wpkz_fullyear_weekday" value="Thursday" <?php 
    checked( 'Thursday', get_option( 'wpkz_fullyear_weekday' ) );
    ?> /> 
      <label for="Sunday">Thursday</label>
      <input type="radio" id="Friday" name="wpkz_fullyear_weekday" value="Friday" <?php 
    checked( 'Friday', get_option( 'wpkz_fullyear_weekday' ) );
    ?> /> 
      <label for="Sunday">Friday</label>
      <input type="radio" id="Saturday" name="wpkz_fullyear_weekday" value="Saturday" <?php 
    checked( 'Saturday', get_option( 'wpkz_fullyear_weekday' ) );
    ?> /> 
      <label for="Sunday">Saturday</label>

<P>NOTE: The weekly list will begin on the day of the week BEFORE the starting date</P>

  <H3>Set up Columns</H3>
  <P>Now use Zmanim WP shortcodes (the same as you would use on a page, post, or widget) to set up columns. As a reminder, those shortcodes include:<BR>
    [zman_zmandate], [zman_candles], [zman_parsha], [zman_sunrise], [zman_sunset], [zman_alot], [zman_misheyakir], [zman_shema], [zman_chatzot], [zman_plag], [zman_tzait]</P>

  <P>Note that you need to give the shortcode EXACTLy the way you'd use it on a post, page, or widget. Examples:</P>
  <UL>
    <LI> - [zman_parsha lang="hebrew"] - would give the Torah portion for that week, in Hebrew</LI>
    <LI> - [zman_sunset] - would give sunset (shkia) for that SPECIFIC day.</LI>
    <LI> - [zman_sunset date="saturday"] - would give sunset (shkia) for Saturday of that week.</LI>
    <LI> - [zman_plag offset=-20 date="friday"] - would give 20 minutes before plag haMincha for Friday that week</LI>
  </UL>
  
  <H2>Columns</H2>
  <style>
table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}
</style>
  <table class="form-table" border="1" >
    <tr><td>
      <input name="wpkz_yearly_col1_title" value="<?php 
    echo esc_html( get_option( 'wpkz_yearly_col1_title' ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col2_title" value="<?php 
    echo esc_html( get_option( 'wpkz_yearly_col2_title' ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col3_title" value="<?php 
    echo esc_html( get_option( 'wpkz_yearly_col3_title' ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col4_title" value="<?php 
    echo esc_html( get_option( 'wpkz_yearly_col4_title' ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col5_title" value="<?php 
    echo esc_html( get_option( 'wpkz_yearly_col5_title' ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col6_title" value="<?php 
    echo esc_html( get_option( 'wpkz_yearly_col6_title' ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col7_title" value="<?php 
    echo esc_html( get_option( 'wpkz_yearly_col7_title' ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col8_title" value="<?php 
    echo esc_html( get_option( 'wpkz_yearly_col8_title' ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col9_title" value="<?php 
    echo esc_html( get_option( 'wpkz_yearly_col9_title' ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col10_title" value="<?php 
    echo esc_html( get_option( 'wpkz_yearly_col10_title' ) );
    ?>"/>
    </td></tr>      
     <tr><td>
      <input name="wpkz_yearly_col1" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_yearly_col1' ) ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col2" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_yearly_col2' ) ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col3" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_yearly_col3' ) ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col4" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_yearly_col4' ) ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col5" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_yearly_col5' ) ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col6" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_yearly_col6' ) ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col7" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_yearly_col7' ) ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col8" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_yearly_col8' ) ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col9" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_yearly_col9' ) ) );
    ?>"/>
    </td><td>
      <input name="wpkz_yearly_col10" value="<?php 
    echo esc_html( htmlentities( get_option( 'wpkz_yearly_col10' ) ) );
    ?>"/>
    </td></tr>
  </table>
<?php 
    submit_button();
    ?>
</form>


<P>Now you can use the shortcode [zman_fullyear] on a page or post to display a full year of times. It will look like this:</P>

<?php 
    echo esc_html( do_shortcode( "[zman_fullyear iteration=6]" ) );
}

//end zmanim_wp_add_full_year

// Callback function for the 'About' submenu
function zmanim_wp_add_about() {
    // functions and such go here
    ?>
  <!-- HTML page stuff goes here -->
  <h1>About Zmanim WP</h1>
<P>Let me clear: I don't want ANYONE paying if they don't want to, or if money is tight. I do this because it makes me happy to help. At the same time, some folks have asked how they can show appreciation. So here are some options if you are so moved.</P>

<UL>
<LI> - Make a donation to <A HREF="https://bkcscle.com/donate/">my synagogue</A></LI>
<LI> - Make a donation to the cause of your choice, and just mention me in your donation note.</LI>
<LI> - Schedule yourself to <A HREF="https://www.redcrossblood.org/give.html/find-drive">donate blood.</A></LI>
<LI> - Buy me <A HREF="https://ko-fi.com/leonadato">Kofi</A></LI>
</UL>

  <P>This plugin lets WordPress administrators configure a variety of shitot (halachic opinions) on time calculation. A series of shortcodes, along with standard options to control the date, formatting, time offset, and more. These shortcodes can be used to display the zmanim (times) in any post, page, widge, or even outbound email coming from the site.</P>

  <P>This plugin would not be possible without the amazing <A HREF="https://github.com/KosherJava/zmanim">kosher java library</A> by <A HREF="https://kosherjava.com/">Eliyahu Hershveld</A>, which has been <A HREF="https://github.com/zachweix/PhpZmanim">ported to PHP</A> by the incredible <A HREF="https://www.linkedin.com/in/zachweix/">Zachary Weixelbaum</A>.</P>

  <P>For detailed usage information, refer to the <A HREF="https://www.adatosystems.com/zmanim-wp/">Zmanim WP page</A> on AdatoSystems.com: <A HREF="https://www.adatosystems.com/zmanim-wp/">https://www.adatosystems.com/zmanim-wp/</A>.</P>
  <!-- end HTML page stuff -->
  <?php 
}

// end zmanim_wp_add_about
// Plugin logic for adding zmanim_wp to posts
if ( !function_exists( "zmanim_wp" ) ) {
    function zmanim_wp(  $content  ) {
        return $content;
    }

    // Apply the zmanim_wp function on our content
    add_filter( 'the_content', 'zmanim_wp' );
}
$shortcodes = [
    'tzone',
    'location',
    'announcement1',
    'announcement2',
    'announcement3',
    'announcement4',
    'lat',
    'long',
    'zmandate',
    'candles',
    'nusach',
    'alot',
    'misheyakir',
    'sunrise',
    'shema',
    'shema2',
    'tefilla',
    'tefilla2',
    'chatzot',
    'gedola',
    'ketana',
    'plag',
    'plag2',
    'bain',
    'sunset',
    'tzait',
    'tzait2',
    'shaah',
    'parsha',
    'chodesh',
    'molad',
    'mevorchim',
    'yomtov',
    'omer',
    'earlyshkia',
    'lateshkia',
    'misheyakirweekly',
    'fullyear',
    'early_shabbat_1',
    'early_shabbat_2',
    'early_shabbat_3',
    'early_shabbat_4',
    'early_shabbat_5',
    'early_shabbat_6',
    'early_shabbat_7',
    'early_shabbat_8',
    'early_shabbat_9',
    'early_shabbat_10',
    'secondary_zmanim_1',
    'secondary_zmanim_2',
    'secondary_zmanim_3',
    'secondary_zmanim_4'
];


foreach ( $shortcodes as $shortcode ) {
    add_shortcode( 'zman_' . $shortcode, $shortcode . '_handler' );
}

// // only add shortcodes after WP starts
// add_action( 'init', 'zmanim_wp_init' );
