--- a/eventprime-event-calendar-management/event-prime.php
+++ b/eventprime-event-calendar-management/event-prime.php
@@ -16,7 +16,7 @@
* Plugin Name: EventPrime – Modern Events Calendar, Bookings and Tickets
* Plugin URI: https://theeventprime.com
* Description: Beginner-friendly Events Calendar plugin to create free as well as paid Events. Includes Event Types, Event Sites & Performers too.
- * Version: 4.2.8.4
+ * Version: 4.2.8.5
* Author: EventPrime Event Calendar
* Author URI: https://theeventprime.com/
* License: GPL-2.0+
@@ -35,7 +35,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
-define( 'EVENTPRIME_VERSION', '4.2.8.4' );
+define( 'EVENTPRIME_VERSION', '4.2.8.5' );
define('EM_DB_VERSION',4.0);
if( ! defined( 'EP_PLUGIN_FILE' ) ) {
define( 'EP_PLUGIN_FILE', __FILE__ );
--- a/eventprime-event-calendar-management/includes/class-ep-ajax.php
+++ b/eventprime-event-calendar-management/includes/class-ep-ajax.php
@@ -891,18 +891,23 @@
$event_description = wp_kses_post( stripslashes( $data['em_descriptions'] ) );
- if( isset( $data['event_id'] ) && ! empty( $data['event_id'] ) ) {
- $post_id = $data['event_id'];
- if(empty(get_post($post_id)) || get_post_type($post_id) != 'em_event' ){
- wp_send_json_error( array( 'error' => esc_html__( 'There is some issue with event. Please try later.', 'eventprime-event-calendar-management' ) ) );
- }
- if(!empty($guest_submission) && get_post_meta($post_id, 'em_user_submitted', true) != get_current_user_id()){
- wp_send_json_error( array( 'error' => esc_html__( 'Event does not belong to you.', 'eventprime-event-calendar-management' ) ) );
-
- }
- $post_update = array(
- 'ID' => $post_id,
- 'post_title' => $em_name,
+ if( isset( $data['event_id'] ) && ! empty( $data['event_id'] ) ) {
+ $post_id = absint( $data['event_id'] );
+ if(empty(get_post($post_id)) || get_post_type($post_id) != 'em_event' ){
+ wp_send_json_error( array( 'error' => esc_html__( 'There is some issue with event. Please try later.', 'eventprime-event-calendar-management' ) ) );
+ }
+ $current_user_id = get_current_user_id();
+ $post_author_id = (int) get_post_field( 'post_author', $post_id );
+ $submitted_user_id = (int) get_post_meta( $post_id, 'em_user', true );
+ $can_edit = current_user_can( 'edit_post', $post_id )
+ || ( $current_user_id > 0 && $post_author_id === $current_user_id )
+ || ( $current_user_id > 0 && $submitted_user_id === $current_user_id );
+ if ( ! $can_edit ) {
+ wp_send_json_error( array( 'error' => esc_html__( 'You are not allowed to edit this event.', 'eventprime-event-calendar-management' ) ) );
+ }
+ $post_update = array(
+ 'ID' => $post_id,
+ 'post_title' => $em_name,
'post_content' => $event_description,
);
wp_update_post( $post_update );
@@ -1759,45 +1764,59 @@
}
- public function upload_file_media(){
- if(isset($_FILES["file"]) && !empty($_FILES["file"])){
- $extension = pathinfo( $_FILES["file"]["name"], PATHINFO_EXTENSION );
- if( $extension != 'jpg' && $extension != 'jpeg' && $extension != 'png' && $extension != 'gif' ) {
- wp_send_json_error( array( 'errors' => array( 'Only Image File Allowed.' ) ) );
- }
- $file = $_FILES['file'];
- $filename = $file['name'];
- $tmp_name = $file['tmp_name'];
- $upload_dir = wp_upload_dir();
- if (move_uploaded_file($file["tmp_name"], $upload_dir['path'] . "/" . $filename)) {
- $uploaded_file['file_name'] = $filename;
- $uploaded_file['upload_url'] = $upload_dir['url'] . "/" . $filename;
- $wp_filetype = wp_check_filetype($filename, null );
- $attachment = array(
- 'guid' => $uploaded_file['upload_url'],
- 'post_mime_type' => $wp_filetype['type'],
- 'post_title' => preg_replace( '/.[^.]+$/', '', $filename ),
- 'post_content' => '',
- 'post_status' => 'inherit'
- );
- $attachment_id = wp_insert_attachment( $attachment, $upload_dir['path'] . "/" . $filename );
- if ( ! is_wp_error( $attachment_id ) ) {
- require_once(ABSPATH . "wp-admin" . '/includes/file.php');
- $attachment_data = wp_generate_attachment_metadata( $attachment_id, $upload_dir['path'] . "/" . $filename );
- wp_update_attachment_metadata( $attachment_id, $attachment_data );
- $returnData['success'] = array( 'attachment_id' => $attachment_id );
- }
- }
- else{
- $returnData['errors'] = __($upload_file['error']);
- }
- }
- if( isset( $returnData['success'] ) ) {
- wp_send_json_success( $returnData['success'] );
- }else{
- wp_send_json_success( $returnData );
- }
- }
+ public function upload_file_media(){
+ if ( ! isset( $_POST['security'] ) || ! wp_verify_nonce( $_POST['security'], 'ep-frontend-event-submission-nonce' ) ) {
+ wp_send_json_error( array( 'errors' => array( esc_html__( 'Security check failed.', 'eventprime-event-calendar-management' ) ) ) );
+ }
+
+ if ( empty( $_FILES['file'] ) || empty( $_FILES['file']['name'] ) ) {
+ wp_send_json_error( array( 'errors' => array( esc_html__( 'No file provided.', 'eventprime-event-calendar-management' ) ) ) );
+ }
+
+ $file = $_FILES['file'];
+ $allowed_mimes = array(
+ 'jpg|jpeg|jpe' => 'image/jpeg',
+ 'png' => 'image/png',
+ 'gif' => 'image/gif',
+ );
+ $filecheck = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $allowed_mimes );
+ if ( empty( $filecheck['ext'] ) || empty( $filecheck['type'] ) ) {
+ wp_send_json_error( array( 'errors' => array( esc_html__( 'Only image files are allowed.', 'eventprime-event-calendar-management' ) ) ) );
+ }
+
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
+
+ $upload_overrides = array(
+ 'test_form' => false,
+ 'mimes' => $allowed_mimes,
+ );
+ $uploaded = wp_handle_upload( $file, $upload_overrides );
+ if ( isset( $uploaded['error'] ) ) {
+ wp_send_json_error( array( 'errors' => array( $uploaded['error'] ) ) );
+ }
+
+ $safe_name = sanitize_file_name( $file['name'] );
+ $attachment = array(
+ 'guid' => $uploaded['url'],
+ 'post_mime_type' => $filecheck['type'],
+ 'post_title' => preg_replace( '/.[^.]+$/', '', $safe_name ),
+ 'post_content' => '',
+ 'post_status' => 'inherit'
+ );
+ $attachment_id = wp_insert_attachment( $attachment, $uploaded['file'] );
+ if ( ! is_wp_error( $attachment_id ) ) {
+ $attachment_data = wp_generate_attachment_metadata( $attachment_id, $uploaded['file'] );
+ wp_update_attachment_metadata( $attachment_id, $attachment_data );
+ $returnData['success'] = array( 'attachment_id' => $attachment_id );
+ }
+
+ if ( isset( $returnData['success'] ) ) {
+ wp_send_json_success( $returnData['success'] );
+ } else {
+ wp_send_json_success( $returnData );
+ }
+ }
public function booking_update_status(){
--- a/eventprime-event-calendar-management/includes/class-eventprime-event-calendar-management.php
+++ b/eventprime-event-calendar-management/includes/class-eventprime-event-calendar-management.php
@@ -374,11 +374,11 @@
$this->loader->add_filter( 'handle_bulk_actions-edit-em_booking', $plugin_admin, 'ep_export_booking_bulk_action_handle', 10, 3 );
$this->loader->add_action( 'admin_head-edit.php',$plugin_admin, 'ep_add_booking_export_btn');
- $this->loader->add_action( 'before_delete_post', $plugin_admin, 'ep_before_delete_event_bookings', 99, 2 );
-
- $this->loader->add_action( 'save_post', $plugin_admin, 'ep_save_event_meta_boxes', 1, 2 );
- $this->loader->add_filter( 'wp_insert_post_data', $plugin_admin, 'ep_respect_requested_post_status', 10, 2 );
- $this->loader->add_filter( 'manage_em_event_posts_columns', $plugin_admin, 'ep_filter_event_columns' );
+ $this->loader->add_action( 'before_delete_post', $plugin_admin, 'ep_before_delete_event_bookings', 99, 2 );
+
+ $this->loader->add_action( 'save_post', $plugin_admin, 'ep_save_event_meta_boxes', 1, 2 );
+ $this->loader->add_filter( 'wp_insert_post_data', $plugin_admin, 'ep_respect_requested_post_status', 10, 2 );
+ $this->loader->add_filter( 'manage_em_event_posts_columns', $plugin_admin, 'ep_filter_event_columns' );
$this->loader->add_action( 'manage_em_event_posts_custom_column', $plugin_admin, 'ep_filter_event_columns_content', 10, 2 );
$this->loader->add_filter( 'manage_edit-em_event_sortable_columns',$plugin_admin, 'ep_sortable_event_columns', 10, 1 );
$this->loader->add_action( 'pre_get_posts', $plugin_admin, 'ep_sort_events_date' , 10, 1 );
@@ -665,4 +665,4 @@
}
}
-}
+}
--- a/eventprime-event-calendar-management/includes/class-eventprime-functions.php
+++ b/eventprime-event-calendar-management/includes/class-eventprime-functions.php
@@ -141,15 +141,27 @@
$url = add_query_arg($slug, $id, $url);
}
$enable_seo_urls = $this->ep_get_global_settings('enable_seo_urls');
- if (!empty($enable_seo_urls) && !empty($permalink)) {
- $url = get_permalink($id);
- if ($type == 'term') {
- if (empty($taxonomy)) {
- $taxonomy = get_term($id)->taxonomy;
- }
- $url = get_term_link($id, $taxonomy);
- }
- }
+ if (!empty($enable_seo_urls) && !empty($permalink)) {
+ $url = get_permalink($id);
+ if ($type == 'term') {
+ $term = null;
+ if (empty($taxonomy)) {
+ $term = get_term($id);
+ if (!is_wp_error($term) && $term && !empty($term->taxonomy)) {
+ $taxonomy = $term->taxonomy;
+ }
+ }
+ if (empty($term)) {
+ $term = get_term($id, $taxonomy);
+ }
+ if (!is_wp_error($term) && $term && !empty($term->term_id)) {
+ $term_link = get_term_link($term);
+ if (!is_wp_error($term_link)) {
+ $url = $term_link;
+ }
+ }
+ }
+ }
}
return $url;
}
@@ -14018,6 +14030,13 @@
'done' => true,
);
}
+
+ public function get_event_id_from_ticket_id($ticket_id)
+ {
+ $DBhandler = new EP_DBhandler();
+ $event_id = $DBhandler->get_value('TICKET','event_id', $ticket_id);
+ return $event_id;
+ }
}
--- a/eventprime-event-calendar-management/public/partials/eventprime-event-type.php
+++ b/eventprime-event-calendar-management/public/partials/eventprime-event-type.php
@@ -11,6 +11,7 @@
}
$event_type_id = absint( $atts['id'] );
$term = get_term( $event_type_id );
+ $event_types_data = array();
if( ! empty( $term ) ) {
wp_enqueue_script(
'ep-eventtypes-details',
@@ -26,7 +27,7 @@
)
);
- $event_types_data = array();
+
$event_types_data['term'] = $term;
$event_types_data['event_type'] = $ep_functions->get_single_event_type( $term->term_id );
// upcoming events
@@ -86,6 +87,7 @@
plugin_dir_url( EP_PLUGIN_FILE ) . 'public/css/ep-frontend-views.css',
false, EVENTPRIME_VERSION
);
+ //var_dump($event_type_data);die;
$args = (object)$event_types_data;
?>
<div class="emagic">
--- a/eventprime-event-calendar-management/public/partials/themes/default/events/views/calendar.php
+++ b/eventprime-event-calendar-management/public/partials/themes/default/events/views/calendar.php
@@ -28,12 +28,21 @@
<div class="ep-event-type ep-event-type ep-mr-2 ep-border ep-p-2 ep-rounded-1 ep-lh-0 ep-di-flex ep-align-items-center ep-mb-2">
<?php
$type_id = (int)trim($type_id);
+ $type = get_term( $type_id );
+ if ( is_wp_error( $type ) || ! $type || empty( $type->term_id ) ) {
+ continue;
+ }
+
$type_url = $ep_functions->ep_get_custom_page_url( 'event_types', $type_id, 'event_type', 'term' );
$enable_seo_urls = $ep_functions->ep_get_global_settings( 'enable_seo_urls' );
- if( isset( $enable_seo_urls ) && ! empty( $enable_seo_urls ) ){
- $type_url = get_term_link( $type_id );
+ $permalink_structure = get_option( 'permalink_structure' );
+ if( isset( $enable_seo_urls ) && ! empty( $enable_seo_urls ) && ! empty( $permalink_structure ) ){
+ $term_link = get_term_link( $type ); // pass term object is safer
+ if ( ! is_wp_error( $term_link ) ) {
+ $type_url = $term_link;
+ }
}
- $type = get_term( $type_id );
+
$type_color = get_term_meta( $type->term_id, 'em_color', true );
?>
<a class="ep-outline-width-0" href="<?php echo esc_url( $type_url ); ?>"><?php echo esc_html( $type->name ); ?></a><?php
@@ -49,9 +58,16 @@
<?php
$type_url = $ep_functions->ep_get_custom_page_url( 'event_types', $type['id'], 'event_type', 'term' );
$enable_seo_urls = $ep_functions->ep_get_global_settings( 'enable_seo_urls' );
- if( isset( $enable_seo_urls ) && ! empty( $enable_seo_urls ) ){
- $type_url = get_term_link( $type['id'] );
- }?>
+ $permalink_structure = get_option( 'permalink_structure' );
+ if( isset( $enable_seo_urls ) && ! empty( $enable_seo_urls ) && ! empty( $permalink_structure ) ){
+ $term_link = get_term_link( $type['id'] ); // pass term object is safer
+ if ( ! is_wp_error( $term_link ) ) {
+ $type_url = $term_link;
+ }
+ }
+
+
+ ?>
<a class="ep-outline-width-0" href="<?php echo esc_url( $type_url ); ?>"><?php echo esc_html( $type['name'] ); ?></a><?php
if( ! empty( $type['em_color'] ) && $type['em_color'] != '#' ) {?>
<span style="background-color:<?php echo esc_attr( $type['em_color'] ); ?>" class="ep-ml-1"></span><?php