Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • Docs Home

Packages

  • None
  • Order-Delivery-Date-Pro-for-WooCommerce
    • Admin
      • Edit-Order
      • Non-Sensitive-Data-Capture
      • Settings
        • Custom-Delivery
        • General
        • Google-Calendar-Sync
    • Class-ORDDD-Email-Manager
    • Common-Functions
    • Delivery-Calendar
    • Emails
      • Class-ORDDD-Email-Update-Date
    • Filter
    • Frontend
      • Checkout-Page-Processes
      • ICS-Files-Data
    • Google-Calendar
    • Integration
    • Lang
    • License
    • Plugin-Updates
      • EDD-SL-Plugin-Updater

Classes

  • EDD_SL_Plugin_Updater
  • orddd_additional_settings
  • orddd_admin_delivery_class
  • orddd_appearance_settings
  • orddd_calendar_sync
  • orddd_calendar_sync_settings
  • orddd_class_view_deliveries
  • orddd_common
  • orddd_date_settings
  • orddd_delivery_days_settings
  • ORDDD_Email_Manager
  • ORDDD_Email_Update_Date
  • orddd_filter
  • orddd_holidays_settings
  • orddd_integration
  • orddd_license
  • orddd_process
  • orddd_settings
  • orddd_shipping_based_settings
  • orddd_shipping_days_settings
  • orddd_shipping_multiple_address
  • orddd_time_settings
  • orddd_time_slot_settings
  • ORDDD_View_Delivery_Dates_Table
  • ORDDD_View_Disable_Time_Slots_Table
  • ORDDD_View_Holidays_Table
  • ORDDD_View_Shipping_Settings_Table
  • ORDDD_View_Time_Slots_Table
  • OrdddGcal
  • order_delivery_date
  • TS_Tracker
  • TS_tracking

Functions

  • orddd_get_dateToCal
  • orddd_get_escapeString
  • orddd_t
  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  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 
<?php
/**
 * Order Delivery Date Pro for WooCommerce
 *
 * Send data to the ICS files.
 * 
 * Variables used in this script:
 *   $summary     - text title of the event
 *   $datestart   - the starting date (in seconds since unix epoch)
 *   $dateend     - the ending date (in seconds since unix epoch)
 *   $address     - the event's address
 *   $uri         - the URL of the event (add http://)
 *   $description - text description of the event
 *   $filename    - the name of this file for saving (e.g. my-event-name.ics)
 *
 * Notes:
 *  - the UID should be unique to the event, so in this case I'm just using
 *    uniqid to create a uid, but you could do whatever you'd like.
 *
 *  - iCal requires a date format of "yyyymmddThhiissZ". The "T" and "Z"
 *    characters are not placeholders, just plain ol' characters. The "T"
 *    character acts as a delimeter between the date (yyyymmdd) and the time
 *    (hhiiss), and the "Z" states that the date is in UTC time. Note that if
 *    you don't want to use UTC time, you must prepend your date-time values
 *    with a TZID property. See RFC 5545 section 3.3.5
 *
 *  - The Content-Disposition: attachment; header tells the browser to save/open
 *    the file. The filename param sets the name of the file, so you could set
 *    it as "my-event-name.ics" or something similar.
 *
 *  - Read up on RFC 5545, the iCalendar specification. There is a lot of helpful
 *    info in there, such as formatting rules. There are also many more options
 *    to set, including alarms, invitees, busy status, etc.
 *
 *    https://www.ietf.org/rfc/rfc5545.txt
 * @author      Tyche Softwares
 * @package     Order-Delivery-Date-Pro-for-WooCommerce/Frontend/ICS-Files-Data
 * @since       1.0
 */
 
/**
 * Set the correct headers for this file
 *
 * @since 1.0
 */
header( 'Content-type: text/calendar; charset=utf-8' );
header( 'Content-Disposition: attachment; filename=Calendar-event.ics' );

/**
 * Converts a unix timestamp to an ics-friendly format
 * NOTE: "Z" means that this timestamp is a UTC timestamp. If you need
 * to set a locale, remove the "\Z" and modify DTEND, DTSTAMP and DTSTART
 * with TZID properties (see RFC 5545 section 3.3.5 for info)
 * 
 * @return string Date in the UTC format
 * @since 1.0
 */
function orddd_get_dateToCal( $timestamp ) {
    date_default_timezone_set( "UTC" );
    $time = date( "H:i", $timestamp );
    if( $time != "00:00" && $time != "00:01" ) {
        return date( 'Ymd\THis\Z', $timestamp );
    } else {
        return date( 'Ymd', $timestamp );
    }
}
 
/**
 * Escapes a string of characters
 * 
 * @return string
 * @since 1.0
 */
function orddd_get_escapeString( $string ) {
    return preg_replace( '/([\,;])/', '\\\$1', $string );
}

/**
* Echo out the ics file's contents
*
* @since 1.0
*/

?>
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 13.0 MIMEDIR//EN
VERSION:2.0
CALSCALE:GREGORIAN
X-PRIMARY-CALENDAR:TRUE
BEGIN:VEVENT
LOCATION:<?php echo $_GET[ 'event_location' ] . "\n"; ?>
DTSTART:<?php echo ( orddd_get_dateToCal( $_GET[ 'event_date_start' ] ) )."\n"; ?>
DTEND:<?php echo ( orddd_get_dateToCal( $_GET[ 'event_date_end' ] ) )."\n"; ?>
DTSTAMP:<?php echo ( orddd_get_dateToCal( $_GET[ 'current_time' ] ) )."\n"; ?>
UID:<?php echo ( uniqid() )."\n"; ?>
DESCRIPTION:<?php echo ( orddd_get_escapeString( $_GET[ 'description' ] ) )."\n"; ?>
SUMMARY:<?php echo ( orddd_get_escapeString( $_GET[ 'summary' ] ) )."\n"; ?>
END:VEVENT
END:VCALENDAR
<?php 
exit;
?>
API documentation generated by ApiGen