725 lines
26 KiB
PHP
725 lines
26 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Mage WooCommerce Event Booking Manager
|
|
* Plugin URI: http://mage-people.com
|
|
* Description: A Complete Event Solution for WordPress by MagePeople..
|
|
* Version: 1.0.6
|
|
* Author: MagePeople Team
|
|
* Author URI: http://www.mage-people.com/
|
|
*/
|
|
|
|
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
|
|
|
|
require_once(dirname(__FILE__) . "/inc/class/mep_settings_api.php");
|
|
require_once(dirname(__FILE__) . "/inc/mep_cpt.php");
|
|
require_once(dirname(__FILE__) . "/inc/mep_tax.php");
|
|
require_once(dirname(__FILE__) . "/inc/mep_event_meta.php");
|
|
require_once(dirname(__FILE__) . "/inc/mep_extra_price.php");
|
|
require_once(dirname(__FILE__) . "/inc/mep_shortcode.php");
|
|
require_once(dirname(__FILE__) . "/inc/admin_setting_panel.php");
|
|
|
|
|
|
|
|
|
|
|
|
// Enqueue Scripts for admin dashboard
|
|
add_action('admin_enqueue_scripts', 'mep_event_admin_scripts');
|
|
function mep_event_admin_scripts() {
|
|
$user_api = mep_get_option( 'google-map-api', 'general_setting_sec', '');
|
|
wp_enqueue_script('jquery-ui-datepicker');
|
|
wp_enqueue_script('jquery-ui-core');
|
|
wp_enqueue_script('jquery-ui-timepicker-addon',plugin_dir_url( __FILE__ ).'js/jquery-ui-timepicker-addon.js',array('jquery','jquery-ui-core'),1,true);
|
|
wp_enqueue_script('jquery-ui-timepicker-addon',plugin_dir_url( __FILE__ ).'js/jquery-ui-sliderAccess.js',array('jquery','jquery-ui-core','jquery-ui-timepicker-addon'),1,true);
|
|
wp_enqueue_style('jquery-ui-timepicker-addon',plugin_dir_url( __FILE__ ).'css/jquery-ui-timepicker-addon.css',array());
|
|
wp_enqueue_style('mep-admin-style',plugin_dir_url( __FILE__ ).'css/admin_style.css',array());
|
|
wp_enqueue_style('mep-jquery-ui-style',plugin_dir_url( __FILE__ ).'css/jquery-ui.css',array());
|
|
|
|
wp_enqueue_script('gmap-scripts',plugin_dir_url( __FILE__ ).'js/mkb-admin.js',array('jquery','jquery-ui-core'),1,true);
|
|
if($user_api){
|
|
wp_enqueue_script('gmap-libs','https://maps.googleapis.com/maps/api/js?key='.$user_api.'&libraries=places&callback=initMap',array('jquery','gmap-scripts'),1,true);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enqueue Scripts for frontend
|
|
add_action('wp_enqueue_scripts', 'mep_event_enqueue_scripts');
|
|
function mep_event_enqueue_scripts() {
|
|
wp_enqueue_style('mep-event-style',plugin_dir_url( __FILE__ ).'css/style.css',array());
|
|
wp_enqueue_style ('font-awesome-css-cdn',"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css",null,1);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Datepicker code for admin dashboard load in footer section
|
|
add_action('admin_footer','mep_admin_footer_script',10,99);
|
|
function mep_admin_footer_script(){
|
|
global $pagenow, $typenow;
|
|
if ($typenow=='mep_events') {
|
|
?>
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function($){
|
|
var startDateTextBox = jQuery('.event_start');
|
|
var endDateTextBox = jQuery('.event_end');
|
|
jQuery.timepicker.datetimeRange(
|
|
startDateTextBox,
|
|
endDateTextBox,
|
|
{
|
|
minInterval: (1000*60*60), // 1hr
|
|
dateFormat: 'dd M yy',
|
|
timeFormat: 'HH:mm',
|
|
start: {}, // start picker options
|
|
end: {} // end picker options
|
|
}
|
|
);
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
|
|
// Class for Linking with Woocommerce with Event Pricing
|
|
add_action('plugins_loaded', 'mep_load_wc_class');
|
|
function mep_load_wc_class() {
|
|
|
|
if ( class_exists('WC_Product_Data_Store_CPT') ) {
|
|
|
|
class MEP_Product_Data_Store_CPT extends WC_Product_Data_Store_CPT {
|
|
|
|
public function read( &$product ) {
|
|
|
|
$product->set_defaults();
|
|
|
|
if ( ! $product->get_id() || ! ( $post_object = get_post( $product->get_id() ) ) || ! in_array( $post_object->post_type, array( 'mep_events', 'product' ) ) ) { // change birds with your post type
|
|
throw new Exception( __( 'Invalid product.', 'woocommerce' ) );
|
|
}
|
|
|
|
$id = $product->get_id();
|
|
|
|
$product->set_props( array(
|
|
'name' => $post_object->post_title,
|
|
'slug' => $post_object->post_name,
|
|
'date_created' => 0 < $post_object->post_date_gmt ? wc_string_to_timestamp( $post_object->post_date_gmt ) : null,
|
|
'date_modified' => 0 < $post_object->post_modified_gmt ? wc_string_to_timestamp( $post_object->post_modified_gmt ) : null,
|
|
'status' => $post_object->post_status,
|
|
'description' => $post_object->post_content,
|
|
'short_description' => $post_object->post_excerpt,
|
|
'parent_id' => $post_object->post_parent,
|
|
'menu_order' => $post_object->menu_order,
|
|
'reviews_allowed' => 'open' === $post_object->comment_status,
|
|
) );
|
|
|
|
$this->read_attributes( $product );
|
|
$this->read_downloads( $product );
|
|
$this->read_visibility( $product );
|
|
$this->read_product_data( $product );
|
|
$this->read_extra_data( $product );
|
|
$product->set_object_read( true );
|
|
}
|
|
|
|
/**
|
|
* Get the product type based on product ID.
|
|
*
|
|
* @since 3.0.0
|
|
* @param int $product_id
|
|
* @return bool|string
|
|
*/
|
|
public function get_product_type( $product_id ) {
|
|
$post_type = get_post_type( $product_id );
|
|
if ( 'product_variation' === $post_type ) {
|
|
return 'variation';
|
|
} elseif ( in_array( $post_type, array( 'mep_events', 'product' ) ) ) { // change birds with your post type
|
|
$terms = get_the_terms( $product_id, 'product_type' );
|
|
return ! empty( $terms ) ? sanitize_title( current( $terms )->name ) : 'simple';
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
add_filter( 'woocommerce_data_stores', 'mep_woocommerce_data_stores' );
|
|
function mep_woocommerce_data_stores ( $stores ) {
|
|
$stores['product'] = 'MEP_Product_Data_Store_CPT';
|
|
return $stores;
|
|
}
|
|
|
|
} else {
|
|
|
|
add_action('admin_notices', 'wc_not_loaded');
|
|
|
|
}
|
|
|
|
|
|
|
|
add_action('woocommerce_before_checkout_form', 'mep_displays_cart_products_feature_image');
|
|
|
|
function mep_displays_cart_products_feature_image() {
|
|
foreach ( WC()->cart->get_cart() as $cart_item ) {
|
|
$item = $cart_item['data'];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Get user information and save to attendee list after order confirmation
|
|
add_action( 'woocommerce_order_status_completed_notification', 'mep_set_event_attendee_data' );
|
|
function mep_set_event_attendee_data( $order_id ) {
|
|
|
|
if ( ! $order_id )
|
|
return;
|
|
|
|
// Getting an instance of the order object
|
|
$order = wc_get_order( $order_id );
|
|
$order_meta = get_post_meta($order_id);
|
|
|
|
|
|
# Iterating through each order items (WC_Order_Item_Product objects in WC 3+)
|
|
foreach ( $order->get_items() as $item_id => $item_values ) {
|
|
$product_id = $item_values->get_product_id();
|
|
$item_data = $item_values->get_data();
|
|
$product_id = $item_data['product_id'];
|
|
$item_quantity = $item_values->get_quantity();
|
|
$product = get_page_by_title( $item_data['name'], OBJECT, 'mep_events' );
|
|
$event_name = $item_data['name'];
|
|
$event_id = $product->ID;
|
|
}
|
|
|
|
|
|
|
|
$first_name = $order_meta['_billing_first_name'][0];
|
|
$last_name = $order_meta['_billing_last_name'][0];
|
|
$company_name = $order_meta['_billing_company'][0];
|
|
$address_1 = $order_meta['_billing_address_1'][0];
|
|
$address_2 = $order_meta['_billing_address_2'][0];
|
|
$city = $order_meta['_billing_city'][0];
|
|
$state = $order_meta['_billing_state'][0];
|
|
$postcode = $order_meta['_billing_postcode'][0];
|
|
$country = $order_meta['_billing_country'][0];
|
|
$email = $order_meta['_billing_email'][0];
|
|
$phone = $order_meta['_billing_phone'][0];
|
|
$billing_intotal = $order_meta['_billing_address_index'][0];
|
|
$payment_method = $order_meta['_payment_method_title'][0];
|
|
|
|
|
|
|
|
|
|
// ADD THE FORM INPUT TO $new_post ARRAY
|
|
$new_post = array(
|
|
'post_title' => $first_name." ".$last_name,
|
|
'post_content' => '',
|
|
'post_category' => array(), // Usable for custom taxonomies too
|
|
'tags_input' => array(),
|
|
'post_status' => 'publish', // Choose: publish, preview, future, draft, etc.
|
|
'post_type' => 'mep_events_attendees' //'post',page' or use a custom post type if you want to
|
|
);
|
|
|
|
//SAVE THE POST
|
|
$pid = wp_insert_post($new_post);
|
|
$update_fname = update_post_meta( $pid, 'ea_first_name', $first_name);
|
|
$update_lname = update_post_meta( $pid, 'ea_last_name', $last_name);
|
|
$update_company = update_post_meta( $pid, 'ea_company_name', $company_name);
|
|
$update_ad1 = update_post_meta( $pid, 'ea_address_1', $address_1);
|
|
$update_ad2 = update_post_meta( $pid, 'ea_address_2', $address_2);
|
|
$update_city = update_post_meta( $pid, 'ea_city', $city);
|
|
$update_state = update_post_meta( $pid, 'ea_state', $state);
|
|
$update_postcode = update_post_meta( $pid, 'ea_postcode', $postcode);
|
|
$update_country = update_post_meta( $pid, 'ea_country', $country);
|
|
$update_email = update_post_meta( $pid, 'ea_email', $email);
|
|
$update_phone = update_post_meta( $pid, 'ea_phone', $phone);
|
|
$update_pym = update_post_meta( $pid, 'ea_payment_method', $payment_method);
|
|
$update_event_name = update_post_meta( $pid, 'ea_event_name', $event_name);
|
|
$update_eid = update_post_meta( $pid, 'ea_event_id', $event_id);
|
|
$update_oid = update_post_meta( $pid, 'ea_order_id', $order_id);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function mep_get_order_info($info,$id){
|
|
$stock_msg = $info;
|
|
$koba = explode("_", $stock_msg);
|
|
return $koba[$id];
|
|
}
|
|
|
|
|
|
add_action('woocommerce_order_status_changed', 'mep_event_seat_management', 10, 4);
|
|
function mep_event_seat_management( $order_id, $from_status, $to_status, $order ) {
|
|
|
|
|
|
// Getting an instance of the order object
|
|
$order = wc_get_order( $order_id );
|
|
$order_meta = get_post_meta($order_id);
|
|
|
|
|
|
# Iterating through each order items (WC_Order_Item_Product objects in WC 3+)
|
|
foreach ( $order->get_items() as $item_id => $item_values ) {
|
|
$product_id = $item_values->get_product_id();
|
|
$item_data = $item_values->get_data();
|
|
$product_id = $item_data['product_id'];
|
|
$item_quantity = $item_values->get_quantity();
|
|
$product = get_page_by_title( $item_data['name'], OBJECT, 'mep_events' );
|
|
$event_name = $item_data['name'];
|
|
$event_id = $product->ID;
|
|
}
|
|
|
|
$mep_total = get_post_meta($event_id,'total_booking', true);
|
|
if($mep_total){
|
|
$mep_total_booking = $mep_total;
|
|
}else{
|
|
$mep_total_booking =0;
|
|
}
|
|
|
|
|
|
|
|
$order_meta_text = "_stock_msg_".$order_id;
|
|
$order_processing = "processing_".$order_id;
|
|
$order_completed = "completed_".$order_id;
|
|
$order_cancelled = "cancelled_".$order_id;
|
|
|
|
|
|
if( $order->has_status( 'processing' )) {
|
|
|
|
update_post_meta( $event_id, $order_meta_text, $order_processing);
|
|
|
|
$mep_stock_msg = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
|
|
$mep_stock_order = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
|
|
|
|
|
|
if($mep_stock_order==$order_id){
|
|
if($mep_stock_msg=='completed'){
|
|
update_post_meta( $event_id, $order_meta_text, $order_processing);
|
|
}
|
|
else{
|
|
update_post_meta( $event_id, 'total_booking', ($mep_total_booking+$item_quantity));
|
|
update_post_meta( $event_id, $order_meta_text, $order_processing);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if($order->has_status( 'cancelled' )) {
|
|
|
|
update_post_meta( $event_id, $order_meta_text, $order_cancelled);
|
|
$mep_stock_msg = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
|
|
$mep_stock_order = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
|
|
|
|
|
|
if($mep_stock_order==$order_id){
|
|
$update_total_booking = update_post_meta( $event_id, 'total_booking', ($mep_total_booking-$item_quantity));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if( $order->has_status( 'completed' )) {
|
|
|
|
// update_post_meta( $event_id, $order_meta_text, $order_completed);
|
|
$mep_stock_msg = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),0);
|
|
$mep_stock_order = mep_get_order_info(get_post_meta($event_id,$order_meta_text, true),1);
|
|
|
|
|
|
if($mep_stock_order==$order_id){
|
|
|
|
if($mep_stock_msg=='processing'){
|
|
update_post_meta( $event_id, $order_meta_text, $order_completed);
|
|
}
|
|
else{
|
|
update_post_meta( $event_id, 'total_booking', ($mep_total_booking+$item_quantity));
|
|
update_post_meta( $event_id, $order_meta_text, $order_completed);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
add_action('restrict_manage_posts', 'mep_filter_post_type_by_taxonomy');
|
|
function mep_filter_post_type_by_taxonomy() {
|
|
global $typenow;
|
|
$post_type = 'mep_events'; // change to your post type
|
|
$taxonomy = 'mep_cat'; // change to your taxonomy
|
|
if ($typenow == $post_type) {
|
|
$selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
|
|
$info_taxonomy = get_taxonomy($taxonomy);
|
|
wp_dropdown_categories(array(
|
|
'show_option_all' => __("Show All {$info_taxonomy->label}"),
|
|
'taxonomy' => $taxonomy,
|
|
'name' => $taxonomy,
|
|
'orderby' => 'name',
|
|
'selected' => $selected,
|
|
'show_count' => true,
|
|
'hide_empty' => true,
|
|
));
|
|
};
|
|
}
|
|
|
|
|
|
|
|
|
|
add_filter('parse_query', 'mep_convert_id_to_term_in_query');
|
|
function mep_convert_id_to_term_in_query($query) {
|
|
global $pagenow;
|
|
$post_type = 'mep_events'; // change to your post type
|
|
$taxonomy = 'mep_cat'; // change to your taxonomy
|
|
$q_vars = &$query->query_vars;
|
|
|
|
if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) {
|
|
$term = get_term_by('id', $q_vars[$taxonomy], $taxonomy);
|
|
$q_vars[$taxonomy] = $term->slug;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
add_filter('parse_query', 'mep_attendee_filter_query');
|
|
function mep_attendee_filter_query($query) {
|
|
global $pagenow;
|
|
$post_type = 'mep_events_attendees';
|
|
$q_vars = &$query->query_vars;
|
|
|
|
if ( $pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == $post_type && isset($_GET['meta_value']) && $_GET['meta_value'] != 0) {
|
|
|
|
$q_vars['meta_key'] = 'ea_event_id';
|
|
$q_vars['meta_value'] = $_GET['meta_value'];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
add_filter( 'post_row_actions', 'mep_remove_row_actions', 10, 1 );
|
|
function mep_remove_row_actions( $actions )
|
|
{
|
|
if( get_post_type() === 'mep_events_attendees' )
|
|
unset( $actions['edit'] );
|
|
// unset( $actions['view'] );
|
|
unset( $actions['trash'] );
|
|
unset( $actions['inline hide-if-no-js'] );
|
|
return $actions;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add the custom columns to the book post type:
|
|
add_filter( 'manage_mep_events_posts_columns', 'mep_set_custom_edit_event_columns' );
|
|
function mep_set_custom_edit_event_columns($columns) {
|
|
|
|
unset( $columns['date'] );
|
|
|
|
$columns['mep_status'] = __( 'Status', 'mep' );
|
|
$columns['mep_atten'] = __( 'Attendees', 'mep' );
|
|
|
|
return $columns;
|
|
}
|
|
|
|
|
|
// Add the data to the custom columns for the book post type:
|
|
add_action( 'manage_mep_events_posts_custom_column' , 'mep_custom_event_column', 10, 2 );
|
|
function mep_custom_event_column( $column, $post_id ) {
|
|
switch ( $column ) {
|
|
case 'mep_status' :
|
|
$values = get_post_custom( $post_id );
|
|
echo mep_get_event_status($values['mep_event_start_date'][0]);
|
|
break;
|
|
|
|
case 'mep_atten' :
|
|
echo '<a class="button button-primary button-large" href="'.get_site_url().'/wp-admin/edit.php?post_type=mep_events_attendees&meta_value='.$post_id.'">Attendees List</a>';
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
// Getting event exprie date & time
|
|
function mep_get_event_status($startdatetime){
|
|
|
|
$time = strtotime($startdatetime);
|
|
$newformat = date('Y-m-d H:i:s',$time);
|
|
$datetime1 = new DateTime();
|
|
$datetime2 = new DateTime($newformat);
|
|
$interval = $datetime1->diff($datetime2);
|
|
// print_r($newformat);
|
|
if(time() > strtotime($newformat)){
|
|
return "<span class=err>Expired</span>";
|
|
}
|
|
else{
|
|
$days = $interval->days;
|
|
$hours = $interval->h;
|
|
$minutes = $interval->i;
|
|
if($days>0){ $dd = $days." days "; }else{ $dd=""; }
|
|
if($hours>0){ $hh = $hours." hours "; }else{ $hh=""; }
|
|
if($minutes>0){ $mm = $minutes." minutes "; }else{ $mm=""; }
|
|
return "<span class='active'>$dd $hh $mm</span>";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get Event Registration Button
|
|
function mep_get_event_reg_btn($post_id){
|
|
|
|
// $event_meta = get_post_meta($post_id, 'mep_event_meta',true);
|
|
$event_meta = get_post_custom(get_the_id());
|
|
$event_expire_date = $event_meta['mep_event_start_date'][0];
|
|
$event_sqi = $event_meta['mep_sqi'][0];
|
|
$event_ecternal_link = '';
|
|
// $event_ecternal_url = $event_meta['ex_reg_url'][0];
|
|
$book_count = get_post_meta($post_id,'total_booking', true);
|
|
|
|
if($book_count){ $total_book = $book_count; }else{ $total_book = 0; }
|
|
$seat_left = ($event_meta['mep_total_seat'][0]- $total_book);
|
|
$time = strtotime($event_expire_date);
|
|
$newformat = date('Y-m-d H:i:s',$time);
|
|
$datetime1 = new DateTime();
|
|
$datetime2 = new DateTime($newformat);
|
|
$interval = $datetime1->diff($datetime2);
|
|
|
|
if(time() > strtotime($newformat)){
|
|
echo "<span class=event-expire-btn>Event Expired</span>";
|
|
}
|
|
elseif($seat_left<=0){
|
|
echo "<span class=event-expire-btn>No Seat Available</span>";
|
|
}
|
|
else{
|
|
$days = $interval->d;
|
|
$hours = $interval->h;
|
|
$minutes = $interval->i;
|
|
if($days>0){ $dd = $days." days "; }else{ $dd=""; }
|
|
if($hours>0){ $hh = $hours." hours "; }else{ $hh=""; }
|
|
if($minutes>0){ $mm = $minutes." minutes "; }else{ $mm=""; }
|
|
|
|
|
|
?>
|
|
<form action="" method='post'>
|
|
<?php do_action('event_kaku_before_reg_btn'); ?>
|
|
|
|
<?php if($event_sqi==1){ ?>
|
|
|
|
<label for="quantity_5a7abbd1bff73" class='qty-ttl'><?php _e('Total'); ?> <input id="quantity_5a7abbd1bff73" class="input-text qty text" step="1" min="1" max="<?php echo ($event_meta['mep_total_seat'][0]- $total_book); ?>" name="quantity" value="1" title="Qty" size="4" pattern="[0-9]*" inputmode="numeric" type="number"></label>
|
|
<?php } ?>
|
|
|
|
|
|
<span id="usertotal"> </span>
|
|
<button type="submit" name="add-to-cart" value="<?php echo esc_attr($post_id); ?>" class="single_add_to_cart_button button alt btn-mep-event-cart">Register This Event </button>
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// Redirect to Checkout after successfuly event registration
|
|
add_filter ('add_to_cart_redirect', 'mep_event_redirect_to_checkout');
|
|
function mep_event_redirect_to_checkout() {
|
|
global $woocommerce;
|
|
$checkout_url = $woocommerce->cart->get_checkout_url();
|
|
return $checkout_url;
|
|
}
|
|
|
|
|
|
|
|
// Add the custom columns to the book post type:
|
|
add_filter( 'manage_mep_events_attendees_posts_columns', 'mep_set_custom_events_attendees_columns' );
|
|
function mep_set_custom_events_attendees_columns($columns) {
|
|
|
|
unset( $columns['title'] );
|
|
unset( $columns['date'] );
|
|
|
|
$columns['mep_uid'] = __( 'Unique ID', 'mep' );
|
|
$columns['mep_fn'] = __( 'Full Name', 'mep' );
|
|
$columns['mep_email'] = __( 'email', 'mep' );
|
|
$columns['mep_phone'] = __( 'Phone', 'mep' );
|
|
$columns['mep_address'] = __( 'Addresss', 'mep' );
|
|
$columns['mep_evnt'] = __( 'Event', 'mep' );
|
|
|
|
return $columns;
|
|
}
|
|
|
|
|
|
// Add the data to the custom columns for the book post type:
|
|
add_action( 'manage_mep_events_attendees_posts_custom_column' , 'mep_events_attendees_column', 10, 2 );
|
|
function mep_events_attendees_column( $column, $post_id ) {
|
|
switch ( $column ) {
|
|
|
|
case 'mep_uid' :
|
|
echo get_post_meta( $post_id, 'ea_order_id', true );
|
|
break;
|
|
|
|
case 'mep_fn' :
|
|
echo get_post_meta( $post_id, 'ea_first_name', true )." ".get_post_meta( $post_id, 'ea_last_name', true );
|
|
break;
|
|
|
|
case 'mep_email' :
|
|
echo get_post_meta( $post_id, 'ea_email', true );
|
|
break;
|
|
|
|
case 'mep_phone' :
|
|
echo get_post_meta( $post_id, 'ea_phone', true );
|
|
break;
|
|
|
|
case 'mep_address' :
|
|
echo get_post_meta( $post_id, 'ea_address_1', true )."<br/>".get_post_meta( $post_id, 'ea_address_2', true )."<br/>".get_post_meta( $post_id, 'ea_state', true ).", ".get_post_meta( $post_id, 'ea_city', true ).", ".get_post_meta( $post_id, 'ea_country', true );
|
|
break;
|
|
|
|
case 'mep_evnt' :
|
|
echo get_post_meta( $post_id, 'ea_event_name', true );
|
|
break;
|
|
|
|
case 'mep_atten' :
|
|
echo '<a class="button button-primary button-large" href="'.get_site_url().'/wp-admin/edit.php?post_type=mep_events_attendees&meta_value='.$post_id.'">Attendees List</a>';
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
function mep_disable_new_posts() {
|
|
// Hide sidebar link
|
|
global $submenu;
|
|
unset($submenu['edit.php?post_type=mep_events_attendees'][10]);
|
|
// // Hide link on listing page
|
|
if (isset($_GET['post_type']) && $_GET['post_type'] == 'mep_events_attendees') {
|
|
echo '<style type="text/css">
|
|
#favorite-actions, .add-new-h2, .tablenav, .page-title-action { display:none; }
|
|
</style>';
|
|
}
|
|
}
|
|
add_action('admin_menu', 'mep_disable_new_posts');
|
|
|
|
|
|
|
|
function mep_load_events_templates($template) {
|
|
global $post;
|
|
|
|
// Is this a "my-custom-post-type" post?
|
|
if ($post->post_type == "mep_events"){
|
|
|
|
//Your plugin path
|
|
$plugin_path = plugin_dir_path( __FILE__ );
|
|
|
|
// The name of custom post type single template
|
|
$template_name = 'templates/single-events.php';
|
|
|
|
// A specific single template for my custom post type exists in theme folder? Or it also doesn't exist in my plugin?
|
|
if($template === get_stylesheet_directory() . '/' . $template_name
|
|
|| !file_exists($plugin_path . $template_name)) {
|
|
|
|
//Then return "single.php" or "single-my-custom-post-type.php" from theme directory.
|
|
return $template;
|
|
}
|
|
|
|
// If not, return my plugin custom post type template.
|
|
return $plugin_path . $template_name;
|
|
}
|
|
|
|
//This is not my custom post type, do nothing with $template
|
|
return $template;
|
|
}
|
|
add_filter('single_template', 'mep_load_events_templates');
|
|
|
|
|
|
|
|
|
|
|
|
add_filter('template_include', 'mep_organizer_set_template');
|
|
function mep_organizer_set_template( $template ){
|
|
|
|
if( is_tax('mep_org')){
|
|
$template = plugin_dir_path( __FILE__ ).'templates/taxonomy-organozer.php';
|
|
}
|
|
|
|
if( is_tax('mep_cat')){
|
|
$template = plugin_dir_path( __FILE__ ).'templates/taxonomy-category.php';
|
|
}
|
|
|
|
return $template;
|
|
}
|
|
|
|
|
|
|
|
function mep_social_share(){
|
|
?>
|
|
<ul class='mep-social-share'>
|
|
<li> <a data-toggle="tooltip" title="" class="facebook" onclick="window.open('https://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>','Facebook','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>" data-original-title="Share on Facebook"><i class="fa fa-facebook"></i></a></li>
|
|
|
|
<li><a data-toggle="tooltip" title="" class="gpuls" onclick="window.open('https://plus.google.com/share?url=<?php the_permalink(); ?>','Google plus','width=585,height=666,left='+(screen.availWidth/2-292)+',top='+(screen.availHeight/2-333)+''); return false;" href="https://plus.google.com/share?url=<?php the_permalink(); ?>" data-original-title="Share on Google Plus"><i class="fa fa-google-plus"></i></a> </li>
|
|
|
|
<li><a data-toggle="tooltip" title="" class="twitter" onclick="window.open('https_ssl_verify://twitter.com/share?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>','Twitter share','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" href="http://twitter.com/share?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" data-original-title="Twittet it"><i class="fa fa-twitter"></i></a></li>
|
|
</ul>
|
|
<?php
|
|
}
|
|
|
|
function mep_calender_date($datetime){
|
|
$time = strtotime($datetime);
|
|
$newdate = date('Ymd',$time);
|
|
$newtime = date('Hi',$time);
|
|
$newformat = $newdate."T".$newtime."00Z";
|
|
return $newformat;
|
|
}
|
|
|
|
|
|
|
|
function mep_add_to_google_calender_link($pid){
|
|
$event = get_post($pid);
|
|
$event_meta = get_post_custom($pid);
|
|
$event_start = $event_meta['mep_event_start_date'][0];
|
|
$event_end = $event_meta['mep_event_end_date'][0];
|
|
|
|
$location = $event_meta['mep_location_venue'][0]." ".$event_meta['mep_street'][0]." ".$event_meta['mep_city'][0]." ".$event_meta['mep_state'][0]." ".$event_meta['mep_postcode'][0]." ".$event_meta['mep_country'][0];
|
|
|
|
|
|
ob_start();
|
|
|
|
|
|
|
|
?>
|
|
<a href="http://www.google.com/calendar/event?
|
|
action=TEMPLATE
|
|
&text=<?php echo $event->post_title; ?>
|
|
&dates=<?php echo mep_calender_date($event_start); ?>/<?php echo mep_calender_date($event_end); ?>
|
|
&details=<?php echo strip_tags($event->post_content); ?>
|
|
&location=<?php echo $location; ?>
|
|
&trp=false
|
|
&sprop=
|
|
&sprop=name:"
|
|
target="_blank" class='mep-add-calender' rel="nofollow"> <i class="fa fa-calendar"></i> Add To Your Calendar</a>
|
|
<?php
|
|
$content = ob_get_clean();
|
|
echo $content;
|
|
}
|
|
|
|
|
|
|
|
|
|
function mep_get_item_name($name){
|
|
$explode_name = explode('_', $name, 2);
|
|
$the_item_name = str_replace('-', ' ', $explode_name[0]);
|
|
return $the_item_name;
|
|
}
|
|
|
|
|
|
|
|
function mep_get_item_price($name){
|
|
$explode_name = explode('_', $name, 2);
|
|
$the_item_name = str_replace('-', ' ', $explode_name[1]);
|
|
return $the_item_name;
|
|
}
|