function update

This commit is contained in:
magepeopleteam 2021-01-26 06:04:24 +00:00
parent d6769b5f2d
commit b1dee3a551
3 changed files with 46 additions and 53 deletions

View File

@ -167,6 +167,17 @@ if (!class_exists('MAGE_Events_Setting_Controls')) :
'no' => 'No'
)
),
array(
'name' => 'mep_show_product_cat_in_event',
'label' => __('Show Product Category in Event?', 'mage-eventpress'),
'desc' => __('Want to show Product Category in Event Edit Page? If you want set product category based coupon code you need to assign event into Product category, Please set yes only when you need it', 'mage-eventpress'),
'type' => 'select',
'default' => 'no',
'options' => array(
'yes' => 'Yes',
'no' => 'No'
)
),
array(
'name' => 'mep_global_single_template',
'label' => __('Event Details Template', 'mage-eventpress'),

View File

@ -19,7 +19,7 @@ class MP_Event_All_Info_In_One
public function mp_event_all_in_tab()
{
$event_label = mep_get_option('mep_event_label', 'general_setting_sec', 'Events');
$post_id = get_the_id();
$post_id = get_the_id();
?>
<div class="mp_event_all_meta_in_tab mp_event_tab_area">
<div class="mp_tab_menu">
@ -137,7 +137,7 @@ class MP_Event_All_Info_In_One
public function mp_event_venue($post_id)
{
$event_label = mep_get_option('mep_event_label', 'general_setting_sec', 'Events');
$event_label = mep_get_option('mep_event_label', 'general_setting_sec', 'Events');
$values = get_post_custom($post_id);
$user_api = mep_get_option('google-map-api', 'general_setting_sec', '');
$map_type = mep_get_option('mep_google_map_type', 'general_setting_sec', 'iframe');
@ -371,8 +371,6 @@ class MP_Event_All_Info_In_One
jQuery('#show_gmap').html('<iframe id="gmap_canvas" src="https://maps.google.com/maps?q=' + location + '&t=&z=19&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>')
}
})
jQuery('[name="mep_location_venue"]').keypress(function() {
let location = jQuery(this).val();
if (location === '') {
@ -1044,7 +1042,6 @@ function mep_events_ticket_type_save($post_id)
$new[$i]['option_qty_t'] = stripslashes(strip_tags($qty[$i]));
endif;
if ($rsv[$i] != '') :
$new[$i]['option_rsv_t'] = stripslashes(strip_tags($rsv[$i]));
endif;
@ -1065,7 +1062,6 @@ function mep_events_ticket_type_save($post_id)
$ticket_type_list = apply_filters('mep_ticket_type_arr_save', $new);
if (!empty($ticket_type_list) && $ticket_type_list != $old) {
update_post_meta($post_id, 'mep_event_ticket_type', $ticket_type_list);
} elseif (empty($ticket_type_list) && $old) {
@ -1097,9 +1093,9 @@ function mep_events_repeatable_meta_box_save($post_id)
if (get_post_type($post_id) == 'mep_events') {
$old = get_post_meta($post_id, 'mep_events_extra_prices', true);
$new = array();
$names = $_POST['option_name'];
$old = get_post_meta($post_id, 'mep_events_extra_prices', true);
$new = array();
$names = $_POST['option_name'];
$urls = $_POST['option_price'];
$qty = $_POST['option_qty'];
$qty_type = $_POST['option_qty_type'];
@ -1107,7 +1103,6 @@ function mep_events_repeatable_meta_box_save($post_id)
$count = count($names);
for ($i = 0; $i < $count; $i++) {
if ($names[$i] != '') :
$new[$i]['option_name'] = stripslashes(strip_tags($names[$i]));
endif;
@ -1154,7 +1149,6 @@ function mep_event_meta_save($post_id)
return;
}
/**
* If the saving post is event then go on
*/
@ -1204,7 +1198,7 @@ function mep_event_meta_save($post_id)
$latitude = isset($_POST['latitude']) ? strip_tags($_POST['latitude']) : "";
$longitude = isset($_POST['latitude']) ? strip_tags($_POST['longitude']) : "";
$location_name = isset($_POST['location_name']) ? strip_tags($_POST['location_name']) : "";
$location_name = isset($_POST['location_name']) ? strip_tags($_POST['location_name']) : "";
$mep_full_name = isset($_POST['mep_full_name']) ? strip_tags($_POST['mep_full_name']) : "";
$mep_reg_email = isset($_POST['mep_reg_email']) ? strip_tags($_POST['mep_reg_email']) : "";
@ -1220,19 +1214,19 @@ function mep_event_meta_save($post_id)
$mep_event_template = isset($_POST['mep_event_template']) ? strip_tags($_POST['mep_event_template']) : "";
$event_start_datetime = date('Y-m-d H:i:s', strtotime($event_start_date . ' ' . $event_start_time));
$event_end_datetime = date('Y-m-d H:i:s', strtotime($event_end_date . ' ' . $event_end_time));
$md = sizeof($mdate) > 0 ? end($mdate) : array();
$event_expire_datetime = sizeof($md) > 0 ? date('Y-m-d H:i:s', strtotime($md['event_more_end_date'] . ' ' . $md['event_more_end_time'])) : $event_end_datetime;
$event_start_datetime = date('Y-m-d H:i:s', strtotime($event_start_date . ' ' . $event_start_time));
$event_end_datetime = date('Y-m-d H:i:s', strtotime($event_end_date . ' ' . $event_end_time));
$md = sizeof($mdate) > 0 ? end($mdate) : array();
$event_expire_datetime = sizeof($md) > 0 ? date('Y-m-d H:i:s', strtotime($md['event_more_end_date'] . ' ' . $md['event_more_end_time'])) : $event_end_datetime;
$mep_reg_status = isset($_POST['mep_reg_status']) ? strip_tags($_POST['mep_reg_status']) : 'off';
$mep_reset_status = isset($_POST['mep_reset_status']) ? strip_tags($_POST['mep_reset_status']) : 'off';
$mep_available_seat = isset($_POST['mep_available_seat']) ? strip_tags($_POST['mep_available_seat']) : 'off';
$_tax_status = isset($_POST['_tax_status']) ? strip_tags($_POST['_tax_status']) : 'none';
$_tax_class = isset($_POST['_tax_class']) ? strip_tags($_POST['_tax_class']) : '';
$mep_rich_text_status = isset($_POST['mep_rich_text_status']) ? strip_tags($_POST['mep_rich_text_status']) : 'enable';
$mep_reg_status = isset($_POST['mep_reg_status']) ? strip_tags($_POST['mep_reg_status']) : 'off';
$mep_reset_status = isset($_POST['mep_reset_status']) ? strip_tags($_POST['mep_reset_status']) : 'off';
$mep_available_seat = isset($_POST['mep_available_seat']) ? strip_tags($_POST['mep_available_seat']) : 'off';
$_tax_status = isset($_POST['_tax_status']) ? strip_tags($_POST['_tax_status']) : 'none';
$_tax_class = isset($_POST['_tax_class']) ? strip_tags($_POST['_tax_class']) : '';
$mep_rich_text_status = isset($_POST['mep_rich_text_status']) ? strip_tags($_POST['mep_rich_text_status']) : 'enable';
if ($mep_reset_status == 'on') {
mep_reset_event_booking($post_id);

View File

@ -2235,7 +2235,7 @@ if (!function_exists('mep_get_event_upcomming_date')) {
if (!function_exists('mep_on_post_publish')) {
function mep_on_post_publish( $post_id, $post, $update ) {
if ($post->post_type == 'mep_events' && $post->post_status == 'publish' && empty(get_post_meta( $post_id, 'check_if_run_once' ))) {
$product_cat_ids = wp_get_post_terms( $post_id, 'product_cat', array( 'fields' => 'ids' ) );
// ADD THE FORM INPUT TO $new_post ARRAY
$new_post = array(
'post_title' => $post->post_title,
@ -2256,6 +2256,7 @@ if (!function_exists('mep_on_post_publish')) {
update_post_meta( $pid, '_virtual', $product_type );
$terms = array( 'exclude-from-catalog', 'exclude-from-search' );
wp_set_object_terms( $pid, $terms, 'product_visibility' );
wp_set_post_terms( $pid, $product_cat_ids, 'product_cat' );
update_post_meta( $post_id, 'check_if_run_once', true );
}
}
@ -2301,7 +2302,8 @@ if (!function_exists('mep_on_post_publish')) {
if(mep_count_hidden_wc_product($post_id) == 0 || empty(get_post_meta($post_id,'link_wc_product',true))){
mep_create_hidden_event_product($post_id,$event_name);
}
$product_cat_ids = wp_get_post_terms( $post_id, 'product_cat', array( 'fields' => 'ids' ) );
$product_id = get_post_meta($post_id,'link_wc_product',true) ? get_post_meta($post_id,'link_wc_product',true) : $post_id;
set_post_thumbnail( $product_id, get_post_thumbnail_id($post_id) );
wp_publish_post( $product_id );
@ -2317,9 +2319,10 @@ if (!function_exists('mep_on_post_publish')) {
$update__tax_class = update_post_meta( $product_id, '_manage_stock', 'no');
$update__tax_class = update_post_meta( $product_id, '_virtual', $product_type);
$update__tax_class = update_post_meta( $product_id, '_sold_individually', 'yes');
wp_set_post_terms( $product_id, $product_cat_ids, 'product_cat' );
$terms = array( 'exclude-from-catalog', 'exclude-from-search' );
wp_set_object_terms( $product_id, $terms, 'product_visibility' );
// Update post
$my_post = array(
'ID' => $product_id,
@ -3508,29 +3511,14 @@ function mep_fb_get_reg_form_id($event_id){
return $event_reg_form_id;
}
// function mep_get_event_upcomming_date($event_id){
// $date = [];
// $event_start_datetime = get_post_meta($event_id,'event_start_datetime',true);
// $event_end_datetime = get_post_meta($event_id,'event_end_datetime',true);
// $event_multidate = get_post_meta($event_id,'mep_event_more_date',true);
// $event_std[] = array(
// 'event_std' => $event_start_datetime,
// 'event_etd' => $event_end_datetime
// );
// $a = 1;
// foreach($event_multidate as $event_mdt){
// $event_std[$a]['event_std'] = $event_mdt['event_more_start_date'].' '.$event_mdt['event_more_start_time'];
// $event_std[$a]['event_etd'] = $event_mdt['event_more_end_date'].' '.$event_mdt['event_more_end_time'];
// $a++;
// }
// $cn = 0;
// foreach($event_std as $_event_std){
// $std = $_event_std['event_std'];
// $start_date = date('Y-m-d H:i:s',strtotime($_event_std['event_std']));
// $end_date = date('Y-m-d',strtotime($_event_std['event_etd']));
// if (strtotime(current_time('Y-m-d H:i')) < strtotime($std) && $cn == 0) {
// $date = $start_date;
// $cn++;
// }
// }
// }
add_action( 'init', 'mep_show_product_cat_in_event' );
function mep_show_product_cat_in_event() {
$pro_cat_status = mep_get_option( 'mep_show_product_cat_in_event', 'general_setting_sec', 'no');
if($pro_cat_status == 'yes'){
register_taxonomy_for_object_type( 'product_cat', 'mep_events' );
}else{
return null;
}
}