-
-
Save smeric/6f0ff8df68fc434dc5971a4b6cb23bbf to your computer and use it in GitHub Desktop.
Show Pickup Time with Google calendar link in the Order Details in the Admin Screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Show Pickup Time with Google calendar link in the Order Details in the Admin Screen | |
*/ | |
if ( class_exists( 'Local_Pickup_Time' ) && class_exists( 'Local_Pickup_Time_Admin' ) ) { | |
// Show Pickup Time in the Order Details in the Admin Screen | |
remove_action( apply_filters( 'local_pickup_time_admin_location', 'woocommerce_admin_order_data_after_billing_address' ), array( Local_Pickup_Time_Admin::get_instance(), 'show_metabox' ), 10, 1 ); | |
add_action( apply_filters( 'local_pickup_time_admin_location', 'woocommerce_admin_order_data_after_billing_address' ), 'my_show_metabox', 10, 1 ); | |
/** | |
* Show Pickup Time with Google calendar link in the Order Details in the Admin Screen | |
* | |
* @param WC_Order $order The order object. | |
* | |
* @return void | |
*/ | |
function my_show_metabox( $order ) { | |
$plugin = Local_Pickup_Time::get_instance(); | |
$order_meta = get_post_custom( $order->get_id() ); | |
$pickup_time = $order_meta[ $plugin->get_order_meta_key() ][0]; | |
$allowed_html = array( | |
'a' => array( | |
'href' => array(), | |
'class' => array(), | |
'style' => array(), | |
'target' => array(), | |
), | |
'p' => array(), | |
'strong' => array(), | |
); | |
$event_title = urlencode( __( 'Pickup Time:', 'woocommerce-local-pickup-time' ) . ' ' . esc_html( Local_Pickup_Time_Admin::get_instance()->pickup_time_select_translatable( $pickup_time ) ) ); | |
$start_date = wp_date( 'Ymd\THi00', $pickup_time ); | |
$end_date = wp_date( 'Ymd\THi00', $pickup_time + 900 ); // 900 seconds = 15 minutes | |
echo wp_kses( '<p><strong>' . __( 'Pickup Time:', 'woocommerce-local-pickup-time' ) . '</strong> ' . esc_html( Local_Pickup_Time_Admin::get_instance()->pickup_time_select_translatable( $pickup_time ) ) . ' <a href="http://www.google.com/calendar/render?action=TEMPLATE&text='.$event_title.'&dates='.$start_date.'/'.$end_date.'&details='.$event_title.'&trp=false" class="dashicons-calendar" style="font-family:\'dashicons\';text-decoration:none;" target="_blank"></a></p>', $allowed_html ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment