| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WP Event Manager |
| 4 |
* Plugin URI: https://www.wp-eventmanager.com/ |
| 5 |
* Description: Lightweight, scalable and full-featured event listings & management plugin for managing event listings from the Frontend and Backend. |
| 6 |
* Author: WP Event Manager |
| 7 |
* Author URI: https://www.wp-eventmanager.com |
| 8 |
* Text Domain: wp-event-manager |
| 9 |
* Domain Path: /languages |
| 10 |
* Version: 3.4.1 |
| 11 |
* Since: 1.0.0 |
| 12 |
* Requires at least: 6.5 |
| 13 |
* Tested up to: 7.0 |
| 14 |
* Requires PHP: 7.6 |
| 15 |
* Copyright: 2019 WP Event Manager |
| 16 |
* License: GNU General Public License v3.0 |
| 17 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 18 |
* |
| 19 |
**/ |
| 20 |
|
| 21 |
// Exit if accessed directly |
| 22 |
if(!defined('ABSPATH')) { |
| 23 |
exit; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* A class that defines the main features of the WP event manager plugin. |
| 28 |
*/ |
| 29 |
class WP_Event_Manager { |
| 30 |
|
| 31 |
public $forms; |
| 32 |
public $post_types; |
| 33 |
|
| 34 |
/** |
| 35 |
* The single instance of the class. |
| 36 |
* |
| 37 |
* @var self |
| 38 |
* @since 2.5 |
| 39 |
*/ |
| 40 |
private static $_instance = null; |
| 41 |
|
| 42 |
/** |
| 43 |
* version of plugin. |
| 44 |
* |
| 45 |
* @var plugin version |
| 46 |
* @since 3.1.33 |
| 47 |
*/ |
| 48 |
private static $wpem_verion = '3.4.1'; |
| 49 |
|
| 50 |
|
| 51 |
/** |
| 52 |
* REST API instance. |
| 53 |
* |
| 54 |
* @var WP_Event_Manager_REST_API |
| 55 |
*/ |
| 56 |
private $rest_api = null; |
| 57 |
|
| 58 |
/** |
| 59 |
* Main WP Event Manager Instance. |
| 60 |
* |
| 61 |
* Ensures only one instance of WP Event Manager is loaded or can be loaded. |
| 62 |
* |
| 63 |
* @since 2.5 |
| 64 |
* @static |
| 65 |
* @see WP_Event_Manager() |
| 66 |
* @return self Main instance. |
| 67 |
*/ |
| 68 |
public static function instance() { |
| 69 |
if(is_null(self::$_instance)) { |
| 70 |
self::$_instance = new self(); |
| 71 |
} |
| 72 |
return self::$_instance; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Constructor - get the plugin hooked in and ready. |
| 77 |
* |
| 78 |
* @since 1.0.0 |
| 79 |
*/ |
| 80 |
public function __construct() { |
| 81 |
// Define constants |
| 82 |
define('EVENT_MANAGER_VERSION', self::$wpem_verion); |
| 83 |
define('EVENT_MANAGER_PLUGIN_DIR', untrailingslashit(plugin_dir_path(__FILE__))); |
| 84 |
define('EVENT_MANAGER_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)))); |
| 85 |
|
| 86 |
// Here are all the files for the admin side of WP Event Manager. |
| 87 |
include('includes/wp-event-manager-install.php'); |
| 88 |
include('includes/wp-event-manager-post-types.php'); |
| 89 |
include('includes/wp-event-manager-ajax.php'); |
| 90 |
include('includes/wp-event-manager-geocode.php'); |
| 91 |
include('includes/wp-event-manager-filters.php'); |
| 92 |
include('includes/wp-event-manager-cache-helper.php'); |
| 93 |
include('includes/wp-event-manager-date-time.php'); |
| 94 |
|
| 95 |
// Here is the list of all the shortcodes for WP Event Manager. |
| 96 |
include('shortcodes/wp-event-manager-shortcodes.php'); |
| 97 |
|
| 98 |
// Forms of WP Event manager. |
| 99 |
include('forms/wp-event-manager-forms.php'); |
| 100 |
|
| 101 |
if(is_admin()) { |
| 102 |
include('admin/wp-event-manager-admin.php'); |
| 103 |
} |
| 104 |
|
| 105 |
// In the case of third party support, use this. |
| 106 |
include('external/external.php'); |
| 107 |
|
| 108 |
// Init classes |
| 109 |
$this->forms = WP_Event_Manager_Forms::instance(); |
| 110 |
$this->post_types = WP_Event_Manager_Post_Types::instance(); |
| 111 |
|
| 112 |
// Activation hooks provide ways to perform actions when plugins are activated. |
| 113 |
register_activation_hook(basename(dirname(__FILE__)) . '/' . basename(__FILE__), array($this, 'activate')); |
| 114 |
|
| 115 |
// Hide dashboard pages from non organizer user |
| 116 |
add_action('event_manager_organizer_dashboard_before', array($this, 'wpem_restrict_non_organizer_access_to_dashboard')); |
| 117 |
add_action('event_manager_venue_dashboard_before',array($this, 'wpem_restrict_non_organizer_access_to_dashboard')); |
| 118 |
add_action('event_manager_event_dashboard_before',array($this, 'wpem_restrict_non_organizer_access_to_dashboard')); |
| 119 |
|
| 120 |
// Restrict to add venue, organizer, event form for non organizer user. |
| 121 |
add_action('wp_event_manager_venue_submit_before', array($this, 'wpem_restrict_non_organizer_access_to_dashboard')); |
| 122 |
add_action('wp_event_manager_organizer_submit_before', array($this, 'wpem_restrict_non_organizer_access_to_dashboard')); |
| 123 |
add_action('wp_event_manager_event_submit_before', array($this, 'wpem_restrict_non_organizer_access_to_dashboard')); |
| 124 |
|
| 125 |
// Switch theme |
| 126 |
add_action('after_switch_theme', array('WP_Event_Manager_Ajax', 'add_endpoint'), 10); |
| 127 |
add_action('after_switch_theme', array($this->post_types, 'register_post_types'), 11); |
| 128 |
add_action('after_switch_theme', 'flush_rewrite_rules', 15); |
| 129 |
|
| 130 |
add_action('after_setup_theme', array($this, 'include_template_functions'), 11); |
| 131 |
|
| 132 |
add_action('widgets_init', array($this, 'widgets_init')); |
| 133 |
add_action('wp_enqueue_scripts', array($this, 'frontend_scripts')); |
| 134 |
add_action('admin_init', array($this, 'updater')); |
| 135 |
add_action('wp_logout', array($this, 'cleanup_event_posting_cookies')); |
| 136 |
|
| 137 |
// Defaults for core actions |
| 138 |
add_action('event_manager_notify_new_user', 'wp_event_manager_notify_new_user', 10, 2); |
| 139 |
|
| 140 |
// Duplicate the_content filter for Wp event Manager plugin |
| 141 |
global $wp_embed; |
| 142 |
add_filter('wpem_the_content', array($wp_embed, 'run_shortcode'), 8); |
| 143 |
add_filter('wpem_the_content', array($wp_embed, 'autoembed' ), 8); |
| 144 |
add_filter('wpem_the_content', 'wptexturize' ); |
| 145 |
add_filter('wpem_the_content', 'convert_chars' ); |
| 146 |
add_filter('wpem_the_content', 'wpautop' ); |
| 147 |
add_filter('wpem_the_content', 'shortcode_unautop' ); |
| 148 |
add_filter('wpem_the_content', 'do_shortcode' ); |
| 149 |
add_filter('wpem_the_content', 'wpem_embed_oembed_html' ); |
| 150 |
// Schedule cron events |
| 151 |
self::check_schedule_crons(); |
| 152 |
} |
| 153 |
|
| 154 |
/** |
| 155 |
* Provide ways to perform actions when plugins are activated. |
| 156 |
* |
| 157 |
* @since 1.0.0 |
| 158 |
*/ |
| 159 |
public function activate() { |
| 160 |
WP_Event_Manager_Ajax::add_endpoint(); |
| 161 |
unregister_post_type('event_listing'); |
| 162 |
add_filter('pre_option_event_manager_enable_categories', '__return_true'); |
| 163 |
add_filter('pre_option_event_manager_enable_event_types', '__return_true'); |
| 164 |
$this->post_types->register_post_types(); |
| 165 |
remove_filter('pre_option_event_manager_enable_categories', '__return_true'); |
| 166 |
remove_filter('pre_option_event_manager_enable_event_types', '__return_true'); |
| 167 |
WP_Event_Manager_Install::install(); |
| 168 |
// Show notice after activating plugin |
| 169 |
update_option('event_manager_rating_showcase_admin_notices_dismiss','0'); |
| 170 |
// 3.1.37.1 change field option name |
| 171 |
if(!empty(get_option('event_manager_form_fields', true))) { |
| 172 |
$all_fields = get_option('event_manager_form_fields', true); |
| 173 |
|
| 174 |
if(isset($all_fields) && !empty($all_fields) && is_array($all_fields)) { |
| 175 |
|
| 176 |
// 3.1.37.1 change field option name |
| 177 |
if(isset($all_fields['event']['event_registration_email'])) |
| 178 |
unset($all_fields['event']['event_registration_email']); |
| 179 |
|
| 180 |
update_option('event_manager_submit_event_form_fields', array('event' =>$all_fields['event'])); |
| 181 |
} |
| 182 |
} |
| 183 |
flush_rewrite_rules(); |
| 184 |
} |
| 185 |
|
| 186 |
/** |
| 187 |
* Handle Updates. |
| 188 |
* @since 1.0.0 |
| 189 |
*/ |
| 190 |
public function updater() { |
| 191 |
if(version_compare(EVENT_MANAGER_VERSION, get_option('wp_event_manager_version'), '>')) { |
| 192 |
WP_Event_Manager_Install::update(); |
| 193 |
flush_rewrite_rules(); |
| 194 |
} |
| 195 |
} |
| 196 |
|
| 197 |
/** |
| 198 |
* Load the functions files for WP Event Manager. |
| 199 |
* @since 1.0.0 |
| 200 |
*/ |
| 201 |
public function include_template_functions() { |
| 202 |
include('wp-event-manager-functions.php'); |
| 203 |
include('wp-event-manager-template.php'); |
| 204 |
} |
| 205 |
|
| 206 |
/** |
| 207 |
* Manage WordPress widgets. |
| 208 |
* @since 1.0.0 |
| 209 |
*/ |
| 210 |
public function widgets_init() { |
| 211 |
include_once('widgets/wp-event-manager-widgets.php'); |
| 212 |
} |
| 213 |
|
| 214 |
/** |
| 215 |
* Format array for the datepicker. |
| 216 |
* |
| 217 |
* WordPress stores the locale information in an array with a alphanumeric index, and |
| 218 |
* the datepicker wants a numerical index. This function replaces the index with a number |
| 219 |
*/ |
| 220 |
public function strip_array_indices($ArrayToStrip) { |
| 221 |
foreach($ArrayToStrip as $objArrayItem) { |
| 222 |
$NewArray[] = $objArrayItem; |
| 223 |
} |
| 224 |
return($NewArray); |
| 225 |
} |
| 226 |
|
| 227 |
/** |
| 228 |
* Register and enqueue scripts and css. |
| 229 |
*/ |
| 230 |
|
| 231 |
public function frontend_scripts() { |
| 232 |
$ajax_url = WP_Event_Manager_Ajax::get_endpoint(); |
| 233 |
$ajax_filter_deps = array('jquery', 'jquery-deserialize'); |
| 234 |
|
| 235 |
$chosen_shortcodes = array('submit_event_form', 'event_dashboard', 'events'); |
| 236 |
$chosen_used_on_page = wpem_has_shortcode(null, $chosen_shortcodes); |
| 237 |
|
| 238 |
// jQuery Chosen - vendor |
| 239 |
if(apply_filters('event_manager_chosen_enabled', $chosen_used_on_page)) { |
| 240 |
wp_enqueue_script('wpem-dompurify', EVENT_MANAGER_PLUGIN_URL . '/assets/js/dom-purify/dompurify.min.js', [], '3.0.5', true); |
| 241 |
wp_register_script('chosen', EVENT_MANAGER_PLUGIN_URL . '/assets/js/jquery-chosen/chosen.jquery.min.js', array('jquery'), '1.1.0', true); |
| 242 |
wp_localize_script('chosen', 'wpem_chosen', array( |
| 243 |
'multiple_text' => __('Select Some Options', 'wp-event-manager'), |
| 244 |
'single_text' => __('Select an Option', 'wp-event-manager'), |
| 245 |
'no_result_text' => __('No results match', 'wp-event-manager'), |
| 246 |
)); |
| 247 |
wp_enqueue_script('chosen'); |
| 248 |
wp_register_script('wp-event-manager-term-multiselect', EVENT_MANAGER_PLUGIN_URL . '/assets/js/term-multiselect.min.js', array('jquery', 'chosen'), EVENT_MANAGER_VERSION, true); |
| 249 |
wp_register_script('wp-event-manager-multiselect', EVENT_MANAGER_PLUGIN_URL . '/assets/js/multiselect.min.js', array('jquery', 'chosen'), EVENT_MANAGER_VERSION, true); |
| 250 |
wp_enqueue_style('chosen', EVENT_MANAGER_PLUGIN_URL . '/assets/css/chosen.css', array(), '1.0.0'); |
| 251 |
$ajax_filter_deps[] = 'chosen'; |
| 252 |
} |
| 253 |
|
| 254 |
// File upload - vendor |
| 255 |
if(apply_filters('event_manager_ajax_file_upload_enabled', true)) { |
| 256 |
|
| 257 |
wp_register_script('jquery-iframe-transport', EVENT_MANAGER_PLUGIN_URL . '/assets/js/jquery-fileupload/jquery.iframe-transport.js', array('jquery'), '1.8.3', true); |
| 258 |
wp_register_script('jquery-fileupload', EVENT_MANAGER_PLUGIN_URL . '/assets/js/jquery-fileupload/jquery.fileupload.js', array('jquery', 'jquery-iframe-transport', 'jquery-ui-widget'), '5.42.3', true); |
| 259 |
wp_register_script('wp-event-manager-ajax-file-upload', EVENT_MANAGER_PLUGIN_URL . '/assets/js/ajax-file-upload.min.js', array('jquery', 'jquery-fileupload'), EVENT_MANAGER_VERSION, true); |
| 260 |
|
| 261 |
ob_start(); |
| 262 |
wpem_get_event_manager_template('form-fields/uploaded-file-html.php', array('name' => '', 'value' => '', 'extension' => 'jpg')); |
| 263 |
$js_field_html_img = ob_get_clean(); |
| 264 |
|
| 265 |
ob_start(); |
| 266 |
wpem_get_event_manager_template('form-fields/uploaded-file-html.php', array('name' => '', 'value' => '', 'extension' => 'zip')); |
| 267 |
$js_field_html = ob_get_clean(); |
| 268 |
|
| 269 |
wp_localize_script('wp-event-manager-ajax-file-upload', 'event_manager_ajax_file_upload', array( |
| 270 |
'ajax_url' => $ajax_url, |
| 271 |
'js_field_html_img' => esc_js(str_replace("\n", "", $js_field_html_img)), |
| 272 |
'js_field_html' => esc_js(str_replace("\n", "", $js_field_html)), |
| 273 |
'i18n_invalid_file_type' => __('Invalid file type. Accepted types:', 'wp-event-manager') |
| 274 |
)); |
| 275 |
} |
| 276 |
|
| 277 |
// jQuery Deserialize - vendor |
| 278 |
wp_register_script('jquery-deserialize', EVENT_MANAGER_PLUGIN_URL . '/assets/js/jquery-deserialize/jquery.deserialize.js', array('jquery'), '1.2.1', true); |
| 279 |
|
| 280 |
// Common js |
| 281 |
wp_register_script('wp-event-manager-common', EVENT_MANAGER_PLUGIN_URL . '/assets/js/common.min.js', array('jquery'), EVENT_MANAGER_VERSION, true); |
| 282 |
|
| 283 |
wp_enqueue_style('wp-event-manager-frontend', EVENT_MANAGER_PLUGIN_URL . '/assets/css/frontend.min.css', array(), '1.0.0'); |
| 284 |
wp_enqueue_script('wp-event-manager-common'); |
| 285 |
|
| 286 |
// event submission forms and validation js |
| 287 |
global $wp_locale; // |
| 288 |
wp_register_script('wp-event-manager-event-submission', EVENT_MANAGER_PLUGIN_URL . '/assets/js/event-submission.min.js', array('jquery','jquery-ui-core','jquery-ui-datepicker') , EVENT_MANAGER_VERSION, true); |
| 289 |
wp_localize_script('wp-event-manager-event-submission', 'wp_event_manager_event_submission', array( |
| 290 |
'start_of_week' => get_option('start_of_week'), |
| 291 |
'i18n_datepicker_format' => WP_Event_Manager_Date_Time::get_datepicker_format(), |
| 292 |
'i18n_timepicker_format' => WP_Event_Manager_Date_Time::get_timepicker_format(), |
| 293 |
'i18n_timepicker_step' => WP_Event_Manager_Date_Time::get_timepicker_step(), |
| 294 |
'monthNames' => $this->strip_array_indices($wp_locale->month), |
| 295 |
'i18n_dayNames' => $this->strip_array_indices($wp_locale->weekday), |
| 296 |
'i18n_dayNamesMin' => $this->strip_array_indices($wp_locale->weekday_abbrev), |
| 297 |
'ajax_url' => admin_url('admin-ajax.php'), |
| 298 |
'show_past_date' => apply_filters('event_manager_show_past_date_frontend', false), |
| 299 |
)); |
| 300 |
|
| 301 |
// Lightpick Date range picker |
| 302 |
wp_register_style('wp-event-manager-lightpick-datepicker-style', EVENT_MANAGER_PLUGIN_URL . '/assets/js/lightpick-datepicker/lightpick.css', array(), '1.0.0'); |
| 303 |
wp_register_script('wp-event-manager-lightpick-datepicker', EVENT_MANAGER_PLUGIN_URL . '/assets/js/lightpick-datepicker/lightpick.js', array('jquery-ui-core', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-menu', 'jquery-ui-widget', 'moment') , EVENT_MANAGER_VERSION, true); |
| 304 |
|
| 305 |
// jQuery UI date rang picker |
| 306 |
wp_register_style('wp-event-manager-jquery-ui-daterangepicker', EVENT_MANAGER_PLUGIN_URL . '/assets/js/jquery-ui-daterangepicker/jquery.comiseo.daterangepicker.css', array(), '1.0.0'); |
| 307 |
wp_register_style('wp-event-manager-jquery-ui-daterangepicker-style', EVENT_MANAGER_PLUGIN_URL . '/assets/js/jquery-ui-daterangepicker/styles.css', array(), '1.0.0'); |
| 308 |
wp_register_script('wp-event-manager-jquery-ui-daterangepicker', EVENT_MANAGER_PLUGIN_URL . '/assets/js/jquery-ui-daterangepicker/jquery.comiseo.daterangepicker.js', array('jquery-ui-core', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-menu', 'jquery-ui-widget', 'moment') , EVENT_MANAGER_VERSION, true); |
| 309 |
|
| 310 |
wp_register_script('wp-event-manager-content-event-listing', EVENT_MANAGER_PLUGIN_URL . '/assets/js/content-event-listing.min.js', array('jquery','wp-event-manager-common'), EVENT_MANAGER_VERSION, true); |
| 311 |
wp_localize_script('wp-event-manager-content-event-listing', 'event_manager_content_event_listing', array( |
| 312 |
'i18n_datepicker_format' => WP_Event_Manager_Date_Time::get_datepicker_format(), |
| 313 |
'i18n_initialText' => __('Select Date Range', 'wp-event-manager'), |
| 314 |
'i18n_applyButtonText' => __('Apply', 'wp-event-manager'), |
| 315 |
'i18n_clearButtonText' => __('Clear', 'wp-event-manager'), |
| 316 |
'i18n_cancelButtonText' => __('Cancel', 'wp-event-manager'), |
| 317 |
'i18n_monthNames' => $this->strip_array_indices($wp_locale->month), |
| 318 |
'i18n_dayNames' => $this->strip_array_indices($wp_locale->weekday), |
| 319 |
'i18n_dayNamesMin' => $this->strip_array_indices($wp_locale->weekday_abbrev), |
| 320 |
'i18n_today' => __('Today', 'wp-event-manager'), |
| 321 |
'i18n_tomorrow' => __('Tomorrow', 'wp-event-manager'), |
| 322 |
'i18n_thisWeek' => __('This Week', 'wp-event-manager'), |
| 323 |
'i18n_nextWeek' => __('Next Week', 'wp-event-manager'), |
| 324 |
'i18n_thisMonth' => __('This Month', 'wp-event-manager'), |
| 325 |
'i18n_nextMonth' => __('Next Month', 'wp-event-manager'), |
| 326 |
'i18n_thisYear' => __('This Year', 'wp-event-manager'), |
| 327 |
'i18n_nextYear' => __('Next Year', 'wp-event-manager') |
| 328 |
)); |
| 329 |
// Ajax filters js |
| 330 |
wp_register_script('wp-event-manager-ajax-filters', EVENT_MANAGER_PLUGIN_URL . '/assets/js/event-ajax-filters.min.js', $ajax_filter_deps, EVENT_MANAGER_VERSION, true); |
| 331 |
wp_localize_script('wp-event-manager-ajax-filters', 'event_manager_ajax_filters', array( |
| 332 |
'ajax_url' => $ajax_url, |
| 333 |
'nonce' => wp_create_nonce('event_manager_ajax_filters_nonce'), |
| 334 |
'is_rtl' => is_rtl() ? 1 : 0, |
| 335 |
'lang' => apply_filters('wpem_lang', null) //defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : '', // WPML workaround until this is standardized |
| 336 |
)); |
| 337 |
|
| 338 |
// Use for dashboard |
| 339 |
wp_register_script('wp-event-manager-event-dashboard', EVENT_MANAGER_PLUGIN_URL . '/assets/js/event-dashboard.min.js', array('jquery'), EVENT_MANAGER_VERSION, true); |
| 340 |
wp_localize_script('wp-event-manager-event-dashboard', 'event_manager_event_dashboard', array( |
| 341 |
'i18n_btnOkLabel' => __('Delete', 'wp-event-manager'), |
| 342 |
'i18n_btnCancelLabel' => __('Cancel', 'wp-event-manager'), |
| 343 |
'i18n_confirm_delete' => __('Are you sure you want to delete this event?', 'wp-event-manager') |
| 344 |
)); |
| 345 |
|
| 346 |
// Use for organizer dashboard |
| 347 |
wp_register_script('wp-event-manager-organizer-dashboard', EVENT_MANAGER_PLUGIN_URL . '/assets/js/organizer-dashboard.min.js', array('jquery'), EVENT_MANAGER_VERSION, true); |
| 348 |
wp_localize_script('wp-event-manager-organizer-dashboard', 'event_manager_organizer_dashboard', array( |
| 349 |
'i18n_btnOkLabel' => __('Delete', 'wp-event-manager'), |
| 350 |
'i18n_btnCancelLabel' => __('Cancel', 'wp-event-manager'), |
| 351 |
'i18n_confirm_delete' => __('Are you sure you want to delete this organizer?', 'wp-event-manager') |
| 352 |
|
| 353 |
)); |
| 354 |
|
| 355 |
// Use for venue dashboard |
| 356 |
wp_register_script('wp-event-manager-venue-dashboard', EVENT_MANAGER_PLUGIN_URL . '/assets/js/venue-dashboard.min.js', array('jquery'), EVENT_MANAGER_VERSION, true); |
| 357 |
wp_localize_script('wp-event-manager-venue-dashboard', 'event_manager_venue_dashboard', array( |
| 358 |
'i18n_btnOkLabel' => __('Delete', 'wp-event-manager'), |
| 359 |
'i18n_btnCancelLabel' => __('Cancel', 'wp-event-manager'), |
| 360 |
'i18n_confirm_delete' => __('Are you sure you want to delete this venue?', 'wp-event-manager') |
| 361 |
)); |
| 362 |
|
| 363 |
// Use for organizer |
| 364 |
wp_register_script('wp-event-manager-organizer', EVENT_MANAGER_PLUGIN_URL . '/assets/js/organizer.min.js', array('jquery','wp-event-manager-common'), EVENT_MANAGER_VERSION, true); |
| 365 |
wp_localize_script('wp-event-manager-organizer', 'event_manager_organizer', array( |
| 366 |
'i18n_upcomingEventsTitle' => __('Upcoming Events', 'wp-event-manager'), |
| 367 |
'i18n_pastEventsTitle' => __('Past Events', 'wp-event-manager'), |
| 368 |
'i18n_currentEventsTitle' => __('Current Events', 'wp-event-manager') |
| 369 |
)); |
| 370 |
|
| 371 |
// Use for venue |
| 372 |
wp_register_script('wp-event-manager-venue', EVENT_MANAGER_PLUGIN_URL . '/assets/js/venue.min.js', array('jquery','wp-event-manager-common'), EVENT_MANAGER_VERSION, true); |
| 373 |
wp_localize_script('wp-event-manager-venue', 'event_manager_venue', array( |
| 374 |
'i18n_upcomingEventsTitle' => __('Upcoming Events', 'wp-event-manager'), |
| 375 |
'i18n_pastEventsTitle' => __('Past Events', 'wp-event-manager'), |
| 376 |
'i18n_currentEventsTitle' => __('Current Events', 'wp-event-manager') |
| 377 |
)); |
| 378 |
|
| 379 |
// Use for registration |
| 380 |
wp_register_script('wp-event-manager-event-registration', EVENT_MANAGER_PLUGIN_URL . '/assets/js/event-registration.min.js', array('jquery'), EVENT_MANAGER_VERSION, true); |
| 381 |
|
| 382 |
wp_enqueue_style('wp-event-manager-jquery-ui-css', EVENT_MANAGER_PLUGIN_URL . '/assets/js/jquery-ui/jquery-ui.css', array(), '1.0.0'); |
| 383 |
|
| 384 |
wp_enqueue_style('wp-event-manager-jquery-timepicker-css', EVENT_MANAGER_PLUGIN_URL . '/assets/js/jquery-timepicker/jquery.timepicker.min.css', array(), '1.0.0'); |
| 385 |
wp_register_script('wp-event-manager-jquery-timepicker', EVENT_MANAGER_PLUGIN_URL. '/assets/js/jquery-timepicker/jquery.timepicker.min.js', array('jquery' ,'jquery-ui-core'), EVENT_MANAGER_VERSION, true); |
| 386 |
wp_enqueue_script('wp-event-manager-jquery-timepicker'); |
| 387 |
|
| 388 |
wp_register_script( 'wp-event-manager-slick-script', EVENT_MANAGER_PLUGIN_URL . '/assets/js/slick/slick.min.js', array( 'jquery' ), '1.0.0', true); |
| 389 |
wp_register_style('wp-event-manager-slick-style', EVENT_MANAGER_PLUGIN_URL . '/assets/js/slick/slick.css' , array(), '1.0.0'); |
| 390 |
|
| 391 |
wp_register_style('wp-event-manager-grid-style', EVENT_MANAGER_PLUGIN_URL . '/assets/css/wpem-grid.min.css', array(), '1.0.0'); |
| 392 |
wp_register_style('wp-event-manager-font-style', EVENT_MANAGER_PLUGIN_URL . '/assets/fonts/style.css', array(), '1.0.0'); |
| 393 |
|
| 394 |
wp_enqueue_style('wp-event-manager-grid-style'); |
| 395 |
wp_enqueue_style('wp-event-manager-font-style'); |
| 396 |
} |
| 397 |
|
| 398 |
/** |
| 399 |
* Cleanup event posting cookies. |
| 400 |
* @since 1.0.0 |
| 401 |
*/ |
| 402 |
public function cleanup_event_posting_cookies() { |
| 403 |
if(isset($_COOKIE['wp-event-manager-submitting-event-id'])) { |
| 404 |
setcookie('wp-event-manager-submitting-event-id', '', 0, COOKIEPATH, COOKIE_DOMAIN, false); |
| 405 |
} |
| 406 |
if(isset($_COOKIE['wp-event-manager-submitting-event-key'])) { |
| 407 |
setcookie('wp-event-manager-submitting-event-key', '', 0, COOKIEPATH, COOKIE_DOMAIN, false); |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
/** |
| 412 |
* Check cron status. |
| 413 |
* @since 1.0.0 |
| 414 |
**/ |
| 415 |
public function check_schedule_crons(){ |
| 416 |
if(!wp_next_scheduled('event_manager_check_for_expired_events')) { |
| 417 |
wp_schedule_event(time(), 'hourly', 'event_manager_check_for_expired_events'); |
| 418 |
} |
| 419 |
if(!wp_next_scheduled('event_manager_delete_old_previews')) { |
| 420 |
wp_schedule_event(time(), 'daily', 'event_manager_delete_old_previews'); |
| 421 |
} |
| 422 |
if(!wp_next_scheduled('event_manager_clear_expired_transients')) { |
| 423 |
wp_schedule_event(time(), 'twicedaily', 'event_manager_clear_expired_transients'); |
| 424 |
} |
| 425 |
} |
| 426 |
/** |
| 427 |
* Restrict access to the dashboard for non-organizer and non-administrator users. |
| 428 |
* |
| 429 |
* This function checks if the current user has the 'organizer' or 'administrator' role. |
| 430 |
* If the user lacks both capabilities, an informational message is displayed, |
| 431 |
* and further access to the dashboard is restricted. |
| 432 |
* |
| 433 |
* @return void |
| 434 |
*/ |
| 435 |
public function wpem_restrict_non_organizer_access_to_dashboard() { |
| 436 |
if (is_user_logged_in()) { |
| 437 |
$current_user = wp_get_current_user(); |
| 438 |
|
| 439 |
// Get allowed roles from option, fallback to all roles if not set |
| 440 |
$allowed_roles = get_option('event_manager_allowed_submission_roles', array_keys(wp_roles()->roles)); |
| 441 |
|
| 442 |
// Ensure $allowed_roles is always an array |
| 443 |
if (!is_array($allowed_roles)) { |
| 444 |
// Convert comma-separated string to array safely |
| 445 |
$allowed_roles = array_filter(array_map('trim', explode(',', $allowed_roles))); |
| 446 |
} |
| 447 |
|
| 448 |
$allowed_roles = array_map('strtolower', $allowed_roles); |
| 449 |
$user_roles = array_map('strtolower', $current_user->roles); |
| 450 |
|
| 451 |
if (!in_array('administrator', $user_roles) && !array_intersect($allowed_roles, $user_roles)) { ?> |
| 452 |
<p class="account-sign-in wpem-alert wpem-alert-info"> |
| 453 |
<?php esc_html_e('You do not have permission to manage this dashboard.', 'wp-event-manager'); ?> |
| 454 |
</p> |
| 455 |
<?php exit; |
| 456 |
} |
| 457 |
} |
| 458 |
} |
| 459 |
} |
| 460 |
|
| 461 |
/** |
| 462 |
* Create link on plugin page for event manager plugin settings. |
| 463 |
*/ |
| 464 |
function wpem_add_plugin_page_event_manager_settings_link($links) { |
| 465 |
$links[] = '<a href="' . |
| 466 |
admin_url('edit.php?post_type=event_listing&page=event-manager-settings') . |
| 467 |
'">' . __('Settings', 'wp-event-manager') . '</a>'; |
| 468 |
return $links; |
| 469 |
} |
| 470 |
add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'wpem_add_plugin_page_event_manager_settings_link'); |
| 471 |
|
| 472 |
/** |
| 473 |
* Main instance of WP Event Manager. |
| 474 |
* |
| 475 |
* Returns the main instance of WP Event Manager to prevent the need to use globals. |
| 476 |
* |
| 477 |
* @since 2.5 |
| 478 |
* @return WP_Event_Manager |
| 479 |
*/ |
| 480 |
function WPEM() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName |
| 481 |
return WP_Event_Manager::instance(); |
| 482 |
} |
| 483 |
$GLOBALS['event_manager'] = WPEM(); |
| 484 |
|