array( 'path' => 'lib/pickadate/picker.js', 'dependencies' => array( 'jquery' ), 'version' => '3.6.1', 'footer' => true, ), 'pickadate-date' => array( 'path' => 'lib/pickadate/picker.date.js', 'dependencies' => array( 'jquery' ), 'version' => '3.6.1', 'footer' => true, ), 'pickadate-time' => array( 'path' => 'lib/pickadate/picker.time.js', 'dependencies' => array( 'jquery' ), 'version' => '3.6.1', 'footer' => true, ), 'pickadate-legacy' => array( 'path' => 'lib/pickadate/legacy.js', 'dependencies' => array( 'jquery' ), 'version' => '3.6.1', 'footer' => true, ), 'sap-scheduler' => array( 'path' => 'js/scheduler.js', 'dependencies' => array( 'jquery' ), 'version' => SAP_VERSION, 'footer' => true, ), // @todo there should be some way to load alternate language .js files // and RTL CSS scripts ); /** * Styles that must be loaded for this component * @since 2.0.a.4 */ public $styles = array( 'pickadate-default' => array( 'path' => 'lib/pickadate/themes/default.css', 'dependencies' => '', 'version' => '3.6.1', 'media' => null, ), 'pickadate-date' => array( 'path' => 'lib/pickadate/themes/default.date.css', 'dependencies' => '', 'version' => '3.6.1', 'media' => null, ), 'pickadate-time' => array( 'path' => 'lib/pickadate/themes/default.time.css', 'dependencies' => '', 'version' => '3.6.1', 'media' => null, ), ); /** * Used for data storage. Not translated */ public $weekdays = array( 'monday' => 'Mo', 'tuesday' => 'Tu', 'wednesday' => 'We', 'thursday' => 'Th', 'friday' => 'Fr', 'saturday' => 'Sa', 'sunday' => 'Su', ); /** * Used for data storage. Not translated */ public $weeks = array( 'first' => '1st', 'second' => '2nd', 'third' => '3rd', 'fourth' => '4th', 'last' => 'last', ); /** * Translateable strings required for this component * @since 2.0.a.8 */ public $strings = array( 'add_rule' => null, // __( 'Add new scheduling rule', 'textdomain' ), 'weekly' => null, // _x( 'Weekly', 'Format of a scheduling rule', 'textdomain' ), 'monthly' => null, // _x( 'Monthly', 'Format of a scheduling rule', 'textdomain' ), 'date' => null, // _x( 'Date', 'Format of a scheduling rule', 'textdomain' ), 'date_range' => null, // _x( 'Date Range', 'Format of a scheduling rule', 'textdomain' ), 'weekdays' => null, // _x( 'Days of the week', 'Label for selecting days of the week in a scheduling rule', 'textdomain' ), 'month_weeks' => null, // _x( 'Weeks of the month', 'Label for selecting weeks of the month in a scheduling rule', 'textdomain' ), 'date_label' => null, // _x( 'Date', 'Label to select a date for a scheduling rule', 'textdomain' ), 'time_label' => null, // _x( 'Time', 'Label to select a time slot for a scheduling rule', 'textdomain' ), 'allday' => null, // _x( 'All day', 'Label to set a scheduling rule to last all day', 'textdomain' ), 'start' => null, // _x( 'Start', 'Label for the starting date/time of a scheduling rule', 'textdomain' ), 'end' => null, // _x( 'End', 'Label for the ending date/time of a scheduling rule', 'textdomain' ), 'set_time_prompt' => null, // _x( 'All day long. Want to %sset a time slot%s?', 'Prompt displayed when a scheduling rule is set without any time restrictions', 'textdomain' ), 'toggle' => null, // _x( 'Open and close this rule', 'Toggle a scheduling rule open and closed', 'textdomain' ), 'delete' => null, // _x( 'Delete rule', 'Delete a scheduling rule', 'textdomain' ), 'delete_schedule' => null, // __( 'Delete scheduling rule', 'textdomain' ), 'never' => null, // _x( 'Never', 'Brief default description of a scheduling rule when no weekdays or weeks are included in the rule', 'textdomain' ), 'weekly_always' => null, // _x( 'Every day', 'Brief default description of a scheduling rule when all the weekdays/weeks are included in the rule', 'textdomain' ), 'monthly_weekdays' => null, // _x( '%s on the %s week of the month', 'Brief default description of a scheduling rule when some weekdays are included on only some weeks of the month. %s should be left alone and will be replaced by a comma-separated list of days and weeks in the following format: M, T, W on the first, second week of the month', 'textdomain' ), 'monthly_weeks' => null, // _x( '%s week of the month', 'Brief default description of a scheduling rule when some weeks of the month are included but all or no weekdays are selected. %s should be left alone and will be replaced by a comma-separated list of weeks in the following format: First, second week of the month', 'textdomain' ), 'all_day' => null, // _x( 'All day', 'Brief default description of a scheduling rule when no times are set', 'textdomain' ), 'before' => null, // _x( 'Ends at', 'Brief default description of a scheduling rule when an end time is set but no start time. If the end time is 6pm, it will read: Ends at 6pm', 'textdomain' ), 'after' => null, // _x( 'Starts at', 'Brief default description of a scheduling rule when a start time is set but no end time. If the start time is 6pm, it will read: Starts at 6pm', 'textdomain' ), 'separator' => null, // _x( '—', 'Separator between times of a scheduling rule', 'textdomain' ), 'date_range_from_today' => null, // _x( 'From Today', 'When Date range start date is not set', 'textdomain' ), 'date_range_upto_indefinite' => null // _x( 'Upto Indefinite', 'When Date range end date is not set', 'textdomain' ), ); /** * Number of minutes between time selection intervals */ public $time_interval = 15; /** * Display format for time selection * See http://amsul.ca/pickadate.js/ for formatting options */ public $time_format = 'h:i A'; /** * Display format for date selection * See http://amsul.ca/pickadate.js/ for formatting options */ public $date_format = 'd mmmm, yyyy'; /** * Boolean to disable the weekday selection option */ public $disable_weekdays = false; /** * Boolean to disable the weeks selection option */ public $disable_weeks = false; /** * Boolean to disable the date selection option */ public $disable_date = false; /** * Boolean to disable the date range selection option */ public $disable_date_range = false; /** * Boolean to disable the time selection option */ public $disable_time = false; /** * Boolean to disable the end time selection option */ public $disable_end_time = false; /** * Boolean to disable multiple rules per component */ public $disable_multiple = false; /** * Schedule summary strings that can be passed to scripts */ public $schedule_summaries = array(); /** * Escape the value to display it in text fields and other input fields * @since 2.0 */ public function esc_value( $val ) { $value = array(); if ( empty( $val ) ) { return $value; } foreach ( $val as $i => $rule ) { if ( !empty( $rule['weekdays'] ) ) { $value[$i]['weekdays'] = array(); foreach ( $rule['weekdays'] as $day => $flag ) { if ( $flag !== '1' ) { continue; } $value[$i]['weekdays'][$day] = $flag; } } if ( !empty( $rule['weeks'] ) ) { $value[$i]['weeks'] = array(); foreach ( $rule['weeks'] as $week => $flag ) { if ( $flag !== '1' ) { continue; } $value[$i]['weeks'][$week] = $flag; } } if ( !empty( $rule['date'] ) ) { $value[$i]['date'] = esc_attr( $rule['date'] ); } if ( !empty( $rule['date_range'] ) ) { $value[$i]['date_range']['start'] = esc_attr( $rule['date_range']['start'] ); $value[$i]['date_range']['end'] = esc_attr( $rule['date_range']['end'] ); } if ( !empty( $rule['time']['start'] ) ) { $value[$i]['time']['start'] = esc_attr( $rule['time']['start'] ); } if ( !empty( $rule['time']['end'] ) ) { $value[$i]['time']['end'] = esc_attr( $rule['time']['end'] ); } } return $value; } /** * Compile and pass configurable variables to the javascript file, so they * can be used when we initialize the pickadate components * @since 2.0 */ public function pass_to_scripts() { // Create a global variable containing settings for all schedulers // that are being rendered on the page. This allows us to pass different // settings for different schedulers on the same page. global $sap_scheduler_settings; if ( !isset( $sap_scheduler_settings ) ) { $sap_scheduler_settings = array(); } $sap_scheduler_settings[ $this->id ] = array( 'time_interval' => $this->time_interval, 'time_format' => $this->time_format, 'date_format' => $this->date_format, 'template' => $this->get_template(), 'weekdays' => $this->weekdays, 'weeks' => $this->weeks, 'disable_weekdays' => $this->disable_weekdays, 'disable_weeks' => $this->disable_weeks, 'disable_date' => $this->disable_date, 'disable_date_range' => $this->disable_date_range, 'disable_time' => $this->disable_time, 'disable_multiple' => $this->disable_multiple, 'summaries' => $this->schedule_summaries, ); // This gets called multiple times, but only the last call is actually // pushed to the script. wp_localize_script( 'sap-scheduler', 'sap_scheduler', array( 'settings' => $sap_scheduler_settings ) ); } /** * Display this setting * @since 2.0 */ public function display_setting() { $this->display_description(); // Define summary text to use when a rule is displayed in brief $this->set_schedule_summaries(); // Pass data to the script files to handle js interactions $this->pass_to_scripts(); ?>
get_date_format( $values ); $time_format = $this->get_time_format( $values ); ob_start(); ?>