@@ -32,20 +32,20 @@ |
||
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 35 | + /** |
|
| 36 | 36 | * set_hooks - for hooking into EE Core, other modules, etc |
| 37 | 37 | * |
| 38 | 38 | * @access public |
| 39 | 39 | * @return void |
| 40 | 40 | */ |
| 41 | 41 | public static function set_hooks() { |
| 42 | - $custom_post_types = EE_Register_CPTs::get_CPTs(); |
|
| 43 | - EE_Config::register_route( |
|
| 44 | - $custom_post_types['espresso_venues']['singular_slug'], |
|
| 45 | - 'Venue_Single', |
|
| 46 | - 'run' |
|
| 47 | - ); |
|
| 48 | - } |
|
| 42 | + $custom_post_types = EE_Register_CPTs::get_CPTs(); |
|
| 43 | + EE_Config::register_route( |
|
| 44 | + $custom_post_types['espresso_venues']['singular_slug'], |
|
| 45 | + 'Venue_Single', |
|
| 46 | + 'run' |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @return EED_Venue_Single |
| 28 | 28 | */ |
| 29 | 29 | public static function instance() { |
| 30 | - return parent::get_instance( __CLASS__ ); |
|
| 30 | + return parent::get_instance(__CLASS__); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | * @access public |
| 65 | 65 | * @param \WP $WP |
| 66 | 66 | */ |
| 67 | - public function run( $WP ) { |
|
| 67 | + public function run($WP) { |
|
| 68 | 68 | // check what template is loaded |
| 69 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
| 70 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
| 69 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 70 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | |
@@ -79,15 +79,15 @@ discard block |
||
| 79 | 79 | * @param string $template |
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | - public function template_include( $template ) { |
|
| 82 | + public function template_include($template) { |
|
| 83 | 83 | // not a custom template? |
| 84 | - if ( EE_Registry::instance()->load_core( 'Front_Controller', array(), false, true )->get_selected_template() != 'single-espresso_venues.php' ) { |
|
| 84 | + if (EE_Registry::instance()->load_core('Front_Controller', array(), false, true)->get_selected_template() != 'single-espresso_venues.php') { |
|
| 85 | 85 | EEH_Template::load_espresso_theme_functions(); |
| 86 | 86 | // then add extra event data via hooks |
| 87 | - add_filter( 'the_title', array( $this, 'the_title' ), 100, 1 ); |
|
| 88 | - add_filter( 'the_content', array( $this, 'venue_details' ), 100 ); |
|
| 87 | + add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
| 88 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
| 89 | 89 | // don't display entry meta because the existing theme will take car of that |
| 90 | - add_filter( 'FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false' ); |
|
| 90 | + add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
| 91 | 91 | } |
| 92 | 92 | return $template; |
| 93 | 93 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param string $title |
| 102 | 102 | * @return string |
| 103 | 103 | */ |
| 104 | - public function the_title( $title = '' ) { |
|
| 104 | + public function the_title($title = '') { |
|
| 105 | 105 | return $title; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @param string $content |
| 114 | 114 | * @return string |
| 115 | 115 | */ |
| 116 | - public function venue_details( $content ) { |
|
| 116 | + public function venue_details($content) { |
|
| 117 | 117 | global $post; |
| 118 | 118 | if ( |
| 119 | 119 | $post->post_type == 'espresso_venues' |
@@ -123,16 +123,16 @@ discard block |
||
| 123 | 123 | // it uses the_content() for displaying the $post->post_content |
| 124 | 124 | // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
| 125 | 125 | // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
| 126 | - remove_filter( 'the_content', array( $this, 'venue_details' ), 100 ); |
|
| 126 | + remove_filter('the_content', array($this, 'venue_details'), 100); |
|
| 127 | 127 | // add filters we want |
| 128 | - add_filter( 'the_content', array( $this, 'venue_location' ), 110 ); |
|
| 128 | + add_filter('the_content', array($this, 'venue_location'), 110); |
|
| 129 | 129 | // now load our template |
| 130 | - $template = EEH_Template::locate_template( 'content-espresso_venues-details.php' ); |
|
| 130 | + $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
| 131 | 131 | // remove other filters we added so they won't get applied to the next post |
| 132 | - remove_filter( 'the_content', array( $this, 'venue_location' ), 110 ); |
|
| 132 | + remove_filter('the_content', array($this, 'venue_location'), 110); |
|
| 133 | 133 | } |
| 134 | 134 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
| 135 | - return ! empty( $template ) ? $template : $content; |
|
| 135 | + return ! empty($template) ? $template : $content; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | * @param string $content |
| 145 | 145 | * @return string |
| 146 | 146 | */ |
| 147 | - public function venue_location( $content ) { |
|
| 148 | - return $content . EEH_Template::locate_template( 'content-espresso_venues-location.php' ); |
|
| 147 | + public function venue_location($content) { |
|
| 148 | + return $content.EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
@@ -158,16 +158,16 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function wp_enqueue_scripts() { |
| 160 | 160 | // get some style |
| 161 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', TRUE ) && is_single() ) { |
|
| 161 | + if (apply_filters('FHEE_enable_default_espresso_css', TRUE) && is_single()) { |
|
| 162 | 162 | // first check theme folder |
| 163 | - if ( is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
| 164 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ) ); |
|
| 165 | - } else if ( is_readable( EE_TEMPLATES . $this->theme . DS . 'style.css' )) { |
|
| 166 | - wp_register_style( $this->theme, EE_TEMPLATES_URL . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ) ); |
|
| 163 | + if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
| 164 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
| 165 | + } else if (is_readable(EE_TEMPLATES.$this->theme.DS.'style.css')) { |
|
| 166 | + wp_register_style($this->theme, EE_TEMPLATES_URL.$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
| 167 | 167 | } |
| 168 | - wp_enqueue_style( $this->theme ); |
|
| 169 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
| 170 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
| 168 | + wp_enqueue_style($this->theme); |
|
| 169 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 170 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -13,467 +13,467 @@ discard block |
||
| 13 | 13 | class EED_Event_Single extends EED_Module |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - const EVENT_DETAILS_PRIORITY = 100; |
|
| 17 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
| 18 | - const EVENT_TICKETS_PRIORITY = 120; |
|
| 19 | - const EVENT_VENUES_PRIORITY = 130; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @type bool $using_get_the_excerpt |
|
| 23 | - */ |
|
| 24 | - protected static $using_get_the_excerpt = false; |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @type EE_Template_Part_Manager $template_parts |
|
| 29 | - */ |
|
| 30 | - protected $template_parts; |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @return EED_Module|EED_Event_Single |
|
| 35 | - */ |
|
| 36 | - public static function instance() |
|
| 37 | - { |
|
| 38 | - return parent::get_instance(__CLASS__); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 44 | - * |
|
| 45 | - * @return void |
|
| 46 | - */ |
|
| 47 | - public static function set_hooks() |
|
| 48 | - { |
|
| 49 | - add_filter('FHEE_run_EE_wp', '__return_true'); |
|
| 50 | - add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 51 | - $custom_post_types = EE_Register_CPTs::get_CPTs(); |
|
| 52 | - EE_Config::register_route( |
|
| 53 | - $custom_post_types['espresso_events']['singular_slug'], |
|
| 54 | - 'Event_Single', |
|
| 55 | - 'run' |
|
| 56 | - ); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 61 | - * |
|
| 62 | - * @return void |
|
| 63 | - */ |
|
| 64 | - public static function set_hooks_admin() |
|
| 65 | - { |
|
| 66 | - add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * set_definitions |
|
| 72 | - * |
|
| 73 | - * @static |
|
| 74 | - * @return void |
|
| 75 | - */ |
|
| 76 | - public static function set_definitions() |
|
| 77 | - { |
|
| 78 | - define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
| 79 | - define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * set_config |
|
| 85 | - * |
|
| 86 | - * @void |
|
| 87 | - */ |
|
| 88 | - protected function set_config() |
|
| 89 | - { |
|
| 90 | - $this->set_config_section('template_settings'); |
|
| 91 | - $this->set_config_class('EE_Event_Single_Config'); |
|
| 92 | - $this->set_config_name('EED_Event_Single'); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * initialize_template_parts |
|
| 98 | - * |
|
| 99 | - * @param EE_Config_Base|EE_Event_Single_Config $config |
|
| 100 | - * @return EE_Template_Part_Manager |
|
| 101 | - */ |
|
| 102 | - public function initialize_template_parts(EE_Event_Single_Config $config = null) |
|
| 103 | - { |
|
| 104 | - /** @type EE_Event_Single_Config $config */ |
|
| 105 | - $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
| 106 | - EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
| 107 | - $template_parts = new EE_Template_Part_Manager(); |
|
| 108 | - $template_parts->add_template_part( |
|
| 109 | - 'tickets', |
|
| 110 | - __('Ticket Selector', 'event_espresso'), |
|
| 111 | - 'content-espresso_events-tickets.php', |
|
| 112 | - $config->display_order_tickets |
|
| 113 | - ); |
|
| 114 | - $template_parts->add_template_part( |
|
| 115 | - 'datetimes', |
|
| 116 | - __('Dates and Times', 'event_espresso'), |
|
| 117 | - 'content-espresso_events-datetimes.php', |
|
| 118 | - $config->display_order_datetimes |
|
| 119 | - ); |
|
| 120 | - $template_parts->add_template_part( |
|
| 121 | - 'event', |
|
| 122 | - __('Event Description', 'event_espresso'), |
|
| 123 | - 'content-espresso_events-details.php', |
|
| 124 | - $config->display_order_event |
|
| 125 | - ); |
|
| 126 | - $template_parts->add_template_part( |
|
| 127 | - 'venue', |
|
| 128 | - __('Venue Information', 'event_espresso'), |
|
| 129 | - 'content-espresso_events-venues.php', |
|
| 130 | - $config->display_order_venue |
|
| 131 | - ); |
|
| 132 | - do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
| 133 | - return $template_parts; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * run - initial module setup |
|
| 139 | - * |
|
| 140 | - * @param WP $WP |
|
| 141 | - * @return void |
|
| 142 | - */ |
|
| 143 | - public function run($WP) |
|
| 144 | - { |
|
| 145 | - // ensure valid EE_Events_Single_Config() object exists |
|
| 146 | - $this->set_config(); |
|
| 147 | - // check what template is loaded |
|
| 148 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 149 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 150 | - // load css |
|
| 151 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * template_include |
|
| 157 | - * |
|
| 158 | - * @param string $template |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - public function template_include($template) |
|
| 162 | - { |
|
| 163 | - global $post; |
|
| 164 | - /** @type EE_Event_Single_Config $config */ |
|
| 165 | - $config = $this->config(); |
|
| 166 | - if ($config->display_status_banner_single) { |
|
| 167 | - add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
| 168 | - } |
|
| 169 | - // not a custom template? |
|
| 170 | - if ( |
|
| 171 | - !post_password_required($post) |
|
| 172 | - && ( |
|
| 173 | - apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
| 174 | - || EE_Registry::instance() |
|
| 175 | - ->load_core('Front_Controller') |
|
| 176 | - ->get_selected_template() !== 'single-espresso_events.php' |
|
| 177 | - ) |
|
| 178 | - |
|
| 179 | - ) { |
|
| 180 | - EEH_Template::load_espresso_theme_functions(); |
|
| 181 | - // then add extra event data via hooks |
|
| 182 | - add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
| 183 | - add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
| 184 | - add_filter( |
|
| 185 | - 'the_content', |
|
| 186 | - array('EED_Event_Single', 'event_details'), |
|
| 187 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 188 | - ); |
|
| 189 | - add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
| 190 | - // don't display entry meta because the existing theme will take car of that |
|
| 191 | - add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 192 | - } |
|
| 193 | - return $template; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * loop_start |
|
| 199 | - * |
|
| 200 | - * @param array $wp_query_array an array containing the WP_Query object |
|
| 201 | - * @return void |
|
| 202 | - */ |
|
| 203 | - public static function loop_start($wp_query_array) |
|
| 204 | - { |
|
| 205 | - global $post; |
|
| 206 | - do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * the_title |
|
| 212 | - * |
|
| 213 | - * @param string $title |
|
| 214 | - * @param int $id |
|
| 215 | - * @return string |
|
| 216 | - */ |
|
| 217 | - public static function the_title($title = '', $id = 0) |
|
| 218 | - { |
|
| 219 | - global $post; |
|
| 220 | - return in_the_loop() && $post->ID === (int)$id |
|
| 221 | - ? espresso_event_status_banner($post->ID) . $title |
|
| 222 | - : $title; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * get_the_excerpt |
|
| 228 | - * kinda hacky, but if a theme is using get_the_excerpt(), |
|
| 229 | - * then we need to remove our filters on the_content() |
|
| 230 | - * |
|
| 231 | - * @param string $excerpt |
|
| 232 | - * @return string |
|
| 233 | - */ |
|
| 234 | - public static function get_the_excerpt($excerpt = '') |
|
| 235 | - { |
|
| 236 | - EED_Event_Single::$using_get_the_excerpt = true; |
|
| 237 | - add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
| 238 | - return $excerpt; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * end_get_the_excerpt |
|
| 244 | - * |
|
| 245 | - * @param string $text |
|
| 246 | - * @return string |
|
| 247 | - */ |
|
| 248 | - public static function end_get_the_excerpt($text = '') |
|
| 249 | - { |
|
| 250 | - EED_Event_Single::$using_get_the_excerpt = false; |
|
| 251 | - return $text; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * event_details |
|
| 257 | - * |
|
| 258 | - * @param string $content |
|
| 259 | - * @return string |
|
| 260 | - */ |
|
| 261 | - public static function event_details($content) |
|
| 262 | - { |
|
| 263 | - global $post; |
|
| 264 | - static $current_post_ID = 0; |
|
| 265 | - if ( |
|
| 266 | - $current_post_ID !== $post->ID |
|
| 267 | - && $post->post_type === 'espresso_events' |
|
| 268 | - && !EED_Event_Single::$using_get_the_excerpt |
|
| 269 | - && !post_password_required() |
|
| 270 | - ) { |
|
| 271 | - // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
| 272 | - // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
| 273 | - // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
| 274 | - // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
| 275 | - // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
| 276 | - // so the following allows this filter to be applied multiple times, but only once for real |
|
| 277 | - $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 278 | - if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
| 279 | - // we need to first remove this callback from being applied to the_content() |
|
| 280 | - // (otherwise it will recurse and blow up the interweb) |
|
| 281 | - remove_filter( |
|
| 282 | - 'the_content', |
|
| 283 | - array('EED_Event_Single', 'event_details'), |
|
| 284 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 285 | - ); |
|
| 286 | - EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
|
| 287 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 288 | - $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
| 289 | - add_filter( |
|
| 290 | - 'the_content', |
|
| 291 | - array('EED_Event_Single', 'event_details'), |
|
| 292 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 293 | - ); |
|
| 294 | - } else { |
|
| 295 | - $content = EED_Event_Single::use_filterable_display_order(); |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - return $content; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - |
|
| 302 | - /** |
|
| 303 | - * use_filterable_display_order |
|
| 304 | - * |
|
| 305 | - * @return string |
|
| 306 | - */ |
|
| 307 | - protected static function use_filterable_display_order() |
|
| 308 | - { |
|
| 309 | - // since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
| 310 | - // it uses the_content() for displaying the $post->post_content |
|
| 311 | - // so in order to load a template that uses the_content() |
|
| 312 | - // from within a callback being used to filter the_content(), |
|
| 313 | - // we need to first remove this callback from being applied to the_content() |
|
| 314 | - // (otherwise it will recurse and blow up the interweb) |
|
| 315 | - remove_filter( |
|
| 316 | - 'the_content', |
|
| 317 | - array('EED_Event_Single', 'event_details'), |
|
| 318 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 319 | - ); |
|
| 320 | - //now add additional content |
|
| 321 | - add_filter( |
|
| 322 | - 'the_content', |
|
| 323 | - array('EED_Event_Single', 'event_datetimes'), |
|
| 324 | - EED_Event_Single::EVENT_DATETIMES_PRIORITY, |
|
| 325 | - 1 |
|
| 326 | - ); |
|
| 327 | - add_filter( |
|
| 328 | - 'the_content', |
|
| 329 | - array('EED_Event_Single', 'event_tickets'), |
|
| 330 | - EED_Event_Single::EVENT_TICKETS_PRIORITY, |
|
| 331 | - 1 |
|
| 332 | - ); |
|
| 333 | - add_filter( |
|
| 334 | - 'the_content', |
|
| 335 | - array('EED_Event_Single', 'event_venues'), |
|
| 336 | - EED_Event_Single::EVENT_VENUES_PRIORITY, |
|
| 337 | - 1 |
|
| 338 | - ); |
|
| 339 | - do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
| 340 | - // now load our template |
|
| 341 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 342 | - //now add our filter back in, plus some others |
|
| 343 | - add_filter( |
|
| 344 | - 'the_content', |
|
| 345 | - array('EED_Event_Single', 'event_details'), |
|
| 346 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 347 | - ); |
|
| 348 | - remove_filter( |
|
| 349 | - 'the_content', |
|
| 350 | - array('EED_Event_Single', 'event_datetimes'), |
|
| 351 | - EED_Event_Single::EVENT_DATETIMES_PRIORITY |
|
| 352 | - ); |
|
| 353 | - remove_filter( |
|
| 354 | - 'the_content', |
|
| 355 | - array('EED_Event_Single', 'event_tickets'), |
|
| 356 | - EED_Event_Single::EVENT_TICKETS_PRIORITY |
|
| 357 | - ); |
|
| 358 | - remove_filter( |
|
| 359 | - 'the_content', |
|
| 360 | - array('EED_Event_Single', 'event_venues'), |
|
| 361 | - EED_Event_Single::EVENT_VENUES_PRIORITY |
|
| 362 | - ); |
|
| 363 | - do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
| 364 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
| 365 | - return $content; |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * event_datetimes - adds datetimes ABOVE content |
|
| 371 | - * |
|
| 372 | - * @param string $content |
|
| 373 | - * @return string |
|
| 374 | - */ |
|
| 375 | - public static function event_datetimes($content) |
|
| 376 | - { |
|
| 377 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
| 383 | - * |
|
| 384 | - * @param string $content |
|
| 385 | - * @return string |
|
| 386 | - */ |
|
| 387 | - public static function event_tickets($content) |
|
| 388 | - { |
|
| 389 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * event_venues |
|
| 395 | - * |
|
| 396 | - * @param string $content |
|
| 397 | - * @return string |
|
| 398 | - */ |
|
| 399 | - public static function event_venue($content) |
|
| 400 | - { |
|
| 401 | - return EED_Event_Single::event_venues($content); |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * event_venues - adds venues BELOW content |
|
| 407 | - * |
|
| 408 | - * @param string $content |
|
| 409 | - * @return string |
|
| 410 | - */ |
|
| 411 | - public static function event_venues($content) |
|
| 412 | - { |
|
| 413 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - |
|
| 417 | - /** |
|
| 418 | - * loop_end |
|
| 419 | - * |
|
| 420 | - * @param array $wp_query_array an array containing the WP_Query object |
|
| 421 | - * @return void |
|
| 422 | - */ |
|
| 423 | - public static function loop_end($wp_query_array) |
|
| 424 | - { |
|
| 425 | - global $post; |
|
| 426 | - do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - |
|
| 430 | - /** |
|
| 431 | - * wp_enqueue_scripts |
|
| 432 | - * |
|
| 433 | - * @return void |
|
| 434 | - */ |
|
| 435 | - public function wp_enqueue_scripts() |
|
| 436 | - { |
|
| 437 | - // get some style |
|
| 438 | - if ( |
|
| 439 | - apply_filters('FHEE_enable_default_espresso_css', TRUE) |
|
| 440 | - && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE) |
|
| 441 | - ) { |
|
| 442 | - // first check uploads folder |
|
| 443 | - if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
| 444 | - wp_register_style( |
|
| 445 | - $this->theme, |
|
| 446 | - get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
| 447 | - array('dashicons', 'espresso_default') |
|
| 448 | - ); |
|
| 449 | - } else { |
|
| 450 | - wp_register_style( |
|
| 451 | - $this->theme, |
|
| 452 | - EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
| 453 | - array('dashicons', 'espresso_default') |
|
| 454 | - ); |
|
| 455 | - } |
|
| 456 | - wp_enqueue_script($this->theme); |
|
| 457 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 458 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 459 | - } |
|
| 460 | - } |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - |
|
| 464 | - /** |
|
| 465 | - * display_venue |
|
| 466 | - * |
|
| 467 | - * @return bool |
|
| 468 | - */ |
|
| 469 | - public static function display_venue() |
|
| 470 | - { |
|
| 471 | - /** @type EE_Event_Single_Config $config */ |
|
| 472 | - $config = EED_Event_Single::instance()->config(); |
|
| 473 | - $display_venue = $config->display_venue === null ? true : $config->display_venue; |
|
| 474 | - $venue_name = EEH_Venue_View::venue_name(); |
|
| 475 | - return $display_venue && !empty($venue_name); |
|
| 476 | - } |
|
| 16 | + const EVENT_DETAILS_PRIORITY = 100; |
|
| 17 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
| 18 | + const EVENT_TICKETS_PRIORITY = 120; |
|
| 19 | + const EVENT_VENUES_PRIORITY = 130; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @type bool $using_get_the_excerpt |
|
| 23 | + */ |
|
| 24 | + protected static $using_get_the_excerpt = false; |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @type EE_Template_Part_Manager $template_parts |
|
| 29 | + */ |
|
| 30 | + protected $template_parts; |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @return EED_Module|EED_Event_Single |
|
| 35 | + */ |
|
| 36 | + public static function instance() |
|
| 37 | + { |
|
| 38 | + return parent::get_instance(__CLASS__); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 44 | + * |
|
| 45 | + * @return void |
|
| 46 | + */ |
|
| 47 | + public static function set_hooks() |
|
| 48 | + { |
|
| 49 | + add_filter('FHEE_run_EE_wp', '__return_true'); |
|
| 50 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 51 | + $custom_post_types = EE_Register_CPTs::get_CPTs(); |
|
| 52 | + EE_Config::register_route( |
|
| 53 | + $custom_post_types['espresso_events']['singular_slug'], |
|
| 54 | + 'Event_Single', |
|
| 55 | + 'run' |
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 61 | + * |
|
| 62 | + * @return void |
|
| 63 | + */ |
|
| 64 | + public static function set_hooks_admin() |
|
| 65 | + { |
|
| 66 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * set_definitions |
|
| 72 | + * |
|
| 73 | + * @static |
|
| 74 | + * @return void |
|
| 75 | + */ |
|
| 76 | + public static function set_definitions() |
|
| 77 | + { |
|
| 78 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
| 79 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * set_config |
|
| 85 | + * |
|
| 86 | + * @void |
|
| 87 | + */ |
|
| 88 | + protected function set_config() |
|
| 89 | + { |
|
| 90 | + $this->set_config_section('template_settings'); |
|
| 91 | + $this->set_config_class('EE_Event_Single_Config'); |
|
| 92 | + $this->set_config_name('EED_Event_Single'); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * initialize_template_parts |
|
| 98 | + * |
|
| 99 | + * @param EE_Config_Base|EE_Event_Single_Config $config |
|
| 100 | + * @return EE_Template_Part_Manager |
|
| 101 | + */ |
|
| 102 | + public function initialize_template_parts(EE_Event_Single_Config $config = null) |
|
| 103 | + { |
|
| 104 | + /** @type EE_Event_Single_Config $config */ |
|
| 105 | + $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
| 106 | + EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
| 107 | + $template_parts = new EE_Template_Part_Manager(); |
|
| 108 | + $template_parts->add_template_part( |
|
| 109 | + 'tickets', |
|
| 110 | + __('Ticket Selector', 'event_espresso'), |
|
| 111 | + 'content-espresso_events-tickets.php', |
|
| 112 | + $config->display_order_tickets |
|
| 113 | + ); |
|
| 114 | + $template_parts->add_template_part( |
|
| 115 | + 'datetimes', |
|
| 116 | + __('Dates and Times', 'event_espresso'), |
|
| 117 | + 'content-espresso_events-datetimes.php', |
|
| 118 | + $config->display_order_datetimes |
|
| 119 | + ); |
|
| 120 | + $template_parts->add_template_part( |
|
| 121 | + 'event', |
|
| 122 | + __('Event Description', 'event_espresso'), |
|
| 123 | + 'content-espresso_events-details.php', |
|
| 124 | + $config->display_order_event |
|
| 125 | + ); |
|
| 126 | + $template_parts->add_template_part( |
|
| 127 | + 'venue', |
|
| 128 | + __('Venue Information', 'event_espresso'), |
|
| 129 | + 'content-espresso_events-venues.php', |
|
| 130 | + $config->display_order_venue |
|
| 131 | + ); |
|
| 132 | + do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
| 133 | + return $template_parts; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * run - initial module setup |
|
| 139 | + * |
|
| 140 | + * @param WP $WP |
|
| 141 | + * @return void |
|
| 142 | + */ |
|
| 143 | + public function run($WP) |
|
| 144 | + { |
|
| 145 | + // ensure valid EE_Events_Single_Config() object exists |
|
| 146 | + $this->set_config(); |
|
| 147 | + // check what template is loaded |
|
| 148 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 149 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 150 | + // load css |
|
| 151 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * template_include |
|
| 157 | + * |
|
| 158 | + * @param string $template |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + public function template_include($template) |
|
| 162 | + { |
|
| 163 | + global $post; |
|
| 164 | + /** @type EE_Event_Single_Config $config */ |
|
| 165 | + $config = $this->config(); |
|
| 166 | + if ($config->display_status_banner_single) { |
|
| 167 | + add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
| 168 | + } |
|
| 169 | + // not a custom template? |
|
| 170 | + if ( |
|
| 171 | + !post_password_required($post) |
|
| 172 | + && ( |
|
| 173 | + apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
| 174 | + || EE_Registry::instance() |
|
| 175 | + ->load_core('Front_Controller') |
|
| 176 | + ->get_selected_template() !== 'single-espresso_events.php' |
|
| 177 | + ) |
|
| 178 | + |
|
| 179 | + ) { |
|
| 180 | + EEH_Template::load_espresso_theme_functions(); |
|
| 181 | + // then add extra event data via hooks |
|
| 182 | + add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
| 183 | + add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
| 184 | + add_filter( |
|
| 185 | + 'the_content', |
|
| 186 | + array('EED_Event_Single', 'event_details'), |
|
| 187 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 188 | + ); |
|
| 189 | + add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
| 190 | + // don't display entry meta because the existing theme will take car of that |
|
| 191 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 192 | + } |
|
| 193 | + return $template; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * loop_start |
|
| 199 | + * |
|
| 200 | + * @param array $wp_query_array an array containing the WP_Query object |
|
| 201 | + * @return void |
|
| 202 | + */ |
|
| 203 | + public static function loop_start($wp_query_array) |
|
| 204 | + { |
|
| 205 | + global $post; |
|
| 206 | + do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * the_title |
|
| 212 | + * |
|
| 213 | + * @param string $title |
|
| 214 | + * @param int $id |
|
| 215 | + * @return string |
|
| 216 | + */ |
|
| 217 | + public static function the_title($title = '', $id = 0) |
|
| 218 | + { |
|
| 219 | + global $post; |
|
| 220 | + return in_the_loop() && $post->ID === (int)$id |
|
| 221 | + ? espresso_event_status_banner($post->ID) . $title |
|
| 222 | + : $title; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * get_the_excerpt |
|
| 228 | + * kinda hacky, but if a theme is using get_the_excerpt(), |
|
| 229 | + * then we need to remove our filters on the_content() |
|
| 230 | + * |
|
| 231 | + * @param string $excerpt |
|
| 232 | + * @return string |
|
| 233 | + */ |
|
| 234 | + public static function get_the_excerpt($excerpt = '') |
|
| 235 | + { |
|
| 236 | + EED_Event_Single::$using_get_the_excerpt = true; |
|
| 237 | + add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
| 238 | + return $excerpt; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * end_get_the_excerpt |
|
| 244 | + * |
|
| 245 | + * @param string $text |
|
| 246 | + * @return string |
|
| 247 | + */ |
|
| 248 | + public static function end_get_the_excerpt($text = '') |
|
| 249 | + { |
|
| 250 | + EED_Event_Single::$using_get_the_excerpt = false; |
|
| 251 | + return $text; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * event_details |
|
| 257 | + * |
|
| 258 | + * @param string $content |
|
| 259 | + * @return string |
|
| 260 | + */ |
|
| 261 | + public static function event_details($content) |
|
| 262 | + { |
|
| 263 | + global $post; |
|
| 264 | + static $current_post_ID = 0; |
|
| 265 | + if ( |
|
| 266 | + $current_post_ID !== $post->ID |
|
| 267 | + && $post->post_type === 'espresso_events' |
|
| 268 | + && !EED_Event_Single::$using_get_the_excerpt |
|
| 269 | + && !post_password_required() |
|
| 270 | + ) { |
|
| 271 | + // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
| 272 | + // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
| 273 | + // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
| 274 | + // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
| 275 | + // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
| 276 | + // so the following allows this filter to be applied multiple times, but only once for real |
|
| 277 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 278 | + if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
| 279 | + // we need to first remove this callback from being applied to the_content() |
|
| 280 | + // (otherwise it will recurse and blow up the interweb) |
|
| 281 | + remove_filter( |
|
| 282 | + 'the_content', |
|
| 283 | + array('EED_Event_Single', 'event_details'), |
|
| 284 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 285 | + ); |
|
| 286 | + EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
|
| 287 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 288 | + $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
| 289 | + add_filter( |
|
| 290 | + 'the_content', |
|
| 291 | + array('EED_Event_Single', 'event_details'), |
|
| 292 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 293 | + ); |
|
| 294 | + } else { |
|
| 295 | + $content = EED_Event_Single::use_filterable_display_order(); |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + return $content; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + |
|
| 302 | + /** |
|
| 303 | + * use_filterable_display_order |
|
| 304 | + * |
|
| 305 | + * @return string |
|
| 306 | + */ |
|
| 307 | + protected static function use_filterable_display_order() |
|
| 308 | + { |
|
| 309 | + // since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
| 310 | + // it uses the_content() for displaying the $post->post_content |
|
| 311 | + // so in order to load a template that uses the_content() |
|
| 312 | + // from within a callback being used to filter the_content(), |
|
| 313 | + // we need to first remove this callback from being applied to the_content() |
|
| 314 | + // (otherwise it will recurse and blow up the interweb) |
|
| 315 | + remove_filter( |
|
| 316 | + 'the_content', |
|
| 317 | + array('EED_Event_Single', 'event_details'), |
|
| 318 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 319 | + ); |
|
| 320 | + //now add additional content |
|
| 321 | + add_filter( |
|
| 322 | + 'the_content', |
|
| 323 | + array('EED_Event_Single', 'event_datetimes'), |
|
| 324 | + EED_Event_Single::EVENT_DATETIMES_PRIORITY, |
|
| 325 | + 1 |
|
| 326 | + ); |
|
| 327 | + add_filter( |
|
| 328 | + 'the_content', |
|
| 329 | + array('EED_Event_Single', 'event_tickets'), |
|
| 330 | + EED_Event_Single::EVENT_TICKETS_PRIORITY, |
|
| 331 | + 1 |
|
| 332 | + ); |
|
| 333 | + add_filter( |
|
| 334 | + 'the_content', |
|
| 335 | + array('EED_Event_Single', 'event_venues'), |
|
| 336 | + EED_Event_Single::EVENT_VENUES_PRIORITY, |
|
| 337 | + 1 |
|
| 338 | + ); |
|
| 339 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
| 340 | + // now load our template |
|
| 341 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 342 | + //now add our filter back in, plus some others |
|
| 343 | + add_filter( |
|
| 344 | + 'the_content', |
|
| 345 | + array('EED_Event_Single', 'event_details'), |
|
| 346 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 347 | + ); |
|
| 348 | + remove_filter( |
|
| 349 | + 'the_content', |
|
| 350 | + array('EED_Event_Single', 'event_datetimes'), |
|
| 351 | + EED_Event_Single::EVENT_DATETIMES_PRIORITY |
|
| 352 | + ); |
|
| 353 | + remove_filter( |
|
| 354 | + 'the_content', |
|
| 355 | + array('EED_Event_Single', 'event_tickets'), |
|
| 356 | + EED_Event_Single::EVENT_TICKETS_PRIORITY |
|
| 357 | + ); |
|
| 358 | + remove_filter( |
|
| 359 | + 'the_content', |
|
| 360 | + array('EED_Event_Single', 'event_venues'), |
|
| 361 | + EED_Event_Single::EVENT_VENUES_PRIORITY |
|
| 362 | + ); |
|
| 363 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
| 364 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
| 365 | + return $content; |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * event_datetimes - adds datetimes ABOVE content |
|
| 371 | + * |
|
| 372 | + * @param string $content |
|
| 373 | + * @return string |
|
| 374 | + */ |
|
| 375 | + public static function event_datetimes($content) |
|
| 376 | + { |
|
| 377 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
| 383 | + * |
|
| 384 | + * @param string $content |
|
| 385 | + * @return string |
|
| 386 | + */ |
|
| 387 | + public static function event_tickets($content) |
|
| 388 | + { |
|
| 389 | + return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * event_venues |
|
| 395 | + * |
|
| 396 | + * @param string $content |
|
| 397 | + * @return string |
|
| 398 | + */ |
|
| 399 | + public static function event_venue($content) |
|
| 400 | + { |
|
| 401 | + return EED_Event_Single::event_venues($content); |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * event_venues - adds venues BELOW content |
|
| 407 | + * |
|
| 408 | + * @param string $content |
|
| 409 | + * @return string |
|
| 410 | + */ |
|
| 411 | + public static function event_venues($content) |
|
| 412 | + { |
|
| 413 | + return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + |
|
| 417 | + /** |
|
| 418 | + * loop_end |
|
| 419 | + * |
|
| 420 | + * @param array $wp_query_array an array containing the WP_Query object |
|
| 421 | + * @return void |
|
| 422 | + */ |
|
| 423 | + public static function loop_end($wp_query_array) |
|
| 424 | + { |
|
| 425 | + global $post; |
|
| 426 | + do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + |
|
| 430 | + /** |
|
| 431 | + * wp_enqueue_scripts |
|
| 432 | + * |
|
| 433 | + * @return void |
|
| 434 | + */ |
|
| 435 | + public function wp_enqueue_scripts() |
|
| 436 | + { |
|
| 437 | + // get some style |
|
| 438 | + if ( |
|
| 439 | + apply_filters('FHEE_enable_default_espresso_css', TRUE) |
|
| 440 | + && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE) |
|
| 441 | + ) { |
|
| 442 | + // first check uploads folder |
|
| 443 | + if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
| 444 | + wp_register_style( |
|
| 445 | + $this->theme, |
|
| 446 | + get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
| 447 | + array('dashicons', 'espresso_default') |
|
| 448 | + ); |
|
| 449 | + } else { |
|
| 450 | + wp_register_style( |
|
| 451 | + $this->theme, |
|
| 452 | + EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
| 453 | + array('dashicons', 'espresso_default') |
|
| 454 | + ); |
|
| 455 | + } |
|
| 456 | + wp_enqueue_script($this->theme); |
|
| 457 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 458 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 459 | + } |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + |
|
| 464 | + /** |
|
| 465 | + * display_venue |
|
| 466 | + * |
|
| 467 | + * @return bool |
|
| 468 | + */ |
|
| 469 | + public static function display_venue() |
|
| 470 | + { |
|
| 471 | + /** @type EE_Event_Single_Config $config */ |
|
| 472 | + $config = EED_Event_Single::instance()->config(); |
|
| 473 | + $display_venue = $config->display_venue === null ? true : $config->display_venue; |
|
| 474 | + $venue_name = EEH_Venue_View::venue_name(); |
|
| 475 | + return $display_venue && !empty($venue_name); |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | 478 | |
| 479 | 479 | } |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | */ |
| 488 | 488 | function espresso_display_venue_in_event_details() |
| 489 | 489 | { |
| 490 | - return EED_Event_Single::display_venue(); |
|
| 490 | + return EED_Event_Single::display_venue(); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class EED_Events_Archive extends EED_Module { |
| 16 | 16 | |
| 17 | - const EVENT_DETAILS_PRIORITY = 100; |
|
| 18 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
| 19 | - const EVENT_TICKETS_PRIORITY = 120; |
|
| 20 | - const EVENT_VENUES_PRIORITY = 130; |
|
| 17 | + const EVENT_DETAILS_PRIORITY = 100; |
|
| 18 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
| 19 | + const EVENT_TICKETS_PRIORITY = 120; |
|
| 20 | + const EVENT_VENUES_PRIORITY = 130; |
|
| 21 | 21 | |
| 22 | 22 | |
| 23 | - public static $espresso_event_list_ID = 0; |
|
| 23 | + public static $espresso_event_list_ID = 0; |
|
| 24 | 24 | public static $espresso_grid_event_lists = array(); |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -28,19 +28,19 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | protected static $using_get_the_excerpt = false; |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Used to flag when the event list is being called from an external iframe. |
|
| 33 | - * |
|
| 34 | - * @var bool $iframe |
|
| 35 | - */ |
|
| 36 | - protected static $iframe = false; |
|
| 31 | + /** |
|
| 32 | + * Used to flag when the event list is being called from an external iframe. |
|
| 33 | + * |
|
| 34 | + * @var bool $iframe |
|
| 35 | + */ |
|
| 36 | + protected static $iframe = false; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button |
| 40 | 40 | */ |
| 41 | 41 | private static $_iframe_embed_button; |
| 42 | 42 | |
| 43 | - /** |
|
| 43 | + /** |
|
| 44 | 44 | * @type EE_Template_Part_Manager $template_parts |
| 45 | 45 | */ |
| 46 | 46 | protected $template_parts; |
@@ -63,24 +63,24 @@ discard block |
||
| 63 | 63 | * @return void |
| 64 | 64 | */ |
| 65 | 65 | public static function set_hooks() { |
| 66 | - $custom_post_types = EE_Register_CPTs::get_CPTs(); |
|
| 67 | - EE_Config::register_route( |
|
| 68 | - $custom_post_types['espresso_events']['plural_slug'], |
|
| 69 | - 'Events_Archive', |
|
| 70 | - 'run' |
|
| 71 | - ); |
|
| 72 | - EE_Config::register_route( |
|
| 73 | - 'event_list', |
|
| 74 | - 'Events_Archive', |
|
| 75 | - 'event_list' |
|
| 76 | - ); |
|
| 77 | - EE_Config::register_route( |
|
| 78 | - 'iframe', |
|
| 79 | - 'Events_Archive', |
|
| 80 | - 'event_list_iframe', |
|
| 81 | - 'event_list' |
|
| 82 | - ); |
|
| 83 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
| 66 | + $custom_post_types = EE_Register_CPTs::get_CPTs(); |
|
| 67 | + EE_Config::register_route( |
|
| 68 | + $custom_post_types['espresso_events']['plural_slug'], |
|
| 69 | + 'Events_Archive', |
|
| 70 | + 'run' |
|
| 71 | + ); |
|
| 72 | + EE_Config::register_route( |
|
| 73 | + 'event_list', |
|
| 74 | + 'Events_Archive', |
|
| 75 | + 'event_list' |
|
| 76 | + ); |
|
| 77 | + EE_Config::register_route( |
|
| 78 | + 'iframe', |
|
| 79 | + 'Events_Archive', |
|
| 80 | + 'event_list_iframe', |
|
| 81 | + 'event_list' |
|
| 82 | + ); |
|
| 83 | + add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | - * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
| 228 | - * |
|
| 229 | - * @return void |
|
| 227 | + * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
| 228 | + * |
|
| 229 | + * @return void |
|
| 230 | 230 | */ |
| 231 | 231 | public function event_list() { |
| 232 | 232 | // ensure valid EE_Events_Archive_Config() object exists |
@@ -237,36 +237,36 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | |
| 240 | - /** |
|
| 241 | - * @access public |
|
| 242 | - * @return void |
|
| 243 | - * @throws \EE_Error |
|
| 244 | - * @throws \DomainException |
|
| 245 | - */ |
|
| 240 | + /** |
|
| 241 | + * @access public |
|
| 242 | + * @return void |
|
| 243 | + * @throws \EE_Error |
|
| 244 | + * @throws \DomainException |
|
| 245 | + */ |
|
| 246 | 246 | public function event_list_iframe() { |
| 247 | - \EED_Events_Archive::$iframe = true; |
|
| 247 | + \EED_Events_Archive::$iframe = true; |
|
| 248 | 248 | $event_list_iframe = new EventsArchiveIframe( $this ); |
| 249 | 249 | $event_list_iframe->display(); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
| 253 | 253 | |
| 254 | - /** |
|
| 255 | - * @access public |
|
| 256 | - * @return string |
|
| 257 | - */ |
|
| 254 | + /** |
|
| 255 | + * @access public |
|
| 256 | + * @return string |
|
| 257 | + */ |
|
| 258 | 258 | public static function is_iframe() { |
| 259 | - return \EED_Events_Archive::$iframe; |
|
| 259 | + return \EED_Events_Archive::$iframe; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | |
| 263 | 263 | |
| 264 | - /** |
|
| 265 | - * @access public |
|
| 266 | - * @return string |
|
| 267 | - */ |
|
| 264 | + /** |
|
| 265 | + * @access public |
|
| 266 | + * @return string |
|
| 267 | + */ |
|
| 268 | 268 | public static function link_target() { |
| 269 | - return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
| 269 | + return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | // if NOT a custom template |
| 296 | 296 | if ( |
| 297 | - apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
| 297 | + apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
| 298 | 298 | || EE_Registry::instance() |
| 299 | - ->load_core( 'Front_Controller' ) |
|
| 300 | - ->get_selected_template() !== 'archive-espresso_events.php' |
|
| 299 | + ->load_core( 'Front_Controller' ) |
|
| 300 | + ->get_selected_template() !== 'archive-espresso_events.php' |
|
| 301 | 301 | ) { |
| 302 | 302 | // don't display entry meta because the existing theme will take care of that |
| 303 | 303 | add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' ); |
@@ -305,16 +305,16 @@ discard block |
||
| 305 | 305 | EEH_Template::load_espresso_theme_functions(); |
| 306 | 306 | // because we don't know if the theme is using the_excerpt() |
| 307 | 307 | add_filter( |
| 308 | - 'the_excerpt', |
|
| 309 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 310 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 311 | - ); |
|
| 308 | + 'the_excerpt', |
|
| 309 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 310 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 311 | + ); |
|
| 312 | 312 | // or the_content |
| 313 | 313 | add_filter( |
| 314 | - 'the_content', |
|
| 315 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 316 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 317 | - ); |
|
| 314 | + 'the_content', |
|
| 315 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 316 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 317 | + ); |
|
| 318 | 318 | // and just in case they are running get_the_excerpt() which DESTROYS things |
| 319 | 319 | add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
| 320 | 320 | // don't display entry meta because the existing theme will take care of that |
@@ -339,15 +339,15 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) { |
| 341 | 341 | remove_filter( |
| 342 | - 'the_excerpt', |
|
| 343 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 344 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 345 | - ); |
|
| 342 | + 'the_excerpt', |
|
| 343 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 344 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 345 | + ); |
|
| 346 | 346 | remove_filter( |
| 347 | - 'the_content', |
|
| 348 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 349 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 350 | - ); |
|
| 347 | + 'the_content', |
|
| 348 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 349 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 350 | + ); |
|
| 351 | 351 | $excerpt = EED_Events_Archive::event_details( $excerpt ); |
| 352 | 352 | } else { |
| 353 | 353 | EED_Events_Archive::$using_get_the_excerpt = true; |
@@ -438,17 +438,17 @@ discard block |
||
| 438 | 438 | // no further password checks required atm |
| 439 | 439 | add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
| 440 | 440 | // we need to first remove this callback from being applied to the_content() or the_excerpt() |
| 441 | - // (otherwise it will recurse and blow up the interweb) |
|
| 441 | + // (otherwise it will recurse and blow up the interweb) |
|
| 442 | 442 | remove_filter( |
| 443 | - 'the_excerpt', |
|
| 444 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 445 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 446 | - ); |
|
| 443 | + 'the_excerpt', |
|
| 444 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 445 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 446 | + ); |
|
| 447 | 447 | remove_filter( |
| 448 | - 'the_content', |
|
| 449 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 450 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 451 | - ); |
|
| 448 | + 'the_content', |
|
| 449 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 450 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 451 | + ); |
|
| 452 | 452 | remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
| 453 | 453 | // now add additional content depending on whether event is using the_excerpt() or the_content() |
| 454 | 454 | EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
@@ -456,20 +456,20 @@ discard block |
||
| 456 | 456 | $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content ); |
| 457 | 457 | // re-add our main filters (or else the next event won't have them) |
| 458 | 458 | add_filter( |
| 459 | - 'the_excerpt', |
|
| 460 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 461 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 462 | - ); |
|
| 459 | + 'the_excerpt', |
|
| 460 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 461 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 462 | + ); |
|
| 463 | 463 | add_filter( |
| 464 | - 'the_content', |
|
| 465 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 466 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 467 | - ); |
|
| 464 | + 'the_content', |
|
| 465 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 466 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 467 | + ); |
|
| 468 | 468 | add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
| 469 | 469 | remove_filter( |
| 470 | - 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
| 471 | - '__return_true' |
|
| 472 | - ); |
|
| 470 | + 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
| 471 | + '__return_true' |
|
| 472 | + ); |
|
| 473 | 473 | return $content; |
| 474 | 474 | } |
| 475 | 475 | |
@@ -485,15 +485,15 @@ discard block |
||
| 485 | 485 | // we need to first remove this callback from being applied to the_content() |
| 486 | 486 | // (otherwise it will recurse and blow up the interweb) |
| 487 | 487 | remove_filter( |
| 488 | - 'the_excerpt', |
|
| 489 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 490 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 491 | - ); |
|
| 488 | + 'the_excerpt', |
|
| 489 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 490 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 491 | + ); |
|
| 492 | 492 | remove_filter( |
| 493 | - 'the_content', |
|
| 494 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 495 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 496 | - ); |
|
| 493 | + 'the_content', |
|
| 494 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 495 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 496 | + ); |
|
| 497 | 497 | remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
| 498 | 498 | //now add additional content depending on whether event is using the_excerpt() or the_content() |
| 499 | 499 | EED_Events_Archive::_add_additional_excerpt_filters(); |
@@ -503,15 +503,15 @@ discard block |
||
| 503 | 503 | $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
| 504 | 504 | // re-add our main filters (or else the next event won't have them) |
| 505 | 505 | add_filter( |
| 506 | - 'the_excerpt', |
|
| 507 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 508 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 509 | - ); |
|
| 506 | + 'the_excerpt', |
|
| 507 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 508 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 509 | + ); |
|
| 510 | 510 | add_filter( |
| 511 | - 'the_content', |
|
| 512 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 513 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 514 | - ); |
|
| 511 | + 'the_content', |
|
| 512 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 513 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 514 | + ); |
|
| 515 | 515 | add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
| 516 | 516 | // but remove the other filters so that they don't get applied to the next post |
| 517 | 517 | EED_Events_Archive::_remove_additional_events_archive_filters(); |
@@ -588,20 +588,20 @@ discard block |
||
| 588 | 588 | */ |
| 589 | 589 | private static function _add_additional_excerpt_filters() { |
| 590 | 590 | add_filter( |
| 591 | - 'the_excerpt', |
|
| 592 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 593 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 594 | - ); |
|
| 591 | + 'the_excerpt', |
|
| 592 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 593 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 594 | + ); |
|
| 595 | 595 | add_filter( |
| 596 | - 'the_excerpt', |
|
| 597 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 598 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 599 | - ); |
|
| 596 | + 'the_excerpt', |
|
| 597 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 598 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 599 | + ); |
|
| 600 | 600 | add_filter( |
| 601 | - 'the_excerpt', |
|
| 602 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 603 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 604 | - ); |
|
| 601 | + 'the_excerpt', |
|
| 602 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
| 603 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 604 | + ); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | |
@@ -614,20 +614,20 @@ discard block |
||
| 614 | 614 | */ |
| 615 | 615 | private static function _add_additional_content_filters() { |
| 616 | 616 | add_filter( |
| 617 | - 'the_content', |
|
| 618 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 619 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 620 | - ); |
|
| 617 | + 'the_content', |
|
| 618 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 619 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 620 | + ); |
|
| 621 | 621 | add_filter( |
| 622 | - 'the_content', |
|
| 623 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 624 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 625 | - ); |
|
| 622 | + 'the_content', |
|
| 623 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 624 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 625 | + ); |
|
| 626 | 626 | add_filter( |
| 627 | - 'the_content', |
|
| 628 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 629 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 630 | - ); |
|
| 627 | + 'the_content', |
|
| 628 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
| 629 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 630 | + ); |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | |
@@ -640,35 +640,35 @@ discard block |
||
| 640 | 640 | */ |
| 641 | 641 | private static function _remove_additional_events_archive_filters() { |
| 642 | 642 | remove_filter( |
| 643 | - 'the_excerpt', |
|
| 644 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 645 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 646 | - ); |
|
| 643 | + 'the_excerpt', |
|
| 644 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 645 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 646 | + ); |
|
| 647 | 647 | remove_filter( |
| 648 | - 'the_excerpt', |
|
| 649 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 650 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 651 | - ); |
|
| 648 | + 'the_excerpt', |
|
| 649 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 650 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 651 | + ); |
|
| 652 | 652 | remove_filter( |
| 653 | - 'the_excerpt', |
|
| 654 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 655 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 656 | - ); |
|
| 653 | + 'the_excerpt', |
|
| 654 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
| 655 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 656 | + ); |
|
| 657 | 657 | remove_filter( |
| 658 | - 'the_content', |
|
| 659 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 660 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 661 | - ); |
|
| 658 | + 'the_content', |
|
| 659 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 660 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 661 | + ); |
|
| 662 | 662 | remove_filter( |
| 663 | - 'the_content', |
|
| 664 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 665 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 666 | - ); |
|
| 663 | + 'the_content', |
|
| 664 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 665 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 666 | + ); |
|
| 667 | 667 | remove_filter( |
| 668 | - 'the_content', |
|
| 669 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 670 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 671 | - ); |
|
| 668 | + 'the_content', |
|
| 669 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
| 670 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 671 | + ); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | |
@@ -683,50 +683,50 @@ discard block |
||
| 683 | 683 | //remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
| 684 | 684 | remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 ); |
| 685 | 685 | remove_filter( |
| 686 | - 'the_excerpt', |
|
| 687 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 688 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 689 | - ); |
|
| 686 | + 'the_excerpt', |
|
| 687 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 688 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 689 | + ); |
|
| 690 | 690 | remove_filter( |
| 691 | - 'the_excerpt', |
|
| 692 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 693 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 694 | - ); |
|
| 691 | + 'the_excerpt', |
|
| 692 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 693 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 694 | + ); |
|
| 695 | 695 | remove_filter( |
| 696 | - 'the_excerpt', |
|
| 697 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 698 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 699 | - ); |
|
| 696 | + 'the_excerpt', |
|
| 697 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 698 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 699 | + ); |
|
| 700 | 700 | remove_filter( |
| 701 | - 'the_excerpt', |
|
| 702 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 703 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 704 | - ); |
|
| 701 | + 'the_excerpt', |
|
| 702 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
| 703 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 704 | + ); |
|
| 705 | 705 | remove_filter( |
| 706 | - 'the_content', |
|
| 707 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 708 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 709 | - ); |
|
| 706 | + 'the_content', |
|
| 707 | + array( 'EED_Events_Archive', 'event_details' ), |
|
| 708 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 709 | + ); |
|
| 710 | 710 | remove_filter( |
| 711 | - 'the_content', |
|
| 712 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 713 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 714 | - ); |
|
| 711 | + 'the_content', |
|
| 712 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 713 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 714 | + ); |
|
| 715 | 715 | remove_filter( |
| 716 | - 'the_content', |
|
| 717 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 718 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 719 | - ); |
|
| 716 | + 'the_content', |
|
| 717 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 718 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 719 | + ); |
|
| 720 | 720 | remove_filter( |
| 721 | - 'the_content', |
|
| 722 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 723 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 724 | - ); |
|
| 721 | + 'the_content', |
|
| 722 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
| 723 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 724 | + ); |
|
| 725 | 725 | // don't display entry meta because the existing theme will take care of that |
| 726 | 726 | remove_filter( |
| 727 | - 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
| 728 | - '__return_false' |
|
| 729 | - ); |
|
| 727 | + 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
| 728 | + '__return_false' |
|
| 729 | + ); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | * @return void |
| 742 | 742 | */ |
| 743 | 743 | public function load_event_list_assets() { |
| 744 | - do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
| 744 | + do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
| 745 | 745 | add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
| 746 | 746 | add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
| 747 | 747 | add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton; |
| 4 | 4 | use EventEspresso\modules\events_archive\EventsArchiveIframe; |
| 5 | 5 | |
| 6 | -defined( 'EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
|
| 6 | +defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Event List |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @return EED_Events_Archive |
| 52 | 52 | */ |
| 53 | 53 | public static function instance() { |
| 54 | - return parent::get_instance( __CLASS__ ); |
|
| 54 | + return parent::get_instance(__CLASS__); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | 'event_list_iframe', |
| 81 | 81 | 'event_list' |
| 82 | 82 | ); |
| 83 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
| 83 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | * @return void |
| 91 | 91 | */ |
| 92 | 92 | public static function set_hooks_admin() { |
| 93 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
| 93 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
| 94 | 94 | // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
| 95 | 95 | // to load assets for "espresso_events" page on the "default" route (action) |
| 96 | 96 | add_action( |
| 97 | 97 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
| 98 | - array( 'EED_Events_Archive', 'event_list_iframe_embed_button' ), |
|
| 98 | + array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
| 99 | 99 | 10 |
| 100 | 100 | ); |
| 101 | 101 | } |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | * @return void |
| 111 | 111 | */ |
| 112 | 112 | public static function set_definitions() { |
| 113 | - define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
| 114 | - define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
| 113 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
| 114 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | /** |
| 120 | 120 | * set up EE_Events_Archive_Config |
| 121 | 121 | */ |
| 122 | - protected function set_config(){ |
|
| 123 | - $this->set_config_section( 'template_settings' ); |
|
| 124 | - $this->set_config_class( 'EE_Events_Archive_Config' ); |
|
| 125 | - $this->set_config_name( 'EED_Events_Archive' ); |
|
| 122 | + protected function set_config() { |
|
| 123 | + $this->set_config_section('template_settings'); |
|
| 124 | + $this->set_config_class('EE_Events_Archive_Config'); |
|
| 125 | + $this->set_config_name('EED_Events_Archive'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @return EventListIframeEmbedButton |
| 132 | 132 | */ |
| 133 | 133 | public static function get_iframe_embed_button() { |
| 134 | - if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton ) { |
|
| 134 | + if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
| 135 | 135 | self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
| 136 | 136 | } |
| 137 | 137 | return self::$_iframe_embed_button; |
@@ -157,35 +157,35 @@ discard block |
||
| 157 | 157 | * @param \EE_Events_Archive_Config $config |
| 158 | 158 | * @return \EE_Template_Part_Manager |
| 159 | 159 | */ |
| 160 | - public function initialize_template_parts( EE_Events_Archive_Config $config = null ) { |
|
| 160 | + public function initialize_template_parts(EE_Events_Archive_Config $config = null) { |
|
| 161 | 161 | $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
| 162 | 162 | EEH_Autoloader::instance()->register_template_part_autoloaders(); |
| 163 | 163 | $template_parts = new EE_Template_Part_Manager(); |
| 164 | 164 | $template_parts->add_template_part( |
| 165 | 165 | 'tickets', |
| 166 | - __( 'Ticket Selector', 'event_espresso' ), |
|
| 166 | + __('Ticket Selector', 'event_espresso'), |
|
| 167 | 167 | 'content-espresso_events-tickets.php', |
| 168 | 168 | $config->display_order_tickets |
| 169 | 169 | ); |
| 170 | 170 | $template_parts->add_template_part( |
| 171 | 171 | 'datetimes', |
| 172 | - __( 'Dates and Times', 'event_espresso' ), |
|
| 172 | + __('Dates and Times', 'event_espresso'), |
|
| 173 | 173 | 'content-espresso_events-datetimes.php', |
| 174 | 174 | $config->display_order_datetimes |
| 175 | 175 | ); |
| 176 | 176 | $template_parts->add_template_part( |
| 177 | 177 | 'event', |
| 178 | - __( 'Event Description', 'event_espresso' ), |
|
| 178 | + __('Event Description', 'event_espresso'), |
|
| 179 | 179 | 'content-espresso_events-details.php', |
| 180 | 180 | $config->display_order_event |
| 181 | 181 | ); |
| 182 | 182 | $template_parts->add_template_part( |
| 183 | 183 | 'venue', |
| 184 | - __( 'Venue Information', 'event_espresso' ), |
|
| 184 | + __('Venue Information', 'event_espresso'), |
|
| 185 | 185 | 'content-espresso_events-venues.php', |
| 186 | 186 | $config->display_order_venue |
| 187 | 187 | ); |
| 188 | - do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts ); |
|
| 188 | + do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
| 189 | 189 | return $template_parts; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | * @param WP $WP |
| 199 | 199 | * @return void |
| 200 | 200 | */ |
| 201 | - public function run( $WP ) { |
|
| 202 | - do_action( 'AHEE__EED_Events_Archive__before_run' ); |
|
| 201 | + public function run($WP) { |
|
| 202 | + do_action('AHEE__EED_Events_Archive__before_run'); |
|
| 203 | 203 | // ensure valid EE_Events_Archive_Config() object exists |
| 204 | 204 | $this->set_config(); |
| 205 | 205 | /** @type EE_Events_Archive_Config $config */ |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | EEH_Event_Query::add_query_filters(); |
| 212 | 212 | // set params that will get used by the filters |
| 213 | 213 | EEH_Event_Query::set_query_params( |
| 214 | - '', // month |
|
| 215 | - '', // category |
|
| 216 | - $config->display_expired_events, // show_expired |
|
| 217 | - 'start_date', // orderby |
|
| 214 | + '', // month |
|
| 215 | + '', // category |
|
| 216 | + $config->display_expired_events, // show_expired |
|
| 217 | + 'start_date', // orderby |
|
| 218 | 218 | 'ASC' // sort |
| 219 | 219 | ); |
| 220 | 220 | // check what template is loaded |
| 221 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
| 221 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function event_list_iframe() { |
| 247 | 247 | \EED_Events_Archive::$iframe = true; |
| 248 | - $event_list_iframe = new EventsArchiveIframe( $this ); |
|
| 248 | + $event_list_iframe = new EventsArchiveIframe($this); |
|
| 249 | 249 | $event_list_iframe->display(); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -283,42 +283,42 @@ discard block |
||
| 283 | 283 | * @param string $template |
| 284 | 284 | * @return string |
| 285 | 285 | */ |
| 286 | - public function template_include( $template = '' ) { |
|
| 286 | + public function template_include($template = '') { |
|
| 287 | 287 | // don't add content filter for dedicated EE child themes or private posts |
| 288 | - if ( ! EEH_Template::is_espresso_theme() ) { |
|
| 288 | + if ( ! EEH_Template::is_espresso_theme()) { |
|
| 289 | 289 | /** @type EE_Events_Archive_Config $config */ |
| 290 | 290 | $config = $this->config(); |
| 291 | 291 | // add status banner ? |
| 292 | - if ( $config->display_status_banner ) { |
|
| 293 | - add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 ); |
|
| 292 | + if ($config->display_status_banner) { |
|
| 293 | + add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
| 294 | 294 | } |
| 295 | 295 | // if NOT a custom template |
| 296 | 296 | if ( |
| 297 | 297 | apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
| 298 | 298 | || EE_Registry::instance() |
| 299 | - ->load_core( 'Front_Controller' ) |
|
| 299 | + ->load_core('Front_Controller') |
|
| 300 | 300 | ->get_selected_template() !== 'archive-espresso_events.php' |
| 301 | 301 | ) { |
| 302 | 302 | // don't display entry meta because the existing theme will take care of that |
| 303 | - add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' ); |
|
| 303 | + add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
| 304 | 304 | // load functions.php file for the theme (loaded by WP if using child theme) |
| 305 | 305 | EEH_Template::load_espresso_theme_functions(); |
| 306 | 306 | // because we don't know if the theme is using the_excerpt() |
| 307 | 307 | add_filter( |
| 308 | 308 | 'the_excerpt', |
| 309 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 309 | + array('EED_Events_Archive', 'event_details'), |
|
| 310 | 310 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 311 | 311 | ); |
| 312 | 312 | // or the_content |
| 313 | 313 | add_filter( |
| 314 | 314 | 'the_content', |
| 315 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 315 | + array('EED_Events_Archive', 'event_details'), |
|
| 316 | 316 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 317 | 317 | ); |
| 318 | 318 | // and just in case they are running get_the_excerpt() which DESTROYS things |
| 319 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
| 319 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 320 | 320 | // don't display entry meta because the existing theme will take care of that |
| 321 | - add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
| 321 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | return $template; |
@@ -333,25 +333,25 @@ discard block |
||
| 333 | 333 | * @param string $excerpt |
| 334 | 334 | * @return string |
| 335 | 335 | */ |
| 336 | - public static function get_the_excerpt( $excerpt = '' ) { |
|
| 337 | - if ( post_password_required() ) { |
|
| 336 | + public static function get_the_excerpt($excerpt = '') { |
|
| 337 | + if (post_password_required()) { |
|
| 338 | 338 | return $excerpt; |
| 339 | 339 | } |
| 340 | - if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) { |
|
| 340 | + if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
| 341 | 341 | remove_filter( |
| 342 | 342 | 'the_excerpt', |
| 343 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 343 | + array('EED_Events_Archive', 'event_details'), |
|
| 344 | 344 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 345 | 345 | ); |
| 346 | 346 | remove_filter( |
| 347 | 347 | 'the_content', |
| 348 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 348 | + array('EED_Events_Archive', 'event_details'), |
|
| 349 | 349 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 350 | 350 | ); |
| 351 | - $excerpt = EED_Events_Archive::event_details( $excerpt ); |
|
| 351 | + $excerpt = EED_Events_Archive::event_details($excerpt); |
|
| 352 | 352 | } else { |
| 353 | 353 | EED_Events_Archive::$using_get_the_excerpt = true; |
| 354 | - add_filter( 'wp_trim_excerpt', array( 'EED_Events_Archive', 'end_get_the_excerpt' ), 999, 1 ); |
|
| 354 | + add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
| 355 | 355 | } |
| 356 | 356 | return $excerpt; |
| 357 | 357 | } |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param string $text |
| 366 | 366 | * @return string |
| 367 | 367 | */ |
| 368 | - public static function end_get_the_excerpt( $text = '' ) { |
|
| 368 | + public static function end_get_the_excerpt($text = '') { |
|
| 369 | 369 | EED_Events_Archive::$using_get_the_excerpt = false; |
| 370 | 370 | return $text; |
| 371 | 371 | } |
@@ -380,10 +380,10 @@ discard block |
||
| 380 | 380 | * @param string $id |
| 381 | 381 | * @return string |
| 382 | 382 | */ |
| 383 | - public static function the_title( $title = '', $id = '' ) { |
|
| 383 | + public static function the_title($title = '', $id = '') { |
|
| 384 | 384 | global $post; |
| 385 | - if ( $post instanceof WP_Post ) { |
|
| 386 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
| 385 | + if ($post instanceof WP_Post) { |
|
| 386 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
| 387 | 387 | } |
| 388 | 388 | return $title; |
| 389 | 389 | } |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | * @param string $content |
| 398 | 398 | * @return string |
| 399 | 399 | */ |
| 400 | - public static function event_details( $content ) { |
|
| 400 | + public static function event_details($content) { |
|
| 401 | 401 | global $post; |
| 402 | 402 | static $current_post_ID = 0; |
| 403 | 403 | if ( |
@@ -406,8 +406,8 @@ discard block |
||
| 406 | 406 | && ! EED_Events_Archive::$using_get_the_excerpt |
| 407 | 407 | && ! post_password_required() |
| 408 | 408 | && ( |
| 409 | - apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false ) |
|
| 410 | - || ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false ) |
|
| 409 | + apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
| 410 | + || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
| 411 | 411 | ) |
| 412 | 412 | ) { |
| 413 | 413 | // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
@@ -416,8 +416,8 @@ discard block |
||
| 416 | 416 | // We want to allow those plugins to still do their thing and have access to our content, but depending on |
| 417 | 417 | // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
| 418 | 418 | // so the following allows this filter to be applied multiple times, but only once for real |
| 419 | - $current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
| 420 | - if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) { |
|
| 419 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 420 | + if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
| 421 | 421 | $content = \EED_Events_Archive::use_sortable_display_order(); |
| 422 | 422 | } else { |
| 423 | 423 | $content = \EED_Events_Archive::use_filterable_display_order(); |
@@ -436,36 +436,36 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | protected static function use_sortable_display_order() { |
| 438 | 438 | // no further password checks required atm |
| 439 | - add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
|
| 439 | + add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
| 440 | 440 | // we need to first remove this callback from being applied to the_content() or the_excerpt() |
| 441 | 441 | // (otherwise it will recurse and blow up the interweb) |
| 442 | 442 | remove_filter( |
| 443 | 443 | 'the_excerpt', |
| 444 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 444 | + array('EED_Events_Archive', 'event_details'), |
|
| 445 | 445 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 446 | 446 | ); |
| 447 | 447 | remove_filter( |
| 448 | 448 | 'the_content', |
| 449 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 449 | + array('EED_Events_Archive', 'event_details'), |
|
| 450 | 450 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 451 | 451 | ); |
| 452 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
| 452 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
| 453 | 453 | // now add additional content depending on whether event is using the_excerpt() or the_content() |
| 454 | 454 | EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
| 455 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
| 456 | - $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content ); |
|
| 455 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 456 | + $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
| 457 | 457 | // re-add our main filters (or else the next event won't have them) |
| 458 | 458 | add_filter( |
| 459 | 459 | 'the_excerpt', |
| 460 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 460 | + array('EED_Events_Archive', 'event_details'), |
|
| 461 | 461 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 462 | 462 | ); |
| 463 | 463 | add_filter( |
| 464 | 464 | 'the_content', |
| 465 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 465 | + array('EED_Events_Archive', 'event_details'), |
|
| 466 | 466 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 467 | 467 | ); |
| 468 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
| 468 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 469 | 469 | remove_filter( |
| 470 | 470 | 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
| 471 | 471 | '__return_true' |
@@ -486,36 +486,36 @@ discard block |
||
| 486 | 486 | // (otherwise it will recurse and blow up the interweb) |
| 487 | 487 | remove_filter( |
| 488 | 488 | 'the_excerpt', |
| 489 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 489 | + array('EED_Events_Archive', 'event_details'), |
|
| 490 | 490 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 491 | 491 | ); |
| 492 | 492 | remove_filter( |
| 493 | 493 | 'the_content', |
| 494 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 494 | + array('EED_Events_Archive', 'event_details'), |
|
| 495 | 495 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 496 | 496 | ); |
| 497 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
| 497 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
| 498 | 498 | //now add additional content depending on whether event is using the_excerpt() or the_content() |
| 499 | 499 | EED_Events_Archive::_add_additional_excerpt_filters(); |
| 500 | 500 | EED_Events_Archive::_add_additional_content_filters(); |
| 501 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' ); |
|
| 501 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
| 502 | 502 | // now load our template |
| 503 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
| 503 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 504 | 504 | // re-add our main filters (or else the next event won't have them) |
| 505 | 505 | add_filter( |
| 506 | 506 | 'the_excerpt', |
| 507 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 507 | + array('EED_Events_Archive', 'event_details'), |
|
| 508 | 508 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 509 | 509 | ); |
| 510 | 510 | add_filter( |
| 511 | 511 | 'the_content', |
| 512 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 512 | + array('EED_Events_Archive', 'event_details'), |
|
| 513 | 513 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 514 | 514 | ); |
| 515 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
| 515 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 516 | 516 | // but remove the other filters so that they don't get applied to the next post |
| 517 | 517 | EED_Events_Archive::_remove_additional_events_archive_filters(); |
| 518 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' ); |
|
| 518 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
| 519 | 519 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
| 520 | 520 | //return ! empty( $template ) ? $template : $content; |
| 521 | 521 | return $content; |
@@ -530,11 +530,11 @@ discard block |
||
| 530 | 530 | * @param string $content |
| 531 | 531 | * @return string |
| 532 | 532 | */ |
| 533 | - public static function event_datetimes( $content ) { |
|
| 534 | - if ( post_password_required() ) { |
|
| 533 | + public static function event_datetimes($content) { |
|
| 534 | + if (post_password_required()) { |
|
| 535 | 535 | return $content; |
| 536 | 536 | } |
| 537 | - return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
| 537 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | /** |
@@ -544,11 +544,11 @@ discard block |
||
| 544 | 544 | * @param string $content |
| 545 | 545 | * @return string |
| 546 | 546 | */ |
| 547 | - public static function event_tickets( $content ) { |
|
| 548 | - if ( post_password_required() ) { |
|
| 547 | + public static function event_tickets($content) { |
|
| 548 | + if (post_password_required()) { |
|
| 549 | 549 | return $content; |
| 550 | 550 | } |
| 551 | - return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
| 551 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | |
@@ -560,8 +560,8 @@ discard block |
||
| 560 | 560 | * @param string $content |
| 561 | 561 | * @return string |
| 562 | 562 | */ |
| 563 | - public static function event_venue( $content ) { |
|
| 564 | - return EED_Events_Archive::event_venues( $content ); |
|
| 563 | + public static function event_venue($content) { |
|
| 564 | + return EED_Events_Archive::event_venues($content); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | /** |
@@ -571,11 +571,11 @@ discard block |
||
| 571 | 571 | * @param string $content |
| 572 | 572 | * @return string |
| 573 | 573 | */ |
| 574 | - public static function event_venues( $content ) { |
|
| 575 | - if ( post_password_required() ) { |
|
| 574 | + public static function event_venues($content) { |
|
| 575 | + if (post_password_required()) { |
|
| 576 | 576 | return $content; |
| 577 | 577 | } |
| 578 | - return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
| 578 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | |
@@ -589,17 +589,17 @@ discard block |
||
| 589 | 589 | private static function _add_additional_excerpt_filters() { |
| 590 | 590 | add_filter( |
| 591 | 591 | 'the_excerpt', |
| 592 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 592 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 593 | 593 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
| 594 | 594 | ); |
| 595 | 595 | add_filter( |
| 596 | 596 | 'the_excerpt', |
| 597 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 597 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 598 | 598 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
| 599 | 599 | ); |
| 600 | 600 | add_filter( |
| 601 | 601 | 'the_excerpt', |
| 602 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 602 | + array('EED_Events_Archive', 'event_venues'), |
|
| 603 | 603 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
| 604 | 604 | ); |
| 605 | 605 | } |
@@ -615,17 +615,17 @@ discard block |
||
| 615 | 615 | private static function _add_additional_content_filters() { |
| 616 | 616 | add_filter( |
| 617 | 617 | 'the_content', |
| 618 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 618 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 619 | 619 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
| 620 | 620 | ); |
| 621 | 621 | add_filter( |
| 622 | 622 | 'the_content', |
| 623 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 623 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 624 | 624 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
| 625 | 625 | ); |
| 626 | 626 | add_filter( |
| 627 | 627 | 'the_content', |
| 628 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 628 | + array('EED_Events_Archive', 'event_venues'), |
|
| 629 | 629 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
| 630 | 630 | ); |
| 631 | 631 | } |
@@ -641,32 +641,32 @@ discard block |
||
| 641 | 641 | private static function _remove_additional_events_archive_filters() { |
| 642 | 642 | remove_filter( |
| 643 | 643 | 'the_excerpt', |
| 644 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 644 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 645 | 645 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
| 646 | 646 | ); |
| 647 | 647 | remove_filter( |
| 648 | 648 | 'the_excerpt', |
| 649 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 649 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 650 | 650 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
| 651 | 651 | ); |
| 652 | 652 | remove_filter( |
| 653 | 653 | 'the_excerpt', |
| 654 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 654 | + array('EED_Events_Archive', 'event_venues'), |
|
| 655 | 655 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
| 656 | 656 | ); |
| 657 | 657 | remove_filter( |
| 658 | 658 | 'the_content', |
| 659 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 659 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 660 | 660 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
| 661 | 661 | ); |
| 662 | 662 | remove_filter( |
| 663 | 663 | 'the_content', |
| 664 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 664 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 665 | 665 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
| 666 | 666 | ); |
| 667 | 667 | remove_filter( |
| 668 | 668 | 'the_content', |
| 669 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 669 | + array('EED_Events_Archive', 'event_venues'), |
|
| 670 | 670 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
| 671 | 671 | ); |
| 672 | 672 | } |
@@ -681,45 +681,45 @@ discard block |
||
| 681 | 681 | */ |
| 682 | 682 | public static function remove_all_events_archive_filters() { |
| 683 | 683 | //remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
| 684 | - remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 ); |
|
| 684 | + remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1); |
|
| 685 | 685 | remove_filter( |
| 686 | 686 | 'the_excerpt', |
| 687 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 687 | + array('EED_Events_Archive', 'event_details'), |
|
| 688 | 688 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 689 | 689 | ); |
| 690 | 690 | remove_filter( |
| 691 | 691 | 'the_excerpt', |
| 692 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 692 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 693 | 693 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
| 694 | 694 | ); |
| 695 | 695 | remove_filter( |
| 696 | 696 | 'the_excerpt', |
| 697 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 697 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 698 | 698 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
| 699 | 699 | ); |
| 700 | 700 | remove_filter( |
| 701 | 701 | 'the_excerpt', |
| 702 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 702 | + array('EED_Events_Archive', 'event_venues'), |
|
| 703 | 703 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
| 704 | 704 | ); |
| 705 | 705 | remove_filter( |
| 706 | 706 | 'the_content', |
| 707 | - array( 'EED_Events_Archive', 'event_details' ), |
|
| 707 | + array('EED_Events_Archive', 'event_details'), |
|
| 708 | 708 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
| 709 | 709 | ); |
| 710 | 710 | remove_filter( |
| 711 | 711 | 'the_content', |
| 712 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
| 712 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 713 | 713 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
| 714 | 714 | ); |
| 715 | 715 | remove_filter( |
| 716 | 716 | 'the_content', |
| 717 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
| 717 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 718 | 718 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
| 719 | 719 | ); |
| 720 | 720 | remove_filter( |
| 721 | 721 | 'the_content', |
| 722 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
| 722 | + array('EED_Events_Archive', 'event_venues'), |
|
| 723 | 723 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
| 724 | 724 | ); |
| 725 | 725 | // don't display entry meta because the existing theme will take care of that |
@@ -741,12 +741,12 @@ discard block |
||
| 741 | 741 | * @return void |
| 742 | 742 | */ |
| 743 | 743 | public function load_event_list_assets() { |
| 744 | - do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
| 745 | - add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
|
| 746 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
| 747 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
| 748 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
| 749 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
| 744 | + do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
| 745 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
| 746 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 747 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 748 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 749 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 750 | 750 | } |
| 751 | 751 | } |
| 752 | 752 | |
@@ -763,13 +763,13 @@ discard block |
||
| 763 | 763 | */ |
| 764 | 764 | public function wp_enqueue_scripts() { |
| 765 | 765 | // get some style |
| 766 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) { |
|
| 766 | + if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) { |
|
| 767 | 767 | // first check uploads folder |
| 768 | - if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
| 769 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
| 768 | + if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
| 769 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
| 770 | 770 | } else { |
| 771 | 771 | } |
| 772 | - wp_enqueue_style( $this->theme ); |
|
| 772 | + wp_enqueue_style($this->theme); |
|
| 773 | 773 | |
| 774 | 774 | } |
| 775 | 775 | } |
@@ -787,8 +787,8 @@ discard block |
||
| 787 | 787 | */ |
| 788 | 788 | public static function template_settings_form() { |
| 789 | 789 | $template_settings = EE_Registry::instance()->CFG->template_settings; |
| 790 | - $template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
| 791 | - $template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive ); |
|
| 790 | + $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
| 791 | + $template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive); |
|
| 792 | 792 | $events_archive_settings = array( |
| 793 | 793 | 'display_status_banner' => 0, |
| 794 | 794 | 'display_description' => 1, |
@@ -797,8 +797,8 @@ discard block |
||
| 797 | 797 | 'display_venue' => 0, |
| 798 | 798 | 'display_expired_events' => 0 |
| 799 | 799 | ); |
| 800 | - $events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive ); |
|
| 801 | - EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings ); |
|
| 800 | + $events_archive_settings = array_merge($events_archive_settings, (array) $template_settings->EED_Events_Archive); |
|
| 801 | + EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $events_archive_settings); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | |
@@ -814,16 +814,16 @@ discard block |
||
| 814 | 814 | * @param EE_Request_Handler $REQ |
| 815 | 815 | * @return EE_Template_Config |
| 816 | 816 | */ |
| 817 | - public static function update_template_settings( $CFG, $REQ ) { |
|
| 817 | + public static function update_template_settings($CFG, $REQ) { |
|
| 818 | 818 | $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
| 819 | 819 | // unless we are resetting the config... |
| 820 | - if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) { |
|
| 821 | - $CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0; |
|
| 822 | - $CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1; |
|
| 823 | - $CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0; |
|
| 824 | - $CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1; |
|
| 825 | - $CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0; |
|
| 826 | - $CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; } |
|
| 820 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
| 821 | + $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
| 822 | + $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
| 823 | + $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
| 824 | + $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
| 825 | + $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
| 826 | + $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; } |
|
| 827 | 827 | return $CFG; |
| 828 | 828 | } |
| 829 | 829 | |
@@ -836,10 +836,10 @@ discard block |
||
| 836 | 836 | * @param string $extra_class |
| 837 | 837 | * @return string |
| 838 | 838 | */ |
| 839 | - public static function event_list_css( $extra_class = '' ) { |
|
| 840 | - $event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array(); |
|
| 839 | + public static function event_list_css($extra_class = '') { |
|
| 840 | + $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
| 841 | 841 | $event_list_css[] = 'espresso-event-list-event'; |
| 842 | - return implode( ' ', $event_list_css ); |
|
| 842 | + return implode(' ', $event_list_css); |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | 845 | |
@@ -866,9 +866,9 @@ discard block |
||
| 866 | 866 | * @param $value |
| 867 | 867 | * @return bool |
| 868 | 868 | */ |
| 869 | - public static function display_description( $value ) { |
|
| 869 | + public static function display_description($value) { |
|
| 870 | 870 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
| 871 | - $display_description= isset( $config->display_description ) ? $config->display_description : 1; |
|
| 871 | + $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
| 872 | 872 | return $display_description === $value ? TRUE : FALSE; |
| 873 | 873 | } |
| 874 | 874 | |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | */ |
| 882 | 882 | public static function display_ticket_selector() { |
| 883 | 883 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
| 884 | - return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE; |
|
| 884 | + return isset($config->display_ticket_selector) && $config->display_ticket_selector ? TRUE : FALSE; |
|
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | */ |
| 895 | 895 | public static function display_venue() { |
| 896 | 896 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
| 897 | - return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
| 897 | + return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | |
@@ -906,7 +906,7 @@ discard block |
||
| 906 | 906 | */ |
| 907 | 907 | public static function display_datetimes() { |
| 908 | 908 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
| 909 | - return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE; |
|
| 909 | + return isset($config->display_datetimes) && $config->display_datetimes ? TRUE : FALSE; |
|
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | * @return string |
| 922 | 922 | */ |
| 923 | 923 | public static function event_list_title() { |
| 924 | - return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' )); |
|
| 924 | + return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso')); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | |
@@ -930,11 +930,11 @@ discard block |
||
| 930 | 930 | /** |
| 931 | 931 | * @since 4.4.0 |
| 932 | 932 | */ |
| 933 | - public static function _doing_it_wrong_notice( $function = '' ) { |
|
| 933 | + public static function _doing_it_wrong_notice($function = '') { |
|
| 934 | 934 | EE_Error::doing_it_wrong( |
| 935 | 935 | __FUNCTION__, |
| 936 | 936 | sprintf( |
| 937 | - __( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ), |
|
| 937 | + __('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'), |
|
| 938 | 938 | $function, |
| 939 | 939 | '<br />', |
| 940 | 940 | '4.6.0' |
@@ -956,89 +956,89 @@ discard block |
||
| 956 | 956 | * @deprecated |
| 957 | 957 | * @since 4.4.0 |
| 958 | 958 | */ |
| 959 | - public function posts_fields( $SQL, WP_Query $wp_query ) { |
|
| 960 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 961 | - return EEH_Event_Query::posts_fields( $SQL, $wp_query ); |
|
| 959 | + public function posts_fields($SQL, WP_Query $wp_query) { |
|
| 960 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 961 | + return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
| 962 | 962 | } |
| 963 | 963 | /** |
| 964 | 964 | * @deprecated |
| 965 | 965 | * @since 4.4.0 |
| 966 | 966 | */ |
| 967 | - public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
|
| 968 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 969 | - return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params ); |
|
| 967 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) { |
|
| 968 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 969 | + return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
| 970 | 970 | } |
| 971 | 971 | /** |
| 972 | 972 | * @deprecated |
| 973 | 973 | * @since 4.4.0 |
| 974 | 974 | */ |
| 975 | - public function posts_join( $SQL, WP_Query $wp_query ) { |
|
| 976 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 977 | - return EEH_Event_Query::posts_join( $SQL, $wp_query ); |
|
| 975 | + public function posts_join($SQL, WP_Query $wp_query) { |
|
| 976 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 977 | + return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
| 978 | 978 | } |
| 979 | 979 | /** |
| 980 | 980 | * @deprecated |
| 981 | 981 | * @since 4.4.0 |
| 982 | 982 | */ |
| 983 | - public static function posts_join_sql_for_terms( $join_terms = NULL ) { |
|
| 984 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 985 | - return EEH_Event_Query::posts_join_sql_for_terms( $join_terms ); |
|
| 983 | + public static function posts_join_sql_for_terms($join_terms = NULL) { |
|
| 984 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 985 | + return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
| 986 | 986 | } |
| 987 | 987 | /** |
| 988 | 988 | * @deprecated |
| 989 | 989 | * @since 4.4.0 |
| 990 | 990 | */ |
| 991 | - public static function posts_join_for_orderby( $orderby_params = array() ) { |
|
| 992 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 993 | - return EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
| 991 | + public static function posts_join_for_orderby($orderby_params = array()) { |
|
| 992 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 993 | + return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
| 994 | 994 | } |
| 995 | 995 | /** |
| 996 | 996 | * @deprecated |
| 997 | 997 | * @since 4.4.0 |
| 998 | 998 | */ |
| 999 | - public function posts_where( $SQL, WP_Query $wp_query ) { |
|
| 1000 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 1001 | - return EEH_Event_Query::posts_where( $SQL, $wp_query ); |
|
| 999 | + public function posts_where($SQL, WP_Query $wp_query) { |
|
| 1000 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1001 | + return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
| 1002 | 1002 | } |
| 1003 | 1003 | /** |
| 1004 | 1004 | * @deprecated |
| 1005 | 1005 | * @since 4.4.0 |
| 1006 | 1006 | */ |
| 1007 | - public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
|
| 1008 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 1009 | - return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired ); |
|
| 1007 | + public static function posts_where_sql_for_show_expired($show_expired = FALSE) { |
|
| 1008 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1009 | + return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
| 1010 | 1010 | } |
| 1011 | 1011 | /** |
| 1012 | 1012 | * @deprecated |
| 1013 | 1013 | * @since 4.4.0 |
| 1014 | 1014 | */ |
| 1015 | - public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
|
| 1016 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 1017 | - return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug ); |
|
| 1015 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) { |
|
| 1016 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1017 | + return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
| 1018 | 1018 | } |
| 1019 | 1019 | /** |
| 1020 | 1020 | * @deprecated |
| 1021 | 1021 | * @since 4.4.0 |
| 1022 | 1022 | */ |
| 1023 | - public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
|
| 1024 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 1025 | - return EEH_Event_Query::posts_where_sql_for_event_list_month( $month ); |
|
| 1023 | + public static function posts_where_sql_for_event_list_month($month = NULL) { |
|
| 1024 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1025 | + return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | /** |
| 1028 | 1028 | * @deprecated |
| 1029 | 1029 | * @since 4.4.0 |
| 1030 | 1030 | */ |
| 1031 | - public function posts_orderby( $SQL, WP_Query $wp_query ) { |
|
| 1032 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 1033 | - return EEH_Event_Query::posts_orderby( $SQL, $wp_query ); |
|
| 1031 | + public function posts_orderby($SQL, WP_Query $wp_query) { |
|
| 1032 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1033 | + return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | /** |
| 1036 | 1036 | * @deprecated |
| 1037 | 1037 | * @since 4.4.0 |
| 1038 | 1038 | */ |
| 1039 | - public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
|
| 1040 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 1041 | - return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort ); |
|
| 1039 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') { |
|
| 1040 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1041 | + return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | |
@@ -1069,8 +1069,8 @@ discard block |
||
| 1069 | 1069 | * @param string $extra_class |
| 1070 | 1070 | * @return string |
| 1071 | 1071 | */ |
| 1072 | -function espresso_event_list_css( $extra_class = '' ) { |
|
| 1073 | - return EED_Events_Archive::event_list_css( $extra_class ); |
|
| 1072 | +function espresso_event_list_css($extra_class = '') { |
|
| 1073 | + return EED_Events_Archive::event_list_css($extra_class); |
|
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | 1076 | /** |
@@ -1084,14 +1084,14 @@ discard block |
||
| 1084 | 1084 | * @return bool |
| 1085 | 1085 | */ |
| 1086 | 1086 | function espresso_display_full_description_in_event_list() { |
| 1087 | - return EED_Events_Archive::display_description( 2 ); |
|
| 1087 | + return EED_Events_Archive::display_description(2); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | /** |
| 1091 | 1091 | * @return bool |
| 1092 | 1092 | */ |
| 1093 | 1093 | function espresso_display_excerpt_in_event_list() { |
| 1094 | - return EED_Events_Archive::display_description( 1 ); |
|
| 1094 | + return EED_Events_Archive::display_description(1); |
|
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | 1097 | /** |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -14,604 +14,604 @@ discard block |
||
| 14 | 14 | class EE_Register_CPTs |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * This property is used to hold an array of EE_default_term objects assigned to a custom post type when the post |
|
| 19 | - * for that post type is published with no terms set for the taxonomy. |
|
| 20 | - * |
|
| 21 | - * @var array of EE_Default_Term objects |
|
| 22 | - */ |
|
| 23 | - protected $_default_terms = array(); |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * constructor |
|
| 29 | - * instantiated at init priority 5 |
|
| 30 | - */ |
|
| 31 | - public function __construct() |
|
| 32 | - { |
|
| 33 | - // register taxonomies |
|
| 34 | - $taxonomies = self::get_taxonomies(); |
|
| 35 | - foreach ($taxonomies as $taxonomy => $tax) { |
|
| 36 | - $this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']); |
|
| 37 | - } |
|
| 38 | - // register CPTs |
|
| 39 | - $CPTs = self::get_CPTs(); |
|
| 40 | - foreach ($CPTs as $CPT_name => $CPT) { |
|
| 41 | - $this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'], |
|
| 42 | - $CPT['singular_slug'], $CPT['plural_slug']); |
|
| 43 | - } |
|
| 44 | - // setup default terms in any of our taxonomies (but only if we're in admin). |
|
| 45 | - // Why not added via register_activation_hook? |
|
| 46 | - // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies |
|
| 47 | - // (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
|
| 48 | - // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
|
| 49 | - // if ( is_admin() ) { |
|
| 50 | - // $this->set_must_use_event_types(); |
|
| 51 | - // } |
|
| 52 | - //set default terms |
|
| 53 | - $this->set_default_term('espresso_event_type', 'single-event', array('espresso_events')); |
|
| 54 | - add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10); |
|
| 55 | - // hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts |
|
| 56 | - // IF they don't have a term for that taxonomy set. |
|
| 57 | - add_action('save_post', array($this, 'save_default_term'), 100, 2); |
|
| 58 | - // remove no html restrictions from core wp saving of term descriptions. |
|
| 59 | - // Note. this will affect only registered EE taxonomies. |
|
| 60 | - $this->_allow_html_descriptions_for_ee_taxonomies(); |
|
| 61 | - do_action('AHEE__EE_Register_CPTs__construct_end', $this); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
| 68 | - * |
|
| 69 | - * @since 4.5.0 |
|
| 70 | - * @return void |
|
| 71 | - */ |
|
| 72 | - public static function maybe_flush_rewrite_rules() |
|
| 73 | - { |
|
| 74 | - if (get_option('ee_flush_rewrite_rules', true)) { |
|
| 75 | - flush_rewrite_rules(); |
|
| 76 | - update_option('ee_flush_rewrite_rules', false); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * By default, WordPress strips all html from term taxonomy description content. The purpose of this method is to |
|
| 84 | - * remove that restriction and ensure that we still run ee term taxonomy descriptions through some full html |
|
| 85 | - * sanitization equivalent to the post content field. |
|
| 86 | - * |
|
| 87 | - * @since 4.7.8 |
|
| 88 | - */ |
|
| 89 | - protected function _allow_html_descriptions_for_ee_taxonomies() |
|
| 90 | - { |
|
| 91 | - // first remove default filter for term description but we have to do this earlier |
|
| 92 | - // before wp sets their own filter |
|
| 93 | - // because they just set a global filter on all term descriptions before the custom term description filter. |
|
| 94 | - // Really sux. |
|
| 95 | - add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Callback for pre_term_description hook. |
|
| 102 | - * |
|
| 103 | - * @param string $description The description content. |
|
| 104 | - * @param string $taxonomy The taxonomy name for the taxonomy being filtered. |
|
| 105 | - * @return string |
|
| 106 | - */ |
|
| 107 | - public function ee_filter_ee_term_description_not_wp($description, $taxonomy) |
|
| 108 | - { |
|
| 109 | - //get a list of EE taxonomies |
|
| 110 | - $ee_taxonomies = array_keys(self::get_taxonomies()); |
|
| 111 | - //only do our own thing if the taxonomy listed is an ee taxonomy. |
|
| 112 | - if (in_array($taxonomy, $ee_taxonomies, true)) { |
|
| 113 | - //remove default wp filter |
|
| 114 | - remove_filter('pre_term_description', 'wp_filter_kses'); |
|
| 115 | - //sanitize THIS content. |
|
| 116 | - $description = wp_kses($description, wp_kses_allowed_html('post')); |
|
| 117 | - } |
|
| 118 | - return $description; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * get_taxonomies |
|
| 125 | - * |
|
| 126 | - * @access public |
|
| 127 | - * @return array |
|
| 128 | - */ |
|
| 129 | - public static function get_taxonomies() |
|
| 130 | - { |
|
| 131 | - // define taxonomies |
|
| 132 | - return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( |
|
| 133 | - 'espresso_event_categories' => array( |
|
| 134 | - 'singular_name' => __("Event Category", "event_espresso"), |
|
| 135 | - 'plural_name' => __("Event Categories", "event_espresso"), |
|
| 136 | - 'args' => array( |
|
| 137 | - 'public' => true, |
|
| 138 | - 'show_in_nav_menus' => true, |
|
| 139 | - 'show_in_rest' => true, |
|
| 140 | - 'capabilities' => array( |
|
| 141 | - 'manage_terms' => 'ee_manage_event_categories', |
|
| 142 | - 'edit_terms' => 'ee_edit_event_category', |
|
| 143 | - 'delete_terms' => 'ee_delete_event_category', |
|
| 144 | - 'assign_terms' => 'ee_assign_event_category', |
|
| 145 | - ), |
|
| 146 | - 'rewrite' => array('slug' => __('event-category', 'event_espresso')), |
|
| 147 | - ), |
|
| 148 | - ), |
|
| 149 | - 'espresso_venue_categories' => array( |
|
| 150 | - 'singular_name' => __("Venue Category", "event_espresso"), |
|
| 151 | - 'plural_name' => __("Venue Categories", "event_espresso"), |
|
| 152 | - 'args' => array( |
|
| 153 | - 'public' => true, |
|
| 154 | - 'show_in_nav_menus' => false, //by default this doesn't show for decaf |
|
| 155 | - 'show_in_rest' => true, |
|
| 156 | - 'capabilities' => array( |
|
| 157 | - 'manage_terms' => 'ee_manage_venue_categories', |
|
| 158 | - 'edit_terms' => 'ee_edit_venue_category', |
|
| 159 | - 'delete_terms' => 'ee_delete_venue_category', |
|
| 160 | - 'assign_terms' => 'ee_assign_venue_category', |
|
| 161 | - ), |
|
| 162 | - 'rewrite' => array('slug' => __('venue-category', 'event_espresso')), |
|
| 163 | - ), |
|
| 164 | - ), |
|
| 165 | - 'espresso_event_type' => array( |
|
| 166 | - 'singular_name' => __("Event Type", "event_espresso"), |
|
| 167 | - 'plural_name' => __("Event Types", "event_espresso"), |
|
| 168 | - 'args' => array( |
|
| 169 | - 'public' => true, |
|
| 170 | - 'show_ui' => false, |
|
| 171 | - 'show_in_rest' => true, |
|
| 172 | - 'capabilities' => array( |
|
| 173 | - 'manage_terms' => 'ee_read_event_type', |
|
| 174 | - 'edit_terms' => 'ee_edit_event_type', |
|
| 175 | - 'delete_terms' => 'ee_delete_event_type', |
|
| 176 | - 'assign_terms' => 'ee_assign_event_type', |
|
| 177 | - ), |
|
| 178 | - 'rewrite' => array('slug' => __('event-type', 'event_espresso')), |
|
| 179 | - 'hierarchical' => true, |
|
| 180 | - ), |
|
| 181 | - ), |
|
| 182 | - )); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * This returns the corresponding model name for cpts registered by EE. |
|
| 189 | - * |
|
| 190 | - * @since 4.6.16.rc.000 |
|
| 191 | - * @param string $post_type_slug If a slug is included, then attempt to retrieve the model name for |
|
| 192 | - * the given cpt slug. Otherwise if empty, then we'll return all cpt |
|
| 193 | - * model names for cpts registered in EE. |
|
| 194 | - * @return array Empty array if no matching model names for the given slug or an array of model |
|
| 195 | - * names indexed by post type slug. |
|
| 196 | - */ |
|
| 197 | - public static function get_cpt_model_names($post_type_slug = '') |
|
| 198 | - { |
|
| 199 | - $cpts = self::get_CPTs(); |
|
| 200 | - //first if slug passed in... |
|
| 201 | - if ( ! empty($post_type_slug)) { |
|
| 202 | - //match? |
|
| 203 | - if ( |
|
| 204 | - ! isset($cpts[$post_type_slug]) |
|
| 205 | - || (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name'])) |
|
| 206 | - ) { |
|
| 207 | - return array(); |
|
| 208 | - } |
|
| 209 | - //k let's get the model name for this cpt. |
|
| 210 | - return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name'])); |
|
| 211 | - } |
|
| 212 | - //if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
|
| 213 | - $cpt_models = array(); |
|
| 214 | - foreach ($cpts as $slug => $args) { |
|
| 215 | - if ( ! empty($args['class_name'])) { |
|
| 216 | - $cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']); |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - return $cpt_models; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * This instantiates cpt models related to the cpts registered via EE. |
|
| 226 | - * |
|
| 227 | - * @since 4.6.16.rc.000 |
|
| 228 | - * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
| 229 | - * the cpt matching the given slug. Otherwise all cpt models will be |
|
| 230 | - * instantiated (if possible). |
|
| 231 | - * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
| 232 | - * EEM models indexed by post slug. |
|
| 233 | - */ |
|
| 234 | - public static function instantiate_cpt_models($post_type_slug = '') |
|
| 235 | - { |
|
| 236 | - $cpt_model_names = self::get_cpt_model_names($post_type_slug); |
|
| 237 | - $instantiated = array(); |
|
| 238 | - foreach ($cpt_model_names as $slug => $model_name) { |
|
| 239 | - $instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name)); |
|
| 240 | - if ($instance instanceof EEM_CPT_Base) { |
|
| 241 | - $instantiated[$slug] = $instance; |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - return $instantiated; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * get_CPTs |
|
| 251 | - * |
|
| 252 | - * @access public |
|
| 253 | - * @return array |
|
| 254 | - */ |
|
| 255 | - public static function get_CPTs() |
|
| 256 | - { |
|
| 257 | - // define CPTs |
|
| 258 | - // NOTE the ['args']['page_templates'] array index is something specific to our CPTs |
|
| 259 | - // and not part of the WP custom post type api. |
|
| 260 | - return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array( |
|
| 261 | - 'espresso_events' => array( |
|
| 262 | - 'singular_name' => __("Event", "event_espresso"), |
|
| 263 | - 'plural_name' => __("Events", "event_espresso"), |
|
| 264 | - 'singular_slug' => __("event", "event_espresso"), |
|
| 265 | - 'plural_slug' => EE_Registry::instance()->CFG->core->event_cpt_slug, |
|
| 266 | - 'class_name' => 'EE_Event', |
|
| 267 | - 'args' => array( |
|
| 268 | - 'public' => true, |
|
| 269 | - 'show_in_nav_menus' => true, |
|
| 270 | - 'capability_type' => 'event', |
|
| 271 | - 'capabilities' => array( |
|
| 272 | - 'edit_post' => 'ee_edit_event', |
|
| 273 | - 'read_post' => 'ee_read_event', |
|
| 274 | - 'delete_post' => 'ee_delete_event', |
|
| 275 | - 'edit_posts' => 'ee_edit_events', |
|
| 276 | - 'edit_others_posts' => 'ee_edit_others_events', |
|
| 277 | - 'publish_posts' => 'ee_publish_events', |
|
| 278 | - 'read_private_posts' => 'ee_read_private_events', |
|
| 279 | - 'delete_posts' => 'ee_delete_events', |
|
| 280 | - 'delete_private_posts' => 'ee_delete_private_events', |
|
| 281 | - 'delete_published_posts' => 'ee_delete_published_events', |
|
| 282 | - 'delete_others_posts' => 'ee_delete_others_events', |
|
| 283 | - 'edit_private_posts' => 'ee_edit_private_events', |
|
| 284 | - 'edit_published_posts' => 'ee_edit_published_events', |
|
| 285 | - ), |
|
| 286 | - 'taxonomies' => array( |
|
| 287 | - 'espresso_event_categories', |
|
| 288 | - 'espresso_event_type', |
|
| 289 | - 'post_tag', |
|
| 290 | - ), |
|
| 291 | - 'page_templates' => true, |
|
| 292 | - ), |
|
| 293 | - ), |
|
| 294 | - 'espresso_venues' => array( |
|
| 295 | - 'singular_name' => __("Venue", "event_espresso"), |
|
| 296 | - 'plural_name' => __("Venues", "event_espresso"), |
|
| 297 | - 'singular_slug' => __("venue", "event_espresso"), |
|
| 298 | - 'plural_slug' => __("venues", "event_espresso"), |
|
| 299 | - 'class_name' => 'EE_Venue', |
|
| 300 | - 'args' => array( |
|
| 301 | - 'public' => true, |
|
| 302 | - 'show_in_nav_menus' => false, //by default this doesn't show for decaf, |
|
| 303 | - 'capability_type' => 'venue', |
|
| 304 | - 'capabilities' => array( |
|
| 305 | - 'edit_post' => 'ee_edit_venue', |
|
| 306 | - 'read_post' => 'ee_read_venue', |
|
| 307 | - 'delete_post' => 'ee_delete_venue', |
|
| 308 | - 'edit_posts' => 'ee_edit_venues', |
|
| 309 | - 'edit_others_posts' => 'ee_edit_others_venues', |
|
| 310 | - 'publish_posts' => 'ee_publish_venues', |
|
| 311 | - 'read_private_posts' => 'ee_read_private_venues', |
|
| 312 | - 'delete_posts' => 'ee_delete_venues', |
|
| 313 | - 'delete_private_posts' => 'ee_delete_private_venues', |
|
| 314 | - 'delete_published_posts' => 'ee_delete_published_venues', |
|
| 315 | - 'delete_others_posts' => 'ee_edit_others_venues', |
|
| 316 | - 'edit_private_posts' => 'ee_edit_private_venues', |
|
| 317 | - 'edit_published_posts' => 'ee_edit_published_venues', |
|
| 318 | - ), |
|
| 319 | - 'taxonomies' => array( |
|
| 320 | - 'espresso_venue_categories', |
|
| 321 | - 'post_tag', |
|
| 322 | - ), |
|
| 323 | - 'page_templates' => true, |
|
| 324 | - ), |
|
| 325 | - ), |
|
| 326 | - 'espresso_attendees' => array( |
|
| 327 | - 'singular_name' => __("Contact", "event_espresso"), |
|
| 328 | - 'plural_name' => __("Contacts", "event_espresso"), |
|
| 329 | - 'singular_slug' => __("contact", "event_espresso"), |
|
| 330 | - 'plural_slug' => __("contacts", "event_espresso"), |
|
| 331 | - 'class_name' => 'EE_Attendee', |
|
| 332 | - 'args' => array( |
|
| 333 | - 'public' => false, |
|
| 334 | - 'publicly_queryable' => false, |
|
| 335 | - 'hierarchical' => false, |
|
| 336 | - 'has_archive' => false, |
|
| 337 | - 'taxonomies' => array('post_tag'), |
|
| 338 | - 'capability_type' => 'contact', |
|
| 339 | - 'capabilities' => array( |
|
| 340 | - 'edit_post' => 'ee_edit_contact', |
|
| 341 | - 'read_post' => 'ee_read_contact', |
|
| 342 | - 'delete_post' => 'ee_delete_contact', |
|
| 343 | - 'edit_posts' => 'ee_edit_contacts', |
|
| 344 | - 'edit_others_posts' => 'ee_edit_contacts', |
|
| 345 | - 'publish_posts' => 'ee_edit_contacts', |
|
| 346 | - 'read_private_posts' => 'ee_edit_contacts', |
|
| 347 | - 'delete_posts' => 'ee_delete_contacts', |
|
| 348 | - 'delete_private_posts' => 'ee_delete_contacts', |
|
| 349 | - 'delete_published_posts' => 'ee_delete_contacts', |
|
| 350 | - 'delete_others_posts' => 'ee_delete_contacts', |
|
| 351 | - 'edit_private_posts' => 'ee_edit_contacts', |
|
| 352 | - 'edit_published_posts' => 'ee_edit_contacts', |
|
| 353 | - ), |
|
| 354 | - 'supports' => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'), |
|
| 355 | - ), |
|
| 356 | - ), |
|
| 357 | - )); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * This basically goes through the CPT array and returns only CPT's |
|
| 364 | - * that have the ['args']['public'] option set as false |
|
| 365 | - * |
|
| 366 | - * @return array |
|
| 367 | - */ |
|
| 368 | - public static function get_private_CPTs() |
|
| 369 | - { |
|
| 370 | - $CPTs = self::get_CPTs(); |
|
| 371 | - $private_CPTs = array(); |
|
| 372 | - foreach ($CPTs as $CPT => $details) { |
|
| 373 | - if (empty($details['args']['public'])) { |
|
| 374 | - $private_CPTs[$CPT] = $details; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - return $private_CPTs; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * Registers a custom taxonomy. Should be called before registering custom post types, |
|
| 384 | - * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'. |
|
| 385 | - * |
|
| 386 | - * @param string $taxonomy_name , eg 'books' |
|
| 387 | - * @param string $singular_name internationalized singular name |
|
| 388 | - * @param string $plural_name internationalized plural name |
|
| 389 | - * @param array $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
|
| 390 | - */ |
|
| 391 | - public function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array()) |
|
| 392 | - { |
|
| 393 | - $args = array( |
|
| 394 | - 'hierarchical' => true, |
|
| 395 | - 'labels' => array( |
|
| 396 | - 'name' => $plural_name, |
|
| 397 | - 'singular_name' => $singular_name, |
|
| 398 | - ), |
|
| 399 | - 'show_ui' => true, |
|
| 400 | - 'show_ee_ui' => true, |
|
| 401 | - 'show_admin_column' => true, |
|
| 402 | - 'query_var' => true, |
|
| 403 | - 'show_in_nav_menus' => false, |
|
| 404 | - 'map_meta_cap' => true |
|
| 405 | - //'rewrite' => array( 'slug' => 'genre' ), |
|
| 406 | - ); |
|
| 407 | - if ($override_args) { |
|
| 408 | - if (isset($override_args['labels'])) { |
|
| 409 | - $labels = array_merge($args['labels'], $override_args['labels']); |
|
| 410 | - $args['labels'] = $labels; |
|
| 411 | - } |
|
| 412 | - $args = array_merge($args, $override_args); |
|
| 413 | - } |
|
| 414 | - register_taxonomy($taxonomy_name, null, $args); |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - |
|
| 418 | - |
|
| 419 | - /** |
|
| 420 | - * Registers a new custom post type. Sets default settings given only the following params. |
|
| 421 | - * |
|
| 422 | - * @param string $post_type the actual post type name |
|
| 423 | - * (VERY IMPORTANT: this much match what the slug is for admin pages related to this |
|
| 424 | - * cpt Also any models must use this slug as well) |
|
| 425 | - * @param string $singular_name a pre-internationalized string for the singular name of the objects |
|
| 426 | - * @param string $plural_name a pre-internalized string for the plural name of the objects |
|
| 427 | - * @param array $override_args exactly like $args as described in |
|
| 428 | - * http://codex.wordpress.org/Function_Reference/register_post_type The default values |
|
| 429 | - * set in this function will be overridden by whatever you set in $override_args |
|
| 430 | - * @param string $singular_slug |
|
| 431 | - * @param string $plural_slug |
|
| 432 | - * @return void , but registers the custom post type |
|
| 433 | - */ |
|
| 434 | - public function register_CPT( |
|
| 435 | - $post_type, |
|
| 436 | - $singular_name, |
|
| 437 | - $plural_name, |
|
| 438 | - $override_args = array(), |
|
| 439 | - $singular_slug = '', |
|
| 440 | - $plural_slug = '' |
|
| 441 | - ) { |
|
| 442 | - $labels = array( |
|
| 443 | - 'name' => $plural_name, |
|
| 444 | - 'singular_name' => $singular_name, |
|
| 445 | - 'singular_slug' => $singular_slug, |
|
| 446 | - 'plural_slug' => $plural_slug, |
|
| 447 | - 'add_new' => sprintf(__("Add %s", "event_espresso"), $singular_name), |
|
| 448 | - 'add_new_item' => sprintf(__("Add New %s", "event_espresso"), $singular_name), |
|
| 449 | - 'edit_item' => sprintf(__("Edit %s", "event_espresso"), $singular_name), |
|
| 450 | - 'new_item' => sprintf(__("New %s", "event_espresso"), $singular_name), |
|
| 451 | - 'all_items' => sprintf(__("All %s", "event_espresso"), $plural_name), |
|
| 452 | - 'view_item' => sprintf(__("View %s", "event_espresso"), $singular_name), |
|
| 453 | - 'search_items' => sprintf(__("Search %s", "event_espresso"), $plural_name), |
|
| 454 | - 'not_found' => sprintf(__("No %s found", "event_espresso"), $plural_name), |
|
| 455 | - 'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name), |
|
| 456 | - 'parent_item_colon' => '', |
|
| 457 | - 'menu_name' => sprintf(__("%s", "event_espresso"), $plural_name), |
|
| 458 | - ); |
|
| 459 | - //verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name |
|
| 460 | - // $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name; |
|
| 461 | - $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name; |
|
| 462 | - //note the page_templates arg in the supports index is something specific to EE. |
|
| 463 | - // WordPress doesn't actually have that in their register_post_type api. |
|
| 464 | - $args = array( |
|
| 465 | - 'labels' => $labels, |
|
| 466 | - 'public' => true, |
|
| 467 | - 'publicly_queryable' => true, |
|
| 468 | - 'show_ui' => false, |
|
| 469 | - 'show_ee_ui' => true, |
|
| 470 | - 'show_in_menu' => false, |
|
| 471 | - 'show_in_nav_menus' => false, |
|
| 472 | - 'query_var' => true, |
|
| 473 | - 'rewrite' => apply_filters( |
|
| 474 | - 'FHEE__EE_Register_CPTs__register_CPT__rewrite', |
|
| 475 | - array('slug' => $plural_slug), |
|
| 476 | - $post_type |
|
| 477 | - ), |
|
| 478 | - 'capability_type' => 'post', |
|
| 479 | - 'map_meta_cap' => true, |
|
| 480 | - 'has_archive' => true, |
|
| 481 | - 'hierarchical' => false, |
|
| 482 | - 'menu_position' => null, |
|
| 483 | - 'supports' => array( |
|
| 484 | - 'title', |
|
| 485 | - 'editor', |
|
| 486 | - 'author', |
|
| 487 | - 'thumbnail', |
|
| 488 | - 'excerpt', |
|
| 489 | - 'custom-fields', |
|
| 490 | - 'comments', |
|
| 491 | - ), |
|
| 492 | - ); |
|
| 493 | - if ($override_args) { |
|
| 494 | - if (isset($override_args['labels'])) { |
|
| 495 | - $labels = array_merge($args['labels'], $override_args['labels']); |
|
| 496 | - } |
|
| 497 | - $args = array_merge($args, $override_args); |
|
| 498 | - $args['labels'] = $labels; |
|
| 499 | - } |
|
| 500 | - register_post_type($post_type, $args); |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - |
|
| 504 | - |
|
| 505 | - public function set_must_use_event_types() |
|
| 506 | - { |
|
| 507 | - $term_details = array( |
|
| 508 | - //Attendee's register for the first date-time only |
|
| 509 | - 'single-event' => array( |
|
| 510 | - __('Single Event', 'event_espresso'), |
|
| 511 | - __('A single event that spans one or more consecutive days.', 'event_espresso'), |
|
| 512 | - ), |
|
| 513 | - //example: a party or two-day long workshop |
|
| 514 | - //Attendee's can register for any of the date-times |
|
| 515 | - 'multi-event' => array( |
|
| 516 | - __('Multi Event', 'event_espresso'), |
|
| 517 | - __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso'), |
|
| 518 | - ), |
|
| 519 | - //example: a three day music festival or week long conference |
|
| 520 | - //Attendee's register for the first date-time only |
|
| 521 | - 'event-series' => array( |
|
| 522 | - __('Event Series', 'event_espresso'), |
|
| 523 | - __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso'), |
|
| 524 | - ), |
|
| 525 | - //example: an 8 week introduction to basket weaving course |
|
| 526 | - //Attendee's can register for any of the date-times. |
|
| 527 | - 'recurring-event' => array( |
|
| 528 | - __('Recurring Event', 'event_espresso'), |
|
| 529 | - __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso'), |
|
| 530 | - ), |
|
| 531 | - //example: a yoga class |
|
| 532 | - 'ongoing' => array( |
|
| 533 | - __('Ongoing Event', 'event_espresso'), |
|
| 534 | - __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', |
|
| 535 | - 'event_espresso'), |
|
| 536 | - ) |
|
| 537 | - //example: access to a museum |
|
| 538 | - //'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
|
| 539 | - //'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
| 540 | - // 'multiple-session' => array( __('Multiple Session', 'event_espresso'), __('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
| 541 | - //'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
|
| 542 | - ); |
|
| 543 | - $this->set_must_use_terms('espresso_event_type', $term_details); |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - |
|
| 547 | - |
|
| 548 | - /** |
|
| 549 | - * wrapper method for handling the setting up of initial terms in the db (if they don't already exist). |
|
| 550 | - * Note this should ONLY be used for terms that always must be present. Be aware that if an initial term is |
|
| 551 | - * deleted then it WILL be recreated. |
|
| 552 | - * |
|
| 553 | - * @param string $taxonomy The name of the taxonomy |
|
| 554 | - * @param array $term_details An array of term details indexed by slug and containing Name of term, and |
|
| 555 | - * description as the elements in the array |
|
| 556 | - * @return void |
|
| 557 | - */ |
|
| 558 | - public function set_must_use_terms($taxonomy, $term_details) |
|
| 559 | - { |
|
| 560 | - $term_details = (array)$term_details; |
|
| 561 | - foreach ($term_details as $slug => $details) { |
|
| 562 | - if ( ! term_exists($slug, $taxonomy)) { |
|
| 563 | - $insert_arr = array( |
|
| 564 | - 'slug' => $slug, |
|
| 565 | - 'description' => $details[1], |
|
| 566 | - ); |
|
| 567 | - wp_insert_term($details[0], $taxonomy, $insert_arr); |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * Allows us to set what the default will be for terms when a cpt is PUBLISHED. |
|
| 576 | - * |
|
| 577 | - * @param string $taxonomy The taxonomy we're using for the default term |
|
| 578 | - * @param string $term_slug The slug of the term that will be the default. |
|
| 579 | - * @param array $cpt_slugs An array of custom post types we want the default assigned to |
|
| 580 | - */ |
|
| 581 | - public function set_default_term($taxonomy, $term_slug, $cpt_slugs = array()) |
|
| 582 | - { |
|
| 583 | - $this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs); |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property |
|
| 590 | - * |
|
| 591 | - * @param int $post_id ID of CPT being saved |
|
| 592 | - * @param object $post Post object |
|
| 593 | - * @return void |
|
| 594 | - */ |
|
| 595 | - public function save_default_term($post_id, $post) |
|
| 596 | - { |
|
| 597 | - if (empty($this->_default_terms)) { |
|
| 598 | - return; |
|
| 599 | - } //no default terms set so lets just exit. |
|
| 600 | - foreach ($this->_default_terms as $defaults) { |
|
| 601 | - foreach ($defaults as $default_obj) { |
|
| 602 | - if ($post->post_status === 'publish' && in_array($post->post_type, $default_obj->cpt_slugs, true)) { |
|
| 603 | - //note some error proofing going on here to save unnecessary db queries |
|
| 604 | - $taxonomies = get_object_taxonomies($post->post_type); |
|
| 605 | - foreach ((array)$taxonomies as $taxonomy) { |
|
| 606 | - $terms = wp_get_post_terms($post_id, $taxonomy); |
|
| 607 | - if (empty($terms) && $taxonomy === $default_obj->taxonomy) { |
|
| 608 | - wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy); |
|
| 609 | - } |
|
| 610 | - } |
|
| 611 | - } |
|
| 612 | - } |
|
| 613 | - } |
|
| 614 | - } |
|
| 17 | + /** |
|
| 18 | + * This property is used to hold an array of EE_default_term objects assigned to a custom post type when the post |
|
| 19 | + * for that post type is published with no terms set for the taxonomy. |
|
| 20 | + * |
|
| 21 | + * @var array of EE_Default_Term objects |
|
| 22 | + */ |
|
| 23 | + protected $_default_terms = array(); |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * constructor |
|
| 29 | + * instantiated at init priority 5 |
|
| 30 | + */ |
|
| 31 | + public function __construct() |
|
| 32 | + { |
|
| 33 | + // register taxonomies |
|
| 34 | + $taxonomies = self::get_taxonomies(); |
|
| 35 | + foreach ($taxonomies as $taxonomy => $tax) { |
|
| 36 | + $this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']); |
|
| 37 | + } |
|
| 38 | + // register CPTs |
|
| 39 | + $CPTs = self::get_CPTs(); |
|
| 40 | + foreach ($CPTs as $CPT_name => $CPT) { |
|
| 41 | + $this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'], |
|
| 42 | + $CPT['singular_slug'], $CPT['plural_slug']); |
|
| 43 | + } |
|
| 44 | + // setup default terms in any of our taxonomies (but only if we're in admin). |
|
| 45 | + // Why not added via register_activation_hook? |
|
| 46 | + // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies |
|
| 47 | + // (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
|
| 48 | + // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
|
| 49 | + // if ( is_admin() ) { |
|
| 50 | + // $this->set_must_use_event_types(); |
|
| 51 | + // } |
|
| 52 | + //set default terms |
|
| 53 | + $this->set_default_term('espresso_event_type', 'single-event', array('espresso_events')); |
|
| 54 | + add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10); |
|
| 55 | + // hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts |
|
| 56 | + // IF they don't have a term for that taxonomy set. |
|
| 57 | + add_action('save_post', array($this, 'save_default_term'), 100, 2); |
|
| 58 | + // remove no html restrictions from core wp saving of term descriptions. |
|
| 59 | + // Note. this will affect only registered EE taxonomies. |
|
| 60 | + $this->_allow_html_descriptions_for_ee_taxonomies(); |
|
| 61 | + do_action('AHEE__EE_Register_CPTs__construct_end', $this); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
| 68 | + * |
|
| 69 | + * @since 4.5.0 |
|
| 70 | + * @return void |
|
| 71 | + */ |
|
| 72 | + public static function maybe_flush_rewrite_rules() |
|
| 73 | + { |
|
| 74 | + if (get_option('ee_flush_rewrite_rules', true)) { |
|
| 75 | + flush_rewrite_rules(); |
|
| 76 | + update_option('ee_flush_rewrite_rules', false); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * By default, WordPress strips all html from term taxonomy description content. The purpose of this method is to |
|
| 84 | + * remove that restriction and ensure that we still run ee term taxonomy descriptions through some full html |
|
| 85 | + * sanitization equivalent to the post content field. |
|
| 86 | + * |
|
| 87 | + * @since 4.7.8 |
|
| 88 | + */ |
|
| 89 | + protected function _allow_html_descriptions_for_ee_taxonomies() |
|
| 90 | + { |
|
| 91 | + // first remove default filter for term description but we have to do this earlier |
|
| 92 | + // before wp sets their own filter |
|
| 93 | + // because they just set a global filter on all term descriptions before the custom term description filter. |
|
| 94 | + // Really sux. |
|
| 95 | + add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Callback for pre_term_description hook. |
|
| 102 | + * |
|
| 103 | + * @param string $description The description content. |
|
| 104 | + * @param string $taxonomy The taxonomy name for the taxonomy being filtered. |
|
| 105 | + * @return string |
|
| 106 | + */ |
|
| 107 | + public function ee_filter_ee_term_description_not_wp($description, $taxonomy) |
|
| 108 | + { |
|
| 109 | + //get a list of EE taxonomies |
|
| 110 | + $ee_taxonomies = array_keys(self::get_taxonomies()); |
|
| 111 | + //only do our own thing if the taxonomy listed is an ee taxonomy. |
|
| 112 | + if (in_array($taxonomy, $ee_taxonomies, true)) { |
|
| 113 | + //remove default wp filter |
|
| 114 | + remove_filter('pre_term_description', 'wp_filter_kses'); |
|
| 115 | + //sanitize THIS content. |
|
| 116 | + $description = wp_kses($description, wp_kses_allowed_html('post')); |
|
| 117 | + } |
|
| 118 | + return $description; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * get_taxonomies |
|
| 125 | + * |
|
| 126 | + * @access public |
|
| 127 | + * @return array |
|
| 128 | + */ |
|
| 129 | + public static function get_taxonomies() |
|
| 130 | + { |
|
| 131 | + // define taxonomies |
|
| 132 | + return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( |
|
| 133 | + 'espresso_event_categories' => array( |
|
| 134 | + 'singular_name' => __("Event Category", "event_espresso"), |
|
| 135 | + 'plural_name' => __("Event Categories", "event_espresso"), |
|
| 136 | + 'args' => array( |
|
| 137 | + 'public' => true, |
|
| 138 | + 'show_in_nav_menus' => true, |
|
| 139 | + 'show_in_rest' => true, |
|
| 140 | + 'capabilities' => array( |
|
| 141 | + 'manage_terms' => 'ee_manage_event_categories', |
|
| 142 | + 'edit_terms' => 'ee_edit_event_category', |
|
| 143 | + 'delete_terms' => 'ee_delete_event_category', |
|
| 144 | + 'assign_terms' => 'ee_assign_event_category', |
|
| 145 | + ), |
|
| 146 | + 'rewrite' => array('slug' => __('event-category', 'event_espresso')), |
|
| 147 | + ), |
|
| 148 | + ), |
|
| 149 | + 'espresso_venue_categories' => array( |
|
| 150 | + 'singular_name' => __("Venue Category", "event_espresso"), |
|
| 151 | + 'plural_name' => __("Venue Categories", "event_espresso"), |
|
| 152 | + 'args' => array( |
|
| 153 | + 'public' => true, |
|
| 154 | + 'show_in_nav_menus' => false, //by default this doesn't show for decaf |
|
| 155 | + 'show_in_rest' => true, |
|
| 156 | + 'capabilities' => array( |
|
| 157 | + 'manage_terms' => 'ee_manage_venue_categories', |
|
| 158 | + 'edit_terms' => 'ee_edit_venue_category', |
|
| 159 | + 'delete_terms' => 'ee_delete_venue_category', |
|
| 160 | + 'assign_terms' => 'ee_assign_venue_category', |
|
| 161 | + ), |
|
| 162 | + 'rewrite' => array('slug' => __('venue-category', 'event_espresso')), |
|
| 163 | + ), |
|
| 164 | + ), |
|
| 165 | + 'espresso_event_type' => array( |
|
| 166 | + 'singular_name' => __("Event Type", "event_espresso"), |
|
| 167 | + 'plural_name' => __("Event Types", "event_espresso"), |
|
| 168 | + 'args' => array( |
|
| 169 | + 'public' => true, |
|
| 170 | + 'show_ui' => false, |
|
| 171 | + 'show_in_rest' => true, |
|
| 172 | + 'capabilities' => array( |
|
| 173 | + 'manage_terms' => 'ee_read_event_type', |
|
| 174 | + 'edit_terms' => 'ee_edit_event_type', |
|
| 175 | + 'delete_terms' => 'ee_delete_event_type', |
|
| 176 | + 'assign_terms' => 'ee_assign_event_type', |
|
| 177 | + ), |
|
| 178 | + 'rewrite' => array('slug' => __('event-type', 'event_espresso')), |
|
| 179 | + 'hierarchical' => true, |
|
| 180 | + ), |
|
| 181 | + ), |
|
| 182 | + )); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * This returns the corresponding model name for cpts registered by EE. |
|
| 189 | + * |
|
| 190 | + * @since 4.6.16.rc.000 |
|
| 191 | + * @param string $post_type_slug If a slug is included, then attempt to retrieve the model name for |
|
| 192 | + * the given cpt slug. Otherwise if empty, then we'll return all cpt |
|
| 193 | + * model names for cpts registered in EE. |
|
| 194 | + * @return array Empty array if no matching model names for the given slug or an array of model |
|
| 195 | + * names indexed by post type slug. |
|
| 196 | + */ |
|
| 197 | + public static function get_cpt_model_names($post_type_slug = '') |
|
| 198 | + { |
|
| 199 | + $cpts = self::get_CPTs(); |
|
| 200 | + //first if slug passed in... |
|
| 201 | + if ( ! empty($post_type_slug)) { |
|
| 202 | + //match? |
|
| 203 | + if ( |
|
| 204 | + ! isset($cpts[$post_type_slug]) |
|
| 205 | + || (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name'])) |
|
| 206 | + ) { |
|
| 207 | + return array(); |
|
| 208 | + } |
|
| 209 | + //k let's get the model name for this cpt. |
|
| 210 | + return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name'])); |
|
| 211 | + } |
|
| 212 | + //if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
|
| 213 | + $cpt_models = array(); |
|
| 214 | + foreach ($cpts as $slug => $args) { |
|
| 215 | + if ( ! empty($args['class_name'])) { |
|
| 216 | + $cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']); |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + return $cpt_models; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * This instantiates cpt models related to the cpts registered via EE. |
|
| 226 | + * |
|
| 227 | + * @since 4.6.16.rc.000 |
|
| 228 | + * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
| 229 | + * the cpt matching the given slug. Otherwise all cpt models will be |
|
| 230 | + * instantiated (if possible). |
|
| 231 | + * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
| 232 | + * EEM models indexed by post slug. |
|
| 233 | + */ |
|
| 234 | + public static function instantiate_cpt_models($post_type_slug = '') |
|
| 235 | + { |
|
| 236 | + $cpt_model_names = self::get_cpt_model_names($post_type_slug); |
|
| 237 | + $instantiated = array(); |
|
| 238 | + foreach ($cpt_model_names as $slug => $model_name) { |
|
| 239 | + $instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name)); |
|
| 240 | + if ($instance instanceof EEM_CPT_Base) { |
|
| 241 | + $instantiated[$slug] = $instance; |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + return $instantiated; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * get_CPTs |
|
| 251 | + * |
|
| 252 | + * @access public |
|
| 253 | + * @return array |
|
| 254 | + */ |
|
| 255 | + public static function get_CPTs() |
|
| 256 | + { |
|
| 257 | + // define CPTs |
|
| 258 | + // NOTE the ['args']['page_templates'] array index is something specific to our CPTs |
|
| 259 | + // and not part of the WP custom post type api. |
|
| 260 | + return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array( |
|
| 261 | + 'espresso_events' => array( |
|
| 262 | + 'singular_name' => __("Event", "event_espresso"), |
|
| 263 | + 'plural_name' => __("Events", "event_espresso"), |
|
| 264 | + 'singular_slug' => __("event", "event_espresso"), |
|
| 265 | + 'plural_slug' => EE_Registry::instance()->CFG->core->event_cpt_slug, |
|
| 266 | + 'class_name' => 'EE_Event', |
|
| 267 | + 'args' => array( |
|
| 268 | + 'public' => true, |
|
| 269 | + 'show_in_nav_menus' => true, |
|
| 270 | + 'capability_type' => 'event', |
|
| 271 | + 'capabilities' => array( |
|
| 272 | + 'edit_post' => 'ee_edit_event', |
|
| 273 | + 'read_post' => 'ee_read_event', |
|
| 274 | + 'delete_post' => 'ee_delete_event', |
|
| 275 | + 'edit_posts' => 'ee_edit_events', |
|
| 276 | + 'edit_others_posts' => 'ee_edit_others_events', |
|
| 277 | + 'publish_posts' => 'ee_publish_events', |
|
| 278 | + 'read_private_posts' => 'ee_read_private_events', |
|
| 279 | + 'delete_posts' => 'ee_delete_events', |
|
| 280 | + 'delete_private_posts' => 'ee_delete_private_events', |
|
| 281 | + 'delete_published_posts' => 'ee_delete_published_events', |
|
| 282 | + 'delete_others_posts' => 'ee_delete_others_events', |
|
| 283 | + 'edit_private_posts' => 'ee_edit_private_events', |
|
| 284 | + 'edit_published_posts' => 'ee_edit_published_events', |
|
| 285 | + ), |
|
| 286 | + 'taxonomies' => array( |
|
| 287 | + 'espresso_event_categories', |
|
| 288 | + 'espresso_event_type', |
|
| 289 | + 'post_tag', |
|
| 290 | + ), |
|
| 291 | + 'page_templates' => true, |
|
| 292 | + ), |
|
| 293 | + ), |
|
| 294 | + 'espresso_venues' => array( |
|
| 295 | + 'singular_name' => __("Venue", "event_espresso"), |
|
| 296 | + 'plural_name' => __("Venues", "event_espresso"), |
|
| 297 | + 'singular_slug' => __("venue", "event_espresso"), |
|
| 298 | + 'plural_slug' => __("venues", "event_espresso"), |
|
| 299 | + 'class_name' => 'EE_Venue', |
|
| 300 | + 'args' => array( |
|
| 301 | + 'public' => true, |
|
| 302 | + 'show_in_nav_menus' => false, //by default this doesn't show for decaf, |
|
| 303 | + 'capability_type' => 'venue', |
|
| 304 | + 'capabilities' => array( |
|
| 305 | + 'edit_post' => 'ee_edit_venue', |
|
| 306 | + 'read_post' => 'ee_read_venue', |
|
| 307 | + 'delete_post' => 'ee_delete_venue', |
|
| 308 | + 'edit_posts' => 'ee_edit_venues', |
|
| 309 | + 'edit_others_posts' => 'ee_edit_others_venues', |
|
| 310 | + 'publish_posts' => 'ee_publish_venues', |
|
| 311 | + 'read_private_posts' => 'ee_read_private_venues', |
|
| 312 | + 'delete_posts' => 'ee_delete_venues', |
|
| 313 | + 'delete_private_posts' => 'ee_delete_private_venues', |
|
| 314 | + 'delete_published_posts' => 'ee_delete_published_venues', |
|
| 315 | + 'delete_others_posts' => 'ee_edit_others_venues', |
|
| 316 | + 'edit_private_posts' => 'ee_edit_private_venues', |
|
| 317 | + 'edit_published_posts' => 'ee_edit_published_venues', |
|
| 318 | + ), |
|
| 319 | + 'taxonomies' => array( |
|
| 320 | + 'espresso_venue_categories', |
|
| 321 | + 'post_tag', |
|
| 322 | + ), |
|
| 323 | + 'page_templates' => true, |
|
| 324 | + ), |
|
| 325 | + ), |
|
| 326 | + 'espresso_attendees' => array( |
|
| 327 | + 'singular_name' => __("Contact", "event_espresso"), |
|
| 328 | + 'plural_name' => __("Contacts", "event_espresso"), |
|
| 329 | + 'singular_slug' => __("contact", "event_espresso"), |
|
| 330 | + 'plural_slug' => __("contacts", "event_espresso"), |
|
| 331 | + 'class_name' => 'EE_Attendee', |
|
| 332 | + 'args' => array( |
|
| 333 | + 'public' => false, |
|
| 334 | + 'publicly_queryable' => false, |
|
| 335 | + 'hierarchical' => false, |
|
| 336 | + 'has_archive' => false, |
|
| 337 | + 'taxonomies' => array('post_tag'), |
|
| 338 | + 'capability_type' => 'contact', |
|
| 339 | + 'capabilities' => array( |
|
| 340 | + 'edit_post' => 'ee_edit_contact', |
|
| 341 | + 'read_post' => 'ee_read_contact', |
|
| 342 | + 'delete_post' => 'ee_delete_contact', |
|
| 343 | + 'edit_posts' => 'ee_edit_contacts', |
|
| 344 | + 'edit_others_posts' => 'ee_edit_contacts', |
|
| 345 | + 'publish_posts' => 'ee_edit_contacts', |
|
| 346 | + 'read_private_posts' => 'ee_edit_contacts', |
|
| 347 | + 'delete_posts' => 'ee_delete_contacts', |
|
| 348 | + 'delete_private_posts' => 'ee_delete_contacts', |
|
| 349 | + 'delete_published_posts' => 'ee_delete_contacts', |
|
| 350 | + 'delete_others_posts' => 'ee_delete_contacts', |
|
| 351 | + 'edit_private_posts' => 'ee_edit_contacts', |
|
| 352 | + 'edit_published_posts' => 'ee_edit_contacts', |
|
| 353 | + ), |
|
| 354 | + 'supports' => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'), |
|
| 355 | + ), |
|
| 356 | + ), |
|
| 357 | + )); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * This basically goes through the CPT array and returns only CPT's |
|
| 364 | + * that have the ['args']['public'] option set as false |
|
| 365 | + * |
|
| 366 | + * @return array |
|
| 367 | + */ |
|
| 368 | + public static function get_private_CPTs() |
|
| 369 | + { |
|
| 370 | + $CPTs = self::get_CPTs(); |
|
| 371 | + $private_CPTs = array(); |
|
| 372 | + foreach ($CPTs as $CPT => $details) { |
|
| 373 | + if (empty($details['args']['public'])) { |
|
| 374 | + $private_CPTs[$CPT] = $details; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + return $private_CPTs; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * Registers a custom taxonomy. Should be called before registering custom post types, |
|
| 384 | + * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'. |
|
| 385 | + * |
|
| 386 | + * @param string $taxonomy_name , eg 'books' |
|
| 387 | + * @param string $singular_name internationalized singular name |
|
| 388 | + * @param string $plural_name internationalized plural name |
|
| 389 | + * @param array $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
|
| 390 | + */ |
|
| 391 | + public function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array()) |
|
| 392 | + { |
|
| 393 | + $args = array( |
|
| 394 | + 'hierarchical' => true, |
|
| 395 | + 'labels' => array( |
|
| 396 | + 'name' => $plural_name, |
|
| 397 | + 'singular_name' => $singular_name, |
|
| 398 | + ), |
|
| 399 | + 'show_ui' => true, |
|
| 400 | + 'show_ee_ui' => true, |
|
| 401 | + 'show_admin_column' => true, |
|
| 402 | + 'query_var' => true, |
|
| 403 | + 'show_in_nav_menus' => false, |
|
| 404 | + 'map_meta_cap' => true |
|
| 405 | + //'rewrite' => array( 'slug' => 'genre' ), |
|
| 406 | + ); |
|
| 407 | + if ($override_args) { |
|
| 408 | + if (isset($override_args['labels'])) { |
|
| 409 | + $labels = array_merge($args['labels'], $override_args['labels']); |
|
| 410 | + $args['labels'] = $labels; |
|
| 411 | + } |
|
| 412 | + $args = array_merge($args, $override_args); |
|
| 413 | + } |
|
| 414 | + register_taxonomy($taxonomy_name, null, $args); |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + |
|
| 418 | + |
|
| 419 | + /** |
|
| 420 | + * Registers a new custom post type. Sets default settings given only the following params. |
|
| 421 | + * |
|
| 422 | + * @param string $post_type the actual post type name |
|
| 423 | + * (VERY IMPORTANT: this much match what the slug is for admin pages related to this |
|
| 424 | + * cpt Also any models must use this slug as well) |
|
| 425 | + * @param string $singular_name a pre-internationalized string for the singular name of the objects |
|
| 426 | + * @param string $plural_name a pre-internalized string for the plural name of the objects |
|
| 427 | + * @param array $override_args exactly like $args as described in |
|
| 428 | + * http://codex.wordpress.org/Function_Reference/register_post_type The default values |
|
| 429 | + * set in this function will be overridden by whatever you set in $override_args |
|
| 430 | + * @param string $singular_slug |
|
| 431 | + * @param string $plural_slug |
|
| 432 | + * @return void , but registers the custom post type |
|
| 433 | + */ |
|
| 434 | + public function register_CPT( |
|
| 435 | + $post_type, |
|
| 436 | + $singular_name, |
|
| 437 | + $plural_name, |
|
| 438 | + $override_args = array(), |
|
| 439 | + $singular_slug = '', |
|
| 440 | + $plural_slug = '' |
|
| 441 | + ) { |
|
| 442 | + $labels = array( |
|
| 443 | + 'name' => $plural_name, |
|
| 444 | + 'singular_name' => $singular_name, |
|
| 445 | + 'singular_slug' => $singular_slug, |
|
| 446 | + 'plural_slug' => $plural_slug, |
|
| 447 | + 'add_new' => sprintf(__("Add %s", "event_espresso"), $singular_name), |
|
| 448 | + 'add_new_item' => sprintf(__("Add New %s", "event_espresso"), $singular_name), |
|
| 449 | + 'edit_item' => sprintf(__("Edit %s", "event_espresso"), $singular_name), |
|
| 450 | + 'new_item' => sprintf(__("New %s", "event_espresso"), $singular_name), |
|
| 451 | + 'all_items' => sprintf(__("All %s", "event_espresso"), $plural_name), |
|
| 452 | + 'view_item' => sprintf(__("View %s", "event_espresso"), $singular_name), |
|
| 453 | + 'search_items' => sprintf(__("Search %s", "event_espresso"), $plural_name), |
|
| 454 | + 'not_found' => sprintf(__("No %s found", "event_espresso"), $plural_name), |
|
| 455 | + 'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name), |
|
| 456 | + 'parent_item_colon' => '', |
|
| 457 | + 'menu_name' => sprintf(__("%s", "event_espresso"), $plural_name), |
|
| 458 | + ); |
|
| 459 | + //verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name |
|
| 460 | + // $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name; |
|
| 461 | + $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name; |
|
| 462 | + //note the page_templates arg in the supports index is something specific to EE. |
|
| 463 | + // WordPress doesn't actually have that in their register_post_type api. |
|
| 464 | + $args = array( |
|
| 465 | + 'labels' => $labels, |
|
| 466 | + 'public' => true, |
|
| 467 | + 'publicly_queryable' => true, |
|
| 468 | + 'show_ui' => false, |
|
| 469 | + 'show_ee_ui' => true, |
|
| 470 | + 'show_in_menu' => false, |
|
| 471 | + 'show_in_nav_menus' => false, |
|
| 472 | + 'query_var' => true, |
|
| 473 | + 'rewrite' => apply_filters( |
|
| 474 | + 'FHEE__EE_Register_CPTs__register_CPT__rewrite', |
|
| 475 | + array('slug' => $plural_slug), |
|
| 476 | + $post_type |
|
| 477 | + ), |
|
| 478 | + 'capability_type' => 'post', |
|
| 479 | + 'map_meta_cap' => true, |
|
| 480 | + 'has_archive' => true, |
|
| 481 | + 'hierarchical' => false, |
|
| 482 | + 'menu_position' => null, |
|
| 483 | + 'supports' => array( |
|
| 484 | + 'title', |
|
| 485 | + 'editor', |
|
| 486 | + 'author', |
|
| 487 | + 'thumbnail', |
|
| 488 | + 'excerpt', |
|
| 489 | + 'custom-fields', |
|
| 490 | + 'comments', |
|
| 491 | + ), |
|
| 492 | + ); |
|
| 493 | + if ($override_args) { |
|
| 494 | + if (isset($override_args['labels'])) { |
|
| 495 | + $labels = array_merge($args['labels'], $override_args['labels']); |
|
| 496 | + } |
|
| 497 | + $args = array_merge($args, $override_args); |
|
| 498 | + $args['labels'] = $labels; |
|
| 499 | + } |
|
| 500 | + register_post_type($post_type, $args); |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + |
|
| 504 | + |
|
| 505 | + public function set_must_use_event_types() |
|
| 506 | + { |
|
| 507 | + $term_details = array( |
|
| 508 | + //Attendee's register for the first date-time only |
|
| 509 | + 'single-event' => array( |
|
| 510 | + __('Single Event', 'event_espresso'), |
|
| 511 | + __('A single event that spans one or more consecutive days.', 'event_espresso'), |
|
| 512 | + ), |
|
| 513 | + //example: a party or two-day long workshop |
|
| 514 | + //Attendee's can register for any of the date-times |
|
| 515 | + 'multi-event' => array( |
|
| 516 | + __('Multi Event', 'event_espresso'), |
|
| 517 | + __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso'), |
|
| 518 | + ), |
|
| 519 | + //example: a three day music festival or week long conference |
|
| 520 | + //Attendee's register for the first date-time only |
|
| 521 | + 'event-series' => array( |
|
| 522 | + __('Event Series', 'event_espresso'), |
|
| 523 | + __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso'), |
|
| 524 | + ), |
|
| 525 | + //example: an 8 week introduction to basket weaving course |
|
| 526 | + //Attendee's can register for any of the date-times. |
|
| 527 | + 'recurring-event' => array( |
|
| 528 | + __('Recurring Event', 'event_espresso'), |
|
| 529 | + __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso'), |
|
| 530 | + ), |
|
| 531 | + //example: a yoga class |
|
| 532 | + 'ongoing' => array( |
|
| 533 | + __('Ongoing Event', 'event_espresso'), |
|
| 534 | + __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', |
|
| 535 | + 'event_espresso'), |
|
| 536 | + ) |
|
| 537 | + //example: access to a museum |
|
| 538 | + //'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
|
| 539 | + //'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
| 540 | + // 'multiple-session' => array( __('Multiple Session', 'event_espresso'), __('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
| 541 | + //'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
|
| 542 | + ); |
|
| 543 | + $this->set_must_use_terms('espresso_event_type', $term_details); |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + |
|
| 547 | + |
|
| 548 | + /** |
|
| 549 | + * wrapper method for handling the setting up of initial terms in the db (if they don't already exist). |
|
| 550 | + * Note this should ONLY be used for terms that always must be present. Be aware that if an initial term is |
|
| 551 | + * deleted then it WILL be recreated. |
|
| 552 | + * |
|
| 553 | + * @param string $taxonomy The name of the taxonomy |
|
| 554 | + * @param array $term_details An array of term details indexed by slug and containing Name of term, and |
|
| 555 | + * description as the elements in the array |
|
| 556 | + * @return void |
|
| 557 | + */ |
|
| 558 | + public function set_must_use_terms($taxonomy, $term_details) |
|
| 559 | + { |
|
| 560 | + $term_details = (array)$term_details; |
|
| 561 | + foreach ($term_details as $slug => $details) { |
|
| 562 | + if ( ! term_exists($slug, $taxonomy)) { |
|
| 563 | + $insert_arr = array( |
|
| 564 | + 'slug' => $slug, |
|
| 565 | + 'description' => $details[1], |
|
| 566 | + ); |
|
| 567 | + wp_insert_term($details[0], $taxonomy, $insert_arr); |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + |
|
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * Allows us to set what the default will be for terms when a cpt is PUBLISHED. |
|
| 576 | + * |
|
| 577 | + * @param string $taxonomy The taxonomy we're using for the default term |
|
| 578 | + * @param string $term_slug The slug of the term that will be the default. |
|
| 579 | + * @param array $cpt_slugs An array of custom post types we want the default assigned to |
|
| 580 | + */ |
|
| 581 | + public function set_default_term($taxonomy, $term_slug, $cpt_slugs = array()) |
|
| 582 | + { |
|
| 583 | + $this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs); |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property |
|
| 590 | + * |
|
| 591 | + * @param int $post_id ID of CPT being saved |
|
| 592 | + * @param object $post Post object |
|
| 593 | + * @return void |
|
| 594 | + */ |
|
| 595 | + public function save_default_term($post_id, $post) |
|
| 596 | + { |
|
| 597 | + if (empty($this->_default_terms)) { |
|
| 598 | + return; |
|
| 599 | + } //no default terms set so lets just exit. |
|
| 600 | + foreach ($this->_default_terms as $defaults) { |
|
| 601 | + foreach ($defaults as $default_obj) { |
|
| 602 | + if ($post->post_status === 'publish' && in_array($post->post_type, $default_obj->cpt_slugs, true)) { |
|
| 603 | + //note some error proofing going on here to save unnecessary db queries |
|
| 604 | + $taxonomies = get_object_taxonomies($post->post_type); |
|
| 605 | + foreach ((array)$taxonomies as $taxonomy) { |
|
| 606 | + $terms = wp_get_post_terms($post_id, $taxonomy); |
|
| 607 | + if (empty($terms) && $taxonomy === $default_obj->taxonomy) { |
|
| 608 | + wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy); |
|
| 609 | + } |
|
| 610 | + } |
|
| 611 | + } |
|
| 612 | + } |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | 615 | |
| 616 | 616 | } |
| 617 | 617 | |
@@ -625,27 +625,27 @@ discard block |
||
| 625 | 625 | { |
| 626 | 626 | |
| 627 | 627 | |
| 628 | - //props holding the items |
|
| 629 | - public $taxonomy = ''; |
|
| 628 | + //props holding the items |
|
| 629 | + public $taxonomy = ''; |
|
| 630 | 630 | |
| 631 | - public $cpt_slugs = array(); |
|
| 631 | + public $cpt_slugs = array(); |
|
| 632 | 632 | |
| 633 | - public $term_slug = ''; |
|
| 633 | + public $term_slug = ''; |
|
| 634 | 634 | |
| 635 | 635 | |
| 636 | 636 | |
| 637 | - /** |
|
| 638 | - * constructor |
|
| 639 | - * |
|
| 640 | - * @param string $taxonomy The taxonomy the default term belongs to |
|
| 641 | - * @param string $term_slug The slug of the term that will be the default. |
|
| 642 | - * @param array $cpt_slugs The custom post type the default term gets saved with |
|
| 643 | - */ |
|
| 644 | - public function __construct($taxonomy, $term_slug, $cpt_slugs = array()) |
|
| 645 | - { |
|
| 646 | - $this->taxonomy = $taxonomy; |
|
| 647 | - $this->cpt_slugs = (array)$cpt_slugs; |
|
| 648 | - $this->term_slug = $term_slug; |
|
| 649 | - } |
|
| 637 | + /** |
|
| 638 | + * constructor |
|
| 639 | + * |
|
| 640 | + * @param string $taxonomy The taxonomy the default term belongs to |
|
| 641 | + * @param string $term_slug The slug of the term that will be the default. |
|
| 642 | + * @param array $cpt_slugs The custom post type the default term gets saved with |
|
| 643 | + */ |
|
| 644 | + public function __construct($taxonomy, $term_slug, $cpt_slugs = array()) |
|
| 645 | + { |
|
| 646 | + $this->taxonomy = $taxonomy; |
|
| 647 | + $this->cpt_slugs = (array)$cpt_slugs; |
|
| 648 | + $this->term_slug = $term_slug; |
|
| 649 | + } |
|
| 650 | 650 | |
| 651 | 651 | } |
@@ -14,132 +14,132 @@ |
||
| 14 | 14 | class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * opening div tag for a form |
|
| 19 | - * |
|
| 20 | - * @return string |
|
| 21 | - */ |
|
| 22 | - public function layout_form_begin() |
|
| 23 | - { |
|
| 24 | - return EEH_HTML::div( |
|
| 25 | - '', |
|
| 26 | - $this->_form_section->html_id(), |
|
| 27 | - $this->_form_section->html_class(), |
|
| 28 | - $this->_form_section->html_style() |
|
| 29 | - ); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Lays out the row for the input, including label and errors |
|
| 36 | - * |
|
| 37 | - * @param EE_Form_Input_Base $input |
|
| 38 | - * @return string |
|
| 39 | - * @throws \EE_Error |
|
| 40 | - */ |
|
| 41 | - public function layout_input($input) |
|
| 42 | - { |
|
| 43 | - $html = ''; |
|
| 44 | - // set something unique for the id |
|
| 45 | - $html_id = (string)$input->html_id() !== '' |
|
| 46 | - ? (string)$input->html_id() |
|
| 47 | - : spl_object_hash($input); |
|
| 48 | - // and add a generic class |
|
| 49 | - $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv'; |
|
| 50 | - if ($input instanceof EE_Hidden_Input) { |
|
| 51 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
| 52 | - } else if ($input instanceof EE_Submit_Input) { |
|
| 53 | - $html .= EEH_HTML::div( |
|
| 54 | - $input->get_html_for_input(), |
|
| 55 | - $html_id . '-submit-dv', |
|
| 56 | - $html_class |
|
| 57 | - ); |
|
| 58 | - } else if ($input instanceof EE_Select_Input) { |
|
| 59 | - $html .= EEH_HTML::div( |
|
| 60 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 61 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 62 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 63 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 64 | - $html_id . '-input-dv', |
|
| 65 | - $html_class |
|
| 66 | - ); |
|
| 67 | - } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
|
| 68 | - $html .= EEH_HTML::div( |
|
| 69 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
| 70 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 71 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 72 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 73 | - $html_id . '-input-dv', |
|
| 74 | - $html_class |
|
| 75 | - ); |
|
| 76 | - } else { |
|
| 77 | - $html .= EEH_HTML::div( |
|
| 78 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 79 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 80 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 81 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 82 | - $html_id . '-input-dv', |
|
| 83 | - $html_class |
|
| 84 | - ); |
|
| 85 | - } |
|
| 86 | - return $html; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * |
|
| 93 | - * _display_label_for_option_type_question |
|
| 94 | - * Gets the HTML for the 'label', which is just text for this (because labels |
|
| 95 | - * should be for each input) |
|
| 96 | - * |
|
| 97 | - * @param EE_Form_Input_With_Options_Base $input |
|
| 98 | - * @return string |
|
| 99 | - */ |
|
| 100 | - protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) |
|
| 101 | - { |
|
| 102 | - if ($input->display_html_label_text() !== '') { |
|
| 103 | - return EEH_HTML::div( |
|
| 104 | - $input->required() |
|
| 105 | - ? $input->html_label_text() . EEH_HTML::span('*', '', 'ee-asterisk') |
|
| 106 | - : $input->html_label_text(), |
|
| 107 | - $input->html_label_id(), |
|
| 108 | - $input->required() |
|
| 109 | - ? 'ee-required-label ' . $input->html_label_class() |
|
| 110 | - : $input->html_label_class(), |
|
| 111 | - $input->html_label_style(), |
|
| 112 | - $input->html_other_attributes() |
|
| 113 | - ); |
|
| 114 | - } |
|
| 115 | - return ''; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Lays out a row for the subsection |
|
| 122 | - * |
|
| 123 | - * @param EE_Form_Section_Proper $form_section |
|
| 124 | - * @return string |
|
| 125 | - */ |
|
| 126 | - public function layout_subsection($form_section) |
|
| 127 | - { |
|
| 128 | - // d( $form_section ); |
|
| 129 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * closing div tag for a form |
|
| 136 | - * |
|
| 137 | - * @return string |
|
| 138 | - */ |
|
| 139 | - public function layout_form_end() |
|
| 140 | - { |
|
| 141 | - return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
| 142 | - } |
|
| 17 | + /** |
|
| 18 | + * opening div tag for a form |
|
| 19 | + * |
|
| 20 | + * @return string |
|
| 21 | + */ |
|
| 22 | + public function layout_form_begin() |
|
| 23 | + { |
|
| 24 | + return EEH_HTML::div( |
|
| 25 | + '', |
|
| 26 | + $this->_form_section->html_id(), |
|
| 27 | + $this->_form_section->html_class(), |
|
| 28 | + $this->_form_section->html_style() |
|
| 29 | + ); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Lays out the row for the input, including label and errors |
|
| 36 | + * |
|
| 37 | + * @param EE_Form_Input_Base $input |
|
| 38 | + * @return string |
|
| 39 | + * @throws \EE_Error |
|
| 40 | + */ |
|
| 41 | + public function layout_input($input) |
|
| 42 | + { |
|
| 43 | + $html = ''; |
|
| 44 | + // set something unique for the id |
|
| 45 | + $html_id = (string)$input->html_id() !== '' |
|
| 46 | + ? (string)$input->html_id() |
|
| 47 | + : spl_object_hash($input); |
|
| 48 | + // and add a generic class |
|
| 49 | + $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv'; |
|
| 50 | + if ($input instanceof EE_Hidden_Input) { |
|
| 51 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
| 52 | + } else if ($input instanceof EE_Submit_Input) { |
|
| 53 | + $html .= EEH_HTML::div( |
|
| 54 | + $input->get_html_for_input(), |
|
| 55 | + $html_id . '-submit-dv', |
|
| 56 | + $html_class |
|
| 57 | + ); |
|
| 58 | + } else if ($input instanceof EE_Select_Input) { |
|
| 59 | + $html .= EEH_HTML::div( |
|
| 60 | + EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 61 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 62 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 63 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 64 | + $html_id . '-input-dv', |
|
| 65 | + $html_class |
|
| 66 | + ); |
|
| 67 | + } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
|
| 68 | + $html .= EEH_HTML::div( |
|
| 69 | + EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
| 70 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 71 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 72 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 73 | + $html_id . '-input-dv', |
|
| 74 | + $html_class |
|
| 75 | + ); |
|
| 76 | + } else { |
|
| 77 | + $html .= EEH_HTML::div( |
|
| 78 | + EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 79 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 80 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 81 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 82 | + $html_id . '-input-dv', |
|
| 83 | + $html_class |
|
| 84 | + ); |
|
| 85 | + } |
|
| 86 | + return $html; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * |
|
| 93 | + * _display_label_for_option_type_question |
|
| 94 | + * Gets the HTML for the 'label', which is just text for this (because labels |
|
| 95 | + * should be for each input) |
|
| 96 | + * |
|
| 97 | + * @param EE_Form_Input_With_Options_Base $input |
|
| 98 | + * @return string |
|
| 99 | + */ |
|
| 100 | + protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) |
|
| 101 | + { |
|
| 102 | + if ($input->display_html_label_text() !== '') { |
|
| 103 | + return EEH_HTML::div( |
|
| 104 | + $input->required() |
|
| 105 | + ? $input->html_label_text() . EEH_HTML::span('*', '', 'ee-asterisk') |
|
| 106 | + : $input->html_label_text(), |
|
| 107 | + $input->html_label_id(), |
|
| 108 | + $input->required() |
|
| 109 | + ? 'ee-required-label ' . $input->html_label_class() |
|
| 110 | + : $input->html_label_class(), |
|
| 111 | + $input->html_label_style(), |
|
| 112 | + $input->html_other_attributes() |
|
| 113 | + ); |
|
| 114 | + } |
|
| 115 | + return ''; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Lays out a row for the subsection |
|
| 122 | + * |
|
| 123 | + * @param EE_Form_Section_Proper $form_section |
|
| 124 | + * @return string |
|
| 125 | + */ |
|
| 126 | + public function layout_subsection($form_section) |
|
| 127 | + { |
|
| 128 | + // d( $form_section ); |
|
| 129 | + return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * closing div tag for a form |
|
| 136 | + * |
|
| 137 | + * @return string |
|
| 138 | + */ |
|
| 139 | + public function layout_form_end() |
|
| 140 | + { |
|
| 141 | + return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | 145 | |
@@ -42,44 +42,44 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $html = ''; |
| 44 | 44 | // set something unique for the id |
| 45 | - $html_id = (string)$input->html_id() !== '' |
|
| 46 | - ? (string)$input->html_id() |
|
| 45 | + $html_id = (string) $input->html_id() !== '' |
|
| 46 | + ? (string) $input->html_id() |
|
| 47 | 47 | : spl_object_hash($input); |
| 48 | 48 | // and add a generic class |
| 49 | - $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv'; |
|
| 49 | + $html_class = sanitize_key(str_replace('_', '-', get_class($input))).'-dv'; |
|
| 50 | 50 | if ($input instanceof EE_Hidden_Input) { |
| 51 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
| 51 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
| 52 | 52 | } else if ($input instanceof EE_Submit_Input) { |
| 53 | 53 | $html .= EEH_HTML::div( |
| 54 | 54 | $input->get_html_for_input(), |
| 55 | - $html_id . '-submit-dv', |
|
| 55 | + $html_id.'-submit-dv', |
|
| 56 | 56 | $html_class |
| 57 | 57 | ); |
| 58 | 58 | } else if ($input instanceof EE_Select_Input) { |
| 59 | 59 | $html .= EEH_HTML::div( |
| 60 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 61 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 62 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 63 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 64 | - $html_id . '-input-dv', |
|
| 60 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
| 61 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
| 62 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
| 63 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
| 64 | + $html_id.'-input-dv', |
|
| 65 | 65 | $html_class |
| 66 | 66 | ); |
| 67 | 67 | } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
| 68 | 68 | $html .= EEH_HTML::div( |
| 69 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
| 70 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 71 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 72 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 73 | - $html_id . '-input-dv', |
|
| 69 | + EEH_HTML::nl().$this->_display_label_for_option_type_question($input). |
|
| 70 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
| 71 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
| 72 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
| 73 | + $html_id.'-input-dv', |
|
| 74 | 74 | $html_class |
| 75 | 75 | ); |
| 76 | 76 | } else { |
| 77 | 77 | $html .= EEH_HTML::div( |
| 78 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 79 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 80 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 81 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 82 | - $html_id . '-input-dv', |
|
| 78 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
| 79 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
| 80 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
| 81 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
| 82 | + $html_id.'-input-dv', |
|
| 83 | 83 | $html_class |
| 84 | 84 | ); |
| 85 | 85 | } |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | if ($input->display_html_label_text() !== '') { |
| 103 | 103 | return EEH_HTML::div( |
| 104 | 104 | $input->required() |
| 105 | - ? $input->html_label_text() . EEH_HTML::span('*', '', 'ee-asterisk') |
|
| 105 | + ? $input->html_label_text().EEH_HTML::span('*', '', 'ee-asterisk') |
|
| 106 | 106 | : $input->html_label_text(), |
| 107 | 107 | $input->html_label_id(), |
| 108 | 108 | $input->required() |
| 109 | - ? 'ee-required-label ' . $input->html_label_class() |
|
| 109 | + ? 'ee-required-label '.$input->html_label_class() |
|
| 110 | 110 | : $input->html_label_class(), |
| 111 | 111 | $input->html_label_style(), |
| 112 | 112 | $input->html_other_attributes() |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | public function layout_subsection($form_section) |
| 127 | 127 | { |
| 128 | 128 | // d( $form_section ); |
| 129 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
| 129 | + return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | |
@@ -1047,11 +1047,11 @@ discard block |
||
| 1047 | 1047 | 'filter' |
| 1048 | 1048 | ); |
| 1049 | 1049 | return apply_filters( |
| 1050 | - 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
| 1051 | - $existing_attendee, $registration, $attendee_data |
|
| 1052 | - ); |
|
| 1050 | + 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
| 1051 | + $existing_attendee, $registration, $attendee_data |
|
| 1052 | + ); |
|
| 1053 | 1053 | }, |
| 1054 | - 10,3 |
|
| 1054 | + 10,3 |
|
| 1055 | 1055 | ); |
| 1056 | 1056 | |
| 1057 | 1057 | |
@@ -1064,88 +1064,88 @@ discard block |
||
| 1064 | 1064 | class EE_Event_List_Query extends WP_Query |
| 1065 | 1065 | { |
| 1066 | 1066 | |
| 1067 | - private $title; |
|
| 1068 | - |
|
| 1069 | - private $css_class; |
|
| 1070 | - |
|
| 1071 | - private $category_slug; |
|
| 1072 | - |
|
| 1073 | - /** |
|
| 1074 | - * EE_Event_List_Query constructor. |
|
| 1075 | - * |
|
| 1076 | - * @param array $args |
|
| 1077 | - */ |
|
| 1078 | - public function __construct($args = array()) |
|
| 1079 | - { |
|
| 1080 | - \EE_Error::doing_it_wrong( |
|
| 1081 | - __METHOD__, |
|
| 1082 | - __( |
|
| 1083 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
| 1084 | - 'event_espresso' |
|
| 1085 | - ), |
|
| 1086 | - '4.9.27', |
|
| 1087 | - '5.0.0' |
|
| 1088 | - ); |
|
| 1089 | - $this->title = isset($args['title']) ? $args['title'] : ''; |
|
| 1090 | - $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
| 1091 | - $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
| 1092 | - $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
| 1093 | - // the current "page" we are viewing |
|
| 1094 | - $paged = max(1, get_query_var('paged')); |
|
| 1095 | - // Force these args |
|
| 1096 | - $args = array_merge( |
|
| 1097 | - $args, array( |
|
| 1098 | - 'post_type' => 'espresso_events', |
|
| 1099 | - 'posts_per_page' => $limit, |
|
| 1100 | - 'update_post_term_cache' => false, |
|
| 1101 | - 'update_post_meta_cache' => false, |
|
| 1102 | - 'paged' => $paged, |
|
| 1103 | - 'offset' => ($paged - 1) * $limit |
|
| 1104 | - ) |
|
| 1105 | - ); |
|
| 1106 | - // run the query |
|
| 1107 | - parent::__construct($args); |
|
| 1108 | - } |
|
| 1109 | - |
|
| 1110 | - |
|
| 1111 | - |
|
| 1112 | - /** |
|
| 1113 | - * event_list_title |
|
| 1114 | - * |
|
| 1115 | - * @param string $event_list_title |
|
| 1116 | - * @return string |
|
| 1117 | - */ |
|
| 1118 | - public function event_list_title($event_list_title = '') |
|
| 1119 | - { |
|
| 1120 | - if (! empty($this->title)) { |
|
| 1121 | - return $this->title; |
|
| 1122 | - } |
|
| 1123 | - return $event_list_title; |
|
| 1124 | - } |
|
| 1125 | - |
|
| 1126 | - |
|
| 1127 | - |
|
| 1128 | - /** |
|
| 1129 | - * event_list_css |
|
| 1130 | - * |
|
| 1131 | - * @param string $event_list_css |
|
| 1132 | - * @return string |
|
| 1133 | - */ |
|
| 1134 | - public function event_list_css($event_list_css = '') |
|
| 1135 | - { |
|
| 1136 | - $event_list_css .= ! empty($event_list_css) |
|
| 1137 | - ? ' ' |
|
| 1138 | - : ''; |
|
| 1139 | - $event_list_css .= ! empty($this->css_class) |
|
| 1140 | - ? $this->css_class |
|
| 1141 | - : ''; |
|
| 1142 | - $event_list_css .= ! empty($event_list_css) |
|
| 1143 | - ? ' ' |
|
| 1144 | - : ''; |
|
| 1145 | - $event_list_css .= ! empty($this->category_slug) |
|
| 1146 | - ? $this->category_slug |
|
| 1147 | - : ''; |
|
| 1148 | - return $event_list_css; |
|
| 1149 | - } |
|
| 1067 | + private $title; |
|
| 1068 | + |
|
| 1069 | + private $css_class; |
|
| 1070 | + |
|
| 1071 | + private $category_slug; |
|
| 1072 | + |
|
| 1073 | + /** |
|
| 1074 | + * EE_Event_List_Query constructor. |
|
| 1075 | + * |
|
| 1076 | + * @param array $args |
|
| 1077 | + */ |
|
| 1078 | + public function __construct($args = array()) |
|
| 1079 | + { |
|
| 1080 | + \EE_Error::doing_it_wrong( |
|
| 1081 | + __METHOD__, |
|
| 1082 | + __( |
|
| 1083 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
| 1084 | + 'event_espresso' |
|
| 1085 | + ), |
|
| 1086 | + '4.9.27', |
|
| 1087 | + '5.0.0' |
|
| 1088 | + ); |
|
| 1089 | + $this->title = isset($args['title']) ? $args['title'] : ''; |
|
| 1090 | + $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
| 1091 | + $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
| 1092 | + $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
| 1093 | + // the current "page" we are viewing |
|
| 1094 | + $paged = max(1, get_query_var('paged')); |
|
| 1095 | + // Force these args |
|
| 1096 | + $args = array_merge( |
|
| 1097 | + $args, array( |
|
| 1098 | + 'post_type' => 'espresso_events', |
|
| 1099 | + 'posts_per_page' => $limit, |
|
| 1100 | + 'update_post_term_cache' => false, |
|
| 1101 | + 'update_post_meta_cache' => false, |
|
| 1102 | + 'paged' => $paged, |
|
| 1103 | + 'offset' => ($paged - 1) * $limit |
|
| 1104 | + ) |
|
| 1105 | + ); |
|
| 1106 | + // run the query |
|
| 1107 | + parent::__construct($args); |
|
| 1108 | + } |
|
| 1109 | + |
|
| 1110 | + |
|
| 1111 | + |
|
| 1112 | + /** |
|
| 1113 | + * event_list_title |
|
| 1114 | + * |
|
| 1115 | + * @param string $event_list_title |
|
| 1116 | + * @return string |
|
| 1117 | + */ |
|
| 1118 | + public function event_list_title($event_list_title = '') |
|
| 1119 | + { |
|
| 1120 | + if (! empty($this->title)) { |
|
| 1121 | + return $this->title; |
|
| 1122 | + } |
|
| 1123 | + return $event_list_title; |
|
| 1124 | + } |
|
| 1125 | + |
|
| 1126 | + |
|
| 1127 | + |
|
| 1128 | + /** |
|
| 1129 | + * event_list_css |
|
| 1130 | + * |
|
| 1131 | + * @param string $event_list_css |
|
| 1132 | + * @return string |
|
| 1133 | + */ |
|
| 1134 | + public function event_list_css($event_list_css = '') |
|
| 1135 | + { |
|
| 1136 | + $event_list_css .= ! empty($event_list_css) |
|
| 1137 | + ? ' ' |
|
| 1138 | + : ''; |
|
| 1139 | + $event_list_css .= ! empty($this->css_class) |
|
| 1140 | + ? $this->css_class |
|
| 1141 | + : ''; |
|
| 1142 | + $event_list_css .= ! empty($event_list_css) |
|
| 1143 | + ? ' ' |
|
| 1144 | + : ''; |
|
| 1145 | + $event_list_css .= ! empty($this->category_slug) |
|
| 1146 | + ? $this->category_slug |
|
| 1147 | + : ''; |
|
| 1148 | + return $event_list_css; |
|
| 1149 | + } |
|
| 1150 | 1150 | |
| 1151 | 1151 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | /** |
| 6 | 6 | * ************************************************************************ |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | $action_or_filter = 'action' |
| 44 | 44 | ) { |
| 45 | 45 | $action_or_filter = $action_or_filter === 'action' |
| 46 | - ? esc_html__( 'action', 'event_espresso' ) |
|
| 47 | - : esc_html__( 'filter', 'event_espresso' ); |
|
| 46 | + ? esc_html__('action', 'event_espresso') |
|
| 47 | + : esc_html__('filter', 'event_espresso'); |
|
| 48 | 48 | EE_Error::doing_it_wrong( |
| 49 | 49 | $deprecated_filter, |
| 50 | 50 | sprintf( |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param \EE_Checkout $checkout |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
| 71 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
| 72 | 72 | // list of old filters |
| 73 | 73 | $deprecated_filters = array( |
| 74 | 74 | 'update_registration_details' => true, |
@@ -78,16 +78,16 @@ discard block |
||
| 78 | 78 | 'proceed_to' => true, |
| 79 | 79 | ); |
| 80 | 80 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
| 81 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
| 81 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
| 82 | 82 | // was this filter called ? |
| 83 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
| 83 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
| 84 | 84 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
| 85 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
| 85 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
| 86 | 86 | EE_Error::doing_it_wrong( |
| 87 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 87 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 88 | 88 | sprintf( |
| 89 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
| 90 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 89 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
| 90 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 91 | 91 | '<br />', |
| 92 | 92 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
| 93 | 93 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -96,24 +96,24 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | } |
| 98 | 98 | } else { |
| 99 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
| 99 | + unset($deprecated_filters[$deprecated_filter]); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | - if ( ! empty( $deprecated_filters )) { |
|
| 103 | - |
|
| 104 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
| 105 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
| 106 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
| 107 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
| 108 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
| 109 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
| 102 | + if ( ! empty($deprecated_filters)) { |
|
| 103 | + |
|
| 104 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
| 105 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
| 106 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
| 107 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
| 108 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
| 109 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
| 110 | 110 | } |
| 111 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
| 112 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
| 113 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
| 111 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 112 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
| 113 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
| 114 | 114 | } |
| 115 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
| 116 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
| 115 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
| 116 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | return $submit_button_text; |
| 122 | 122 | |
| 123 | 123 | } |
| 124 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
| 124 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | |
@@ -132,16 +132,16 @@ discard block |
||
| 132 | 132 | * @param \EE_Checkout $checkout |
| 133 | 133 | * @param boolean $status_updates |
| 134 | 134 | */ |
| 135 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
| 135 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
| 136 | 136 | $action_ref = NULL; |
| 137 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 138 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 139 | - if ( $action_ref ) { |
|
| 137 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 138 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 139 | + if ($action_ref) { |
|
| 140 | 140 | |
| 141 | 141 | EE_Error::doing_it_wrong( |
| 142 | 142 | $action_ref, |
| 143 | 143 | sprintf( |
| 144 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
| 144 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
| 145 | 145 | '<br />', |
| 146 | 146 | '/core/business/EE_Transaction_Processor.class.php', |
| 147 | 147 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -151,39 +151,39 @@ discard block |
||
| 151 | 151 | ), |
| 152 | 152 | '4.6.0' |
| 153 | 153 | ); |
| 154 | - switch ( $action_ref ) { |
|
| 154 | + switch ($action_ref) { |
|
| 155 | 155 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
| 156 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
| 156 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
| 157 | 157 | break; |
| 158 | 158 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
| 159 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
| 159 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
| 160 | 160 | break; |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
| 164 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
| 165 | 165 | /** |
| 166 | 166 | * ee_deprecated_finalize_registration |
| 167 | 167 | * |
| 168 | 168 | * @param EE_Registration $registration |
| 169 | 169 | */ |
| 170 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
| 171 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 172 | - if ( $action_ref ) { |
|
| 170 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
| 171 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 172 | + if ($action_ref) { |
|
| 173 | 173 | EE_Error::doing_it_wrong( |
| 174 | 174 | $action_ref, |
| 175 | 175 | sprintf( |
| 176 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
| 176 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
| 177 | 177 | '<br />', |
| 178 | 178 | '/core/business/EE_Registration_Processor.class.php', |
| 179 | 179 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
| 180 | 180 | ), |
| 181 | 181 | '4.6.0' |
| 182 | 182 | ); |
| 183 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
| 183 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
| 186 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
| 192 | 192 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
| 193 | 193 | */ |
| 194 | -function ee_deprecated_hooks(){ |
|
| 194 | +function ee_deprecated_hooks() { |
|
| 195 | 195 | /** |
| 196 | 196 | * @var $hooks array where keys are hook names, and their values are array{ |
| 197 | 197 | * @type string $version when deprecated |
@@ -202,25 +202,25 @@ discard block |
||
| 202 | 202 | $hooks = array( |
| 203 | 203 | 'AHEE__EE_System___do_setup_validations' => array( |
| 204 | 204 | 'version' => '4.6.0', |
| 205 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
| 205 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
| 206 | 206 | 'still_works' => FALSE |
| 207 | 207 | ) |
| 208 | 208 | ); |
| 209 | - foreach( $hooks as $name => $deprecation_info ){ |
|
| 210 | - if( has_action( $name ) ){ |
|
| 209 | + foreach ($hooks as $name => $deprecation_info) { |
|
| 210 | + if (has_action($name)) { |
|
| 211 | 211 | EE_Error::doing_it_wrong( |
| 212 | 212 | $name, |
| 213 | 213 | sprintf( |
| 214 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
| 215 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
| 216 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
| 214 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
| 215 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
| 216 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
| 217 | 217 | ), |
| 218 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ) |
|
| 218 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
| 219 | 219 | ); |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
| 223 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | * @return boolean |
| 232 | 232 | */ |
| 233 | 233 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
| 234 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
| 235 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
| 236 | - if( $in_use ) { |
|
| 234 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
| 235 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
| 236 | + if ($in_use) { |
|
| 237 | 237 | $msg = __( |
| 238 | 238 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
| 239 | 239 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -242,18 +242,18 @@ discard block |
||
| 242 | 242 | 'event_espresso' ) |
| 243 | 243 | ; |
| 244 | 244 | EE_Error::doing_it_wrong( |
| 245 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 245 | + __CLASS__.'::'.__FUNCTION__, |
|
| 246 | 246 | $msg, |
| 247 | 247 | '4.8.32.rc.000' |
| 248 | 248 | ); |
| 249 | 249 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
| 250 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 251 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 250 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 251 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | return $in_use; |
| 255 | 255 | } |
| 256 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
| 256 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -262,34 +262,34 @@ discard block |
||
| 262 | 262 | * @param EE_Admin_Page $admin_page |
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
| 265 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
| 266 | 266 | //check if the old hooks are in use. If not, do the default |
| 267 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 268 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 267 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 268 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | 271 | $req_data = $admin_page->get_request_data(); |
| 272 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
| 273 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
| 274 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
| 275 | - if ( ! $REG_ID || ! $qstns ) { |
|
| 276 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 272 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
| 273 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
| 274 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
| 275 | + if ( ! $REG_ID || ! $qstns) { |
|
| 276 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 277 | 277 | } |
| 278 | 278 | $success = TRUE; |
| 279 | 279 | |
| 280 | 280 | // allow others to get in on this awesome fun :D |
| 281 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
| 281 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
| 282 | 282 | // loop thru questions... FINALLY!!! |
| 283 | 283 | |
| 284 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
| 284 | + foreach ($qstns as $QST_ID => $qstn) { |
|
| 285 | 285 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
| 286 | - if ( !is_array($qstn) ) { |
|
| 287 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
| 286 | + if ( ! is_array($qstn)) { |
|
| 287 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
| 288 | 288 | continue; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
| 292 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
| 292 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
| 293 | 293 | //get answer |
| 294 | 294 | $query_params = array( |
| 295 | 295 | 0 => array( |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | ); |
| 301 | 301 | $answer = EEM_Answer::instance()->get_one($query_params); |
| 302 | 302 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
| 303 | - if ( ! $answer instanceof EE_Answer ) { |
|
| 303 | + if ( ! $answer instanceof EE_Answer) { |
|
| 304 | 304 | $set_values = array( |
| 305 | 305 | 'QST_ID' => $QST_ID, |
| 306 | 306 | 'REG_ID' => $REG_ID, |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | $what = __('Registration Form', 'event_espresso'); |
| 318 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
| 319 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
| 318 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
| 319 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 320 | 320 | exit; |
| 321 | 321 | } |
| 322 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
| 322 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
| 323 | 323 | /** |
| 324 | 324 | * Render the registration admin page's custom questions area in the old fashion |
| 325 | 325 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -332,31 +332,31 @@ discard block |
||
| 332 | 332 | * @return bool |
| 333 | 333 | * @throws \EE_Error |
| 334 | 334 | */ |
| 335 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
| 335 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
| 336 | 336 | //check if the old hooks are in use. If not, do the default |
| 337 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 338 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 337 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 338 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 339 | 339 | return $do_default_action; |
| 340 | 340 | } |
| 341 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
| 342 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
| 343 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
| 344 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
| 341 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
| 342 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
| 343 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
| 344 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
| 345 | 345 | |
| 346 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
| 346 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
| 347 | 347 | |
| 348 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
| 348 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
| 349 | 349 | $template_args = array( |
| 350 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
| 350 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
| 351 | 351 | 'reg_questions_form_action' => 'edit_registration', |
| 352 | 352 | 'REG_ID' => $registration->ID() |
| 353 | 353 | ); |
| 354 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 355 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 354 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 355 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 356 | 356 | //indicate that we should not do the default admin page code |
| 357 | 357 | return false; |
| 358 | 358 | } |
| 359 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
| 359 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
| 360 | 360 | |
| 361 | 361 | |
| 362 | 362 | |
@@ -397,9 +397,9 @@ discard block |
||
| 397 | 397 | '4.9.0' |
| 398 | 398 | ); |
| 399 | 399 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
| 400 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 401 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
| 402 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
| 400 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 401 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
| 402 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
| 403 | 403 | return EE_Registry::instance()->load_lib( |
| 404 | 404 | 'Messages_Template_Defaults', |
| 405 | 405 | array( |
@@ -464,15 +464,15 @@ discard block |
||
| 464 | 464 | /** |
| 465 | 465 | * @param string $method |
| 466 | 466 | */ |
| 467 | - public function _class_is_deprecated( $method ) { |
|
| 467 | + public function _class_is_deprecated($method) { |
|
| 468 | 468 | EE_Error::doing_it_wrong( |
| 469 | - 'EE_messages::' . $method, |
|
| 470 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
| 469 | + 'EE_messages::'.$method, |
|
| 470 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
| 471 | 471 | '4.9.0', |
| 472 | 472 | '4.10.0.p' |
| 473 | 473 | ); |
| 474 | 474 | // Please use EE_Message_Resource_Manager instead |
| 475 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 475 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | |
@@ -482,10 +482,10 @@ discard block |
||
| 482 | 482 | * @param string $messenger_name |
| 483 | 483 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
| 484 | 484 | */ |
| 485 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
| 485 | + public function ensure_messenger_is_active($messenger_name) { |
|
| 486 | 486 | // EE_messages has been deprecated |
| 487 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 488 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
| 487 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 488 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | |
@@ -497,10 +497,10 @@ discard block |
||
| 497 | 497 | * @return bool true if it got activated (or was active) and false if not. |
| 498 | 498 | * @throws \EE_Error |
| 499 | 499 | */ |
| 500 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
| 500 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
| 501 | 501 | // EE_messages has been deprecated |
| 502 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 503 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
| 502 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 503 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | * they are already setup.) |
| 514 | 514 | * @return boolean an array of generated templates or false if nothing generated/activated. |
| 515 | 515 | */ |
| 516 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
| 516 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
| 517 | 517 | // EE_messages has been deprecated |
| 518 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 519 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
| 518 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 519 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
@@ -528,10 +528,10 @@ discard block |
||
| 528 | 528 | * |
| 529 | 529 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
| 530 | 530 | */ |
| 531 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 531 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
| 532 | 532 | // EE_messages has been deprecated |
| 533 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 534 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
| 533 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 534 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
@@ -541,10 +541,10 @@ discard block |
||
| 541 | 541 | * @param string $messenger |
| 542 | 542 | * @return EE_messenger | null |
| 543 | 543 | */ |
| 544 | - public function get_messenger_if_active( $messenger ) { |
|
| 544 | + public function get_messenger_if_active($messenger) { |
|
| 545 | 545 | // EE_messages has been deprecated |
| 546 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 547 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
| 546 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 547 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | * 'message_type' => null |
| 566 | 566 | * ) |
| 567 | 567 | */ |
| 568 | - public function validate_for_use( EE_Message $message ) { |
|
| 568 | + public function validate_for_use(EE_Message $message) { |
|
| 569 | 569 | // EE_messages has been deprecated |
| 570 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 570 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 571 | 571 | return array( |
| 572 | 572 | 'messenger' => $message->messenger_object(), |
| 573 | 573 | 'message_type' => $message->message_type_object(), |
@@ -595,41 +595,41 @@ discard block |
||
| 595 | 595 | $send = true |
| 596 | 596 | ) { |
| 597 | 597 | // EE_messages has been deprecated |
| 598 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 598 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 599 | 599 | /** @type EE_Messages_Processor $processor */ |
| 600 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
| 600 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
| 601 | 601 | $error = false; |
| 602 | 602 | //try to intelligently determine what method we'll call based on the incoming data. |
| 603 | 603 | //if generating and sending are different then generate and send immediately. |
| 604 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
| 604 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
| 605 | 605 | //in the legacy system, when generating and sending were different, that means all the |
| 606 | 606 | //vars are already in the request object. So let's just use that. |
| 607 | 607 | try { |
| 608 | 608 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
| 609 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
| 610 | - $processor->generate_and_send_now( $mtg ); |
|
| 611 | - } catch ( EE_Error $e ) { |
|
| 609 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
| 610 | + $processor->generate_and_send_now($mtg); |
|
| 611 | + } catch (EE_Error $e) { |
|
| 612 | 612 | $error_msg = __( |
| 613 | 613 | 'Please note that a system message failed to send due to a technical issue.', |
| 614 | 614 | 'event_espresso' |
| 615 | 615 | ); |
| 616 | 616 | // add specific message for developers if WP_DEBUG in on |
| 617 | - $error_msg .= '||' . $e->getMessage(); |
|
| 618 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 617 | + $error_msg .= '||'.$e->getMessage(); |
|
| 618 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 619 | 619 | $error = true; |
| 620 | 620 | } |
| 621 | 621 | } else { |
| 622 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
| 622 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
| 623 | 623 | //let's find out if there were any errors and how many successfully were queued. |
| 624 | 624 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
| 625 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
| 625 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
| 626 | 626 | ); |
| 627 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
| 628 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
| 627 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
| 628 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
| 629 | 629 | $count_errors = $count_errors + $count_retry; |
| 630 | - if ( $count_errors > 0 ) { |
|
| 630 | + if ($count_errors > 0) { |
|
| 631 | 631 | $error = true; |
| 632 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
| 632 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
| 633 | 633 | $message = sprintf( |
| 634 | 634 | __( |
| 635 | 635 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | $count_errors, |
| 639 | 639 | $count_queued |
| 640 | 640 | ); |
| 641 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
| 641 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
| 642 | 642 | $message = sprintf( |
| 643 | 643 | __( |
| 644 | 644 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | $count_errors, |
| 648 | 648 | $count_queued |
| 649 | 649 | ); |
| 650 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
| 650 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
| 651 | 651 | $message = sprintf( |
| 652 | 652 | __( |
| 653 | 653 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -665,9 +665,9 @@ discard block |
||
| 665 | 665 | $count_errors |
| 666 | 666 | ); |
| 667 | 667 | } |
| 668 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 668 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
| 669 | 669 | } else { |
| 670 | - if ( $count_queued === 1 ) { |
|
| 670 | + if ($count_queued === 1) { |
|
| 671 | 671 | $message = sprintf( |
| 672 | 672 | __( |
| 673 | 673 | '%d message successfully queued for generation.', |
@@ -684,18 +684,18 @@ discard block |
||
| 684 | 684 | $count_queued |
| 685 | 685 | ); |
| 686 | 686 | } |
| 687 | - EE_Error::add_success( $message ); |
|
| 687 | + EE_Error::add_success($message); |
|
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | //if no error then return the generated message(s). |
| 691 | - if ( ! $error && ! $send ) { |
|
| 692 | - $generated_queue = $processor->generate_queue( false ); |
|
| 691 | + if ( ! $error && ! $send) { |
|
| 692 | + $generated_queue = $processor->generate_queue(false); |
|
| 693 | 693 | //get message and return. |
| 694 | 694 | $generated_queue->get_message_repository()->rewind(); |
| 695 | 695 | $messages = array(); |
| 696 | - while ( $generated_queue->get_message_repository()->valid() ) { |
|
| 696 | + while ($generated_queue->get_message_repository()->valid()) { |
|
| 697 | 697 | $message = $generated_queue->get_message_repository()->current(); |
| 698 | - if ( $message instanceof EE_Message ) { |
|
| 698 | + if ($message instanceof EE_Message) { |
|
| 699 | 699 | //set properties that might be expected by add-ons (backward compat) |
| 700 | 700 | $message->content = $message->content(); |
| 701 | 701 | $message->template_pack = $message->get_template_pack(); |
@@ -720,10 +720,10 @@ discard block |
||
| 720 | 720 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
| 721 | 721 | * @return string The body of the message. |
| 722 | 722 | */ |
| 723 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
| 723 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
| 724 | 724 | // EE_messages has been deprecated |
| 725 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 726 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
| 725 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 726 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | |
@@ -737,14 +737,14 @@ discard block |
||
| 737 | 737 | * |
| 738 | 738 | * @return bool success or fail. |
| 739 | 739 | */ |
| 740 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
| 740 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
| 741 | 741 | // EE_messages has been deprecated |
| 742 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 742 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 743 | 743 | //setup for sending to new method. |
| 744 | 744 | /** @type EE_Messages_Queue $queue */ |
| 745 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
| 745 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
| 746 | 746 | //make sure we have a proper message object |
| 747 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
| 747 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
| 748 | 748 | $msg = EE_Message_Factory::create( |
| 749 | 749 | array( |
| 750 | 750 | 'MSG_messenger' => $messenger, |
@@ -756,15 +756,15 @@ discard block |
||
| 756 | 756 | } else { |
| 757 | 757 | $msg = $message; |
| 758 | 758 | } |
| 759 | - if ( ! $msg instanceof EE_Message ) { |
|
| 759 | + if ( ! $msg instanceof EE_Message) { |
|
| 760 | 760 | return false; |
| 761 | 761 | } |
| 762 | 762 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
| 763 | - if ( ! empty( $msg->content ) ) { |
|
| 764 | - $msg->set( 'MSG_content', $msg->content ); |
|
| 763 | + if ( ! empty($msg->content)) { |
|
| 764 | + $msg->set('MSG_content', $msg->content); |
|
| 765 | 765 | } |
| 766 | - $queue->add( $msg ); |
|
| 767 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
| 766 | + $queue->add($msg); |
|
| 767 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | |
@@ -778,11 +778,11 @@ discard block |
||
| 778 | 778 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
| 779 | 779 | * @throws \EE_Error |
| 780 | 780 | */ |
| 781 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
| 781 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
| 782 | 782 | // EE_messages has been deprecated |
| 783 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 784 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 785 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
| 783 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 784 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 785 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | |
@@ -793,11 +793,11 @@ discard block |
||
| 793 | 793 | * @param string $message_type_name name of EE_message_type |
| 794 | 794 | * @return array |
| 795 | 795 | */ |
| 796 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
| 796 | + public function get_fields($messenger_name, $message_type_name) { |
|
| 797 | 797 | // EE_messages has been deprecated |
| 798 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 799 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 800 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
| 798 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 799 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 800 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | |
@@ -811,13 +811,13 @@ discard block |
||
| 811 | 811 | * @return array multidimensional array of messenger and message_type objects |
| 812 | 812 | * (messengers index, and message_type index); |
| 813 | 813 | */ |
| 814 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
| 814 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
| 815 | 815 | // EE_messages has been deprecated |
| 816 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 817 | - if ( $skip_cache ) { |
|
| 816 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 817 | + if ($skip_cache) { |
|
| 818 | 818 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
| 819 | 819 | } |
| 820 | - switch ( $type ) { |
|
| 820 | + switch ($type) { |
|
| 821 | 821 | case 'messengers' : |
| 822 | 822 | return array( |
| 823 | 823 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | */ |
| 847 | 847 | public function get_active_messengers() { |
| 848 | 848 | // EE_messages has been deprecated |
| 849 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 849 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 850 | 850 | return $this->_message_resource_manager->active_messengers(); |
| 851 | 851 | } |
| 852 | 852 | |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | */ |
| 859 | 859 | public function get_active_message_types() { |
| 860 | 860 | // EE_messages has been deprecated |
| 861 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 861 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 862 | 862 | return $this->_message_resource_manager->list_of_active_message_types(); |
| 863 | 863 | } |
| 864 | 864 | |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | */ |
| 871 | 871 | public function get_active_message_type_objects() { |
| 872 | 872 | // EE_messages has been deprecated |
| 873 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 873 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 874 | 874 | return $this->_message_resource_manager->get_active_message_type_objects(); |
| 875 | 875 | } |
| 876 | 876 | |
@@ -882,10 +882,10 @@ discard block |
||
| 882 | 882 | * @param string $messenger The messenger being checked |
| 883 | 883 | * @return EE_message_type[] (or empty array if none present) |
| 884 | 884 | */ |
| 885 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
| 885 | + public function get_active_message_types_per_messenger($messenger) { |
|
| 886 | 886 | // EE_messages has been deprecated |
| 887 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 888 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
| 887 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 888 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | |
@@ -896,10 +896,10 @@ discard block |
||
| 896 | 896 | * @param string $message_type The string should correspond to a message type. |
| 897 | 897 | * @return EE_message_type|null |
| 898 | 898 | */ |
| 899 | - public function get_active_message_type( $messenger, $message_type ) { |
|
| 899 | + public function get_active_message_type($messenger, $message_type) { |
|
| 900 | 900 | // EE_messages has been deprecated |
| 901 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 902 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
| 901 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 902 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | */ |
| 911 | 911 | public function get_installed_message_types() { |
| 912 | 912 | // EE_messages has been deprecated |
| 913 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 913 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 914 | 914 | return $this->_message_resource_manager->installed_message_types(); |
| 915 | 915 | } |
| 916 | 916 | |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | */ |
| 923 | 923 | public function get_installed_messengers() { |
| 924 | 924 | // EE_messages has been deprecated |
| 925 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 925 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 926 | 926 | return $this->_message_resource_manager->installed_messengers(); |
| 927 | 927 | } |
| 928 | 928 | |
@@ -933,10 +933,10 @@ discard block |
||
| 933 | 933 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
| 934 | 934 | * @return array |
| 935 | 935 | */ |
| 936 | - public function get_all_contexts( $slugs_only = true ) { |
|
| 936 | + public function get_all_contexts($slugs_only = true) { |
|
| 937 | 937 | // EE_messages has been deprecated |
| 938 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 939 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
| 938 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 939 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | add_filter( |
| 996 | 996 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
| 997 | 997 | function($event_list_iframe_css) { |
| 998 | - if ( ! has_filter( 'FHEE__EventsArchiveIframe__event_list_iframe__css' )) { |
|
| 998 | + if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
| 999 | 999 | return $event_list_iframe_css; |
| 1000 | 1000 | } |
| 1001 | 1001 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | add_filter( |
| 1016 | 1016 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
| 1017 | 1017 | function($event_list_iframe_js) { |
| 1018 | - if ( ! has_filter( 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js' )) { |
|
| 1018 | + if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
| 1019 | 1019 | return $event_list_iframe_js; |
| 1020 | 1020 | } |
| 1021 | 1021 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | add_filter( |
| 1036 | 1036 | 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
| 1037 | 1037 | function($existing_attendee, $registration, $attendee_data) { |
| 1038 | - if ( ! has_filter( 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee' )) { |
|
| 1038 | + if ( ! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
| 1039 | 1039 | return $existing_attendee; |
| 1040 | 1040 | } |
| 1041 | 1041 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | $existing_attendee, $registration, $attendee_data |
| 1052 | 1052 | ); |
| 1053 | 1053 | }, |
| 1054 | - 10,3 |
|
| 1054 | + 10, 3 |
|
| 1055 | 1055 | ); |
| 1056 | 1056 | |
| 1057 | 1057 | |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | */ |
| 1118 | 1118 | public function event_list_title($event_list_title = '') |
| 1119 | 1119 | { |
| 1120 | - if (! empty($this->title)) { |
|
| 1120 | + if ( ! empty($this->title)) { |
|
| 1121 | 1121 | return $this->title; |
| 1122 | 1122 | } |
| 1123 | 1123 | return $event_list_title; |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
| 2 | 2 | |
| 3 | 3 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 4 | - exit('No direct script access allowed'); |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -15,1690 +15,1690 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Used to reference when a registration has never been checked in. |
|
| 20 | - * |
|
| 21 | - * @type int |
|
| 22 | - */ |
|
| 23 | - const checkin_status_never = 2; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Used to reference when a registration has been checked in. |
|
| 27 | - * |
|
| 28 | - * @type int |
|
| 29 | - */ |
|
| 30 | - const checkin_status_in = 1; |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Used to reference when a registration has been checked out. |
|
| 35 | - * |
|
| 36 | - * @type int |
|
| 37 | - */ |
|
| 38 | - const checkin_status_out = 0; |
|
| 39 | - |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * extra meta key for tracking reg status os trashed registrations |
|
| 43 | - * |
|
| 44 | - * @type string |
|
| 45 | - */ |
|
| 46 | - const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * extra meta key for tracking if registration has reserved ticket |
|
| 51 | - * |
|
| 52 | - * @type string |
|
| 53 | - */ |
|
| 54 | - const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @param array $props_n_values incoming values |
|
| 59 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 60 | - * used.) |
|
| 61 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 62 | - * date_format and the second value is the time format |
|
| 63 | - * @return EE_Registration |
|
| 64 | - */ |
|
| 65 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 66 | - { |
|
| 67 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 68 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @param array $props_n_values incoming values from the database |
|
| 74 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 75 | - * the website will be used. |
|
| 76 | - * @return EE_Registration |
|
| 77 | - */ |
|
| 78 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 79 | - { |
|
| 80 | - return new self($props_n_values, true, $timezone); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Set Event ID |
|
| 86 | - * |
|
| 87 | - * @param int $EVT_ID Event ID |
|
| 88 | - */ |
|
| 89 | - public function set_event($EVT_ID = 0) |
|
| 90 | - { |
|
| 91 | - $this->set('EVT_ID', $EVT_ID); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can |
|
| 97 | - * be routed to internal methods |
|
| 98 | - * |
|
| 99 | - * @param string $field_name |
|
| 100 | - * @param mixed $field_value |
|
| 101 | - * @param bool $use_default |
|
| 102 | - * @throws \EE_Error |
|
| 103 | - * @throws \RuntimeException |
|
| 104 | - */ |
|
| 105 | - public function set($field_name, $field_value, $use_default = false) |
|
| 106 | - { |
|
| 107 | - switch ($field_name) { |
|
| 108 | - case 'REG_code' : |
|
| 109 | - if (! empty($field_value) && $this->reg_code() === null) { |
|
| 110 | - $this->set_reg_code($field_value, $use_default); |
|
| 111 | - } |
|
| 112 | - break; |
|
| 113 | - case 'STS_ID' : |
|
| 114 | - $this->set_status($field_value, $use_default); |
|
| 115 | - break; |
|
| 116 | - default : |
|
| 117 | - parent::set($field_name, $field_value, $use_default); |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Set Status ID |
|
| 124 | - * updates the registration status and ALSO... |
|
| 125 | - * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
|
| 126 | - * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
|
| 127 | - * |
|
| 128 | - * @param string $new_STS_ID |
|
| 129 | - * @param boolean $use_default |
|
| 130 | - * @return bool |
|
| 131 | - * @throws \RuntimeException |
|
| 132 | - * @throws \EE_Error |
|
| 133 | - */ |
|
| 134 | - public function set_status($new_STS_ID = null, $use_default = false) |
|
| 135 | - { |
|
| 136 | - // get current REG_Status |
|
| 137 | - $old_STS_ID = $this->status_ID(); |
|
| 138 | - // if status has changed |
|
| 139 | - if ( |
|
| 140 | - $old_STS_ID !== $new_STS_ID // and that status has actually changed |
|
| 141 | - && ! empty($old_STS_ID) // and that old status is actually set |
|
| 142 | - && ! empty($new_STS_ID) // as well as the new status |
|
| 143 | - && $this->ID() // ensure registration is in the db |
|
| 144 | - ) { |
|
| 145 | - // TO approved |
|
| 146 | - if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
| 147 | - // reserve a space by incrementing ticket and datetime sold values |
|
| 148 | - $this->_reserve_registration_space(); |
|
| 149 | - do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
| 150 | - // OR FROM approved |
|
| 151 | - } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
| 152 | - // release a space by decrementing ticket and datetime sold values |
|
| 153 | - $this->_release_registration_space(); |
|
| 154 | - do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
| 155 | - } |
|
| 156 | - // update status |
|
| 157 | - parent::set('STS_ID', $new_STS_ID, $use_default); |
|
| 158 | - $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID); |
|
| 159 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
| 160 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 161 | - $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
| 162 | - $this->transaction()->update_status_based_on_total_paid(true); |
|
| 163 | - do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID); |
|
| 164 | - return true; |
|
| 165 | - } |
|
| 166 | - //even though the old value matches the new value, it's still good to |
|
| 167 | - //allow the parent set method to have a say |
|
| 168 | - parent::set('STS_ID', $new_STS_ID, $use_default); |
|
| 169 | - return true; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * update REGs and TXN when cancelled or declined registrations involved |
|
| 175 | - * |
|
| 176 | - * @param string $new_STS_ID |
|
| 177 | - * @param string $old_STS_ID |
|
| 178 | - * @throws \EE_Error |
|
| 179 | - */ |
|
| 180 | - private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID) |
|
| 181 | - { |
|
| 182 | - // these reg statuses should not be considered in any calculations involving monies owing |
|
| 183 | - $closed_reg_statuses = EEM_Registration::closed_reg_statuses(); |
|
| 184 | - // true if registration has been cancelled or declined |
|
| 185 | - if ( |
|
| 186 | - in_array($new_STS_ID, $closed_reg_statuses, true) |
|
| 187 | - && ! in_array($old_STS_ID, $closed_reg_statuses, true) |
|
| 188 | - ) { |
|
| 189 | - /** @type EE_Registration_Processor $registration_processor */ |
|
| 190 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 191 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 192 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 193 | - // cancelled or declined registration |
|
| 194 | - $registration_processor->update_registration_after_being_canceled_or_declined( |
|
| 195 | - $this, |
|
| 196 | - $closed_reg_statuses |
|
| 197 | - ); |
|
| 198 | - $transaction_processor->update_transaction_after_canceled_or_declined_registration( |
|
| 199 | - $this, |
|
| 200 | - $closed_reg_statuses, |
|
| 201 | - false |
|
| 202 | - ); |
|
| 203 | - do_action('AHEE__EE_Registration__set_status__canceled_or_declined', $this, $old_STS_ID, $new_STS_ID); |
|
| 204 | - return; |
|
| 205 | - } |
|
| 206 | - // true if reinstating cancelled or declined registration |
|
| 207 | - if ( |
|
| 208 | - in_array($old_STS_ID, $closed_reg_statuses, true) |
|
| 209 | - && ! in_array($new_STS_ID, $closed_reg_statuses, true) |
|
| 210 | - ) { |
|
| 211 | - /** @type EE_Registration_Processor $registration_processor */ |
|
| 212 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 213 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 214 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 215 | - // reinstating cancelled or declined registration |
|
| 216 | - $registration_processor->update_canceled_or_declined_registration_after_being_reinstated( |
|
| 217 | - $this, |
|
| 218 | - $closed_reg_statuses |
|
| 219 | - ); |
|
| 220 | - $transaction_processor->update_transaction_after_reinstating_canceled_registration( |
|
| 221 | - $this, |
|
| 222 | - $closed_reg_statuses, |
|
| 223 | - false |
|
| 224 | - ); |
|
| 225 | - do_action('AHEE__EE_Registration__set_status__after_reinstated', $this, $old_STS_ID, $new_STS_ID); |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * get Status ID |
|
| 232 | - */ |
|
| 233 | - public function status_ID() |
|
| 234 | - { |
|
| 235 | - return $this->get('STS_ID'); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * increments this registration's related ticket sold and corresponding datetime sold values |
|
| 241 | - * |
|
| 242 | - * @return void |
|
| 243 | - * @throws \EE_Error |
|
| 244 | - */ |
|
| 245 | - private function _reserve_registration_space() |
|
| 246 | - { |
|
| 247 | - // reserved ticket and datetime counts will be decremented as sold counts are incremented |
|
| 248 | - // so stop tracking that this reg has a ticket reserved |
|
| 249 | - $this->release_reserved_ticket(); |
|
| 250 | - $ticket = $this->ticket(); |
|
| 251 | - $ticket->increase_sold(); |
|
| 252 | - $ticket->save(); |
|
| 253 | - // possibly set event status to sold out |
|
| 254 | - $this->event()->perform_sold_out_status_check(); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * Gets the ticket this registration is for |
|
| 260 | - * |
|
| 261 | - * @param boolean $include_archived whether to include archived tickets or not. |
|
| 262 | - * @return EE_Ticket|EE_Base_Class |
|
| 263 | - * @throws \EE_Error |
|
| 264 | - */ |
|
| 265 | - public function ticket($include_archived = true) |
|
| 266 | - { |
|
| 267 | - $query_params = array(); |
|
| 268 | - if ($include_archived) { |
|
| 269 | - $query_params['default_where_conditions'] = 'none'; |
|
| 270 | - } |
|
| 271 | - return $this->get_first_related('Ticket', $query_params); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * Gets the event this registration is for |
|
| 277 | - * |
|
| 278 | - * @return EE_Event |
|
| 279 | - */ |
|
| 280 | - public function event() |
|
| 281 | - { |
|
| 282 | - $event = $this->get_first_related('Event'); |
|
| 283 | - if (! $event instanceof \EE_Event) { |
|
| 284 | - throw new EntityNotFoundException('Event ID', $this->event_ID()); |
|
| 285 | - } |
|
| 286 | - return $event; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond |
|
| 292 | - * with the author of the event this registration is for. |
|
| 293 | - * |
|
| 294 | - * @since 4.5.0 |
|
| 295 | - * @return int |
|
| 296 | - */ |
|
| 297 | - public function wp_user() |
|
| 298 | - { |
|
| 299 | - $event = $this->event(); |
|
| 300 | - if ($event instanceof EE_Event) { |
|
| 301 | - return $event->wp_user(); |
|
| 302 | - } |
|
| 303 | - return 0; |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - |
|
| 307 | - /** |
|
| 308 | - * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
|
| 309 | - * |
|
| 310 | - * @return void |
|
| 311 | - * @throws \EE_Error |
|
| 312 | - */ |
|
| 313 | - private function _release_registration_space() |
|
| 314 | - { |
|
| 315 | - $ticket = $this->ticket(); |
|
| 316 | - $ticket->decrease_sold(); |
|
| 317 | - $ticket->save(); |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * tracks this registration's ticket reservation in extra meta |
|
| 323 | - * and can increment related ticket reserved and corresponding datetime reserved values |
|
| 324 | - * |
|
| 325 | - * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
|
| 326 | - * @return void |
|
| 327 | - * @throws \EE_Error |
|
| 328 | - */ |
|
| 329 | - public function reserve_ticket($update_ticket = false) |
|
| 330 | - { |
|
| 331 | - if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) { |
|
| 332 | - // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
| 333 | - // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
|
| 334 | - if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) { |
|
| 335 | - $ticket = $this->ticket(); |
|
| 336 | - $ticket->increase_reserved(); |
|
| 337 | - $ticket->save(); |
|
| 338 | - } |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * stops tracking this registration's ticket reservation in extra meta |
|
| 345 | - * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
|
| 346 | - * |
|
| 347 | - * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
|
| 348 | - * @return void |
|
| 349 | - * @throws \EE_Error |
|
| 350 | - */ |
|
| 351 | - public function release_reserved_ticket($update_ticket = false) |
|
| 352 | - { |
|
| 353 | - if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) { |
|
| 354 | - // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
| 355 | - // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first |
|
| 356 | - if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) { |
|
| 357 | - $ticket = $this->ticket(); |
|
| 358 | - $ticket->decrease_reserved(); |
|
| 359 | - $ticket->save(); |
|
| 360 | - } |
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * Set Attendee ID |
|
| 367 | - * |
|
| 368 | - * @param int $ATT_ID Attendee ID |
|
| 369 | - */ |
|
| 370 | - public function set_attendee_id($ATT_ID = 0) |
|
| 371 | - { |
|
| 372 | - $this->set('ATT_ID', $ATT_ID); |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Set Transaction ID |
|
| 378 | - * |
|
| 379 | - * @param int $TXN_ID Transaction ID |
|
| 380 | - */ |
|
| 381 | - public function set_transaction_id($TXN_ID = 0) |
|
| 382 | - { |
|
| 383 | - $this->set('TXN_ID', $TXN_ID); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - |
|
| 387 | - /** |
|
| 388 | - * Set Session |
|
| 389 | - * |
|
| 390 | - * @param string $REG_session PHP Session ID |
|
| 391 | - */ |
|
| 392 | - public function set_session($REG_session = '') |
|
| 393 | - { |
|
| 394 | - $this->set('REG_session', $REG_session); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * Set Registration URL Link |
|
| 400 | - * |
|
| 401 | - * @param string $REG_url_link Registration URL Link |
|
| 402 | - */ |
|
| 403 | - public function set_reg_url_link($REG_url_link = '') |
|
| 404 | - { |
|
| 405 | - $this->set('REG_url_link', $REG_url_link); |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - |
|
| 409 | - /** |
|
| 410 | - * Set Attendee Counter |
|
| 411 | - * |
|
| 412 | - * @param int $REG_count Primary Attendee |
|
| 413 | - */ |
|
| 414 | - public function set_count($REG_count = 1) |
|
| 415 | - { |
|
| 416 | - $this->set('REG_count', $REG_count); |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * Set Group Size |
|
| 422 | - * |
|
| 423 | - * @param boolean $REG_group_size Group Registration |
|
| 424 | - */ |
|
| 425 | - public function set_group_size($REG_group_size = false) |
|
| 426 | - { |
|
| 427 | - $this->set('REG_group_size', $REG_group_size); |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * is_not_approved - convenience method that returns TRUE if REG status ID == |
|
| 433 | - * EEM_Registration::status_id_not_approved |
|
| 434 | - * |
|
| 435 | - * @return boolean |
|
| 436 | - */ |
|
| 437 | - public function is_not_approved() |
|
| 438 | - { |
|
| 439 | - return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false; |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - |
|
| 443 | - /** |
|
| 444 | - * is_pending_payment - convenience method that returns TRUE if REG status ID == |
|
| 445 | - * EEM_Registration::status_id_pending_payment |
|
| 446 | - * |
|
| 447 | - * @return boolean |
|
| 448 | - */ |
|
| 449 | - public function is_pending_payment() |
|
| 450 | - { |
|
| 451 | - return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false; |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - |
|
| 455 | - /** |
|
| 456 | - * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
|
| 457 | - * |
|
| 458 | - * @return boolean |
|
| 459 | - */ |
|
| 460 | - public function is_approved() |
|
| 461 | - { |
|
| 462 | - return $this->status_ID() == EEM_Registration::status_id_approved ? true : false; |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - |
|
| 466 | - /** |
|
| 467 | - * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
|
| 468 | - * |
|
| 469 | - * @return boolean |
|
| 470 | - */ |
|
| 471 | - public function is_cancelled() |
|
| 472 | - { |
|
| 473 | - return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false; |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - |
|
| 477 | - /** |
|
| 478 | - * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
|
| 479 | - * |
|
| 480 | - * @return boolean |
|
| 481 | - */ |
|
| 482 | - public function is_declined() |
|
| 483 | - { |
|
| 484 | - return $this->status_ID() == EEM_Registration::status_id_declined ? true : false; |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - |
|
| 488 | - /** |
|
| 489 | - * is_incomplete - convenience method that returns TRUE if REG status ID == |
|
| 490 | - * EEM_Registration::status_id_incomplete |
|
| 491 | - * |
|
| 492 | - * @return boolean |
|
| 493 | - */ |
|
| 494 | - public function is_incomplete() |
|
| 495 | - { |
|
| 496 | - return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false; |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - |
|
| 500 | - /** |
|
| 501 | - * Set Registration Date |
|
| 502 | - * |
|
| 503 | - * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of |
|
| 504 | - * Date |
|
| 505 | - */ |
|
| 506 | - public function set_reg_date($REG_date = false) |
|
| 507 | - { |
|
| 508 | - $this->set('REG_date', $REG_date); |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * Set final price owing for this registration after all ticket/price modifications |
|
| 514 | - * |
|
| 515 | - * @access public |
|
| 516 | - * @param float $REG_final_price |
|
| 517 | - */ |
|
| 518 | - public function set_final_price($REG_final_price = 0.00) |
|
| 519 | - { |
|
| 520 | - $this->set('REG_final_price', $REG_final_price); |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - |
|
| 524 | - /** |
|
| 525 | - * Set amount paid towards this registration's final price |
|
| 526 | - * |
|
| 527 | - * @access public |
|
| 528 | - * @param float $REG_paid |
|
| 529 | - */ |
|
| 530 | - public function set_paid($REG_paid = 0.00) |
|
| 531 | - { |
|
| 532 | - $this->set('REG_paid', $REG_paid); |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - |
|
| 536 | - /** |
|
| 537 | - * Attendee Is Going |
|
| 538 | - * |
|
| 539 | - * @param boolean $REG_att_is_going Attendee Is Going |
|
| 540 | - */ |
|
| 541 | - public function set_att_is_going($REG_att_is_going = false) |
|
| 542 | - { |
|
| 543 | - $this->set('REG_att_is_going', $REG_att_is_going); |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - |
|
| 547 | - /** |
|
| 548 | - * Gets the related attendee |
|
| 549 | - * |
|
| 550 | - * @return EE_Attendee |
|
| 551 | - */ |
|
| 552 | - public function attendee() |
|
| 553 | - { |
|
| 554 | - return $this->get_first_related('Attendee'); |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - |
|
| 558 | - /** |
|
| 559 | - * get Event ID |
|
| 560 | - */ |
|
| 561 | - public function event_ID() |
|
| 562 | - { |
|
| 563 | - return $this->get('EVT_ID'); |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * get Event ID |
|
| 569 | - */ |
|
| 570 | - public function event_name() |
|
| 571 | - { |
|
| 572 | - $event = $this->event_obj(); |
|
| 573 | - if ($event) { |
|
| 574 | - return $event->name(); |
|
| 575 | - } else { |
|
| 576 | - return null; |
|
| 577 | - } |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - |
|
| 581 | - /** |
|
| 582 | - * Fetches the event this registration is for |
|
| 583 | - * |
|
| 584 | - * @return EE_Event |
|
| 585 | - */ |
|
| 586 | - public function event_obj() |
|
| 587 | - { |
|
| 588 | - return $this->get_first_related('Event'); |
|
| 589 | - } |
|
| 590 | - |
|
| 591 | - |
|
| 592 | - /** |
|
| 593 | - * get Attendee ID |
|
| 594 | - */ |
|
| 595 | - public function attendee_ID() |
|
| 596 | - { |
|
| 597 | - return $this->get('ATT_ID'); |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - |
|
| 601 | - /** |
|
| 602 | - * get PHP Session ID |
|
| 603 | - */ |
|
| 604 | - public function session_ID() |
|
| 605 | - { |
|
| 606 | - return $this->get('REG_session'); |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - |
|
| 610 | - /** |
|
| 611 | - * Gets the string which represents the URL trigger for the receipt template in the message template system. |
|
| 612 | - * |
|
| 613 | - * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
| 614 | - * @return string |
|
| 615 | - */ |
|
| 616 | - public function receipt_url($messenger = 'html') |
|
| 617 | - { |
|
| 618 | - |
|
| 619 | - /** |
|
| 620 | - * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
|
| 621 | - * |
|
| 622 | - * @since 4.5.0 |
|
| 623 | - */ |
|
| 624 | - $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
|
| 625 | - $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
| 626 | - |
|
| 627 | - if ($has_custom) { |
|
| 628 | - return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
| 629 | - } |
|
| 630 | - return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - |
|
| 634 | - /** |
|
| 635 | - * Gets the string which represents the URL trigger for the invoice template in the message template system. |
|
| 636 | - * |
|
| 637 | - * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
| 638 | - * @return string |
|
| 639 | - */ |
|
| 640 | - public function invoice_url($messenger = 'html') |
|
| 641 | - { |
|
| 642 | - /** |
|
| 643 | - * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
|
| 644 | - * |
|
| 645 | - * @since 4.5.0 |
|
| 646 | - */ |
|
| 647 | - $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
|
| 648 | - $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
| 649 | - |
|
| 650 | - if ($has_custom) { |
|
| 651 | - if ($messenger == 'html') { |
|
| 652 | - return $this->invoice_url('launch'); |
|
| 653 | - } |
|
| 654 | - $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
|
| 655 | - |
|
| 656 | - $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
| 657 | - if ($messenger == 'html') { |
|
| 658 | - $query_args['html'] = true; |
|
| 659 | - } |
|
| 660 | - return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
| 661 | - } |
|
| 662 | - return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - |
|
| 666 | - /** |
|
| 667 | - * get Registration URL Link |
|
| 668 | - * |
|
| 669 | - * @access public |
|
| 670 | - * @return string |
|
| 671 | - * @throws \EE_Error |
|
| 672 | - */ |
|
| 673 | - public function reg_url_link() |
|
| 674 | - { |
|
| 675 | - return (string)$this->get('REG_url_link'); |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - |
|
| 679 | - /** |
|
| 680 | - * Echoes out invoice_url() |
|
| 681 | - * |
|
| 682 | - * @param string $type 'download','launch', or 'html' (default is 'launch') |
|
| 683 | - * @return void |
|
| 684 | - */ |
|
| 685 | - public function e_invoice_url($type = 'launch') |
|
| 686 | - { |
|
| 687 | - echo $this->invoice_url($type); |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - |
|
| 691 | - /** |
|
| 692 | - * Echoes out payment_overview_url |
|
| 693 | - */ |
|
| 694 | - public function e_payment_overview_url() |
|
| 695 | - { |
|
| 696 | - echo $this->payment_overview_url(); |
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - |
|
| 700 | - /** |
|
| 701 | - * Gets the URL of the thank you page with this registration REG_url_link added as |
|
| 702 | - * a query parameter |
|
| 703 | - * |
|
| 704 | - * @return string |
|
| 705 | - */ |
|
| 706 | - public function payment_overview_url() |
|
| 707 | - { |
|
| 708 | - return add_query_arg(array( |
|
| 709 | - 'e_reg_url_link' => $this->reg_url_link(), |
|
| 710 | - 'step' => 'payment_options', |
|
| 711 | - 'revisit' => true, |
|
| 712 | - ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
| 713 | - } |
|
| 714 | - |
|
| 715 | - |
|
| 716 | - /** |
|
| 717 | - * Gets the URL of the thank you page with this registration REG_url_link added as |
|
| 718 | - * a query parameter |
|
| 719 | - * |
|
| 720 | - * @return string |
|
| 721 | - */ |
|
| 722 | - public function edit_attendee_information_url() |
|
| 723 | - { |
|
| 724 | - return add_query_arg(array( |
|
| 725 | - 'e_reg_url_link' => $this->reg_url_link(), |
|
| 726 | - 'step' => 'attendee_information', |
|
| 727 | - 'revisit' => true, |
|
| 728 | - ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - |
|
| 732 | - /** |
|
| 733 | - * Simply generates and returns the appropriate admin_url link to edit this registration |
|
| 734 | - * |
|
| 735 | - * @return string |
|
| 736 | - */ |
|
| 737 | - public function get_admin_edit_url() |
|
| 738 | - { |
|
| 739 | - return EEH_URL::add_query_args_and_nonce(array( |
|
| 740 | - 'page' => 'espresso_registrations', |
|
| 741 | - 'action' => 'view_registration', |
|
| 742 | - '_REG_ID' => $this->ID(), |
|
| 743 | - ), admin_url('admin.php')); |
|
| 744 | - } |
|
| 745 | - |
|
| 746 | - |
|
| 747 | - /** |
|
| 748 | - * is_primary_registrant? |
|
| 749 | - */ |
|
| 750 | - public function is_primary_registrant() |
|
| 751 | - { |
|
| 752 | - return $this->get('REG_count') == 1 ? true : false; |
|
| 753 | - } |
|
| 754 | - |
|
| 755 | - |
|
| 756 | - /** |
|
| 757 | - * This returns the primary registration object for this registration group (which may be this object). |
|
| 758 | - * |
|
| 759 | - * @return EE_Registration |
|
| 760 | - */ |
|
| 761 | - public function get_primary_registration() |
|
| 762 | - { |
|
| 763 | - if ($this->is_primary_registrant()) { |
|
| 764 | - return $this; |
|
| 765 | - } |
|
| 766 | - |
|
| 767 | - //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
|
| 768 | - $primary_registrant = EEM_Registration::instance()->get_one(array( |
|
| 769 | - array( |
|
| 770 | - 'TXN_ID' => $this->transaction_ID(), |
|
| 771 | - 'REG_count' => 1, |
|
| 772 | - ), |
|
| 773 | - )); |
|
| 774 | - return $primary_registrant; |
|
| 775 | - } |
|
| 776 | - |
|
| 777 | - |
|
| 778 | - /** |
|
| 779 | - * get Attendee Number |
|
| 780 | - * |
|
| 781 | - * @access public |
|
| 782 | - */ |
|
| 783 | - public function count() |
|
| 784 | - { |
|
| 785 | - return $this->get('REG_count'); |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - |
|
| 789 | - /** |
|
| 790 | - * get Group Size |
|
| 791 | - */ |
|
| 792 | - public function group_size() |
|
| 793 | - { |
|
| 794 | - return $this->get('REG_group_size'); |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - |
|
| 798 | - /** |
|
| 799 | - * get Registration Date |
|
| 800 | - */ |
|
| 801 | - public function date() |
|
| 802 | - { |
|
| 803 | - return $this->get('REG_date'); |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - |
|
| 807 | - /** |
|
| 808 | - * gets a pretty date |
|
| 809 | - * |
|
| 810 | - * @param string $date_format |
|
| 811 | - * @param string $time_format |
|
| 812 | - * @return string |
|
| 813 | - */ |
|
| 814 | - public function pretty_date($date_format = null, $time_format = null) |
|
| 815 | - { |
|
| 816 | - return $this->get_datetime('REG_date', $date_format, $time_format); |
|
| 817 | - } |
|
| 818 | - |
|
| 819 | - |
|
| 820 | - /** |
|
| 821 | - * final_price |
|
| 822 | - * the registration's share of the transaction total, so that the |
|
| 823 | - * sum of all the transaction's REG_final_prices equal the transaction's total |
|
| 824 | - * |
|
| 825 | - * @return float |
|
| 826 | - */ |
|
| 827 | - public function final_price() |
|
| 828 | - { |
|
| 829 | - return $this->get('REG_final_price'); |
|
| 830 | - } |
|
| 831 | - |
|
| 832 | - |
|
| 833 | - /** |
|
| 834 | - * pretty_final_price |
|
| 835 | - * final price as formatted string, with correct decimal places and currency symbol |
|
| 836 | - * |
|
| 837 | - * @return string |
|
| 838 | - */ |
|
| 839 | - public function pretty_final_price() |
|
| 840 | - { |
|
| 841 | - return $this->get_pretty('REG_final_price'); |
|
| 842 | - } |
|
| 843 | - |
|
| 844 | - |
|
| 845 | - /** |
|
| 846 | - * get paid (yeah) |
|
| 847 | - * |
|
| 848 | - * @return float |
|
| 849 | - */ |
|
| 850 | - public function paid() |
|
| 851 | - { |
|
| 852 | - return $this->get('REG_paid'); |
|
| 853 | - } |
|
| 854 | - |
|
| 855 | - |
|
| 856 | - /** |
|
| 857 | - * pretty_paid |
|
| 858 | - * |
|
| 859 | - * @return float |
|
| 860 | - */ |
|
| 861 | - public function pretty_paid() |
|
| 862 | - { |
|
| 863 | - return $this->get_pretty('REG_paid'); |
|
| 864 | - } |
|
| 865 | - |
|
| 866 | - |
|
| 867 | - /** |
|
| 868 | - * owes_monies_and_can_pay |
|
| 869 | - * whether or not this registration has monies owing and it's' status allows payment |
|
| 870 | - * |
|
| 871 | - * @param array $requires_payment |
|
| 872 | - * @return bool |
|
| 873 | - */ |
|
| 874 | - public function owes_monies_and_can_pay($requires_payment = array()) |
|
| 875 | - { |
|
| 876 | - // these reg statuses require payment (if event is not free) |
|
| 877 | - $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
| 878 | - if ( |
|
| 879 | - in_array($this->status_ID(), $requires_payment) && |
|
| 880 | - $this->final_price() != 0 && |
|
| 881 | - $this->final_price() != $this->paid() |
|
| 882 | - ) { |
|
| 883 | - return true; |
|
| 884 | - } else { |
|
| 885 | - return false; |
|
| 886 | - } |
|
| 887 | - } |
|
| 888 | - |
|
| 889 | - |
|
| 890 | - /** |
|
| 891 | - * Prints out the return value of $this->pretty_status() |
|
| 892 | - * |
|
| 893 | - * @param bool $show_icons |
|
| 894 | - * @return void |
|
| 895 | - */ |
|
| 896 | - public function e_pretty_status($show_icons = false) |
|
| 897 | - { |
|
| 898 | - echo $this->pretty_status($show_icons); |
|
| 899 | - } |
|
| 900 | - |
|
| 901 | - |
|
| 902 | - /** |
|
| 903 | - * Returns a nice version of the status for displaying to customers |
|
| 904 | - * |
|
| 905 | - * @param bool $show_icons |
|
| 906 | - * @return string |
|
| 907 | - */ |
|
| 908 | - public function pretty_status($show_icons = false) |
|
| 909 | - { |
|
| 910 | - $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), |
|
| 911 | - false, 'sentence'); |
|
| 912 | - $icon = ''; |
|
| 913 | - switch ($this->status_ID()) { |
|
| 914 | - case EEM_Registration::status_id_approved: |
|
| 915 | - $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
|
| 916 | - break; |
|
| 917 | - case EEM_Registration::status_id_pending_payment: |
|
| 918 | - $icon = $show_icons ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>' : ''; |
|
| 919 | - break; |
|
| 920 | - case EEM_Registration::status_id_not_approved: |
|
| 921 | - $icon = $show_icons ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>' : ''; |
|
| 922 | - break; |
|
| 923 | - case EEM_Registration::status_id_cancelled: |
|
| 924 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>' : ''; |
|
| 925 | - break; |
|
| 926 | - case EEM_Registration::status_id_incomplete: |
|
| 927 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>' : ''; |
|
| 928 | - break; |
|
| 929 | - case EEM_Registration::status_id_declined: |
|
| 930 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
|
| 931 | - break; |
|
| 932 | - case EEM_Registration::status_id_wait_list: |
|
| 933 | - $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
|
| 934 | - break; |
|
| 935 | - } |
|
| 936 | - return $icon . $status[$this->status_ID()]; |
|
| 937 | - } |
|
| 938 | - |
|
| 939 | - |
|
| 940 | - /** |
|
| 941 | - * get Attendee Is Going |
|
| 942 | - */ |
|
| 943 | - public function att_is_going() |
|
| 944 | - { |
|
| 945 | - return $this->get('REG_att_is_going'); |
|
| 946 | - } |
|
| 947 | - |
|
| 948 | - |
|
| 949 | - /** |
|
| 950 | - * Gets related answers |
|
| 951 | - * |
|
| 952 | - * @param array $query_params like EEM_Base::get_all |
|
| 953 | - * @return EE_Answer[] |
|
| 954 | - */ |
|
| 955 | - public function answers($query_params = null) |
|
| 956 | - { |
|
| 957 | - return $this->get_many_related('Answer', $query_params); |
|
| 958 | - } |
|
| 959 | - |
|
| 960 | - |
|
| 961 | - /** |
|
| 962 | - * Gets the registration's answer value to the specified question |
|
| 963 | - * (either the question's ID or a question object) |
|
| 964 | - * |
|
| 965 | - * @param EE_Question|int $question |
|
| 966 | - * @param bool $pretty_value |
|
| 967 | - * @return array|string if pretty_value= true, the result will always be a string |
|
| 968 | - * (because the answer might be an array of answer values, so passing pretty_value=true |
|
| 969 | - * will convert it into some kind of string) |
|
| 970 | - */ |
|
| 971 | - public function answer_value_to_question($question, $pretty_value = true) |
|
| 972 | - { |
|
| 973 | - $question_id = EEM_Question::instance()->ensure_is_ID($question); |
|
| 974 | - return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
| 975 | - } |
|
| 976 | - |
|
| 977 | - |
|
| 978 | - /** |
|
| 979 | - * question_groups |
|
| 980 | - * returns an array of EE_Question_Group objects for this registration |
|
| 981 | - * |
|
| 982 | - * @return EE_Question_Group[] |
|
| 983 | - */ |
|
| 984 | - public function question_groups() |
|
| 985 | - { |
|
| 986 | - $question_groups = array(); |
|
| 987 | - if ($this->event() instanceof EE_Event) { |
|
| 988 | - $question_groups = $this->event()->question_groups( |
|
| 989 | - array( |
|
| 990 | - array( |
|
| 991 | - 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
| 992 | - ), |
|
| 993 | - 'order_by' => array('QSG_order' => 'ASC'), |
|
| 994 | - ) |
|
| 995 | - ); |
|
| 996 | - } |
|
| 997 | - return $question_groups; |
|
| 998 | - } |
|
| 999 | - |
|
| 1000 | - |
|
| 1001 | - /** |
|
| 1002 | - * count_question_groups |
|
| 1003 | - * returns a count of the number of EE_Question_Group objects for this registration |
|
| 1004 | - * |
|
| 1005 | - * @return int |
|
| 1006 | - */ |
|
| 1007 | - public function count_question_groups() |
|
| 1008 | - { |
|
| 1009 | - $qg_count = 0; |
|
| 1010 | - if ($this->event() instanceof EE_Event) { |
|
| 1011 | - $qg_count = $this->event()->count_related( |
|
| 1012 | - 'Question_Group', |
|
| 1013 | - array( |
|
| 1014 | - array( |
|
| 1015 | - 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
| 1016 | - ), |
|
| 1017 | - ) |
|
| 1018 | - ); |
|
| 1019 | - } |
|
| 1020 | - return $qg_count; |
|
| 1021 | - } |
|
| 1022 | - |
|
| 1023 | - |
|
| 1024 | - /** |
|
| 1025 | - * Returns the registration date in the 'standard' string format |
|
| 1026 | - * (function may be improved in the future to allow for different formats and timezones) |
|
| 1027 | - * |
|
| 1028 | - * @return string |
|
| 1029 | - */ |
|
| 1030 | - public function reg_date() |
|
| 1031 | - { |
|
| 1032 | - return $this->get_datetime('REG_date'); |
|
| 1033 | - } |
|
| 1034 | - |
|
| 1035 | - |
|
| 1036 | - /** |
|
| 1037 | - * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
|
| 1038 | - * the ticket this registration purchased, or the datetime they have registered |
|
| 1039 | - * to attend) |
|
| 1040 | - * |
|
| 1041 | - * @return EE_Datetime_Ticket |
|
| 1042 | - */ |
|
| 1043 | - public function datetime_ticket() |
|
| 1044 | - { |
|
| 1045 | - return $this->get_first_related('Datetime_Ticket'); |
|
| 1046 | - } |
|
| 1047 | - |
|
| 1048 | - |
|
| 1049 | - /** |
|
| 1050 | - * Sets the registration's datetime_ticket. |
|
| 1051 | - * |
|
| 1052 | - * @param EE_Datetime_Ticket $datetime_ticket |
|
| 1053 | - * @return EE_Datetime_Ticket |
|
| 1054 | - */ |
|
| 1055 | - public function set_datetime_ticket($datetime_ticket) |
|
| 1056 | - { |
|
| 1057 | - return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
| 1058 | - } |
|
| 1059 | - |
|
| 1060 | - /** |
|
| 1061 | - * Gets deleted |
|
| 1062 | - * |
|
| 1063 | - * @return boolean |
|
| 1064 | - */ |
|
| 1065 | - public function deleted() |
|
| 1066 | - { |
|
| 1067 | - return $this->get('REG_deleted'); |
|
| 1068 | - } |
|
| 1069 | - |
|
| 1070 | - /** |
|
| 1071 | - * Sets deleted |
|
| 1072 | - * |
|
| 1073 | - * @param boolean $deleted |
|
| 1074 | - * @return boolean |
|
| 1075 | - */ |
|
| 1076 | - public function set_deleted($deleted) |
|
| 1077 | - { |
|
| 1078 | - if ($deleted) { |
|
| 1079 | - $this->delete(); |
|
| 1080 | - } else { |
|
| 1081 | - $this->restore(); |
|
| 1082 | - } |
|
| 1083 | - } |
|
| 1084 | - |
|
| 1085 | - |
|
| 1086 | - /** |
|
| 1087 | - * Get the status object of this object |
|
| 1088 | - * |
|
| 1089 | - * @return EE_Status |
|
| 1090 | - */ |
|
| 1091 | - public function status_obj() |
|
| 1092 | - { |
|
| 1093 | - return $this->get_first_related('Status'); |
|
| 1094 | - } |
|
| 1095 | - |
|
| 1096 | - |
|
| 1097 | - /** |
|
| 1098 | - * Returns the number of times this registration has checked into any of the datetimes |
|
| 1099 | - * its available for |
|
| 1100 | - * |
|
| 1101 | - * @return int |
|
| 1102 | - */ |
|
| 1103 | - public function count_checkins() |
|
| 1104 | - { |
|
| 1105 | - return $this->get_model()->count_related($this, 'Checkin'); |
|
| 1106 | - } |
|
| 1107 | - |
|
| 1108 | - |
|
| 1109 | - /** |
|
| 1110 | - * Returns the number of current Check-ins this registration is checked into for any of the datetimes the |
|
| 1111 | - * registration is for. Note, this is ONLY checked in (does not include checkedout) |
|
| 1112 | - * |
|
| 1113 | - * @return int |
|
| 1114 | - */ |
|
| 1115 | - public function count_checkins_not_checkedout() |
|
| 1116 | - { |
|
| 1117 | - return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
| 1118 | - } |
|
| 1119 | - |
|
| 1120 | - |
|
| 1121 | - /** |
|
| 1122 | - * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
|
| 1123 | - * |
|
| 1124 | - * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
| 1125 | - * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
|
| 1126 | - * consider registration status as well as datetime access. |
|
| 1127 | - * @return bool |
|
| 1128 | - */ |
|
| 1129 | - public function can_checkin($DTT_OR_ID, $check_approved = true) |
|
| 1130 | - { |
|
| 1131 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
| 1132 | - |
|
| 1133 | - //first check registration status |
|
| 1134 | - if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
| 1135 | - return false; |
|
| 1136 | - } |
|
| 1137 | - //is there a datetime ticket that matches this dtt_ID? |
|
| 1138 | - if (! (EEM_Datetime_Ticket::instance()->exists(array( |
|
| 1139 | - array( |
|
| 1140 | - 'TKT_ID' => $this->get('TKT_ID'), |
|
| 1141 | - 'DTT_ID' => $DTT_ID, |
|
| 1142 | - ), |
|
| 1143 | - ))) |
|
| 1144 | - ) { |
|
| 1145 | - return false; |
|
| 1146 | - } |
|
| 1147 | - |
|
| 1148 | - //final check is against TKT_uses |
|
| 1149 | - return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
| 1150 | - } |
|
| 1151 | - |
|
| 1152 | - |
|
| 1153 | - /** |
|
| 1154 | - * This method verifies whether the user can checkin for the given datetime considering the max uses value set on |
|
| 1155 | - * the ticket. To do this, a query is done to get the count of the datetime records already checked into. If the |
|
| 1156 | - * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses, |
|
| 1157 | - * then return false. Otherwise return true. |
|
| 1158 | - * |
|
| 1159 | - * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
| 1160 | - * @return bool true means can checkin. false means cannot checkin. |
|
| 1161 | - */ |
|
| 1162 | - public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) |
|
| 1163 | - { |
|
| 1164 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
| 1165 | - |
|
| 1166 | - if (! $DTT_ID) { |
|
| 1167 | - return false; |
|
| 1168 | - } |
|
| 1169 | - |
|
| 1170 | - $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF; |
|
| 1171 | - |
|
| 1172 | - // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
|
| 1173 | - // or not. |
|
| 1174 | - if (! $max_uses || $max_uses === EE_INF) { |
|
| 1175 | - return true; |
|
| 1176 | - } |
|
| 1177 | - |
|
| 1178 | - //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
|
| 1179 | - //go ahead and toggle. |
|
| 1180 | - if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
| 1181 | - return true; |
|
| 1182 | - } |
|
| 1183 | - |
|
| 1184 | - //made it here so the last check is whether the number of checkins per unique datetime on this registration |
|
| 1185 | - //disallows further check-ins. |
|
| 1186 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array( |
|
| 1187 | - array( |
|
| 1188 | - 'REG_ID' => $this->ID(), |
|
| 1189 | - 'CHK_in' => true, |
|
| 1190 | - ), |
|
| 1191 | - ), 'DTT_ID', true); |
|
| 1192 | - // checkins have already reached their max number of uses |
|
| 1193 | - // so registrant can NOT checkin |
|
| 1194 | - if ($count_unique_dtt_checkins >= $max_uses) { |
|
| 1195 | - EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', |
|
| 1196 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1197 | - return false; |
|
| 1198 | - } |
|
| 1199 | - return true; |
|
| 1200 | - } |
|
| 1201 | - |
|
| 1202 | - |
|
| 1203 | - /** |
|
| 1204 | - * toggle Check-in status for this registration |
|
| 1205 | - * Check-ins are toggled in the following order: |
|
| 1206 | - * never checked in -> checked in |
|
| 1207 | - * checked in -> checked out |
|
| 1208 | - * checked out -> checked in |
|
| 1209 | - * |
|
| 1210 | - * @param int $DTT_ID include specific datetime to toggle Check-in for. |
|
| 1211 | - * If not included or null, then it is assumed latest datetime is being toggled. |
|
| 1212 | - * @param bool $verify If true then can_checkin() is used to verify whether the person |
|
| 1213 | - * can be checked in or not. Otherwise this forces change in checkin status. |
|
| 1214 | - * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
|
| 1215 | - * @throws EE_Error |
|
| 1216 | - */ |
|
| 1217 | - public function toggle_checkin_status($DTT_ID = null, $verify = false) |
|
| 1218 | - { |
|
| 1219 | - if (empty($DTT_ID)) { |
|
| 1220 | - $datetime = $this->get_latest_related_datetime(); |
|
| 1221 | - $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
| 1222 | - // verify the registration can checkin for the given DTT_ID |
|
| 1223 | - } elseif (! $this->can_checkin($DTT_ID, $verify)) { |
|
| 1224 | - EE_Error::add_error( |
|
| 1225 | - sprintf( |
|
| 1226 | - __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', |
|
| 1227 | - 'event_espresso'), |
|
| 1228 | - $this->ID(), |
|
| 1229 | - $DTT_ID |
|
| 1230 | - ), |
|
| 1231 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1232 | - ); |
|
| 1233 | - return false; |
|
| 1234 | - } |
|
| 1235 | - $status_paths = array( |
|
| 1236 | - EE_Registration::checkin_status_never => EE_Registration::checkin_status_in, |
|
| 1237 | - EE_Registration::checkin_status_in => EE_Registration::checkin_status_out, |
|
| 1238 | - EE_Registration::checkin_status_out => EE_Registration::checkin_status_in, |
|
| 1239 | - ); |
|
| 1240 | - //start by getting the current status so we know what status we'll be changing to. |
|
| 1241 | - $cur_status = $this->check_in_status_for_datetime($DTT_ID, null); |
|
| 1242 | - $status_to = $status_paths[$cur_status]; |
|
| 1243 | - // database only records true for checked IN or false for checked OUT |
|
| 1244 | - // no record ( null ) means checked in NEVER, but we obviously don't save that |
|
| 1245 | - $new_status = $status_to === EE_Registration::checkin_status_in ? true : false; |
|
| 1246 | - // add relation - note Check-ins are always creating new rows |
|
| 1247 | - // because we are keeping track of Check-ins over time. |
|
| 1248 | - // Eventually we'll probably want to show a list table |
|
| 1249 | - // for the individual Check-ins so that they can be managed. |
|
| 1250 | - $checkin = EE_Checkin::new_instance(array( |
|
| 1251 | - 'REG_ID' => $this->ID(), |
|
| 1252 | - 'DTT_ID' => $DTT_ID, |
|
| 1253 | - 'CHK_in' => $new_status, |
|
| 1254 | - )); |
|
| 1255 | - // if the record could not be saved then return false |
|
| 1256 | - if ($checkin->save() === 0) { |
|
| 1257 | - if (WP_DEBUG) { |
|
| 1258 | - global $wpdb; |
|
| 1259 | - $error = sprintf( |
|
| 1260 | - __('Registration check in update failed because of the following database error: %1$s%2$s', |
|
| 1261 | - 'event_espresso'), |
|
| 1262 | - '<br />', |
|
| 1263 | - $wpdb->last_error |
|
| 1264 | - ); |
|
| 1265 | - } else { |
|
| 1266 | - $error = __('Registration check in update failed because of an unknown database error', |
|
| 1267 | - 'event_espresso'); |
|
| 1268 | - } |
|
| 1269 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
| 1270 | - return false; |
|
| 1271 | - } |
|
| 1272 | - return $status_to; |
|
| 1273 | - } |
|
| 1274 | - |
|
| 1275 | - |
|
| 1276 | - /** |
|
| 1277 | - * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
|
| 1278 | - * "Latest" is defined by the `DTT_EVT_start` column. |
|
| 1279 | - * |
|
| 1280 | - * @return EE_Datetime|null |
|
| 1281 | - * @throws \EE_Error |
|
| 1282 | - */ |
|
| 1283 | - public function get_latest_related_datetime() |
|
| 1284 | - { |
|
| 1285 | - return EEM_Datetime::instance()->get_one( |
|
| 1286 | - array( |
|
| 1287 | - array( |
|
| 1288 | - 'Ticket.Registration.REG_ID' => $this->ID(), |
|
| 1289 | - ), |
|
| 1290 | - 'order_by' => array('DTT_EVT_start' => 'DESC'), |
|
| 1291 | - ) |
|
| 1292 | - ); |
|
| 1293 | - } |
|
| 1294 | - |
|
| 1295 | - |
|
| 1296 | - /** |
|
| 1297 | - * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
|
| 1298 | - * "Earliest" is defined by the `DTT_EVT_start` column. |
|
| 1299 | - * |
|
| 1300 | - * @throws \EE_Error |
|
| 1301 | - */ |
|
| 1302 | - public function get_earliest_related_datetime() |
|
| 1303 | - { |
|
| 1304 | - return EEM_Datetime::instance()->get_one( |
|
| 1305 | - array( |
|
| 1306 | - array( |
|
| 1307 | - 'Ticket.Registration.REG_ID' => $this->ID(), |
|
| 1308 | - ), |
|
| 1309 | - 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
| 1310 | - ) |
|
| 1311 | - ); |
|
| 1312 | - } |
|
| 1313 | - |
|
| 1314 | - |
|
| 1315 | - /** |
|
| 1316 | - * This method simply returns the check-in status for this registration and the given datetime. |
|
| 1317 | - * If neither the datetime nor the checkin values are provided as arguments, |
|
| 1318 | - * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
|
| 1319 | - * |
|
| 1320 | - * @param int $DTT_ID The ID of the datetime we're checking against |
|
| 1321 | - * (if empty we'll get the primary datetime for |
|
| 1322 | - * this registration (via event) and use it's ID); |
|
| 1323 | - * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
|
| 1324 | - * @return int Integer representing Check-in status. |
|
| 1325 | - * @throws \EE_Error |
|
| 1326 | - */ |
|
| 1327 | - public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) |
|
| 1328 | - { |
|
| 1329 | - $checkin_query_params = array( |
|
| 1330 | - 'order_by' => array('CHK_timestamp' => 'DESC'), |
|
| 1331 | - ); |
|
| 1332 | - |
|
| 1333 | - if ($DTT_ID > 0) { |
|
| 1334 | - $checkin_query_params[0] = array('DTT_ID' => $DTT_ID); |
|
| 1335 | - } |
|
| 1336 | - |
|
| 1337 | - //get checkin object (if exists) |
|
| 1338 | - $checkin = $checkin instanceof EE_Checkin |
|
| 1339 | - ? $checkin |
|
| 1340 | - : $this->get_first_related('Checkin', $checkin_query_params); |
|
| 1341 | - if ($checkin instanceof EE_Checkin) { |
|
| 1342 | - if ($checkin->get('CHK_in')) { |
|
| 1343 | - return EE_Registration::checkin_status_in; //checked in |
|
| 1344 | - } |
|
| 1345 | - return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
|
| 1346 | - } |
|
| 1347 | - return EE_Registration::checkin_status_never; //never been checked in |
|
| 1348 | - } |
|
| 1349 | - |
|
| 1350 | - |
|
| 1351 | - /** |
|
| 1352 | - * This method returns a localized message for the toggled Check-in message. |
|
| 1353 | - * |
|
| 1354 | - * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, |
|
| 1355 | - * then it is assumed Check-in for primary datetime was toggled. |
|
| 1356 | - * @param bool $error This just flags that you want an error message returned. This is put in so that the error |
|
| 1357 | - * message can be customized with the attendee name. |
|
| 1358 | - * @return string internationalized message |
|
| 1359 | - */ |
|
| 1360 | - public function get_checkin_msg($DTT_ID, $error = false) |
|
| 1361 | - { |
|
| 1362 | - //let's get the attendee first so we can include the name of the attendee |
|
| 1363 | - $attendee = $this->get_first_related('Attendee'); |
|
| 1364 | - if ($attendee instanceof EE_Attendee) { |
|
| 1365 | - if ($error) { |
|
| 1366 | - return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
| 1367 | - } |
|
| 1368 | - $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
| 1369 | - //what is the status message going to be? |
|
| 1370 | - switch ($cur_status) { |
|
| 1371 | - case EE_Registration::checkin_status_never : |
|
| 1372 | - return sprintf(__("%s has been removed from Check-in records", "event_espresso"), |
|
| 1373 | - $attendee->full_name()); |
|
| 1374 | - break; |
|
| 1375 | - case EE_Registration::checkin_status_in : |
|
| 1376 | - return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
| 1377 | - break; |
|
| 1378 | - case EE_Registration::checkin_status_out : |
|
| 1379 | - return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
| 1380 | - break; |
|
| 1381 | - } |
|
| 1382 | - } |
|
| 1383 | - return __("The check-in status could not be determined.", "event_espresso"); |
|
| 1384 | - } |
|
| 1385 | - |
|
| 1386 | - |
|
| 1387 | - /** |
|
| 1388 | - * Returns the related EE_Transaction to this registration |
|
| 1389 | - * |
|
| 1390 | - * @return EE_Transaction |
|
| 1391 | - */ |
|
| 1392 | - public function transaction() |
|
| 1393 | - { |
|
| 1394 | - $transaction = $this->get_first_related('Transaction'); |
|
| 1395 | - if (! $transaction instanceof \EE_Transaction) { |
|
| 1396 | - throw new EntityNotFoundException('Transaction ID', $this->transaction_ID()); |
|
| 1397 | - } |
|
| 1398 | - return $transaction; |
|
| 1399 | - } |
|
| 1400 | - |
|
| 1401 | - |
|
| 1402 | - /** |
|
| 1403 | - * get Registration Code |
|
| 1404 | - */ |
|
| 1405 | - public function reg_code() |
|
| 1406 | - { |
|
| 1407 | - return $this->get('REG_code'); |
|
| 1408 | - } |
|
| 1409 | - |
|
| 1410 | - |
|
| 1411 | - /** |
|
| 1412 | - * get Transaction ID |
|
| 1413 | - */ |
|
| 1414 | - public function transaction_ID() |
|
| 1415 | - { |
|
| 1416 | - return $this->get('TXN_ID'); |
|
| 1417 | - } |
|
| 1418 | - |
|
| 1419 | - |
|
| 1420 | - /** |
|
| 1421 | - * @return int |
|
| 1422 | - */ |
|
| 1423 | - public function ticket_ID() |
|
| 1424 | - { |
|
| 1425 | - return $this->get('TKT_ID'); |
|
| 1426 | - } |
|
| 1427 | - |
|
| 1428 | - |
|
| 1429 | - /** |
|
| 1430 | - * Set Registration Code |
|
| 1431 | - * |
|
| 1432 | - * @access public |
|
| 1433 | - * @param string $REG_code Registration Code |
|
| 1434 | - * @param boolean $use_default |
|
| 1435 | - */ |
|
| 1436 | - public function set_reg_code($REG_code, $use_default = false) |
|
| 1437 | - { |
|
| 1438 | - if (empty($REG_code)) { |
|
| 1439 | - EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1440 | - return; |
|
| 1441 | - } |
|
| 1442 | - if (! $this->reg_code()) { |
|
| 1443 | - parent::set('REG_code', $REG_code, $use_default); |
|
| 1444 | - } else { |
|
| 1445 | - EE_Error::doing_it_wrong( |
|
| 1446 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 1447 | - __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
| 1448 | - '4.6.0' |
|
| 1449 | - ); |
|
| 1450 | - } |
|
| 1451 | - } |
|
| 1452 | - |
|
| 1453 | - |
|
| 1454 | - /** |
|
| 1455 | - * Returns all other registrations in the same group as this registrant who have the same ticket option. |
|
| 1456 | - * Note, if you want to just get all registrations in the same transaction (group), use: |
|
| 1457 | - * $registration->transaction()->registrations(); |
|
| 1458 | - * |
|
| 1459 | - * @since 4.5.0 |
|
| 1460 | - * @return EE_Registration[] or empty array if this isn't a group registration. |
|
| 1461 | - */ |
|
| 1462 | - public function get_all_other_registrations_in_group() |
|
| 1463 | - { |
|
| 1464 | - if ($this->group_size() < 2) { |
|
| 1465 | - return array(); |
|
| 1466 | - } |
|
| 1467 | - |
|
| 1468 | - $query[0] = array( |
|
| 1469 | - 'TXN_ID' => $this->transaction_ID(), |
|
| 1470 | - 'REG_ID' => array('!=', $this->ID()), |
|
| 1471 | - 'TKT_ID' => $this->ticket_ID(), |
|
| 1472 | - ); |
|
| 1473 | - |
|
| 1474 | - $registrations = $this->get_model()->get_all($query); |
|
| 1475 | - return $registrations; |
|
| 1476 | - } |
|
| 1477 | - |
|
| 1478 | - /** |
|
| 1479 | - * Return the link to the admin details for the object. |
|
| 1480 | - * |
|
| 1481 | - * @return string |
|
| 1482 | - */ |
|
| 1483 | - public function get_admin_details_link() |
|
| 1484 | - { |
|
| 1485 | - EE_Registry::instance()->load_helper('URL'); |
|
| 1486 | - return EEH_URL::add_query_args_and_nonce( |
|
| 1487 | - array( |
|
| 1488 | - 'page' => 'espresso_registrations', |
|
| 1489 | - 'action' => 'view_registration', |
|
| 1490 | - '_REG_ID' => $this->ID(), |
|
| 1491 | - ), |
|
| 1492 | - admin_url('admin.php') |
|
| 1493 | - ); |
|
| 1494 | - } |
|
| 1495 | - |
|
| 1496 | - /** |
|
| 1497 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 1498 | - * |
|
| 1499 | - * @return string |
|
| 1500 | - */ |
|
| 1501 | - public function get_admin_edit_link() |
|
| 1502 | - { |
|
| 1503 | - return $this->get_admin_details_link(); |
|
| 1504 | - } |
|
| 1505 | - |
|
| 1506 | - /** |
|
| 1507 | - * Returns the link to a settings page for the object. |
|
| 1508 | - * |
|
| 1509 | - * @return string |
|
| 1510 | - */ |
|
| 1511 | - public function get_admin_settings_link() |
|
| 1512 | - { |
|
| 1513 | - return $this->get_admin_details_link(); |
|
| 1514 | - } |
|
| 1515 | - |
|
| 1516 | - /** |
|
| 1517 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 1518 | - * |
|
| 1519 | - * @return string |
|
| 1520 | - */ |
|
| 1521 | - public function get_admin_overview_link() |
|
| 1522 | - { |
|
| 1523 | - EE_Registry::instance()->load_helper('URL'); |
|
| 1524 | - return EEH_URL::add_query_args_and_nonce( |
|
| 1525 | - array( |
|
| 1526 | - 'page' => 'espresso_registrations', |
|
| 1527 | - ), |
|
| 1528 | - admin_url('admin.php') |
|
| 1529 | - ); |
|
| 1530 | - } |
|
| 1531 | - |
|
| 1532 | - |
|
| 1533 | - /** |
|
| 1534 | - * @param array $query_params |
|
| 1535 | - * @return \EE_Registration[] |
|
| 1536 | - * @throws \EE_Error |
|
| 1537 | - */ |
|
| 1538 | - public function payments($query_params = array()) |
|
| 1539 | - { |
|
| 1540 | - return $this->get_many_related('Payment', $query_params); |
|
| 1541 | - } |
|
| 1542 | - |
|
| 1543 | - |
|
| 1544 | - /** |
|
| 1545 | - * @param array $query_params |
|
| 1546 | - * @return \EE_Registration_Payment[] |
|
| 1547 | - * @throws \EE_Error |
|
| 1548 | - */ |
|
| 1549 | - public function registration_payments($query_params = array()) |
|
| 1550 | - { |
|
| 1551 | - return $this->get_many_related('Registration_Payment', $query_params); |
|
| 1552 | - } |
|
| 1553 | - |
|
| 1554 | - |
|
| 1555 | - /** |
|
| 1556 | - * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
|
| 1557 | - * Note: if there are no payments on the registration there will be no payment method returned. |
|
| 1558 | - * |
|
| 1559 | - * @return EE_Payment_Method|null |
|
| 1560 | - */ |
|
| 1561 | - public function payment_method() |
|
| 1562 | - { |
|
| 1563 | - return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
| 1564 | - } |
|
| 1565 | - |
|
| 1566 | - |
|
| 1567 | - /** |
|
| 1568 | - * @return \EE_Line_Item |
|
| 1569 | - * @throws EntityNotFoundException |
|
| 1570 | - * @throws \EE_Error |
|
| 1571 | - */ |
|
| 1572 | - public function ticket_line_item() |
|
| 1573 | - { |
|
| 1574 | - $ticket = $this->ticket(); |
|
| 1575 | - $transaction = $this->transaction(); |
|
| 1576 | - $line_item = null; |
|
| 1577 | - $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
| 1578 | - $transaction->total_line_item(), |
|
| 1579 | - 'Ticket', |
|
| 1580 | - array($ticket->ID()) |
|
| 1581 | - ); |
|
| 1582 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
| 1583 | - if ( |
|
| 1584 | - $ticket_line_item instanceof \EE_Line_Item |
|
| 1585 | - && $ticket_line_item->OBJ_type() === 'Ticket' |
|
| 1586 | - && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
| 1587 | - ) { |
|
| 1588 | - $line_item = $ticket_line_item; |
|
| 1589 | - break; |
|
| 1590 | - } |
|
| 1591 | - } |
|
| 1592 | - if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
| 1593 | - throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
| 1594 | - } |
|
| 1595 | - return $line_item; |
|
| 1596 | - } |
|
| 1597 | - |
|
| 1598 | - |
|
| 1599 | - /** |
|
| 1600 | - * Soft Deletes this model object. |
|
| 1601 | - * |
|
| 1602 | - * @return boolean | int |
|
| 1603 | - * @throws \RuntimeException |
|
| 1604 | - * @throws \EE_Error |
|
| 1605 | - */ |
|
| 1606 | - public function delete() |
|
| 1607 | - { |
|
| 1608 | - if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) { |
|
| 1609 | - $this->set_status(EEM_Registration::status_id_cancelled); |
|
| 1610 | - } |
|
| 1611 | - return parent::delete(); |
|
| 1612 | - } |
|
| 1613 | - |
|
| 1614 | - |
|
| 1615 | - /** |
|
| 1616 | - * Restores whatever the previous status was on a registration before it was trashed (if possible) |
|
| 1617 | - * |
|
| 1618 | - * @throws \EE_Error |
|
| 1619 | - * @throws \RuntimeException |
|
| 1620 | - */ |
|
| 1621 | - public function restore() |
|
| 1622 | - { |
|
| 1623 | - $previous_status = $this->get_extra_meta( |
|
| 1624 | - EE_Registration::PRE_TRASH_REG_STATUS_KEY, |
|
| 1625 | - true, |
|
| 1626 | - EEM_Registration::status_id_cancelled |
|
| 1627 | - ); |
|
| 1628 | - if ($previous_status) { |
|
| 1629 | - $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY); |
|
| 1630 | - $this->set_status($previous_status); |
|
| 1631 | - } |
|
| 1632 | - return parent::restore(); |
|
| 1633 | - } |
|
| 1634 | - |
|
| 1635 | - |
|
| 1636 | - |
|
| 1637 | - /*************************** DEPRECATED ***************************/ |
|
| 1638 | - |
|
| 1639 | - |
|
| 1640 | - /** |
|
| 1641 | - * @deprecated |
|
| 1642 | - * @since 4.7.0 |
|
| 1643 | - * @access public |
|
| 1644 | - */ |
|
| 1645 | - public function price_paid() |
|
| 1646 | - { |
|
| 1647 | - EE_Error::doing_it_wrong('EE_Registration::price_paid()', |
|
| 1648 | - __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), |
|
| 1649 | - '4.7.0'); |
|
| 1650 | - return $this->final_price(); |
|
| 1651 | - } |
|
| 1652 | - |
|
| 1653 | - |
|
| 1654 | - /** |
|
| 1655 | - * @deprecated |
|
| 1656 | - * @since 4.7.0 |
|
| 1657 | - * @access public |
|
| 1658 | - * @param float $REG_final_price |
|
| 1659 | - */ |
|
| 1660 | - public function set_price_paid($REG_final_price = 0.00) |
|
| 1661 | - { |
|
| 1662 | - EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', |
|
| 1663 | - __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), |
|
| 1664 | - '4.7.0'); |
|
| 1665 | - $this->set_final_price($REG_final_price); |
|
| 1666 | - } |
|
| 1667 | - |
|
| 1668 | - |
|
| 1669 | - /** |
|
| 1670 | - * @deprecated |
|
| 1671 | - * @since 4.7.0 |
|
| 1672 | - * @return string |
|
| 1673 | - */ |
|
| 1674 | - public function pretty_price_paid() |
|
| 1675 | - { |
|
| 1676 | - EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', |
|
| 1677 | - __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', |
|
| 1678 | - 'event_espresso'), '4.7.0'); |
|
| 1679 | - return $this->pretty_final_price(); |
|
| 1680 | - } |
|
| 1681 | - |
|
| 1682 | - |
|
| 1683 | - /** |
|
| 1684 | - * Gets the primary datetime related to this registration via the related Event to this registration |
|
| 1685 | - * |
|
| 1686 | - * @deprecated 4.9.17 |
|
| 1687 | - * @return EE_Datetime |
|
| 1688 | - */ |
|
| 1689 | - public function get_related_primary_datetime() |
|
| 1690 | - { |
|
| 1691 | - EE_Error::doing_it_wrong( |
|
| 1692 | - __METHOD__, |
|
| 1693 | - esc_html__( |
|
| 1694 | - 'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()', |
|
| 1695 | - 'event_espresso' |
|
| 1696 | - ), |
|
| 1697 | - '4.9.17', |
|
| 1698 | - '5.0.0' |
|
| 1699 | - ); |
|
| 1700 | - return $this->event()->primary_datetime(); |
|
| 1701 | - } |
|
| 18 | + /** |
|
| 19 | + * Used to reference when a registration has never been checked in. |
|
| 20 | + * |
|
| 21 | + * @type int |
|
| 22 | + */ |
|
| 23 | + const checkin_status_never = 2; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Used to reference when a registration has been checked in. |
|
| 27 | + * |
|
| 28 | + * @type int |
|
| 29 | + */ |
|
| 30 | + const checkin_status_in = 1; |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Used to reference when a registration has been checked out. |
|
| 35 | + * |
|
| 36 | + * @type int |
|
| 37 | + */ |
|
| 38 | + const checkin_status_out = 0; |
|
| 39 | + |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * extra meta key for tracking reg status os trashed registrations |
|
| 43 | + * |
|
| 44 | + * @type string |
|
| 45 | + */ |
|
| 46 | + const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * extra meta key for tracking if registration has reserved ticket |
|
| 51 | + * |
|
| 52 | + * @type string |
|
| 53 | + */ |
|
| 54 | + const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @param array $props_n_values incoming values |
|
| 59 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 60 | + * used.) |
|
| 61 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 62 | + * date_format and the second value is the time format |
|
| 63 | + * @return EE_Registration |
|
| 64 | + */ |
|
| 65 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 66 | + { |
|
| 67 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 68 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @param array $props_n_values incoming values from the database |
|
| 74 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 75 | + * the website will be used. |
|
| 76 | + * @return EE_Registration |
|
| 77 | + */ |
|
| 78 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 79 | + { |
|
| 80 | + return new self($props_n_values, true, $timezone); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Set Event ID |
|
| 86 | + * |
|
| 87 | + * @param int $EVT_ID Event ID |
|
| 88 | + */ |
|
| 89 | + public function set_event($EVT_ID = 0) |
|
| 90 | + { |
|
| 91 | + $this->set('EVT_ID', $EVT_ID); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can |
|
| 97 | + * be routed to internal methods |
|
| 98 | + * |
|
| 99 | + * @param string $field_name |
|
| 100 | + * @param mixed $field_value |
|
| 101 | + * @param bool $use_default |
|
| 102 | + * @throws \EE_Error |
|
| 103 | + * @throws \RuntimeException |
|
| 104 | + */ |
|
| 105 | + public function set($field_name, $field_value, $use_default = false) |
|
| 106 | + { |
|
| 107 | + switch ($field_name) { |
|
| 108 | + case 'REG_code' : |
|
| 109 | + if (! empty($field_value) && $this->reg_code() === null) { |
|
| 110 | + $this->set_reg_code($field_value, $use_default); |
|
| 111 | + } |
|
| 112 | + break; |
|
| 113 | + case 'STS_ID' : |
|
| 114 | + $this->set_status($field_value, $use_default); |
|
| 115 | + break; |
|
| 116 | + default : |
|
| 117 | + parent::set($field_name, $field_value, $use_default); |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Set Status ID |
|
| 124 | + * updates the registration status and ALSO... |
|
| 125 | + * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
|
| 126 | + * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
|
| 127 | + * |
|
| 128 | + * @param string $new_STS_ID |
|
| 129 | + * @param boolean $use_default |
|
| 130 | + * @return bool |
|
| 131 | + * @throws \RuntimeException |
|
| 132 | + * @throws \EE_Error |
|
| 133 | + */ |
|
| 134 | + public function set_status($new_STS_ID = null, $use_default = false) |
|
| 135 | + { |
|
| 136 | + // get current REG_Status |
|
| 137 | + $old_STS_ID = $this->status_ID(); |
|
| 138 | + // if status has changed |
|
| 139 | + if ( |
|
| 140 | + $old_STS_ID !== $new_STS_ID // and that status has actually changed |
|
| 141 | + && ! empty($old_STS_ID) // and that old status is actually set |
|
| 142 | + && ! empty($new_STS_ID) // as well as the new status |
|
| 143 | + && $this->ID() // ensure registration is in the db |
|
| 144 | + ) { |
|
| 145 | + // TO approved |
|
| 146 | + if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
| 147 | + // reserve a space by incrementing ticket and datetime sold values |
|
| 148 | + $this->_reserve_registration_space(); |
|
| 149 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
| 150 | + // OR FROM approved |
|
| 151 | + } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
| 152 | + // release a space by decrementing ticket and datetime sold values |
|
| 153 | + $this->_release_registration_space(); |
|
| 154 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
| 155 | + } |
|
| 156 | + // update status |
|
| 157 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
| 158 | + $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID); |
|
| 159 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
| 160 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 161 | + $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
| 162 | + $this->transaction()->update_status_based_on_total_paid(true); |
|
| 163 | + do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID); |
|
| 164 | + return true; |
|
| 165 | + } |
|
| 166 | + //even though the old value matches the new value, it's still good to |
|
| 167 | + //allow the parent set method to have a say |
|
| 168 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
| 169 | + return true; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * update REGs and TXN when cancelled or declined registrations involved |
|
| 175 | + * |
|
| 176 | + * @param string $new_STS_ID |
|
| 177 | + * @param string $old_STS_ID |
|
| 178 | + * @throws \EE_Error |
|
| 179 | + */ |
|
| 180 | + private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID) |
|
| 181 | + { |
|
| 182 | + // these reg statuses should not be considered in any calculations involving monies owing |
|
| 183 | + $closed_reg_statuses = EEM_Registration::closed_reg_statuses(); |
|
| 184 | + // true if registration has been cancelled or declined |
|
| 185 | + if ( |
|
| 186 | + in_array($new_STS_ID, $closed_reg_statuses, true) |
|
| 187 | + && ! in_array($old_STS_ID, $closed_reg_statuses, true) |
|
| 188 | + ) { |
|
| 189 | + /** @type EE_Registration_Processor $registration_processor */ |
|
| 190 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 191 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 192 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 193 | + // cancelled or declined registration |
|
| 194 | + $registration_processor->update_registration_after_being_canceled_or_declined( |
|
| 195 | + $this, |
|
| 196 | + $closed_reg_statuses |
|
| 197 | + ); |
|
| 198 | + $transaction_processor->update_transaction_after_canceled_or_declined_registration( |
|
| 199 | + $this, |
|
| 200 | + $closed_reg_statuses, |
|
| 201 | + false |
|
| 202 | + ); |
|
| 203 | + do_action('AHEE__EE_Registration__set_status__canceled_or_declined', $this, $old_STS_ID, $new_STS_ID); |
|
| 204 | + return; |
|
| 205 | + } |
|
| 206 | + // true if reinstating cancelled or declined registration |
|
| 207 | + if ( |
|
| 208 | + in_array($old_STS_ID, $closed_reg_statuses, true) |
|
| 209 | + && ! in_array($new_STS_ID, $closed_reg_statuses, true) |
|
| 210 | + ) { |
|
| 211 | + /** @type EE_Registration_Processor $registration_processor */ |
|
| 212 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 213 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 214 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 215 | + // reinstating cancelled or declined registration |
|
| 216 | + $registration_processor->update_canceled_or_declined_registration_after_being_reinstated( |
|
| 217 | + $this, |
|
| 218 | + $closed_reg_statuses |
|
| 219 | + ); |
|
| 220 | + $transaction_processor->update_transaction_after_reinstating_canceled_registration( |
|
| 221 | + $this, |
|
| 222 | + $closed_reg_statuses, |
|
| 223 | + false |
|
| 224 | + ); |
|
| 225 | + do_action('AHEE__EE_Registration__set_status__after_reinstated', $this, $old_STS_ID, $new_STS_ID); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * get Status ID |
|
| 232 | + */ |
|
| 233 | + public function status_ID() |
|
| 234 | + { |
|
| 235 | + return $this->get('STS_ID'); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * increments this registration's related ticket sold and corresponding datetime sold values |
|
| 241 | + * |
|
| 242 | + * @return void |
|
| 243 | + * @throws \EE_Error |
|
| 244 | + */ |
|
| 245 | + private function _reserve_registration_space() |
|
| 246 | + { |
|
| 247 | + // reserved ticket and datetime counts will be decremented as sold counts are incremented |
|
| 248 | + // so stop tracking that this reg has a ticket reserved |
|
| 249 | + $this->release_reserved_ticket(); |
|
| 250 | + $ticket = $this->ticket(); |
|
| 251 | + $ticket->increase_sold(); |
|
| 252 | + $ticket->save(); |
|
| 253 | + // possibly set event status to sold out |
|
| 254 | + $this->event()->perform_sold_out_status_check(); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Gets the ticket this registration is for |
|
| 260 | + * |
|
| 261 | + * @param boolean $include_archived whether to include archived tickets or not. |
|
| 262 | + * @return EE_Ticket|EE_Base_Class |
|
| 263 | + * @throws \EE_Error |
|
| 264 | + */ |
|
| 265 | + public function ticket($include_archived = true) |
|
| 266 | + { |
|
| 267 | + $query_params = array(); |
|
| 268 | + if ($include_archived) { |
|
| 269 | + $query_params['default_where_conditions'] = 'none'; |
|
| 270 | + } |
|
| 271 | + return $this->get_first_related('Ticket', $query_params); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * Gets the event this registration is for |
|
| 277 | + * |
|
| 278 | + * @return EE_Event |
|
| 279 | + */ |
|
| 280 | + public function event() |
|
| 281 | + { |
|
| 282 | + $event = $this->get_first_related('Event'); |
|
| 283 | + if (! $event instanceof \EE_Event) { |
|
| 284 | + throw new EntityNotFoundException('Event ID', $this->event_ID()); |
|
| 285 | + } |
|
| 286 | + return $event; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond |
|
| 292 | + * with the author of the event this registration is for. |
|
| 293 | + * |
|
| 294 | + * @since 4.5.0 |
|
| 295 | + * @return int |
|
| 296 | + */ |
|
| 297 | + public function wp_user() |
|
| 298 | + { |
|
| 299 | + $event = $this->event(); |
|
| 300 | + if ($event instanceof EE_Event) { |
|
| 301 | + return $event->wp_user(); |
|
| 302 | + } |
|
| 303 | + return 0; |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + |
|
| 307 | + /** |
|
| 308 | + * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
|
| 309 | + * |
|
| 310 | + * @return void |
|
| 311 | + * @throws \EE_Error |
|
| 312 | + */ |
|
| 313 | + private function _release_registration_space() |
|
| 314 | + { |
|
| 315 | + $ticket = $this->ticket(); |
|
| 316 | + $ticket->decrease_sold(); |
|
| 317 | + $ticket->save(); |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * tracks this registration's ticket reservation in extra meta |
|
| 323 | + * and can increment related ticket reserved and corresponding datetime reserved values |
|
| 324 | + * |
|
| 325 | + * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
|
| 326 | + * @return void |
|
| 327 | + * @throws \EE_Error |
|
| 328 | + */ |
|
| 329 | + public function reserve_ticket($update_ticket = false) |
|
| 330 | + { |
|
| 331 | + if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) { |
|
| 332 | + // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
| 333 | + // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
|
| 334 | + if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) { |
|
| 335 | + $ticket = $this->ticket(); |
|
| 336 | + $ticket->increase_reserved(); |
|
| 337 | + $ticket->save(); |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * stops tracking this registration's ticket reservation in extra meta |
|
| 345 | + * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
|
| 346 | + * |
|
| 347 | + * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
|
| 348 | + * @return void |
|
| 349 | + * @throws \EE_Error |
|
| 350 | + */ |
|
| 351 | + public function release_reserved_ticket($update_ticket = false) |
|
| 352 | + { |
|
| 353 | + if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) { |
|
| 354 | + // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
| 355 | + // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first |
|
| 356 | + if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) { |
|
| 357 | + $ticket = $this->ticket(); |
|
| 358 | + $ticket->decrease_reserved(); |
|
| 359 | + $ticket->save(); |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * Set Attendee ID |
|
| 367 | + * |
|
| 368 | + * @param int $ATT_ID Attendee ID |
|
| 369 | + */ |
|
| 370 | + public function set_attendee_id($ATT_ID = 0) |
|
| 371 | + { |
|
| 372 | + $this->set('ATT_ID', $ATT_ID); |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Set Transaction ID |
|
| 378 | + * |
|
| 379 | + * @param int $TXN_ID Transaction ID |
|
| 380 | + */ |
|
| 381 | + public function set_transaction_id($TXN_ID = 0) |
|
| 382 | + { |
|
| 383 | + $this->set('TXN_ID', $TXN_ID); |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + |
|
| 387 | + /** |
|
| 388 | + * Set Session |
|
| 389 | + * |
|
| 390 | + * @param string $REG_session PHP Session ID |
|
| 391 | + */ |
|
| 392 | + public function set_session($REG_session = '') |
|
| 393 | + { |
|
| 394 | + $this->set('REG_session', $REG_session); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * Set Registration URL Link |
|
| 400 | + * |
|
| 401 | + * @param string $REG_url_link Registration URL Link |
|
| 402 | + */ |
|
| 403 | + public function set_reg_url_link($REG_url_link = '') |
|
| 404 | + { |
|
| 405 | + $this->set('REG_url_link', $REG_url_link); |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + |
|
| 409 | + /** |
|
| 410 | + * Set Attendee Counter |
|
| 411 | + * |
|
| 412 | + * @param int $REG_count Primary Attendee |
|
| 413 | + */ |
|
| 414 | + public function set_count($REG_count = 1) |
|
| 415 | + { |
|
| 416 | + $this->set('REG_count', $REG_count); |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * Set Group Size |
|
| 422 | + * |
|
| 423 | + * @param boolean $REG_group_size Group Registration |
|
| 424 | + */ |
|
| 425 | + public function set_group_size($REG_group_size = false) |
|
| 426 | + { |
|
| 427 | + $this->set('REG_group_size', $REG_group_size); |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * is_not_approved - convenience method that returns TRUE if REG status ID == |
|
| 433 | + * EEM_Registration::status_id_not_approved |
|
| 434 | + * |
|
| 435 | + * @return boolean |
|
| 436 | + */ |
|
| 437 | + public function is_not_approved() |
|
| 438 | + { |
|
| 439 | + return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false; |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + |
|
| 443 | + /** |
|
| 444 | + * is_pending_payment - convenience method that returns TRUE if REG status ID == |
|
| 445 | + * EEM_Registration::status_id_pending_payment |
|
| 446 | + * |
|
| 447 | + * @return boolean |
|
| 448 | + */ |
|
| 449 | + public function is_pending_payment() |
|
| 450 | + { |
|
| 451 | + return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false; |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + |
|
| 455 | + /** |
|
| 456 | + * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
|
| 457 | + * |
|
| 458 | + * @return boolean |
|
| 459 | + */ |
|
| 460 | + public function is_approved() |
|
| 461 | + { |
|
| 462 | + return $this->status_ID() == EEM_Registration::status_id_approved ? true : false; |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + |
|
| 466 | + /** |
|
| 467 | + * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
|
| 468 | + * |
|
| 469 | + * @return boolean |
|
| 470 | + */ |
|
| 471 | + public function is_cancelled() |
|
| 472 | + { |
|
| 473 | + return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + |
|
| 477 | + /** |
|
| 478 | + * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
|
| 479 | + * |
|
| 480 | + * @return boolean |
|
| 481 | + */ |
|
| 482 | + public function is_declined() |
|
| 483 | + { |
|
| 484 | + return $this->status_ID() == EEM_Registration::status_id_declined ? true : false; |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + |
|
| 488 | + /** |
|
| 489 | + * is_incomplete - convenience method that returns TRUE if REG status ID == |
|
| 490 | + * EEM_Registration::status_id_incomplete |
|
| 491 | + * |
|
| 492 | + * @return boolean |
|
| 493 | + */ |
|
| 494 | + public function is_incomplete() |
|
| 495 | + { |
|
| 496 | + return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false; |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + |
|
| 500 | + /** |
|
| 501 | + * Set Registration Date |
|
| 502 | + * |
|
| 503 | + * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of |
|
| 504 | + * Date |
|
| 505 | + */ |
|
| 506 | + public function set_reg_date($REG_date = false) |
|
| 507 | + { |
|
| 508 | + $this->set('REG_date', $REG_date); |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * Set final price owing for this registration after all ticket/price modifications |
|
| 514 | + * |
|
| 515 | + * @access public |
|
| 516 | + * @param float $REG_final_price |
|
| 517 | + */ |
|
| 518 | + public function set_final_price($REG_final_price = 0.00) |
|
| 519 | + { |
|
| 520 | + $this->set('REG_final_price', $REG_final_price); |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + |
|
| 524 | + /** |
|
| 525 | + * Set amount paid towards this registration's final price |
|
| 526 | + * |
|
| 527 | + * @access public |
|
| 528 | + * @param float $REG_paid |
|
| 529 | + */ |
|
| 530 | + public function set_paid($REG_paid = 0.00) |
|
| 531 | + { |
|
| 532 | + $this->set('REG_paid', $REG_paid); |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + |
|
| 536 | + /** |
|
| 537 | + * Attendee Is Going |
|
| 538 | + * |
|
| 539 | + * @param boolean $REG_att_is_going Attendee Is Going |
|
| 540 | + */ |
|
| 541 | + public function set_att_is_going($REG_att_is_going = false) |
|
| 542 | + { |
|
| 543 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + |
|
| 547 | + /** |
|
| 548 | + * Gets the related attendee |
|
| 549 | + * |
|
| 550 | + * @return EE_Attendee |
|
| 551 | + */ |
|
| 552 | + public function attendee() |
|
| 553 | + { |
|
| 554 | + return $this->get_first_related('Attendee'); |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + |
|
| 558 | + /** |
|
| 559 | + * get Event ID |
|
| 560 | + */ |
|
| 561 | + public function event_ID() |
|
| 562 | + { |
|
| 563 | + return $this->get('EVT_ID'); |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * get Event ID |
|
| 569 | + */ |
|
| 570 | + public function event_name() |
|
| 571 | + { |
|
| 572 | + $event = $this->event_obj(); |
|
| 573 | + if ($event) { |
|
| 574 | + return $event->name(); |
|
| 575 | + } else { |
|
| 576 | + return null; |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + |
|
| 581 | + /** |
|
| 582 | + * Fetches the event this registration is for |
|
| 583 | + * |
|
| 584 | + * @return EE_Event |
|
| 585 | + */ |
|
| 586 | + public function event_obj() |
|
| 587 | + { |
|
| 588 | + return $this->get_first_related('Event'); |
|
| 589 | + } |
|
| 590 | + |
|
| 591 | + |
|
| 592 | + /** |
|
| 593 | + * get Attendee ID |
|
| 594 | + */ |
|
| 595 | + public function attendee_ID() |
|
| 596 | + { |
|
| 597 | + return $this->get('ATT_ID'); |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + |
|
| 601 | + /** |
|
| 602 | + * get PHP Session ID |
|
| 603 | + */ |
|
| 604 | + public function session_ID() |
|
| 605 | + { |
|
| 606 | + return $this->get('REG_session'); |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + |
|
| 610 | + /** |
|
| 611 | + * Gets the string which represents the URL trigger for the receipt template in the message template system. |
|
| 612 | + * |
|
| 613 | + * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
| 614 | + * @return string |
|
| 615 | + */ |
|
| 616 | + public function receipt_url($messenger = 'html') |
|
| 617 | + { |
|
| 618 | + |
|
| 619 | + /** |
|
| 620 | + * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
|
| 621 | + * |
|
| 622 | + * @since 4.5.0 |
|
| 623 | + */ |
|
| 624 | + $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
|
| 625 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
| 626 | + |
|
| 627 | + if ($has_custom) { |
|
| 628 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
| 629 | + } |
|
| 630 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + |
|
| 634 | + /** |
|
| 635 | + * Gets the string which represents the URL trigger for the invoice template in the message template system. |
|
| 636 | + * |
|
| 637 | + * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
| 638 | + * @return string |
|
| 639 | + */ |
|
| 640 | + public function invoice_url($messenger = 'html') |
|
| 641 | + { |
|
| 642 | + /** |
|
| 643 | + * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
|
| 644 | + * |
|
| 645 | + * @since 4.5.0 |
|
| 646 | + */ |
|
| 647 | + $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
|
| 648 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
| 649 | + |
|
| 650 | + if ($has_custom) { |
|
| 651 | + if ($messenger == 'html') { |
|
| 652 | + return $this->invoice_url('launch'); |
|
| 653 | + } |
|
| 654 | + $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
|
| 655 | + |
|
| 656 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
| 657 | + if ($messenger == 'html') { |
|
| 658 | + $query_args['html'] = true; |
|
| 659 | + } |
|
| 660 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
| 661 | + } |
|
| 662 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + |
|
| 666 | + /** |
|
| 667 | + * get Registration URL Link |
|
| 668 | + * |
|
| 669 | + * @access public |
|
| 670 | + * @return string |
|
| 671 | + * @throws \EE_Error |
|
| 672 | + */ |
|
| 673 | + public function reg_url_link() |
|
| 674 | + { |
|
| 675 | + return (string)$this->get('REG_url_link'); |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + |
|
| 679 | + /** |
|
| 680 | + * Echoes out invoice_url() |
|
| 681 | + * |
|
| 682 | + * @param string $type 'download','launch', or 'html' (default is 'launch') |
|
| 683 | + * @return void |
|
| 684 | + */ |
|
| 685 | + public function e_invoice_url($type = 'launch') |
|
| 686 | + { |
|
| 687 | + echo $this->invoice_url($type); |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + |
|
| 691 | + /** |
|
| 692 | + * Echoes out payment_overview_url |
|
| 693 | + */ |
|
| 694 | + public function e_payment_overview_url() |
|
| 695 | + { |
|
| 696 | + echo $this->payment_overview_url(); |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + |
|
| 700 | + /** |
|
| 701 | + * Gets the URL of the thank you page with this registration REG_url_link added as |
|
| 702 | + * a query parameter |
|
| 703 | + * |
|
| 704 | + * @return string |
|
| 705 | + */ |
|
| 706 | + public function payment_overview_url() |
|
| 707 | + { |
|
| 708 | + return add_query_arg(array( |
|
| 709 | + 'e_reg_url_link' => $this->reg_url_link(), |
|
| 710 | + 'step' => 'payment_options', |
|
| 711 | + 'revisit' => true, |
|
| 712 | + ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
| 713 | + } |
|
| 714 | + |
|
| 715 | + |
|
| 716 | + /** |
|
| 717 | + * Gets the URL of the thank you page with this registration REG_url_link added as |
|
| 718 | + * a query parameter |
|
| 719 | + * |
|
| 720 | + * @return string |
|
| 721 | + */ |
|
| 722 | + public function edit_attendee_information_url() |
|
| 723 | + { |
|
| 724 | + return add_query_arg(array( |
|
| 725 | + 'e_reg_url_link' => $this->reg_url_link(), |
|
| 726 | + 'step' => 'attendee_information', |
|
| 727 | + 'revisit' => true, |
|
| 728 | + ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
| 729 | + } |
|
| 730 | + |
|
| 731 | + |
|
| 732 | + /** |
|
| 733 | + * Simply generates and returns the appropriate admin_url link to edit this registration |
|
| 734 | + * |
|
| 735 | + * @return string |
|
| 736 | + */ |
|
| 737 | + public function get_admin_edit_url() |
|
| 738 | + { |
|
| 739 | + return EEH_URL::add_query_args_and_nonce(array( |
|
| 740 | + 'page' => 'espresso_registrations', |
|
| 741 | + 'action' => 'view_registration', |
|
| 742 | + '_REG_ID' => $this->ID(), |
|
| 743 | + ), admin_url('admin.php')); |
|
| 744 | + } |
|
| 745 | + |
|
| 746 | + |
|
| 747 | + /** |
|
| 748 | + * is_primary_registrant? |
|
| 749 | + */ |
|
| 750 | + public function is_primary_registrant() |
|
| 751 | + { |
|
| 752 | + return $this->get('REG_count') == 1 ? true : false; |
|
| 753 | + } |
|
| 754 | + |
|
| 755 | + |
|
| 756 | + /** |
|
| 757 | + * This returns the primary registration object for this registration group (which may be this object). |
|
| 758 | + * |
|
| 759 | + * @return EE_Registration |
|
| 760 | + */ |
|
| 761 | + public function get_primary_registration() |
|
| 762 | + { |
|
| 763 | + if ($this->is_primary_registrant()) { |
|
| 764 | + return $this; |
|
| 765 | + } |
|
| 766 | + |
|
| 767 | + //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
|
| 768 | + $primary_registrant = EEM_Registration::instance()->get_one(array( |
|
| 769 | + array( |
|
| 770 | + 'TXN_ID' => $this->transaction_ID(), |
|
| 771 | + 'REG_count' => 1, |
|
| 772 | + ), |
|
| 773 | + )); |
|
| 774 | + return $primary_registrant; |
|
| 775 | + } |
|
| 776 | + |
|
| 777 | + |
|
| 778 | + /** |
|
| 779 | + * get Attendee Number |
|
| 780 | + * |
|
| 781 | + * @access public |
|
| 782 | + */ |
|
| 783 | + public function count() |
|
| 784 | + { |
|
| 785 | + return $this->get('REG_count'); |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + |
|
| 789 | + /** |
|
| 790 | + * get Group Size |
|
| 791 | + */ |
|
| 792 | + public function group_size() |
|
| 793 | + { |
|
| 794 | + return $this->get('REG_group_size'); |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + |
|
| 798 | + /** |
|
| 799 | + * get Registration Date |
|
| 800 | + */ |
|
| 801 | + public function date() |
|
| 802 | + { |
|
| 803 | + return $this->get('REG_date'); |
|
| 804 | + } |
|
| 805 | + |
|
| 806 | + |
|
| 807 | + /** |
|
| 808 | + * gets a pretty date |
|
| 809 | + * |
|
| 810 | + * @param string $date_format |
|
| 811 | + * @param string $time_format |
|
| 812 | + * @return string |
|
| 813 | + */ |
|
| 814 | + public function pretty_date($date_format = null, $time_format = null) |
|
| 815 | + { |
|
| 816 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
| 817 | + } |
|
| 818 | + |
|
| 819 | + |
|
| 820 | + /** |
|
| 821 | + * final_price |
|
| 822 | + * the registration's share of the transaction total, so that the |
|
| 823 | + * sum of all the transaction's REG_final_prices equal the transaction's total |
|
| 824 | + * |
|
| 825 | + * @return float |
|
| 826 | + */ |
|
| 827 | + public function final_price() |
|
| 828 | + { |
|
| 829 | + return $this->get('REG_final_price'); |
|
| 830 | + } |
|
| 831 | + |
|
| 832 | + |
|
| 833 | + /** |
|
| 834 | + * pretty_final_price |
|
| 835 | + * final price as formatted string, with correct decimal places and currency symbol |
|
| 836 | + * |
|
| 837 | + * @return string |
|
| 838 | + */ |
|
| 839 | + public function pretty_final_price() |
|
| 840 | + { |
|
| 841 | + return $this->get_pretty('REG_final_price'); |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + |
|
| 845 | + /** |
|
| 846 | + * get paid (yeah) |
|
| 847 | + * |
|
| 848 | + * @return float |
|
| 849 | + */ |
|
| 850 | + public function paid() |
|
| 851 | + { |
|
| 852 | + return $this->get('REG_paid'); |
|
| 853 | + } |
|
| 854 | + |
|
| 855 | + |
|
| 856 | + /** |
|
| 857 | + * pretty_paid |
|
| 858 | + * |
|
| 859 | + * @return float |
|
| 860 | + */ |
|
| 861 | + public function pretty_paid() |
|
| 862 | + { |
|
| 863 | + return $this->get_pretty('REG_paid'); |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + |
|
| 867 | + /** |
|
| 868 | + * owes_monies_and_can_pay |
|
| 869 | + * whether or not this registration has monies owing and it's' status allows payment |
|
| 870 | + * |
|
| 871 | + * @param array $requires_payment |
|
| 872 | + * @return bool |
|
| 873 | + */ |
|
| 874 | + public function owes_monies_and_can_pay($requires_payment = array()) |
|
| 875 | + { |
|
| 876 | + // these reg statuses require payment (if event is not free) |
|
| 877 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
| 878 | + if ( |
|
| 879 | + in_array($this->status_ID(), $requires_payment) && |
|
| 880 | + $this->final_price() != 0 && |
|
| 881 | + $this->final_price() != $this->paid() |
|
| 882 | + ) { |
|
| 883 | + return true; |
|
| 884 | + } else { |
|
| 885 | + return false; |
|
| 886 | + } |
|
| 887 | + } |
|
| 888 | + |
|
| 889 | + |
|
| 890 | + /** |
|
| 891 | + * Prints out the return value of $this->pretty_status() |
|
| 892 | + * |
|
| 893 | + * @param bool $show_icons |
|
| 894 | + * @return void |
|
| 895 | + */ |
|
| 896 | + public function e_pretty_status($show_icons = false) |
|
| 897 | + { |
|
| 898 | + echo $this->pretty_status($show_icons); |
|
| 899 | + } |
|
| 900 | + |
|
| 901 | + |
|
| 902 | + /** |
|
| 903 | + * Returns a nice version of the status for displaying to customers |
|
| 904 | + * |
|
| 905 | + * @param bool $show_icons |
|
| 906 | + * @return string |
|
| 907 | + */ |
|
| 908 | + public function pretty_status($show_icons = false) |
|
| 909 | + { |
|
| 910 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), |
|
| 911 | + false, 'sentence'); |
|
| 912 | + $icon = ''; |
|
| 913 | + switch ($this->status_ID()) { |
|
| 914 | + case EEM_Registration::status_id_approved: |
|
| 915 | + $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
|
| 916 | + break; |
|
| 917 | + case EEM_Registration::status_id_pending_payment: |
|
| 918 | + $icon = $show_icons ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>' : ''; |
|
| 919 | + break; |
|
| 920 | + case EEM_Registration::status_id_not_approved: |
|
| 921 | + $icon = $show_icons ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>' : ''; |
|
| 922 | + break; |
|
| 923 | + case EEM_Registration::status_id_cancelled: |
|
| 924 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>' : ''; |
|
| 925 | + break; |
|
| 926 | + case EEM_Registration::status_id_incomplete: |
|
| 927 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>' : ''; |
|
| 928 | + break; |
|
| 929 | + case EEM_Registration::status_id_declined: |
|
| 930 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
|
| 931 | + break; |
|
| 932 | + case EEM_Registration::status_id_wait_list: |
|
| 933 | + $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
|
| 934 | + break; |
|
| 935 | + } |
|
| 936 | + return $icon . $status[$this->status_ID()]; |
|
| 937 | + } |
|
| 938 | + |
|
| 939 | + |
|
| 940 | + /** |
|
| 941 | + * get Attendee Is Going |
|
| 942 | + */ |
|
| 943 | + public function att_is_going() |
|
| 944 | + { |
|
| 945 | + return $this->get('REG_att_is_going'); |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + |
|
| 949 | + /** |
|
| 950 | + * Gets related answers |
|
| 951 | + * |
|
| 952 | + * @param array $query_params like EEM_Base::get_all |
|
| 953 | + * @return EE_Answer[] |
|
| 954 | + */ |
|
| 955 | + public function answers($query_params = null) |
|
| 956 | + { |
|
| 957 | + return $this->get_many_related('Answer', $query_params); |
|
| 958 | + } |
|
| 959 | + |
|
| 960 | + |
|
| 961 | + /** |
|
| 962 | + * Gets the registration's answer value to the specified question |
|
| 963 | + * (either the question's ID or a question object) |
|
| 964 | + * |
|
| 965 | + * @param EE_Question|int $question |
|
| 966 | + * @param bool $pretty_value |
|
| 967 | + * @return array|string if pretty_value= true, the result will always be a string |
|
| 968 | + * (because the answer might be an array of answer values, so passing pretty_value=true |
|
| 969 | + * will convert it into some kind of string) |
|
| 970 | + */ |
|
| 971 | + public function answer_value_to_question($question, $pretty_value = true) |
|
| 972 | + { |
|
| 973 | + $question_id = EEM_Question::instance()->ensure_is_ID($question); |
|
| 974 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
| 975 | + } |
|
| 976 | + |
|
| 977 | + |
|
| 978 | + /** |
|
| 979 | + * question_groups |
|
| 980 | + * returns an array of EE_Question_Group objects for this registration |
|
| 981 | + * |
|
| 982 | + * @return EE_Question_Group[] |
|
| 983 | + */ |
|
| 984 | + public function question_groups() |
|
| 985 | + { |
|
| 986 | + $question_groups = array(); |
|
| 987 | + if ($this->event() instanceof EE_Event) { |
|
| 988 | + $question_groups = $this->event()->question_groups( |
|
| 989 | + array( |
|
| 990 | + array( |
|
| 991 | + 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
| 992 | + ), |
|
| 993 | + 'order_by' => array('QSG_order' => 'ASC'), |
|
| 994 | + ) |
|
| 995 | + ); |
|
| 996 | + } |
|
| 997 | + return $question_groups; |
|
| 998 | + } |
|
| 999 | + |
|
| 1000 | + |
|
| 1001 | + /** |
|
| 1002 | + * count_question_groups |
|
| 1003 | + * returns a count of the number of EE_Question_Group objects for this registration |
|
| 1004 | + * |
|
| 1005 | + * @return int |
|
| 1006 | + */ |
|
| 1007 | + public function count_question_groups() |
|
| 1008 | + { |
|
| 1009 | + $qg_count = 0; |
|
| 1010 | + if ($this->event() instanceof EE_Event) { |
|
| 1011 | + $qg_count = $this->event()->count_related( |
|
| 1012 | + 'Question_Group', |
|
| 1013 | + array( |
|
| 1014 | + array( |
|
| 1015 | + 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
| 1016 | + ), |
|
| 1017 | + ) |
|
| 1018 | + ); |
|
| 1019 | + } |
|
| 1020 | + return $qg_count; |
|
| 1021 | + } |
|
| 1022 | + |
|
| 1023 | + |
|
| 1024 | + /** |
|
| 1025 | + * Returns the registration date in the 'standard' string format |
|
| 1026 | + * (function may be improved in the future to allow for different formats and timezones) |
|
| 1027 | + * |
|
| 1028 | + * @return string |
|
| 1029 | + */ |
|
| 1030 | + public function reg_date() |
|
| 1031 | + { |
|
| 1032 | + return $this->get_datetime('REG_date'); |
|
| 1033 | + } |
|
| 1034 | + |
|
| 1035 | + |
|
| 1036 | + /** |
|
| 1037 | + * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
|
| 1038 | + * the ticket this registration purchased, or the datetime they have registered |
|
| 1039 | + * to attend) |
|
| 1040 | + * |
|
| 1041 | + * @return EE_Datetime_Ticket |
|
| 1042 | + */ |
|
| 1043 | + public function datetime_ticket() |
|
| 1044 | + { |
|
| 1045 | + return $this->get_first_related('Datetime_Ticket'); |
|
| 1046 | + } |
|
| 1047 | + |
|
| 1048 | + |
|
| 1049 | + /** |
|
| 1050 | + * Sets the registration's datetime_ticket. |
|
| 1051 | + * |
|
| 1052 | + * @param EE_Datetime_Ticket $datetime_ticket |
|
| 1053 | + * @return EE_Datetime_Ticket |
|
| 1054 | + */ |
|
| 1055 | + public function set_datetime_ticket($datetime_ticket) |
|
| 1056 | + { |
|
| 1057 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
| 1058 | + } |
|
| 1059 | + |
|
| 1060 | + /** |
|
| 1061 | + * Gets deleted |
|
| 1062 | + * |
|
| 1063 | + * @return boolean |
|
| 1064 | + */ |
|
| 1065 | + public function deleted() |
|
| 1066 | + { |
|
| 1067 | + return $this->get('REG_deleted'); |
|
| 1068 | + } |
|
| 1069 | + |
|
| 1070 | + /** |
|
| 1071 | + * Sets deleted |
|
| 1072 | + * |
|
| 1073 | + * @param boolean $deleted |
|
| 1074 | + * @return boolean |
|
| 1075 | + */ |
|
| 1076 | + public function set_deleted($deleted) |
|
| 1077 | + { |
|
| 1078 | + if ($deleted) { |
|
| 1079 | + $this->delete(); |
|
| 1080 | + } else { |
|
| 1081 | + $this->restore(); |
|
| 1082 | + } |
|
| 1083 | + } |
|
| 1084 | + |
|
| 1085 | + |
|
| 1086 | + /** |
|
| 1087 | + * Get the status object of this object |
|
| 1088 | + * |
|
| 1089 | + * @return EE_Status |
|
| 1090 | + */ |
|
| 1091 | + public function status_obj() |
|
| 1092 | + { |
|
| 1093 | + return $this->get_first_related('Status'); |
|
| 1094 | + } |
|
| 1095 | + |
|
| 1096 | + |
|
| 1097 | + /** |
|
| 1098 | + * Returns the number of times this registration has checked into any of the datetimes |
|
| 1099 | + * its available for |
|
| 1100 | + * |
|
| 1101 | + * @return int |
|
| 1102 | + */ |
|
| 1103 | + public function count_checkins() |
|
| 1104 | + { |
|
| 1105 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
| 1106 | + } |
|
| 1107 | + |
|
| 1108 | + |
|
| 1109 | + /** |
|
| 1110 | + * Returns the number of current Check-ins this registration is checked into for any of the datetimes the |
|
| 1111 | + * registration is for. Note, this is ONLY checked in (does not include checkedout) |
|
| 1112 | + * |
|
| 1113 | + * @return int |
|
| 1114 | + */ |
|
| 1115 | + public function count_checkins_not_checkedout() |
|
| 1116 | + { |
|
| 1117 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + |
|
| 1121 | + /** |
|
| 1122 | + * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
|
| 1123 | + * |
|
| 1124 | + * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
| 1125 | + * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
|
| 1126 | + * consider registration status as well as datetime access. |
|
| 1127 | + * @return bool |
|
| 1128 | + */ |
|
| 1129 | + public function can_checkin($DTT_OR_ID, $check_approved = true) |
|
| 1130 | + { |
|
| 1131 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
| 1132 | + |
|
| 1133 | + //first check registration status |
|
| 1134 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
| 1135 | + return false; |
|
| 1136 | + } |
|
| 1137 | + //is there a datetime ticket that matches this dtt_ID? |
|
| 1138 | + if (! (EEM_Datetime_Ticket::instance()->exists(array( |
|
| 1139 | + array( |
|
| 1140 | + 'TKT_ID' => $this->get('TKT_ID'), |
|
| 1141 | + 'DTT_ID' => $DTT_ID, |
|
| 1142 | + ), |
|
| 1143 | + ))) |
|
| 1144 | + ) { |
|
| 1145 | + return false; |
|
| 1146 | + } |
|
| 1147 | + |
|
| 1148 | + //final check is against TKT_uses |
|
| 1149 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
| 1150 | + } |
|
| 1151 | + |
|
| 1152 | + |
|
| 1153 | + /** |
|
| 1154 | + * This method verifies whether the user can checkin for the given datetime considering the max uses value set on |
|
| 1155 | + * the ticket. To do this, a query is done to get the count of the datetime records already checked into. If the |
|
| 1156 | + * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses, |
|
| 1157 | + * then return false. Otherwise return true. |
|
| 1158 | + * |
|
| 1159 | + * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
| 1160 | + * @return bool true means can checkin. false means cannot checkin. |
|
| 1161 | + */ |
|
| 1162 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) |
|
| 1163 | + { |
|
| 1164 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
| 1165 | + |
|
| 1166 | + if (! $DTT_ID) { |
|
| 1167 | + return false; |
|
| 1168 | + } |
|
| 1169 | + |
|
| 1170 | + $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF; |
|
| 1171 | + |
|
| 1172 | + // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
|
| 1173 | + // or not. |
|
| 1174 | + if (! $max_uses || $max_uses === EE_INF) { |
|
| 1175 | + return true; |
|
| 1176 | + } |
|
| 1177 | + |
|
| 1178 | + //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
|
| 1179 | + //go ahead and toggle. |
|
| 1180 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
| 1181 | + return true; |
|
| 1182 | + } |
|
| 1183 | + |
|
| 1184 | + //made it here so the last check is whether the number of checkins per unique datetime on this registration |
|
| 1185 | + //disallows further check-ins. |
|
| 1186 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array( |
|
| 1187 | + array( |
|
| 1188 | + 'REG_ID' => $this->ID(), |
|
| 1189 | + 'CHK_in' => true, |
|
| 1190 | + ), |
|
| 1191 | + ), 'DTT_ID', true); |
|
| 1192 | + // checkins have already reached their max number of uses |
|
| 1193 | + // so registrant can NOT checkin |
|
| 1194 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
| 1195 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', |
|
| 1196 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1197 | + return false; |
|
| 1198 | + } |
|
| 1199 | + return true; |
|
| 1200 | + } |
|
| 1201 | + |
|
| 1202 | + |
|
| 1203 | + /** |
|
| 1204 | + * toggle Check-in status for this registration |
|
| 1205 | + * Check-ins are toggled in the following order: |
|
| 1206 | + * never checked in -> checked in |
|
| 1207 | + * checked in -> checked out |
|
| 1208 | + * checked out -> checked in |
|
| 1209 | + * |
|
| 1210 | + * @param int $DTT_ID include specific datetime to toggle Check-in for. |
|
| 1211 | + * If not included or null, then it is assumed latest datetime is being toggled. |
|
| 1212 | + * @param bool $verify If true then can_checkin() is used to verify whether the person |
|
| 1213 | + * can be checked in or not. Otherwise this forces change in checkin status. |
|
| 1214 | + * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
|
| 1215 | + * @throws EE_Error |
|
| 1216 | + */ |
|
| 1217 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) |
|
| 1218 | + { |
|
| 1219 | + if (empty($DTT_ID)) { |
|
| 1220 | + $datetime = $this->get_latest_related_datetime(); |
|
| 1221 | + $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
| 1222 | + // verify the registration can checkin for the given DTT_ID |
|
| 1223 | + } elseif (! $this->can_checkin($DTT_ID, $verify)) { |
|
| 1224 | + EE_Error::add_error( |
|
| 1225 | + sprintf( |
|
| 1226 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', |
|
| 1227 | + 'event_espresso'), |
|
| 1228 | + $this->ID(), |
|
| 1229 | + $DTT_ID |
|
| 1230 | + ), |
|
| 1231 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1232 | + ); |
|
| 1233 | + return false; |
|
| 1234 | + } |
|
| 1235 | + $status_paths = array( |
|
| 1236 | + EE_Registration::checkin_status_never => EE_Registration::checkin_status_in, |
|
| 1237 | + EE_Registration::checkin_status_in => EE_Registration::checkin_status_out, |
|
| 1238 | + EE_Registration::checkin_status_out => EE_Registration::checkin_status_in, |
|
| 1239 | + ); |
|
| 1240 | + //start by getting the current status so we know what status we'll be changing to. |
|
| 1241 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, null); |
|
| 1242 | + $status_to = $status_paths[$cur_status]; |
|
| 1243 | + // database only records true for checked IN or false for checked OUT |
|
| 1244 | + // no record ( null ) means checked in NEVER, but we obviously don't save that |
|
| 1245 | + $new_status = $status_to === EE_Registration::checkin_status_in ? true : false; |
|
| 1246 | + // add relation - note Check-ins are always creating new rows |
|
| 1247 | + // because we are keeping track of Check-ins over time. |
|
| 1248 | + // Eventually we'll probably want to show a list table |
|
| 1249 | + // for the individual Check-ins so that they can be managed. |
|
| 1250 | + $checkin = EE_Checkin::new_instance(array( |
|
| 1251 | + 'REG_ID' => $this->ID(), |
|
| 1252 | + 'DTT_ID' => $DTT_ID, |
|
| 1253 | + 'CHK_in' => $new_status, |
|
| 1254 | + )); |
|
| 1255 | + // if the record could not be saved then return false |
|
| 1256 | + if ($checkin->save() === 0) { |
|
| 1257 | + if (WP_DEBUG) { |
|
| 1258 | + global $wpdb; |
|
| 1259 | + $error = sprintf( |
|
| 1260 | + __('Registration check in update failed because of the following database error: %1$s%2$s', |
|
| 1261 | + 'event_espresso'), |
|
| 1262 | + '<br />', |
|
| 1263 | + $wpdb->last_error |
|
| 1264 | + ); |
|
| 1265 | + } else { |
|
| 1266 | + $error = __('Registration check in update failed because of an unknown database error', |
|
| 1267 | + 'event_espresso'); |
|
| 1268 | + } |
|
| 1269 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
| 1270 | + return false; |
|
| 1271 | + } |
|
| 1272 | + return $status_to; |
|
| 1273 | + } |
|
| 1274 | + |
|
| 1275 | + |
|
| 1276 | + /** |
|
| 1277 | + * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
|
| 1278 | + * "Latest" is defined by the `DTT_EVT_start` column. |
|
| 1279 | + * |
|
| 1280 | + * @return EE_Datetime|null |
|
| 1281 | + * @throws \EE_Error |
|
| 1282 | + */ |
|
| 1283 | + public function get_latest_related_datetime() |
|
| 1284 | + { |
|
| 1285 | + return EEM_Datetime::instance()->get_one( |
|
| 1286 | + array( |
|
| 1287 | + array( |
|
| 1288 | + 'Ticket.Registration.REG_ID' => $this->ID(), |
|
| 1289 | + ), |
|
| 1290 | + 'order_by' => array('DTT_EVT_start' => 'DESC'), |
|
| 1291 | + ) |
|
| 1292 | + ); |
|
| 1293 | + } |
|
| 1294 | + |
|
| 1295 | + |
|
| 1296 | + /** |
|
| 1297 | + * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
|
| 1298 | + * "Earliest" is defined by the `DTT_EVT_start` column. |
|
| 1299 | + * |
|
| 1300 | + * @throws \EE_Error |
|
| 1301 | + */ |
|
| 1302 | + public function get_earliest_related_datetime() |
|
| 1303 | + { |
|
| 1304 | + return EEM_Datetime::instance()->get_one( |
|
| 1305 | + array( |
|
| 1306 | + array( |
|
| 1307 | + 'Ticket.Registration.REG_ID' => $this->ID(), |
|
| 1308 | + ), |
|
| 1309 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
| 1310 | + ) |
|
| 1311 | + ); |
|
| 1312 | + } |
|
| 1313 | + |
|
| 1314 | + |
|
| 1315 | + /** |
|
| 1316 | + * This method simply returns the check-in status for this registration and the given datetime. |
|
| 1317 | + * If neither the datetime nor the checkin values are provided as arguments, |
|
| 1318 | + * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
|
| 1319 | + * |
|
| 1320 | + * @param int $DTT_ID The ID of the datetime we're checking against |
|
| 1321 | + * (if empty we'll get the primary datetime for |
|
| 1322 | + * this registration (via event) and use it's ID); |
|
| 1323 | + * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
|
| 1324 | + * @return int Integer representing Check-in status. |
|
| 1325 | + * @throws \EE_Error |
|
| 1326 | + */ |
|
| 1327 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) |
|
| 1328 | + { |
|
| 1329 | + $checkin_query_params = array( |
|
| 1330 | + 'order_by' => array('CHK_timestamp' => 'DESC'), |
|
| 1331 | + ); |
|
| 1332 | + |
|
| 1333 | + if ($DTT_ID > 0) { |
|
| 1334 | + $checkin_query_params[0] = array('DTT_ID' => $DTT_ID); |
|
| 1335 | + } |
|
| 1336 | + |
|
| 1337 | + //get checkin object (if exists) |
|
| 1338 | + $checkin = $checkin instanceof EE_Checkin |
|
| 1339 | + ? $checkin |
|
| 1340 | + : $this->get_first_related('Checkin', $checkin_query_params); |
|
| 1341 | + if ($checkin instanceof EE_Checkin) { |
|
| 1342 | + if ($checkin->get('CHK_in')) { |
|
| 1343 | + return EE_Registration::checkin_status_in; //checked in |
|
| 1344 | + } |
|
| 1345 | + return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
|
| 1346 | + } |
|
| 1347 | + return EE_Registration::checkin_status_never; //never been checked in |
|
| 1348 | + } |
|
| 1349 | + |
|
| 1350 | + |
|
| 1351 | + /** |
|
| 1352 | + * This method returns a localized message for the toggled Check-in message. |
|
| 1353 | + * |
|
| 1354 | + * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, |
|
| 1355 | + * then it is assumed Check-in for primary datetime was toggled. |
|
| 1356 | + * @param bool $error This just flags that you want an error message returned. This is put in so that the error |
|
| 1357 | + * message can be customized with the attendee name. |
|
| 1358 | + * @return string internationalized message |
|
| 1359 | + */ |
|
| 1360 | + public function get_checkin_msg($DTT_ID, $error = false) |
|
| 1361 | + { |
|
| 1362 | + //let's get the attendee first so we can include the name of the attendee |
|
| 1363 | + $attendee = $this->get_first_related('Attendee'); |
|
| 1364 | + if ($attendee instanceof EE_Attendee) { |
|
| 1365 | + if ($error) { |
|
| 1366 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
| 1367 | + } |
|
| 1368 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
| 1369 | + //what is the status message going to be? |
|
| 1370 | + switch ($cur_status) { |
|
| 1371 | + case EE_Registration::checkin_status_never : |
|
| 1372 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), |
|
| 1373 | + $attendee->full_name()); |
|
| 1374 | + break; |
|
| 1375 | + case EE_Registration::checkin_status_in : |
|
| 1376 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
| 1377 | + break; |
|
| 1378 | + case EE_Registration::checkin_status_out : |
|
| 1379 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
| 1380 | + break; |
|
| 1381 | + } |
|
| 1382 | + } |
|
| 1383 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
| 1384 | + } |
|
| 1385 | + |
|
| 1386 | + |
|
| 1387 | + /** |
|
| 1388 | + * Returns the related EE_Transaction to this registration |
|
| 1389 | + * |
|
| 1390 | + * @return EE_Transaction |
|
| 1391 | + */ |
|
| 1392 | + public function transaction() |
|
| 1393 | + { |
|
| 1394 | + $transaction = $this->get_first_related('Transaction'); |
|
| 1395 | + if (! $transaction instanceof \EE_Transaction) { |
|
| 1396 | + throw new EntityNotFoundException('Transaction ID', $this->transaction_ID()); |
|
| 1397 | + } |
|
| 1398 | + return $transaction; |
|
| 1399 | + } |
|
| 1400 | + |
|
| 1401 | + |
|
| 1402 | + /** |
|
| 1403 | + * get Registration Code |
|
| 1404 | + */ |
|
| 1405 | + public function reg_code() |
|
| 1406 | + { |
|
| 1407 | + return $this->get('REG_code'); |
|
| 1408 | + } |
|
| 1409 | + |
|
| 1410 | + |
|
| 1411 | + /** |
|
| 1412 | + * get Transaction ID |
|
| 1413 | + */ |
|
| 1414 | + public function transaction_ID() |
|
| 1415 | + { |
|
| 1416 | + return $this->get('TXN_ID'); |
|
| 1417 | + } |
|
| 1418 | + |
|
| 1419 | + |
|
| 1420 | + /** |
|
| 1421 | + * @return int |
|
| 1422 | + */ |
|
| 1423 | + public function ticket_ID() |
|
| 1424 | + { |
|
| 1425 | + return $this->get('TKT_ID'); |
|
| 1426 | + } |
|
| 1427 | + |
|
| 1428 | + |
|
| 1429 | + /** |
|
| 1430 | + * Set Registration Code |
|
| 1431 | + * |
|
| 1432 | + * @access public |
|
| 1433 | + * @param string $REG_code Registration Code |
|
| 1434 | + * @param boolean $use_default |
|
| 1435 | + */ |
|
| 1436 | + public function set_reg_code($REG_code, $use_default = false) |
|
| 1437 | + { |
|
| 1438 | + if (empty($REG_code)) { |
|
| 1439 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1440 | + return; |
|
| 1441 | + } |
|
| 1442 | + if (! $this->reg_code()) { |
|
| 1443 | + parent::set('REG_code', $REG_code, $use_default); |
|
| 1444 | + } else { |
|
| 1445 | + EE_Error::doing_it_wrong( |
|
| 1446 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 1447 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
| 1448 | + '4.6.0' |
|
| 1449 | + ); |
|
| 1450 | + } |
|
| 1451 | + } |
|
| 1452 | + |
|
| 1453 | + |
|
| 1454 | + /** |
|
| 1455 | + * Returns all other registrations in the same group as this registrant who have the same ticket option. |
|
| 1456 | + * Note, if you want to just get all registrations in the same transaction (group), use: |
|
| 1457 | + * $registration->transaction()->registrations(); |
|
| 1458 | + * |
|
| 1459 | + * @since 4.5.0 |
|
| 1460 | + * @return EE_Registration[] or empty array if this isn't a group registration. |
|
| 1461 | + */ |
|
| 1462 | + public function get_all_other_registrations_in_group() |
|
| 1463 | + { |
|
| 1464 | + if ($this->group_size() < 2) { |
|
| 1465 | + return array(); |
|
| 1466 | + } |
|
| 1467 | + |
|
| 1468 | + $query[0] = array( |
|
| 1469 | + 'TXN_ID' => $this->transaction_ID(), |
|
| 1470 | + 'REG_ID' => array('!=', $this->ID()), |
|
| 1471 | + 'TKT_ID' => $this->ticket_ID(), |
|
| 1472 | + ); |
|
| 1473 | + |
|
| 1474 | + $registrations = $this->get_model()->get_all($query); |
|
| 1475 | + return $registrations; |
|
| 1476 | + } |
|
| 1477 | + |
|
| 1478 | + /** |
|
| 1479 | + * Return the link to the admin details for the object. |
|
| 1480 | + * |
|
| 1481 | + * @return string |
|
| 1482 | + */ |
|
| 1483 | + public function get_admin_details_link() |
|
| 1484 | + { |
|
| 1485 | + EE_Registry::instance()->load_helper('URL'); |
|
| 1486 | + return EEH_URL::add_query_args_and_nonce( |
|
| 1487 | + array( |
|
| 1488 | + 'page' => 'espresso_registrations', |
|
| 1489 | + 'action' => 'view_registration', |
|
| 1490 | + '_REG_ID' => $this->ID(), |
|
| 1491 | + ), |
|
| 1492 | + admin_url('admin.php') |
|
| 1493 | + ); |
|
| 1494 | + } |
|
| 1495 | + |
|
| 1496 | + /** |
|
| 1497 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 1498 | + * |
|
| 1499 | + * @return string |
|
| 1500 | + */ |
|
| 1501 | + public function get_admin_edit_link() |
|
| 1502 | + { |
|
| 1503 | + return $this->get_admin_details_link(); |
|
| 1504 | + } |
|
| 1505 | + |
|
| 1506 | + /** |
|
| 1507 | + * Returns the link to a settings page for the object. |
|
| 1508 | + * |
|
| 1509 | + * @return string |
|
| 1510 | + */ |
|
| 1511 | + public function get_admin_settings_link() |
|
| 1512 | + { |
|
| 1513 | + return $this->get_admin_details_link(); |
|
| 1514 | + } |
|
| 1515 | + |
|
| 1516 | + /** |
|
| 1517 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 1518 | + * |
|
| 1519 | + * @return string |
|
| 1520 | + */ |
|
| 1521 | + public function get_admin_overview_link() |
|
| 1522 | + { |
|
| 1523 | + EE_Registry::instance()->load_helper('URL'); |
|
| 1524 | + return EEH_URL::add_query_args_and_nonce( |
|
| 1525 | + array( |
|
| 1526 | + 'page' => 'espresso_registrations', |
|
| 1527 | + ), |
|
| 1528 | + admin_url('admin.php') |
|
| 1529 | + ); |
|
| 1530 | + } |
|
| 1531 | + |
|
| 1532 | + |
|
| 1533 | + /** |
|
| 1534 | + * @param array $query_params |
|
| 1535 | + * @return \EE_Registration[] |
|
| 1536 | + * @throws \EE_Error |
|
| 1537 | + */ |
|
| 1538 | + public function payments($query_params = array()) |
|
| 1539 | + { |
|
| 1540 | + return $this->get_many_related('Payment', $query_params); |
|
| 1541 | + } |
|
| 1542 | + |
|
| 1543 | + |
|
| 1544 | + /** |
|
| 1545 | + * @param array $query_params |
|
| 1546 | + * @return \EE_Registration_Payment[] |
|
| 1547 | + * @throws \EE_Error |
|
| 1548 | + */ |
|
| 1549 | + public function registration_payments($query_params = array()) |
|
| 1550 | + { |
|
| 1551 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
| 1552 | + } |
|
| 1553 | + |
|
| 1554 | + |
|
| 1555 | + /** |
|
| 1556 | + * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
|
| 1557 | + * Note: if there are no payments on the registration there will be no payment method returned. |
|
| 1558 | + * |
|
| 1559 | + * @return EE_Payment_Method|null |
|
| 1560 | + */ |
|
| 1561 | + public function payment_method() |
|
| 1562 | + { |
|
| 1563 | + return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
| 1564 | + } |
|
| 1565 | + |
|
| 1566 | + |
|
| 1567 | + /** |
|
| 1568 | + * @return \EE_Line_Item |
|
| 1569 | + * @throws EntityNotFoundException |
|
| 1570 | + * @throws \EE_Error |
|
| 1571 | + */ |
|
| 1572 | + public function ticket_line_item() |
|
| 1573 | + { |
|
| 1574 | + $ticket = $this->ticket(); |
|
| 1575 | + $transaction = $this->transaction(); |
|
| 1576 | + $line_item = null; |
|
| 1577 | + $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
| 1578 | + $transaction->total_line_item(), |
|
| 1579 | + 'Ticket', |
|
| 1580 | + array($ticket->ID()) |
|
| 1581 | + ); |
|
| 1582 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
| 1583 | + if ( |
|
| 1584 | + $ticket_line_item instanceof \EE_Line_Item |
|
| 1585 | + && $ticket_line_item->OBJ_type() === 'Ticket' |
|
| 1586 | + && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
| 1587 | + ) { |
|
| 1588 | + $line_item = $ticket_line_item; |
|
| 1589 | + break; |
|
| 1590 | + } |
|
| 1591 | + } |
|
| 1592 | + if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
| 1593 | + throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
| 1594 | + } |
|
| 1595 | + return $line_item; |
|
| 1596 | + } |
|
| 1597 | + |
|
| 1598 | + |
|
| 1599 | + /** |
|
| 1600 | + * Soft Deletes this model object. |
|
| 1601 | + * |
|
| 1602 | + * @return boolean | int |
|
| 1603 | + * @throws \RuntimeException |
|
| 1604 | + * @throws \EE_Error |
|
| 1605 | + */ |
|
| 1606 | + public function delete() |
|
| 1607 | + { |
|
| 1608 | + if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) { |
|
| 1609 | + $this->set_status(EEM_Registration::status_id_cancelled); |
|
| 1610 | + } |
|
| 1611 | + return parent::delete(); |
|
| 1612 | + } |
|
| 1613 | + |
|
| 1614 | + |
|
| 1615 | + /** |
|
| 1616 | + * Restores whatever the previous status was on a registration before it was trashed (if possible) |
|
| 1617 | + * |
|
| 1618 | + * @throws \EE_Error |
|
| 1619 | + * @throws \RuntimeException |
|
| 1620 | + */ |
|
| 1621 | + public function restore() |
|
| 1622 | + { |
|
| 1623 | + $previous_status = $this->get_extra_meta( |
|
| 1624 | + EE_Registration::PRE_TRASH_REG_STATUS_KEY, |
|
| 1625 | + true, |
|
| 1626 | + EEM_Registration::status_id_cancelled |
|
| 1627 | + ); |
|
| 1628 | + if ($previous_status) { |
|
| 1629 | + $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY); |
|
| 1630 | + $this->set_status($previous_status); |
|
| 1631 | + } |
|
| 1632 | + return parent::restore(); |
|
| 1633 | + } |
|
| 1634 | + |
|
| 1635 | + |
|
| 1636 | + |
|
| 1637 | + /*************************** DEPRECATED ***************************/ |
|
| 1638 | + |
|
| 1639 | + |
|
| 1640 | + /** |
|
| 1641 | + * @deprecated |
|
| 1642 | + * @since 4.7.0 |
|
| 1643 | + * @access public |
|
| 1644 | + */ |
|
| 1645 | + public function price_paid() |
|
| 1646 | + { |
|
| 1647 | + EE_Error::doing_it_wrong('EE_Registration::price_paid()', |
|
| 1648 | + __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), |
|
| 1649 | + '4.7.0'); |
|
| 1650 | + return $this->final_price(); |
|
| 1651 | + } |
|
| 1652 | + |
|
| 1653 | + |
|
| 1654 | + /** |
|
| 1655 | + * @deprecated |
|
| 1656 | + * @since 4.7.0 |
|
| 1657 | + * @access public |
|
| 1658 | + * @param float $REG_final_price |
|
| 1659 | + */ |
|
| 1660 | + public function set_price_paid($REG_final_price = 0.00) |
|
| 1661 | + { |
|
| 1662 | + EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', |
|
| 1663 | + __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), |
|
| 1664 | + '4.7.0'); |
|
| 1665 | + $this->set_final_price($REG_final_price); |
|
| 1666 | + } |
|
| 1667 | + |
|
| 1668 | + |
|
| 1669 | + /** |
|
| 1670 | + * @deprecated |
|
| 1671 | + * @since 4.7.0 |
|
| 1672 | + * @return string |
|
| 1673 | + */ |
|
| 1674 | + public function pretty_price_paid() |
|
| 1675 | + { |
|
| 1676 | + EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', |
|
| 1677 | + __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', |
|
| 1678 | + 'event_espresso'), '4.7.0'); |
|
| 1679 | + return $this->pretty_final_price(); |
|
| 1680 | + } |
|
| 1681 | + |
|
| 1682 | + |
|
| 1683 | + /** |
|
| 1684 | + * Gets the primary datetime related to this registration via the related Event to this registration |
|
| 1685 | + * |
|
| 1686 | + * @deprecated 4.9.17 |
|
| 1687 | + * @return EE_Datetime |
|
| 1688 | + */ |
|
| 1689 | + public function get_related_primary_datetime() |
|
| 1690 | + { |
|
| 1691 | + EE_Error::doing_it_wrong( |
|
| 1692 | + __METHOD__, |
|
| 1693 | + esc_html__( |
|
| 1694 | + 'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()', |
|
| 1695 | + 'event_espresso' |
|
| 1696 | + ), |
|
| 1697 | + '4.9.17', |
|
| 1698 | + '5.0.0' |
|
| 1699 | + ); |
|
| 1700 | + return $this->event()->primary_datetime(); |
|
| 1701 | + } |
|
| 1702 | 1702 | |
| 1703 | 1703 | |
| 1704 | 1704 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | use WP_Post; |
| 17 | 17 | |
| 18 | 18 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
| 19 | - exit( 'No direct script access allowed' ); |
|
| 19 | + exit( 'No direct script access allowed' ); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -33,683 +33,683 @@ discard block |
||
| 33 | 33 | class DisplayTicketSelector |
| 34 | 34 | { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * event that ticket selector is being generated for |
|
| 38 | - * |
|
| 39 | - * @access protected |
|
| 40 | - * @var EE_Event $event |
|
| 41 | - */ |
|
| 42 | - protected $event; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Used to flag when the ticket selector is being called from an external iframe. |
|
| 46 | - * |
|
| 47 | - * @var bool $iframe |
|
| 48 | - */ |
|
| 49 | - protected $iframe = false; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * max attendees that can register for event at one time |
|
| 53 | - * |
|
| 54 | - * @var int $max_attendees |
|
| 55 | - */ |
|
| 56 | - private $max_attendees = EE_INF; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - *@var string $date_format |
|
| 60 | - */ |
|
| 61 | - private $date_format; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - *@var string $time_format |
|
| 65 | - */ |
|
| 66 | - private $time_format; |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * DisplayTicketSelector constructor. |
|
| 72 | - */ |
|
| 73 | - public function __construct() |
|
| 74 | - { |
|
| 75 | - $this->date_format = apply_filters( |
|
| 76 | - 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
|
| 77 | - get_option('date_format') |
|
| 78 | - ); |
|
| 79 | - $this->time_format = apply_filters( |
|
| 80 | - 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
|
| 81 | - get_option('time_format') |
|
| 82 | - ); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @param boolean $iframe |
|
| 89 | - */ |
|
| 90 | - public function setIframe( $iframe = true ) |
|
| 91 | - { |
|
| 92 | - $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * finds and sets the \EE_Event object for use throughout class |
|
| 98 | - * |
|
| 99 | - * @param mixed $event |
|
| 100 | - * @return bool |
|
| 101 | - * @throws EE_Error |
|
| 102 | - */ |
|
| 103 | - protected function setEvent( $event = null ) |
|
| 104 | - { |
|
| 105 | - if ( $event === null ) { |
|
| 106 | - global $post; |
|
| 107 | - $event = $post; |
|
| 108 | - } |
|
| 109 | - if ( $event instanceof EE_Event ) { |
|
| 110 | - $this->event = $event; |
|
| 111 | - } else if ( $event instanceof WP_Post ) { |
|
| 112 | - if ( isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
|
| 113 | - $this->event = $event->EE_Event; |
|
| 114 | - } else if ( $event->post_type === 'espresso_events' ) { |
|
| 115 | - $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
| 116 | - $this->event = $event->EE_Event; |
|
| 117 | - } |
|
| 118 | - } else { |
|
| 119 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
| 120 | - $dev_msg = $user_msg . __( |
|
| 121 | - 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
|
| 122 | - 'event_espresso' |
|
| 123 | - ); |
|
| 124 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 125 | - return false; |
|
| 126 | - } |
|
| 127 | - return true; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @return int |
|
| 134 | - */ |
|
| 135 | - public function getMaxAttendees() |
|
| 136 | - { |
|
| 137 | - return $this->max_attendees; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @param int $max_attendees |
|
| 144 | - */ |
|
| 145 | - public function setMaxAttendees($max_attendees) |
|
| 146 | - { |
|
| 147 | - $this->max_attendees = absint( |
|
| 148 | - apply_filters( |
|
| 149 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
|
| 150 | - $max_attendees |
|
| 151 | - ) |
|
| 152 | - ); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * creates buttons for selecting number of attendees for an event |
|
| 159 | - * |
|
| 160 | - * @param WP_Post|int $event |
|
| 161 | - * @param bool $view_details |
|
| 162 | - * @return string |
|
| 163 | - * @throws EE_Error |
|
| 164 | - */ |
|
| 165 | - public function display( $event = null, $view_details = false ) |
|
| 166 | - { |
|
| 167 | - // reset filter for displaying submit button |
|
| 168 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
| 169 | - // poke and prod incoming event till it tells us what it is |
|
| 170 | - if ( ! $this->setEvent( $event ) ) { |
|
| 171 | - return false; |
|
| 172 | - } |
|
| 173 | - // begin gathering template arguments by getting event status |
|
| 174 | - $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
| 175 | - if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
| 176 | - return ! is_single() ? $this->displayViewDetailsButton() : ''; |
|
| 177 | - } |
|
| 178 | - // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
|
| 179 | - $this->setMaxAttendees($this->event->additional_limit()); |
|
| 180 | - if ($this->getMaxAttendees() < 1) { |
|
| 181 | - return $this->ticketSalesClosedMessage(); |
|
| 182 | - } |
|
| 183 | - // is the event expired ? |
|
| 184 | - $template_args['event_is_expired'] = $this->event->is_expired(); |
|
| 185 | - if ( $template_args[ 'event_is_expired' ] ) { |
|
| 186 | - return $this->expiredEventMessage(); |
|
| 187 | - } |
|
| 188 | - // get all tickets for this event ordered by the datetime |
|
| 189 | - $tickets = $this->getTickets(); |
|
| 190 | - if (count($tickets) < 1) { |
|
| 191 | - return $this->noTicketAvailableMessage(); |
|
| 192 | - } |
|
| 193 | - if (EED_Events_Archive::is_iframe()){ |
|
| 194 | - $this->setIframe(); |
|
| 195 | - } |
|
| 196 | - // redirecting to another site for registration ?? |
|
| 197 | - $external_url = (string) $this->event->external_url(); |
|
| 198 | - // if redirecting to another site for registration, then we don't load the TS |
|
| 199 | - $ticket_selector = $external_url |
|
| 200 | - ? $this->externalEventRegistration() |
|
| 201 | - : $this->loadTicketSelector($tickets,$template_args); |
|
| 202 | - // now set up the form (but not for the admin) |
|
| 203 | - $ticket_selector = ! is_admin() |
|
| 204 | - ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
| 205 | - : $ticket_selector; |
|
| 206 | - // submit button and form close tag |
|
| 207 | - $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
|
| 208 | - return $ticket_selector; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * displayTicketSelector |
|
| 215 | - * examines the event properties and determines whether a Ticket Selector should be displayed |
|
| 216 | - * |
|
| 217 | - * @param WP_Post|int $event |
|
| 218 | - * @param string $_event_active_status |
|
| 219 | - * @param bool $view_details |
|
| 220 | - * @return bool |
|
| 221 | - * @throws EE_Error |
|
| 222 | - */ |
|
| 223 | - protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details) |
|
| 224 | - { |
|
| 225 | - $event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event; |
|
| 226 | - return ! is_admin() |
|
| 227 | - && ( |
|
| 228 | - ! $this->event->display_ticket_selector() |
|
| 229 | - || $view_details |
|
| 230 | - || post_password_required($event_post) |
|
| 231 | - || ( |
|
| 232 | - $_event_active_status !== EE_Datetime::active |
|
| 233 | - && $_event_active_status !== EE_Datetime::upcoming |
|
| 234 | - && $_event_active_status !== EE_Datetime::sold_out |
|
| 235 | - && ! ( |
|
| 236 | - $_event_active_status === EE_Datetime::inactive |
|
| 237 | - && is_user_logged_in() |
|
| 238 | - ) |
|
| 239 | - ) |
|
| 240 | - ); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * noTicketAvailableMessage |
|
| 247 | - * notice displayed if event is expired |
|
| 248 | - * |
|
| 249 | - * @return string |
|
| 250 | - * @throws EE_Error |
|
| 251 | - */ |
|
| 252 | - protected function expiredEventMessage() |
|
| 253 | - { |
|
| 254 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
| 255 | - 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
|
| 256 | - 'event_espresso' |
|
| 257 | - ) . '</span></div><!-- .ee-event-expired-notice -->'; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * noTicketAvailableMessage |
|
| 264 | - * notice displayed if event has no more tickets available |
|
| 265 | - * |
|
| 266 | - * @return string |
|
| 267 | - * @throws EE_Error |
|
| 268 | - */ |
|
| 269 | - protected function noTicketAvailableMessage() |
|
| 270 | - { |
|
| 271 | - $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
| 272 | - if (current_user_can('edit_post', $this->event->ID())) { |
|
| 273 | - $no_ticket_available_msg .= sprintf( |
|
| 274 | - esc_html__( |
|
| 275 | - '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s', |
|
| 276 | - 'event_espresso' |
|
| 277 | - ), |
|
| 278 | - '<div class="ee-attention" style="text-align: left;"><b>', |
|
| 279 | - '</b><br />', |
|
| 280 | - '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
| 281 | - '</a></span></div><!-- .ee-attention noTicketAvailableMessage -->' |
|
| 282 | - ); |
|
| 283 | - } |
|
| 284 | - return ' |
|
| 36 | + /** |
|
| 37 | + * event that ticket selector is being generated for |
|
| 38 | + * |
|
| 39 | + * @access protected |
|
| 40 | + * @var EE_Event $event |
|
| 41 | + */ |
|
| 42 | + protected $event; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Used to flag when the ticket selector is being called from an external iframe. |
|
| 46 | + * |
|
| 47 | + * @var bool $iframe |
|
| 48 | + */ |
|
| 49 | + protected $iframe = false; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * max attendees that can register for event at one time |
|
| 53 | + * |
|
| 54 | + * @var int $max_attendees |
|
| 55 | + */ |
|
| 56 | + private $max_attendees = EE_INF; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + *@var string $date_format |
|
| 60 | + */ |
|
| 61 | + private $date_format; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + *@var string $time_format |
|
| 65 | + */ |
|
| 66 | + private $time_format; |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * DisplayTicketSelector constructor. |
|
| 72 | + */ |
|
| 73 | + public function __construct() |
|
| 74 | + { |
|
| 75 | + $this->date_format = apply_filters( |
|
| 76 | + 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
|
| 77 | + get_option('date_format') |
|
| 78 | + ); |
|
| 79 | + $this->time_format = apply_filters( |
|
| 80 | + 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
|
| 81 | + get_option('time_format') |
|
| 82 | + ); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @param boolean $iframe |
|
| 89 | + */ |
|
| 90 | + public function setIframe( $iframe = true ) |
|
| 91 | + { |
|
| 92 | + $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * finds and sets the \EE_Event object for use throughout class |
|
| 98 | + * |
|
| 99 | + * @param mixed $event |
|
| 100 | + * @return bool |
|
| 101 | + * @throws EE_Error |
|
| 102 | + */ |
|
| 103 | + protected function setEvent( $event = null ) |
|
| 104 | + { |
|
| 105 | + if ( $event === null ) { |
|
| 106 | + global $post; |
|
| 107 | + $event = $post; |
|
| 108 | + } |
|
| 109 | + if ( $event instanceof EE_Event ) { |
|
| 110 | + $this->event = $event; |
|
| 111 | + } else if ( $event instanceof WP_Post ) { |
|
| 112 | + if ( isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
|
| 113 | + $this->event = $event->EE_Event; |
|
| 114 | + } else if ( $event->post_type === 'espresso_events' ) { |
|
| 115 | + $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
| 116 | + $this->event = $event->EE_Event; |
|
| 117 | + } |
|
| 118 | + } else { |
|
| 119 | + $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
| 120 | + $dev_msg = $user_msg . __( |
|
| 121 | + 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
|
| 122 | + 'event_espresso' |
|
| 123 | + ); |
|
| 124 | + EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 125 | + return false; |
|
| 126 | + } |
|
| 127 | + return true; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @return int |
|
| 134 | + */ |
|
| 135 | + public function getMaxAttendees() |
|
| 136 | + { |
|
| 137 | + return $this->max_attendees; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @param int $max_attendees |
|
| 144 | + */ |
|
| 145 | + public function setMaxAttendees($max_attendees) |
|
| 146 | + { |
|
| 147 | + $this->max_attendees = absint( |
|
| 148 | + apply_filters( |
|
| 149 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
|
| 150 | + $max_attendees |
|
| 151 | + ) |
|
| 152 | + ); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * creates buttons for selecting number of attendees for an event |
|
| 159 | + * |
|
| 160 | + * @param WP_Post|int $event |
|
| 161 | + * @param bool $view_details |
|
| 162 | + * @return string |
|
| 163 | + * @throws EE_Error |
|
| 164 | + */ |
|
| 165 | + public function display( $event = null, $view_details = false ) |
|
| 166 | + { |
|
| 167 | + // reset filter for displaying submit button |
|
| 168 | + remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
| 169 | + // poke and prod incoming event till it tells us what it is |
|
| 170 | + if ( ! $this->setEvent( $event ) ) { |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 173 | + // begin gathering template arguments by getting event status |
|
| 174 | + $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
| 175 | + if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
| 176 | + return ! is_single() ? $this->displayViewDetailsButton() : ''; |
|
| 177 | + } |
|
| 178 | + // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
|
| 179 | + $this->setMaxAttendees($this->event->additional_limit()); |
|
| 180 | + if ($this->getMaxAttendees() < 1) { |
|
| 181 | + return $this->ticketSalesClosedMessage(); |
|
| 182 | + } |
|
| 183 | + // is the event expired ? |
|
| 184 | + $template_args['event_is_expired'] = $this->event->is_expired(); |
|
| 185 | + if ( $template_args[ 'event_is_expired' ] ) { |
|
| 186 | + return $this->expiredEventMessage(); |
|
| 187 | + } |
|
| 188 | + // get all tickets for this event ordered by the datetime |
|
| 189 | + $tickets = $this->getTickets(); |
|
| 190 | + if (count($tickets) < 1) { |
|
| 191 | + return $this->noTicketAvailableMessage(); |
|
| 192 | + } |
|
| 193 | + if (EED_Events_Archive::is_iframe()){ |
|
| 194 | + $this->setIframe(); |
|
| 195 | + } |
|
| 196 | + // redirecting to another site for registration ?? |
|
| 197 | + $external_url = (string) $this->event->external_url(); |
|
| 198 | + // if redirecting to another site for registration, then we don't load the TS |
|
| 199 | + $ticket_selector = $external_url |
|
| 200 | + ? $this->externalEventRegistration() |
|
| 201 | + : $this->loadTicketSelector($tickets,$template_args); |
|
| 202 | + // now set up the form (but not for the admin) |
|
| 203 | + $ticket_selector = ! is_admin() |
|
| 204 | + ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
| 205 | + : $ticket_selector; |
|
| 206 | + // submit button and form close tag |
|
| 207 | + $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
|
| 208 | + return $ticket_selector; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * displayTicketSelector |
|
| 215 | + * examines the event properties and determines whether a Ticket Selector should be displayed |
|
| 216 | + * |
|
| 217 | + * @param WP_Post|int $event |
|
| 218 | + * @param string $_event_active_status |
|
| 219 | + * @param bool $view_details |
|
| 220 | + * @return bool |
|
| 221 | + * @throws EE_Error |
|
| 222 | + */ |
|
| 223 | + protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details) |
|
| 224 | + { |
|
| 225 | + $event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event; |
|
| 226 | + return ! is_admin() |
|
| 227 | + && ( |
|
| 228 | + ! $this->event->display_ticket_selector() |
|
| 229 | + || $view_details |
|
| 230 | + || post_password_required($event_post) |
|
| 231 | + || ( |
|
| 232 | + $_event_active_status !== EE_Datetime::active |
|
| 233 | + && $_event_active_status !== EE_Datetime::upcoming |
|
| 234 | + && $_event_active_status !== EE_Datetime::sold_out |
|
| 235 | + && ! ( |
|
| 236 | + $_event_active_status === EE_Datetime::inactive |
|
| 237 | + && is_user_logged_in() |
|
| 238 | + ) |
|
| 239 | + ) |
|
| 240 | + ); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * noTicketAvailableMessage |
|
| 247 | + * notice displayed if event is expired |
|
| 248 | + * |
|
| 249 | + * @return string |
|
| 250 | + * @throws EE_Error |
|
| 251 | + */ |
|
| 252 | + protected function expiredEventMessage() |
|
| 253 | + { |
|
| 254 | + return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
| 255 | + 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
|
| 256 | + 'event_espresso' |
|
| 257 | + ) . '</span></div><!-- .ee-event-expired-notice -->'; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * noTicketAvailableMessage |
|
| 264 | + * notice displayed if event has no more tickets available |
|
| 265 | + * |
|
| 266 | + * @return string |
|
| 267 | + * @throws EE_Error |
|
| 268 | + */ |
|
| 269 | + protected function noTicketAvailableMessage() |
|
| 270 | + { |
|
| 271 | + $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
| 272 | + if (current_user_can('edit_post', $this->event->ID())) { |
|
| 273 | + $no_ticket_available_msg .= sprintf( |
|
| 274 | + esc_html__( |
|
| 275 | + '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s', |
|
| 276 | + 'event_espresso' |
|
| 277 | + ), |
|
| 278 | + '<div class="ee-attention" style="text-align: left;"><b>', |
|
| 279 | + '</b><br />', |
|
| 280 | + '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
| 281 | + '</a></span></div><!-- .ee-attention noTicketAvailableMessage -->' |
|
| 282 | + ); |
|
| 283 | + } |
|
| 284 | + return ' |
|
| 285 | 285 | <div class="ee-event-expired-notice"> |
| 286 | 286 | <span class="important-notice">' . $no_ticket_available_msg . '</span> |
| 287 | 287 | </div><!-- .ee-event-expired-notice -->'; |
| 288 | - } |
|
| 289 | - |
|
| 290 | - |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * ticketSalesClosed |
|
| 294 | - * notice displayed if event ticket sales are turned off |
|
| 295 | - * |
|
| 296 | - * @return string |
|
| 297 | - * @throws EE_Error |
|
| 298 | - */ |
|
| 299 | - protected function ticketSalesClosedMessage() |
|
| 300 | - { |
|
| 301 | - $sales_closed_msg = esc_html__( |
|
| 302 | - 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
|
| 303 | - 'event_espresso' |
|
| 304 | - ); |
|
| 305 | - if (current_user_can('edit_post', $this->event->ID())) { |
|
| 306 | - $sales_closed_msg .= sprintf( |
|
| 307 | - esc_html__( |
|
| 308 | - '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
|
| 309 | - 'event_espresso' |
|
| 310 | - ), |
|
| 311 | - '<div class="ee-attention" style="text-align: left;"><b>', |
|
| 312 | - '</b><br />', |
|
| 313 | - '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
| 314 | - '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->' |
|
| 315 | - ); |
|
| 316 | - } |
|
| 317 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * getTickets |
|
| 324 | - * |
|
| 325 | - * @return \EE_Base_Class[]|\EE_Ticket[] |
|
| 326 | - * @throws EE_Error |
|
| 327 | - */ |
|
| 328 | - protected function getTickets() |
|
| 329 | - { |
|
| 330 | - $ticket_query_args = array( |
|
| 331 | - array('Datetime.EVT_ID' => $this->event->ID()), |
|
| 332 | - 'order_by' => array( |
|
| 333 | - 'TKT_order' => 'ASC', |
|
| 334 | - 'TKT_required' => 'DESC', |
|
| 335 | - 'TKT_start_date' => 'ASC', |
|
| 336 | - 'TKT_end_date' => 'ASC', |
|
| 337 | - 'Datetime.DTT_EVT_start' => 'DESC', |
|
| 338 | - ), |
|
| 339 | - ); |
|
| 340 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
| 341 | - //use the correct applicable time query depending on what version of core is being run. |
|
| 342 | - $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
|
| 343 | - ? time() |
|
| 344 | - : current_time('timestamp'); |
|
| 345 | - $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
| 346 | - } |
|
| 347 | - return EEM_Ticket::instance()->get_all($ticket_query_args); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * loadTicketSelector |
|
| 354 | - * begins to assemble template arguments |
|
| 355 | - * and decides whether to load a "simple" ticket selector, or the standard |
|
| 356 | - * |
|
| 357 | - * @param \EE_Ticket[] $tickets |
|
| 358 | - * @param array $template_args |
|
| 359 | - * @return string |
|
| 360 | - * @throws EE_Error |
|
| 361 | - */ |
|
| 362 | - protected function loadTicketSelector(array $tickets, array $template_args) |
|
| 363 | - { |
|
| 364 | - $template_args['event'] = $this->event; |
|
| 365 | - $template_args['EVT_ID'] = $this->event->ID(); |
|
| 366 | - $template_args['event_is_expired'] = $this->event->is_expired(); |
|
| 367 | - $template_args['max_atndz'] = $this->getMaxAttendees(); |
|
| 368 | - $template_args['date_format'] = $this->date_format; |
|
| 369 | - $template_args['time_format'] = $this->time_format; |
|
| 370 | - /** |
|
| 371 | - * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected |
|
| 372 | - * |
|
| 373 | - * @since 4.9.13 |
|
| 374 | - * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
|
| 375 | - * @param int $EVT_ID The Event ID |
|
| 376 | - */ |
|
| 377 | - $template_args['anchor_id'] = apply_filters( |
|
| 378 | - 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
|
| 379 | - '#tkt-slctr-tbl-' . $this->event->ID(), |
|
| 380 | - $this->event->ID() |
|
| 381 | - ); |
|
| 382 | - $template_args['tickets'] = $tickets; |
|
| 383 | - $template_args['ticket_count'] = count($tickets); |
|
| 384 | - $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
| 385 | - return $ticket_selector instanceof TicketSelectorSimple |
|
| 386 | - ? $ticket_selector |
|
| 387 | - : new TicketSelectorStandard( |
|
| 388 | - $this->event, |
|
| 389 | - $tickets, |
|
| 390 | - $this->getMaxAttendees(), |
|
| 391 | - $template_args, |
|
| 392 | - $this->date_format, |
|
| 393 | - $this->time_format |
|
| 394 | - ); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * simpleTicketSelector |
|
| 401 | - * there's one ticket, and max attendees is set to one, |
|
| 402 | - * so if the event is free, then this is a "simple" ticket selector |
|
| 403 | - * a.k.a. "Dude Where's my Ticket Selector?" |
|
| 404 | - * |
|
| 405 | - * @param \EE_Ticket[] $tickets |
|
| 406 | - * @param array $template_args |
|
| 407 | - * @return string |
|
| 408 | - * @throws EE_Error |
|
| 409 | - */ |
|
| 410 | - protected function simpleTicketSelector($tickets, array $template_args) |
|
| 411 | - { |
|
| 412 | - // if there is only ONE ticket with a max qty of ONE |
|
| 413 | - if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) { |
|
| 414 | - return ''; |
|
| 415 | - } |
|
| 416 | - /** @var \EE_Ticket $ticket */ |
|
| 417 | - $ticket = reset($tickets); |
|
| 418 | - // if the ticket is free... then not much need for the ticket selector |
|
| 419 | - if ( |
|
| 420 | - apply_filters( |
|
| 421 | - 'FHEE__ticket_selector_chart_template__hide_ticket_selector', |
|
| 422 | - $ticket->is_free(), |
|
| 423 | - $this->event->ID() |
|
| 424 | - ) |
|
| 425 | - ) { |
|
| 426 | - return new TicketSelectorSimple( |
|
| 427 | - $this->event, |
|
| 428 | - $ticket, |
|
| 429 | - $this->getMaxAttendees(), |
|
| 430 | - $template_args |
|
| 431 | - ); |
|
| 432 | - } |
|
| 433 | - return ''; |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * externalEventRegistration |
|
| 440 | - * |
|
| 441 | - * @return string |
|
| 442 | - */ |
|
| 443 | - public function externalEventRegistration() |
|
| 444 | - { |
|
| 445 | - // if not we still need to trigger the display of the submit button |
|
| 446 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 447 | - //display notice to admin that registration is external |
|
| 448 | - return is_admin() |
|
| 449 | - ? esc_html__( |
|
| 450 | - 'Registration is at an external URL for this event.', |
|
| 451 | - 'event_espresso' |
|
| 452 | - ) |
|
| 453 | - : ''; |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - |
|
| 457 | - |
|
| 458 | - /** |
|
| 459 | - * formOpen |
|
| 460 | - * |
|
| 461 | - * @param int $ID |
|
| 462 | - * @param string $external_url |
|
| 463 | - * @return string |
|
| 464 | - */ |
|
| 465 | - public function formOpen( $ID = 0, $external_url = '' ) |
|
| 466 | - { |
|
| 467 | - // if redirecting, we don't need any anything else |
|
| 468 | - if ( $external_url ) { |
|
| 469 | - $html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '"'; |
|
| 470 | - // open link in new window ? |
|
| 471 | - $html .= apply_filters( |
|
| 472 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
|
| 473 | - EED_Events_Archive::is_iframe() |
|
| 474 | - ) |
|
| 475 | - ? ' target="_blank"' |
|
| 476 | - : ''; |
|
| 477 | - $html .= '>'; |
|
| 478 | - $query_args = EEH_URL::get_query_string( $external_url ); |
|
| 479 | - foreach ( (array)$query_args as $query_arg => $value ) { |
|
| 480 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
| 481 | - } |
|
| 482 | - return $html; |
|
| 483 | - } |
|
| 484 | - // if there is no submit button, then don't start building a form |
|
| 485 | - // because the "View Details" button will build its own form |
|
| 486 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
| 487 | - return ''; |
|
| 488 | - } |
|
| 489 | - $checkout_url = EEH_Event_View::event_link_url( $ID ); |
|
| 490 | - if ( ! $checkout_url ) { |
|
| 491 | - EE_Error::add_error( |
|
| 492 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
| 493 | - __FILE__, |
|
| 494 | - __FUNCTION__, |
|
| 495 | - __LINE__ |
|
| 496 | - ); |
|
| 497 | - } |
|
| 498 | - // set no cache headers and constants |
|
| 499 | - EE_System::do_not_cache(); |
|
| 500 | - $extra_params = $this->iframe ? ' target="_blank"' : ''; |
|
| 501 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
| 502 | - $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
|
| 503 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
| 504 | - return $html; |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - |
|
| 508 | - |
|
| 509 | - /** |
|
| 510 | - * displaySubmitButton |
|
| 511 | - * |
|
| 512 | - * @param string $external_url |
|
| 513 | - * @return string |
|
| 514 | - * @throws EE_Error |
|
| 515 | - */ |
|
| 516 | - public function displaySubmitButton($external_url = '') |
|
| 517 | - { |
|
| 518 | - $html = ''; |
|
| 519 | - if ( ! is_admin()) { |
|
| 520 | - // standard TS displayed with submit button, ie: "Register Now" |
|
| 521 | - if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
| 522 | - $html .= $this->displayRegisterNowButton(); |
|
| 523 | - $html .= empty($external_url) |
|
| 524 | - ? $this->ticketSelectorEndDiv() |
|
| 525 | - : $this->clearTicketSelector(); |
|
| 526 | - $html .= '<br/>' . $this->formClose(); |
|
| 527 | - } else if ($this->getMaxAttendees() === 1) { |
|
| 528 | - // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
|
| 529 | - if ($this->event->is_sold_out()) { |
|
| 530 | - // then instead of a View Details or Submit button, just display a "Sold Out" message |
|
| 531 | - $html .= apply_filters( |
|
| 532 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', |
|
| 533 | - sprintf( |
|
| 534 | - __( |
|
| 535 | - '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', |
|
| 536 | - 'event_espresso' |
|
| 537 | - ), |
|
| 538 | - '<p class="no-ticket-selector-msg clear-float">', |
|
| 539 | - $this->event->name(), |
|
| 540 | - '</p>', |
|
| 541 | - '<br />' |
|
| 542 | - ), |
|
| 543 | - $this->event |
|
| 544 | - ); |
|
| 545 | - if ( |
|
| 546 | - apply_filters( |
|
| 547 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
| 548 | - false, |
|
| 549 | - $this->event |
|
| 550 | - ) |
|
| 551 | - ) { |
|
| 552 | - $html .= $this->displayRegisterNowButton(); |
|
| 553 | - } |
|
| 554 | - // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
|
| 555 | - $html .= $this->ticketSelectorEndDiv(); |
|
| 556 | - } else if ( |
|
| 557 | - apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
| 558 | - && ! is_single() |
|
| 559 | - ) { |
|
| 560 | - // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
|
| 561 | - // but no tickets are available, so display event's "View Details" button. |
|
| 562 | - // it is being viewed via somewhere other than a single post |
|
| 563 | - $html .= $this->displayViewDetailsButton(true); |
|
| 564 | - } else { |
|
| 565 | - $html .= $this->ticketSelectorEndDiv(); |
|
| 566 | - } |
|
| 567 | - } else if (is_archive()) { |
|
| 568 | - // event list, no tickets available so display event's "View Details" button |
|
| 569 | - $html .= $this->ticketSelectorEndDiv(); |
|
| 570 | - $html .= $this->displayViewDetailsButton(); |
|
| 571 | - } else { |
|
| 572 | - if ( |
|
| 573 | - apply_filters( |
|
| 574 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
| 575 | - false, |
|
| 576 | - $this->event |
|
| 577 | - ) |
|
| 578 | - ) { |
|
| 579 | - $html .= $this->displayRegisterNowButton(); |
|
| 580 | - } |
|
| 581 | - // no submit or view details button, and no additional content |
|
| 582 | - $html .= $this->ticketSelectorEndDiv(); |
|
| 583 | - } |
|
| 584 | - if ( ! $this->iframe && ! is_archive()) { |
|
| 585 | - $html .= EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector')); |
|
| 586 | - } |
|
| 587 | - } |
|
| 588 | - return apply_filters( |
|
| 589 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displaySubmitButton__html', |
|
| 590 | - $html, |
|
| 591 | - $this->event |
|
| 592 | - ); |
|
| 593 | - } |
|
| 594 | - |
|
| 595 | - |
|
| 596 | - |
|
| 597 | - /** |
|
| 598 | - * @return string |
|
| 599 | - * @throws EE_Error |
|
| 600 | - */ |
|
| 601 | - public function displayRegisterNowButton() |
|
| 602 | - { |
|
| 603 | - $btn_text = apply_filters( |
|
| 604 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
|
| 605 | - __('Register Now', 'event_espresso'), |
|
| 606 | - $this->event |
|
| 607 | - ); |
|
| 608 | - $external_url = $this->event->external_url(); |
|
| 609 | - $html = EEH_HTML::div( |
|
| 610 | - '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
| 611 | - ); |
|
| 612 | - $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
| 613 | - $html .= ' class="ticket-selector-submit-btn '; |
|
| 614 | - $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
| 615 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
| 616 | - $html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->'; |
|
| 617 | - $html .= apply_filters( |
|
| 618 | - 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
| 619 | - '', |
|
| 620 | - $this->event |
|
| 621 | - ); |
|
| 622 | - return $html; |
|
| 623 | - } |
|
| 624 | - |
|
| 625 | - |
|
| 626 | - /** |
|
| 627 | - * displayViewDetailsButton |
|
| 628 | - * |
|
| 629 | - * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event |
|
| 630 | - * (ie: $_max_atndz === 1) where there are no available tickets, |
|
| 631 | - * either because they are sold out, expired, or not yet on sale. |
|
| 632 | - * In this case, we need to close the form BEFORE adding any closing divs |
|
| 633 | - * @return string |
|
| 634 | - * @throws EE_Error |
|
| 635 | - */ |
|
| 636 | - public function displayViewDetailsButton( $DWMTS = false ) |
|
| 637 | - { |
|
| 638 | - if ( ! $this->event->get_permalink() ) { |
|
| 639 | - EE_Error::add_error( |
|
| 640 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
| 641 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 642 | - ); |
|
| 643 | - } |
|
| 644 | - $view_details_btn = '<form method="POST" action="'; |
|
| 645 | - $view_details_btn .= apply_filters( |
|
| 646 | - 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url', |
|
| 647 | - $this->event->get_permalink(), |
|
| 648 | - $this->event |
|
| 649 | - ); |
|
| 650 | - $view_details_btn .= '"'; |
|
| 651 | - // open link in new window ? |
|
| 652 | - $view_details_btn .= apply_filters( |
|
| 653 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank', |
|
| 654 | - EED_Events_Archive::is_iframe() |
|
| 655 | - ) |
|
| 656 | - ? ' target="_blank"' |
|
| 657 | - : ''; |
|
| 658 | - $view_details_btn .='>'; |
|
| 659 | - $btn_text = apply_filters( |
|
| 660 | - 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
|
| 661 | - esc_html__('View Details', 'event_espresso'), |
|
| 662 | - $this->event |
|
| 663 | - ); |
|
| 664 | - $view_details_btn .= '<input id="ticket-selector-submit-' |
|
| 665 | - . $this->event->ID() |
|
| 666 | - . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
|
| 667 | - . $btn_text |
|
| 668 | - . '" />'; |
|
| 669 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
| 670 | - if ($DWMTS) { |
|
| 671 | - $view_details_btn .= $this->formClose(); |
|
| 672 | - $view_details_btn .= $this->ticketSelectorEndDiv(); |
|
| 673 | - $view_details_btn .= '<br/>'; |
|
| 674 | - } else { |
|
| 675 | - $view_details_btn .= $this->clearTicketSelector(); |
|
| 676 | - $view_details_btn .= '<br/>'; |
|
| 677 | - $view_details_btn .= $this->formClose(); |
|
| 678 | - } |
|
| 679 | - return $view_details_btn; |
|
| 680 | - } |
|
| 681 | - |
|
| 682 | - |
|
| 683 | - |
|
| 684 | - /** |
|
| 685 | - * @return string |
|
| 686 | - */ |
|
| 687 | - public function ticketSelectorEndDiv() |
|
| 688 | - { |
|
| 689 | - return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->'; |
|
| 690 | - } |
|
| 691 | - |
|
| 692 | - |
|
| 693 | - |
|
| 694 | - /** |
|
| 695 | - * @return string |
|
| 696 | - */ |
|
| 697 | - public function clearTicketSelector() |
|
| 698 | - { |
|
| 699 | - // standard TS displayed, appears after a "Register Now" or "view Details" button |
|
| 700 | - return '<div class="clear"></div><!-- clearTicketSelector -->'; |
|
| 701 | - } |
|
| 702 | - |
|
| 703 | - |
|
| 704 | - |
|
| 705 | - /** |
|
| 706 | - * @access public |
|
| 707 | - * @return string |
|
| 708 | - */ |
|
| 709 | - public function formClose() |
|
| 710 | - { |
|
| 711 | - return '</form>'; |
|
| 712 | - } |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * ticketSalesClosed |
|
| 294 | + * notice displayed if event ticket sales are turned off |
|
| 295 | + * |
|
| 296 | + * @return string |
|
| 297 | + * @throws EE_Error |
|
| 298 | + */ |
|
| 299 | + protected function ticketSalesClosedMessage() |
|
| 300 | + { |
|
| 301 | + $sales_closed_msg = esc_html__( |
|
| 302 | + 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
|
| 303 | + 'event_espresso' |
|
| 304 | + ); |
|
| 305 | + if (current_user_can('edit_post', $this->event->ID())) { |
|
| 306 | + $sales_closed_msg .= sprintf( |
|
| 307 | + esc_html__( |
|
| 308 | + '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
|
| 309 | + 'event_espresso' |
|
| 310 | + ), |
|
| 311 | + '<div class="ee-attention" style="text-align: left;"><b>', |
|
| 312 | + '</b><br />', |
|
| 313 | + '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
| 314 | + '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->' |
|
| 315 | + ); |
|
| 316 | + } |
|
| 317 | + return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * getTickets |
|
| 324 | + * |
|
| 325 | + * @return \EE_Base_Class[]|\EE_Ticket[] |
|
| 326 | + * @throws EE_Error |
|
| 327 | + */ |
|
| 328 | + protected function getTickets() |
|
| 329 | + { |
|
| 330 | + $ticket_query_args = array( |
|
| 331 | + array('Datetime.EVT_ID' => $this->event->ID()), |
|
| 332 | + 'order_by' => array( |
|
| 333 | + 'TKT_order' => 'ASC', |
|
| 334 | + 'TKT_required' => 'DESC', |
|
| 335 | + 'TKT_start_date' => 'ASC', |
|
| 336 | + 'TKT_end_date' => 'ASC', |
|
| 337 | + 'Datetime.DTT_EVT_start' => 'DESC', |
|
| 338 | + ), |
|
| 339 | + ); |
|
| 340 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
| 341 | + //use the correct applicable time query depending on what version of core is being run. |
|
| 342 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
|
| 343 | + ? time() |
|
| 344 | + : current_time('timestamp'); |
|
| 345 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
| 346 | + } |
|
| 347 | + return EEM_Ticket::instance()->get_all($ticket_query_args); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * loadTicketSelector |
|
| 354 | + * begins to assemble template arguments |
|
| 355 | + * and decides whether to load a "simple" ticket selector, or the standard |
|
| 356 | + * |
|
| 357 | + * @param \EE_Ticket[] $tickets |
|
| 358 | + * @param array $template_args |
|
| 359 | + * @return string |
|
| 360 | + * @throws EE_Error |
|
| 361 | + */ |
|
| 362 | + protected function loadTicketSelector(array $tickets, array $template_args) |
|
| 363 | + { |
|
| 364 | + $template_args['event'] = $this->event; |
|
| 365 | + $template_args['EVT_ID'] = $this->event->ID(); |
|
| 366 | + $template_args['event_is_expired'] = $this->event->is_expired(); |
|
| 367 | + $template_args['max_atndz'] = $this->getMaxAttendees(); |
|
| 368 | + $template_args['date_format'] = $this->date_format; |
|
| 369 | + $template_args['time_format'] = $this->time_format; |
|
| 370 | + /** |
|
| 371 | + * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected |
|
| 372 | + * |
|
| 373 | + * @since 4.9.13 |
|
| 374 | + * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
|
| 375 | + * @param int $EVT_ID The Event ID |
|
| 376 | + */ |
|
| 377 | + $template_args['anchor_id'] = apply_filters( |
|
| 378 | + 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
|
| 379 | + '#tkt-slctr-tbl-' . $this->event->ID(), |
|
| 380 | + $this->event->ID() |
|
| 381 | + ); |
|
| 382 | + $template_args['tickets'] = $tickets; |
|
| 383 | + $template_args['ticket_count'] = count($tickets); |
|
| 384 | + $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
| 385 | + return $ticket_selector instanceof TicketSelectorSimple |
|
| 386 | + ? $ticket_selector |
|
| 387 | + : new TicketSelectorStandard( |
|
| 388 | + $this->event, |
|
| 389 | + $tickets, |
|
| 390 | + $this->getMaxAttendees(), |
|
| 391 | + $template_args, |
|
| 392 | + $this->date_format, |
|
| 393 | + $this->time_format |
|
| 394 | + ); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * simpleTicketSelector |
|
| 401 | + * there's one ticket, and max attendees is set to one, |
|
| 402 | + * so if the event is free, then this is a "simple" ticket selector |
|
| 403 | + * a.k.a. "Dude Where's my Ticket Selector?" |
|
| 404 | + * |
|
| 405 | + * @param \EE_Ticket[] $tickets |
|
| 406 | + * @param array $template_args |
|
| 407 | + * @return string |
|
| 408 | + * @throws EE_Error |
|
| 409 | + */ |
|
| 410 | + protected function simpleTicketSelector($tickets, array $template_args) |
|
| 411 | + { |
|
| 412 | + // if there is only ONE ticket with a max qty of ONE |
|
| 413 | + if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) { |
|
| 414 | + return ''; |
|
| 415 | + } |
|
| 416 | + /** @var \EE_Ticket $ticket */ |
|
| 417 | + $ticket = reset($tickets); |
|
| 418 | + // if the ticket is free... then not much need for the ticket selector |
|
| 419 | + if ( |
|
| 420 | + apply_filters( |
|
| 421 | + 'FHEE__ticket_selector_chart_template__hide_ticket_selector', |
|
| 422 | + $ticket->is_free(), |
|
| 423 | + $this->event->ID() |
|
| 424 | + ) |
|
| 425 | + ) { |
|
| 426 | + return new TicketSelectorSimple( |
|
| 427 | + $this->event, |
|
| 428 | + $ticket, |
|
| 429 | + $this->getMaxAttendees(), |
|
| 430 | + $template_args |
|
| 431 | + ); |
|
| 432 | + } |
|
| 433 | + return ''; |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * externalEventRegistration |
|
| 440 | + * |
|
| 441 | + * @return string |
|
| 442 | + */ |
|
| 443 | + public function externalEventRegistration() |
|
| 444 | + { |
|
| 445 | + // if not we still need to trigger the display of the submit button |
|
| 446 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 447 | + //display notice to admin that registration is external |
|
| 448 | + return is_admin() |
|
| 449 | + ? esc_html__( |
|
| 450 | + 'Registration is at an external URL for this event.', |
|
| 451 | + 'event_espresso' |
|
| 452 | + ) |
|
| 453 | + : ''; |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + |
|
| 457 | + |
|
| 458 | + /** |
|
| 459 | + * formOpen |
|
| 460 | + * |
|
| 461 | + * @param int $ID |
|
| 462 | + * @param string $external_url |
|
| 463 | + * @return string |
|
| 464 | + */ |
|
| 465 | + public function formOpen( $ID = 0, $external_url = '' ) |
|
| 466 | + { |
|
| 467 | + // if redirecting, we don't need any anything else |
|
| 468 | + if ( $external_url ) { |
|
| 469 | + $html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '"'; |
|
| 470 | + // open link in new window ? |
|
| 471 | + $html .= apply_filters( |
|
| 472 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
|
| 473 | + EED_Events_Archive::is_iframe() |
|
| 474 | + ) |
|
| 475 | + ? ' target="_blank"' |
|
| 476 | + : ''; |
|
| 477 | + $html .= '>'; |
|
| 478 | + $query_args = EEH_URL::get_query_string( $external_url ); |
|
| 479 | + foreach ( (array)$query_args as $query_arg => $value ) { |
|
| 480 | + $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
| 481 | + } |
|
| 482 | + return $html; |
|
| 483 | + } |
|
| 484 | + // if there is no submit button, then don't start building a form |
|
| 485 | + // because the "View Details" button will build its own form |
|
| 486 | + if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
| 487 | + return ''; |
|
| 488 | + } |
|
| 489 | + $checkout_url = EEH_Event_View::event_link_url( $ID ); |
|
| 490 | + if ( ! $checkout_url ) { |
|
| 491 | + EE_Error::add_error( |
|
| 492 | + esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
| 493 | + __FILE__, |
|
| 494 | + __FUNCTION__, |
|
| 495 | + __LINE__ |
|
| 496 | + ); |
|
| 497 | + } |
|
| 498 | + // set no cache headers and constants |
|
| 499 | + EE_System::do_not_cache(); |
|
| 500 | + $extra_params = $this->iframe ? ' target="_blank"' : ''; |
|
| 501 | + $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
| 502 | + $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
|
| 503 | + $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
| 504 | + return $html; |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + |
|
| 508 | + |
|
| 509 | + /** |
|
| 510 | + * displaySubmitButton |
|
| 511 | + * |
|
| 512 | + * @param string $external_url |
|
| 513 | + * @return string |
|
| 514 | + * @throws EE_Error |
|
| 515 | + */ |
|
| 516 | + public function displaySubmitButton($external_url = '') |
|
| 517 | + { |
|
| 518 | + $html = ''; |
|
| 519 | + if ( ! is_admin()) { |
|
| 520 | + // standard TS displayed with submit button, ie: "Register Now" |
|
| 521 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
| 522 | + $html .= $this->displayRegisterNowButton(); |
|
| 523 | + $html .= empty($external_url) |
|
| 524 | + ? $this->ticketSelectorEndDiv() |
|
| 525 | + : $this->clearTicketSelector(); |
|
| 526 | + $html .= '<br/>' . $this->formClose(); |
|
| 527 | + } else if ($this->getMaxAttendees() === 1) { |
|
| 528 | + // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
|
| 529 | + if ($this->event->is_sold_out()) { |
|
| 530 | + // then instead of a View Details or Submit button, just display a "Sold Out" message |
|
| 531 | + $html .= apply_filters( |
|
| 532 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', |
|
| 533 | + sprintf( |
|
| 534 | + __( |
|
| 535 | + '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', |
|
| 536 | + 'event_espresso' |
|
| 537 | + ), |
|
| 538 | + '<p class="no-ticket-selector-msg clear-float">', |
|
| 539 | + $this->event->name(), |
|
| 540 | + '</p>', |
|
| 541 | + '<br />' |
|
| 542 | + ), |
|
| 543 | + $this->event |
|
| 544 | + ); |
|
| 545 | + if ( |
|
| 546 | + apply_filters( |
|
| 547 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
| 548 | + false, |
|
| 549 | + $this->event |
|
| 550 | + ) |
|
| 551 | + ) { |
|
| 552 | + $html .= $this->displayRegisterNowButton(); |
|
| 553 | + } |
|
| 554 | + // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
|
| 555 | + $html .= $this->ticketSelectorEndDiv(); |
|
| 556 | + } else if ( |
|
| 557 | + apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
| 558 | + && ! is_single() |
|
| 559 | + ) { |
|
| 560 | + // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
|
| 561 | + // but no tickets are available, so display event's "View Details" button. |
|
| 562 | + // it is being viewed via somewhere other than a single post |
|
| 563 | + $html .= $this->displayViewDetailsButton(true); |
|
| 564 | + } else { |
|
| 565 | + $html .= $this->ticketSelectorEndDiv(); |
|
| 566 | + } |
|
| 567 | + } else if (is_archive()) { |
|
| 568 | + // event list, no tickets available so display event's "View Details" button |
|
| 569 | + $html .= $this->ticketSelectorEndDiv(); |
|
| 570 | + $html .= $this->displayViewDetailsButton(); |
|
| 571 | + } else { |
|
| 572 | + if ( |
|
| 573 | + apply_filters( |
|
| 574 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
| 575 | + false, |
|
| 576 | + $this->event |
|
| 577 | + ) |
|
| 578 | + ) { |
|
| 579 | + $html .= $this->displayRegisterNowButton(); |
|
| 580 | + } |
|
| 581 | + // no submit or view details button, and no additional content |
|
| 582 | + $html .= $this->ticketSelectorEndDiv(); |
|
| 583 | + } |
|
| 584 | + if ( ! $this->iframe && ! is_archive()) { |
|
| 585 | + $html .= EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector')); |
|
| 586 | + } |
|
| 587 | + } |
|
| 588 | + return apply_filters( |
|
| 589 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displaySubmitButton__html', |
|
| 590 | + $html, |
|
| 591 | + $this->event |
|
| 592 | + ); |
|
| 593 | + } |
|
| 594 | + |
|
| 595 | + |
|
| 596 | + |
|
| 597 | + /** |
|
| 598 | + * @return string |
|
| 599 | + * @throws EE_Error |
|
| 600 | + */ |
|
| 601 | + public function displayRegisterNowButton() |
|
| 602 | + { |
|
| 603 | + $btn_text = apply_filters( |
|
| 604 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
|
| 605 | + __('Register Now', 'event_espresso'), |
|
| 606 | + $this->event |
|
| 607 | + ); |
|
| 608 | + $external_url = $this->event->external_url(); |
|
| 609 | + $html = EEH_HTML::div( |
|
| 610 | + '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
| 611 | + ); |
|
| 612 | + $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
| 613 | + $html .= ' class="ticket-selector-submit-btn '; |
|
| 614 | + $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
| 615 | + $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
| 616 | + $html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->'; |
|
| 617 | + $html .= apply_filters( |
|
| 618 | + 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
| 619 | + '', |
|
| 620 | + $this->event |
|
| 621 | + ); |
|
| 622 | + return $html; |
|
| 623 | + } |
|
| 624 | + |
|
| 625 | + |
|
| 626 | + /** |
|
| 627 | + * displayViewDetailsButton |
|
| 628 | + * |
|
| 629 | + * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event |
|
| 630 | + * (ie: $_max_atndz === 1) where there are no available tickets, |
|
| 631 | + * either because they are sold out, expired, or not yet on sale. |
|
| 632 | + * In this case, we need to close the form BEFORE adding any closing divs |
|
| 633 | + * @return string |
|
| 634 | + * @throws EE_Error |
|
| 635 | + */ |
|
| 636 | + public function displayViewDetailsButton( $DWMTS = false ) |
|
| 637 | + { |
|
| 638 | + if ( ! $this->event->get_permalink() ) { |
|
| 639 | + EE_Error::add_error( |
|
| 640 | + esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
| 641 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 642 | + ); |
|
| 643 | + } |
|
| 644 | + $view_details_btn = '<form method="POST" action="'; |
|
| 645 | + $view_details_btn .= apply_filters( |
|
| 646 | + 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url', |
|
| 647 | + $this->event->get_permalink(), |
|
| 648 | + $this->event |
|
| 649 | + ); |
|
| 650 | + $view_details_btn .= '"'; |
|
| 651 | + // open link in new window ? |
|
| 652 | + $view_details_btn .= apply_filters( |
|
| 653 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank', |
|
| 654 | + EED_Events_Archive::is_iframe() |
|
| 655 | + ) |
|
| 656 | + ? ' target="_blank"' |
|
| 657 | + : ''; |
|
| 658 | + $view_details_btn .='>'; |
|
| 659 | + $btn_text = apply_filters( |
|
| 660 | + 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
|
| 661 | + esc_html__('View Details', 'event_espresso'), |
|
| 662 | + $this->event |
|
| 663 | + ); |
|
| 664 | + $view_details_btn .= '<input id="ticket-selector-submit-' |
|
| 665 | + . $this->event->ID() |
|
| 666 | + . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
|
| 667 | + . $btn_text |
|
| 668 | + . '" />'; |
|
| 669 | + $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
| 670 | + if ($DWMTS) { |
|
| 671 | + $view_details_btn .= $this->formClose(); |
|
| 672 | + $view_details_btn .= $this->ticketSelectorEndDiv(); |
|
| 673 | + $view_details_btn .= '<br/>'; |
|
| 674 | + } else { |
|
| 675 | + $view_details_btn .= $this->clearTicketSelector(); |
|
| 676 | + $view_details_btn .= '<br/>'; |
|
| 677 | + $view_details_btn .= $this->formClose(); |
|
| 678 | + } |
|
| 679 | + return $view_details_btn; |
|
| 680 | + } |
|
| 681 | + |
|
| 682 | + |
|
| 683 | + |
|
| 684 | + /** |
|
| 685 | + * @return string |
|
| 686 | + */ |
|
| 687 | + public function ticketSelectorEndDiv() |
|
| 688 | + { |
|
| 689 | + return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->'; |
|
| 690 | + } |
|
| 691 | + |
|
| 692 | + |
|
| 693 | + |
|
| 694 | + /** |
|
| 695 | + * @return string |
|
| 696 | + */ |
|
| 697 | + public function clearTicketSelector() |
|
| 698 | + { |
|
| 699 | + // standard TS displayed, appears after a "Register Now" or "view Details" button |
|
| 700 | + return '<div class="clear"></div><!-- clearTicketSelector -->'; |
|
| 701 | + } |
|
| 702 | + |
|
| 703 | + |
|
| 704 | + |
|
| 705 | + /** |
|
| 706 | + * @access public |
|
| 707 | + * @return string |
|
| 708 | + */ |
|
| 709 | + public function formClose() |
|
| 710 | + { |
|
| 711 | + return '</form>'; |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | 714 | |
| 715 | 715 | |
@@ -15,2694 +15,2694 @@ |
||
| 15 | 15 | class Events_Admin_Page extends EE_Admin_Page_CPT |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * This will hold the event object for event_details screen. |
|
| 20 | - * |
|
| 21 | - * @access protected |
|
| 22 | - * @var EE_Event $_event |
|
| 23 | - */ |
|
| 24 | - protected $_event; |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * This will hold the category object for category_details screen. |
|
| 29 | - * |
|
| 30 | - * @var stdClass $_category |
|
| 31 | - */ |
|
| 32 | - protected $_category; |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * This will hold the event model instance |
|
| 37 | - * |
|
| 38 | - * @var EEM_Event $_event_model |
|
| 39 | - */ |
|
| 40 | - protected $_event_model; |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @var EE_Event |
|
| 46 | - */ |
|
| 47 | - protected $_cpt_model_obj = false; |
|
| 48 | - |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Initialize page props for this admin page group. |
|
| 52 | - */ |
|
| 53 | - protected function _init_page_props() |
|
| 54 | - { |
|
| 55 | - $this->page_slug = EVENTS_PG_SLUG; |
|
| 56 | - $this->page_label = EVENTS_LABEL; |
|
| 57 | - $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
| 58 | - $this->_admin_base_path = EVENTS_ADMIN; |
|
| 59 | - $this->_cpt_model_names = array( |
|
| 60 | - 'create_new' => 'EEM_Event', |
|
| 61 | - 'edit' => 'EEM_Event', |
|
| 62 | - ); |
|
| 63 | - $this->_cpt_edit_routes = array( |
|
| 64 | - 'espresso_events' => 'edit', |
|
| 65 | - ); |
|
| 66 | - add_action( |
|
| 67 | - 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
| 68 | - array($this, 'verify_event_edit'), 10, 2 |
|
| 69 | - ); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Sets the ajax hooks used for this admin page group. |
|
| 75 | - */ |
|
| 76 | - protected function _ajax_hooks() |
|
| 77 | - { |
|
| 78 | - add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting')); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Sets the page properties for this admin page group. |
|
| 84 | - */ |
|
| 85 | - protected function _define_page_props() |
|
| 86 | - { |
|
| 87 | - $this->_admin_page_title = EVENTS_LABEL; |
|
| 88 | - $this->_labels = array( |
|
| 89 | - 'buttons' => array( |
|
| 90 | - 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
| 91 | - 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
| 92 | - 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
| 93 | - 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
| 94 | - 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
| 95 | - 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
| 96 | - ), |
|
| 97 | - 'editor_title' => array( |
|
| 98 | - 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
| 99 | - ), |
|
| 100 | - 'publishbox' => array( |
|
| 101 | - 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
| 102 | - 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
| 103 | - 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
| 104 | - 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
| 105 | - 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
| 106 | - ), |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Sets the page routes property for this admin page group. |
|
| 113 | - */ |
|
| 114 | - protected function _set_page_routes() |
|
| 115 | - { |
|
| 116 | - //load formatter helper |
|
| 117 | - //load field generator helper |
|
| 118 | - //is there a evt_id in the request? |
|
| 119 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
| 120 | - ? $this->_req_data['EVT_ID'] |
|
| 121 | - : 0; |
|
| 122 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
| 123 | - $this->_page_routes = array( |
|
| 124 | - 'default' => array( |
|
| 125 | - 'func' => '_events_overview_list_table', |
|
| 126 | - 'capability' => 'ee_read_events', |
|
| 127 | - ), |
|
| 128 | - 'create_new' => array( |
|
| 129 | - 'func' => '_create_new_cpt_item', |
|
| 130 | - 'capability' => 'ee_edit_events', |
|
| 131 | - ), |
|
| 132 | - 'edit' => array( |
|
| 133 | - 'func' => '_edit_cpt_item', |
|
| 134 | - 'capability' => 'ee_edit_event', |
|
| 135 | - 'obj_id' => $evt_id, |
|
| 136 | - ), |
|
| 137 | - 'copy_event' => array( |
|
| 138 | - 'func' => '_copy_events', |
|
| 139 | - 'capability' => 'ee_edit_event', |
|
| 140 | - 'obj_id' => $evt_id, |
|
| 141 | - 'noheader' => true, |
|
| 142 | - ), |
|
| 143 | - 'trash_event' => array( |
|
| 144 | - 'func' => '_trash_or_restore_event', |
|
| 145 | - 'args' => array('event_status' => 'trash'), |
|
| 146 | - 'capability' => 'ee_delete_event', |
|
| 147 | - 'obj_id' => $evt_id, |
|
| 148 | - 'noheader' => true, |
|
| 149 | - ), |
|
| 150 | - 'trash_events' => array( |
|
| 151 | - 'func' => '_trash_or_restore_events', |
|
| 152 | - 'args' => array('event_status' => 'trash'), |
|
| 153 | - 'capability' => 'ee_delete_events', |
|
| 154 | - 'noheader' => true, |
|
| 155 | - ), |
|
| 156 | - 'restore_event' => array( |
|
| 157 | - 'func' => '_trash_or_restore_event', |
|
| 158 | - 'args' => array('event_status' => 'draft'), |
|
| 159 | - 'capability' => 'ee_delete_event', |
|
| 160 | - 'obj_id' => $evt_id, |
|
| 161 | - 'noheader' => true, |
|
| 162 | - ), |
|
| 163 | - 'restore_events' => array( |
|
| 164 | - 'func' => '_trash_or_restore_events', |
|
| 165 | - 'args' => array('event_status' => 'draft'), |
|
| 166 | - 'capability' => 'ee_delete_events', |
|
| 167 | - 'noheader' => true, |
|
| 168 | - ), |
|
| 169 | - 'delete_event' => array( |
|
| 170 | - 'func' => '_delete_event', |
|
| 171 | - 'capability' => 'ee_delete_event', |
|
| 172 | - 'obj_id' => $evt_id, |
|
| 173 | - 'noheader' => true, |
|
| 174 | - ), |
|
| 175 | - 'delete_events' => array( |
|
| 176 | - 'func' => '_delete_events', |
|
| 177 | - 'capability' => 'ee_delete_events', |
|
| 178 | - 'noheader' => true, |
|
| 179 | - ), |
|
| 180 | - 'view_report' => array( |
|
| 181 | - 'func' => '_view_report', |
|
| 182 | - 'capablity' => 'ee_edit_events', |
|
| 183 | - ), |
|
| 184 | - 'default_event_settings' => array( |
|
| 185 | - 'func' => '_default_event_settings', |
|
| 186 | - 'capability' => 'manage_options', |
|
| 187 | - ), |
|
| 188 | - 'update_default_event_settings' => array( |
|
| 189 | - 'func' => '_update_default_event_settings', |
|
| 190 | - 'capability' => 'manage_options', |
|
| 191 | - 'noheader' => true, |
|
| 192 | - ), |
|
| 193 | - 'template_settings' => array( |
|
| 194 | - 'func' => '_template_settings', |
|
| 195 | - 'capability' => 'manage_options', |
|
| 196 | - ), |
|
| 197 | - //event category tab related |
|
| 198 | - 'add_category' => array( |
|
| 199 | - 'func' => '_category_details', |
|
| 200 | - 'capability' => 'ee_edit_event_category', |
|
| 201 | - 'args' => array('add'), |
|
| 202 | - ), |
|
| 203 | - 'edit_category' => array( |
|
| 204 | - 'func' => '_category_details', |
|
| 205 | - 'capability' => 'ee_edit_event_category', |
|
| 206 | - 'args' => array('edit'), |
|
| 207 | - ), |
|
| 208 | - 'delete_categories' => array( |
|
| 209 | - 'func' => '_delete_categories', |
|
| 210 | - 'capability' => 'ee_delete_event_category', |
|
| 211 | - 'noheader' => true, |
|
| 212 | - ), |
|
| 213 | - 'delete_category' => array( |
|
| 214 | - 'func' => '_delete_categories', |
|
| 215 | - 'capability' => 'ee_delete_event_category', |
|
| 216 | - 'noheader' => true, |
|
| 217 | - ), |
|
| 218 | - 'insert_category' => array( |
|
| 219 | - 'func' => '_insert_or_update_category', |
|
| 220 | - 'args' => array('new_category' => true), |
|
| 221 | - 'capability' => 'ee_edit_event_category', |
|
| 222 | - 'noheader' => true, |
|
| 223 | - ), |
|
| 224 | - 'update_category' => array( |
|
| 225 | - 'func' => '_insert_or_update_category', |
|
| 226 | - 'args' => array('new_category' => false), |
|
| 227 | - 'capability' => 'ee_edit_event_category', |
|
| 228 | - 'noheader' => true, |
|
| 229 | - ), |
|
| 230 | - 'category_list' => array( |
|
| 231 | - 'func' => '_category_list_table', |
|
| 232 | - 'capability' => 'ee_manage_event_categories', |
|
| 233 | - ), |
|
| 234 | - ); |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Set the _page_config property for this admin page group. |
|
| 240 | - */ |
|
| 241 | - protected function _set_page_config() |
|
| 242 | - { |
|
| 243 | - $this->_page_config = array( |
|
| 244 | - 'default' => array( |
|
| 245 | - 'nav' => array( |
|
| 246 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 247 | - 'order' => 10, |
|
| 248 | - ), |
|
| 249 | - 'list_table' => 'Events_Admin_List_Table', |
|
| 250 | - 'help_tabs' => array( |
|
| 251 | - 'events_overview_help_tab' => array( |
|
| 252 | - 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
| 253 | - 'filename' => 'events_overview', |
|
| 254 | - ), |
|
| 255 | - 'events_overview_table_column_headings_help_tab' => array( |
|
| 256 | - 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
| 257 | - 'filename' => 'events_overview_table_column_headings', |
|
| 258 | - ), |
|
| 259 | - 'events_overview_filters_help_tab' => array( |
|
| 260 | - 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
| 261 | - 'filename' => 'events_overview_filters', |
|
| 262 | - ), |
|
| 263 | - 'events_overview_view_help_tab' => array( |
|
| 264 | - 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
| 265 | - 'filename' => 'events_overview_views', |
|
| 266 | - ), |
|
| 267 | - 'events_overview_other_help_tab' => array( |
|
| 268 | - 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
| 269 | - 'filename' => 'events_overview_other', |
|
| 270 | - ), |
|
| 271 | - ), |
|
| 272 | - 'help_tour' => array( |
|
| 273 | - 'Event_Overview_Help_Tour', |
|
| 274 | - //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
| 275 | - ), |
|
| 276 | - 'qtips' => array( |
|
| 277 | - 'EE_Event_List_Table_Tips', |
|
| 278 | - ), |
|
| 279 | - 'require_nonce' => false, |
|
| 280 | - ), |
|
| 281 | - 'create_new' => array( |
|
| 282 | - 'nav' => array( |
|
| 283 | - 'label' => esc_html__('Add Event', 'event_espresso'), |
|
| 284 | - 'order' => 5, |
|
| 285 | - 'persistent' => false, |
|
| 286 | - ), |
|
| 287 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
| 288 | - 'help_tabs' => array( |
|
| 289 | - 'event_editor_help_tab' => array( |
|
| 290 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 291 | - 'filename' => 'event_editor', |
|
| 292 | - ), |
|
| 293 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
| 294 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 295 | - 'filename' => 'event_editor_title_richtexteditor', |
|
| 296 | - ), |
|
| 297 | - 'event_editor_venue_details_help_tab' => array( |
|
| 298 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 299 | - 'filename' => 'event_editor_venue_details', |
|
| 300 | - ), |
|
| 301 | - 'event_editor_event_datetimes_help_tab' => array( |
|
| 302 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 303 | - 'filename' => 'event_editor_event_datetimes', |
|
| 304 | - ), |
|
| 305 | - 'event_editor_event_tickets_help_tab' => array( |
|
| 306 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 307 | - 'filename' => 'event_editor_event_tickets', |
|
| 308 | - ), |
|
| 309 | - 'event_editor_event_registration_options_help_tab' => array( |
|
| 310 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 311 | - 'filename' => 'event_editor_event_registration_options', |
|
| 312 | - ), |
|
| 313 | - 'event_editor_tags_categories_help_tab' => array( |
|
| 314 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 315 | - 'filename' => 'event_editor_tags_categories', |
|
| 316 | - ), |
|
| 317 | - 'event_editor_questions_registrants_help_tab' => array( |
|
| 318 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 319 | - 'filename' => 'event_editor_questions_registrants', |
|
| 320 | - ), |
|
| 321 | - 'event_editor_save_new_event_help_tab' => array( |
|
| 322 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 323 | - 'filename' => 'event_editor_save_new_event', |
|
| 324 | - ), |
|
| 325 | - 'event_editor_other_help_tab' => array( |
|
| 326 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 327 | - 'filename' => 'event_editor_other', |
|
| 328 | - ), |
|
| 329 | - ), |
|
| 330 | - 'help_tour' => array( |
|
| 331 | - 'Event_Editor_Help_Tour', |
|
| 332 | - ), |
|
| 333 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
| 334 | - 'require_nonce' => false, |
|
| 335 | - ), |
|
| 336 | - 'edit' => array( |
|
| 337 | - 'nav' => array( |
|
| 338 | - 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
| 339 | - 'order' => 5, |
|
| 340 | - 'persistent' => false, |
|
| 341 | - 'url' => isset($this->_req_data['post']) |
|
| 342 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 343 | - array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
| 344 | - $this->_current_page_view_url |
|
| 345 | - ) |
|
| 346 | - : $this->_admin_base_url, |
|
| 347 | - ), |
|
| 348 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
| 349 | - 'help_tabs' => array( |
|
| 350 | - 'event_editor_help_tab' => array( |
|
| 351 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 352 | - 'filename' => 'event_editor', |
|
| 353 | - ), |
|
| 354 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
| 355 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 356 | - 'filename' => 'event_editor_title_richtexteditor', |
|
| 357 | - ), |
|
| 358 | - 'event_editor_venue_details_help_tab' => array( |
|
| 359 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 360 | - 'filename' => 'event_editor_venue_details', |
|
| 361 | - ), |
|
| 362 | - 'event_editor_event_datetimes_help_tab' => array( |
|
| 363 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 364 | - 'filename' => 'event_editor_event_datetimes', |
|
| 365 | - ), |
|
| 366 | - 'event_editor_event_tickets_help_tab' => array( |
|
| 367 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 368 | - 'filename' => 'event_editor_event_tickets', |
|
| 369 | - ), |
|
| 370 | - 'event_editor_event_registration_options_help_tab' => array( |
|
| 371 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 372 | - 'filename' => 'event_editor_event_registration_options', |
|
| 373 | - ), |
|
| 374 | - 'event_editor_tags_categories_help_tab' => array( |
|
| 375 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 376 | - 'filename' => 'event_editor_tags_categories', |
|
| 377 | - ), |
|
| 378 | - 'event_editor_questions_registrants_help_tab' => array( |
|
| 379 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 380 | - 'filename' => 'event_editor_questions_registrants', |
|
| 381 | - ), |
|
| 382 | - 'event_editor_save_new_event_help_tab' => array( |
|
| 383 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 384 | - 'filename' => 'event_editor_save_new_event', |
|
| 385 | - ), |
|
| 386 | - 'event_editor_other_help_tab' => array( |
|
| 387 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 388 | - 'filename' => 'event_editor_other', |
|
| 389 | - ), |
|
| 390 | - ), |
|
| 391 | - /*'help_tour' => array( |
|
| 18 | + /** |
|
| 19 | + * This will hold the event object for event_details screen. |
|
| 20 | + * |
|
| 21 | + * @access protected |
|
| 22 | + * @var EE_Event $_event |
|
| 23 | + */ |
|
| 24 | + protected $_event; |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * This will hold the category object for category_details screen. |
|
| 29 | + * |
|
| 30 | + * @var stdClass $_category |
|
| 31 | + */ |
|
| 32 | + protected $_category; |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * This will hold the event model instance |
|
| 37 | + * |
|
| 38 | + * @var EEM_Event $_event_model |
|
| 39 | + */ |
|
| 40 | + protected $_event_model; |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @var EE_Event |
|
| 46 | + */ |
|
| 47 | + protected $_cpt_model_obj = false; |
|
| 48 | + |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Initialize page props for this admin page group. |
|
| 52 | + */ |
|
| 53 | + protected function _init_page_props() |
|
| 54 | + { |
|
| 55 | + $this->page_slug = EVENTS_PG_SLUG; |
|
| 56 | + $this->page_label = EVENTS_LABEL; |
|
| 57 | + $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
| 58 | + $this->_admin_base_path = EVENTS_ADMIN; |
|
| 59 | + $this->_cpt_model_names = array( |
|
| 60 | + 'create_new' => 'EEM_Event', |
|
| 61 | + 'edit' => 'EEM_Event', |
|
| 62 | + ); |
|
| 63 | + $this->_cpt_edit_routes = array( |
|
| 64 | + 'espresso_events' => 'edit', |
|
| 65 | + ); |
|
| 66 | + add_action( |
|
| 67 | + 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
| 68 | + array($this, 'verify_event_edit'), 10, 2 |
|
| 69 | + ); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Sets the ajax hooks used for this admin page group. |
|
| 75 | + */ |
|
| 76 | + protected function _ajax_hooks() |
|
| 77 | + { |
|
| 78 | + add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting')); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Sets the page properties for this admin page group. |
|
| 84 | + */ |
|
| 85 | + protected function _define_page_props() |
|
| 86 | + { |
|
| 87 | + $this->_admin_page_title = EVENTS_LABEL; |
|
| 88 | + $this->_labels = array( |
|
| 89 | + 'buttons' => array( |
|
| 90 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
| 91 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
| 92 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
| 93 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
| 94 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
| 95 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
| 96 | + ), |
|
| 97 | + 'editor_title' => array( |
|
| 98 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
| 99 | + ), |
|
| 100 | + 'publishbox' => array( |
|
| 101 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
| 102 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
| 103 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
| 104 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
| 105 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
| 106 | + ), |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Sets the page routes property for this admin page group. |
|
| 113 | + */ |
|
| 114 | + protected function _set_page_routes() |
|
| 115 | + { |
|
| 116 | + //load formatter helper |
|
| 117 | + //load field generator helper |
|
| 118 | + //is there a evt_id in the request? |
|
| 119 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
| 120 | + ? $this->_req_data['EVT_ID'] |
|
| 121 | + : 0; |
|
| 122 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
| 123 | + $this->_page_routes = array( |
|
| 124 | + 'default' => array( |
|
| 125 | + 'func' => '_events_overview_list_table', |
|
| 126 | + 'capability' => 'ee_read_events', |
|
| 127 | + ), |
|
| 128 | + 'create_new' => array( |
|
| 129 | + 'func' => '_create_new_cpt_item', |
|
| 130 | + 'capability' => 'ee_edit_events', |
|
| 131 | + ), |
|
| 132 | + 'edit' => array( |
|
| 133 | + 'func' => '_edit_cpt_item', |
|
| 134 | + 'capability' => 'ee_edit_event', |
|
| 135 | + 'obj_id' => $evt_id, |
|
| 136 | + ), |
|
| 137 | + 'copy_event' => array( |
|
| 138 | + 'func' => '_copy_events', |
|
| 139 | + 'capability' => 'ee_edit_event', |
|
| 140 | + 'obj_id' => $evt_id, |
|
| 141 | + 'noheader' => true, |
|
| 142 | + ), |
|
| 143 | + 'trash_event' => array( |
|
| 144 | + 'func' => '_trash_or_restore_event', |
|
| 145 | + 'args' => array('event_status' => 'trash'), |
|
| 146 | + 'capability' => 'ee_delete_event', |
|
| 147 | + 'obj_id' => $evt_id, |
|
| 148 | + 'noheader' => true, |
|
| 149 | + ), |
|
| 150 | + 'trash_events' => array( |
|
| 151 | + 'func' => '_trash_or_restore_events', |
|
| 152 | + 'args' => array('event_status' => 'trash'), |
|
| 153 | + 'capability' => 'ee_delete_events', |
|
| 154 | + 'noheader' => true, |
|
| 155 | + ), |
|
| 156 | + 'restore_event' => array( |
|
| 157 | + 'func' => '_trash_or_restore_event', |
|
| 158 | + 'args' => array('event_status' => 'draft'), |
|
| 159 | + 'capability' => 'ee_delete_event', |
|
| 160 | + 'obj_id' => $evt_id, |
|
| 161 | + 'noheader' => true, |
|
| 162 | + ), |
|
| 163 | + 'restore_events' => array( |
|
| 164 | + 'func' => '_trash_or_restore_events', |
|
| 165 | + 'args' => array('event_status' => 'draft'), |
|
| 166 | + 'capability' => 'ee_delete_events', |
|
| 167 | + 'noheader' => true, |
|
| 168 | + ), |
|
| 169 | + 'delete_event' => array( |
|
| 170 | + 'func' => '_delete_event', |
|
| 171 | + 'capability' => 'ee_delete_event', |
|
| 172 | + 'obj_id' => $evt_id, |
|
| 173 | + 'noheader' => true, |
|
| 174 | + ), |
|
| 175 | + 'delete_events' => array( |
|
| 176 | + 'func' => '_delete_events', |
|
| 177 | + 'capability' => 'ee_delete_events', |
|
| 178 | + 'noheader' => true, |
|
| 179 | + ), |
|
| 180 | + 'view_report' => array( |
|
| 181 | + 'func' => '_view_report', |
|
| 182 | + 'capablity' => 'ee_edit_events', |
|
| 183 | + ), |
|
| 184 | + 'default_event_settings' => array( |
|
| 185 | + 'func' => '_default_event_settings', |
|
| 186 | + 'capability' => 'manage_options', |
|
| 187 | + ), |
|
| 188 | + 'update_default_event_settings' => array( |
|
| 189 | + 'func' => '_update_default_event_settings', |
|
| 190 | + 'capability' => 'manage_options', |
|
| 191 | + 'noheader' => true, |
|
| 192 | + ), |
|
| 193 | + 'template_settings' => array( |
|
| 194 | + 'func' => '_template_settings', |
|
| 195 | + 'capability' => 'manage_options', |
|
| 196 | + ), |
|
| 197 | + //event category tab related |
|
| 198 | + 'add_category' => array( |
|
| 199 | + 'func' => '_category_details', |
|
| 200 | + 'capability' => 'ee_edit_event_category', |
|
| 201 | + 'args' => array('add'), |
|
| 202 | + ), |
|
| 203 | + 'edit_category' => array( |
|
| 204 | + 'func' => '_category_details', |
|
| 205 | + 'capability' => 'ee_edit_event_category', |
|
| 206 | + 'args' => array('edit'), |
|
| 207 | + ), |
|
| 208 | + 'delete_categories' => array( |
|
| 209 | + 'func' => '_delete_categories', |
|
| 210 | + 'capability' => 'ee_delete_event_category', |
|
| 211 | + 'noheader' => true, |
|
| 212 | + ), |
|
| 213 | + 'delete_category' => array( |
|
| 214 | + 'func' => '_delete_categories', |
|
| 215 | + 'capability' => 'ee_delete_event_category', |
|
| 216 | + 'noheader' => true, |
|
| 217 | + ), |
|
| 218 | + 'insert_category' => array( |
|
| 219 | + 'func' => '_insert_or_update_category', |
|
| 220 | + 'args' => array('new_category' => true), |
|
| 221 | + 'capability' => 'ee_edit_event_category', |
|
| 222 | + 'noheader' => true, |
|
| 223 | + ), |
|
| 224 | + 'update_category' => array( |
|
| 225 | + 'func' => '_insert_or_update_category', |
|
| 226 | + 'args' => array('new_category' => false), |
|
| 227 | + 'capability' => 'ee_edit_event_category', |
|
| 228 | + 'noheader' => true, |
|
| 229 | + ), |
|
| 230 | + 'category_list' => array( |
|
| 231 | + 'func' => '_category_list_table', |
|
| 232 | + 'capability' => 'ee_manage_event_categories', |
|
| 233 | + ), |
|
| 234 | + ); |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * Set the _page_config property for this admin page group. |
|
| 240 | + */ |
|
| 241 | + protected function _set_page_config() |
|
| 242 | + { |
|
| 243 | + $this->_page_config = array( |
|
| 244 | + 'default' => array( |
|
| 245 | + 'nav' => array( |
|
| 246 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 247 | + 'order' => 10, |
|
| 248 | + ), |
|
| 249 | + 'list_table' => 'Events_Admin_List_Table', |
|
| 250 | + 'help_tabs' => array( |
|
| 251 | + 'events_overview_help_tab' => array( |
|
| 252 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
| 253 | + 'filename' => 'events_overview', |
|
| 254 | + ), |
|
| 255 | + 'events_overview_table_column_headings_help_tab' => array( |
|
| 256 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
| 257 | + 'filename' => 'events_overview_table_column_headings', |
|
| 258 | + ), |
|
| 259 | + 'events_overview_filters_help_tab' => array( |
|
| 260 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
| 261 | + 'filename' => 'events_overview_filters', |
|
| 262 | + ), |
|
| 263 | + 'events_overview_view_help_tab' => array( |
|
| 264 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
| 265 | + 'filename' => 'events_overview_views', |
|
| 266 | + ), |
|
| 267 | + 'events_overview_other_help_tab' => array( |
|
| 268 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
| 269 | + 'filename' => 'events_overview_other', |
|
| 270 | + ), |
|
| 271 | + ), |
|
| 272 | + 'help_tour' => array( |
|
| 273 | + 'Event_Overview_Help_Tour', |
|
| 274 | + //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
| 275 | + ), |
|
| 276 | + 'qtips' => array( |
|
| 277 | + 'EE_Event_List_Table_Tips', |
|
| 278 | + ), |
|
| 279 | + 'require_nonce' => false, |
|
| 280 | + ), |
|
| 281 | + 'create_new' => array( |
|
| 282 | + 'nav' => array( |
|
| 283 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
| 284 | + 'order' => 5, |
|
| 285 | + 'persistent' => false, |
|
| 286 | + ), |
|
| 287 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
| 288 | + 'help_tabs' => array( |
|
| 289 | + 'event_editor_help_tab' => array( |
|
| 290 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 291 | + 'filename' => 'event_editor', |
|
| 292 | + ), |
|
| 293 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
| 294 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 295 | + 'filename' => 'event_editor_title_richtexteditor', |
|
| 296 | + ), |
|
| 297 | + 'event_editor_venue_details_help_tab' => array( |
|
| 298 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 299 | + 'filename' => 'event_editor_venue_details', |
|
| 300 | + ), |
|
| 301 | + 'event_editor_event_datetimes_help_tab' => array( |
|
| 302 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 303 | + 'filename' => 'event_editor_event_datetimes', |
|
| 304 | + ), |
|
| 305 | + 'event_editor_event_tickets_help_tab' => array( |
|
| 306 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 307 | + 'filename' => 'event_editor_event_tickets', |
|
| 308 | + ), |
|
| 309 | + 'event_editor_event_registration_options_help_tab' => array( |
|
| 310 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 311 | + 'filename' => 'event_editor_event_registration_options', |
|
| 312 | + ), |
|
| 313 | + 'event_editor_tags_categories_help_tab' => array( |
|
| 314 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 315 | + 'filename' => 'event_editor_tags_categories', |
|
| 316 | + ), |
|
| 317 | + 'event_editor_questions_registrants_help_tab' => array( |
|
| 318 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 319 | + 'filename' => 'event_editor_questions_registrants', |
|
| 320 | + ), |
|
| 321 | + 'event_editor_save_new_event_help_tab' => array( |
|
| 322 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 323 | + 'filename' => 'event_editor_save_new_event', |
|
| 324 | + ), |
|
| 325 | + 'event_editor_other_help_tab' => array( |
|
| 326 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 327 | + 'filename' => 'event_editor_other', |
|
| 328 | + ), |
|
| 329 | + ), |
|
| 330 | + 'help_tour' => array( |
|
| 331 | + 'Event_Editor_Help_Tour', |
|
| 332 | + ), |
|
| 333 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
| 334 | + 'require_nonce' => false, |
|
| 335 | + ), |
|
| 336 | + 'edit' => array( |
|
| 337 | + 'nav' => array( |
|
| 338 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
| 339 | + 'order' => 5, |
|
| 340 | + 'persistent' => false, |
|
| 341 | + 'url' => isset($this->_req_data['post']) |
|
| 342 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 343 | + array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
| 344 | + $this->_current_page_view_url |
|
| 345 | + ) |
|
| 346 | + : $this->_admin_base_url, |
|
| 347 | + ), |
|
| 348 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
| 349 | + 'help_tabs' => array( |
|
| 350 | + 'event_editor_help_tab' => array( |
|
| 351 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 352 | + 'filename' => 'event_editor', |
|
| 353 | + ), |
|
| 354 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
| 355 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 356 | + 'filename' => 'event_editor_title_richtexteditor', |
|
| 357 | + ), |
|
| 358 | + 'event_editor_venue_details_help_tab' => array( |
|
| 359 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 360 | + 'filename' => 'event_editor_venue_details', |
|
| 361 | + ), |
|
| 362 | + 'event_editor_event_datetimes_help_tab' => array( |
|
| 363 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 364 | + 'filename' => 'event_editor_event_datetimes', |
|
| 365 | + ), |
|
| 366 | + 'event_editor_event_tickets_help_tab' => array( |
|
| 367 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 368 | + 'filename' => 'event_editor_event_tickets', |
|
| 369 | + ), |
|
| 370 | + 'event_editor_event_registration_options_help_tab' => array( |
|
| 371 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 372 | + 'filename' => 'event_editor_event_registration_options', |
|
| 373 | + ), |
|
| 374 | + 'event_editor_tags_categories_help_tab' => array( |
|
| 375 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 376 | + 'filename' => 'event_editor_tags_categories', |
|
| 377 | + ), |
|
| 378 | + 'event_editor_questions_registrants_help_tab' => array( |
|
| 379 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 380 | + 'filename' => 'event_editor_questions_registrants', |
|
| 381 | + ), |
|
| 382 | + 'event_editor_save_new_event_help_tab' => array( |
|
| 383 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 384 | + 'filename' => 'event_editor_save_new_event', |
|
| 385 | + ), |
|
| 386 | + 'event_editor_other_help_tab' => array( |
|
| 387 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 388 | + 'filename' => 'event_editor_other', |
|
| 389 | + ), |
|
| 390 | + ), |
|
| 391 | + /*'help_tour' => array( |
|
| 392 | 392 | 'Event_Edit_Help_Tour' |
| 393 | 393 | ),*/ |
| 394 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
| 395 | - 'require_nonce' => false, |
|
| 396 | - ), |
|
| 397 | - 'default_event_settings' => array( |
|
| 398 | - 'nav' => array( |
|
| 399 | - 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
| 400 | - 'order' => 40, |
|
| 401 | - ), |
|
| 402 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 403 | - 'labels' => array( |
|
| 404 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
| 405 | - ), |
|
| 406 | - 'help_tabs' => array( |
|
| 407 | - 'default_settings_help_tab' => array( |
|
| 408 | - 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
| 409 | - 'filename' => 'events_default_settings', |
|
| 410 | - ), |
|
| 411 | - 'default_settings_status_help_tab' => array( |
|
| 412 | - 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
| 413 | - 'filename' => 'events_default_settings_status', |
|
| 414 | - ), |
|
| 415 | - 'default_maximum_tickets_help_tab' => array( |
|
| 416 | - 'title' => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'), |
|
| 417 | - 'filename' => 'events_default_settings_max_tickets', |
|
| 418 | - ) |
|
| 419 | - ), |
|
| 420 | - 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
| 421 | - 'require_nonce' => false, |
|
| 422 | - ), |
|
| 423 | - //template settings |
|
| 424 | - 'template_settings' => array( |
|
| 425 | - 'nav' => array( |
|
| 426 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
| 427 | - 'order' => 30, |
|
| 428 | - ), |
|
| 429 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 430 | - 'help_tabs' => array( |
|
| 431 | - 'general_settings_templates_help_tab' => array( |
|
| 432 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
| 433 | - 'filename' => 'general_settings_templates', |
|
| 434 | - ), |
|
| 435 | - ), |
|
| 436 | - 'help_tour' => array('Templates_Help_Tour'), |
|
| 437 | - 'require_nonce' => false, |
|
| 438 | - ), |
|
| 439 | - //event category stuff |
|
| 440 | - 'add_category' => array( |
|
| 441 | - 'nav' => array( |
|
| 442 | - 'label' => esc_html__('Add Category', 'event_espresso'), |
|
| 443 | - 'order' => 15, |
|
| 444 | - 'persistent' => false, |
|
| 445 | - ), |
|
| 446 | - 'help_tabs' => array( |
|
| 447 | - 'add_category_help_tab' => array( |
|
| 448 | - 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
| 449 | - 'filename' => 'events_add_category', |
|
| 450 | - ), |
|
| 451 | - ), |
|
| 452 | - 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
| 453 | - 'metaboxes' => array('_publish_post_box'), |
|
| 454 | - 'require_nonce' => false, |
|
| 455 | - ), |
|
| 456 | - 'edit_category' => array( |
|
| 457 | - 'nav' => array( |
|
| 458 | - 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
| 459 | - 'order' => 15, |
|
| 460 | - 'persistent' => false, |
|
| 461 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
| 462 | - ? add_query_arg( |
|
| 463 | - array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
| 464 | - $this->_current_page_view_url |
|
| 465 | - ) |
|
| 466 | - : $this->_admin_base_url, |
|
| 467 | - ), |
|
| 468 | - 'help_tabs' => array( |
|
| 469 | - 'edit_category_help_tab' => array( |
|
| 470 | - 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
| 471 | - 'filename' => 'events_edit_category', |
|
| 472 | - ), |
|
| 473 | - ), |
|
| 474 | - /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
| 475 | - 'metaboxes' => array('_publish_post_box'), |
|
| 476 | - 'require_nonce' => false, |
|
| 477 | - ), |
|
| 478 | - 'category_list' => array( |
|
| 479 | - 'nav' => array( |
|
| 480 | - 'label' => esc_html__('Categories', 'event_espresso'), |
|
| 481 | - 'order' => 20, |
|
| 482 | - ), |
|
| 483 | - 'list_table' => 'Event_Categories_Admin_List_Table', |
|
| 484 | - 'help_tabs' => array( |
|
| 485 | - 'events_categories_help_tab' => array( |
|
| 486 | - 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
| 487 | - 'filename' => 'events_categories', |
|
| 488 | - ), |
|
| 489 | - 'events_categories_table_column_headings_help_tab' => array( |
|
| 490 | - 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
| 491 | - 'filename' => 'events_categories_table_column_headings', |
|
| 492 | - ), |
|
| 493 | - 'events_categories_view_help_tab' => array( |
|
| 494 | - 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
| 495 | - 'filename' => 'events_categories_views', |
|
| 496 | - ), |
|
| 497 | - 'events_categories_other_help_tab' => array( |
|
| 498 | - 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
| 499 | - 'filename' => 'events_categories_other', |
|
| 500 | - ), |
|
| 501 | - ), |
|
| 502 | - 'help_tour' => array( |
|
| 503 | - 'Event_Categories_Help_Tour', |
|
| 504 | - ), |
|
| 505 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 506 | - 'require_nonce' => false, |
|
| 507 | - ), |
|
| 508 | - ); |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * Used to register any global screen options if necessary for every route in this admin page group. |
|
| 514 | - */ |
|
| 515 | - protected function _add_screen_options() |
|
| 516 | - { |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - |
|
| 520 | - /** |
|
| 521 | - * Implementing the screen options for the 'default' route. |
|
| 522 | - */ |
|
| 523 | - protected function _add_screen_options_default() |
|
| 524 | - { |
|
| 525 | - $this->_per_page_screen_option(); |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * Implementing screen options for the category list route. |
|
| 531 | - */ |
|
| 532 | - protected function _add_screen_options_category_list() |
|
| 533 | - { |
|
| 534 | - $page_title = $this->_admin_page_title; |
|
| 535 | - $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
| 536 | - $this->_per_page_screen_option(); |
|
| 537 | - $this->_admin_page_title = $page_title; |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - |
|
| 541 | - /** |
|
| 542 | - * Used to register any global feature pointers for the admin page group. |
|
| 543 | - */ |
|
| 544 | - protected function _add_feature_pointers() |
|
| 545 | - { |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - |
|
| 549 | - /** |
|
| 550 | - * Registers and enqueues any global scripts and styles for the entire admin page group. |
|
| 551 | - */ |
|
| 552 | - public function load_scripts_styles() |
|
| 553 | - { |
|
| 554 | - wp_register_style( |
|
| 555 | - 'events-admin-css', |
|
| 556 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
| 557 | - array(), |
|
| 558 | - EVENT_ESPRESSO_VERSION |
|
| 559 | - ); |
|
| 560 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 561 | - wp_enqueue_style('events-admin-css'); |
|
| 562 | - wp_enqueue_style('ee-cat-admin'); |
|
| 563 | - //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
| 564 | - //registers for all views |
|
| 565 | - //scripts |
|
| 566 | - wp_register_script( |
|
| 567 | - 'event_editor_js', |
|
| 568 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
| 569 | - array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
| 570 | - EVENT_ESPRESSO_VERSION, |
|
| 571 | - true |
|
| 572 | - ); |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - |
|
| 576 | - |
|
| 577 | - /** |
|
| 578 | - * Enqueuing scripts and styles specific to this view |
|
| 579 | - */ |
|
| 580 | - public function load_scripts_styles_create_new() |
|
| 581 | - { |
|
| 582 | - $this->load_scripts_styles_edit(); |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - |
|
| 586 | - |
|
| 587 | - /** |
|
| 588 | - * Enqueuing scripts and styles specific to this view |
|
| 589 | - */ |
|
| 590 | - public function load_scripts_styles_edit() |
|
| 591 | - { |
|
| 592 | - //styles |
|
| 593 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 594 | - wp_register_style( |
|
| 595 | - 'event-editor-css', |
|
| 596 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 597 | - array('ee-admin-css'), |
|
| 598 | - EVENT_ESPRESSO_VERSION |
|
| 599 | - ); |
|
| 600 | - wp_enqueue_style('event-editor-css'); |
|
| 601 | - //scripts |
|
| 602 | - wp_register_script( |
|
| 603 | - 'event-datetime-metabox', |
|
| 604 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
| 605 | - array('event_editor_js', 'ee-datepicker'), |
|
| 606 | - EVENT_ESPRESSO_VERSION |
|
| 607 | - ); |
|
| 608 | - wp_enqueue_script('event-datetime-metabox'); |
|
| 609 | - } |
|
| 610 | - |
|
| 611 | - |
|
| 612 | - /** |
|
| 613 | - * Populating the _views property for the category list table view. |
|
| 614 | - */ |
|
| 615 | - protected function _set_list_table_views_category_list() |
|
| 616 | - { |
|
| 617 | - $this->_views = array( |
|
| 618 | - 'all' => array( |
|
| 619 | - 'slug' => 'all', |
|
| 620 | - 'label' => esc_html__('All', 'event_espresso'), |
|
| 621 | - 'count' => 0, |
|
| 622 | - 'bulk_action' => array( |
|
| 623 | - 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 624 | - ), |
|
| 625 | - ), |
|
| 626 | - ); |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * For adding anything that fires on the admin_init hook for any route within this admin page group. |
|
| 632 | - */ |
|
| 633 | - public function admin_init() |
|
| 634 | - { |
|
| 635 | - EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
| 636 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
| 637 | - 'event_espresso' |
|
| 638 | - ); |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - |
|
| 642 | - /** |
|
| 643 | - * For adding anything that should be triggered on the admin_notices hook for any route within this admin page group. |
|
| 644 | - */ |
|
| 645 | - public function admin_notices() |
|
| 646 | - { |
|
| 647 | - } |
|
| 648 | - |
|
| 649 | - |
|
| 650 | - /** |
|
| 651 | - * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within |
|
| 652 | - * this admin page group. |
|
| 653 | - */ |
|
| 654 | - public function admin_footer_scripts() |
|
| 655 | - { |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - |
|
| 659 | - |
|
| 660 | - /** |
|
| 661 | - * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
| 662 | - * warning (via EE_Error::add_error()); |
|
| 663 | - * |
|
| 664 | - * @param EE_Event $event Event object |
|
| 665 | - * @param string $req_type |
|
| 666 | - * @return void |
|
| 667 | - * @throws EE_Error |
|
| 668 | - * @access public |
|
| 669 | - */ |
|
| 670 | - public function verify_event_edit($event = null, $req_type = '') |
|
| 671 | - { |
|
| 672 | - // don't need to do this when processing |
|
| 673 | - if(!empty($req_type)) { |
|
| 674 | - return; |
|
| 675 | - } |
|
| 676 | - // no event? |
|
| 677 | - if (empty($event)) { |
|
| 678 | - // set event |
|
| 679 | - $event = $this->_cpt_model_obj; |
|
| 680 | - } |
|
| 681 | - // STILL no event? |
|
| 682 | - if (! $event instanceof EE_Event) { |
|
| 683 | - return; |
|
| 684 | - } |
|
| 685 | - $orig_status = $event->status(); |
|
| 686 | - // first check if event is active. |
|
| 687 | - if ( |
|
| 688 | - $orig_status === EEM_Event::cancelled |
|
| 689 | - || $orig_status === EEM_Event::postponed |
|
| 690 | - || $event->is_expired() |
|
| 691 | - || $event->is_inactive() |
|
| 692 | - ) { |
|
| 693 | - return; |
|
| 694 | - } |
|
| 695 | - //made it here so it IS active... next check that any of the tickets are sold. |
|
| 696 | - if ($event->is_sold_out(true)) { |
|
| 697 | - if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
| 698 | - EE_Error::add_attention( |
|
| 699 | - sprintf( |
|
| 700 | - esc_html__( |
|
| 701 | - 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
| 702 | - 'event_espresso' |
|
| 703 | - ), |
|
| 704 | - EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
| 705 | - ) |
|
| 706 | - ); |
|
| 707 | - } |
|
| 708 | - return; |
|
| 709 | - } else if ($orig_status === EEM_Event::sold_out) { |
|
| 710 | - EE_Error::add_attention( |
|
| 711 | - sprintf( |
|
| 712 | - esc_html__( |
|
| 713 | - 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
| 714 | - 'event_espresso' |
|
| 715 | - ), |
|
| 716 | - EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
| 717 | - ) |
|
| 718 | - ); |
|
| 719 | - } |
|
| 720 | - //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
| 721 | - if ( ! $event->tickets_on_sale()) { |
|
| 722 | - return; |
|
| 723 | - } |
|
| 724 | - //made it here so show warning |
|
| 725 | - $this->_edit_event_warning(); |
|
| 726 | - } |
|
| 727 | - |
|
| 728 | - |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
| 732 | - * When needed, hook this into a EE_Error::add_error() notice. |
|
| 733 | - * |
|
| 734 | - * @access protected |
|
| 735 | - * @return void |
|
| 736 | - */ |
|
| 737 | - protected function _edit_event_warning() |
|
| 738 | - { |
|
| 739 | - // we don't want to add warnings during these requests |
|
| 740 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
| 741 | - return; |
|
| 742 | - } |
|
| 743 | - EE_Error::add_attention( |
|
| 744 | - esc_html__( |
|
| 745 | - 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
| 746 | - 'event_espresso' |
|
| 747 | - ) |
|
| 748 | - ); |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - |
|
| 752 | - |
|
| 753 | - /** |
|
| 754 | - * When a user is creating a new event, notify them if they haven't set their timezone. |
|
| 755 | - * Otherwise, do the normal logic |
|
| 756 | - * |
|
| 757 | - * @return string |
|
| 758 | - * @throws \EE_Error |
|
| 759 | - */ |
|
| 760 | - protected function _create_new_cpt_item() |
|
| 761 | - { |
|
| 762 | - $has_timezone_string = get_option('timezone_string'); |
|
| 763 | - //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
| 764 | - if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) { |
|
| 765 | - EE_Error::add_attention( |
|
| 766 | - sprintf( |
|
| 767 | - __( |
|
| 768 | - 'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s', |
|
| 769 | - 'event_espresso' |
|
| 770 | - ), |
|
| 771 | - '<br>', |
|
| 772 | - '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">' |
|
| 773 | - . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale()) |
|
| 774 | - . '</select>', |
|
| 775 | - '<button class="button button-secondary timezone-submit">', |
|
| 776 | - '</button><span class="spinner"></span>' |
|
| 777 | - ), |
|
| 778 | - __FILE__, |
|
| 779 | - __FUNCTION__, |
|
| 780 | - __LINE__ |
|
| 781 | - ); |
|
| 782 | - } |
|
| 783 | - return parent::_create_new_cpt_item(); |
|
| 784 | - } |
|
| 785 | - |
|
| 786 | - |
|
| 787 | - /** |
|
| 788 | - * Sets the _views property for the default route in this admin page group. |
|
| 789 | - */ |
|
| 790 | - protected function _set_list_table_views_default() |
|
| 791 | - { |
|
| 792 | - $this->_views = array( |
|
| 793 | - 'all' => array( |
|
| 794 | - 'slug' => 'all', |
|
| 795 | - 'label' => esc_html__('View All Events', 'event_espresso'), |
|
| 796 | - 'count' => 0, |
|
| 797 | - 'bulk_action' => array( |
|
| 798 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 799 | - ), |
|
| 800 | - ), |
|
| 801 | - 'draft' => array( |
|
| 802 | - 'slug' => 'draft', |
|
| 803 | - 'label' => esc_html__('Draft', 'event_espresso'), |
|
| 804 | - 'count' => 0, |
|
| 805 | - 'bulk_action' => array( |
|
| 806 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 807 | - ), |
|
| 808 | - ), |
|
| 809 | - ); |
|
| 810 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
| 811 | - $this->_views['trash'] = array( |
|
| 812 | - 'slug' => 'trash', |
|
| 813 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 814 | - 'count' => 0, |
|
| 815 | - 'bulk_action' => array( |
|
| 816 | - 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
| 817 | - 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 818 | - ), |
|
| 819 | - ); |
|
| 820 | - } |
|
| 821 | - } |
|
| 822 | - |
|
| 823 | - |
|
| 824 | - |
|
| 825 | - /** |
|
| 826 | - * Provides the legend item array for the default list table view. |
|
| 827 | - * @return array |
|
| 828 | - */ |
|
| 829 | - protected function _event_legend_items() |
|
| 830 | - { |
|
| 831 | - $items = array( |
|
| 832 | - 'view_details' => array( |
|
| 833 | - 'class' => 'dashicons dashicons-search', |
|
| 834 | - 'desc' => esc_html__('View Event', 'event_espresso'), |
|
| 835 | - ), |
|
| 836 | - 'edit_event' => array( |
|
| 837 | - 'class' => 'ee-icon ee-icon-calendar-edit', |
|
| 838 | - 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
| 839 | - ), |
|
| 840 | - 'view_attendees' => array( |
|
| 841 | - 'class' => 'dashicons dashicons-groups', |
|
| 842 | - 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
| 843 | - ), |
|
| 844 | - ); |
|
| 845 | - $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
| 846 | - $statuses = array( |
|
| 847 | - 'sold_out_status' => array( |
|
| 848 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
| 849 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
| 850 | - ), |
|
| 851 | - 'active_status' => array( |
|
| 852 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
| 853 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
| 854 | - ), |
|
| 855 | - 'upcoming_status' => array( |
|
| 856 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
| 857 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
| 858 | - ), |
|
| 859 | - 'postponed_status' => array( |
|
| 860 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
| 861 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
| 862 | - ), |
|
| 863 | - 'cancelled_status' => array( |
|
| 864 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
| 865 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
| 866 | - ), |
|
| 867 | - 'expired_status' => array( |
|
| 868 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
| 869 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
| 870 | - ), |
|
| 871 | - 'inactive_status' => array( |
|
| 872 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
| 873 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
| 874 | - ), |
|
| 875 | - ); |
|
| 876 | - $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
| 877 | - return array_merge($items, $statuses); |
|
| 878 | - } |
|
| 879 | - |
|
| 880 | - |
|
| 881 | - |
|
| 882 | - /** |
|
| 883 | - * @return EEM_Event |
|
| 884 | - */ |
|
| 885 | - private function _event_model() |
|
| 886 | - { |
|
| 887 | - if ( ! $this->_event_model instanceof EEM_Event) { |
|
| 888 | - $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
| 889 | - } |
|
| 890 | - return $this->_event_model; |
|
| 891 | - } |
|
| 892 | - |
|
| 893 | - |
|
| 894 | - |
|
| 895 | - /** |
|
| 896 | - * Adds extra buttons to the WP CPT permalink field row. |
|
| 897 | - * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
| 898 | - * |
|
| 899 | - * @param string $return the current html |
|
| 900 | - * @param int $id the post id for the page |
|
| 901 | - * @param string $new_title What the title is |
|
| 902 | - * @param string $new_slug what the slug is |
|
| 903 | - * @return string The new html string for the permalink area |
|
| 904 | - */ |
|
| 905 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
| 906 | - { |
|
| 907 | - //make sure this is only when editing |
|
| 908 | - if ( ! empty($id)) { |
|
| 909 | - $post = get_post($id); |
|
| 910 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
| 911 | - . esc_html__('Shortcode', 'event_espresso') |
|
| 912 | - . '</a> '; |
|
| 913 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
| 914 | - . $post->ID |
|
| 915 | - . ']">'; |
|
| 916 | - } |
|
| 917 | - return $return; |
|
| 918 | - } |
|
| 919 | - |
|
| 920 | - |
|
| 921 | - |
|
| 922 | - /** |
|
| 923 | - * _events_overview_list_table |
|
| 924 | - * This contains the logic for showing the events_overview list |
|
| 925 | - * |
|
| 926 | - * @access protected |
|
| 927 | - * @return void |
|
| 928 | - * @throws \EE_Error |
|
| 929 | - */ |
|
| 930 | - protected function _events_overview_list_table() |
|
| 931 | - { |
|
| 932 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 933 | - $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
| 934 | - ? (array)$this->_template_args['after_list_table'] |
|
| 935 | - : array(); |
|
| 936 | - $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
| 937 | - . EEH_Template::get_button_or_link( |
|
| 938 | - get_post_type_archive_link('espresso_events'), |
|
| 939 | - esc_html__("View Event Archive Page", "event_espresso"), |
|
| 940 | - 'button' |
|
| 941 | - ); |
|
| 942 | - $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
| 943 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 944 | - 'create_new', |
|
| 945 | - 'add', |
|
| 946 | - array(), |
|
| 947 | - 'add-new-h2' |
|
| 948 | - ); |
|
| 949 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - |
|
| 953 | - |
|
| 954 | - /** |
|
| 955 | - * this allows for extra misc actions in the default WP publish box |
|
| 956 | - * |
|
| 957 | - * @return void |
|
| 958 | - */ |
|
| 959 | - public function extra_misc_actions_publish_box() |
|
| 960 | - { |
|
| 961 | - $this->_generate_publish_box_extra_content(); |
|
| 962 | - } |
|
| 963 | - |
|
| 964 | - |
|
| 965 | - |
|
| 966 | - /** |
|
| 967 | - * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been saved. |
|
| 968 | - * Typically you would use this to save any additional data. |
|
| 969 | - * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
| 970 | - * ALSO very important. When a post transitions from scheduled to published, |
|
| 971 | - * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from other meta saves. |
|
| 972 | - * So MAKE sure that you handle this accordingly. |
|
| 973 | - * |
|
| 974 | - * @access protected |
|
| 975 | - * @abstract |
|
| 976 | - * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
| 977 | - * @param object $post The post object of the cpt that was saved. |
|
| 978 | - * @return void |
|
| 979 | - * @throws \EE_Error |
|
| 980 | - */ |
|
| 981 | - protected function _insert_update_cpt_item($post_id, $post) |
|
| 982 | - { |
|
| 983 | - if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
| 984 | - //get out we're not processing an event save. |
|
| 985 | - return; |
|
| 986 | - } |
|
| 987 | - $event_values = array( |
|
| 988 | - 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
| 989 | - 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
| 990 | - 'EVT_additional_limit' => min( |
|
| 991 | - apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
| 992 | - ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
| 993 | - ), |
|
| 994 | - 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
| 995 | - ? $this->_req_data['EVT_default_registration_status'] |
|
| 996 | - : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
| 997 | - 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
| 998 | - 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
| 999 | - 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
| 1000 | - ? $this->_req_data['timezone_string'] : null, |
|
| 1001 | - 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
| 1002 | - ? $this->_req_data['externalURL'] : null, |
|
| 1003 | - 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
| 1004 | - ? $this->_req_data['event_phone'] : null, |
|
| 1005 | - ); |
|
| 1006 | - //update event |
|
| 1007 | - $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
| 1008 | - //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
|
| 1009 | - $get_one_where = array( |
|
| 1010 | - $this->_event_model()->primary_key_name() => $post_id, |
|
| 1011 | - 'OR' => array( |
|
| 1012 | - 'status' => $post->post_status, |
|
| 1013 | - // if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db, |
|
| 1014 | - // but the returned object here has a status of "publish", so use the original post status as well |
|
| 1015 | - 'status*1' => $this->_req_data['original_post_status'], |
|
| 1016 | - ) |
|
| 1017 | - ); |
|
| 1018 | - $event = $this->_event_model()->get_one(array($get_one_where)); |
|
| 1019 | - //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
| 1020 | - $event_update_callbacks = apply_filters( |
|
| 1021 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 1022 | - array( |
|
| 1023 | - array($this, '_default_venue_update'), |
|
| 1024 | - array($this, '_default_tickets_update') |
|
| 1025 | - ) |
|
| 1026 | - ); |
|
| 1027 | - $att_success = true; |
|
| 1028 | - foreach ($event_update_callbacks as $e_callback) { |
|
| 1029 | - $_success = $e_callback($event, $this->_req_data); |
|
| 1030 | - //if ANY of these updates fail then we want the appropriate global error message |
|
| 1031 | - $att_success = ! $att_success ? $att_success : $_success; |
|
| 1032 | - } |
|
| 1033 | - //any errors? |
|
| 1034 | - if ($success && false === $att_success) { |
|
| 1035 | - EE_Error::add_error( |
|
| 1036 | - esc_html__( |
|
| 1037 | - 'Event Details saved successfully but something went wrong with saving attachments.', |
|
| 1038 | - 'event_espresso' |
|
| 1039 | - ), |
|
| 1040 | - __FILE__, |
|
| 1041 | - __FUNCTION__, |
|
| 1042 | - __LINE__ |
|
| 1043 | - ); |
|
| 1044 | - } else if ($success === false) { |
|
| 1045 | - EE_Error::add_error( |
|
| 1046 | - esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
| 1047 | - __FILE__, |
|
| 1048 | - __FUNCTION__, |
|
| 1049 | - __LINE__ |
|
| 1050 | - ); |
|
| 1051 | - } |
|
| 1052 | - } |
|
| 1053 | - |
|
| 1054 | - |
|
| 1055 | - |
|
| 1056 | - /** |
|
| 1057 | - * @see parent::restore_item() |
|
| 1058 | - * @param int $post_id |
|
| 1059 | - * @param int $revision_id |
|
| 1060 | - */ |
|
| 1061 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
| 1062 | - { |
|
| 1063 | - //copy existing event meta to new post |
|
| 1064 | - $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
| 1065 | - if ($post_evt instanceof EE_Event) { |
|
| 1066 | - //meta revision restore |
|
| 1067 | - $post_evt->restore_revision($revision_id); |
|
| 1068 | - //related objs restore |
|
| 1069 | - $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
| 1070 | - } |
|
| 1071 | - } |
|
| 1072 | - |
|
| 1073 | - |
|
| 1074 | - |
|
| 1075 | - /** |
|
| 1076 | - * Attach the venue to the Event |
|
| 1077 | - * |
|
| 1078 | - * @param \EE_Event $evtobj Event Object to add the venue to |
|
| 1079 | - * @param array $data The request data from the form |
|
| 1080 | - * @return bool Success or fail. |
|
| 1081 | - */ |
|
| 1082 | - protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
| 1083 | - { |
|
| 1084 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
| 1085 | - $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
| 1086 | - $rows_affected = null; |
|
| 1087 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
| 1088 | - // very important. If we don't have a venue name... |
|
| 1089 | - // then we'll get out because not necessary to create empty venue |
|
| 1090 | - if (empty($data['venue_title'])) { |
|
| 1091 | - return false; |
|
| 1092 | - } |
|
| 1093 | - $venue_array = array( |
|
| 1094 | - 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
| 1095 | - 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
| 1096 | - 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
| 1097 | - 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
| 1098 | - 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
| 1099 | - : null, |
|
| 1100 | - 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
| 1101 | - 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
| 1102 | - 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
| 1103 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
| 1104 | - 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
| 1105 | - 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
| 1106 | - 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
| 1107 | - 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
| 1108 | - 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
| 1109 | - 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
| 1110 | - 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
| 1111 | - 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
| 1112 | - 'status' => 'publish', |
|
| 1113 | - ); |
|
| 1114 | - //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
| 1115 | - if ( ! empty($venue_id)) { |
|
| 1116 | - $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
| 1117 | - $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
| 1118 | - //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
|
| 1119 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
| 1120 | - return $rows_affected > 0 ? true : false; |
|
| 1121 | - } else { |
|
| 1122 | - //we insert the venue |
|
| 1123 | - $venue_id = $venue_model->insert($venue_array); |
|
| 1124 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
| 1125 | - return ! empty($venue_id) ? true : false; |
|
| 1126 | - } |
|
| 1127 | - //when we have the ancestor come in it's already been handled by the revision save. |
|
| 1128 | - } |
|
| 1129 | - |
|
| 1130 | - |
|
| 1131 | - |
|
| 1132 | - /** |
|
| 1133 | - * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
| 1134 | - * |
|
| 1135 | - * @param EE_Event $evtobj The Event object we're attaching data to |
|
| 1136 | - * @param array $data The request data from the form |
|
| 1137 | - * @return array |
|
| 1138 | - */ |
|
| 1139 | - protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
| 1140 | - { |
|
| 1141 | - $success = true; |
|
| 1142 | - $saved_dtt = null; |
|
| 1143 | - $saved_tickets = array(); |
|
| 1144 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
| 1145 | - foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
| 1146 | - //trim all values to ensure any excess whitespace is removed. |
|
| 1147 | - $dtt = array_map('trim', $dtt); |
|
| 1148 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
| 1149 | - : $dtt['DTT_EVT_start']; |
|
| 1150 | - $datetime_values = array( |
|
| 1151 | - 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
| 1152 | - 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
| 1153 | - 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
| 1154 | - 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
| 1155 | - 'DTT_order' => $row, |
|
| 1156 | - ); |
|
| 1157 | - //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
|
| 1158 | - if ( ! empty($dtt['DTT_ID'])) { |
|
| 1159 | - $DTM = EE_Registry::instance() |
|
| 1160 | - ->load_model('Datetime', array($evtobj->get_timezone())) |
|
| 1161 | - ->get_one_by_ID($dtt['DTT_ID']); |
|
| 1162 | - $DTM->set_date_format($incoming_date_formats[0]); |
|
| 1163 | - $DTM->set_time_format($incoming_date_formats[1]); |
|
| 1164 | - foreach ($datetime_values as $field => $value) { |
|
| 1165 | - $DTM->set($field, $value); |
|
| 1166 | - } |
|
| 1167 | - //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
|
| 1168 | - $saved_dtts[$DTM->ID()] = $DTM; |
|
| 1169 | - } else { |
|
| 1170 | - $DTM = EE_Registry::instance()->load_class( |
|
| 1171 | - 'Datetime', |
|
| 1172 | - array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
| 1173 | - false, |
|
| 1174 | - false |
|
| 1175 | - ); |
|
| 1176 | - foreach ($datetime_values as $field => $value) { |
|
| 1177 | - $DTM->set($field, $value); |
|
| 1178 | - } |
|
| 1179 | - } |
|
| 1180 | - $DTM->save(); |
|
| 1181 | - $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
| 1182 | - //load DTT helper |
|
| 1183 | - //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
| 1184 | - if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
| 1185 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
| 1186 | - $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
| 1187 | - $DTT->save(); |
|
| 1188 | - } |
|
| 1189 | - //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
|
| 1190 | - $saved_dtt = $DTT; |
|
| 1191 | - $success = ! $success ? $success : $DTT; |
|
| 1192 | - //if ANY of these updates fail then we want the appropriate global error message. |
|
| 1193 | - // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
| 1194 | - } |
|
| 1195 | - //no dtts get deleted so we don't do any of that logic here. |
|
| 1196 | - //update tickets next |
|
| 1197 | - $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
| 1198 | - foreach ($data['edit_tickets'] as $row => $tkt) { |
|
| 1199 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
| 1200 | - $update_prices = false; |
|
| 1201 | - $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
| 1202 | - ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
| 1203 | - // trim inputs to ensure any excess whitespace is removed. |
|
| 1204 | - $tkt = array_map('trim', $tkt); |
|
| 1205 | - if (empty($tkt['TKT_start_date'])) { |
|
| 1206 | - //let's use now in the set timezone. |
|
| 1207 | - $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
| 1208 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
| 1209 | - } |
|
| 1210 | - if (empty($tkt['TKT_end_date'])) { |
|
| 1211 | - //use the start date of the first datetime |
|
| 1212 | - $dtt = $evtobj->first_datetime(); |
|
| 1213 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
| 1214 | - $incoming_date_formats[0], |
|
| 1215 | - $incoming_date_formats[1] |
|
| 1216 | - ); |
|
| 1217 | - } |
|
| 1218 | - $TKT_values = array( |
|
| 1219 | - 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
| 1220 | - 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
| 1221 | - 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
| 1222 | - 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
| 1223 | - 'TKT_start_date' => $tkt['TKT_start_date'], |
|
| 1224 | - 'TKT_end_date' => $tkt['TKT_end_date'], |
|
| 1225 | - 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
| 1226 | - 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
| 1227 | - 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
| 1228 | - 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
| 1229 | - 'TKT_row' => $row, |
|
| 1230 | - 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
| 1231 | - 'TKT_price' => $ticket_price, |
|
| 1232 | - ); |
|
| 1233 | - //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
|
| 1234 | - if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
| 1235 | - $TKT_values['TKT_ID'] = 0; |
|
| 1236 | - $TKT_values['TKT_is_default'] = 0; |
|
| 1237 | - $TKT_values['TKT_price'] = $ticket_price; |
|
| 1238 | - $update_prices = true; |
|
| 1239 | - } |
|
| 1240 | - //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
| 1241 | - //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
|
| 1242 | - //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
| 1243 | - if ( ! empty($tkt['TKT_ID'])) { |
|
| 1244 | - $TKT = EE_Registry::instance() |
|
| 1245 | - ->load_model('Ticket', array($evtobj->get_timezone())) |
|
| 1246 | - ->get_one_by_ID($tkt['TKT_ID']); |
|
| 1247 | - if ($TKT instanceof EE_Ticket) { |
|
| 1248 | - $ticket_sold = $TKT->count_related( |
|
| 1249 | - 'Registration', |
|
| 1250 | - array( |
|
| 1251 | - array( |
|
| 1252 | - 'STS_ID' => array( |
|
| 1253 | - 'NOT IN', |
|
| 1254 | - array(EEM_Registration::status_id_incomplete), |
|
| 1255 | - ), |
|
| 1256 | - ), |
|
| 1257 | - ) |
|
| 1258 | - ) > 0 ? true : false; |
|
| 1259 | - //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
|
| 1260 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
| 1261 | - && ! $TKT->get( |
|
| 1262 | - 'TKT_deleted' |
|
| 1263 | - ) ? true : false; |
|
| 1264 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
| 1265 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
| 1266 | - //set new values |
|
| 1267 | - foreach ($TKT_values as $field => $value) { |
|
| 1268 | - if ($field == 'TKT_qty') { |
|
| 1269 | - $TKT->set_qty($value); |
|
| 1270 | - } else { |
|
| 1271 | - $TKT->set($field, $value); |
|
| 1272 | - } |
|
| 1273 | - } |
|
| 1274 | - //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
| 1275 | - if ($create_new_TKT) { |
|
| 1276 | - //archive the old ticket first |
|
| 1277 | - $TKT->set('TKT_deleted', 1); |
|
| 1278 | - $TKT->save(); |
|
| 1279 | - //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
| 1280 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
| 1281 | - //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
|
| 1282 | - $TKT = clone $TKT; |
|
| 1283 | - $TKT->set('TKT_ID', 0); |
|
| 1284 | - $TKT->set('TKT_deleted', 0); |
|
| 1285 | - $TKT->set('TKT_price', $ticket_price); |
|
| 1286 | - $TKT->set('TKT_sold', 0); |
|
| 1287 | - //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
| 1288 | - $update_prices = true; |
|
| 1289 | - } |
|
| 1290 | - //make sure price is set if it hasn't been already |
|
| 1291 | - $TKT->set('TKT_price', $ticket_price); |
|
| 1292 | - } |
|
| 1293 | - } else { |
|
| 1294 | - //no TKT_id so a new TKT |
|
| 1295 | - $TKT_values['TKT_price'] = $ticket_price; |
|
| 1296 | - $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
| 1297 | - if ($TKT instanceof EE_Ticket) { |
|
| 1298 | - //need to reset values to properly account for the date formats |
|
| 1299 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
| 1300 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
| 1301 | - $TKT->set_timezone($evtobj->get_timezone()); |
|
| 1302 | - //set new values |
|
| 1303 | - foreach ($TKT_values as $field => $value) { |
|
| 1304 | - if ($field == 'TKT_qty') { |
|
| 1305 | - $TKT->set_qty($value); |
|
| 1306 | - } else { |
|
| 1307 | - $TKT->set($field, $value); |
|
| 1308 | - } |
|
| 1309 | - } |
|
| 1310 | - $update_prices = true; |
|
| 1311 | - } |
|
| 1312 | - } |
|
| 1313 | - // cap ticket qty by datetime reg limits |
|
| 1314 | - $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
| 1315 | - //update ticket. |
|
| 1316 | - $TKT->save(); |
|
| 1317 | - //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
| 1318 | - if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
| 1319 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
| 1320 | - $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
| 1321 | - $TKT->save(); |
|
| 1322 | - } |
|
| 1323 | - //initially let's add the ticket to the dtt |
|
| 1324 | - $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
| 1325 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
| 1326 | - //add prices to ticket |
|
| 1327 | - $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
| 1328 | - } |
|
| 1329 | - //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
| 1330 | - $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
| 1331 | - $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
| 1332 | - foreach ($tickets_removed as $id) { |
|
| 1333 | - $id = absint($id); |
|
| 1334 | - //get the ticket for this id |
|
| 1335 | - $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
| 1336 | - //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
| 1337 | - $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
| 1338 | - foreach ($dtts as $dtt) { |
|
| 1339 | - $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
| 1340 | - } |
|
| 1341 | - //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
| 1342 | - $tkt_to_remove->delete_related_permanently('Price'); |
|
| 1343 | - //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
| 1344 | - $tkt_to_remove->delete_permanently(); |
|
| 1345 | - } |
|
| 1346 | - return array($saved_dtt, $saved_tickets); |
|
| 1347 | - } |
|
| 1348 | - |
|
| 1349 | - |
|
| 1350 | - |
|
| 1351 | - /** |
|
| 1352 | - * This attaches a list of given prices to a ticket. |
|
| 1353 | - * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
| 1354 | - * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
| 1355 | - * price info and prices are automatically "archived" via the ticket. |
|
| 1356 | - * |
|
| 1357 | - * @access private |
|
| 1358 | - * @param array $prices Array of prices from the form. |
|
| 1359 | - * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
| 1360 | - * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
| 1361 | - * @return void |
|
| 1362 | - */ |
|
| 1363 | - private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
| 1364 | - { |
|
| 1365 | - foreach ($prices as $row => $prc) { |
|
| 1366 | - $PRC_values = array( |
|
| 1367 | - 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
| 1368 | - 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
| 1369 | - 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
| 1370 | - 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
| 1371 | - 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
| 1372 | - 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
| 1373 | - 'PRC_order' => $row, |
|
| 1374 | - ); |
|
| 1375 | - if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
| 1376 | - $PRC_values['PRC_ID'] = 0; |
|
| 1377 | - $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
| 1378 | - } else { |
|
| 1379 | - $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
| 1380 | - //update this price with new values |
|
| 1381 | - foreach ($PRC_values as $field => $newprc) { |
|
| 1382 | - $PRC->set($field, $newprc); |
|
| 1383 | - } |
|
| 1384 | - $PRC->save(); |
|
| 1385 | - } |
|
| 1386 | - $ticket->_add_relation_to($PRC, 'Price'); |
|
| 1387 | - } |
|
| 1388 | - } |
|
| 1389 | - |
|
| 1390 | - |
|
| 1391 | - |
|
| 1392 | - /** |
|
| 1393 | - * Add in our autosave ajax handlers |
|
| 1394 | - * |
|
| 1395 | - */ |
|
| 1396 | - protected function _ee_autosave_create_new() |
|
| 1397 | - { |
|
| 1398 | - } |
|
| 1399 | - |
|
| 1400 | - |
|
| 1401 | - /** |
|
| 1402 | - * More autosave handlers. |
|
| 1403 | - */ |
|
| 1404 | - protected function _ee_autosave_edit() |
|
| 1405 | - { |
|
| 1406 | - return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
| 1407 | - } |
|
| 1408 | - |
|
| 1409 | - |
|
| 1410 | - |
|
| 1411 | - /** |
|
| 1412 | - * _generate_publish_box_extra_content |
|
| 1413 | - */ |
|
| 1414 | - private function _generate_publish_box_extra_content() |
|
| 1415 | - { |
|
| 1416 | - //load formatter helper |
|
| 1417 | - //args for getting related registrations |
|
| 1418 | - $approved_query_args = array( |
|
| 1419 | - array( |
|
| 1420 | - 'REG_deleted' => 0, |
|
| 1421 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 1422 | - ), |
|
| 1423 | - ); |
|
| 1424 | - $not_approved_query_args = array( |
|
| 1425 | - array( |
|
| 1426 | - 'REG_deleted' => 0, |
|
| 1427 | - 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
| 1428 | - ), |
|
| 1429 | - ); |
|
| 1430 | - $pending_payment_query_args = array( |
|
| 1431 | - array( |
|
| 1432 | - 'REG_deleted' => 0, |
|
| 1433 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
| 1434 | - ), |
|
| 1435 | - ); |
|
| 1436 | - // publish box |
|
| 1437 | - $publish_box_extra_args = array( |
|
| 1438 | - 'view_approved_reg_url' => add_query_arg( |
|
| 1439 | - array( |
|
| 1440 | - 'action' => 'default', |
|
| 1441 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1442 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
| 1443 | - ), |
|
| 1444 | - REG_ADMIN_URL |
|
| 1445 | - ), |
|
| 1446 | - 'view_not_approved_reg_url' => add_query_arg( |
|
| 1447 | - array( |
|
| 1448 | - 'action' => 'default', |
|
| 1449 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1450 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
| 1451 | - ), |
|
| 1452 | - REG_ADMIN_URL |
|
| 1453 | - ), |
|
| 1454 | - 'view_pending_payment_reg_url' => add_query_arg( |
|
| 1455 | - array( |
|
| 1456 | - 'action' => 'default', |
|
| 1457 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1458 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
| 1459 | - ), |
|
| 1460 | - REG_ADMIN_URL |
|
| 1461 | - ), |
|
| 1462 | - 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1463 | - 'Registration', |
|
| 1464 | - $approved_query_args |
|
| 1465 | - ), |
|
| 1466 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1467 | - 'Registration', |
|
| 1468 | - $not_approved_query_args |
|
| 1469 | - ), |
|
| 1470 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
| 1471 | - 'Registration', |
|
| 1472 | - $pending_payment_query_args |
|
| 1473 | - ), |
|
| 1474 | - 'misc_pub_section_class' => apply_filters( |
|
| 1475 | - 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
| 1476 | - 'misc-pub-section' |
|
| 1477 | - ), |
|
| 1478 | - ); |
|
| 1479 | - ob_start(); |
|
| 1480 | - do_action( |
|
| 1481 | - 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
| 1482 | - $this->_cpt_model_obj |
|
| 1483 | - ); |
|
| 1484 | - $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
| 1485 | - // load template |
|
| 1486 | - EEH_Template::display_template( |
|
| 1487 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
| 1488 | - $publish_box_extra_args |
|
| 1489 | - ); |
|
| 1490 | - } |
|
| 1491 | - |
|
| 1492 | - |
|
| 1493 | - |
|
| 1494 | - /** |
|
| 1495 | - * @return EE_Event |
|
| 1496 | - */ |
|
| 1497 | - public function get_event_object() |
|
| 1498 | - { |
|
| 1499 | - return $this->_cpt_model_obj; |
|
| 1500 | - } |
|
| 1501 | - |
|
| 1502 | - |
|
| 1503 | - |
|
| 1504 | - |
|
| 1505 | - /** METABOXES * */ |
|
| 1506 | - /** |
|
| 1507 | - * _register_event_editor_meta_boxes |
|
| 1508 | - * add all metaboxes related to the event_editor |
|
| 1509 | - * |
|
| 1510 | - * @return void |
|
| 1511 | - */ |
|
| 1512 | - protected function _register_event_editor_meta_boxes() |
|
| 1513 | - { |
|
| 1514 | - $this->verify_cpt_object(); |
|
| 1515 | - add_meta_box( |
|
| 1516 | - 'espresso_event_editor_tickets', |
|
| 1517 | - esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
| 1518 | - array($this, 'ticket_metabox'), |
|
| 1519 | - $this->page_slug, |
|
| 1520 | - 'normal', |
|
| 1521 | - 'high' |
|
| 1522 | - ); |
|
| 1523 | - add_meta_box( |
|
| 1524 | - 'espresso_event_editor_event_options', |
|
| 1525 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
| 1526 | - array($this, 'registration_options_meta_box'), |
|
| 1527 | - $this->page_slug, |
|
| 1528 | - 'side', |
|
| 1529 | - 'default' |
|
| 1530 | - ); |
|
| 1531 | - // NOTE: if you're looking for other metaboxes in here, |
|
| 1532 | - // where a metabox has a related management page in the admin |
|
| 1533 | - // you will find it setup in the related management page's "_Hooks" file. |
|
| 1534 | - // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
| 1535 | - } |
|
| 1536 | - |
|
| 1537 | - |
|
| 1538 | - /** |
|
| 1539 | - * @throws DomainException |
|
| 1540 | - * @throws EE_Error |
|
| 1541 | - */ |
|
| 1542 | - public function ticket_metabox() |
|
| 1543 | - { |
|
| 1544 | - $existing_datetime_ids = $existing_ticket_ids = array(); |
|
| 1545 | - //defaults for template args |
|
| 1546 | - $template_args = array( |
|
| 1547 | - 'existing_datetime_ids' => '', |
|
| 1548 | - 'event_datetime_help_link' => '', |
|
| 1549 | - 'ticket_options_help_link' => '', |
|
| 1550 | - 'time' => null, |
|
| 1551 | - 'ticket_rows' => '', |
|
| 1552 | - 'existing_ticket_ids' => '', |
|
| 1553 | - 'total_ticket_rows' => 1, |
|
| 1554 | - 'ticket_js_structure' => '', |
|
| 1555 | - 'trash_icon' => 'ee-lock-icon', |
|
| 1556 | - 'disabled' => '', |
|
| 1557 | - ); |
|
| 1558 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
| 1559 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1560 | - /** |
|
| 1561 | - * 1. Start with retrieving Datetimes |
|
| 1562 | - * 2. Fore each datetime get related tickets |
|
| 1563 | - * 3. For each ticket get related prices |
|
| 1564 | - */ |
|
| 1565 | - $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
| 1566 | - /** @type EE_Datetime $first_datetime */ |
|
| 1567 | - $first_datetime = reset($times); |
|
| 1568 | - //do we get related tickets? |
|
| 1569 | - if ($first_datetime instanceof EE_Datetime |
|
| 1570 | - && $first_datetime->ID() !== 0 |
|
| 1571 | - ) { |
|
| 1572 | - $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
| 1573 | - $template_args['time'] = $first_datetime; |
|
| 1574 | - $related_tickets = $first_datetime->tickets( |
|
| 1575 | - array( |
|
| 1576 | - array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
| 1577 | - 'default_where_conditions' => 'none', |
|
| 1578 | - ) |
|
| 1579 | - ); |
|
| 1580 | - if ( ! empty($related_tickets)) { |
|
| 1581 | - $template_args['total_ticket_rows'] = count($related_tickets); |
|
| 1582 | - $row = 0; |
|
| 1583 | - foreach ($related_tickets as $ticket) { |
|
| 1584 | - $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
| 1585 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
| 1586 | - $row++; |
|
| 1587 | - } |
|
| 1588 | - } else { |
|
| 1589 | - $template_args['total_ticket_rows'] = 1; |
|
| 1590 | - /** @type EE_Ticket $ticket */ |
|
| 1591 | - $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
| 1592 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
| 1593 | - } |
|
| 1594 | - } else { |
|
| 1595 | - $template_args['time'] = $times[0]; |
|
| 1596 | - /** @type EE_Ticket $ticket */ |
|
| 1597 | - $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
| 1598 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
| 1599 | - // NOTE: we're just sending the first default row |
|
| 1600 | - // (decaf can't manage default tickets so this should be sufficient); |
|
| 1601 | - } |
|
| 1602 | - $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
| 1603 | - 'event_editor_event_datetimes_help_tab' |
|
| 1604 | - ); |
|
| 1605 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
| 1606 | - $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
| 1607 | - $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
| 1608 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
| 1609 | - EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
| 1610 | - true |
|
| 1611 | - ); |
|
| 1612 | - $template = apply_filters( |
|
| 1613 | - 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
| 1614 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
| 1615 | - ); |
|
| 1616 | - EEH_Template::display_template($template, $template_args); |
|
| 1617 | - } |
|
| 1618 | - |
|
| 1619 | - |
|
| 1620 | - |
|
| 1621 | - /** |
|
| 1622 | - * Setup an individual ticket form for the decaf event editor page |
|
| 1623 | - * |
|
| 1624 | - * @access private |
|
| 1625 | - * @param EE_Ticket $ticket the ticket object |
|
| 1626 | - * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
| 1627 | - * @param int $row |
|
| 1628 | - * @return string generated html for the ticket row. |
|
| 1629 | - */ |
|
| 1630 | - private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
| 1631 | - { |
|
| 1632 | - $template_args = array( |
|
| 1633 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
| 1634 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
| 1635 | - : '', |
|
| 1636 | - 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
| 1637 | - 'TKT_ID' => $ticket->get('TKT_ID'), |
|
| 1638 | - 'TKT_name' => $ticket->get('TKT_name'), |
|
| 1639 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
| 1640 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
| 1641 | - 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
| 1642 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
| 1643 | - 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
| 1644 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
| 1645 | - 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
| 1646 | - && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
| 1647 | - ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
| 1648 | - 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
| 1649 | - : ' disabled=disabled', |
|
| 1650 | - ); |
|
| 1651 | - $price = $ticket->ID() !== 0 |
|
| 1652 | - ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
| 1653 | - : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
| 1654 | - $price_args = array( |
|
| 1655 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
| 1656 | - 'PRC_amount' => $price->get('PRC_amount'), |
|
| 1657 | - 'PRT_ID' => $price->get('PRT_ID'), |
|
| 1658 | - 'PRC_ID' => $price->get('PRC_ID'), |
|
| 1659 | - 'PRC_is_default' => $price->get('PRC_is_default'), |
|
| 1660 | - ); |
|
| 1661 | - //make sure we have default start and end dates if skeleton |
|
| 1662 | - //handle rows that should NOT be empty |
|
| 1663 | - if (empty($template_args['TKT_start_date'])) { |
|
| 1664 | - //if empty then the start date will be now. |
|
| 1665 | - $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
| 1666 | - } |
|
| 1667 | - if (empty($template_args['TKT_end_date'])) { |
|
| 1668 | - //get the earliest datetime (if present); |
|
| 1669 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
| 1670 | - ? $this->_cpt_model_obj->get_first_related( |
|
| 1671 | - 'Datetime', |
|
| 1672 | - array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
| 1673 | - ) |
|
| 1674 | - : null; |
|
| 1675 | - if ( ! empty($earliest_dtt)) { |
|
| 1676 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
| 1677 | - } else { |
|
| 1678 | - $template_args['TKT_end_date'] = date( |
|
| 1679 | - 'Y-m-d h:i a', |
|
| 1680 | - mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
| 1681 | - ); |
|
| 1682 | - } |
|
| 1683 | - } |
|
| 1684 | - $template_args = array_merge($template_args, $price_args); |
|
| 1685 | - $template = apply_filters( |
|
| 1686 | - 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
| 1687 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
| 1688 | - $ticket |
|
| 1689 | - ); |
|
| 1690 | - return EEH_Template::display_template($template, $template_args, true); |
|
| 1691 | - } |
|
| 1692 | - |
|
| 1693 | - |
|
| 1694 | - /** |
|
| 1695 | - * @throws DomainException |
|
| 1696 | - */ |
|
| 1697 | - public function registration_options_meta_box() |
|
| 1698 | - { |
|
| 1699 | - $yes_no_values = array( |
|
| 1700 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
| 1701 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
| 1702 | - ); |
|
| 1703 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
| 1704 | - array( |
|
| 1705 | - EEM_Registration::status_id_cancelled, |
|
| 1706 | - EEM_Registration::status_id_declined, |
|
| 1707 | - EEM_Registration::status_id_incomplete, |
|
| 1708 | - ), |
|
| 1709 | - true |
|
| 1710 | - ); |
|
| 1711 | - //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
| 1712 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
| 1713 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
| 1714 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
| 1715 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 1716 | - 'default_reg_status', |
|
| 1717 | - $default_reg_status_values, |
|
| 1718 | - $this->_cpt_model_obj->default_registration_status() |
|
| 1719 | - ); |
|
| 1720 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 1721 | - 'display_desc', |
|
| 1722 | - $yes_no_values, |
|
| 1723 | - $this->_cpt_model_obj->display_description() |
|
| 1724 | - ); |
|
| 1725 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 1726 | - 'display_ticket_selector', |
|
| 1727 | - $yes_no_values, |
|
| 1728 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
| 1729 | - '', |
|
| 1730 | - '', |
|
| 1731 | - false |
|
| 1732 | - ); |
|
| 1733 | - $template_args['additional_registration_options'] = apply_filters( |
|
| 1734 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
| 1735 | - '', |
|
| 1736 | - $template_args, |
|
| 1737 | - $yes_no_values, |
|
| 1738 | - $default_reg_status_values |
|
| 1739 | - ); |
|
| 1740 | - EEH_Template::display_template( |
|
| 1741 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 1742 | - $template_args |
|
| 1743 | - ); |
|
| 1744 | - } |
|
| 1745 | - |
|
| 1746 | - |
|
| 1747 | - |
|
| 1748 | - /** |
|
| 1749 | - * _get_events() |
|
| 1750 | - * This method simply returns all the events (for the given _view and paging) |
|
| 1751 | - * |
|
| 1752 | - * @access public |
|
| 1753 | - * @param int $per_page count of items per page (20 default); |
|
| 1754 | - * @param int $current_page what is the current page being viewed. |
|
| 1755 | - * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
| 1756 | - * If FALSE then we return an array of event objects |
|
| 1757 | - * that match the given _view and paging parameters. |
|
| 1758 | - * @return array an array of event objects. |
|
| 1759 | - */ |
|
| 1760 | - public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
| 1761 | - { |
|
| 1762 | - $EEME = $this->_event_model(); |
|
| 1763 | - $offset = ($current_page - 1) * $per_page; |
|
| 1764 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
| 1765 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
| 1766 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
| 1767 | - if (isset($this->_req_data['month_range'])) { |
|
| 1768 | - $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
| 1769 | - //simulate the FIRST day of the month, that fixes issues for months like February |
|
| 1770 | - //where PHP doesn't know what to assume for date. |
|
| 1771 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10437 |
|
| 1772 | - $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; |
|
| 1773 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
| 1774 | - } |
|
| 1775 | - $where = array(); |
|
| 1776 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
| 1777 | - //determine what post_status our condition will have for the query. |
|
| 1778 | - switch ($status) { |
|
| 1779 | - case 'month' : |
|
| 1780 | - case 'today' : |
|
| 1781 | - case null : |
|
| 1782 | - case 'all' : |
|
| 1783 | - break; |
|
| 1784 | - case 'draft' : |
|
| 1785 | - $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
| 1786 | - break; |
|
| 1787 | - default : |
|
| 1788 | - $where['status'] = $status; |
|
| 1789 | - } |
|
| 1790 | - //categories? |
|
| 1791 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
| 1792 | - ? $this->_req_data['EVT_CAT'] : null; |
|
| 1793 | - if ( ! empty ($category)) { |
|
| 1794 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 1795 | - $where['Term_Taxonomy.term_id'] = $category; |
|
| 1796 | - } |
|
| 1797 | - //date where conditions |
|
| 1798 | - $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
| 1799 | - if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
| 1800 | - $DateTime = new DateTime( |
|
| 1801 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
| 1802 | - new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
| 1803 | - ); |
|
| 1804 | - $start = $DateTime->format(implode(' ', $start_formats)); |
|
| 1805 | - $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
| 1806 | - ->format('t'))->setTime(23, 59, 59) |
|
| 1807 | - ->format(implode(' ', $start_formats)); |
|
| 1808 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1809 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
| 1810 | - $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1811 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
| 1812 | - $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
| 1813 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1814 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
| 1815 | - $now = date('Y-m-01'); |
|
| 1816 | - $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1817 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
| 1818 | - $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
| 1819 | - ->setTime(23, 59, 59) |
|
| 1820 | - ->format(implode(' ', $start_formats)); |
|
| 1821 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1822 | - } |
|
| 1823 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 1824 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
| 1825 | - } else { |
|
| 1826 | - if ( ! isset($where['status'])) { |
|
| 1827 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 1828 | - $where['OR'] = array( |
|
| 1829 | - 'status*restrict_private' => array('!=', 'private'), |
|
| 1830 | - 'AND' => array( |
|
| 1831 | - 'status*inclusive' => array('=', 'private'), |
|
| 1832 | - 'EVT_wp_user' => get_current_user_id(), |
|
| 1833 | - ), |
|
| 1834 | - ); |
|
| 1835 | - } |
|
| 1836 | - } |
|
| 1837 | - } |
|
| 1838 | - if (isset($this->_req_data['EVT_wp_user'])) { |
|
| 1839 | - if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
| 1840 | - && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
| 1841 | - ) { |
|
| 1842 | - $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
| 1843 | - } |
|
| 1844 | - } |
|
| 1845 | - //search query handling |
|
| 1846 | - if (isset($this->_req_data['s'])) { |
|
| 1847 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 1848 | - $where['OR'] = array( |
|
| 1849 | - 'EVT_name' => array('LIKE', $search_string), |
|
| 1850 | - 'EVT_desc' => array('LIKE', $search_string), |
|
| 1851 | - 'EVT_short_desc' => array('LIKE', $search_string), |
|
| 1852 | - ); |
|
| 1853 | - } |
|
| 1854 | - $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
| 1855 | - $query_params = apply_filters( |
|
| 1856 | - 'FHEE__Events_Admin_Page__get_events__query_params', |
|
| 1857 | - array( |
|
| 1858 | - $where, |
|
| 1859 | - 'limit' => $limit, |
|
| 1860 | - 'order_by' => $orderby, |
|
| 1861 | - 'order' => $order, |
|
| 1862 | - 'group_by' => 'EVT_ID', |
|
| 1863 | - ), |
|
| 1864 | - $this->_req_data |
|
| 1865 | - ); |
|
| 1866 | - //let's first check if we have special requests coming in. |
|
| 1867 | - if (isset($this->_req_data['active_status'])) { |
|
| 1868 | - switch ($this->_req_data['active_status']) { |
|
| 1869 | - case 'upcoming' : |
|
| 1870 | - return $EEME->get_upcoming_events($query_params, $count); |
|
| 1871 | - break; |
|
| 1872 | - case 'expired' : |
|
| 1873 | - return $EEME->get_expired_events($query_params, $count); |
|
| 1874 | - break; |
|
| 1875 | - case 'active' : |
|
| 1876 | - return $EEME->get_active_events($query_params, $count); |
|
| 1877 | - break; |
|
| 1878 | - case 'inactive' : |
|
| 1879 | - return $EEME->get_inactive_events($query_params, $count); |
|
| 1880 | - break; |
|
| 1881 | - } |
|
| 1882 | - } |
|
| 1883 | - $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
| 1884 | - return $events; |
|
| 1885 | - } |
|
| 1886 | - |
|
| 1887 | - |
|
| 1888 | - |
|
| 1889 | - /** |
|
| 1890 | - * handling for WordPress CPT actions (trash, restore, delete) |
|
| 1891 | - * |
|
| 1892 | - * @param string $post_id |
|
| 1893 | - */ |
|
| 1894 | - public function trash_cpt_item($post_id) |
|
| 1895 | - { |
|
| 1896 | - $this->_req_data['EVT_ID'] = $post_id; |
|
| 1897 | - $this->_trash_or_restore_event('trash', false); |
|
| 1898 | - } |
|
| 1899 | - |
|
| 1900 | - |
|
| 1901 | - |
|
| 1902 | - /** |
|
| 1903 | - * @param string $post_id |
|
| 1904 | - */ |
|
| 1905 | - public function restore_cpt_item($post_id) |
|
| 1906 | - { |
|
| 1907 | - $this->_req_data['EVT_ID'] = $post_id; |
|
| 1908 | - $this->_trash_or_restore_event('draft', false); |
|
| 1909 | - } |
|
| 1910 | - |
|
| 1911 | - |
|
| 1912 | - |
|
| 1913 | - /** |
|
| 1914 | - * @param string $post_id |
|
| 1915 | - */ |
|
| 1916 | - public function delete_cpt_item($post_id) |
|
| 1917 | - { |
|
| 1918 | - $this->_req_data['EVT_ID'] = $post_id; |
|
| 1919 | - $this->_delete_event(false); |
|
| 1920 | - } |
|
| 1921 | - |
|
| 1922 | - |
|
| 1923 | - |
|
| 1924 | - /** |
|
| 1925 | - * _trash_or_restore_event |
|
| 1926 | - * |
|
| 1927 | - * @access protected |
|
| 1928 | - * @param string $event_status |
|
| 1929 | - * @param bool $redirect_after |
|
| 1930 | - */ |
|
| 1931 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
| 1932 | - { |
|
| 1933 | - //determine the event id and set to array. |
|
| 1934 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
| 1935 | - // loop thru events |
|
| 1936 | - if ($EVT_ID) { |
|
| 1937 | - // clean status |
|
| 1938 | - $event_status = sanitize_key($event_status); |
|
| 1939 | - // grab status |
|
| 1940 | - if ( ! empty($event_status)) { |
|
| 1941 | - $success = $this->_change_event_status($EVT_ID, $event_status); |
|
| 1942 | - } else { |
|
| 1943 | - $success = false; |
|
| 1944 | - $msg = esc_html__( |
|
| 1945 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 1946 | - 'event_espresso' |
|
| 1947 | - ); |
|
| 1948 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1949 | - } |
|
| 1950 | - } else { |
|
| 1951 | - $success = false; |
|
| 1952 | - $msg = esc_html__( |
|
| 1953 | - 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 1954 | - 'event_espresso' |
|
| 1955 | - ); |
|
| 1956 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1957 | - } |
|
| 1958 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 1959 | - if ($redirect_after) { |
|
| 1960 | - $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
| 1961 | - } |
|
| 1962 | - } |
|
| 1963 | - |
|
| 1964 | - |
|
| 1965 | - |
|
| 1966 | - /** |
|
| 1967 | - * _trash_or_restore_events |
|
| 1968 | - * |
|
| 1969 | - * @access protected |
|
| 1970 | - * @param string $event_status |
|
| 1971 | - * @return void |
|
| 1972 | - */ |
|
| 1973 | - protected function _trash_or_restore_events($event_status = 'trash') |
|
| 1974 | - { |
|
| 1975 | - // clean status |
|
| 1976 | - $event_status = sanitize_key($event_status); |
|
| 1977 | - // grab status |
|
| 1978 | - if ( ! empty($event_status)) { |
|
| 1979 | - $success = true; |
|
| 1980 | - //determine the event id and set to array. |
|
| 1981 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 1982 | - // loop thru events |
|
| 1983 | - foreach ($EVT_IDs as $EVT_ID) { |
|
| 1984 | - if ($EVT_ID = absint($EVT_ID)) { |
|
| 1985 | - $results = $this->_change_event_status($EVT_ID, $event_status); |
|
| 1986 | - $success = $results !== false ? $success : false; |
|
| 1987 | - } else { |
|
| 1988 | - $msg = sprintf( |
|
| 1989 | - esc_html__( |
|
| 1990 | - 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 1991 | - 'event_espresso' |
|
| 1992 | - ), |
|
| 1993 | - $EVT_ID |
|
| 1994 | - ); |
|
| 1995 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1996 | - $success = false; |
|
| 1997 | - } |
|
| 1998 | - } |
|
| 1999 | - } else { |
|
| 2000 | - $success = false; |
|
| 2001 | - $msg = esc_html__( |
|
| 2002 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 2003 | - 'event_espresso' |
|
| 2004 | - ); |
|
| 2005 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2006 | - } |
|
| 2007 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
| 2008 | - $success = $success ? 2 : false; |
|
| 2009 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 2010 | - $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
| 2011 | - } |
|
| 2012 | - |
|
| 2013 | - |
|
| 2014 | - |
|
| 2015 | - /** |
|
| 2016 | - * _trash_or_restore_events |
|
| 2017 | - * |
|
| 2018 | - * @access private |
|
| 2019 | - * @param int $EVT_ID |
|
| 2020 | - * @param string $event_status |
|
| 2021 | - * @return bool |
|
| 2022 | - */ |
|
| 2023 | - private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
| 2024 | - { |
|
| 2025 | - // grab event id |
|
| 2026 | - if ( ! $EVT_ID) { |
|
| 2027 | - $msg = esc_html__( |
|
| 2028 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2029 | - 'event_espresso' |
|
| 2030 | - ); |
|
| 2031 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2032 | - return false; |
|
| 2033 | - } |
|
| 2034 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2035 | - // clean status |
|
| 2036 | - $event_status = sanitize_key($event_status); |
|
| 2037 | - // grab status |
|
| 2038 | - if (empty($event_status)) { |
|
| 2039 | - $msg = esc_html__( |
|
| 2040 | - 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
| 2041 | - 'event_espresso' |
|
| 2042 | - ); |
|
| 2043 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2044 | - return false; |
|
| 2045 | - } |
|
| 2046 | - // was event trashed or restored ? |
|
| 2047 | - switch ($event_status) { |
|
| 2048 | - case 'draft' : |
|
| 2049 | - $action = 'restored from the trash'; |
|
| 2050 | - $hook = 'AHEE_event_restored_from_trash'; |
|
| 2051 | - break; |
|
| 2052 | - case 'trash' : |
|
| 2053 | - $action = 'moved to the trash'; |
|
| 2054 | - $hook = 'AHEE_event_moved_to_trash'; |
|
| 2055 | - break; |
|
| 2056 | - default : |
|
| 2057 | - $action = 'updated'; |
|
| 2058 | - $hook = false; |
|
| 2059 | - } |
|
| 2060 | - //use class to change status |
|
| 2061 | - $this->_cpt_model_obj->set_status($event_status); |
|
| 2062 | - $success = $this->_cpt_model_obj->save(); |
|
| 2063 | - if ($success === false) { |
|
| 2064 | - $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
| 2065 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2066 | - return false; |
|
| 2067 | - } |
|
| 2068 | - if ($hook) { |
|
| 2069 | - do_action($hook); |
|
| 2070 | - } |
|
| 2071 | - return true; |
|
| 2072 | - } |
|
| 2073 | - |
|
| 2074 | - |
|
| 2075 | - |
|
| 2076 | - /** |
|
| 2077 | - * _delete_event |
|
| 2078 | - * |
|
| 2079 | - * @access protected |
|
| 2080 | - * @param bool $redirect_after |
|
| 2081 | - */ |
|
| 2082 | - protected function _delete_event($redirect_after = true) |
|
| 2083 | - { |
|
| 2084 | - //determine the event id and set to array. |
|
| 2085 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
| 2086 | - $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
| 2087 | - // loop thru events |
|
| 2088 | - if ($EVT_ID) { |
|
| 2089 | - $success = $this->_permanently_delete_event($EVT_ID); |
|
| 2090 | - // get list of events with no prices |
|
| 2091 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
| 2092 | - // remove this event from the list of events with no prices |
|
| 2093 | - if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
| 2094 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
| 2095 | - } |
|
| 2096 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
| 2097 | - } else { |
|
| 2098 | - $success = false; |
|
| 2099 | - $msg = esc_html__( |
|
| 2100 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
| 2101 | - 'event_espresso' |
|
| 2102 | - ); |
|
| 2103 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2104 | - } |
|
| 2105 | - if ($redirect_after) { |
|
| 2106 | - $this->_redirect_after_action( |
|
| 2107 | - $success, |
|
| 2108 | - 'Event', |
|
| 2109 | - 'deleted', |
|
| 2110 | - array('action' => 'default', 'status' => 'trash') |
|
| 2111 | - ); |
|
| 2112 | - } |
|
| 2113 | - } |
|
| 2114 | - |
|
| 2115 | - |
|
| 2116 | - |
|
| 2117 | - /** |
|
| 2118 | - * _delete_events |
|
| 2119 | - * |
|
| 2120 | - * @access protected |
|
| 2121 | - * @return void |
|
| 2122 | - */ |
|
| 2123 | - protected function _delete_events() |
|
| 2124 | - { |
|
| 2125 | - $success = true; |
|
| 2126 | - // get list of events with no prices |
|
| 2127 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
| 2128 | - //determine the event id and set to array. |
|
| 2129 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 2130 | - // loop thru events |
|
| 2131 | - foreach ($EVT_IDs as $EVT_ID) { |
|
| 2132 | - $EVT_ID = absint($EVT_ID); |
|
| 2133 | - if ($EVT_ID) { |
|
| 2134 | - $results = $this->_permanently_delete_event($EVT_ID); |
|
| 2135 | - $success = $results !== false ? $success : false; |
|
| 2136 | - // remove this event from the list of events with no prices |
|
| 2137 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
| 2138 | - } else { |
|
| 2139 | - $success = false; |
|
| 2140 | - $msg = esc_html__( |
|
| 2141 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
| 2142 | - 'event_espresso' |
|
| 2143 | - ); |
|
| 2144 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2145 | - } |
|
| 2146 | - } |
|
| 2147 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
| 2148 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
| 2149 | - $success = $success ? 2 : false; |
|
| 2150 | - $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
| 2151 | - } |
|
| 2152 | - |
|
| 2153 | - |
|
| 2154 | - |
|
| 2155 | - /** |
|
| 2156 | - * _permanently_delete_event |
|
| 2157 | - * |
|
| 2158 | - * @access private |
|
| 2159 | - * @param int $EVT_ID |
|
| 2160 | - * @return bool |
|
| 2161 | - */ |
|
| 2162 | - private function _permanently_delete_event($EVT_ID = 0) |
|
| 2163 | - { |
|
| 2164 | - // grab event id |
|
| 2165 | - if ( ! $EVT_ID) { |
|
| 2166 | - $msg = esc_html__( |
|
| 2167 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2168 | - 'event_espresso' |
|
| 2169 | - ); |
|
| 2170 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2171 | - return false; |
|
| 2172 | - } |
|
| 2173 | - if ( |
|
| 2174 | - ! $this->_cpt_model_obj instanceof EE_Event |
|
| 2175 | - || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
| 2176 | - ) { |
|
| 2177 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2178 | - } |
|
| 2179 | - if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
| 2180 | - return false; |
|
| 2181 | - } |
|
| 2182 | - //need to delete related tickets and prices first. |
|
| 2183 | - $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
| 2184 | - foreach ($datetimes as $datetime) { |
|
| 2185 | - $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
| 2186 | - $tickets = $datetime->get_many_related('Ticket'); |
|
| 2187 | - foreach ($tickets as $ticket) { |
|
| 2188 | - $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
| 2189 | - $ticket->delete_related_permanently('Price'); |
|
| 2190 | - $ticket->delete_permanently(); |
|
| 2191 | - } |
|
| 2192 | - $datetime->delete(); |
|
| 2193 | - } |
|
| 2194 | - //what about related venues or terms? |
|
| 2195 | - $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
| 2196 | - foreach ($venues as $venue) { |
|
| 2197 | - $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
| 2198 | - } |
|
| 2199 | - //any attached question groups? |
|
| 2200 | - $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
| 2201 | - if ( ! empty($question_groups)) { |
|
| 2202 | - foreach ($question_groups as $question_group) { |
|
| 2203 | - $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
| 2204 | - } |
|
| 2205 | - } |
|
| 2206 | - //Message Template Groups |
|
| 2207 | - $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
| 2208 | - /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
| 2209 | - $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
| 2210 | - foreach ($term_taxonomies as $term_taxonomy) { |
|
| 2211 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
| 2212 | - } |
|
| 2213 | - $success = $this->_cpt_model_obj->delete_permanently(); |
|
| 2214 | - // did it all go as planned ? |
|
| 2215 | - if ($success) { |
|
| 2216 | - $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
| 2217 | - EE_Error::add_success($msg); |
|
| 2218 | - } else { |
|
| 2219 | - $msg = sprintf( |
|
| 2220 | - esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
| 2221 | - $EVT_ID |
|
| 2222 | - ); |
|
| 2223 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2224 | - return false; |
|
| 2225 | - } |
|
| 2226 | - do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
| 2227 | - return true; |
|
| 2228 | - } |
|
| 2229 | - |
|
| 2230 | - |
|
| 2231 | - |
|
| 2232 | - /** |
|
| 2233 | - * get total number of events |
|
| 2234 | - * |
|
| 2235 | - * @access public |
|
| 2236 | - * @return int |
|
| 2237 | - */ |
|
| 2238 | - public function total_events() |
|
| 2239 | - { |
|
| 2240 | - $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2241 | - return $count; |
|
| 2242 | - } |
|
| 2243 | - |
|
| 2244 | - |
|
| 2245 | - |
|
| 2246 | - /** |
|
| 2247 | - * get total number of draft events |
|
| 2248 | - * |
|
| 2249 | - * @access public |
|
| 2250 | - * @return int |
|
| 2251 | - */ |
|
| 2252 | - public function total_events_draft() |
|
| 2253 | - { |
|
| 2254 | - $where = array( |
|
| 2255 | - 'status' => array('IN', array('draft', 'auto-draft')), |
|
| 2256 | - ); |
|
| 2257 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2258 | - return $count; |
|
| 2259 | - } |
|
| 2260 | - |
|
| 2261 | - |
|
| 2262 | - |
|
| 2263 | - /** |
|
| 2264 | - * get total number of trashed events |
|
| 2265 | - * |
|
| 2266 | - * @access public |
|
| 2267 | - * @return int |
|
| 2268 | - */ |
|
| 2269 | - public function total_trashed_events() |
|
| 2270 | - { |
|
| 2271 | - $where = array( |
|
| 2272 | - 'status' => 'trash', |
|
| 2273 | - ); |
|
| 2274 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2275 | - return $count; |
|
| 2276 | - } |
|
| 2277 | - |
|
| 2278 | - |
|
| 2279 | - /** |
|
| 2280 | - * _default_event_settings |
|
| 2281 | - * This generates the Default Settings Tab |
|
| 2282 | - * |
|
| 2283 | - * @return void |
|
| 2284 | - * @throws EE_Error |
|
| 2285 | - */ |
|
| 2286 | - protected function _default_event_settings() |
|
| 2287 | - { |
|
| 2288 | - $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
| 2289 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 2290 | - $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html(); |
|
| 2291 | - $this->display_admin_page_with_sidebar(); |
|
| 2292 | - } |
|
| 2293 | - |
|
| 2294 | - |
|
| 2295 | - /** |
|
| 2296 | - * Return the form for event settings. |
|
| 2297 | - * @return EE_Form_Section_Proper |
|
| 2298 | - */ |
|
| 2299 | - protected function _default_event_settings_form() |
|
| 2300 | - { |
|
| 2301 | - $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2302 | - $registration_stati_for_selection = EEM_Registration::reg_status_array( |
|
| 2303 | - //exclude |
|
| 2304 | - array( |
|
| 2305 | - EEM_Registration::status_id_cancelled, |
|
| 2306 | - EEM_Registration::status_id_declined, |
|
| 2307 | - EEM_Registration::status_id_incomplete, |
|
| 2308 | - EEM_Registration::status_id_wait_list, |
|
| 2309 | - ), |
|
| 2310 | - true |
|
| 2311 | - ); |
|
| 2312 | - return new EE_Form_Section_Proper( |
|
| 2313 | - array( |
|
| 2314 | - 'name' => 'update_default_event_settings', |
|
| 2315 | - 'html_id' => 'update_default_event_settings', |
|
| 2316 | - 'html_class' => 'form-table', |
|
| 2317 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 2318 | - 'subsections' => apply_filters( |
|
| 2319 | - 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections', |
|
| 2320 | - array( |
|
| 2321 | - 'default_reg_status' => new EE_Select_Input( |
|
| 2322 | - $registration_stati_for_selection, |
|
| 2323 | - array( |
|
| 2324 | - 'default' => isset($registration_config->default_STS_ID) |
|
| 2325 | - && array_key_exists( |
|
| 2326 | - $registration_config->default_STS_ID, |
|
| 2327 | - $registration_stati_for_selection |
|
| 2328 | - ) |
|
| 2329 | - ? sanitize_text_field($registration_config->default_STS_ID) |
|
| 2330 | - : EEM_Registration::status_id_pending_payment, |
|
| 2331 | - 'html_label_text' => esc_html__('Default Registration Status', 'event_espresso') |
|
| 2332 | - . EEH_Template::get_help_tab_link( |
|
| 2333 | - 'default_settings_status_help_tab' |
|
| 2334 | - ), |
|
| 2335 | - 'html_help_text' => esc_html__( |
|
| 2336 | - 'This setting allows you to preselect what the default registration status setting is when creating an event. Note that changing this setting does NOT retroactively apply it to existing events.', |
|
| 2337 | - 'event_espresso' |
|
| 2338 | - ) |
|
| 2339 | - ) |
|
| 2340 | - ), |
|
| 2341 | - 'default_max_tickets' => new EE_Integer_Input( |
|
| 2342 | - array( |
|
| 2343 | - 'default' => isset($registration_config->default_maximum_number_of_tickets) |
|
| 2344 | - ? $registration_config->default_maximum_number_of_tickets |
|
| 2345 | - : EEM_Event::get_default_additional_limit(), |
|
| 2346 | - 'html_label_text' => esc_html__( |
|
| 2347 | - 'Default Maximum Tickets Allowed Per Order:', |
|
| 2348 | - 'event_espresso' |
|
| 2349 | - ) . EEH_Template::get_help_tab_link( |
|
| 2350 | - 'default_maximum_tickets_help_tab"' |
|
| 2351 | - ), |
|
| 2352 | - 'html_help_text' => esc_html__( |
|
| 2353 | - 'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.', |
|
| 2354 | - 'event_espresso' |
|
| 2355 | - ) |
|
| 2356 | - ) |
|
| 2357 | - ) |
|
| 2358 | - ) |
|
| 2359 | - ) |
|
| 2360 | - ) |
|
| 2361 | - ); |
|
| 2362 | - } |
|
| 2363 | - |
|
| 2364 | - |
|
| 2365 | - /** |
|
| 2366 | - * _update_default_event_settings |
|
| 2367 | - * |
|
| 2368 | - * @access protected |
|
| 2369 | - * @return void |
|
| 2370 | - * @throws EE_Error |
|
| 2371 | - */ |
|
| 2372 | - protected function _update_default_event_settings() |
|
| 2373 | - { |
|
| 2374 | - $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2375 | - $form = $this->_default_event_settings_form(); |
|
| 2376 | - if ($form->was_submitted()) { |
|
| 2377 | - $form->receive_form_submission(); |
|
| 2378 | - if ($form->is_valid()) { |
|
| 2379 | - $valid_data = $form->valid_data(); |
|
| 2380 | - if (isset($valid_data['default_reg_status'])) { |
|
| 2381 | - $registration_config->default_STS_ID = $valid_data['default_reg_status']; |
|
| 2382 | - } |
|
| 2383 | - if (isset($valid_data['default_max_tickets'])) { |
|
| 2384 | - $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets']; |
|
| 2385 | - } |
|
| 2386 | - //update because data was valid! |
|
| 2387 | - EE_Registry::instance()->CFG->update_espresso_config(); |
|
| 2388 | - EE_Error::overwrite_success(); |
|
| 2389 | - EE_Error::add_success( |
|
| 2390 | - __('Default Event Settings were updated', 'event_espresso') |
|
| 2391 | - ); |
|
| 2392 | - } |
|
| 2393 | - } |
|
| 2394 | - $this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true); |
|
| 2395 | - } |
|
| 2396 | - |
|
| 2397 | - |
|
| 2398 | - |
|
| 2399 | - /************* Templates *************/ |
|
| 2400 | - protected function _template_settings() |
|
| 2401 | - { |
|
| 2402 | - $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
| 2403 | - $this->_template_args['preview_img'] = '<img src="' |
|
| 2404 | - . EVENTS_ASSETS_URL |
|
| 2405 | - . DS |
|
| 2406 | - . 'images' |
|
| 2407 | - . DS |
|
| 2408 | - . 'caffeinated_template_features.jpg" alt="' |
|
| 2409 | - . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
| 2410 | - . '" />'; |
|
| 2411 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
| 2412 | - 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
| 2413 | - 'event_espresso' |
|
| 2414 | - ) . '</strong>'; |
|
| 2415 | - $this->display_admin_caf_preview_page('template_settings_tab'); |
|
| 2416 | - } |
|
| 2417 | - |
|
| 2418 | - |
|
| 2419 | - /** Event Category Stuff **/ |
|
| 2420 | - /** |
|
| 2421 | - * set the _category property with the category object for the loaded page. |
|
| 2422 | - * |
|
| 2423 | - * @access private |
|
| 2424 | - * @return void |
|
| 2425 | - */ |
|
| 2426 | - private function _set_category_object() |
|
| 2427 | - { |
|
| 2428 | - if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
| 2429 | - return; |
|
| 2430 | - } //already have the category object so get out. |
|
| 2431 | - //set default category object |
|
| 2432 | - $this->_set_empty_category_object(); |
|
| 2433 | - //only set if we've got an id |
|
| 2434 | - if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
| 2435 | - return; |
|
| 2436 | - } |
|
| 2437 | - $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
| 2438 | - $term = get_term($category_id, 'espresso_event_categories'); |
|
| 2439 | - if ( ! empty($term)) { |
|
| 2440 | - $this->_category->category_name = $term->name; |
|
| 2441 | - $this->_category->category_identifier = $term->slug; |
|
| 2442 | - $this->_category->category_desc = $term->description; |
|
| 2443 | - $this->_category->id = $term->term_id; |
|
| 2444 | - $this->_category->parent = $term->parent; |
|
| 2445 | - } |
|
| 2446 | - } |
|
| 2447 | - |
|
| 2448 | - |
|
| 2449 | - /** |
|
| 2450 | - * Clears out category properties. |
|
| 2451 | - */ |
|
| 2452 | - private function _set_empty_category_object() |
|
| 2453 | - { |
|
| 2454 | - $this->_category = new stdClass(); |
|
| 2455 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
| 2456 | - $this->_category->id = $this->_category->parent = 0; |
|
| 2457 | - } |
|
| 2458 | - |
|
| 2459 | - |
|
| 2460 | - /** |
|
| 2461 | - * @throws EE_Error |
|
| 2462 | - */ |
|
| 2463 | - protected function _category_list_table() |
|
| 2464 | - { |
|
| 2465 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2466 | - $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
| 2467 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 2468 | - 'add_category', |
|
| 2469 | - 'add_category', |
|
| 2470 | - array(), |
|
| 2471 | - 'add-new-h2' |
|
| 2472 | - ); |
|
| 2473 | - $this->display_admin_list_table_page_with_sidebar(); |
|
| 2474 | - } |
|
| 2475 | - |
|
| 2476 | - |
|
| 2477 | - |
|
| 2478 | - /** |
|
| 2479 | - * Output category details view. |
|
| 2480 | - */ |
|
| 2481 | - protected function _category_details($view) |
|
| 2482 | - { |
|
| 2483 | - //load formatter helper |
|
| 2484 | - //load field generator helper |
|
| 2485 | - $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
| 2486 | - $this->_set_add_edit_form_tags($route); |
|
| 2487 | - $this->_set_category_object(); |
|
| 2488 | - $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
| 2489 | - $delete_action = 'delete_category'; |
|
| 2490 | - //custom redirect |
|
| 2491 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2492 | - array('action' => 'category_list'), |
|
| 2493 | - $this->_admin_base_url |
|
| 2494 | - ); |
|
| 2495 | - $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
| 2496 | - //take care of contents |
|
| 2497 | - $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
| 2498 | - $this->display_admin_page_with_sidebar(); |
|
| 2499 | - } |
|
| 2500 | - |
|
| 2501 | - |
|
| 2502 | - |
|
| 2503 | - /** |
|
| 2504 | - * Output category details content. |
|
| 2505 | - */ |
|
| 2506 | - protected function _category_details_content() |
|
| 2507 | - { |
|
| 2508 | - $editor_args['category_desc'] = array( |
|
| 2509 | - 'type' => 'wp_editor', |
|
| 2510 | - 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
| 2511 | - 'class' => 'my_editor_custom', |
|
| 2512 | - 'wpeditor_args' => array('media_buttons' => false), |
|
| 2513 | - ); |
|
| 2514 | - $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
| 2515 | - $all_terms = get_terms( |
|
| 2516 | - array('espresso_event_categories'), |
|
| 2517 | - array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
| 2518 | - ); |
|
| 2519 | - //setup category select for term parents. |
|
| 2520 | - $category_select_values[] = array( |
|
| 2521 | - 'text' => esc_html__('No Parent', 'event_espresso'), |
|
| 2522 | - 'id' => 0, |
|
| 2523 | - ); |
|
| 2524 | - foreach ($all_terms as $term) { |
|
| 2525 | - $category_select_values[] = array( |
|
| 2526 | - 'text' => $term->name, |
|
| 2527 | - 'id' => $term->term_id, |
|
| 2528 | - ); |
|
| 2529 | - } |
|
| 2530 | - $category_select = EEH_Form_Fields::select_input( |
|
| 2531 | - 'category_parent', |
|
| 2532 | - $category_select_values, |
|
| 2533 | - $this->_category->parent |
|
| 2534 | - ); |
|
| 2535 | - $template_args = array( |
|
| 2536 | - 'category' => $this->_category, |
|
| 2537 | - 'category_select' => $category_select, |
|
| 2538 | - 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
| 2539 | - 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
| 2540 | - 'disable' => '', |
|
| 2541 | - 'disabled_message' => false, |
|
| 2542 | - ); |
|
| 2543 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
| 2544 | - return EEH_Template::display_template($template, $template_args, true); |
|
| 2545 | - } |
|
| 2546 | - |
|
| 2547 | - |
|
| 2548 | - /** |
|
| 2549 | - * Handles deleting categories. |
|
| 2550 | - */ |
|
| 2551 | - protected function _delete_categories() |
|
| 2552 | - { |
|
| 2553 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
| 2554 | - : (array)$this->_req_data['category_id']; |
|
| 2555 | - foreach ($cat_ids as $cat_id) { |
|
| 2556 | - $this->_delete_category($cat_id); |
|
| 2557 | - } |
|
| 2558 | - //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
| 2559 | - $query_args = array( |
|
| 2560 | - 'action' => 'category_list', |
|
| 2561 | - ); |
|
| 2562 | - $this->_redirect_after_action(0, '', '', $query_args); |
|
| 2563 | - } |
|
| 2564 | - |
|
| 2565 | - |
|
| 2566 | - |
|
| 2567 | - /** |
|
| 2568 | - * Handles deleting specific category. |
|
| 2569 | - * @param int $cat_id |
|
| 2570 | - */ |
|
| 2571 | - protected function _delete_category($cat_id) |
|
| 2572 | - { |
|
| 2573 | - $cat_id = absint($cat_id); |
|
| 2574 | - wp_delete_term($cat_id, 'espresso_event_categories'); |
|
| 2575 | - } |
|
| 2576 | - |
|
| 2577 | - |
|
| 2578 | - |
|
| 2579 | - /** |
|
| 2580 | - * Handles triggering the update or insertion of a new category. |
|
| 2581 | - * @param bool $new_category true means we're triggering the insert of a new category. |
|
| 2582 | - */ |
|
| 2583 | - protected function _insert_or_update_category($new_category) |
|
| 2584 | - { |
|
| 2585 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
| 2586 | - $success = 0; //we already have a success message so lets not send another. |
|
| 2587 | - if ($cat_id) { |
|
| 2588 | - $query_args = array( |
|
| 2589 | - 'action' => 'edit_category', |
|
| 2590 | - 'EVT_CAT_ID' => $cat_id, |
|
| 2591 | - ); |
|
| 2592 | - } else { |
|
| 2593 | - $query_args = array('action' => 'add_category'); |
|
| 2594 | - } |
|
| 2595 | - $this->_redirect_after_action($success, '', '', $query_args, true); |
|
| 2596 | - } |
|
| 2597 | - |
|
| 2598 | - |
|
| 2599 | - |
|
| 2600 | - /** |
|
| 2601 | - * Inserts or updates category |
|
| 2602 | - * @param bool $update (true indicates we're updating a category). |
|
| 2603 | - * @return bool|mixed|string |
|
| 2604 | - */ |
|
| 2605 | - private function _insert_category($update = false) |
|
| 2606 | - { |
|
| 2607 | - $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
| 2608 | - $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
| 2609 | - $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
| 2610 | - $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
| 2611 | - if (empty($category_name)) { |
|
| 2612 | - $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
| 2613 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2614 | - return false; |
|
| 2615 | - } |
|
| 2616 | - $term_args = array( |
|
| 2617 | - 'name' => $category_name, |
|
| 2618 | - 'description' => $category_desc, |
|
| 2619 | - 'parent' => $category_parent, |
|
| 2620 | - ); |
|
| 2621 | - //was the category_identifier input disabled? |
|
| 2622 | - if (isset($this->_req_data['category_identifier'])) { |
|
| 2623 | - $term_args['slug'] = $this->_req_data['category_identifier']; |
|
| 2624 | - } |
|
| 2625 | - $insert_ids = $update |
|
| 2626 | - ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
| 2627 | - : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
| 2628 | - if ( ! is_array($insert_ids)) { |
|
| 2629 | - $msg = esc_html__( |
|
| 2630 | - 'An error occurred and the category has not been saved to the database.', |
|
| 2631 | - 'event_espresso' |
|
| 2632 | - ); |
|
| 2633 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2634 | - } else { |
|
| 2635 | - $cat_id = $insert_ids['term_id']; |
|
| 2636 | - $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
| 2637 | - EE_Error::add_success($msg); |
|
| 2638 | - } |
|
| 2639 | - return $cat_id; |
|
| 2640 | - } |
|
| 2641 | - |
|
| 2642 | - |
|
| 2643 | - |
|
| 2644 | - /** |
|
| 2645 | - * Gets categories or count of categories matching the arguments in the request. |
|
| 2646 | - * @param int $per_page |
|
| 2647 | - * @param int $current_page |
|
| 2648 | - * @param bool $count |
|
| 2649 | - * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int |
|
| 2650 | - */ |
|
| 2651 | - public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
| 2652 | - { |
|
| 2653 | - //testing term stuff |
|
| 2654 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
| 2655 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
| 2656 | - $limit = ($current_page - 1) * $per_page; |
|
| 2657 | - $where = array('taxonomy' => 'espresso_event_categories'); |
|
| 2658 | - if (isset($this->_req_data['s'])) { |
|
| 2659 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2660 | - $where['OR'] = array( |
|
| 2661 | - 'Term.name' => array('LIKE', $sstr), |
|
| 2662 | - 'description' => array('LIKE', $sstr), |
|
| 2663 | - ); |
|
| 2664 | - } |
|
| 2665 | - $query_params = array( |
|
| 2666 | - $where, |
|
| 2667 | - 'order_by' => array($orderby => $order), |
|
| 2668 | - 'limit' => $limit . ',' . $per_page, |
|
| 2669 | - 'force_join' => array('Term'), |
|
| 2670 | - ); |
|
| 2671 | - $categories = $count |
|
| 2672 | - ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
| 2673 | - : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
| 2674 | - return $categories; |
|
| 2675 | - } |
|
| 2676 | - |
|
| 2677 | - /* end category stuff */ |
|
| 2678 | - /**************/ |
|
| 2679 | - |
|
| 2680 | - |
|
| 2681 | - /** |
|
| 2682 | - * Callback for the `ee_save_timezone_setting` ajax action. |
|
| 2683 | - * @throws EE_Error |
|
| 2684 | - */ |
|
| 2685 | - public function save_timezonestring_setting() |
|
| 2686 | - { |
|
| 2687 | - $timezone_string = isset($this->_req_data['timezone_selected']) |
|
| 2688 | - ? $this->_req_data['timezone_selected'] |
|
| 2689 | - : ''; |
|
| 2690 | - if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) |
|
| 2691 | - { |
|
| 2692 | - EE_Error::add_error( |
|
| 2693 | - esc_html('An invalid timezone string submitted.', 'event_espresso'), |
|
| 2694 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2695 | - ); |
|
| 2696 | - $this->_template_args['error'] = true; |
|
| 2697 | - $this->_return_json(); |
|
| 2698 | - } |
|
| 2699 | - |
|
| 2700 | - update_option('timezone_string', $timezone_string); |
|
| 2701 | - EE_Error::add_success( |
|
| 2702 | - esc_html__('Your timezone string was updated.', 'event_espresso') |
|
| 2703 | - ); |
|
| 2704 | - $this->_template_args['success'] = true; |
|
| 2705 | - $this->_return_json(true, array('action' => 'create_new')); |
|
| 2706 | - } |
|
| 394 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
| 395 | + 'require_nonce' => false, |
|
| 396 | + ), |
|
| 397 | + 'default_event_settings' => array( |
|
| 398 | + 'nav' => array( |
|
| 399 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
| 400 | + 'order' => 40, |
|
| 401 | + ), |
|
| 402 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 403 | + 'labels' => array( |
|
| 404 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
| 405 | + ), |
|
| 406 | + 'help_tabs' => array( |
|
| 407 | + 'default_settings_help_tab' => array( |
|
| 408 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
| 409 | + 'filename' => 'events_default_settings', |
|
| 410 | + ), |
|
| 411 | + 'default_settings_status_help_tab' => array( |
|
| 412 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
| 413 | + 'filename' => 'events_default_settings_status', |
|
| 414 | + ), |
|
| 415 | + 'default_maximum_tickets_help_tab' => array( |
|
| 416 | + 'title' => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'), |
|
| 417 | + 'filename' => 'events_default_settings_max_tickets', |
|
| 418 | + ) |
|
| 419 | + ), |
|
| 420 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
| 421 | + 'require_nonce' => false, |
|
| 422 | + ), |
|
| 423 | + //template settings |
|
| 424 | + 'template_settings' => array( |
|
| 425 | + 'nav' => array( |
|
| 426 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
| 427 | + 'order' => 30, |
|
| 428 | + ), |
|
| 429 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 430 | + 'help_tabs' => array( |
|
| 431 | + 'general_settings_templates_help_tab' => array( |
|
| 432 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
| 433 | + 'filename' => 'general_settings_templates', |
|
| 434 | + ), |
|
| 435 | + ), |
|
| 436 | + 'help_tour' => array('Templates_Help_Tour'), |
|
| 437 | + 'require_nonce' => false, |
|
| 438 | + ), |
|
| 439 | + //event category stuff |
|
| 440 | + 'add_category' => array( |
|
| 441 | + 'nav' => array( |
|
| 442 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
| 443 | + 'order' => 15, |
|
| 444 | + 'persistent' => false, |
|
| 445 | + ), |
|
| 446 | + 'help_tabs' => array( |
|
| 447 | + 'add_category_help_tab' => array( |
|
| 448 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
| 449 | + 'filename' => 'events_add_category', |
|
| 450 | + ), |
|
| 451 | + ), |
|
| 452 | + 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
| 453 | + 'metaboxes' => array('_publish_post_box'), |
|
| 454 | + 'require_nonce' => false, |
|
| 455 | + ), |
|
| 456 | + 'edit_category' => array( |
|
| 457 | + 'nav' => array( |
|
| 458 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
| 459 | + 'order' => 15, |
|
| 460 | + 'persistent' => false, |
|
| 461 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
| 462 | + ? add_query_arg( |
|
| 463 | + array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
| 464 | + $this->_current_page_view_url |
|
| 465 | + ) |
|
| 466 | + : $this->_admin_base_url, |
|
| 467 | + ), |
|
| 468 | + 'help_tabs' => array( |
|
| 469 | + 'edit_category_help_tab' => array( |
|
| 470 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
| 471 | + 'filename' => 'events_edit_category', |
|
| 472 | + ), |
|
| 473 | + ), |
|
| 474 | + /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
| 475 | + 'metaboxes' => array('_publish_post_box'), |
|
| 476 | + 'require_nonce' => false, |
|
| 477 | + ), |
|
| 478 | + 'category_list' => array( |
|
| 479 | + 'nav' => array( |
|
| 480 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
| 481 | + 'order' => 20, |
|
| 482 | + ), |
|
| 483 | + 'list_table' => 'Event_Categories_Admin_List_Table', |
|
| 484 | + 'help_tabs' => array( |
|
| 485 | + 'events_categories_help_tab' => array( |
|
| 486 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
| 487 | + 'filename' => 'events_categories', |
|
| 488 | + ), |
|
| 489 | + 'events_categories_table_column_headings_help_tab' => array( |
|
| 490 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
| 491 | + 'filename' => 'events_categories_table_column_headings', |
|
| 492 | + ), |
|
| 493 | + 'events_categories_view_help_tab' => array( |
|
| 494 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
| 495 | + 'filename' => 'events_categories_views', |
|
| 496 | + ), |
|
| 497 | + 'events_categories_other_help_tab' => array( |
|
| 498 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
| 499 | + 'filename' => 'events_categories_other', |
|
| 500 | + ), |
|
| 501 | + ), |
|
| 502 | + 'help_tour' => array( |
|
| 503 | + 'Event_Categories_Help_Tour', |
|
| 504 | + ), |
|
| 505 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 506 | + 'require_nonce' => false, |
|
| 507 | + ), |
|
| 508 | + ); |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * Used to register any global screen options if necessary for every route in this admin page group. |
|
| 514 | + */ |
|
| 515 | + protected function _add_screen_options() |
|
| 516 | + { |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + |
|
| 520 | + /** |
|
| 521 | + * Implementing the screen options for the 'default' route. |
|
| 522 | + */ |
|
| 523 | + protected function _add_screen_options_default() |
|
| 524 | + { |
|
| 525 | + $this->_per_page_screen_option(); |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * Implementing screen options for the category list route. |
|
| 531 | + */ |
|
| 532 | + protected function _add_screen_options_category_list() |
|
| 533 | + { |
|
| 534 | + $page_title = $this->_admin_page_title; |
|
| 535 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
| 536 | + $this->_per_page_screen_option(); |
|
| 537 | + $this->_admin_page_title = $page_title; |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + |
|
| 541 | + /** |
|
| 542 | + * Used to register any global feature pointers for the admin page group. |
|
| 543 | + */ |
|
| 544 | + protected function _add_feature_pointers() |
|
| 545 | + { |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + |
|
| 549 | + /** |
|
| 550 | + * Registers and enqueues any global scripts and styles for the entire admin page group. |
|
| 551 | + */ |
|
| 552 | + public function load_scripts_styles() |
|
| 553 | + { |
|
| 554 | + wp_register_style( |
|
| 555 | + 'events-admin-css', |
|
| 556 | + EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
| 557 | + array(), |
|
| 558 | + EVENT_ESPRESSO_VERSION |
|
| 559 | + ); |
|
| 560 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 561 | + wp_enqueue_style('events-admin-css'); |
|
| 562 | + wp_enqueue_style('ee-cat-admin'); |
|
| 563 | + //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
| 564 | + //registers for all views |
|
| 565 | + //scripts |
|
| 566 | + wp_register_script( |
|
| 567 | + 'event_editor_js', |
|
| 568 | + EVENTS_ASSETS_URL . 'event_editor.js', |
|
| 569 | + array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
| 570 | + EVENT_ESPRESSO_VERSION, |
|
| 571 | + true |
|
| 572 | + ); |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + |
|
| 576 | + |
|
| 577 | + /** |
|
| 578 | + * Enqueuing scripts and styles specific to this view |
|
| 579 | + */ |
|
| 580 | + public function load_scripts_styles_create_new() |
|
| 581 | + { |
|
| 582 | + $this->load_scripts_styles_edit(); |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + |
|
| 586 | + |
|
| 587 | + /** |
|
| 588 | + * Enqueuing scripts and styles specific to this view |
|
| 589 | + */ |
|
| 590 | + public function load_scripts_styles_edit() |
|
| 591 | + { |
|
| 592 | + //styles |
|
| 593 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 594 | + wp_register_style( |
|
| 595 | + 'event-editor-css', |
|
| 596 | + EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 597 | + array('ee-admin-css'), |
|
| 598 | + EVENT_ESPRESSO_VERSION |
|
| 599 | + ); |
|
| 600 | + wp_enqueue_style('event-editor-css'); |
|
| 601 | + //scripts |
|
| 602 | + wp_register_script( |
|
| 603 | + 'event-datetime-metabox', |
|
| 604 | + EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
| 605 | + array('event_editor_js', 'ee-datepicker'), |
|
| 606 | + EVENT_ESPRESSO_VERSION |
|
| 607 | + ); |
|
| 608 | + wp_enqueue_script('event-datetime-metabox'); |
|
| 609 | + } |
|
| 610 | + |
|
| 611 | + |
|
| 612 | + /** |
|
| 613 | + * Populating the _views property for the category list table view. |
|
| 614 | + */ |
|
| 615 | + protected function _set_list_table_views_category_list() |
|
| 616 | + { |
|
| 617 | + $this->_views = array( |
|
| 618 | + 'all' => array( |
|
| 619 | + 'slug' => 'all', |
|
| 620 | + 'label' => esc_html__('All', 'event_espresso'), |
|
| 621 | + 'count' => 0, |
|
| 622 | + 'bulk_action' => array( |
|
| 623 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 624 | + ), |
|
| 625 | + ), |
|
| 626 | + ); |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * For adding anything that fires on the admin_init hook for any route within this admin page group. |
|
| 632 | + */ |
|
| 633 | + public function admin_init() |
|
| 634 | + { |
|
| 635 | + EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
| 636 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
| 637 | + 'event_espresso' |
|
| 638 | + ); |
|
| 639 | + } |
|
| 640 | + |
|
| 641 | + |
|
| 642 | + /** |
|
| 643 | + * For adding anything that should be triggered on the admin_notices hook for any route within this admin page group. |
|
| 644 | + */ |
|
| 645 | + public function admin_notices() |
|
| 646 | + { |
|
| 647 | + } |
|
| 648 | + |
|
| 649 | + |
|
| 650 | + /** |
|
| 651 | + * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within |
|
| 652 | + * this admin page group. |
|
| 653 | + */ |
|
| 654 | + public function admin_footer_scripts() |
|
| 655 | + { |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + |
|
| 659 | + |
|
| 660 | + /** |
|
| 661 | + * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
| 662 | + * warning (via EE_Error::add_error()); |
|
| 663 | + * |
|
| 664 | + * @param EE_Event $event Event object |
|
| 665 | + * @param string $req_type |
|
| 666 | + * @return void |
|
| 667 | + * @throws EE_Error |
|
| 668 | + * @access public |
|
| 669 | + */ |
|
| 670 | + public function verify_event_edit($event = null, $req_type = '') |
|
| 671 | + { |
|
| 672 | + // don't need to do this when processing |
|
| 673 | + if(!empty($req_type)) { |
|
| 674 | + return; |
|
| 675 | + } |
|
| 676 | + // no event? |
|
| 677 | + if (empty($event)) { |
|
| 678 | + // set event |
|
| 679 | + $event = $this->_cpt_model_obj; |
|
| 680 | + } |
|
| 681 | + // STILL no event? |
|
| 682 | + if (! $event instanceof EE_Event) { |
|
| 683 | + return; |
|
| 684 | + } |
|
| 685 | + $orig_status = $event->status(); |
|
| 686 | + // first check if event is active. |
|
| 687 | + if ( |
|
| 688 | + $orig_status === EEM_Event::cancelled |
|
| 689 | + || $orig_status === EEM_Event::postponed |
|
| 690 | + || $event->is_expired() |
|
| 691 | + || $event->is_inactive() |
|
| 692 | + ) { |
|
| 693 | + return; |
|
| 694 | + } |
|
| 695 | + //made it here so it IS active... next check that any of the tickets are sold. |
|
| 696 | + if ($event->is_sold_out(true)) { |
|
| 697 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
| 698 | + EE_Error::add_attention( |
|
| 699 | + sprintf( |
|
| 700 | + esc_html__( |
|
| 701 | + 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
| 702 | + 'event_espresso' |
|
| 703 | + ), |
|
| 704 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
| 705 | + ) |
|
| 706 | + ); |
|
| 707 | + } |
|
| 708 | + return; |
|
| 709 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
| 710 | + EE_Error::add_attention( |
|
| 711 | + sprintf( |
|
| 712 | + esc_html__( |
|
| 713 | + 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
| 714 | + 'event_espresso' |
|
| 715 | + ), |
|
| 716 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
| 717 | + ) |
|
| 718 | + ); |
|
| 719 | + } |
|
| 720 | + //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
| 721 | + if ( ! $event->tickets_on_sale()) { |
|
| 722 | + return; |
|
| 723 | + } |
|
| 724 | + //made it here so show warning |
|
| 725 | + $this->_edit_event_warning(); |
|
| 726 | + } |
|
| 727 | + |
|
| 728 | + |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
| 732 | + * When needed, hook this into a EE_Error::add_error() notice. |
|
| 733 | + * |
|
| 734 | + * @access protected |
|
| 735 | + * @return void |
|
| 736 | + */ |
|
| 737 | + protected function _edit_event_warning() |
|
| 738 | + { |
|
| 739 | + // we don't want to add warnings during these requests |
|
| 740 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
| 741 | + return; |
|
| 742 | + } |
|
| 743 | + EE_Error::add_attention( |
|
| 744 | + esc_html__( |
|
| 745 | + 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
| 746 | + 'event_espresso' |
|
| 747 | + ) |
|
| 748 | + ); |
|
| 749 | + } |
|
| 750 | + |
|
| 751 | + |
|
| 752 | + |
|
| 753 | + /** |
|
| 754 | + * When a user is creating a new event, notify them if they haven't set their timezone. |
|
| 755 | + * Otherwise, do the normal logic |
|
| 756 | + * |
|
| 757 | + * @return string |
|
| 758 | + * @throws \EE_Error |
|
| 759 | + */ |
|
| 760 | + protected function _create_new_cpt_item() |
|
| 761 | + { |
|
| 762 | + $has_timezone_string = get_option('timezone_string'); |
|
| 763 | + //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
| 764 | + if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) { |
|
| 765 | + EE_Error::add_attention( |
|
| 766 | + sprintf( |
|
| 767 | + __( |
|
| 768 | + 'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s', |
|
| 769 | + 'event_espresso' |
|
| 770 | + ), |
|
| 771 | + '<br>', |
|
| 772 | + '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">' |
|
| 773 | + . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale()) |
|
| 774 | + . '</select>', |
|
| 775 | + '<button class="button button-secondary timezone-submit">', |
|
| 776 | + '</button><span class="spinner"></span>' |
|
| 777 | + ), |
|
| 778 | + __FILE__, |
|
| 779 | + __FUNCTION__, |
|
| 780 | + __LINE__ |
|
| 781 | + ); |
|
| 782 | + } |
|
| 783 | + return parent::_create_new_cpt_item(); |
|
| 784 | + } |
|
| 785 | + |
|
| 786 | + |
|
| 787 | + /** |
|
| 788 | + * Sets the _views property for the default route in this admin page group. |
|
| 789 | + */ |
|
| 790 | + protected function _set_list_table_views_default() |
|
| 791 | + { |
|
| 792 | + $this->_views = array( |
|
| 793 | + 'all' => array( |
|
| 794 | + 'slug' => 'all', |
|
| 795 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
| 796 | + 'count' => 0, |
|
| 797 | + 'bulk_action' => array( |
|
| 798 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 799 | + ), |
|
| 800 | + ), |
|
| 801 | + 'draft' => array( |
|
| 802 | + 'slug' => 'draft', |
|
| 803 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
| 804 | + 'count' => 0, |
|
| 805 | + 'bulk_action' => array( |
|
| 806 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 807 | + ), |
|
| 808 | + ), |
|
| 809 | + ); |
|
| 810 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
| 811 | + $this->_views['trash'] = array( |
|
| 812 | + 'slug' => 'trash', |
|
| 813 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 814 | + 'count' => 0, |
|
| 815 | + 'bulk_action' => array( |
|
| 816 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
| 817 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 818 | + ), |
|
| 819 | + ); |
|
| 820 | + } |
|
| 821 | + } |
|
| 822 | + |
|
| 823 | + |
|
| 824 | + |
|
| 825 | + /** |
|
| 826 | + * Provides the legend item array for the default list table view. |
|
| 827 | + * @return array |
|
| 828 | + */ |
|
| 829 | + protected function _event_legend_items() |
|
| 830 | + { |
|
| 831 | + $items = array( |
|
| 832 | + 'view_details' => array( |
|
| 833 | + 'class' => 'dashicons dashicons-search', |
|
| 834 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
| 835 | + ), |
|
| 836 | + 'edit_event' => array( |
|
| 837 | + 'class' => 'ee-icon ee-icon-calendar-edit', |
|
| 838 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
| 839 | + ), |
|
| 840 | + 'view_attendees' => array( |
|
| 841 | + 'class' => 'dashicons dashicons-groups', |
|
| 842 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
| 843 | + ), |
|
| 844 | + ); |
|
| 845 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
| 846 | + $statuses = array( |
|
| 847 | + 'sold_out_status' => array( |
|
| 848 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
| 849 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
| 850 | + ), |
|
| 851 | + 'active_status' => array( |
|
| 852 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
| 853 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
| 854 | + ), |
|
| 855 | + 'upcoming_status' => array( |
|
| 856 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
| 857 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
| 858 | + ), |
|
| 859 | + 'postponed_status' => array( |
|
| 860 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
| 861 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
| 862 | + ), |
|
| 863 | + 'cancelled_status' => array( |
|
| 864 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
| 865 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
| 866 | + ), |
|
| 867 | + 'expired_status' => array( |
|
| 868 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
| 869 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
| 870 | + ), |
|
| 871 | + 'inactive_status' => array( |
|
| 872 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
| 873 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
| 874 | + ), |
|
| 875 | + ); |
|
| 876 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
| 877 | + return array_merge($items, $statuses); |
|
| 878 | + } |
|
| 879 | + |
|
| 880 | + |
|
| 881 | + |
|
| 882 | + /** |
|
| 883 | + * @return EEM_Event |
|
| 884 | + */ |
|
| 885 | + private function _event_model() |
|
| 886 | + { |
|
| 887 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
| 888 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
| 889 | + } |
|
| 890 | + return $this->_event_model; |
|
| 891 | + } |
|
| 892 | + |
|
| 893 | + |
|
| 894 | + |
|
| 895 | + /** |
|
| 896 | + * Adds extra buttons to the WP CPT permalink field row. |
|
| 897 | + * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
| 898 | + * |
|
| 899 | + * @param string $return the current html |
|
| 900 | + * @param int $id the post id for the page |
|
| 901 | + * @param string $new_title What the title is |
|
| 902 | + * @param string $new_slug what the slug is |
|
| 903 | + * @return string The new html string for the permalink area |
|
| 904 | + */ |
|
| 905 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
| 906 | + { |
|
| 907 | + //make sure this is only when editing |
|
| 908 | + if ( ! empty($id)) { |
|
| 909 | + $post = get_post($id); |
|
| 910 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
| 911 | + . esc_html__('Shortcode', 'event_espresso') |
|
| 912 | + . '</a> '; |
|
| 913 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
| 914 | + . $post->ID |
|
| 915 | + . ']">'; |
|
| 916 | + } |
|
| 917 | + return $return; |
|
| 918 | + } |
|
| 919 | + |
|
| 920 | + |
|
| 921 | + |
|
| 922 | + /** |
|
| 923 | + * _events_overview_list_table |
|
| 924 | + * This contains the logic for showing the events_overview list |
|
| 925 | + * |
|
| 926 | + * @access protected |
|
| 927 | + * @return void |
|
| 928 | + * @throws \EE_Error |
|
| 929 | + */ |
|
| 930 | + protected function _events_overview_list_table() |
|
| 931 | + { |
|
| 932 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 933 | + $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
| 934 | + ? (array)$this->_template_args['after_list_table'] |
|
| 935 | + : array(); |
|
| 936 | + $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
| 937 | + . EEH_Template::get_button_or_link( |
|
| 938 | + get_post_type_archive_link('espresso_events'), |
|
| 939 | + esc_html__("View Event Archive Page", "event_espresso"), |
|
| 940 | + 'button' |
|
| 941 | + ); |
|
| 942 | + $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
| 943 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 944 | + 'create_new', |
|
| 945 | + 'add', |
|
| 946 | + array(), |
|
| 947 | + 'add-new-h2' |
|
| 948 | + ); |
|
| 949 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + |
|
| 953 | + |
|
| 954 | + /** |
|
| 955 | + * this allows for extra misc actions in the default WP publish box |
|
| 956 | + * |
|
| 957 | + * @return void |
|
| 958 | + */ |
|
| 959 | + public function extra_misc_actions_publish_box() |
|
| 960 | + { |
|
| 961 | + $this->_generate_publish_box_extra_content(); |
|
| 962 | + } |
|
| 963 | + |
|
| 964 | + |
|
| 965 | + |
|
| 966 | + /** |
|
| 967 | + * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been saved. |
|
| 968 | + * Typically you would use this to save any additional data. |
|
| 969 | + * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
| 970 | + * ALSO very important. When a post transitions from scheduled to published, |
|
| 971 | + * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from other meta saves. |
|
| 972 | + * So MAKE sure that you handle this accordingly. |
|
| 973 | + * |
|
| 974 | + * @access protected |
|
| 975 | + * @abstract |
|
| 976 | + * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
| 977 | + * @param object $post The post object of the cpt that was saved. |
|
| 978 | + * @return void |
|
| 979 | + * @throws \EE_Error |
|
| 980 | + */ |
|
| 981 | + protected function _insert_update_cpt_item($post_id, $post) |
|
| 982 | + { |
|
| 983 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
| 984 | + //get out we're not processing an event save. |
|
| 985 | + return; |
|
| 986 | + } |
|
| 987 | + $event_values = array( |
|
| 988 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
| 989 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
| 990 | + 'EVT_additional_limit' => min( |
|
| 991 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
| 992 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
| 993 | + ), |
|
| 994 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
| 995 | + ? $this->_req_data['EVT_default_registration_status'] |
|
| 996 | + : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
| 997 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
| 998 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
| 999 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
| 1000 | + ? $this->_req_data['timezone_string'] : null, |
|
| 1001 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
| 1002 | + ? $this->_req_data['externalURL'] : null, |
|
| 1003 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
| 1004 | + ? $this->_req_data['event_phone'] : null, |
|
| 1005 | + ); |
|
| 1006 | + //update event |
|
| 1007 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
| 1008 | + //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
|
| 1009 | + $get_one_where = array( |
|
| 1010 | + $this->_event_model()->primary_key_name() => $post_id, |
|
| 1011 | + 'OR' => array( |
|
| 1012 | + 'status' => $post->post_status, |
|
| 1013 | + // if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db, |
|
| 1014 | + // but the returned object here has a status of "publish", so use the original post status as well |
|
| 1015 | + 'status*1' => $this->_req_data['original_post_status'], |
|
| 1016 | + ) |
|
| 1017 | + ); |
|
| 1018 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
| 1019 | + //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
| 1020 | + $event_update_callbacks = apply_filters( |
|
| 1021 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 1022 | + array( |
|
| 1023 | + array($this, '_default_venue_update'), |
|
| 1024 | + array($this, '_default_tickets_update') |
|
| 1025 | + ) |
|
| 1026 | + ); |
|
| 1027 | + $att_success = true; |
|
| 1028 | + foreach ($event_update_callbacks as $e_callback) { |
|
| 1029 | + $_success = $e_callback($event, $this->_req_data); |
|
| 1030 | + //if ANY of these updates fail then we want the appropriate global error message |
|
| 1031 | + $att_success = ! $att_success ? $att_success : $_success; |
|
| 1032 | + } |
|
| 1033 | + //any errors? |
|
| 1034 | + if ($success && false === $att_success) { |
|
| 1035 | + EE_Error::add_error( |
|
| 1036 | + esc_html__( |
|
| 1037 | + 'Event Details saved successfully but something went wrong with saving attachments.', |
|
| 1038 | + 'event_espresso' |
|
| 1039 | + ), |
|
| 1040 | + __FILE__, |
|
| 1041 | + __FUNCTION__, |
|
| 1042 | + __LINE__ |
|
| 1043 | + ); |
|
| 1044 | + } else if ($success === false) { |
|
| 1045 | + EE_Error::add_error( |
|
| 1046 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
| 1047 | + __FILE__, |
|
| 1048 | + __FUNCTION__, |
|
| 1049 | + __LINE__ |
|
| 1050 | + ); |
|
| 1051 | + } |
|
| 1052 | + } |
|
| 1053 | + |
|
| 1054 | + |
|
| 1055 | + |
|
| 1056 | + /** |
|
| 1057 | + * @see parent::restore_item() |
|
| 1058 | + * @param int $post_id |
|
| 1059 | + * @param int $revision_id |
|
| 1060 | + */ |
|
| 1061 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
| 1062 | + { |
|
| 1063 | + //copy existing event meta to new post |
|
| 1064 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
| 1065 | + if ($post_evt instanceof EE_Event) { |
|
| 1066 | + //meta revision restore |
|
| 1067 | + $post_evt->restore_revision($revision_id); |
|
| 1068 | + //related objs restore |
|
| 1069 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
| 1070 | + } |
|
| 1071 | + } |
|
| 1072 | + |
|
| 1073 | + |
|
| 1074 | + |
|
| 1075 | + /** |
|
| 1076 | + * Attach the venue to the Event |
|
| 1077 | + * |
|
| 1078 | + * @param \EE_Event $evtobj Event Object to add the venue to |
|
| 1079 | + * @param array $data The request data from the form |
|
| 1080 | + * @return bool Success or fail. |
|
| 1081 | + */ |
|
| 1082 | + protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
| 1083 | + { |
|
| 1084 | + require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
| 1085 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
| 1086 | + $rows_affected = null; |
|
| 1087 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
| 1088 | + // very important. If we don't have a venue name... |
|
| 1089 | + // then we'll get out because not necessary to create empty venue |
|
| 1090 | + if (empty($data['venue_title'])) { |
|
| 1091 | + return false; |
|
| 1092 | + } |
|
| 1093 | + $venue_array = array( |
|
| 1094 | + 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
| 1095 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
| 1096 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
| 1097 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
| 1098 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
| 1099 | + : null, |
|
| 1100 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
| 1101 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
| 1102 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
| 1103 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
| 1104 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
| 1105 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
| 1106 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
| 1107 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
| 1108 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
| 1109 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
| 1110 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
| 1111 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
| 1112 | + 'status' => 'publish', |
|
| 1113 | + ); |
|
| 1114 | + //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
| 1115 | + if ( ! empty($venue_id)) { |
|
| 1116 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
| 1117 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
| 1118 | + //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
|
| 1119 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
| 1120 | + return $rows_affected > 0 ? true : false; |
|
| 1121 | + } else { |
|
| 1122 | + //we insert the venue |
|
| 1123 | + $venue_id = $venue_model->insert($venue_array); |
|
| 1124 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
| 1125 | + return ! empty($venue_id) ? true : false; |
|
| 1126 | + } |
|
| 1127 | + //when we have the ancestor come in it's already been handled by the revision save. |
|
| 1128 | + } |
|
| 1129 | + |
|
| 1130 | + |
|
| 1131 | + |
|
| 1132 | + /** |
|
| 1133 | + * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
| 1134 | + * |
|
| 1135 | + * @param EE_Event $evtobj The Event object we're attaching data to |
|
| 1136 | + * @param array $data The request data from the form |
|
| 1137 | + * @return array |
|
| 1138 | + */ |
|
| 1139 | + protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
| 1140 | + { |
|
| 1141 | + $success = true; |
|
| 1142 | + $saved_dtt = null; |
|
| 1143 | + $saved_tickets = array(); |
|
| 1144 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
| 1145 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
| 1146 | + //trim all values to ensure any excess whitespace is removed. |
|
| 1147 | + $dtt = array_map('trim', $dtt); |
|
| 1148 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
| 1149 | + : $dtt['DTT_EVT_start']; |
|
| 1150 | + $datetime_values = array( |
|
| 1151 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
| 1152 | + 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
| 1153 | + 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
| 1154 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
| 1155 | + 'DTT_order' => $row, |
|
| 1156 | + ); |
|
| 1157 | + //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
|
| 1158 | + if ( ! empty($dtt['DTT_ID'])) { |
|
| 1159 | + $DTM = EE_Registry::instance() |
|
| 1160 | + ->load_model('Datetime', array($evtobj->get_timezone())) |
|
| 1161 | + ->get_one_by_ID($dtt['DTT_ID']); |
|
| 1162 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
| 1163 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
| 1164 | + foreach ($datetime_values as $field => $value) { |
|
| 1165 | + $DTM->set($field, $value); |
|
| 1166 | + } |
|
| 1167 | + //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
|
| 1168 | + $saved_dtts[$DTM->ID()] = $DTM; |
|
| 1169 | + } else { |
|
| 1170 | + $DTM = EE_Registry::instance()->load_class( |
|
| 1171 | + 'Datetime', |
|
| 1172 | + array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
| 1173 | + false, |
|
| 1174 | + false |
|
| 1175 | + ); |
|
| 1176 | + foreach ($datetime_values as $field => $value) { |
|
| 1177 | + $DTM->set($field, $value); |
|
| 1178 | + } |
|
| 1179 | + } |
|
| 1180 | + $DTM->save(); |
|
| 1181 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
| 1182 | + //load DTT helper |
|
| 1183 | + //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
| 1184 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
| 1185 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
| 1186 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
| 1187 | + $DTT->save(); |
|
| 1188 | + } |
|
| 1189 | + //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
|
| 1190 | + $saved_dtt = $DTT; |
|
| 1191 | + $success = ! $success ? $success : $DTT; |
|
| 1192 | + //if ANY of these updates fail then we want the appropriate global error message. |
|
| 1193 | + // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
| 1194 | + } |
|
| 1195 | + //no dtts get deleted so we don't do any of that logic here. |
|
| 1196 | + //update tickets next |
|
| 1197 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
| 1198 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
| 1199 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
| 1200 | + $update_prices = false; |
|
| 1201 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
| 1202 | + ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
| 1203 | + // trim inputs to ensure any excess whitespace is removed. |
|
| 1204 | + $tkt = array_map('trim', $tkt); |
|
| 1205 | + if (empty($tkt['TKT_start_date'])) { |
|
| 1206 | + //let's use now in the set timezone. |
|
| 1207 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
| 1208 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
| 1209 | + } |
|
| 1210 | + if (empty($tkt['TKT_end_date'])) { |
|
| 1211 | + //use the start date of the first datetime |
|
| 1212 | + $dtt = $evtobj->first_datetime(); |
|
| 1213 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
| 1214 | + $incoming_date_formats[0], |
|
| 1215 | + $incoming_date_formats[1] |
|
| 1216 | + ); |
|
| 1217 | + } |
|
| 1218 | + $TKT_values = array( |
|
| 1219 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
| 1220 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
| 1221 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
| 1222 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
| 1223 | + 'TKT_start_date' => $tkt['TKT_start_date'], |
|
| 1224 | + 'TKT_end_date' => $tkt['TKT_end_date'], |
|
| 1225 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
| 1226 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
| 1227 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
| 1228 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
| 1229 | + 'TKT_row' => $row, |
|
| 1230 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
| 1231 | + 'TKT_price' => $ticket_price, |
|
| 1232 | + ); |
|
| 1233 | + //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
|
| 1234 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
| 1235 | + $TKT_values['TKT_ID'] = 0; |
|
| 1236 | + $TKT_values['TKT_is_default'] = 0; |
|
| 1237 | + $TKT_values['TKT_price'] = $ticket_price; |
|
| 1238 | + $update_prices = true; |
|
| 1239 | + } |
|
| 1240 | + //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
| 1241 | + //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
|
| 1242 | + //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
| 1243 | + if ( ! empty($tkt['TKT_ID'])) { |
|
| 1244 | + $TKT = EE_Registry::instance() |
|
| 1245 | + ->load_model('Ticket', array($evtobj->get_timezone())) |
|
| 1246 | + ->get_one_by_ID($tkt['TKT_ID']); |
|
| 1247 | + if ($TKT instanceof EE_Ticket) { |
|
| 1248 | + $ticket_sold = $TKT->count_related( |
|
| 1249 | + 'Registration', |
|
| 1250 | + array( |
|
| 1251 | + array( |
|
| 1252 | + 'STS_ID' => array( |
|
| 1253 | + 'NOT IN', |
|
| 1254 | + array(EEM_Registration::status_id_incomplete), |
|
| 1255 | + ), |
|
| 1256 | + ), |
|
| 1257 | + ) |
|
| 1258 | + ) > 0 ? true : false; |
|
| 1259 | + //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
|
| 1260 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
| 1261 | + && ! $TKT->get( |
|
| 1262 | + 'TKT_deleted' |
|
| 1263 | + ) ? true : false; |
|
| 1264 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
| 1265 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
| 1266 | + //set new values |
|
| 1267 | + foreach ($TKT_values as $field => $value) { |
|
| 1268 | + if ($field == 'TKT_qty') { |
|
| 1269 | + $TKT->set_qty($value); |
|
| 1270 | + } else { |
|
| 1271 | + $TKT->set($field, $value); |
|
| 1272 | + } |
|
| 1273 | + } |
|
| 1274 | + //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
| 1275 | + if ($create_new_TKT) { |
|
| 1276 | + //archive the old ticket first |
|
| 1277 | + $TKT->set('TKT_deleted', 1); |
|
| 1278 | + $TKT->save(); |
|
| 1279 | + //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
| 1280 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
| 1281 | + //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
|
| 1282 | + $TKT = clone $TKT; |
|
| 1283 | + $TKT->set('TKT_ID', 0); |
|
| 1284 | + $TKT->set('TKT_deleted', 0); |
|
| 1285 | + $TKT->set('TKT_price', $ticket_price); |
|
| 1286 | + $TKT->set('TKT_sold', 0); |
|
| 1287 | + //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
| 1288 | + $update_prices = true; |
|
| 1289 | + } |
|
| 1290 | + //make sure price is set if it hasn't been already |
|
| 1291 | + $TKT->set('TKT_price', $ticket_price); |
|
| 1292 | + } |
|
| 1293 | + } else { |
|
| 1294 | + //no TKT_id so a new TKT |
|
| 1295 | + $TKT_values['TKT_price'] = $ticket_price; |
|
| 1296 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
| 1297 | + if ($TKT instanceof EE_Ticket) { |
|
| 1298 | + //need to reset values to properly account for the date formats |
|
| 1299 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
| 1300 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
| 1301 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
| 1302 | + //set new values |
|
| 1303 | + foreach ($TKT_values as $field => $value) { |
|
| 1304 | + if ($field == 'TKT_qty') { |
|
| 1305 | + $TKT->set_qty($value); |
|
| 1306 | + } else { |
|
| 1307 | + $TKT->set($field, $value); |
|
| 1308 | + } |
|
| 1309 | + } |
|
| 1310 | + $update_prices = true; |
|
| 1311 | + } |
|
| 1312 | + } |
|
| 1313 | + // cap ticket qty by datetime reg limits |
|
| 1314 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
| 1315 | + //update ticket. |
|
| 1316 | + $TKT->save(); |
|
| 1317 | + //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
| 1318 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
| 1319 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
| 1320 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
| 1321 | + $TKT->save(); |
|
| 1322 | + } |
|
| 1323 | + //initially let's add the ticket to the dtt |
|
| 1324 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
| 1325 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
| 1326 | + //add prices to ticket |
|
| 1327 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
| 1328 | + } |
|
| 1329 | + //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
| 1330 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
| 1331 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
| 1332 | + foreach ($tickets_removed as $id) { |
|
| 1333 | + $id = absint($id); |
|
| 1334 | + //get the ticket for this id |
|
| 1335 | + $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
| 1336 | + //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
| 1337 | + $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
| 1338 | + foreach ($dtts as $dtt) { |
|
| 1339 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
| 1340 | + } |
|
| 1341 | + //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
| 1342 | + $tkt_to_remove->delete_related_permanently('Price'); |
|
| 1343 | + //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
| 1344 | + $tkt_to_remove->delete_permanently(); |
|
| 1345 | + } |
|
| 1346 | + return array($saved_dtt, $saved_tickets); |
|
| 1347 | + } |
|
| 1348 | + |
|
| 1349 | + |
|
| 1350 | + |
|
| 1351 | + /** |
|
| 1352 | + * This attaches a list of given prices to a ticket. |
|
| 1353 | + * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
| 1354 | + * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
| 1355 | + * price info and prices are automatically "archived" via the ticket. |
|
| 1356 | + * |
|
| 1357 | + * @access private |
|
| 1358 | + * @param array $prices Array of prices from the form. |
|
| 1359 | + * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
| 1360 | + * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
| 1361 | + * @return void |
|
| 1362 | + */ |
|
| 1363 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
| 1364 | + { |
|
| 1365 | + foreach ($prices as $row => $prc) { |
|
| 1366 | + $PRC_values = array( |
|
| 1367 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
| 1368 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
| 1369 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
| 1370 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
| 1371 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
| 1372 | + 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
| 1373 | + 'PRC_order' => $row, |
|
| 1374 | + ); |
|
| 1375 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
| 1376 | + $PRC_values['PRC_ID'] = 0; |
|
| 1377 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
| 1378 | + } else { |
|
| 1379 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
| 1380 | + //update this price with new values |
|
| 1381 | + foreach ($PRC_values as $field => $newprc) { |
|
| 1382 | + $PRC->set($field, $newprc); |
|
| 1383 | + } |
|
| 1384 | + $PRC->save(); |
|
| 1385 | + } |
|
| 1386 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
| 1387 | + } |
|
| 1388 | + } |
|
| 1389 | + |
|
| 1390 | + |
|
| 1391 | + |
|
| 1392 | + /** |
|
| 1393 | + * Add in our autosave ajax handlers |
|
| 1394 | + * |
|
| 1395 | + */ |
|
| 1396 | + protected function _ee_autosave_create_new() |
|
| 1397 | + { |
|
| 1398 | + } |
|
| 1399 | + |
|
| 1400 | + |
|
| 1401 | + /** |
|
| 1402 | + * More autosave handlers. |
|
| 1403 | + */ |
|
| 1404 | + protected function _ee_autosave_edit() |
|
| 1405 | + { |
|
| 1406 | + return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
| 1407 | + } |
|
| 1408 | + |
|
| 1409 | + |
|
| 1410 | + |
|
| 1411 | + /** |
|
| 1412 | + * _generate_publish_box_extra_content |
|
| 1413 | + */ |
|
| 1414 | + private function _generate_publish_box_extra_content() |
|
| 1415 | + { |
|
| 1416 | + //load formatter helper |
|
| 1417 | + //args for getting related registrations |
|
| 1418 | + $approved_query_args = array( |
|
| 1419 | + array( |
|
| 1420 | + 'REG_deleted' => 0, |
|
| 1421 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 1422 | + ), |
|
| 1423 | + ); |
|
| 1424 | + $not_approved_query_args = array( |
|
| 1425 | + array( |
|
| 1426 | + 'REG_deleted' => 0, |
|
| 1427 | + 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
| 1428 | + ), |
|
| 1429 | + ); |
|
| 1430 | + $pending_payment_query_args = array( |
|
| 1431 | + array( |
|
| 1432 | + 'REG_deleted' => 0, |
|
| 1433 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
| 1434 | + ), |
|
| 1435 | + ); |
|
| 1436 | + // publish box |
|
| 1437 | + $publish_box_extra_args = array( |
|
| 1438 | + 'view_approved_reg_url' => add_query_arg( |
|
| 1439 | + array( |
|
| 1440 | + 'action' => 'default', |
|
| 1441 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1442 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
| 1443 | + ), |
|
| 1444 | + REG_ADMIN_URL |
|
| 1445 | + ), |
|
| 1446 | + 'view_not_approved_reg_url' => add_query_arg( |
|
| 1447 | + array( |
|
| 1448 | + 'action' => 'default', |
|
| 1449 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1450 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
| 1451 | + ), |
|
| 1452 | + REG_ADMIN_URL |
|
| 1453 | + ), |
|
| 1454 | + 'view_pending_payment_reg_url' => add_query_arg( |
|
| 1455 | + array( |
|
| 1456 | + 'action' => 'default', |
|
| 1457 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1458 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
| 1459 | + ), |
|
| 1460 | + REG_ADMIN_URL |
|
| 1461 | + ), |
|
| 1462 | + 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1463 | + 'Registration', |
|
| 1464 | + $approved_query_args |
|
| 1465 | + ), |
|
| 1466 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1467 | + 'Registration', |
|
| 1468 | + $not_approved_query_args |
|
| 1469 | + ), |
|
| 1470 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
| 1471 | + 'Registration', |
|
| 1472 | + $pending_payment_query_args |
|
| 1473 | + ), |
|
| 1474 | + 'misc_pub_section_class' => apply_filters( |
|
| 1475 | + 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
| 1476 | + 'misc-pub-section' |
|
| 1477 | + ), |
|
| 1478 | + ); |
|
| 1479 | + ob_start(); |
|
| 1480 | + do_action( |
|
| 1481 | + 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
| 1482 | + $this->_cpt_model_obj |
|
| 1483 | + ); |
|
| 1484 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
| 1485 | + // load template |
|
| 1486 | + EEH_Template::display_template( |
|
| 1487 | + EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
| 1488 | + $publish_box_extra_args |
|
| 1489 | + ); |
|
| 1490 | + } |
|
| 1491 | + |
|
| 1492 | + |
|
| 1493 | + |
|
| 1494 | + /** |
|
| 1495 | + * @return EE_Event |
|
| 1496 | + */ |
|
| 1497 | + public function get_event_object() |
|
| 1498 | + { |
|
| 1499 | + return $this->_cpt_model_obj; |
|
| 1500 | + } |
|
| 1501 | + |
|
| 1502 | + |
|
| 1503 | + |
|
| 1504 | + |
|
| 1505 | + /** METABOXES * */ |
|
| 1506 | + /** |
|
| 1507 | + * _register_event_editor_meta_boxes |
|
| 1508 | + * add all metaboxes related to the event_editor |
|
| 1509 | + * |
|
| 1510 | + * @return void |
|
| 1511 | + */ |
|
| 1512 | + protected function _register_event_editor_meta_boxes() |
|
| 1513 | + { |
|
| 1514 | + $this->verify_cpt_object(); |
|
| 1515 | + add_meta_box( |
|
| 1516 | + 'espresso_event_editor_tickets', |
|
| 1517 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
| 1518 | + array($this, 'ticket_metabox'), |
|
| 1519 | + $this->page_slug, |
|
| 1520 | + 'normal', |
|
| 1521 | + 'high' |
|
| 1522 | + ); |
|
| 1523 | + add_meta_box( |
|
| 1524 | + 'espresso_event_editor_event_options', |
|
| 1525 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
| 1526 | + array($this, 'registration_options_meta_box'), |
|
| 1527 | + $this->page_slug, |
|
| 1528 | + 'side', |
|
| 1529 | + 'default' |
|
| 1530 | + ); |
|
| 1531 | + // NOTE: if you're looking for other metaboxes in here, |
|
| 1532 | + // where a metabox has a related management page in the admin |
|
| 1533 | + // you will find it setup in the related management page's "_Hooks" file. |
|
| 1534 | + // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
| 1535 | + } |
|
| 1536 | + |
|
| 1537 | + |
|
| 1538 | + /** |
|
| 1539 | + * @throws DomainException |
|
| 1540 | + * @throws EE_Error |
|
| 1541 | + */ |
|
| 1542 | + public function ticket_metabox() |
|
| 1543 | + { |
|
| 1544 | + $existing_datetime_ids = $existing_ticket_ids = array(); |
|
| 1545 | + //defaults for template args |
|
| 1546 | + $template_args = array( |
|
| 1547 | + 'existing_datetime_ids' => '', |
|
| 1548 | + 'event_datetime_help_link' => '', |
|
| 1549 | + 'ticket_options_help_link' => '', |
|
| 1550 | + 'time' => null, |
|
| 1551 | + 'ticket_rows' => '', |
|
| 1552 | + 'existing_ticket_ids' => '', |
|
| 1553 | + 'total_ticket_rows' => 1, |
|
| 1554 | + 'ticket_js_structure' => '', |
|
| 1555 | + 'trash_icon' => 'ee-lock-icon', |
|
| 1556 | + 'disabled' => '', |
|
| 1557 | + ); |
|
| 1558 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
| 1559 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1560 | + /** |
|
| 1561 | + * 1. Start with retrieving Datetimes |
|
| 1562 | + * 2. Fore each datetime get related tickets |
|
| 1563 | + * 3. For each ticket get related prices |
|
| 1564 | + */ |
|
| 1565 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
| 1566 | + /** @type EE_Datetime $first_datetime */ |
|
| 1567 | + $first_datetime = reset($times); |
|
| 1568 | + //do we get related tickets? |
|
| 1569 | + if ($first_datetime instanceof EE_Datetime |
|
| 1570 | + && $first_datetime->ID() !== 0 |
|
| 1571 | + ) { |
|
| 1572 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
| 1573 | + $template_args['time'] = $first_datetime; |
|
| 1574 | + $related_tickets = $first_datetime->tickets( |
|
| 1575 | + array( |
|
| 1576 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
| 1577 | + 'default_where_conditions' => 'none', |
|
| 1578 | + ) |
|
| 1579 | + ); |
|
| 1580 | + if ( ! empty($related_tickets)) { |
|
| 1581 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
| 1582 | + $row = 0; |
|
| 1583 | + foreach ($related_tickets as $ticket) { |
|
| 1584 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
| 1585 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
| 1586 | + $row++; |
|
| 1587 | + } |
|
| 1588 | + } else { |
|
| 1589 | + $template_args['total_ticket_rows'] = 1; |
|
| 1590 | + /** @type EE_Ticket $ticket */ |
|
| 1591 | + $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
| 1592 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
| 1593 | + } |
|
| 1594 | + } else { |
|
| 1595 | + $template_args['time'] = $times[0]; |
|
| 1596 | + /** @type EE_Ticket $ticket */ |
|
| 1597 | + $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
| 1598 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
| 1599 | + // NOTE: we're just sending the first default row |
|
| 1600 | + // (decaf can't manage default tickets so this should be sufficient); |
|
| 1601 | + } |
|
| 1602 | + $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
| 1603 | + 'event_editor_event_datetimes_help_tab' |
|
| 1604 | + ); |
|
| 1605 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
| 1606 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
| 1607 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
| 1608 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
| 1609 | + EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
| 1610 | + true |
|
| 1611 | + ); |
|
| 1612 | + $template = apply_filters( |
|
| 1613 | + 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
| 1614 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
| 1615 | + ); |
|
| 1616 | + EEH_Template::display_template($template, $template_args); |
|
| 1617 | + } |
|
| 1618 | + |
|
| 1619 | + |
|
| 1620 | + |
|
| 1621 | + /** |
|
| 1622 | + * Setup an individual ticket form for the decaf event editor page |
|
| 1623 | + * |
|
| 1624 | + * @access private |
|
| 1625 | + * @param EE_Ticket $ticket the ticket object |
|
| 1626 | + * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
| 1627 | + * @param int $row |
|
| 1628 | + * @return string generated html for the ticket row. |
|
| 1629 | + */ |
|
| 1630 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
| 1631 | + { |
|
| 1632 | + $template_args = array( |
|
| 1633 | + 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
| 1634 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
| 1635 | + : '', |
|
| 1636 | + 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
| 1637 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
| 1638 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
| 1639 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
| 1640 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
| 1641 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
| 1642 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
| 1643 | + 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
| 1644 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
| 1645 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
| 1646 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
| 1647 | + ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
| 1648 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
| 1649 | + : ' disabled=disabled', |
|
| 1650 | + ); |
|
| 1651 | + $price = $ticket->ID() !== 0 |
|
| 1652 | + ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
| 1653 | + : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
| 1654 | + $price_args = array( |
|
| 1655 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
| 1656 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
| 1657 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
| 1658 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
| 1659 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
| 1660 | + ); |
|
| 1661 | + //make sure we have default start and end dates if skeleton |
|
| 1662 | + //handle rows that should NOT be empty |
|
| 1663 | + if (empty($template_args['TKT_start_date'])) { |
|
| 1664 | + //if empty then the start date will be now. |
|
| 1665 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
| 1666 | + } |
|
| 1667 | + if (empty($template_args['TKT_end_date'])) { |
|
| 1668 | + //get the earliest datetime (if present); |
|
| 1669 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
| 1670 | + ? $this->_cpt_model_obj->get_first_related( |
|
| 1671 | + 'Datetime', |
|
| 1672 | + array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
| 1673 | + ) |
|
| 1674 | + : null; |
|
| 1675 | + if ( ! empty($earliest_dtt)) { |
|
| 1676 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
| 1677 | + } else { |
|
| 1678 | + $template_args['TKT_end_date'] = date( |
|
| 1679 | + 'Y-m-d h:i a', |
|
| 1680 | + mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
| 1681 | + ); |
|
| 1682 | + } |
|
| 1683 | + } |
|
| 1684 | + $template_args = array_merge($template_args, $price_args); |
|
| 1685 | + $template = apply_filters( |
|
| 1686 | + 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
| 1687 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
| 1688 | + $ticket |
|
| 1689 | + ); |
|
| 1690 | + return EEH_Template::display_template($template, $template_args, true); |
|
| 1691 | + } |
|
| 1692 | + |
|
| 1693 | + |
|
| 1694 | + /** |
|
| 1695 | + * @throws DomainException |
|
| 1696 | + */ |
|
| 1697 | + public function registration_options_meta_box() |
|
| 1698 | + { |
|
| 1699 | + $yes_no_values = array( |
|
| 1700 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
| 1701 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
| 1702 | + ); |
|
| 1703 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
| 1704 | + array( |
|
| 1705 | + EEM_Registration::status_id_cancelled, |
|
| 1706 | + EEM_Registration::status_id_declined, |
|
| 1707 | + EEM_Registration::status_id_incomplete, |
|
| 1708 | + ), |
|
| 1709 | + true |
|
| 1710 | + ); |
|
| 1711 | + //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
| 1712 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
| 1713 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
| 1714 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
| 1715 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 1716 | + 'default_reg_status', |
|
| 1717 | + $default_reg_status_values, |
|
| 1718 | + $this->_cpt_model_obj->default_registration_status() |
|
| 1719 | + ); |
|
| 1720 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 1721 | + 'display_desc', |
|
| 1722 | + $yes_no_values, |
|
| 1723 | + $this->_cpt_model_obj->display_description() |
|
| 1724 | + ); |
|
| 1725 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 1726 | + 'display_ticket_selector', |
|
| 1727 | + $yes_no_values, |
|
| 1728 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
| 1729 | + '', |
|
| 1730 | + '', |
|
| 1731 | + false |
|
| 1732 | + ); |
|
| 1733 | + $template_args['additional_registration_options'] = apply_filters( |
|
| 1734 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
| 1735 | + '', |
|
| 1736 | + $template_args, |
|
| 1737 | + $yes_no_values, |
|
| 1738 | + $default_reg_status_values |
|
| 1739 | + ); |
|
| 1740 | + EEH_Template::display_template( |
|
| 1741 | + EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 1742 | + $template_args |
|
| 1743 | + ); |
|
| 1744 | + } |
|
| 1745 | + |
|
| 1746 | + |
|
| 1747 | + |
|
| 1748 | + /** |
|
| 1749 | + * _get_events() |
|
| 1750 | + * This method simply returns all the events (for the given _view and paging) |
|
| 1751 | + * |
|
| 1752 | + * @access public |
|
| 1753 | + * @param int $per_page count of items per page (20 default); |
|
| 1754 | + * @param int $current_page what is the current page being viewed. |
|
| 1755 | + * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
| 1756 | + * If FALSE then we return an array of event objects |
|
| 1757 | + * that match the given _view and paging parameters. |
|
| 1758 | + * @return array an array of event objects. |
|
| 1759 | + */ |
|
| 1760 | + public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
| 1761 | + { |
|
| 1762 | + $EEME = $this->_event_model(); |
|
| 1763 | + $offset = ($current_page - 1) * $per_page; |
|
| 1764 | + $limit = $count ? null : $offset . ',' . $per_page; |
|
| 1765 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
| 1766 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
| 1767 | + if (isset($this->_req_data['month_range'])) { |
|
| 1768 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
| 1769 | + //simulate the FIRST day of the month, that fixes issues for months like February |
|
| 1770 | + //where PHP doesn't know what to assume for date. |
|
| 1771 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10437 |
|
| 1772 | + $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; |
|
| 1773 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
| 1774 | + } |
|
| 1775 | + $where = array(); |
|
| 1776 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
| 1777 | + //determine what post_status our condition will have for the query. |
|
| 1778 | + switch ($status) { |
|
| 1779 | + case 'month' : |
|
| 1780 | + case 'today' : |
|
| 1781 | + case null : |
|
| 1782 | + case 'all' : |
|
| 1783 | + break; |
|
| 1784 | + case 'draft' : |
|
| 1785 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
| 1786 | + break; |
|
| 1787 | + default : |
|
| 1788 | + $where['status'] = $status; |
|
| 1789 | + } |
|
| 1790 | + //categories? |
|
| 1791 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
| 1792 | + ? $this->_req_data['EVT_CAT'] : null; |
|
| 1793 | + if ( ! empty ($category)) { |
|
| 1794 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 1795 | + $where['Term_Taxonomy.term_id'] = $category; |
|
| 1796 | + } |
|
| 1797 | + //date where conditions |
|
| 1798 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
| 1799 | + if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
| 1800 | + $DateTime = new DateTime( |
|
| 1801 | + $year_r . '-' . $month_r . '-01 00:00:00', |
|
| 1802 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
| 1803 | + ); |
|
| 1804 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
| 1805 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
| 1806 | + ->format('t'))->setTime(23, 59, 59) |
|
| 1807 | + ->format(implode(' ', $start_formats)); |
|
| 1808 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1809 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
| 1810 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1811 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
| 1812 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
| 1813 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1814 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
| 1815 | + $now = date('Y-m-01'); |
|
| 1816 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1817 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
| 1818 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
| 1819 | + ->setTime(23, 59, 59) |
|
| 1820 | + ->format(implode(' ', $start_formats)); |
|
| 1821 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1822 | + } |
|
| 1823 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 1824 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
| 1825 | + } else { |
|
| 1826 | + if ( ! isset($where['status'])) { |
|
| 1827 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 1828 | + $where['OR'] = array( |
|
| 1829 | + 'status*restrict_private' => array('!=', 'private'), |
|
| 1830 | + 'AND' => array( |
|
| 1831 | + 'status*inclusive' => array('=', 'private'), |
|
| 1832 | + 'EVT_wp_user' => get_current_user_id(), |
|
| 1833 | + ), |
|
| 1834 | + ); |
|
| 1835 | + } |
|
| 1836 | + } |
|
| 1837 | + } |
|
| 1838 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
| 1839 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
| 1840 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
| 1841 | + ) { |
|
| 1842 | + $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
| 1843 | + } |
|
| 1844 | + } |
|
| 1845 | + //search query handling |
|
| 1846 | + if (isset($this->_req_data['s'])) { |
|
| 1847 | + $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 1848 | + $where['OR'] = array( |
|
| 1849 | + 'EVT_name' => array('LIKE', $search_string), |
|
| 1850 | + 'EVT_desc' => array('LIKE', $search_string), |
|
| 1851 | + 'EVT_short_desc' => array('LIKE', $search_string), |
|
| 1852 | + ); |
|
| 1853 | + } |
|
| 1854 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
| 1855 | + $query_params = apply_filters( |
|
| 1856 | + 'FHEE__Events_Admin_Page__get_events__query_params', |
|
| 1857 | + array( |
|
| 1858 | + $where, |
|
| 1859 | + 'limit' => $limit, |
|
| 1860 | + 'order_by' => $orderby, |
|
| 1861 | + 'order' => $order, |
|
| 1862 | + 'group_by' => 'EVT_ID', |
|
| 1863 | + ), |
|
| 1864 | + $this->_req_data |
|
| 1865 | + ); |
|
| 1866 | + //let's first check if we have special requests coming in. |
|
| 1867 | + if (isset($this->_req_data['active_status'])) { |
|
| 1868 | + switch ($this->_req_data['active_status']) { |
|
| 1869 | + case 'upcoming' : |
|
| 1870 | + return $EEME->get_upcoming_events($query_params, $count); |
|
| 1871 | + break; |
|
| 1872 | + case 'expired' : |
|
| 1873 | + return $EEME->get_expired_events($query_params, $count); |
|
| 1874 | + break; |
|
| 1875 | + case 'active' : |
|
| 1876 | + return $EEME->get_active_events($query_params, $count); |
|
| 1877 | + break; |
|
| 1878 | + case 'inactive' : |
|
| 1879 | + return $EEME->get_inactive_events($query_params, $count); |
|
| 1880 | + break; |
|
| 1881 | + } |
|
| 1882 | + } |
|
| 1883 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
| 1884 | + return $events; |
|
| 1885 | + } |
|
| 1886 | + |
|
| 1887 | + |
|
| 1888 | + |
|
| 1889 | + /** |
|
| 1890 | + * handling for WordPress CPT actions (trash, restore, delete) |
|
| 1891 | + * |
|
| 1892 | + * @param string $post_id |
|
| 1893 | + */ |
|
| 1894 | + public function trash_cpt_item($post_id) |
|
| 1895 | + { |
|
| 1896 | + $this->_req_data['EVT_ID'] = $post_id; |
|
| 1897 | + $this->_trash_or_restore_event('trash', false); |
|
| 1898 | + } |
|
| 1899 | + |
|
| 1900 | + |
|
| 1901 | + |
|
| 1902 | + /** |
|
| 1903 | + * @param string $post_id |
|
| 1904 | + */ |
|
| 1905 | + public function restore_cpt_item($post_id) |
|
| 1906 | + { |
|
| 1907 | + $this->_req_data['EVT_ID'] = $post_id; |
|
| 1908 | + $this->_trash_or_restore_event('draft', false); |
|
| 1909 | + } |
|
| 1910 | + |
|
| 1911 | + |
|
| 1912 | + |
|
| 1913 | + /** |
|
| 1914 | + * @param string $post_id |
|
| 1915 | + */ |
|
| 1916 | + public function delete_cpt_item($post_id) |
|
| 1917 | + { |
|
| 1918 | + $this->_req_data['EVT_ID'] = $post_id; |
|
| 1919 | + $this->_delete_event(false); |
|
| 1920 | + } |
|
| 1921 | + |
|
| 1922 | + |
|
| 1923 | + |
|
| 1924 | + /** |
|
| 1925 | + * _trash_or_restore_event |
|
| 1926 | + * |
|
| 1927 | + * @access protected |
|
| 1928 | + * @param string $event_status |
|
| 1929 | + * @param bool $redirect_after |
|
| 1930 | + */ |
|
| 1931 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
| 1932 | + { |
|
| 1933 | + //determine the event id and set to array. |
|
| 1934 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
| 1935 | + // loop thru events |
|
| 1936 | + if ($EVT_ID) { |
|
| 1937 | + // clean status |
|
| 1938 | + $event_status = sanitize_key($event_status); |
|
| 1939 | + // grab status |
|
| 1940 | + if ( ! empty($event_status)) { |
|
| 1941 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
| 1942 | + } else { |
|
| 1943 | + $success = false; |
|
| 1944 | + $msg = esc_html__( |
|
| 1945 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 1946 | + 'event_espresso' |
|
| 1947 | + ); |
|
| 1948 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1949 | + } |
|
| 1950 | + } else { |
|
| 1951 | + $success = false; |
|
| 1952 | + $msg = esc_html__( |
|
| 1953 | + 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 1954 | + 'event_espresso' |
|
| 1955 | + ); |
|
| 1956 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1957 | + } |
|
| 1958 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 1959 | + if ($redirect_after) { |
|
| 1960 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
| 1961 | + } |
|
| 1962 | + } |
|
| 1963 | + |
|
| 1964 | + |
|
| 1965 | + |
|
| 1966 | + /** |
|
| 1967 | + * _trash_or_restore_events |
|
| 1968 | + * |
|
| 1969 | + * @access protected |
|
| 1970 | + * @param string $event_status |
|
| 1971 | + * @return void |
|
| 1972 | + */ |
|
| 1973 | + protected function _trash_or_restore_events($event_status = 'trash') |
|
| 1974 | + { |
|
| 1975 | + // clean status |
|
| 1976 | + $event_status = sanitize_key($event_status); |
|
| 1977 | + // grab status |
|
| 1978 | + if ( ! empty($event_status)) { |
|
| 1979 | + $success = true; |
|
| 1980 | + //determine the event id and set to array. |
|
| 1981 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 1982 | + // loop thru events |
|
| 1983 | + foreach ($EVT_IDs as $EVT_ID) { |
|
| 1984 | + if ($EVT_ID = absint($EVT_ID)) { |
|
| 1985 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
| 1986 | + $success = $results !== false ? $success : false; |
|
| 1987 | + } else { |
|
| 1988 | + $msg = sprintf( |
|
| 1989 | + esc_html__( |
|
| 1990 | + 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 1991 | + 'event_espresso' |
|
| 1992 | + ), |
|
| 1993 | + $EVT_ID |
|
| 1994 | + ); |
|
| 1995 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1996 | + $success = false; |
|
| 1997 | + } |
|
| 1998 | + } |
|
| 1999 | + } else { |
|
| 2000 | + $success = false; |
|
| 2001 | + $msg = esc_html__( |
|
| 2002 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 2003 | + 'event_espresso' |
|
| 2004 | + ); |
|
| 2005 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2006 | + } |
|
| 2007 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
| 2008 | + $success = $success ? 2 : false; |
|
| 2009 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 2010 | + $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
| 2011 | + } |
|
| 2012 | + |
|
| 2013 | + |
|
| 2014 | + |
|
| 2015 | + /** |
|
| 2016 | + * _trash_or_restore_events |
|
| 2017 | + * |
|
| 2018 | + * @access private |
|
| 2019 | + * @param int $EVT_ID |
|
| 2020 | + * @param string $event_status |
|
| 2021 | + * @return bool |
|
| 2022 | + */ |
|
| 2023 | + private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
| 2024 | + { |
|
| 2025 | + // grab event id |
|
| 2026 | + if ( ! $EVT_ID) { |
|
| 2027 | + $msg = esc_html__( |
|
| 2028 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2029 | + 'event_espresso' |
|
| 2030 | + ); |
|
| 2031 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2032 | + return false; |
|
| 2033 | + } |
|
| 2034 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2035 | + // clean status |
|
| 2036 | + $event_status = sanitize_key($event_status); |
|
| 2037 | + // grab status |
|
| 2038 | + if (empty($event_status)) { |
|
| 2039 | + $msg = esc_html__( |
|
| 2040 | + 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
| 2041 | + 'event_espresso' |
|
| 2042 | + ); |
|
| 2043 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2044 | + return false; |
|
| 2045 | + } |
|
| 2046 | + // was event trashed or restored ? |
|
| 2047 | + switch ($event_status) { |
|
| 2048 | + case 'draft' : |
|
| 2049 | + $action = 'restored from the trash'; |
|
| 2050 | + $hook = 'AHEE_event_restored_from_trash'; |
|
| 2051 | + break; |
|
| 2052 | + case 'trash' : |
|
| 2053 | + $action = 'moved to the trash'; |
|
| 2054 | + $hook = 'AHEE_event_moved_to_trash'; |
|
| 2055 | + break; |
|
| 2056 | + default : |
|
| 2057 | + $action = 'updated'; |
|
| 2058 | + $hook = false; |
|
| 2059 | + } |
|
| 2060 | + //use class to change status |
|
| 2061 | + $this->_cpt_model_obj->set_status($event_status); |
|
| 2062 | + $success = $this->_cpt_model_obj->save(); |
|
| 2063 | + if ($success === false) { |
|
| 2064 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
| 2065 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2066 | + return false; |
|
| 2067 | + } |
|
| 2068 | + if ($hook) { |
|
| 2069 | + do_action($hook); |
|
| 2070 | + } |
|
| 2071 | + return true; |
|
| 2072 | + } |
|
| 2073 | + |
|
| 2074 | + |
|
| 2075 | + |
|
| 2076 | + /** |
|
| 2077 | + * _delete_event |
|
| 2078 | + * |
|
| 2079 | + * @access protected |
|
| 2080 | + * @param bool $redirect_after |
|
| 2081 | + */ |
|
| 2082 | + protected function _delete_event($redirect_after = true) |
|
| 2083 | + { |
|
| 2084 | + //determine the event id and set to array. |
|
| 2085 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
| 2086 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
| 2087 | + // loop thru events |
|
| 2088 | + if ($EVT_ID) { |
|
| 2089 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
| 2090 | + // get list of events with no prices |
|
| 2091 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
| 2092 | + // remove this event from the list of events with no prices |
|
| 2093 | + if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
| 2094 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
| 2095 | + } |
|
| 2096 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
| 2097 | + } else { |
|
| 2098 | + $success = false; |
|
| 2099 | + $msg = esc_html__( |
|
| 2100 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
| 2101 | + 'event_espresso' |
|
| 2102 | + ); |
|
| 2103 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2104 | + } |
|
| 2105 | + if ($redirect_after) { |
|
| 2106 | + $this->_redirect_after_action( |
|
| 2107 | + $success, |
|
| 2108 | + 'Event', |
|
| 2109 | + 'deleted', |
|
| 2110 | + array('action' => 'default', 'status' => 'trash') |
|
| 2111 | + ); |
|
| 2112 | + } |
|
| 2113 | + } |
|
| 2114 | + |
|
| 2115 | + |
|
| 2116 | + |
|
| 2117 | + /** |
|
| 2118 | + * _delete_events |
|
| 2119 | + * |
|
| 2120 | + * @access protected |
|
| 2121 | + * @return void |
|
| 2122 | + */ |
|
| 2123 | + protected function _delete_events() |
|
| 2124 | + { |
|
| 2125 | + $success = true; |
|
| 2126 | + // get list of events with no prices |
|
| 2127 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
| 2128 | + //determine the event id and set to array. |
|
| 2129 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 2130 | + // loop thru events |
|
| 2131 | + foreach ($EVT_IDs as $EVT_ID) { |
|
| 2132 | + $EVT_ID = absint($EVT_ID); |
|
| 2133 | + if ($EVT_ID) { |
|
| 2134 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
| 2135 | + $success = $results !== false ? $success : false; |
|
| 2136 | + // remove this event from the list of events with no prices |
|
| 2137 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
| 2138 | + } else { |
|
| 2139 | + $success = false; |
|
| 2140 | + $msg = esc_html__( |
|
| 2141 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
| 2142 | + 'event_espresso' |
|
| 2143 | + ); |
|
| 2144 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2145 | + } |
|
| 2146 | + } |
|
| 2147 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
| 2148 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
| 2149 | + $success = $success ? 2 : false; |
|
| 2150 | + $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
| 2151 | + } |
|
| 2152 | + |
|
| 2153 | + |
|
| 2154 | + |
|
| 2155 | + /** |
|
| 2156 | + * _permanently_delete_event |
|
| 2157 | + * |
|
| 2158 | + * @access private |
|
| 2159 | + * @param int $EVT_ID |
|
| 2160 | + * @return bool |
|
| 2161 | + */ |
|
| 2162 | + private function _permanently_delete_event($EVT_ID = 0) |
|
| 2163 | + { |
|
| 2164 | + // grab event id |
|
| 2165 | + if ( ! $EVT_ID) { |
|
| 2166 | + $msg = esc_html__( |
|
| 2167 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2168 | + 'event_espresso' |
|
| 2169 | + ); |
|
| 2170 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2171 | + return false; |
|
| 2172 | + } |
|
| 2173 | + if ( |
|
| 2174 | + ! $this->_cpt_model_obj instanceof EE_Event |
|
| 2175 | + || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
| 2176 | + ) { |
|
| 2177 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2178 | + } |
|
| 2179 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
| 2180 | + return false; |
|
| 2181 | + } |
|
| 2182 | + //need to delete related tickets and prices first. |
|
| 2183 | + $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
| 2184 | + foreach ($datetimes as $datetime) { |
|
| 2185 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
| 2186 | + $tickets = $datetime->get_many_related('Ticket'); |
|
| 2187 | + foreach ($tickets as $ticket) { |
|
| 2188 | + $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
| 2189 | + $ticket->delete_related_permanently('Price'); |
|
| 2190 | + $ticket->delete_permanently(); |
|
| 2191 | + } |
|
| 2192 | + $datetime->delete(); |
|
| 2193 | + } |
|
| 2194 | + //what about related venues or terms? |
|
| 2195 | + $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
| 2196 | + foreach ($venues as $venue) { |
|
| 2197 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
| 2198 | + } |
|
| 2199 | + //any attached question groups? |
|
| 2200 | + $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
| 2201 | + if ( ! empty($question_groups)) { |
|
| 2202 | + foreach ($question_groups as $question_group) { |
|
| 2203 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
| 2204 | + } |
|
| 2205 | + } |
|
| 2206 | + //Message Template Groups |
|
| 2207 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
| 2208 | + /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
| 2209 | + $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
| 2210 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
| 2211 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
| 2212 | + } |
|
| 2213 | + $success = $this->_cpt_model_obj->delete_permanently(); |
|
| 2214 | + // did it all go as planned ? |
|
| 2215 | + if ($success) { |
|
| 2216 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
| 2217 | + EE_Error::add_success($msg); |
|
| 2218 | + } else { |
|
| 2219 | + $msg = sprintf( |
|
| 2220 | + esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
| 2221 | + $EVT_ID |
|
| 2222 | + ); |
|
| 2223 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2224 | + return false; |
|
| 2225 | + } |
|
| 2226 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
| 2227 | + return true; |
|
| 2228 | + } |
|
| 2229 | + |
|
| 2230 | + |
|
| 2231 | + |
|
| 2232 | + /** |
|
| 2233 | + * get total number of events |
|
| 2234 | + * |
|
| 2235 | + * @access public |
|
| 2236 | + * @return int |
|
| 2237 | + */ |
|
| 2238 | + public function total_events() |
|
| 2239 | + { |
|
| 2240 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2241 | + return $count; |
|
| 2242 | + } |
|
| 2243 | + |
|
| 2244 | + |
|
| 2245 | + |
|
| 2246 | + /** |
|
| 2247 | + * get total number of draft events |
|
| 2248 | + * |
|
| 2249 | + * @access public |
|
| 2250 | + * @return int |
|
| 2251 | + */ |
|
| 2252 | + public function total_events_draft() |
|
| 2253 | + { |
|
| 2254 | + $where = array( |
|
| 2255 | + 'status' => array('IN', array('draft', 'auto-draft')), |
|
| 2256 | + ); |
|
| 2257 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2258 | + return $count; |
|
| 2259 | + } |
|
| 2260 | + |
|
| 2261 | + |
|
| 2262 | + |
|
| 2263 | + /** |
|
| 2264 | + * get total number of trashed events |
|
| 2265 | + * |
|
| 2266 | + * @access public |
|
| 2267 | + * @return int |
|
| 2268 | + */ |
|
| 2269 | + public function total_trashed_events() |
|
| 2270 | + { |
|
| 2271 | + $where = array( |
|
| 2272 | + 'status' => 'trash', |
|
| 2273 | + ); |
|
| 2274 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2275 | + return $count; |
|
| 2276 | + } |
|
| 2277 | + |
|
| 2278 | + |
|
| 2279 | + /** |
|
| 2280 | + * _default_event_settings |
|
| 2281 | + * This generates the Default Settings Tab |
|
| 2282 | + * |
|
| 2283 | + * @return void |
|
| 2284 | + * @throws EE_Error |
|
| 2285 | + */ |
|
| 2286 | + protected function _default_event_settings() |
|
| 2287 | + { |
|
| 2288 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
| 2289 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 2290 | + $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html(); |
|
| 2291 | + $this->display_admin_page_with_sidebar(); |
|
| 2292 | + } |
|
| 2293 | + |
|
| 2294 | + |
|
| 2295 | + /** |
|
| 2296 | + * Return the form for event settings. |
|
| 2297 | + * @return EE_Form_Section_Proper |
|
| 2298 | + */ |
|
| 2299 | + protected function _default_event_settings_form() |
|
| 2300 | + { |
|
| 2301 | + $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2302 | + $registration_stati_for_selection = EEM_Registration::reg_status_array( |
|
| 2303 | + //exclude |
|
| 2304 | + array( |
|
| 2305 | + EEM_Registration::status_id_cancelled, |
|
| 2306 | + EEM_Registration::status_id_declined, |
|
| 2307 | + EEM_Registration::status_id_incomplete, |
|
| 2308 | + EEM_Registration::status_id_wait_list, |
|
| 2309 | + ), |
|
| 2310 | + true |
|
| 2311 | + ); |
|
| 2312 | + return new EE_Form_Section_Proper( |
|
| 2313 | + array( |
|
| 2314 | + 'name' => 'update_default_event_settings', |
|
| 2315 | + 'html_id' => 'update_default_event_settings', |
|
| 2316 | + 'html_class' => 'form-table', |
|
| 2317 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 2318 | + 'subsections' => apply_filters( |
|
| 2319 | + 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections', |
|
| 2320 | + array( |
|
| 2321 | + 'default_reg_status' => new EE_Select_Input( |
|
| 2322 | + $registration_stati_for_selection, |
|
| 2323 | + array( |
|
| 2324 | + 'default' => isset($registration_config->default_STS_ID) |
|
| 2325 | + && array_key_exists( |
|
| 2326 | + $registration_config->default_STS_ID, |
|
| 2327 | + $registration_stati_for_selection |
|
| 2328 | + ) |
|
| 2329 | + ? sanitize_text_field($registration_config->default_STS_ID) |
|
| 2330 | + : EEM_Registration::status_id_pending_payment, |
|
| 2331 | + 'html_label_text' => esc_html__('Default Registration Status', 'event_espresso') |
|
| 2332 | + . EEH_Template::get_help_tab_link( |
|
| 2333 | + 'default_settings_status_help_tab' |
|
| 2334 | + ), |
|
| 2335 | + 'html_help_text' => esc_html__( |
|
| 2336 | + 'This setting allows you to preselect what the default registration status setting is when creating an event. Note that changing this setting does NOT retroactively apply it to existing events.', |
|
| 2337 | + 'event_espresso' |
|
| 2338 | + ) |
|
| 2339 | + ) |
|
| 2340 | + ), |
|
| 2341 | + 'default_max_tickets' => new EE_Integer_Input( |
|
| 2342 | + array( |
|
| 2343 | + 'default' => isset($registration_config->default_maximum_number_of_tickets) |
|
| 2344 | + ? $registration_config->default_maximum_number_of_tickets |
|
| 2345 | + : EEM_Event::get_default_additional_limit(), |
|
| 2346 | + 'html_label_text' => esc_html__( |
|
| 2347 | + 'Default Maximum Tickets Allowed Per Order:', |
|
| 2348 | + 'event_espresso' |
|
| 2349 | + ) . EEH_Template::get_help_tab_link( |
|
| 2350 | + 'default_maximum_tickets_help_tab"' |
|
| 2351 | + ), |
|
| 2352 | + 'html_help_text' => esc_html__( |
|
| 2353 | + 'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.', |
|
| 2354 | + 'event_espresso' |
|
| 2355 | + ) |
|
| 2356 | + ) |
|
| 2357 | + ) |
|
| 2358 | + ) |
|
| 2359 | + ) |
|
| 2360 | + ) |
|
| 2361 | + ); |
|
| 2362 | + } |
|
| 2363 | + |
|
| 2364 | + |
|
| 2365 | + /** |
|
| 2366 | + * _update_default_event_settings |
|
| 2367 | + * |
|
| 2368 | + * @access protected |
|
| 2369 | + * @return void |
|
| 2370 | + * @throws EE_Error |
|
| 2371 | + */ |
|
| 2372 | + protected function _update_default_event_settings() |
|
| 2373 | + { |
|
| 2374 | + $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2375 | + $form = $this->_default_event_settings_form(); |
|
| 2376 | + if ($form->was_submitted()) { |
|
| 2377 | + $form->receive_form_submission(); |
|
| 2378 | + if ($form->is_valid()) { |
|
| 2379 | + $valid_data = $form->valid_data(); |
|
| 2380 | + if (isset($valid_data['default_reg_status'])) { |
|
| 2381 | + $registration_config->default_STS_ID = $valid_data['default_reg_status']; |
|
| 2382 | + } |
|
| 2383 | + if (isset($valid_data['default_max_tickets'])) { |
|
| 2384 | + $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets']; |
|
| 2385 | + } |
|
| 2386 | + //update because data was valid! |
|
| 2387 | + EE_Registry::instance()->CFG->update_espresso_config(); |
|
| 2388 | + EE_Error::overwrite_success(); |
|
| 2389 | + EE_Error::add_success( |
|
| 2390 | + __('Default Event Settings were updated', 'event_espresso') |
|
| 2391 | + ); |
|
| 2392 | + } |
|
| 2393 | + } |
|
| 2394 | + $this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true); |
|
| 2395 | + } |
|
| 2396 | + |
|
| 2397 | + |
|
| 2398 | + |
|
| 2399 | + /************* Templates *************/ |
|
| 2400 | + protected function _template_settings() |
|
| 2401 | + { |
|
| 2402 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
| 2403 | + $this->_template_args['preview_img'] = '<img src="' |
|
| 2404 | + . EVENTS_ASSETS_URL |
|
| 2405 | + . DS |
|
| 2406 | + . 'images' |
|
| 2407 | + . DS |
|
| 2408 | + . 'caffeinated_template_features.jpg" alt="' |
|
| 2409 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
| 2410 | + . '" />'; |
|
| 2411 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
| 2412 | + 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
| 2413 | + 'event_espresso' |
|
| 2414 | + ) . '</strong>'; |
|
| 2415 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
| 2416 | + } |
|
| 2417 | + |
|
| 2418 | + |
|
| 2419 | + /** Event Category Stuff **/ |
|
| 2420 | + /** |
|
| 2421 | + * set the _category property with the category object for the loaded page. |
|
| 2422 | + * |
|
| 2423 | + * @access private |
|
| 2424 | + * @return void |
|
| 2425 | + */ |
|
| 2426 | + private function _set_category_object() |
|
| 2427 | + { |
|
| 2428 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
| 2429 | + return; |
|
| 2430 | + } //already have the category object so get out. |
|
| 2431 | + //set default category object |
|
| 2432 | + $this->_set_empty_category_object(); |
|
| 2433 | + //only set if we've got an id |
|
| 2434 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
| 2435 | + return; |
|
| 2436 | + } |
|
| 2437 | + $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
| 2438 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
| 2439 | + if ( ! empty($term)) { |
|
| 2440 | + $this->_category->category_name = $term->name; |
|
| 2441 | + $this->_category->category_identifier = $term->slug; |
|
| 2442 | + $this->_category->category_desc = $term->description; |
|
| 2443 | + $this->_category->id = $term->term_id; |
|
| 2444 | + $this->_category->parent = $term->parent; |
|
| 2445 | + } |
|
| 2446 | + } |
|
| 2447 | + |
|
| 2448 | + |
|
| 2449 | + /** |
|
| 2450 | + * Clears out category properties. |
|
| 2451 | + */ |
|
| 2452 | + private function _set_empty_category_object() |
|
| 2453 | + { |
|
| 2454 | + $this->_category = new stdClass(); |
|
| 2455 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
| 2456 | + $this->_category->id = $this->_category->parent = 0; |
|
| 2457 | + } |
|
| 2458 | + |
|
| 2459 | + |
|
| 2460 | + /** |
|
| 2461 | + * @throws EE_Error |
|
| 2462 | + */ |
|
| 2463 | + protected function _category_list_table() |
|
| 2464 | + { |
|
| 2465 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2466 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
| 2467 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 2468 | + 'add_category', |
|
| 2469 | + 'add_category', |
|
| 2470 | + array(), |
|
| 2471 | + 'add-new-h2' |
|
| 2472 | + ); |
|
| 2473 | + $this->display_admin_list_table_page_with_sidebar(); |
|
| 2474 | + } |
|
| 2475 | + |
|
| 2476 | + |
|
| 2477 | + |
|
| 2478 | + /** |
|
| 2479 | + * Output category details view. |
|
| 2480 | + */ |
|
| 2481 | + protected function _category_details($view) |
|
| 2482 | + { |
|
| 2483 | + //load formatter helper |
|
| 2484 | + //load field generator helper |
|
| 2485 | + $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
| 2486 | + $this->_set_add_edit_form_tags($route); |
|
| 2487 | + $this->_set_category_object(); |
|
| 2488 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
| 2489 | + $delete_action = 'delete_category'; |
|
| 2490 | + //custom redirect |
|
| 2491 | + $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2492 | + array('action' => 'category_list'), |
|
| 2493 | + $this->_admin_base_url |
|
| 2494 | + ); |
|
| 2495 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
| 2496 | + //take care of contents |
|
| 2497 | + $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
| 2498 | + $this->display_admin_page_with_sidebar(); |
|
| 2499 | + } |
|
| 2500 | + |
|
| 2501 | + |
|
| 2502 | + |
|
| 2503 | + /** |
|
| 2504 | + * Output category details content. |
|
| 2505 | + */ |
|
| 2506 | + protected function _category_details_content() |
|
| 2507 | + { |
|
| 2508 | + $editor_args['category_desc'] = array( |
|
| 2509 | + 'type' => 'wp_editor', |
|
| 2510 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
| 2511 | + 'class' => 'my_editor_custom', |
|
| 2512 | + 'wpeditor_args' => array('media_buttons' => false), |
|
| 2513 | + ); |
|
| 2514 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
| 2515 | + $all_terms = get_terms( |
|
| 2516 | + array('espresso_event_categories'), |
|
| 2517 | + array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
| 2518 | + ); |
|
| 2519 | + //setup category select for term parents. |
|
| 2520 | + $category_select_values[] = array( |
|
| 2521 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
| 2522 | + 'id' => 0, |
|
| 2523 | + ); |
|
| 2524 | + foreach ($all_terms as $term) { |
|
| 2525 | + $category_select_values[] = array( |
|
| 2526 | + 'text' => $term->name, |
|
| 2527 | + 'id' => $term->term_id, |
|
| 2528 | + ); |
|
| 2529 | + } |
|
| 2530 | + $category_select = EEH_Form_Fields::select_input( |
|
| 2531 | + 'category_parent', |
|
| 2532 | + $category_select_values, |
|
| 2533 | + $this->_category->parent |
|
| 2534 | + ); |
|
| 2535 | + $template_args = array( |
|
| 2536 | + 'category' => $this->_category, |
|
| 2537 | + 'category_select' => $category_select, |
|
| 2538 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
| 2539 | + 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
| 2540 | + 'disable' => '', |
|
| 2541 | + 'disabled_message' => false, |
|
| 2542 | + ); |
|
| 2543 | + $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
| 2544 | + return EEH_Template::display_template($template, $template_args, true); |
|
| 2545 | + } |
|
| 2546 | + |
|
| 2547 | + |
|
| 2548 | + /** |
|
| 2549 | + * Handles deleting categories. |
|
| 2550 | + */ |
|
| 2551 | + protected function _delete_categories() |
|
| 2552 | + { |
|
| 2553 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
| 2554 | + : (array)$this->_req_data['category_id']; |
|
| 2555 | + foreach ($cat_ids as $cat_id) { |
|
| 2556 | + $this->_delete_category($cat_id); |
|
| 2557 | + } |
|
| 2558 | + //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
| 2559 | + $query_args = array( |
|
| 2560 | + 'action' => 'category_list', |
|
| 2561 | + ); |
|
| 2562 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
| 2563 | + } |
|
| 2564 | + |
|
| 2565 | + |
|
| 2566 | + |
|
| 2567 | + /** |
|
| 2568 | + * Handles deleting specific category. |
|
| 2569 | + * @param int $cat_id |
|
| 2570 | + */ |
|
| 2571 | + protected function _delete_category($cat_id) |
|
| 2572 | + { |
|
| 2573 | + $cat_id = absint($cat_id); |
|
| 2574 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
| 2575 | + } |
|
| 2576 | + |
|
| 2577 | + |
|
| 2578 | + |
|
| 2579 | + /** |
|
| 2580 | + * Handles triggering the update or insertion of a new category. |
|
| 2581 | + * @param bool $new_category true means we're triggering the insert of a new category. |
|
| 2582 | + */ |
|
| 2583 | + protected function _insert_or_update_category($new_category) |
|
| 2584 | + { |
|
| 2585 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
| 2586 | + $success = 0; //we already have a success message so lets not send another. |
|
| 2587 | + if ($cat_id) { |
|
| 2588 | + $query_args = array( |
|
| 2589 | + 'action' => 'edit_category', |
|
| 2590 | + 'EVT_CAT_ID' => $cat_id, |
|
| 2591 | + ); |
|
| 2592 | + } else { |
|
| 2593 | + $query_args = array('action' => 'add_category'); |
|
| 2594 | + } |
|
| 2595 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
| 2596 | + } |
|
| 2597 | + |
|
| 2598 | + |
|
| 2599 | + |
|
| 2600 | + /** |
|
| 2601 | + * Inserts or updates category |
|
| 2602 | + * @param bool $update (true indicates we're updating a category). |
|
| 2603 | + * @return bool|mixed|string |
|
| 2604 | + */ |
|
| 2605 | + private function _insert_category($update = false) |
|
| 2606 | + { |
|
| 2607 | + $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
| 2608 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
| 2609 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
| 2610 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
| 2611 | + if (empty($category_name)) { |
|
| 2612 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
| 2613 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2614 | + return false; |
|
| 2615 | + } |
|
| 2616 | + $term_args = array( |
|
| 2617 | + 'name' => $category_name, |
|
| 2618 | + 'description' => $category_desc, |
|
| 2619 | + 'parent' => $category_parent, |
|
| 2620 | + ); |
|
| 2621 | + //was the category_identifier input disabled? |
|
| 2622 | + if (isset($this->_req_data['category_identifier'])) { |
|
| 2623 | + $term_args['slug'] = $this->_req_data['category_identifier']; |
|
| 2624 | + } |
|
| 2625 | + $insert_ids = $update |
|
| 2626 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
| 2627 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
| 2628 | + if ( ! is_array($insert_ids)) { |
|
| 2629 | + $msg = esc_html__( |
|
| 2630 | + 'An error occurred and the category has not been saved to the database.', |
|
| 2631 | + 'event_espresso' |
|
| 2632 | + ); |
|
| 2633 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2634 | + } else { |
|
| 2635 | + $cat_id = $insert_ids['term_id']; |
|
| 2636 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
| 2637 | + EE_Error::add_success($msg); |
|
| 2638 | + } |
|
| 2639 | + return $cat_id; |
|
| 2640 | + } |
|
| 2641 | + |
|
| 2642 | + |
|
| 2643 | + |
|
| 2644 | + /** |
|
| 2645 | + * Gets categories or count of categories matching the arguments in the request. |
|
| 2646 | + * @param int $per_page |
|
| 2647 | + * @param int $current_page |
|
| 2648 | + * @param bool $count |
|
| 2649 | + * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int |
|
| 2650 | + */ |
|
| 2651 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
| 2652 | + { |
|
| 2653 | + //testing term stuff |
|
| 2654 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
| 2655 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
| 2656 | + $limit = ($current_page - 1) * $per_page; |
|
| 2657 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
| 2658 | + if (isset($this->_req_data['s'])) { |
|
| 2659 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2660 | + $where['OR'] = array( |
|
| 2661 | + 'Term.name' => array('LIKE', $sstr), |
|
| 2662 | + 'description' => array('LIKE', $sstr), |
|
| 2663 | + ); |
|
| 2664 | + } |
|
| 2665 | + $query_params = array( |
|
| 2666 | + $where, |
|
| 2667 | + 'order_by' => array($orderby => $order), |
|
| 2668 | + 'limit' => $limit . ',' . $per_page, |
|
| 2669 | + 'force_join' => array('Term'), |
|
| 2670 | + ); |
|
| 2671 | + $categories = $count |
|
| 2672 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
| 2673 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
| 2674 | + return $categories; |
|
| 2675 | + } |
|
| 2676 | + |
|
| 2677 | + /* end category stuff */ |
|
| 2678 | + /**************/ |
|
| 2679 | + |
|
| 2680 | + |
|
| 2681 | + /** |
|
| 2682 | + * Callback for the `ee_save_timezone_setting` ajax action. |
|
| 2683 | + * @throws EE_Error |
|
| 2684 | + */ |
|
| 2685 | + public function save_timezonestring_setting() |
|
| 2686 | + { |
|
| 2687 | + $timezone_string = isset($this->_req_data['timezone_selected']) |
|
| 2688 | + ? $this->_req_data['timezone_selected'] |
|
| 2689 | + : ''; |
|
| 2690 | + if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) |
|
| 2691 | + { |
|
| 2692 | + EE_Error::add_error( |
|
| 2693 | + esc_html('An invalid timezone string submitted.', 'event_espresso'), |
|
| 2694 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2695 | + ); |
|
| 2696 | + $this->_template_args['error'] = true; |
|
| 2697 | + $this->_return_json(); |
|
| 2698 | + } |
|
| 2699 | + |
|
| 2700 | + update_option('timezone_string', $timezone_string); |
|
| 2701 | + EE_Error::add_success( |
|
| 2702 | + esc_html__('Your timezone string was updated.', 'event_espresso') |
|
| 2703 | + ); |
|
| 2704 | + $this->_template_args['success'] = true; |
|
| 2705 | + $this->_return_json(true, array('action' => 'create_new')); |
|
| 2706 | + } |
|
| 2707 | 2707 | } |
| 2708 | 2708 | //end class Events_Admin_Page |
@@ -553,11 +553,11 @@ discard block |
||
| 553 | 553 | { |
| 554 | 554 | wp_register_style( |
| 555 | 555 | 'events-admin-css', |
| 556 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
| 556 | + EVENTS_ASSETS_URL.'events-admin-page.css', |
|
| 557 | 557 | array(), |
| 558 | 558 | EVENT_ESPRESSO_VERSION |
| 559 | 559 | ); |
| 560 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 560 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 561 | 561 | wp_enqueue_style('events-admin-css'); |
| 562 | 562 | wp_enqueue_style('ee-cat-admin'); |
| 563 | 563 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | //scripts |
| 566 | 566 | wp_register_script( |
| 567 | 567 | 'event_editor_js', |
| 568 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
| 568 | + EVENTS_ASSETS_URL.'event_editor.js', |
|
| 569 | 569 | array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
| 570 | 570 | EVENT_ESPRESSO_VERSION, |
| 571 | 571 | true |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | wp_enqueue_style('espresso-ui-theme'); |
| 594 | 594 | wp_register_style( |
| 595 | 595 | 'event-editor-css', |
| 596 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 596 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
| 597 | 597 | array('ee-admin-css'), |
| 598 | 598 | EVENT_ESPRESSO_VERSION |
| 599 | 599 | ); |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | //scripts |
| 602 | 602 | wp_register_script( |
| 603 | 603 | 'event-datetime-metabox', |
| 604 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
| 604 | + EVENTS_ASSETS_URL.'event-datetime-metabox.js', |
|
| 605 | 605 | array('event_editor_js', 'ee-datepicker'), |
| 606 | 606 | EVENT_ESPRESSO_VERSION |
| 607 | 607 | ); |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | public function verify_event_edit($event = null, $req_type = '') |
| 671 | 671 | { |
| 672 | 672 | // don't need to do this when processing |
| 673 | - if(!empty($req_type)) { |
|
| 673 | + if ( ! empty($req_type)) { |
|
| 674 | 674 | return; |
| 675 | 675 | } |
| 676 | 676 | // no event? |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | $event = $this->_cpt_model_obj; |
| 680 | 680 | } |
| 681 | 681 | // STILL no event? |
| 682 | - if (! $event instanceof EE_Event) { |
|
| 682 | + if ( ! $event instanceof EE_Event) { |
|
| 683 | 683 | return; |
| 684 | 684 | } |
| 685 | 685 | $orig_status = $event->status(); |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | { |
| 762 | 762 | $has_timezone_string = get_option('timezone_string'); |
| 763 | 763 | //only nag them about setting their timezone if it's their first event, and they haven't already done it |
| 764 | - if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) { |
|
| 764 | + if ( ! $has_timezone_string && ! EEM_Event::instance()->exists(array())) { |
|
| 765 | 765 | EE_Error::add_attention( |
| 766 | 766 | sprintf( |
| 767 | 767 | __( |
@@ -845,31 +845,31 @@ discard block |
||
| 845 | 845 | $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
| 846 | 846 | $statuses = array( |
| 847 | 847 | 'sold_out_status' => array( |
| 848 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
| 848 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
| 849 | 849 | 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
| 850 | 850 | ), |
| 851 | 851 | 'active_status' => array( |
| 852 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
| 852 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
| 853 | 853 | 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
| 854 | 854 | ), |
| 855 | 855 | 'upcoming_status' => array( |
| 856 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
| 856 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
| 857 | 857 | 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
| 858 | 858 | ), |
| 859 | 859 | 'postponed_status' => array( |
| 860 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
| 860 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
| 861 | 861 | 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
| 862 | 862 | ), |
| 863 | 863 | 'cancelled_status' => array( |
| 864 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
| 864 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
| 865 | 865 | 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
| 866 | 866 | ), |
| 867 | 867 | 'expired_status' => array( |
| 868 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
| 868 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
| 869 | 869 | 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
| 870 | 870 | ), |
| 871 | 871 | 'inactive_status' => array( |
| 872 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
| 872 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
| 873 | 873 | 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
| 874 | 874 | ), |
| 875 | 875 | ); |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | { |
| 932 | 932 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
| 933 | 933 | $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
| 934 | - ? (array)$this->_template_args['after_list_table'] |
|
| 934 | + ? (array) $this->_template_args['after_list_table'] |
|
| 935 | 935 | : array(); |
| 936 | 936 | $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
| 937 | 937 | . EEH_Template::get_button_or_link( |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | 'button' |
| 941 | 941 | ); |
| 942 | 942 | $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
| 943 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 943 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 944 | 944 | 'create_new', |
| 945 | 945 | 'add', |
| 946 | 946 | array(), |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | */ |
| 1082 | 1082 | protected function _default_venue_update(\EE_Event $evtobj, $data) |
| 1083 | 1083 | { |
| 1084 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
| 1084 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
| 1085 | 1085 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
| 1086 | 1086 | $rows_affected = null; |
| 1087 | 1087 | $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
@@ -1205,7 +1205,7 @@ discard block |
||
| 1205 | 1205 | if (empty($tkt['TKT_start_date'])) { |
| 1206 | 1206 | //let's use now in the set timezone. |
| 1207 | 1207 | $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
| 1208 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
| 1208 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
| 1209 | 1209 | } |
| 1210 | 1210 | if (empty($tkt['TKT_end_date'])) { |
| 1211 | 1211 | //use the start date of the first datetime |
@@ -1484,7 +1484,7 @@ discard block |
||
| 1484 | 1484 | $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
| 1485 | 1485 | // load template |
| 1486 | 1486 | EEH_Template::display_template( |
| 1487 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
| 1487 | + EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', |
|
| 1488 | 1488 | $publish_box_extra_args |
| 1489 | 1489 | ); |
| 1490 | 1490 | } |
@@ -1611,7 +1611,7 @@ discard block |
||
| 1611 | 1611 | ); |
| 1612 | 1612 | $template = apply_filters( |
| 1613 | 1613 | 'FHEE__Events_Admin_Page__ticket_metabox__template', |
| 1614 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
| 1614 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php' |
|
| 1615 | 1615 | ); |
| 1616 | 1616 | EEH_Template::display_template($template, $template_args); |
| 1617 | 1617 | } |
@@ -1630,7 +1630,7 @@ discard block |
||
| 1630 | 1630 | private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
| 1631 | 1631 | { |
| 1632 | 1632 | $template_args = array( |
| 1633 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
| 1633 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
| 1634 | 1634 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
| 1635 | 1635 | : '', |
| 1636 | 1636 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
@@ -1684,7 +1684,7 @@ discard block |
||
| 1684 | 1684 | $template_args = array_merge($template_args, $price_args); |
| 1685 | 1685 | $template = apply_filters( |
| 1686 | 1686 | 'FHEE__Events_Admin_Page__get_ticket_row__template', |
| 1687 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
| 1687 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', |
|
| 1688 | 1688 | $ticket |
| 1689 | 1689 | ); |
| 1690 | 1690 | return EEH_Template::display_template($template, $template_args, true); |
@@ -1738,7 +1738,7 @@ discard block |
||
| 1738 | 1738 | $default_reg_status_values |
| 1739 | 1739 | ); |
| 1740 | 1740 | EEH_Template::display_template( |
| 1741 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 1741 | + EVENTS_TEMPLATE_PATH.'event_registration_options.template.php', |
|
| 1742 | 1742 | $template_args |
| 1743 | 1743 | ); |
| 1744 | 1744 | } |
@@ -1761,7 +1761,7 @@ discard block |
||
| 1761 | 1761 | { |
| 1762 | 1762 | $EEME = $this->_event_model(); |
| 1763 | 1763 | $offset = ($current_page - 1) * $per_page; |
| 1764 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
| 1764 | + $limit = $count ? null : $offset.','.$per_page; |
|
| 1765 | 1765 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
| 1766 | 1766 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
| 1767 | 1767 | if (isset($this->_req_data['month_range'])) { |
@@ -1798,7 +1798,7 @@ discard block |
||
| 1798 | 1798 | $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
| 1799 | 1799 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
| 1800 | 1800 | $DateTime = new DateTime( |
| 1801 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
| 1801 | + $year_r.'-'.$month_r.'-01 00:00:00', |
|
| 1802 | 1802 | new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
| 1803 | 1803 | ); |
| 1804 | 1804 | $start = $DateTime->format(implode(' ', $start_formats)); |
@@ -1844,7 +1844,7 @@ discard block |
||
| 1844 | 1844 | } |
| 1845 | 1845 | //search query handling |
| 1846 | 1846 | if (isset($this->_req_data['s'])) { |
| 1847 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 1847 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
| 1848 | 1848 | $where['OR'] = array( |
| 1849 | 1849 | 'EVT_name' => array('LIKE', $search_string), |
| 1850 | 1850 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1978,7 +1978,7 @@ discard block |
||
| 1978 | 1978 | if ( ! empty($event_status)) { |
| 1979 | 1979 | $success = true; |
| 1980 | 1980 | //determine the event id and set to array. |
| 1981 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 1981 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
| 1982 | 1982 | // loop thru events |
| 1983 | 1983 | foreach ($EVT_IDs as $EVT_ID) { |
| 1984 | 1984 | if ($EVT_ID = absint($EVT_ID)) { |
@@ -2126,7 +2126,7 @@ discard block |
||
| 2126 | 2126 | // get list of events with no prices |
| 2127 | 2127 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
| 2128 | 2128 | //determine the event id and set to array. |
| 2129 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 2129 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
| 2130 | 2130 | // loop thru events |
| 2131 | 2131 | foreach ($EVT_IDs as $EVT_ID) { |
| 2132 | 2132 | $EVT_ID = absint($EVT_ID); |
@@ -2346,7 +2346,7 @@ discard block |
||
| 2346 | 2346 | 'html_label_text' => esc_html__( |
| 2347 | 2347 | 'Default Maximum Tickets Allowed Per Order:', |
| 2348 | 2348 | 'event_espresso' |
| 2349 | - ) . EEH_Template::get_help_tab_link( |
|
| 2349 | + ).EEH_Template::get_help_tab_link( |
|
| 2350 | 2350 | 'default_maximum_tickets_help_tab"' |
| 2351 | 2351 | ), |
| 2352 | 2352 | 'html_help_text' => esc_html__( |
@@ -2408,10 +2408,10 @@ discard block |
||
| 2408 | 2408 | . 'caffeinated_template_features.jpg" alt="' |
| 2409 | 2409 | . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
| 2410 | 2410 | . '" />'; |
| 2411 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
| 2411 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__( |
|
| 2412 | 2412 | 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
| 2413 | 2413 | 'event_espresso' |
| 2414 | - ) . '</strong>'; |
|
| 2414 | + ).'</strong>'; |
|
| 2415 | 2415 | $this->display_admin_caf_preview_page('template_settings_tab'); |
| 2416 | 2416 | } |
| 2417 | 2417 | |
@@ -2464,7 +2464,7 @@ discard block |
||
| 2464 | 2464 | { |
| 2465 | 2465 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
| 2466 | 2466 | $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
| 2467 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 2467 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 2468 | 2468 | 'add_category', |
| 2469 | 2469 | 'add_category', |
| 2470 | 2470 | array(), |
@@ -2540,7 +2540,7 @@ discard block |
||
| 2540 | 2540 | 'disable' => '', |
| 2541 | 2541 | 'disabled_message' => false, |
| 2542 | 2542 | ); |
| 2543 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
| 2543 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
| 2544 | 2544 | return EEH_Template::display_template($template, $template_args, true); |
| 2545 | 2545 | } |
| 2546 | 2546 | |
@@ -2550,8 +2550,8 @@ discard block |
||
| 2550 | 2550 | */ |
| 2551 | 2551 | protected function _delete_categories() |
| 2552 | 2552 | { |
| 2553 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
| 2554 | - : (array)$this->_req_data['category_id']; |
|
| 2553 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
| 2554 | + : (array) $this->_req_data['category_id']; |
|
| 2555 | 2555 | foreach ($cat_ids as $cat_id) { |
| 2556 | 2556 | $this->_delete_category($cat_id); |
| 2557 | 2557 | } |
@@ -2656,7 +2656,7 @@ discard block |
||
| 2656 | 2656 | $limit = ($current_page - 1) * $per_page; |
| 2657 | 2657 | $where = array('taxonomy' => 'espresso_event_categories'); |
| 2658 | 2658 | if (isset($this->_req_data['s'])) { |
| 2659 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2659 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 2660 | 2660 | $where['OR'] = array( |
| 2661 | 2661 | 'Term.name' => array('LIKE', $sstr), |
| 2662 | 2662 | 'description' => array('LIKE', $sstr), |
@@ -2665,7 +2665,7 @@ discard block |
||
| 2665 | 2665 | $query_params = array( |
| 2666 | 2666 | $where, |
| 2667 | 2667 | 'order_by' => array($orderby => $order), |
| 2668 | - 'limit' => $limit . ',' . $per_page, |
|
| 2668 | + 'limit' => $limit.','.$per_page, |
|
| 2669 | 2669 | 'force_join' => array('Term'), |
| 2670 | 2670 | ); |
| 2671 | 2671 | $categories = $count |
@@ -2687,7 +2687,7 @@ discard block |
||
| 2687 | 2687 | $timezone_string = isset($this->_req_data['timezone_selected']) |
| 2688 | 2688 | ? $this->_req_data['timezone_selected'] |
| 2689 | 2689 | : ''; |
| 2690 | - if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) |
|
| 2690 | + if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) |
|
| 2691 | 2691 | { |
| 2692 | 2692 | EE_Error::add_error( |
| 2693 | 2693 | esc_html('An invalid timezone string submitted.', 'event_espresso'), |