@@ -347,7 +347,7 @@ discard block  | 
                                                    ||
| 347 | 347 | /**  | 
                                                        
| 348 | 348 | * remove param  | 
                                                        
| 349 | 349 | *  | 
                                                        
| 350 | - * @param $key  | 
                                                        |
| 350 | + * @param string $key  | 
                                                        |
| 351 | 351 | * @return void  | 
                                                        
| 352 | 352 | */  | 
                                                        
| 353 | 353 | public function un_set($key)  | 
                                                        
@@ -383,7 +383,7 @@ discard block  | 
                                                    ||
| 383 | 383 | |
| 384 | 384 | |
| 385 | 385 | /**  | 
                                                        
| 386 | - * @param $string  | 
                                                        |
| 386 | + * @param string $string  | 
                                                        |
| 387 | 387 | * @return void  | 
                                                        
| 388 | 388 | */  | 
                                                        
| 389 | 389 | public function add_output($string)  | 
                                                        
@@ -13,478 +13,478 @@  | 
                                                    ||
| 13 | 13 | final class EE_Request_Handler implements InterminableInterface  | 
                                                        
| 14 | 14 |  { | 
                                                        
| 15 | 15 | |
| 16 | - /**  | 
                                                        |
| 17 | - * $_REQUEST parameters  | 
                                                        |
| 18 | - *  | 
                                                        |
| 19 | - * @var array $_params  | 
                                                        |
| 20 | - */  | 
                                                        |
| 21 | - private $_params;  | 
                                                        |
| 22 | -  | 
                                                        |
| 23 | - /**  | 
                                                        |
| 24 | - * @var array $_notice  | 
                                                        |
| 25 | - */  | 
                                                        |
| 26 | - private $_notice = array();  | 
                                                        |
| 27 | -  | 
                                                        |
| 28 | - /**  | 
                                                        |
| 29 | - * rendered output to be returned to WP  | 
                                                        |
| 30 | - *  | 
                                                        |
| 31 | - * @var string $_output  | 
                                                        |
| 32 | - */  | 
                                                        |
| 33 | - private $_output = '';  | 
                                                        |
| 34 | -  | 
                                                        |
| 35 | - /**  | 
                                                        |
| 36 | - * whether current request is via AJAX  | 
                                                        |
| 37 | - *  | 
                                                        |
| 38 | - * @var boolean $ajax  | 
                                                        |
| 39 | - */  | 
                                                        |
| 40 | - public $ajax = false;  | 
                                                        |
| 41 | -  | 
                                                        |
| 42 | - /**  | 
                                                        |
| 43 | - * whether current request is via AJAX from the frontend of the site  | 
                                                        |
| 44 | - *  | 
                                                        |
| 45 | - * @var boolean $front_ajax  | 
                                                        |
| 46 | - */  | 
                                                        |
| 47 | - public $front_ajax = false;  | 
                                                        |
| 48 | -  | 
                                                        |
| 49 | -  | 
                                                        |
| 50 | -  | 
                                                        |
| 51 | - /**  | 
                                                        |
| 52 | - * @param EE_Request $request  | 
                                                        |
| 53 | - */  | 
                                                        |
| 54 | - public function __construct(EE_Request $request)  | 
                                                        |
| 55 | -    { | 
                                                        |
| 56 | - // grab request vars  | 
                                                        |
| 57 | - $this->_params = $request->params();  | 
                                                        |
| 58 | - // AJAX ???  | 
                                                        |
| 59 | -        $this->ajax = defined('DOING_AJAX') && DOING_AJAX; | 
                                                        |
| 60 | -        $this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX; | 
                                                        |
| 61 | -        do_action('AHEE__EE_Request_Handler__construct__complete'); | 
                                                        |
| 62 | - }  | 
                                                        |
| 63 | -  | 
                                                        |
| 64 | -  | 
                                                        |
| 65 | -  | 
                                                        |
| 66 | - /**  | 
                                                        |
| 67 | - * @param WP $wp  | 
                                                        |
| 68 | - * @return void  | 
                                                        |
| 69 | - * @throws EE_Error  | 
                                                        |
| 70 | - * @throws ReflectionException  | 
                                                        |
| 71 | - */  | 
                                                        |
| 72 | - public function parse_request($wp = null)  | 
                                                        |
| 73 | -    { | 
                                                        |
| 74 | - //if somebody forgot to provide us with WP, that's ok because its global  | 
                                                        |
| 75 | -        if (! $wp instanceof WP) { | 
                                                        |
| 76 | - global $wp;  | 
                                                        |
| 77 | - }  | 
                                                        |
| 78 | - $this->set_request_vars($wp);  | 
                                                        |
| 79 | - }  | 
                                                        |
| 80 | -  | 
                                                        |
| 81 | -  | 
                                                        |
| 82 | -  | 
                                                        |
| 83 | - /**  | 
                                                        |
| 84 | - * @param WP $wp  | 
                                                        |
| 85 | - * @return void  | 
                                                        |
| 86 | - * @throws EE_Error  | 
                                                        |
| 87 | - * @throws ReflectionException  | 
                                                        |
| 88 | - */  | 
                                                        |
| 89 | - public function set_request_vars($wp = null)  | 
                                                        |
| 90 | -    { | 
                                                        |
| 91 | -        if (! is_admin()) { | 
                                                        |
| 92 | - // set request post_id  | 
                                                        |
| 93 | -            $this->set('post_id', $this->get_post_id_from_request($wp)); | 
                                                        |
| 94 | - // set request post name  | 
                                                        |
| 95 | -            $this->set('post_name', $this->get_post_name_from_request($wp)); | 
                                                        |
| 96 | - // set request post_type  | 
                                                        |
| 97 | -            $this->set('post_type', $this->get_post_type_from_request($wp)); | 
                                                        |
| 98 | - // true or false ? is this page being used by EE ?  | 
                                                        |
| 99 | - $this->set_espresso_page();  | 
                                                        |
| 100 | - }  | 
                                                        |
| 101 | - }  | 
                                                        |
| 102 | -  | 
                                                        |
| 103 | -  | 
                                                        |
| 104 | -  | 
                                                        |
| 105 | - /**  | 
                                                        |
| 106 | - * @param WP $wp  | 
                                                        |
| 107 | - * @return int  | 
                                                        |
| 108 | - */  | 
                                                        |
| 109 | - public function get_post_id_from_request($wp = null)  | 
                                                        |
| 110 | -    { | 
                                                        |
| 111 | -        if (! $wp instanceof WP) { | 
                                                        |
| 112 | - global $wp;  | 
                                                        |
| 113 | - }  | 
                                                        |
| 114 | - $post_id = null;  | 
                                                        |
| 115 | -        if (isset($wp->query_vars['p'])) { | 
                                                        |
| 116 | - $post_id = $wp->query_vars['p'];  | 
                                                        |
| 117 | - }  | 
                                                        |
| 118 | -        if (! $post_id && isset($wp->query_vars['page_id'])) { | 
                                                        |
| 119 | - $post_id = $wp->query_vars['page_id'];  | 
                                                        |
| 120 | - }  | 
                                                        |
| 121 | -        if (! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) { | 
                                                        |
| 122 | - $post_id = basename($wp->request);  | 
                                                        |
| 123 | - }  | 
                                                        |
| 124 | - return $post_id;  | 
                                                        |
| 125 | - }  | 
                                                        |
| 126 | -  | 
                                                        |
| 127 | -  | 
                                                        |
| 128 | -  | 
                                                        |
| 129 | - /**  | 
                                                        |
| 130 | - * @param WP $wp  | 
                                                        |
| 131 | - * @return string  | 
                                                        |
| 132 | - */  | 
                                                        |
| 133 | - public function get_post_name_from_request($wp = null)  | 
                                                        |
| 134 | -    { | 
                                                        |
| 135 | -        if (! $wp instanceof WP) { | 
                                                        |
| 136 | - global $wp;  | 
                                                        |
| 137 | - }  | 
                                                        |
| 138 | - $post_name = null;  | 
                                                        |
| 139 | -        if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { | 
                                                        |
| 140 | - $post_name = $wp->query_vars['name'];  | 
                                                        |
| 141 | - }  | 
                                                        |
| 142 | -        if (! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { | 
                                                        |
| 143 | - $post_name = $wp->query_vars['pagename'];  | 
                                                        |
| 144 | - }  | 
                                                        |
| 145 | -        if (! $post_name && $wp->request !== null && ! empty($wp->request)) { | 
                                                        |
| 146 | - $possible_post_name = basename($wp->request);  | 
                                                        |
| 147 | -            if (! is_numeric($possible_post_name)) { | 
                                                        |
| 148 | - /** @type WPDB $wpdb */  | 
                                                        |
| 149 | - global $wpdb;  | 
                                                        |
| 150 | - $SQL =  | 
                                                        |
| 151 | -                    "SELECT ID from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s"; | 
                                                        |
| 152 | - $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name));  | 
                                                        |
| 153 | -                if ($possible_post_name) { | 
                                                        |
| 154 | - $post_name = $possible_post_name;  | 
                                                        |
| 155 | - }  | 
                                                        |
| 156 | - }  | 
                                                        |
| 157 | - }  | 
                                                        |
| 158 | -        if (! $post_name && $this->get('post_id')) { | 
                                                        |
| 159 | - /** @type WPDB $wpdb */  | 
                                                        |
| 160 | - global $wpdb;  | 
                                                        |
| 161 | - $SQL =  | 
                                                        |
| 162 | -                "SELECT post_name from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d"; | 
                                                        |
| 163 | -            $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); | 
                                                        |
| 164 | -            if ($possible_post_name) { | 
                                                        |
| 165 | - $post_name = $possible_post_name;  | 
                                                        |
| 166 | - }  | 
                                                        |
| 167 | - }  | 
                                                        |
| 168 | - return $post_name;  | 
                                                        |
| 169 | - }  | 
                                                        |
| 170 | -  | 
                                                        |
| 171 | -  | 
                                                        |
| 172 | -  | 
                                                        |
| 173 | - /**  | 
                                                        |
| 174 | - * @param WP $wp  | 
                                                        |
| 175 | - * @return mixed  | 
                                                        |
| 176 | - */  | 
                                                        |
| 177 | - public function get_post_type_from_request($wp = null)  | 
                                                        |
| 178 | -    { | 
                                                        |
| 179 | -        if (! $wp instanceof WP) { | 
                                                        |
| 180 | - global $wp;  | 
                                                        |
| 181 | - }  | 
                                                        |
| 182 | - return isset($wp->query_vars['post_type'])  | 
                                                        |
| 183 | - ? $wp->query_vars['post_type']  | 
                                                        |
| 184 | - : null;  | 
                                                        |
| 185 | - }  | 
                                                        |
| 186 | -  | 
                                                        |
| 187 | -  | 
                                                        |
| 188 | -  | 
                                                        |
| 189 | - /**  | 
                                                        |
| 190 | - * Just a helper method for getting the url for the displayed page.  | 
                                                        |
| 191 | - *  | 
                                                        |
| 192 | - * @param WP $wp  | 
                                                        |
| 193 | - * @return string  | 
                                                        |
| 194 | - */  | 
                                                        |
| 195 | - public function get_current_page_permalink($wp = null)  | 
                                                        |
| 196 | -    { | 
                                                        |
| 197 | - $post_id = $this->get_post_id_from_request($wp);  | 
                                                        |
| 198 | -        if ($post_id) { | 
                                                        |
| 199 | - $current_page_permalink = get_permalink($post_id);  | 
                                                        |
| 200 | -        } else { | 
                                                        |
| 201 | -            if (! $wp instanceof WP) { | 
                                                        |
| 202 | - global $wp;  | 
                                                        |
| 203 | - }  | 
                                                        |
| 204 | -            if ($wp->request) { | 
                                                        |
| 205 | - $current_page_permalink = site_url($wp->request);  | 
                                                        |
| 206 | -            } else { | 
                                                        |
| 207 | - $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI']));  | 
                                                        |
| 208 | - }  | 
                                                        |
| 209 | - }  | 
                                                        |
| 210 | - return $current_page_permalink;  | 
                                                        |
| 211 | - }  | 
                                                        |
| 212 | -  | 
                                                        |
| 213 | -  | 
                                                        |
| 214 | -  | 
                                                        |
| 215 | - /**  | 
                                                        |
| 216 | - * @return bool  | 
                                                        |
| 217 | - * @throws EE_Error  | 
                                                        |
| 218 | - * @throws ReflectionException  | 
                                                        |
| 219 | - */  | 
                                                        |
| 220 | - public function test_for_espresso_page()  | 
                                                        |
| 221 | -    { | 
                                                        |
| 222 | - global $wp;  | 
                                                        |
| 223 | - /** @type EE_CPT_Strategy $EE_CPT_Strategy */  | 
                                                        |
| 224 | -        $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); | 
                                                        |
| 225 | - $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies();  | 
                                                        |
| 226 | -        if (is_array($espresso_CPT_taxonomies)) { | 
                                                        |
| 227 | -            foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy => $details) { | 
                                                        |
| 228 | -                if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { | 
                                                        |
| 229 | - return true;  | 
                                                        |
| 230 | - }  | 
                                                        |
| 231 | - }  | 
                                                        |
| 232 | - }  | 
                                                        |
| 233 | - // load espresso CPT endpoints  | 
                                                        |
| 234 | - $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints();  | 
                                                        |
| 235 | - $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);  | 
                                                        |
| 236 | -        $post_types = (array)$this->get('post_type'); | 
                                                        |
| 237 | -        foreach ($post_types as $post_type) { | 
                                                        |
| 238 | - // was a post name passed ?  | 
                                                        |
| 239 | -            if (isset($post_type_CPT_endpoints[$post_type])) { | 
                                                        |
| 240 | - // kk we know this is an espresso page, but is it a specific post ?  | 
                                                        |
| 241 | -                if (! $this->get('post_name')) { | 
                                                        |
| 242 | - // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events  | 
                                                        |
| 243 | -                    $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) | 
                                                        |
| 244 | -                        ? $post_type_CPT_endpoints[$this->get('post_type')] | 
                                                        |
| 245 | - : '';  | 
                                                        |
| 246 | - // if the post type matches on of our then set the endpoint  | 
                                                        |
| 247 | -                    if ($post_name) { | 
                                                        |
| 248 | -                        $this->set('post_name', $post_name); | 
                                                        |
| 249 | - }  | 
                                                        |
| 250 | - }  | 
                                                        |
| 251 | - return true;  | 
                                                        |
| 252 | - }  | 
                                                        |
| 253 | - }  | 
                                                        |
| 254 | - return false;  | 
                                                        |
| 255 | - }  | 
                                                        |
| 256 | -  | 
                                                        |
| 257 | -  | 
                                                        |
| 258 | -  | 
                                                        |
| 259 | - /**  | 
                                                        |
| 260 | - * @param null|bool $value  | 
                                                        |
| 261 | - * @return void  | 
                                                        |
| 262 | - * @throws EE_Error  | 
                                                        |
| 263 | - * @throws ReflectionException  | 
                                                        |
| 264 | - */  | 
                                                        |
| 265 | - public function set_espresso_page($value = null)  | 
                                                        |
| 266 | -    { | 
                                                        |
| 267 | - $this->_params['is_espresso_page'] = ! empty($value)  | 
                                                        |
| 268 | - ? $value  | 
                                                        |
| 269 | - : $this->test_for_espresso_page();  | 
                                                        |
| 270 | - }  | 
                                                        |
| 271 | -  | 
                                                        |
| 272 | -  | 
                                                        |
| 273 | -  | 
                                                        |
| 274 | - /**  | 
                                                        |
| 275 | - * @return mixed  | 
                                                        |
| 276 | - */  | 
                                                        |
| 277 | - public function is_espresso_page()  | 
                                                        |
| 278 | -    { | 
                                                        |
| 279 | - return isset($this->_params['is_espresso_page'])  | 
                                                        |
| 280 | - ? $this->_params['is_espresso_page']  | 
                                                        |
| 281 | - : false;  | 
                                                        |
| 282 | - }  | 
                                                        |
| 283 | -  | 
                                                        |
| 284 | -  | 
                                                        |
| 285 | -  | 
                                                        |
| 286 | - /**  | 
                                                        |
| 287 | - * returns contents of $_REQUEST  | 
                                                        |
| 288 | - *  | 
                                                        |
| 289 | - * @return array  | 
                                                        |
| 290 | - */  | 
                                                        |
| 291 | - public function params()  | 
                                                        |
| 292 | -    { | 
                                                        |
| 293 | - return $this->_params;  | 
                                                        |
| 294 | - }  | 
                                                        |
| 295 | -  | 
                                                        |
| 296 | -  | 
                                                        |
| 297 | -  | 
                                                        |
| 298 | - /**  | 
                                                        |
| 299 | - * @param $key  | 
                                                        |
| 300 | - * @param $value  | 
                                                        |
| 301 | - * @param bool $override_ee  | 
                                                        |
| 302 | - * @return void  | 
                                                        |
| 303 | - */  | 
                                                        |
| 304 | - public function set($key, $value, $override_ee = false)  | 
                                                        |
| 305 | -    { | 
                                                        |
| 306 | - // don't allow "ee" to be overwritten unless explicitly instructed to do so  | 
                                                        |
| 307 | - if (  | 
                                                        |
| 308 | - $key !== 'ee'  | 
                                                        |
| 309 | - || ($key === 'ee' && empty($this->_params['ee']))  | 
                                                        |
| 310 | - || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)  | 
                                                        |
| 311 | -        ) { | 
                                                        |
| 312 | - $this->_params[$key] = $value;  | 
                                                        |
| 313 | - }  | 
                                                        |
| 314 | - }  | 
                                                        |
| 315 | -  | 
                                                        |
| 316 | -  | 
                                                        |
| 317 | -  | 
                                                        |
| 318 | - /**  | 
                                                        |
| 319 | - * @param $key  | 
                                                        |
| 320 | - * @param null $default  | 
                                                        |
| 321 | - * @return mixed  | 
                                                        |
| 322 | - */  | 
                                                        |
| 323 | - public function get($key, $default = null)  | 
                                                        |
| 324 | -    { | 
                                                        |
| 325 | - return isset($this->_params[$key])  | 
                                                        |
| 326 | - ? $this->_params[$key]  | 
                                                        |
| 327 | - : $default;  | 
                                                        |
| 328 | - }  | 
                                                        |
| 329 | -  | 
                                                        |
| 330 | -  | 
                                                        |
| 331 | -  | 
                                                        |
| 332 | - /**  | 
                                                        |
| 333 | - * check if param exists  | 
                                                        |
| 334 | - *  | 
                                                        |
| 335 | - * @param $key  | 
                                                        |
| 336 | - * @return boolean  | 
                                                        |
| 337 | - */  | 
                                                        |
| 338 | - public function is_set($key)  | 
                                                        |
| 339 | -    { | 
                                                        |
| 340 | - return isset($this->_params[$key])  | 
                                                        |
| 341 | - ? true  | 
                                                        |
| 342 | - : false;  | 
                                                        |
| 343 | - }  | 
                                                        |
| 344 | -  | 
                                                        |
| 345 | -  | 
                                                        |
| 346 | -  | 
                                                        |
| 347 | - /**  | 
                                                        |
| 348 | - * remove param  | 
                                                        |
| 349 | - *  | 
                                                        |
| 350 | - * @param $key  | 
                                                        |
| 351 | - * @return void  | 
                                                        |
| 352 | - */  | 
                                                        |
| 353 | - public function un_set($key)  | 
                                                        |
| 354 | -    { | 
                                                        |
| 355 | - unset($this->_params[$key]);  | 
                                                        |
| 356 | - }  | 
                                                        |
| 357 | -  | 
                                                        |
| 358 | -  | 
                                                        |
| 359 | -  | 
                                                        |
| 360 | - /**  | 
                                                        |
| 361 | - * @param $key  | 
                                                        |
| 362 | - * @param $value  | 
                                                        |
| 363 | - * @return void  | 
                                                        |
| 364 | - */  | 
                                                        |
| 365 | - public function set_notice($key, $value)  | 
                                                        |
| 366 | -    { | 
                                                        |
| 367 | - $this->_notice[$key] = $value;  | 
                                                        |
| 368 | - }  | 
                                                        |
| 369 | -  | 
                                                        |
| 370 | -  | 
                                                        |
| 16 | + /**  | 
                                                        |
| 17 | + * $_REQUEST parameters  | 
                                                        |
| 18 | + *  | 
                                                        |
| 19 | + * @var array $_params  | 
                                                        |
| 20 | + */  | 
                                                        |
| 21 | + private $_params;  | 
                                                        |
| 22 | +  | 
                                                        |
| 23 | + /**  | 
                                                        |
| 24 | + * @var array $_notice  | 
                                                        |
| 25 | + */  | 
                                                        |
| 26 | + private $_notice = array();  | 
                                                        |
| 27 | +  | 
                                                        |
| 28 | + /**  | 
                                                        |
| 29 | + * rendered output to be returned to WP  | 
                                                        |
| 30 | + *  | 
                                                        |
| 31 | + * @var string $_output  | 
                                                        |
| 32 | + */  | 
                                                        |
| 33 | + private $_output = '';  | 
                                                        |
| 34 | +  | 
                                                        |
| 35 | + /**  | 
                                                        |
| 36 | + * whether current request is via AJAX  | 
                                                        |
| 37 | + *  | 
                                                        |
| 38 | + * @var boolean $ajax  | 
                                                        |
| 39 | + */  | 
                                                        |
| 40 | + public $ajax = false;  | 
                                                        |
| 41 | +  | 
                                                        |
| 42 | + /**  | 
                                                        |
| 43 | + * whether current request is via AJAX from the frontend of the site  | 
                                                        |
| 44 | + *  | 
                                                        |
| 45 | + * @var boolean $front_ajax  | 
                                                        |
| 46 | + */  | 
                                                        |
| 47 | + public $front_ajax = false;  | 
                                                        |
| 48 | +  | 
                                                        |
| 49 | +  | 
                                                        |
| 50 | +  | 
                                                        |
| 51 | + /**  | 
                                                        |
| 52 | + * @param EE_Request $request  | 
                                                        |
| 53 | + */  | 
                                                        |
| 54 | + public function __construct(EE_Request $request)  | 
                                                        |
| 55 | +	{ | 
                                                        |
| 56 | + // grab request vars  | 
                                                        |
| 57 | + $this->_params = $request->params();  | 
                                                        |
| 58 | + // AJAX ???  | 
                                                        |
| 59 | +		$this->ajax = defined('DOING_AJAX') && DOING_AJAX; | 
                                                        |
| 60 | +		$this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX; | 
                                                        |
| 61 | +		do_action('AHEE__EE_Request_Handler__construct__complete'); | 
                                                        |
| 62 | + }  | 
                                                        |
| 63 | +  | 
                                                        |
| 64 | +  | 
                                                        |
| 65 | +  | 
                                                        |
| 66 | + /**  | 
                                                        |
| 67 | + * @param WP $wp  | 
                                                        |
| 68 | + * @return void  | 
                                                        |
| 69 | + * @throws EE_Error  | 
                                                        |
| 70 | + * @throws ReflectionException  | 
                                                        |
| 71 | + */  | 
                                                        |
| 72 | + public function parse_request($wp = null)  | 
                                                        |
| 73 | +	{ | 
                                                        |
| 74 | + //if somebody forgot to provide us with WP, that's ok because its global  | 
                                                        |
| 75 | +		if (! $wp instanceof WP) { | 
                                                        |
| 76 | + global $wp;  | 
                                                        |
| 77 | + }  | 
                                                        |
| 78 | + $this->set_request_vars($wp);  | 
                                                        |
| 79 | + }  | 
                                                        |
| 80 | +  | 
                                                        |
| 81 | +  | 
                                                        |
| 82 | +  | 
                                                        |
| 83 | + /**  | 
                                                        |
| 84 | + * @param WP $wp  | 
                                                        |
| 85 | + * @return void  | 
                                                        |
| 86 | + * @throws EE_Error  | 
                                                        |
| 87 | + * @throws ReflectionException  | 
                                                        |
| 88 | + */  | 
                                                        |
| 89 | + public function set_request_vars($wp = null)  | 
                                                        |
| 90 | +	{ | 
                                                        |
| 91 | +		if (! is_admin()) { | 
                                                        |
| 92 | + // set request post_id  | 
                                                        |
| 93 | +			$this->set('post_id', $this->get_post_id_from_request($wp)); | 
                                                        |
| 94 | + // set request post name  | 
                                                        |
| 95 | +			$this->set('post_name', $this->get_post_name_from_request($wp)); | 
                                                        |
| 96 | + // set request post_type  | 
                                                        |
| 97 | +			$this->set('post_type', $this->get_post_type_from_request($wp)); | 
                                                        |
| 98 | + // true or false ? is this page being used by EE ?  | 
                                                        |
| 99 | + $this->set_espresso_page();  | 
                                                        |
| 100 | + }  | 
                                                        |
| 101 | + }  | 
                                                        |
| 102 | +  | 
                                                        |
| 103 | +  | 
                                                        |
| 104 | +  | 
                                                        |
| 105 | + /**  | 
                                                        |
| 106 | + * @param WP $wp  | 
                                                        |
| 107 | + * @return int  | 
                                                        |
| 108 | + */  | 
                                                        |
| 109 | + public function get_post_id_from_request($wp = null)  | 
                                                        |
| 110 | +	{ | 
                                                        |
| 111 | +		if (! $wp instanceof WP) { | 
                                                        |
| 112 | + global $wp;  | 
                                                        |
| 113 | + }  | 
                                                        |
| 114 | + $post_id = null;  | 
                                                        |
| 115 | +		if (isset($wp->query_vars['p'])) { | 
                                                        |
| 116 | + $post_id = $wp->query_vars['p'];  | 
                                                        |
| 117 | + }  | 
                                                        |
| 118 | +		if (! $post_id && isset($wp->query_vars['page_id'])) { | 
                                                        |
| 119 | + $post_id = $wp->query_vars['page_id'];  | 
                                                        |
| 120 | + }  | 
                                                        |
| 121 | +		if (! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) { | 
                                                        |
| 122 | + $post_id = basename($wp->request);  | 
                                                        |
| 123 | + }  | 
                                                        |
| 124 | + return $post_id;  | 
                                                        |
| 125 | + }  | 
                                                        |
| 126 | +  | 
                                                        |
| 127 | +  | 
                                                        |
| 128 | +  | 
                                                        |
| 129 | + /**  | 
                                                        |
| 130 | + * @param WP $wp  | 
                                                        |
| 131 | + * @return string  | 
                                                        |
| 132 | + */  | 
                                                        |
| 133 | + public function get_post_name_from_request($wp = null)  | 
                                                        |
| 134 | +	{ | 
                                                        |
| 135 | +		if (! $wp instanceof WP) { | 
                                                        |
| 136 | + global $wp;  | 
                                                        |
| 137 | + }  | 
                                                        |
| 138 | + $post_name = null;  | 
                                                        |
| 139 | +		if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { | 
                                                        |
| 140 | + $post_name = $wp->query_vars['name'];  | 
                                                        |
| 141 | + }  | 
                                                        |
| 142 | +		if (! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { | 
                                                        |
| 143 | + $post_name = $wp->query_vars['pagename'];  | 
                                                        |
| 144 | + }  | 
                                                        |
| 145 | +		if (! $post_name && $wp->request !== null && ! empty($wp->request)) { | 
                                                        |
| 146 | + $possible_post_name = basename($wp->request);  | 
                                                        |
| 147 | +			if (! is_numeric($possible_post_name)) { | 
                                                        |
| 148 | + /** @type WPDB $wpdb */  | 
                                                        |
| 149 | + global $wpdb;  | 
                                                        |
| 150 | + $SQL =  | 
                                                        |
| 151 | +					"SELECT ID from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s"; | 
                                                        |
| 152 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name));  | 
                                                        |
| 153 | +				if ($possible_post_name) { | 
                                                        |
| 154 | + $post_name = $possible_post_name;  | 
                                                        |
| 155 | + }  | 
                                                        |
| 156 | + }  | 
                                                        |
| 157 | + }  | 
                                                        |
| 158 | +		if (! $post_name && $this->get('post_id')) { | 
                                                        |
| 159 | + /** @type WPDB $wpdb */  | 
                                                        |
| 160 | + global $wpdb;  | 
                                                        |
| 161 | + $SQL =  | 
                                                        |
| 162 | +				"SELECT post_name from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d"; | 
                                                        |
| 163 | +			$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); | 
                                                        |
| 164 | +			if ($possible_post_name) { | 
                                                        |
| 165 | + $post_name = $possible_post_name;  | 
                                                        |
| 166 | + }  | 
                                                        |
| 167 | + }  | 
                                                        |
| 168 | + return $post_name;  | 
                                                        |
| 169 | + }  | 
                                                        |
| 170 | +  | 
                                                        |
| 171 | +  | 
                                                        |
| 172 | +  | 
                                                        |
| 173 | + /**  | 
                                                        |
| 174 | + * @param WP $wp  | 
                                                        |
| 175 | + * @return mixed  | 
                                                        |
| 176 | + */  | 
                                                        |
| 177 | + public function get_post_type_from_request($wp = null)  | 
                                                        |
| 178 | +	{ | 
                                                        |
| 179 | +		if (! $wp instanceof WP) { | 
                                                        |
| 180 | + global $wp;  | 
                                                        |
| 181 | + }  | 
                                                        |
| 182 | + return isset($wp->query_vars['post_type'])  | 
                                                        |
| 183 | + ? $wp->query_vars['post_type']  | 
                                                        |
| 184 | + : null;  | 
                                                        |
| 185 | + }  | 
                                                        |
| 186 | +  | 
                                                        |
| 187 | +  | 
                                                        |
| 188 | +  | 
                                                        |
| 189 | + /**  | 
                                                        |
| 190 | + * Just a helper method for getting the url for the displayed page.  | 
                                                        |
| 191 | + *  | 
                                                        |
| 192 | + * @param WP $wp  | 
                                                        |
| 193 | + * @return string  | 
                                                        |
| 194 | + */  | 
                                                        |
| 195 | + public function get_current_page_permalink($wp = null)  | 
                                                        |
| 196 | +	{ | 
                                                        |
| 197 | + $post_id = $this->get_post_id_from_request($wp);  | 
                                                        |
| 198 | +		if ($post_id) { | 
                                                        |
| 199 | + $current_page_permalink = get_permalink($post_id);  | 
                                                        |
| 200 | +		} else { | 
                                                        |
| 201 | +			if (! $wp instanceof WP) { | 
                                                        |
| 202 | + global $wp;  | 
                                                        |
| 203 | + }  | 
                                                        |
| 204 | +			if ($wp->request) { | 
                                                        |
| 205 | + $current_page_permalink = site_url($wp->request);  | 
                                                        |
| 206 | +			} else { | 
                                                        |
| 207 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI']));  | 
                                                        |
| 208 | + }  | 
                                                        |
| 209 | + }  | 
                                                        |
| 210 | + return $current_page_permalink;  | 
                                                        |
| 211 | + }  | 
                                                        |
| 212 | +  | 
                                                        |
| 213 | +  | 
                                                        |
| 214 | +  | 
                                                        |
| 215 | + /**  | 
                                                        |
| 216 | + * @return bool  | 
                                                        |
| 217 | + * @throws EE_Error  | 
                                                        |
| 218 | + * @throws ReflectionException  | 
                                                        |
| 219 | + */  | 
                                                        |
| 220 | + public function test_for_espresso_page()  | 
                                                        |
| 221 | +	{ | 
                                                        |
| 222 | + global $wp;  | 
                                                        |
| 223 | + /** @type EE_CPT_Strategy $EE_CPT_Strategy */  | 
                                                        |
| 224 | +		$EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); | 
                                                        |
| 225 | + $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies();  | 
                                                        |
| 226 | +		if (is_array($espresso_CPT_taxonomies)) { | 
                                                        |
| 227 | +			foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy => $details) { | 
                                                        |
| 228 | +				if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { | 
                                                        |
| 229 | + return true;  | 
                                                        |
| 230 | + }  | 
                                                        |
| 231 | + }  | 
                                                        |
| 232 | + }  | 
                                                        |
| 233 | + // load espresso CPT endpoints  | 
                                                        |
| 234 | + $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints();  | 
                                                        |
| 235 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);  | 
                                                        |
| 236 | +		$post_types = (array)$this->get('post_type'); | 
                                                        |
| 237 | +		foreach ($post_types as $post_type) { | 
                                                        |
| 238 | + // was a post name passed ?  | 
                                                        |
| 239 | +			if (isset($post_type_CPT_endpoints[$post_type])) { | 
                                                        |
| 240 | + // kk we know this is an espresso page, but is it a specific post ?  | 
                                                        |
| 241 | +				if (! $this->get('post_name')) { | 
                                                        |
| 242 | + // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events  | 
                                                        |
| 243 | +					$post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) | 
                                                        |
| 244 | +						? $post_type_CPT_endpoints[$this->get('post_type')] | 
                                                        |
| 245 | + : '';  | 
                                                        |
| 246 | + // if the post type matches on of our then set the endpoint  | 
                                                        |
| 247 | +					if ($post_name) { | 
                                                        |
| 248 | +						$this->set('post_name', $post_name); | 
                                                        |
| 249 | + }  | 
                                                        |
| 250 | + }  | 
                                                        |
| 251 | + return true;  | 
                                                        |
| 252 | + }  | 
                                                        |
| 253 | + }  | 
                                                        |
| 254 | + return false;  | 
                                                        |
| 255 | + }  | 
                                                        |
| 256 | +  | 
                                                        |
| 257 | +  | 
                                                        |
| 258 | +  | 
                                                        |
| 259 | + /**  | 
                                                        |
| 260 | + * @param null|bool $value  | 
                                                        |
| 261 | + * @return void  | 
                                                        |
| 262 | + * @throws EE_Error  | 
                                                        |
| 263 | + * @throws ReflectionException  | 
                                                        |
| 264 | + */  | 
                                                        |
| 265 | + public function set_espresso_page($value = null)  | 
                                                        |
| 266 | +	{ | 
                                                        |
| 267 | + $this->_params['is_espresso_page'] = ! empty($value)  | 
                                                        |
| 268 | + ? $value  | 
                                                        |
| 269 | + : $this->test_for_espresso_page();  | 
                                                        |
| 270 | + }  | 
                                                        |
| 271 | +  | 
                                                        |
| 272 | +  | 
                                                        |
| 273 | +  | 
                                                        |
| 274 | + /**  | 
                                                        |
| 275 | + * @return mixed  | 
                                                        |
| 276 | + */  | 
                                                        |
| 277 | + public function is_espresso_page()  | 
                                                        |
| 278 | +	{ | 
                                                        |
| 279 | + return isset($this->_params['is_espresso_page'])  | 
                                                        |
| 280 | + ? $this->_params['is_espresso_page']  | 
                                                        |
| 281 | + : false;  | 
                                                        |
| 282 | + }  | 
                                                        |
| 283 | +  | 
                                                        |
| 284 | +  | 
                                                        |
| 285 | +  | 
                                                        |
| 286 | + /**  | 
                                                        |
| 287 | + * returns contents of $_REQUEST  | 
                                                        |
| 288 | + *  | 
                                                        |
| 289 | + * @return array  | 
                                                        |
| 290 | + */  | 
                                                        |
| 291 | + public function params()  | 
                                                        |
| 292 | +	{ | 
                                                        |
| 293 | + return $this->_params;  | 
                                                        |
| 294 | + }  | 
                                                        |
| 295 | +  | 
                                                        |
| 296 | +  | 
                                                        |
| 297 | +  | 
                                                        |
| 298 | + /**  | 
                                                        |
| 299 | + * @param $key  | 
                                                        |
| 300 | + * @param $value  | 
                                                        |
| 301 | + * @param bool $override_ee  | 
                                                        |
| 302 | + * @return void  | 
                                                        |
| 303 | + */  | 
                                                        |
| 304 | + public function set($key, $value, $override_ee = false)  | 
                                                        |
| 305 | +	{ | 
                                                        |
| 306 | + // don't allow "ee" to be overwritten unless explicitly instructed to do so  | 
                                                        |
| 307 | + if (  | 
                                                        |
| 308 | + $key !== 'ee'  | 
                                                        |
| 309 | + || ($key === 'ee' && empty($this->_params['ee']))  | 
                                                        |
| 310 | + || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)  | 
                                                        |
| 311 | +		) { | 
                                                        |
| 312 | + $this->_params[$key] = $value;  | 
                                                        |
| 313 | + }  | 
                                                        |
| 314 | + }  | 
                                                        |
| 315 | +  | 
                                                        |
| 316 | +  | 
                                                        |
| 317 | +  | 
                                                        |
| 318 | + /**  | 
                                                        |
| 319 | + * @param $key  | 
                                                        |
| 320 | + * @param null $default  | 
                                                        |
| 321 | + * @return mixed  | 
                                                        |
| 322 | + */  | 
                                                        |
| 323 | + public function get($key, $default = null)  | 
                                                        |
| 324 | +	{ | 
                                                        |
| 325 | + return isset($this->_params[$key])  | 
                                                        |
| 326 | + ? $this->_params[$key]  | 
                                                        |
| 327 | + : $default;  | 
                                                        |
| 328 | + }  | 
                                                        |
| 329 | +  | 
                                                        |
| 330 | +  | 
                                                        |
| 331 | +  | 
                                                        |
| 332 | + /**  | 
                                                        |
| 333 | + * check if param exists  | 
                                                        |
| 334 | + *  | 
                                                        |
| 335 | + * @param $key  | 
                                                        |
| 336 | + * @return boolean  | 
                                                        |
| 337 | + */  | 
                                                        |
| 338 | + public function is_set($key)  | 
                                                        |
| 339 | +	{ | 
                                                        |
| 340 | + return isset($this->_params[$key])  | 
                                                        |
| 341 | + ? true  | 
                                                        |
| 342 | + : false;  | 
                                                        |
| 343 | + }  | 
                                                        |
| 344 | +  | 
                                                        |
| 345 | +  | 
                                                        |
| 346 | +  | 
                                                        |
| 347 | + /**  | 
                                                        |
| 348 | + * remove param  | 
                                                        |
| 349 | + *  | 
                                                        |
| 350 | + * @param $key  | 
                                                        |
| 351 | + * @return void  | 
                                                        |
| 352 | + */  | 
                                                        |
| 353 | + public function un_set($key)  | 
                                                        |
| 354 | +	{ | 
                                                        |
| 355 | + unset($this->_params[$key]);  | 
                                                        |
| 356 | + }  | 
                                                        |
| 357 | +  | 
                                                        |
| 358 | +  | 
                                                        |
| 359 | +  | 
                                                        |
| 360 | + /**  | 
                                                        |
| 361 | + * @param $key  | 
                                                        |
| 362 | + * @param $value  | 
                                                        |
| 363 | + * @return void  | 
                                                        |
| 364 | + */  | 
                                                        |
| 365 | + public function set_notice($key, $value)  | 
                                                        |
| 366 | +	{ | 
                                                        |
| 367 | + $this->_notice[$key] = $value;  | 
                                                        |
| 368 | + }  | 
                                                        |
| 369 | +  | 
                                                        |
| 370 | +  | 
                                                        |
| 371 | 371 | |
| 372 | - /**  | 
                                                        |
| 373 | - * @param $key  | 
                                                        |
| 374 | - * @return mixed  | 
                                                        |
| 375 | - */  | 
                                                        |
| 376 | - public function get_notice($key)  | 
                                                        |
| 377 | -    { | 
                                                        |
| 378 | - return isset($this->_notice[$key])  | 
                                                        |
| 379 | - ? $this->_notice[$key]  | 
                                                        |
| 380 | - : null;  | 
                                                        |
| 381 | - }  | 
                                                        |
| 372 | + /**  | 
                                                        |
| 373 | + * @param $key  | 
                                                        |
| 374 | + * @return mixed  | 
                                                        |
| 375 | + */  | 
                                                        |
| 376 | + public function get_notice($key)  | 
                                                        |
| 377 | +	{ | 
                                                        |
| 378 | + return isset($this->_notice[$key])  | 
                                                        |
| 379 | + ? $this->_notice[$key]  | 
                                                        |
| 380 | + : null;  | 
                                                        |
| 381 | + }  | 
                                                        |
| 382 | 382 | |
| 383 | 383 | |
| 384 | 384 | |
| 385 | - /**  | 
                                                        |
| 386 | - * @param $string  | 
                                                        |
| 387 | - * @return void  | 
                                                        |
| 388 | - */  | 
                                                        |
| 389 | - public function add_output($string)  | 
                                                        |
| 390 | -    { | 
                                                        |
| 391 | - $this->_output .= $string;  | 
                                                        |
| 392 | - }  | 
                                                        |
| 385 | + /**  | 
                                                        |
| 386 | + * @param $string  | 
                                                        |
| 387 | + * @return void  | 
                                                        |
| 388 | + */  | 
                                                        |
| 389 | + public function add_output($string)  | 
                                                        |
| 390 | +	{ | 
                                                        |
| 391 | + $this->_output .= $string;  | 
                                                        |
| 392 | + }  | 
                                                        |
| 393 | 393 | |
| 394 | 394 | |
| 395 | 395 | |
| 396 | - /**  | 
                                                        |
| 397 | - * @return string  | 
                                                        |
| 398 | - */  | 
                                                        |
| 399 | - public function get_output()  | 
                                                        |
| 400 | -    { | 
                                                        |
| 401 | - return $this->_output;  | 
                                                        |
| 402 | - }  | 
                                                        |
| 403 | -  | 
                                                        |
| 404 | -  | 
                                                        |
| 396 | + /**  | 
                                                        |
| 397 | + * @return string  | 
                                                        |
| 398 | + */  | 
                                                        |
| 399 | + public function get_output()  | 
                                                        |
| 400 | +	{ | 
                                                        |
| 401 | + return $this->_output;  | 
                                                        |
| 402 | + }  | 
                                                        |
| 403 | +  | 
                                                        |
| 404 | +  | 
                                                        |
| 405 | 405 | |
| 406 | - /**  | 
                                                        |
| 407 | - * @param $item  | 
                                                        |
| 408 | - * @param $key  | 
                                                        |
| 409 | - */  | 
                                                        |
| 410 | - public function sanitize_text_field_for_array_walk(&$item, &$key)  | 
                                                        |
| 411 | -    { | 
                                                        |
| 412 | - $item = strpos($item, 'email') !== false  | 
                                                        |
| 413 | - ? sanitize_email($item)  | 
                                                        |
| 414 | - : sanitize_text_field($item);  | 
                                                        |
| 415 | - }  | 
                                                        |
| 406 | + /**  | 
                                                        |
| 407 | + * @param $item  | 
                                                        |
| 408 | + * @param $key  | 
                                                        |
| 409 | + */  | 
                                                        |
| 410 | + public function sanitize_text_field_for_array_walk(&$item, &$key)  | 
                                                        |
| 411 | +	{ | 
                                                        |
| 412 | + $item = strpos($item, 'email') !== false  | 
                                                        |
| 413 | + ? sanitize_email($item)  | 
                                                        |
| 414 | + : sanitize_text_field($item);  | 
                                                        |
| 415 | + }  | 
                                                        |
| 416 | 416 | |
| 417 | 417 | |
| 418 | 418 | |
| 419 | - /**  | 
                                                        |
| 420 | - * @param $a  | 
                                                        |
| 421 | - * @param $b  | 
                                                        |
| 422 | - * @return bool  | 
                                                        |
| 423 | - */  | 
                                                        |
| 424 | - public function __set($a, $b)  | 
                                                        |
| 425 | -    { | 
                                                        |
| 426 | - return false;  | 
                                                        |
| 427 | - }  | 
                                                        |
| 419 | + /**  | 
                                                        |
| 420 | + * @param $a  | 
                                                        |
| 421 | + * @param $b  | 
                                                        |
| 422 | + * @return bool  | 
                                                        |
| 423 | + */  | 
                                                        |
| 424 | + public function __set($a, $b)  | 
                                                        |
| 425 | +	{ | 
                                                        |
| 426 | + return false;  | 
                                                        |
| 427 | + }  | 
                                                        |
| 428 | 428 | |
| 429 | 429 | |
| 430 | 430 | |
| 431 | - /**  | 
                                                        |
| 432 | - * @param $a  | 
                                                        |
| 433 | - * @return bool  | 
                                                        |
| 434 | - */  | 
                                                        |
| 435 | - public function __get($a)  | 
                                                        |
| 436 | -    { | 
                                                        |
| 437 | - return false;  | 
                                                        |
| 438 | - }  | 
                                                        |
| 431 | + /**  | 
                                                        |
| 432 | + * @param $a  | 
                                                        |
| 433 | + * @return bool  | 
                                                        |
| 434 | + */  | 
                                                        |
| 435 | + public function __get($a)  | 
                                                        |
| 436 | +	{ | 
                                                        |
| 437 | + return false;  | 
                                                        |
| 438 | + }  | 
                                                        |
| 439 | 439 | |
| 440 | 440 | |
| 441 | 441 | |
| 442 | - /**  | 
                                                        |
| 443 | - * @param $a  | 
                                                        |
| 444 | - * @return bool  | 
                                                        |
| 445 | - */  | 
                                                        |
| 446 | - public function __isset($a)  | 
                                                        |
| 447 | -    { | 
                                                        |
| 448 | - return false;  | 
                                                        |
| 449 | - }  | 
                                                        |
| 442 | + /**  | 
                                                        |
| 443 | + * @param $a  | 
                                                        |
| 444 | + * @return bool  | 
                                                        |
| 445 | + */  | 
                                                        |
| 446 | + public function __isset($a)  | 
                                                        |
| 447 | +	{ | 
                                                        |
| 448 | + return false;  | 
                                                        |
| 449 | + }  | 
                                                        |
| 450 | 450 | |
| 451 | 451 | |
| 452 | 452 | |
| 453 | - /**  | 
                                                        |
| 454 | - * @param $a  | 
                                                        |
| 455 | - * @return bool  | 
                                                        |
| 456 | - */  | 
                                                        |
| 457 | - public function __unset($a)  | 
                                                        |
| 458 | -    { | 
                                                        |
| 459 | - return false;  | 
                                                        |
| 460 | - }  | 
                                                        |
| 453 | + /**  | 
                                                        |
| 454 | + * @param $a  | 
                                                        |
| 455 | + * @return bool  | 
                                                        |
| 456 | + */  | 
                                                        |
| 457 | + public function __unset($a)  | 
                                                        |
| 458 | +	{ | 
                                                        |
| 459 | + return false;  | 
                                                        |
| 460 | + }  | 
                                                        |
| 461 | 461 | |
| 462 | 462 | |
| 463 | 463 | |
| 464 | - /**  | 
                                                        |
| 465 | - * @return void  | 
                                                        |
| 466 | - */  | 
                                                        |
| 467 | - public function __clone()  | 
                                                        |
| 468 | -    { | 
                                                        |
| 469 | - }  | 
                                                        |
| 464 | + /**  | 
                                                        |
| 465 | + * @return void  | 
                                                        |
| 466 | + */  | 
                                                        |
| 467 | + public function __clone()  | 
                                                        |
| 468 | +	{ | 
                                                        |
| 469 | + }  | 
                                                        |
| 470 | 470 | |
| 471 | 471 | |
| 472 | 472 | |
| 473 | - /**  | 
                                                        |
| 474 | - * @return void  | 
                                                        |
| 475 | - */  | 
                                                        |
| 476 | - public function __wakeup()  | 
                                                        |
| 477 | -    { | 
                                                        |
| 478 | - }  | 
                                                        |
| 473 | + /**  | 
                                                        |
| 474 | + * @return void  | 
                                                        |
| 475 | + */  | 
                                                        |
| 476 | + public function __wakeup()  | 
                                                        |
| 477 | +	{ | 
                                                        |
| 478 | + }  | 
                                                        |
| 479 | 479 | |
| 480 | 480 | |
| 481 | 481 | |
| 482 | - /**  | 
                                                        |
| 483 | - *  | 
                                                        |
| 484 | - */  | 
                                                        |
| 485 | - public function __destruct()  | 
                                                        |
| 486 | -    { | 
                                                        |
| 487 | - }  | 
                                                        |
| 482 | + /**  | 
                                                        |
| 483 | + *  | 
                                                        |
| 484 | + */  | 
                                                        |
| 485 | + public function __destruct()  | 
                                                        |
| 486 | +	{ | 
                                                        |
| 487 | + }  | 
                                                        |
| 488 | 488 | |
| 489 | 489 | |
| 490 | 490 | }  | 
                                                        
@@ -72,7 +72,7 @@ discard block  | 
                                                    ||
| 72 | 72 | public function parse_request($wp = null)  | 
                                                        
| 73 | 73 |      { | 
                                                        
| 74 | 74 | //if somebody forgot to provide us with WP, that's ok because its global  | 
                                                        
| 75 | -        if (! $wp instanceof WP) { | 
                                                        |
| 75 | +        if ( ! $wp instanceof WP) { | 
                                                        |
| 76 | 76 | global $wp;  | 
                                                        
| 77 | 77 | }  | 
                                                        
| 78 | 78 | $this->set_request_vars($wp);  | 
                                                        
@@ -88,7 +88,7 @@ discard block  | 
                                                    ||
| 88 | 88 | */  | 
                                                        
| 89 | 89 | public function set_request_vars($wp = null)  | 
                                                        
| 90 | 90 |      { | 
                                                        
| 91 | -        if (! is_admin()) { | 
                                                        |
| 91 | +        if ( ! is_admin()) { | 
                                                        |
| 92 | 92 | // set request post_id  | 
                                                        
| 93 | 93 |              $this->set('post_id', $this->get_post_id_from_request($wp)); | 
                                                        
| 94 | 94 | // set request post name  | 
                                                        
@@ -108,17 +108,17 @@ discard block  | 
                                                    ||
| 108 | 108 | */  | 
                                                        
| 109 | 109 | public function get_post_id_from_request($wp = null)  | 
                                                        
| 110 | 110 |      { | 
                                                        
| 111 | -        if (! $wp instanceof WP) { | 
                                                        |
| 111 | +        if ( ! $wp instanceof WP) { | 
                                                        |
| 112 | 112 | global $wp;  | 
                                                        
| 113 | 113 | }  | 
                                                        
| 114 | 114 | $post_id = null;  | 
                                                        
| 115 | 115 |          if (isset($wp->query_vars['p'])) { | 
                                                        
| 116 | 116 | $post_id = $wp->query_vars['p'];  | 
                                                        
| 117 | 117 | }  | 
                                                        
| 118 | -        if (! $post_id && isset($wp->query_vars['page_id'])) { | 
                                                        |
| 118 | +        if ( ! $post_id && isset($wp->query_vars['page_id'])) { | 
                                                        |
| 119 | 119 | $post_id = $wp->query_vars['page_id'];  | 
                                                        
| 120 | 120 | }  | 
                                                        
| 121 | -        if (! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) { | 
                                                        |
| 121 | +        if ( ! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) { | 
                                                        |
| 122 | 122 | $post_id = basename($wp->request);  | 
                                                        
| 123 | 123 | }  | 
                                                        
| 124 | 124 | return $post_id;  | 
                                                        
@@ -132,19 +132,19 @@ discard block  | 
                                                    ||
| 132 | 132 | */  | 
                                                        
| 133 | 133 | public function get_post_name_from_request($wp = null)  | 
                                                        
| 134 | 134 |      { | 
                                                        
| 135 | -        if (! $wp instanceof WP) { | 
                                                        |
| 135 | +        if ( ! $wp instanceof WP) { | 
                                                        |
| 136 | 136 | global $wp;  | 
                                                        
| 137 | 137 | }  | 
                                                        
| 138 | 138 | $post_name = null;  | 
                                                        
| 139 | 139 |          if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { | 
                                                        
| 140 | 140 | $post_name = $wp->query_vars['name'];  | 
                                                        
| 141 | 141 | }  | 
                                                        
| 142 | -        if (! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { | 
                                                        |
| 142 | +        if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { | 
                                                        |
| 143 | 143 | $post_name = $wp->query_vars['pagename'];  | 
                                                        
| 144 | 144 | }  | 
                                                        
| 145 | -        if (! $post_name && $wp->request !== null && ! empty($wp->request)) { | 
                                                        |
| 145 | +        if ( ! $post_name && $wp->request !== null && ! empty($wp->request)) { | 
                                                        |
| 146 | 146 | $possible_post_name = basename($wp->request);  | 
                                                        
| 147 | -            if (! is_numeric($possible_post_name)) { | 
                                                        |
| 147 | +            if ( ! is_numeric($possible_post_name)) { | 
                                                        |
| 148 | 148 | /** @type WPDB $wpdb */  | 
                                                        
| 149 | 149 | global $wpdb;  | 
                                                        
| 150 | 150 | $SQL =  | 
                                                        
@@ -155,7 +155,7 @@ discard block  | 
                                                    ||
| 155 | 155 | }  | 
                                                        
| 156 | 156 | }  | 
                                                        
| 157 | 157 | }  | 
                                                        
| 158 | -        if (! $post_name && $this->get('post_id')) { | 
                                                        |
| 158 | +        if ( ! $post_name && $this->get('post_id')) { | 
                                                        |
| 159 | 159 | /** @type WPDB $wpdb */  | 
                                                        
| 160 | 160 | global $wpdb;  | 
                                                        
| 161 | 161 | $SQL =  | 
                                                        
@@ -176,7 +176,7 @@ discard block  | 
                                                    ||
| 176 | 176 | */  | 
                                                        
| 177 | 177 | public function get_post_type_from_request($wp = null)  | 
                                                        
| 178 | 178 |      { | 
                                                        
| 179 | -        if (! $wp instanceof WP) { | 
                                                        |
| 179 | +        if ( ! $wp instanceof WP) { | 
                                                        |
| 180 | 180 | global $wp;  | 
                                                        
| 181 | 181 | }  | 
                                                        
| 182 | 182 | return isset($wp->query_vars['post_type'])  | 
                                                        
@@ -198,7 +198,7 @@ discard block  | 
                                                    ||
| 198 | 198 |          if ($post_id) { | 
                                                        
| 199 | 199 | $current_page_permalink = get_permalink($post_id);  | 
                                                        
| 200 | 200 |          } else { | 
                                                        
| 201 | -            if (! $wp instanceof WP) { | 
                                                        |
| 201 | +            if ( ! $wp instanceof WP) { | 
                                                        |
| 202 | 202 | global $wp;  | 
                                                        
| 203 | 203 | }  | 
                                                        
| 204 | 204 |              if ($wp->request) { | 
                                                        
@@ -233,12 +233,12 @@ discard block  | 
                                                    ||
| 233 | 233 | // load espresso CPT endpoints  | 
                                                        
| 234 | 234 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints();  | 
                                                        
| 235 | 235 | $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);  | 
                                                        
| 236 | -        $post_types = (array)$this->get('post_type'); | 
                                                        |
| 236 | +        $post_types = (array) $this->get('post_type'); | 
                                                        |
| 237 | 237 |          foreach ($post_types as $post_type) { | 
                                                        
| 238 | 238 | // was a post name passed ?  | 
                                                        
| 239 | 239 |              if (isset($post_type_CPT_endpoints[$post_type])) { | 
                                                        
| 240 | 240 | // kk we know this is an espresso page, but is it a specific post ?  | 
                                                        
| 241 | -                if (! $this->get('post_name')) { | 
                                                        |
| 241 | +                if ( ! $this->get('post_name')) { | 
                                                        |
| 242 | 242 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events  | 
                                                        
| 243 | 243 |                      $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) | 
                                                        
| 244 | 244 |                          ? $post_type_CPT_endpoints[$this->get('post_type')] | 
                                                        
@@ -15,222 +15,222 @@  | 
                                                    ||
| 15 | 15 | class EE_Request implements InterminableInterface  | 
                                                        
| 16 | 16 |  { | 
                                                        
| 17 | 17 | |
| 18 | - /**  | 
                                                        |
| 19 | - * $_GET parameters  | 
                                                        |
| 20 | - *  | 
                                                        |
| 21 | - * @var array $_get  | 
                                                        |
| 22 | - */  | 
                                                        |
| 23 | - private $_get;  | 
                                                        |
| 24 | -  | 
                                                        |
| 25 | - /**  | 
                                                        |
| 26 | - * $_POST parameters  | 
                                                        |
| 27 | - *  | 
                                                        |
| 28 | - * @var array $_post  | 
                                                        |
| 29 | - */  | 
                                                        |
| 30 | - private $_post;  | 
                                                        |
| 31 | -  | 
                                                        |
| 32 | - /**  | 
                                                        |
| 33 | - * $_COOKIE parameters  | 
                                                        |
| 34 | - *  | 
                                                        |
| 35 | - * @var array $_cookie  | 
                                                        |
| 36 | - */  | 
                                                        |
| 37 | - private $_cookie;  | 
                                                        |
| 38 | -  | 
                                                        |
| 39 | - /**  | 
                                                        |
| 40 | - * $_REQUEST parameters  | 
                                                        |
| 41 | - *  | 
                                                        |
| 42 | - * @var array $_params  | 
                                                        |
| 43 | - */  | 
                                                        |
| 44 | - private $_params;  | 
                                                        |
| 45 | -  | 
                                                        |
| 46 | - /**  | 
                                                        |
| 47 | - * whether current request is via AJAX  | 
                                                        |
| 48 | - *  | 
                                                        |
| 49 | - * @access public  | 
                                                        |
| 50 | - */  | 
                                                        |
| 51 | - public $ajax = false;  | 
                                                        |
| 52 | -  | 
                                                        |
| 53 | - /**  | 
                                                        |
| 54 | - * whether current request is via AJAX from the frontend of the site  | 
                                                        |
| 55 | - *  | 
                                                        |
| 56 | - * @access public  | 
                                                        |
| 57 | - */  | 
                                                        |
| 58 | - public $front_ajax = false;  | 
                                                        |
| 59 | -  | 
                                                        |
| 60 | - /**  | 
                                                        |
| 61 | - * IP address for request  | 
                                                        |
| 62 | - *  | 
                                                        |
| 63 | - * @var string $_ip_address  | 
                                                        |
| 64 | - */  | 
                                                        |
| 65 | - private $_ip_address;  | 
                                                        |
| 66 | -  | 
                                                        |
| 67 | -  | 
                                                        |
| 68 | -  | 
                                                        |
| 69 | - /**  | 
                                                        |
| 70 | - * class constructor  | 
                                                        |
| 71 | - *  | 
                                                        |
| 72 | - * @access public  | 
                                                        |
| 73 | - * @param array $get  | 
                                                        |
| 74 | - * @param array $post  | 
                                                        |
| 75 | - * @param array $cookie  | 
                                                        |
| 76 | - */  | 
                                                        |
| 77 | - public function __construct($get, $post, $cookie)  | 
                                                        |
| 78 | -    { | 
                                                        |
| 79 | - // grab request vars  | 
                                                        |
| 80 | - $this->_get = (array)$get;  | 
                                                        |
| 81 | - $this->_post = (array)$post;  | 
                                                        |
| 82 | - $this->_cookie = (array)$cookie;  | 
                                                        |
| 83 | - $this->_params = array_merge($this->_get, $this->_post);  | 
                                                        |
| 84 | - // AJAX ???  | 
                                                        |
| 85 | -        $this->ajax = defined('DOING_AJAX') ? true : false; | 
                                                        |
| 86 | -        $this->front_ajax = $this->is_set('ee_front_ajax') && (int)$this->get('ee_front_ajax') === 1; | 
                                                        |
| 87 | - // grab user IP  | 
                                                        |
| 88 | - $this->_ip_address = $this->_visitor_ip();  | 
                                                        |
| 89 | - }  | 
                                                        |
| 90 | -  | 
                                                        |
| 91 | -  | 
                                                        |
| 92 | -  | 
                                                        |
| 93 | - /**  | 
                                                        |
| 94 | - * @return array  | 
                                                        |
| 95 | - */  | 
                                                        |
| 96 | - public function get_params()  | 
                                                        |
| 97 | -    { | 
                                                        |
| 98 | - return $this->_get;  | 
                                                        |
| 99 | - }  | 
                                                        |
| 100 | -  | 
                                                        |
| 101 | -  | 
                                                        |
| 102 | -  | 
                                                        |
| 103 | - /**  | 
                                                        |
| 104 | - * @return array  | 
                                                        |
| 105 | - */  | 
                                                        |
| 106 | - public function post_params()  | 
                                                        |
| 107 | -    { | 
                                                        |
| 108 | - return $this->_post;  | 
                                                        |
| 109 | - }  | 
                                                        |
| 110 | -  | 
                                                        |
| 111 | -  | 
                                                        |
| 112 | -  | 
                                                        |
| 113 | - /**  | 
                                                        |
| 114 | - * @return array  | 
                                                        |
| 115 | - */  | 
                                                        |
| 116 | - public function cookie_params()  | 
                                                        |
| 117 | -    { | 
                                                        |
| 118 | - return $this->_cookie;  | 
                                                        |
| 119 | - }  | 
                                                        |
| 120 | -  | 
                                                        |
| 121 | -  | 
                                                        |
| 122 | -  | 
                                                        |
| 123 | - /**  | 
                                                        |
| 124 | - * returns contents of $_REQUEST  | 
                                                        |
| 125 | - *  | 
                                                        |
| 126 | - * @return array  | 
                                                        |
| 127 | - */  | 
                                                        |
| 128 | - public function params()  | 
                                                        |
| 129 | -    { | 
                                                        |
| 130 | - return $this->_params;  | 
                                                        |
| 131 | - }  | 
                                                        |
| 132 | -  | 
                                                        |
| 133 | -  | 
                                                        |
| 134 | -  | 
                                                        |
| 135 | - /**  | 
                                                        |
| 136 | - * @param $key  | 
                                                        |
| 137 | - * @param $value  | 
                                                        |
| 138 | - * @param bool $override_ee  | 
                                                        |
| 139 | - * @return void  | 
                                                        |
| 140 | - */  | 
                                                        |
| 141 | - public function set($key, $value, $override_ee = false)  | 
                                                        |
| 142 | -    { | 
                                                        |
| 143 | - // don't allow "ee" to be overwritten unless explicitly instructed to do so  | 
                                                        |
| 144 | - if (  | 
                                                        |
| 145 | - $key !== 'ee'  | 
                                                        |
| 146 | - || ($key === 'ee' && empty($this->_params['ee']))  | 
                                                        |
| 147 | - || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)  | 
                                                        |
| 148 | -        ) { | 
                                                        |
| 149 | - $this->_params[$key] = $value;  | 
                                                        |
| 150 | - }  | 
                                                        |
| 151 | - }  | 
                                                        |
| 152 | -  | 
                                                        |
| 153 | -  | 
                                                        |
| 154 | -  | 
                                                        |
| 155 | - /**  | 
                                                        |
| 156 | - * @param $key  | 
                                                        |
| 157 | - * @param null $default  | 
                                                        |
| 158 | - * @return mixed  | 
                                                        |
| 159 | - */  | 
                                                        |
| 160 | - public function get($key, $default = null)  | 
                                                        |
| 161 | -    { | 
                                                        |
| 162 | - return isset($this->_params[$key]) ? $this->_params[$key] : $default;  | 
                                                        |
| 163 | - }  | 
                                                        |
| 164 | -  | 
                                                        |
| 165 | -  | 
                                                        |
| 166 | -  | 
                                                        |
| 167 | - /**  | 
                                                        |
| 168 | - * @param $key  | 
                                                        |
| 169 | - * @return boolean  | 
                                                        |
| 170 | - */  | 
                                                        |
| 171 | - public function is_set($key)  | 
                                                        |
| 172 | -    { | 
                                                        |
| 173 | - return isset($this->_params[$key]) ? true : false;  | 
                                                        |
| 174 | - }  | 
                                                        |
| 175 | -  | 
                                                        |
| 176 | -  | 
                                                        |
| 177 | -  | 
                                                        |
| 178 | - /**  | 
                                                        |
| 179 | - * remove param  | 
                                                        |
| 180 | - * @param $key  | 
                                                        |
| 181 | - * @param bool $unset_from_global_too  | 
                                                        |
| 182 | - */  | 
                                                        |
| 183 | - public function un_set($key, $unset_from_global_too = false)  | 
                                                        |
| 184 | -    { | 
                                                        |
| 185 | - unset($this->_params[$key]);  | 
                                                        |
| 186 | -        if ($unset_from_global_too) { | 
                                                        |
| 187 | - unset($_REQUEST[$key]);  | 
                                                        |
| 188 | - }  | 
                                                        |
| 189 | - }  | 
                                                        |
| 190 | -  | 
                                                        |
| 191 | -  | 
                                                        |
| 192 | -  | 
                                                        |
| 193 | - /**  | 
                                                        |
| 194 | - * @return string  | 
                                                        |
| 195 | - */  | 
                                                        |
| 196 | - public function ip_address()  | 
                                                        |
| 197 | -    { | 
                                                        |
| 198 | - return $this->_ip_address;  | 
                                                        |
| 199 | - }  | 
                                                        |
| 200 | -  | 
                                                        |
| 201 | -  | 
                                                        |
| 202 | -  | 
                                                        |
| 203 | - /**  | 
                                                        |
| 204 | - * _visitor_ip  | 
                                                        |
| 205 | - * attempt to get IP address of current visitor from server  | 
                                                        |
| 206 | - * plz see: http://stackoverflow.com/a/2031935/1475279  | 
                                                        |
| 207 | - *  | 
                                                        |
| 208 | - * @access public  | 
                                                        |
| 209 | - * @return string  | 
                                                        |
| 210 | - */  | 
                                                        |
| 211 | - private function _visitor_ip()  | 
                                                        |
| 212 | -    { | 
                                                        |
| 213 | - $visitor_ip = '0.0.0.0';  | 
                                                        |
| 214 | - $server_keys = array(  | 
                                                        |
| 215 | - 'HTTP_CLIENT_IP',  | 
                                                        |
| 216 | - 'HTTP_X_FORWARDED_FOR',  | 
                                                        |
| 217 | - 'HTTP_X_FORWARDED',  | 
                                                        |
| 218 | - 'HTTP_X_CLUSTER_CLIENT_IP',  | 
                                                        |
| 219 | - 'HTTP_FORWARDED_FOR',  | 
                                                        |
| 220 | - 'HTTP_FORWARDED',  | 
                                                        |
| 221 | - 'REMOTE_ADDR',  | 
                                                        |
| 222 | - );  | 
                                                        |
| 223 | -        foreach ($server_keys as $key) { | 
                                                        |
| 224 | -            if (isset($_SERVER[$key])) { | 
                                                        |
| 225 | -                foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { | 
                                                        |
| 226 | -                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { | 
                                                        |
| 227 | - $visitor_ip = $ip;  | 
                                                        |
| 228 | - }  | 
                                                        |
| 229 | - }  | 
                                                        |
| 230 | - }  | 
                                                        |
| 231 | - }  | 
                                                        |
| 232 | - return $visitor_ip;  | 
                                                        |
| 233 | - }  | 
                                                        |
| 18 | + /**  | 
                                                        |
| 19 | + * $_GET parameters  | 
                                                        |
| 20 | + *  | 
                                                        |
| 21 | + * @var array $_get  | 
                                                        |
| 22 | + */  | 
                                                        |
| 23 | + private $_get;  | 
                                                        |
| 24 | +  | 
                                                        |
| 25 | + /**  | 
                                                        |
| 26 | + * $_POST parameters  | 
                                                        |
| 27 | + *  | 
                                                        |
| 28 | + * @var array $_post  | 
                                                        |
| 29 | + */  | 
                                                        |
| 30 | + private $_post;  | 
                                                        |
| 31 | +  | 
                                                        |
| 32 | + /**  | 
                                                        |
| 33 | + * $_COOKIE parameters  | 
                                                        |
| 34 | + *  | 
                                                        |
| 35 | + * @var array $_cookie  | 
                                                        |
| 36 | + */  | 
                                                        |
| 37 | + private $_cookie;  | 
                                                        |
| 38 | +  | 
                                                        |
| 39 | + /**  | 
                                                        |
| 40 | + * $_REQUEST parameters  | 
                                                        |
| 41 | + *  | 
                                                        |
| 42 | + * @var array $_params  | 
                                                        |
| 43 | + */  | 
                                                        |
| 44 | + private $_params;  | 
                                                        |
| 45 | +  | 
                                                        |
| 46 | + /**  | 
                                                        |
| 47 | + * whether current request is via AJAX  | 
                                                        |
| 48 | + *  | 
                                                        |
| 49 | + * @access public  | 
                                                        |
| 50 | + */  | 
                                                        |
| 51 | + public $ajax = false;  | 
                                                        |
| 52 | +  | 
                                                        |
| 53 | + /**  | 
                                                        |
| 54 | + * whether current request is via AJAX from the frontend of the site  | 
                                                        |
| 55 | + *  | 
                                                        |
| 56 | + * @access public  | 
                                                        |
| 57 | + */  | 
                                                        |
| 58 | + public $front_ajax = false;  | 
                                                        |
| 59 | +  | 
                                                        |
| 60 | + /**  | 
                                                        |
| 61 | + * IP address for request  | 
                                                        |
| 62 | + *  | 
                                                        |
| 63 | + * @var string $_ip_address  | 
                                                        |
| 64 | + */  | 
                                                        |
| 65 | + private $_ip_address;  | 
                                                        |
| 66 | +  | 
                                                        |
| 67 | +  | 
                                                        |
| 68 | +  | 
                                                        |
| 69 | + /**  | 
                                                        |
| 70 | + * class constructor  | 
                                                        |
| 71 | + *  | 
                                                        |
| 72 | + * @access public  | 
                                                        |
| 73 | + * @param array $get  | 
                                                        |
| 74 | + * @param array $post  | 
                                                        |
| 75 | + * @param array $cookie  | 
                                                        |
| 76 | + */  | 
                                                        |
| 77 | + public function __construct($get, $post, $cookie)  | 
                                                        |
| 78 | +	{ | 
                                                        |
| 79 | + // grab request vars  | 
                                                        |
| 80 | + $this->_get = (array)$get;  | 
                                                        |
| 81 | + $this->_post = (array)$post;  | 
                                                        |
| 82 | + $this->_cookie = (array)$cookie;  | 
                                                        |
| 83 | + $this->_params = array_merge($this->_get, $this->_post);  | 
                                                        |
| 84 | + // AJAX ???  | 
                                                        |
| 85 | +		$this->ajax = defined('DOING_AJAX') ? true : false; | 
                                                        |
| 86 | +		$this->front_ajax = $this->is_set('ee_front_ajax') && (int)$this->get('ee_front_ajax') === 1; | 
                                                        |
| 87 | + // grab user IP  | 
                                                        |
| 88 | + $this->_ip_address = $this->_visitor_ip();  | 
                                                        |
| 89 | + }  | 
                                                        |
| 90 | +  | 
                                                        |
| 91 | +  | 
                                                        |
| 92 | +  | 
                                                        |
| 93 | + /**  | 
                                                        |
| 94 | + * @return array  | 
                                                        |
| 95 | + */  | 
                                                        |
| 96 | + public function get_params()  | 
                                                        |
| 97 | +	{ | 
                                                        |
| 98 | + return $this->_get;  | 
                                                        |
| 99 | + }  | 
                                                        |
| 100 | +  | 
                                                        |
| 101 | +  | 
                                                        |
| 102 | +  | 
                                                        |
| 103 | + /**  | 
                                                        |
| 104 | + * @return array  | 
                                                        |
| 105 | + */  | 
                                                        |
| 106 | + public function post_params()  | 
                                                        |
| 107 | +	{ | 
                                                        |
| 108 | + return $this->_post;  | 
                                                        |
| 109 | + }  | 
                                                        |
| 110 | +  | 
                                                        |
| 111 | +  | 
                                                        |
| 112 | +  | 
                                                        |
| 113 | + /**  | 
                                                        |
| 114 | + * @return array  | 
                                                        |
| 115 | + */  | 
                                                        |
| 116 | + public function cookie_params()  | 
                                                        |
| 117 | +	{ | 
                                                        |
| 118 | + return $this->_cookie;  | 
                                                        |
| 119 | + }  | 
                                                        |
| 120 | +  | 
                                                        |
| 121 | +  | 
                                                        |
| 122 | +  | 
                                                        |
| 123 | + /**  | 
                                                        |
| 124 | + * returns contents of $_REQUEST  | 
                                                        |
| 125 | + *  | 
                                                        |
| 126 | + * @return array  | 
                                                        |
| 127 | + */  | 
                                                        |
| 128 | + public function params()  | 
                                                        |
| 129 | +	{ | 
                                                        |
| 130 | + return $this->_params;  | 
                                                        |
| 131 | + }  | 
                                                        |
| 132 | +  | 
                                                        |
| 133 | +  | 
                                                        |
| 134 | +  | 
                                                        |
| 135 | + /**  | 
                                                        |
| 136 | + * @param $key  | 
                                                        |
| 137 | + * @param $value  | 
                                                        |
| 138 | + * @param bool $override_ee  | 
                                                        |
| 139 | + * @return void  | 
                                                        |
| 140 | + */  | 
                                                        |
| 141 | + public function set($key, $value, $override_ee = false)  | 
                                                        |
| 142 | +	{ | 
                                                        |
| 143 | + // don't allow "ee" to be overwritten unless explicitly instructed to do so  | 
                                                        |
| 144 | + if (  | 
                                                        |
| 145 | + $key !== 'ee'  | 
                                                        |
| 146 | + || ($key === 'ee' && empty($this->_params['ee']))  | 
                                                        |
| 147 | + || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)  | 
                                                        |
| 148 | +		) { | 
                                                        |
| 149 | + $this->_params[$key] = $value;  | 
                                                        |
| 150 | + }  | 
                                                        |
| 151 | + }  | 
                                                        |
| 152 | +  | 
                                                        |
| 153 | +  | 
                                                        |
| 154 | +  | 
                                                        |
| 155 | + /**  | 
                                                        |
| 156 | + * @param $key  | 
                                                        |
| 157 | + * @param null $default  | 
                                                        |
| 158 | + * @return mixed  | 
                                                        |
| 159 | + */  | 
                                                        |
| 160 | + public function get($key, $default = null)  | 
                                                        |
| 161 | +	{ | 
                                                        |
| 162 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default;  | 
                                                        |
| 163 | + }  | 
                                                        |
| 164 | +  | 
                                                        |
| 165 | +  | 
                                                        |
| 166 | +  | 
                                                        |
| 167 | + /**  | 
                                                        |
| 168 | + * @param $key  | 
                                                        |
| 169 | + * @return boolean  | 
                                                        |
| 170 | + */  | 
                                                        |
| 171 | + public function is_set($key)  | 
                                                        |
| 172 | +	{ | 
                                                        |
| 173 | + return isset($this->_params[$key]) ? true : false;  | 
                                                        |
| 174 | + }  | 
                                                        |
| 175 | +  | 
                                                        |
| 176 | +  | 
                                                        |
| 177 | +  | 
                                                        |
| 178 | + /**  | 
                                                        |
| 179 | + * remove param  | 
                                                        |
| 180 | + * @param $key  | 
                                                        |
| 181 | + * @param bool $unset_from_global_too  | 
                                                        |
| 182 | + */  | 
                                                        |
| 183 | + public function un_set($key, $unset_from_global_too = false)  | 
                                                        |
| 184 | +	{ | 
                                                        |
| 185 | + unset($this->_params[$key]);  | 
                                                        |
| 186 | +		if ($unset_from_global_too) { | 
                                                        |
| 187 | + unset($_REQUEST[$key]);  | 
                                                        |
| 188 | + }  | 
                                                        |
| 189 | + }  | 
                                                        |
| 190 | +  | 
                                                        |
| 191 | +  | 
                                                        |
| 192 | +  | 
                                                        |
| 193 | + /**  | 
                                                        |
| 194 | + * @return string  | 
                                                        |
| 195 | + */  | 
                                                        |
| 196 | + public function ip_address()  | 
                                                        |
| 197 | +	{ | 
                                                        |
| 198 | + return $this->_ip_address;  | 
                                                        |
| 199 | + }  | 
                                                        |
| 200 | +  | 
                                                        |
| 201 | +  | 
                                                        |
| 202 | +  | 
                                                        |
| 203 | + /**  | 
                                                        |
| 204 | + * _visitor_ip  | 
                                                        |
| 205 | + * attempt to get IP address of current visitor from server  | 
                                                        |
| 206 | + * plz see: http://stackoverflow.com/a/2031935/1475279  | 
                                                        |
| 207 | + *  | 
                                                        |
| 208 | + * @access public  | 
                                                        |
| 209 | + * @return string  | 
                                                        |
| 210 | + */  | 
                                                        |
| 211 | + private function _visitor_ip()  | 
                                                        |
| 212 | +	{ | 
                                                        |
| 213 | + $visitor_ip = '0.0.0.0';  | 
                                                        |
| 214 | + $server_keys = array(  | 
                                                        |
| 215 | + 'HTTP_CLIENT_IP',  | 
                                                        |
| 216 | + 'HTTP_X_FORWARDED_FOR',  | 
                                                        |
| 217 | + 'HTTP_X_FORWARDED',  | 
                                                        |
| 218 | + 'HTTP_X_CLUSTER_CLIENT_IP',  | 
                                                        |
| 219 | + 'HTTP_FORWARDED_FOR',  | 
                                                        |
| 220 | + 'HTTP_FORWARDED',  | 
                                                        |
| 221 | + 'REMOTE_ADDR',  | 
                                                        |
| 222 | + );  | 
                                                        |
| 223 | +		foreach ($server_keys as $key) { | 
                                                        |
| 224 | +			if (isset($_SERVER[$key])) { | 
                                                        |
| 225 | +				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { | 
                                                        |
| 226 | +					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { | 
                                                        |
| 227 | + $visitor_ip = $ip;  | 
                                                        |
| 228 | + }  | 
                                                        |
| 229 | + }  | 
                                                        |
| 230 | + }  | 
                                                        |
| 231 | + }  | 
                                                        |
| 232 | + return $visitor_ip;  | 
                                                        |
| 233 | + }  | 
                                                        |
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | |
@@ -1,5 +1,5 @@ discard block  | 
                                                    ||
| 1 | 1 |  <?php if ( ! defined('ABSPATH')) { | 
                                                        
| 2 | -    exit('No direct script access allowed'); | 
                                                        |
| 2 | +	exit('No direct script access allowed'); | 
                                                        |
| 3 | 3 | }  | 
                                                        
| 4 | 4 | /*  | 
                                                        
| 5 | 5 | Plugin Name: Event Espresso  | 
                                                        
@@ -40,243 +40,243 @@ discard block  | 
                                                    ||
| 40 | 40 | * @since 4.0  | 
                                                        
| 41 | 41 | */  | 
                                                        
| 42 | 42 |  if (function_exists('espresso_version')) { | 
                                                        
| 43 | - /**  | 
                                                        |
| 44 | - * espresso_duplicate_plugin_error  | 
                                                        |
| 45 | - * displays if more than one version of EE is activated at the same time  | 
                                                        |
| 46 | - */  | 
                                                        |
| 47 | - function espresso_duplicate_plugin_error()  | 
                                                        |
| 48 | -    { | 
                                                        |
| 49 | - ?>  | 
                                                        |
| 43 | + /**  | 
                                                        |
| 44 | + * espresso_duplicate_plugin_error  | 
                                                        |
| 45 | + * displays if more than one version of EE is activated at the same time  | 
                                                        |
| 46 | + */  | 
                                                        |
| 47 | + function espresso_duplicate_plugin_error()  | 
                                                        |
| 48 | +	{ | 
                                                        |
| 49 | + ?>  | 
                                                        |
| 50 | 50 | <div class="error">  | 
                                                        
| 51 | 51 | <p>  | 
                                                        
| 52 | 52 | <?php echo esc_html__(  | 
                                                        
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',  | 
                                                        |
| 54 | - 'event_espresso'  | 
                                                        |
| 55 | - ); ?>  | 
                                                        |
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',  | 
                                                        |
| 54 | + 'event_espresso'  | 
                                                        |
| 55 | + ); ?>  | 
                                                        |
| 56 | 56 | </p>  | 
                                                        
| 57 | 57 | </div>  | 
                                                        
| 58 | 58 | <?php  | 
                                                        
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__));  | 
                                                        |
| 60 | - }  | 
                                                        |
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__));  | 
                                                        |
| 60 | + }  | 
                                                        |
| 61 | 61 | |
| 62 | -    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); | 
                                                        |
| 62 | +	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); | 
                                                        |
| 63 | 63 |  } else { | 
                                                        
| 64 | -    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); | 
                                                        |
| 65 | -    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { | 
                                                        |
| 66 | - /**  | 
                                                        |
| 67 | - * espresso_minimum_php_version_error  | 
                                                        |
| 68 | - *  | 
                                                        |
| 69 | - * @return void  | 
                                                        |
| 70 | - */  | 
                                                        |
| 71 | - function espresso_minimum_php_version_error()  | 
                                                        |
| 72 | -        { | 
                                                        |
| 73 | - ?>  | 
                                                        |
| 64 | +	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); | 
                                                        |
| 65 | +	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { | 
                                                        |
| 66 | + /**  | 
                                                        |
| 67 | + * espresso_minimum_php_version_error  | 
                                                        |
| 68 | + *  | 
                                                        |
| 69 | + * @return void  | 
                                                        |
| 70 | + */  | 
                                                        |
| 71 | + function espresso_minimum_php_version_error()  | 
                                                        |
| 72 | +		{ | 
                                                        |
| 73 | + ?>  | 
                                                        |
| 74 | 74 | <div class="error">  | 
                                                        
| 75 | 75 | <p>  | 
                                                        
| 76 | 76 | <?php  | 
                                                        
| 77 | - printf(  | 
                                                        |
| 78 | - esc_html__(  | 
                                                        |
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',  | 
                                                        |
| 80 | - 'event_espresso'  | 
                                                        |
| 81 | - ),  | 
                                                        |
| 82 | - EE_MIN_PHP_VER_REQUIRED,  | 
                                                        |
| 83 | - PHP_VERSION,  | 
                                                        |
| 84 | - '<br/>',  | 
                                                        |
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'  | 
                                                        |
| 86 | - );  | 
                                                        |
| 87 | - ?>  | 
                                                        |
| 77 | + printf(  | 
                                                        |
| 78 | + esc_html__(  | 
                                                        |
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',  | 
                                                        |
| 80 | + 'event_espresso'  | 
                                                        |
| 81 | + ),  | 
                                                        |
| 82 | + EE_MIN_PHP_VER_REQUIRED,  | 
                                                        |
| 83 | + PHP_VERSION,  | 
                                                        |
| 84 | + '<br/>',  | 
                                                        |
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'  | 
                                                        |
| 86 | + );  | 
                                                        |
| 87 | + ?>  | 
                                                        |
| 88 | 88 | </p>  | 
                                                        
| 89 | 89 | </div>  | 
                                                        
| 90 | 90 | <?php  | 
                                                        
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__));  | 
                                                        |
| 92 | - }  | 
                                                        |
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__));  | 
                                                        |
| 92 | + }  | 
                                                        |
| 93 | 93 | |
| 94 | -        add_action('admin_notices', 'espresso_minimum_php_version_error', 1); | 
                                                        |
| 95 | -    } else { | 
                                                        |
| 96 | - /**  | 
                                                        |
| 97 | - * espresso_version  | 
                                                        |
| 98 | - * Returns the plugin version  | 
                                                        |
| 99 | - *  | 
                                                        |
| 100 | - * @return string  | 
                                                        |
| 101 | - */  | 
                                                        |
| 102 | - function espresso_version()  | 
                                                        |
| 103 | -        { | 
                                                        |
| 104 | -            return apply_filters('FHEE__espresso__espresso_version', '4.9.46.rc.023'); | 
                                                        |
| 105 | - }  | 
                                                        |
| 94 | +		add_action('admin_notices', 'espresso_minimum_php_version_error', 1); | 
                                                        |
| 95 | +	} else { | 
                                                        |
| 96 | + /**  | 
                                                        |
| 97 | + * espresso_version  | 
                                                        |
| 98 | + * Returns the plugin version  | 
                                                        |
| 99 | + *  | 
                                                        |
| 100 | + * @return string  | 
                                                        |
| 101 | + */  | 
                                                        |
| 102 | + function espresso_version()  | 
                                                        |
| 103 | +		{ | 
                                                        |
| 104 | +			return apply_filters('FHEE__espresso__espresso_version', '4.9.46.rc.023'); | 
                                                        |
| 105 | + }  | 
                                                        |
| 106 | 106 | |
| 107 | - // define versions  | 
                                                        |
| 108 | -        define('EVENT_ESPRESSO_VERSION', espresso_version()); | 
                                                        |
| 109 | -        define('EE_MIN_WP_VER_REQUIRED', '4.1'); | 
                                                        |
| 110 | -        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); | 
                                                        |
| 111 | -        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); | 
                                                        |
| 112 | -        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); | 
                                                        |
| 113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows  | 
                                                        |
| 114 | -        if ( ! defined('DS')) { | 
                                                        |
| 115 | -            define('DS', '/'); | 
                                                        |
| 116 | - }  | 
                                                        |
| 117 | -        if ( ! defined('PS')) { | 
                                                        |
| 118 | -            define('PS', PATH_SEPARATOR); | 
                                                        |
| 119 | - }  | 
                                                        |
| 120 | -        if ( ! defined('SP')) { | 
                                                        |
| 121 | -            define('SP', ' '); | 
                                                        |
| 122 | - }  | 
                                                        |
| 123 | -        if ( ! defined('EENL')) { | 
                                                        |
| 124 | -            define('EENL', "\n"); | 
                                                        |
| 125 | - }  | 
                                                        |
| 126 | -        define('EE_SUPPORT_EMAIL', '[email protected]'); | 
                                                        |
| 127 | - // define the plugin directory and URL  | 
                                                        |
| 128 | -        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); | 
                                                        |
| 129 | -        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); | 
                                                        |
| 130 | -        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); | 
                                                        |
| 131 | - // main root folder paths  | 
                                                        |
| 132 | -        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); | 
                                                        |
| 133 | -        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); | 
                                                        |
| 134 | -        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); | 
                                                        |
| 135 | -        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); | 
                                                        |
| 136 | -        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); | 
                                                        |
| 137 | -        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); | 
                                                        |
| 138 | -        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); | 
                                                        |
| 139 | -        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); | 
                                                        |
| 140 | - // core system paths  | 
                                                        |
| 141 | -        define('EE_ADMIN', EE_CORE . 'admin' . DS); | 
                                                        |
| 142 | -        define('EE_CPTS', EE_CORE . 'CPTs' . DS); | 
                                                        |
| 143 | -        define('EE_CLASSES', EE_CORE . 'db_classes' . DS); | 
                                                        |
| 144 | -        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); | 
                                                        |
| 145 | -        define('EE_BUSINESS', EE_CORE . 'business' . DS); | 
                                                        |
| 146 | -        define('EE_MODELS', EE_CORE . 'db_models' . DS); | 
                                                        |
| 147 | -        define('EE_HELPERS', EE_CORE . 'helpers' . DS); | 
                                                        |
| 148 | -        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); | 
                                                        |
| 149 | -        define('EE_TEMPLATES', EE_CORE . 'templates' . DS); | 
                                                        |
| 150 | -        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); | 
                                                        |
| 151 | -        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); | 
                                                        |
| 152 | -        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); | 
                                                        |
| 153 | - // gateways  | 
                                                        |
| 154 | -        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); | 
                                                        |
| 155 | -        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); | 
                                                        |
| 156 | - // asset URL paths  | 
                                                        |
| 157 | -        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); | 
                                                        |
| 158 | -        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); | 
                                                        |
| 159 | -        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); | 
                                                        |
| 160 | -        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); | 
                                                        |
| 161 | -        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); | 
                                                        |
| 162 | -        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); | 
                                                        |
| 163 | - // define upload paths  | 
                                                        |
| 164 | - $uploads = wp_upload_dir();  | 
                                                        |
| 165 | - // define the uploads directory and URL  | 
                                                        |
| 166 | -        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); | 
                                                        |
| 167 | -        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); | 
                                                        |
| 168 | - // define the templates directory and URL  | 
                                                        |
| 169 | -        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); | 
                                                        |
| 170 | -        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); | 
                                                        |
| 171 | - // define the gateway directory and URL  | 
                                                        |
| 172 | -        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); | 
                                                        |
| 173 | -        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); | 
                                                        |
| 174 | - // languages folder/path  | 
                                                        |
| 175 | -        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); | 
                                                        |
| 176 | -        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); | 
                                                        |
| 177 | - //check for dompdf fonts in uploads  | 
                                                        |
| 178 | -        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { | 
                                                        |
| 179 | -            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); | 
                                                        |
| 180 | - }  | 
                                                        |
| 181 | - //ajax constants  | 
                                                        |
| 182 | - define(  | 
                                                        |
| 183 | - 'EE_FRONT_AJAX',  | 
                                                        |
| 184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false  | 
                                                        |
| 185 | - );  | 
                                                        |
| 186 | - define(  | 
                                                        |
| 187 | - 'EE_ADMIN_AJAX',  | 
                                                        |
| 188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false  | 
                                                        |
| 189 | - );  | 
                                                        |
| 190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB  | 
                                                        |
| 191 | - //you're better to use this than its straight value (currently -1) in case you ever  | 
                                                        |
| 192 | - //want to change its default value! or find when -1 means infinity  | 
                                                        |
| 193 | -        define('EE_INF_IN_DB', -1); | 
                                                        |
| 194 | -        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); | 
                                                        |
| 195 | -        define('EE_DEBUG', false); | 
                                                        |
| 196 | - // for older WP versions  | 
                                                        |
| 197 | -        if ( ! defined('MONTH_IN_SECONDS')) { | 
                                                        |
| 198 | -            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); | 
                                                        |
| 199 | - }  | 
                                                        |
| 200 | - /**  | 
                                                        |
| 201 | - * espresso_plugin_activation  | 
                                                        |
| 202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page  | 
                                                        |
| 203 | - */  | 
                                                        |
| 204 | - function espresso_plugin_activation()  | 
                                                        |
| 205 | -        { | 
                                                        |
| 206 | -            update_option('ee_espresso_activation', true); | 
                                                        |
| 207 | - }  | 
                                                        |
| 107 | + // define versions  | 
                                                        |
| 108 | +		define('EVENT_ESPRESSO_VERSION', espresso_version()); | 
                                                        |
| 109 | +		define('EE_MIN_WP_VER_REQUIRED', '4.1'); | 
                                                        |
| 110 | +		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); | 
                                                        |
| 111 | +		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); | 
                                                        |
| 112 | +		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); | 
                                                        |
| 113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows  | 
                                                        |
| 114 | +		if ( ! defined('DS')) { | 
                                                        |
| 115 | +			define('DS', '/'); | 
                                                        |
| 116 | + }  | 
                                                        |
| 117 | +		if ( ! defined('PS')) { | 
                                                        |
| 118 | +			define('PS', PATH_SEPARATOR); | 
                                                        |
| 119 | + }  | 
                                                        |
| 120 | +		if ( ! defined('SP')) { | 
                                                        |
| 121 | +			define('SP', ' '); | 
                                                        |
| 122 | + }  | 
                                                        |
| 123 | +		if ( ! defined('EENL')) { | 
                                                        |
| 124 | +			define('EENL', "\n"); | 
                                                        |
| 125 | + }  | 
                                                        |
| 126 | +		define('EE_SUPPORT_EMAIL', '[email protected]'); | 
                                                        |
| 127 | + // define the plugin directory and URL  | 
                                                        |
| 128 | +		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); | 
                                                        |
| 129 | +		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); | 
                                                        |
| 130 | +		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); | 
                                                        |
| 131 | + // main root folder paths  | 
                                                        |
| 132 | +		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); | 
                                                        |
| 133 | +		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); | 
                                                        |
| 134 | +		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); | 
                                                        |
| 135 | +		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); | 
                                                        |
| 136 | +		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); | 
                                                        |
| 137 | +		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); | 
                                                        |
| 138 | +		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); | 
                                                        |
| 139 | +		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); | 
                                                        |
| 140 | + // core system paths  | 
                                                        |
| 141 | +		define('EE_ADMIN', EE_CORE . 'admin' . DS); | 
                                                        |
| 142 | +		define('EE_CPTS', EE_CORE . 'CPTs' . DS); | 
                                                        |
| 143 | +		define('EE_CLASSES', EE_CORE . 'db_classes' . DS); | 
                                                        |
| 144 | +		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); | 
                                                        |
| 145 | +		define('EE_BUSINESS', EE_CORE . 'business' . DS); | 
                                                        |
| 146 | +		define('EE_MODELS', EE_CORE . 'db_models' . DS); | 
                                                        |
| 147 | +		define('EE_HELPERS', EE_CORE . 'helpers' . DS); | 
                                                        |
| 148 | +		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); | 
                                                        |
| 149 | +		define('EE_TEMPLATES', EE_CORE . 'templates' . DS); | 
                                                        |
| 150 | +		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); | 
                                                        |
| 151 | +		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); | 
                                                        |
| 152 | +		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); | 
                                                        |
| 153 | + // gateways  | 
                                                        |
| 154 | +		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); | 
                                                        |
| 155 | +		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); | 
                                                        |
| 156 | + // asset URL paths  | 
                                                        |
| 157 | +		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); | 
                                                        |
| 158 | +		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); | 
                                                        |
| 159 | +		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); | 
                                                        |
| 160 | +		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); | 
                                                        |
| 161 | +		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); | 
                                                        |
| 162 | +		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); | 
                                                        |
| 163 | + // define upload paths  | 
                                                        |
| 164 | + $uploads = wp_upload_dir();  | 
                                                        |
| 165 | + // define the uploads directory and URL  | 
                                                        |
| 166 | +		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); | 
                                                        |
| 167 | +		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); | 
                                                        |
| 168 | + // define the templates directory and URL  | 
                                                        |
| 169 | +		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); | 
                                                        |
| 170 | +		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); | 
                                                        |
| 171 | + // define the gateway directory and URL  | 
                                                        |
| 172 | +		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); | 
                                                        |
| 173 | +		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); | 
                                                        |
| 174 | + // languages folder/path  | 
                                                        |
| 175 | +		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); | 
                                                        |
| 176 | +		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); | 
                                                        |
| 177 | + //check for dompdf fonts in uploads  | 
                                                        |
| 178 | +		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { | 
                                                        |
| 179 | +			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); | 
                                                        |
| 180 | + }  | 
                                                        |
| 181 | + //ajax constants  | 
                                                        |
| 182 | + define(  | 
                                                        |
| 183 | + 'EE_FRONT_AJAX',  | 
                                                        |
| 184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false  | 
                                                        |
| 185 | + );  | 
                                                        |
| 186 | + define(  | 
                                                        |
| 187 | + 'EE_ADMIN_AJAX',  | 
                                                        |
| 188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false  | 
                                                        |
| 189 | + );  | 
                                                        |
| 190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB  | 
                                                        |
| 191 | + //you're better to use this than its straight value (currently -1) in case you ever  | 
                                                        |
| 192 | + //want to change its default value! or find when -1 means infinity  | 
                                                        |
| 193 | +		define('EE_INF_IN_DB', -1); | 
                                                        |
| 194 | +		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); | 
                                                        |
| 195 | +		define('EE_DEBUG', false); | 
                                                        |
| 196 | + // for older WP versions  | 
                                                        |
| 197 | +		if ( ! defined('MONTH_IN_SECONDS')) { | 
                                                        |
| 198 | +			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); | 
                                                        |
| 199 | + }  | 
                                                        |
| 200 | + /**  | 
                                                        |
| 201 | + * espresso_plugin_activation  | 
                                                        |
| 202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page  | 
                                                        |
| 203 | + */  | 
                                                        |
| 204 | + function espresso_plugin_activation()  | 
                                                        |
| 205 | +		{ | 
                                                        |
| 206 | +			update_option('ee_espresso_activation', true); | 
                                                        |
| 207 | + }  | 
                                                        |
| 208 | 208 | |
| 209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');  | 
                                                        |
| 210 | - /**  | 
                                                        |
| 211 | - * espresso_load_error_handling  | 
                                                        |
| 212 | - * this function loads EE's class for handling exceptions and errors  | 
                                                        |
| 213 | - */  | 
                                                        |
| 214 | - function espresso_load_error_handling()  | 
                                                        |
| 215 | -        { | 
                                                        |
| 216 | - // load debugging tools  | 
                                                        |
| 217 | -            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { | 
                                                        |
| 218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');  | 
                                                        |
| 219 | - EEH_Debug_Tools::instance();  | 
                                                        |
| 220 | - }  | 
                                                        |
| 221 | - // load error handling  | 
                                                        |
| 222 | -            if (is_readable(EE_CORE . 'EE_Error.core.php')) { | 
                                                        |
| 223 | - require_once(EE_CORE . 'EE_Error.core.php');  | 
                                                        |
| 224 | -            } else { | 
                                                        |
| 225 | -                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); | 
                                                        |
| 226 | - }  | 
                                                        |
| 227 | - }  | 
                                                        |
| 209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');  | 
                                                        |
| 210 | + /**  | 
                                                        |
| 211 | + * espresso_load_error_handling  | 
                                                        |
| 212 | + * this function loads EE's class for handling exceptions and errors  | 
                                                        |
| 213 | + */  | 
                                                        |
| 214 | + function espresso_load_error_handling()  | 
                                                        |
| 215 | +		{ | 
                                                        |
| 216 | + // load debugging tools  | 
                                                        |
| 217 | +			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { | 
                                                        |
| 218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');  | 
                                                        |
| 219 | + EEH_Debug_Tools::instance();  | 
                                                        |
| 220 | + }  | 
                                                        |
| 221 | + // load error handling  | 
                                                        |
| 222 | +			if (is_readable(EE_CORE . 'EE_Error.core.php')) { | 
                                                        |
| 223 | + require_once(EE_CORE . 'EE_Error.core.php');  | 
                                                        |
| 224 | +			} else { | 
                                                        |
| 225 | +				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); | 
                                                        |
| 226 | + }  | 
                                                        |
| 227 | + }  | 
                                                        |
| 228 | 228 | |
| 229 | - /**  | 
                                                        |
| 230 | - * espresso_load_required  | 
                                                        |
| 231 | - * given a class name and path, this function will load that file or throw an exception  | 
                                                        |
| 232 | - *  | 
                                                        |
| 233 | - * @param string $classname  | 
                                                        |
| 234 | - * @param string $full_path_to_file  | 
                                                        |
| 235 | - * @throws EE_Error  | 
                                                        |
| 236 | - */  | 
                                                        |
| 237 | - function espresso_load_required($classname, $full_path_to_file)  | 
                                                        |
| 238 | -        { | 
                                                        |
| 239 | - static $error_handling_loaded = false;  | 
                                                        |
| 240 | -            if ( ! $error_handling_loaded) { | 
                                                        |
| 241 | - espresso_load_error_handling();  | 
                                                        |
| 242 | - $error_handling_loaded = true;  | 
                                                        |
| 243 | - }  | 
                                                        |
| 244 | -            if (is_readable($full_path_to_file)) { | 
                                                        |
| 245 | - require_once($full_path_to_file);  | 
                                                        |
| 246 | -            } else { | 
                                                        |
| 247 | - throw new EE_Error (  | 
                                                        |
| 248 | - sprintf(  | 
                                                        |
| 249 | - esc_html__(  | 
                                                        |
| 250 | - 'The %s class file could not be located or is not readable due to file permissions.',  | 
                                                        |
| 251 | - 'event_espresso'  | 
                                                        |
| 252 | - ),  | 
                                                        |
| 253 | - $classname  | 
                                                        |
| 254 | - )  | 
                                                        |
| 255 | - );  | 
                                                        |
| 256 | - }  | 
                                                        |
| 257 | - }  | 
                                                        |
| 229 | + /**  | 
                                                        |
| 230 | + * espresso_load_required  | 
                                                        |
| 231 | + * given a class name and path, this function will load that file or throw an exception  | 
                                                        |
| 232 | + *  | 
                                                        |
| 233 | + * @param string $classname  | 
                                                        |
| 234 | + * @param string $full_path_to_file  | 
                                                        |
| 235 | + * @throws EE_Error  | 
                                                        |
| 236 | + */  | 
                                                        |
| 237 | + function espresso_load_required($classname, $full_path_to_file)  | 
                                                        |
| 238 | +		{ | 
                                                        |
| 239 | + static $error_handling_loaded = false;  | 
                                                        |
| 240 | +			if ( ! $error_handling_loaded) { | 
                                                        |
| 241 | + espresso_load_error_handling();  | 
                                                        |
| 242 | + $error_handling_loaded = true;  | 
                                                        |
| 243 | + }  | 
                                                        |
| 244 | +			if (is_readable($full_path_to_file)) { | 
                                                        |
| 245 | + require_once($full_path_to_file);  | 
                                                        |
| 246 | +			} else { | 
                                                        |
| 247 | + throw new EE_Error (  | 
                                                        |
| 248 | + sprintf(  | 
                                                        |
| 249 | + esc_html__(  | 
                                                        |
| 250 | + 'The %s class file could not be located or is not readable due to file permissions.',  | 
                                                        |
| 251 | + 'event_espresso'  | 
                                                        |
| 252 | + ),  | 
                                                        |
| 253 | + $classname  | 
                                                        |
| 254 | + )  | 
                                                        |
| 255 | + );  | 
                                                        |
| 256 | + }  | 
                                                        |
| 257 | + }  | 
                                                        |
| 258 | 258 | |
| 259 | -        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); | 
                                                        |
| 260 | -        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); | 
                                                        |
| 261 | -        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); | 
                                                        |
| 262 | - new EE_Bootstrap();  | 
                                                        |
| 263 | - }  | 
                                                        |
| 259 | +		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); | 
                                                        |
| 260 | +		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); | 
                                                        |
| 261 | +		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); | 
                                                        |
| 262 | + new EE_Bootstrap();  | 
                                                        |
| 263 | + }  | 
                                                        |
| 264 | 264 | }  | 
                                                        
| 265 | 265 |  if ( ! function_exists('espresso_deactivate_plugin')) { | 
                                                        
| 266 | - /**  | 
                                                        |
| 267 | - * deactivate_plugin  | 
                                                        |
| 268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ ));  | 
                                                        |
| 269 | - *  | 
                                                        |
| 270 | - * @access public  | 
                                                        |
| 271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file  | 
                                                        |
| 272 | - * @return void  | 
                                                        |
| 273 | - */  | 
                                                        |
| 274 | - function espresso_deactivate_plugin($plugin_basename = '')  | 
                                                        |
| 275 | -    { | 
                                                        |
| 276 | -        if ( ! function_exists('deactivate_plugins')) { | 
                                                        |
| 277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php');  | 
                                                        |
| 278 | - }  | 
                                                        |
| 279 | - unset($_GET['activate'], $_REQUEST['activate']);  | 
                                                        |
| 280 | - deactivate_plugins($plugin_basename);  | 
                                                        |
| 281 | - }  | 
                                                        |
| 266 | + /**  | 
                                                        |
| 267 | + * deactivate_plugin  | 
                                                        |
| 268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ ));  | 
                                                        |
| 269 | + *  | 
                                                        |
| 270 | + * @access public  | 
                                                        |
| 271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file  | 
                                                        |
| 272 | + * @return void  | 
                                                        |
| 273 | + */  | 
                                                        |
| 274 | + function espresso_deactivate_plugin($plugin_basename = '')  | 
                                                        |
| 275 | +	{ | 
                                                        |
| 276 | +		if ( ! function_exists('deactivate_plugins')) { | 
                                                        |
| 277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php');  | 
                                                        |
| 278 | + }  | 
                                                        |
| 279 | + unset($_GET['activate'], $_REQUEST['activate']);  | 
                                                        |
| 280 | + deactivate_plugins($plugin_basename);  | 
                                                        |
| 281 | + }  | 
                                                        |
| 282 | 282 | }  | 
                                                        
| 283 | 283 | \ No newline at end of file  | 
                                                        
@@ -15,2708 +15,2708 @@  | 
                                                    ||
| 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_args['upsell_notice'] = sprintf(  | 
                                                        |
| 1613 | - esc_html__(  | 
                                                        |
| 1614 | - '%sCreate multiple occurrences of this event; required tickets and more with %sEvent Espresso 4 Caffienated%s.%s',  | 
                                                        |
| 1615 | - 'event_espresso'  | 
                                                        |
| 1616 | - ),  | 
                                                        |
| 1617 | - '<div class="notice inline notice-info "><p>',  | 
                                                        |
| 1618 | - '<a href="#">',  | 
                                                        |
| 1619 | - '</a>',  | 
                                                        |
| 1620 | - '</p></div>'  | 
                                                        |
| 1621 | - );  | 
                                                        |
| 1622 | - $template_args = apply_filters(  | 
                                                        |
| 1623 | - 'FHEE__Events_Admin_Page__ticket_metabox__template_args__decaf',  | 
                                                        |
| 1624 | - $template_args  | 
                                                        |
| 1625 | - );  | 
                                                        |
| 1626 | - $template = apply_filters(  | 
                                                        |
| 1627 | - 'FHEE__Events_Admin_Page__ticket_metabox__template',  | 
                                                        |
| 1628 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'  | 
                                                        |
| 1629 | - );  | 
                                                        |
| 1630 | - EEH_Template::display_template($template, $template_args);  | 
                                                        |
| 1631 | - }  | 
                                                        |
| 1632 | -  | 
                                                        |
| 1633 | -  | 
                                                        |
| 1634 | -  | 
                                                        |
| 1635 | - /**  | 
                                                        |
| 1636 | - * Setup an individual ticket form for the decaf event editor page  | 
                                                        |
| 1637 | - *  | 
                                                        |
| 1638 | - * @access private  | 
                                                        |
| 1639 | - * @param EE_Ticket $ticket the ticket object  | 
                                                        |
| 1640 | - * @param boolean $skeleton whether we're generating a skeleton for js manipulation  | 
                                                        |
| 1641 | - * @param int $row  | 
                                                        |
| 1642 | - * @return string generated html for the ticket row.  | 
                                                        |
| 1643 | - */  | 
                                                        |
| 1644 | - private function _get_ticket_row($ticket, $skeleton = false, $row = 0)  | 
                                                        |
| 1645 | -    { | 
                                                        |
| 1646 | - $template_args = array(  | 
                                                        |
| 1647 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(),  | 
                                                        |
| 1648 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'  | 
                                                        |
| 1649 | - : '',  | 
                                                        |
| 1650 | - 'ticketrow' => $skeleton ? 'TICKETNUM' : $row,  | 
                                                        |
| 1651 | -            'TKT_ID'              => $ticket->get('TKT_ID'), | 
                                                        |
| 1652 | -            'TKT_name'            => $ticket->get('TKT_name'), | 
                                                        |
| 1653 | -            'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), | 
                                                        |
| 1654 | -            'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), | 
                                                        |
| 1655 | -            'TKT_is_default'      => $ticket->get('TKT_is_default'), | 
                                                        |
| 1656 | -            'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'), | 
                                                        |
| 1657 | - 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',  | 
                                                        |
| 1658 | -            'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'), | 
                                                        |
| 1659 | -            'trash_icon'          => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) | 
                                                        |
| 1660 | -                                     && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) | 
                                                        |
| 1661 | - ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',  | 
                                                        |
| 1662 | -            'disabled'            => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' | 
                                                        |
| 1663 | - : ' disabled=disabled',  | 
                                                        |
| 1664 | - );  | 
                                                        |
| 1665 | - $price = $ticket->ID() !== 0  | 
                                                        |
| 1666 | -            ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) | 
                                                        |
| 1667 | -            : EE_Registry::instance()->load_model('Price')->create_default_object(); | 
                                                        |
| 1668 | - $price_args = array(  | 
                                                        |
| 1669 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,  | 
                                                        |
| 1670 | -            'PRC_amount'            => $price->get('PRC_amount'), | 
                                                        |
| 1671 | -            'PRT_ID'                => $price->get('PRT_ID'), | 
                                                        |
| 1672 | -            'PRC_ID'                => $price->get('PRC_ID'), | 
                                                        |
| 1673 | -            'PRC_is_default'        => $price->get('PRC_is_default'), | 
                                                        |
| 1674 | - );  | 
                                                        |
| 1675 | - //make sure we have default start and end dates if skeleton  | 
                                                        |
| 1676 | - //handle rows that should NOT be empty  | 
                                                        |
| 1677 | -        if (empty($template_args['TKT_start_date'])) { | 
                                                        |
| 1678 | - //if empty then the start date will be now.  | 
                                                        |
| 1679 | -            $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); | 
                                                        |
| 1680 | - }  | 
                                                        |
| 1681 | -        if (empty($template_args['TKT_end_date'])) { | 
                                                        |
| 1682 | - //get the earliest datetime (if present);  | 
                                                        |
| 1683 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0  | 
                                                        |
| 1684 | - ? $this->_cpt_model_obj->get_first_related(  | 
                                                        |
| 1685 | - 'Datetime',  | 
                                                        |
| 1686 | -                    array('order_by' => array('DTT_EVT_start' => 'ASC')) | 
                                                        |
| 1687 | - )  | 
                                                        |
| 1688 | - : null;  | 
                                                        |
| 1689 | -            if ( ! empty($earliest_dtt)) { | 
                                                        |
| 1690 | -                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); | 
                                                        |
| 1691 | -            } else { | 
                                                        |
| 1692 | - $template_args['TKT_end_date'] = date(  | 
                                                        |
| 1693 | - 'Y-m-d h:i a',  | 
                                                        |
| 1694 | -                    mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) | 
                                                        |
| 1695 | - );  | 
                                                        |
| 1696 | - }  | 
                                                        |
| 1697 | - }  | 
                                                        |
| 1698 | - $template_args = array_merge($template_args, $price_args);  | 
                                                        |
| 1699 | - $template = apply_filters(  | 
                                                        |
| 1700 | - 'FHEE__Events_Admin_Page__get_ticket_row__template',  | 
                                                        |
| 1701 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',  | 
                                                        |
| 1702 | - $ticket  | 
                                                        |
| 1703 | - );  | 
                                                        |
| 1704 | - return EEH_Template::display_template($template, $template_args, true);  | 
                                                        |
| 1705 | - }  | 
                                                        |
| 1706 | -  | 
                                                        |
| 1707 | -  | 
                                                        |
| 1708 | - /**  | 
                                                        |
| 1709 | - * @throws DomainException  | 
                                                        |
| 1710 | - */  | 
                                                        |
| 1711 | - public function registration_options_meta_box()  | 
                                                        |
| 1712 | -    { | 
                                                        |
| 1713 | - $yes_no_values = array(  | 
                                                        |
| 1714 | -            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), | 
                                                        |
| 1715 | -            array('id' => false, 'text' => esc_html__('No', 'event_espresso')), | 
                                                        |
| 1716 | - );  | 
                                                        |
| 1717 | - $default_reg_status_values = EEM_Registration::reg_status_array(  | 
                                                        |
| 1718 | - array(  | 
                                                        |
| 1719 | - EEM_Registration::status_id_cancelled,  | 
                                                        |
| 1720 | - EEM_Registration::status_id_declined,  | 
                                                        |
| 1721 | - EEM_Registration::status_id_incomplete,  | 
                                                        |
| 1722 | - ),  | 
                                                        |
| 1723 | - true  | 
                                                        |
| 1724 | - );  | 
                                                        |
| 1725 | -        //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); | 
                                                        |
| 1726 | - $template_args['_event'] = $this->_cpt_model_obj;  | 
                                                        |
| 1727 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);  | 
                                                        |
| 1728 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();  | 
                                                        |
| 1729 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1730 | - 'default_reg_status',  | 
                                                        |
| 1731 | - $default_reg_status_values,  | 
                                                        |
| 1732 | - $this->_cpt_model_obj->default_registration_status()  | 
                                                        |
| 1733 | - );  | 
                                                        |
| 1734 | - $template_args['display_description'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1735 | - 'display_desc',  | 
                                                        |
| 1736 | - $yes_no_values,  | 
                                                        |
| 1737 | - $this->_cpt_model_obj->display_description()  | 
                                                        |
| 1738 | - );  | 
                                                        |
| 1739 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1740 | - 'display_ticket_selector',  | 
                                                        |
| 1741 | - $yes_no_values,  | 
                                                        |
| 1742 | - $this->_cpt_model_obj->display_ticket_selector(),  | 
                                                        |
| 1743 | - '',  | 
                                                        |
| 1744 | - '',  | 
                                                        |
| 1745 | - false  | 
                                                        |
| 1746 | - );  | 
                                                        |
| 1747 | - $template_args['additional_registration_options'] = apply_filters(  | 
                                                        |
| 1748 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',  | 
                                                        |
| 1749 | - '',  | 
                                                        |
| 1750 | - $template_args,  | 
                                                        |
| 1751 | - $yes_no_values,  | 
                                                        |
| 1752 | - $default_reg_status_values  | 
                                                        |
| 1753 | - );  | 
                                                        |
| 1754 | - EEH_Template::display_template(  | 
                                                        |
| 1755 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',  | 
                                                        |
| 1756 | - $template_args  | 
                                                        |
| 1757 | - );  | 
                                                        |
| 1758 | - }  | 
                                                        |
| 1759 | -  | 
                                                        |
| 1760 | -  | 
                                                        |
| 1761 | -  | 
                                                        |
| 1762 | - /**  | 
                                                        |
| 1763 | - * _get_events()  | 
                                                        |
| 1764 | - * This method simply returns all the events (for the given _view and paging)  | 
                                                        |
| 1765 | - *  | 
                                                        |
| 1766 | - * @access public  | 
                                                        |
| 1767 | - * @param int $per_page count of items per page (20 default);  | 
                                                        |
| 1768 | - * @param int $current_page what is the current page being viewed.  | 
                                                        |
| 1769 | - * @param bool $count if TRUE then we just return a count of ALL events matching the given _view.  | 
                                                        |
| 1770 | - * If FALSE then we return an array of event objects  | 
                                                        |
| 1771 | - * that match the given _view and paging parameters.  | 
                                                        |
| 1772 | - * @return array an array of event objects.  | 
                                                        |
| 1773 | - */  | 
                                                        |
| 1774 | - public function get_events($per_page = 10, $current_page = 1, $count = false)  | 
                                                        |
| 1775 | -    { | 
                                                        |
| 1776 | - $EEME = $this->_event_model();  | 
                                                        |
| 1777 | - $offset = ($current_page - 1) * $per_page;  | 
                                                        |
| 1778 | - $limit = $count ? null : $offset . ',' . $per_page;  | 
                                                        |
| 1779 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';  | 
                                                        |
| 1780 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";  | 
                                                        |
| 1781 | -        if (isset($this->_req_data['month_range'])) { | 
                                                        |
| 1782 | -            $pieces = explode(' ', $this->_req_data['month_range'], 3); | 
                                                        |
| 1783 | - //simulate the FIRST day of the month, that fixes issues for months like February  | 
                                                        |
| 1784 | - //where PHP doesn't know what to assume for date.  | 
                                                        |
| 1785 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10437  | 
                                                        |
| 1786 | -            $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; | 
                                                        |
| 1787 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : '';  | 
                                                        |
| 1788 | - }  | 
                                                        |
| 1789 | - $where = array();  | 
                                                        |
| 1790 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;  | 
                                                        |
| 1791 | - //determine what post_status our condition will have for the query.  | 
                                                        |
| 1792 | -        switch ($status) { | 
                                                        |
| 1793 | - case 'month' :  | 
                                                        |
| 1794 | - case 'today' :  | 
                                                        |
| 1795 | - case null :  | 
                                                        |
| 1796 | - case 'all' :  | 
                                                        |
| 1797 | - break;  | 
                                                        |
| 1798 | - case 'draft' :  | 
                                                        |
| 1799 | -                $where['status'] = array('IN', array('draft', 'auto-draft')); | 
                                                        |
| 1800 | - break;  | 
                                                        |
| 1801 | - default :  | 
                                                        |
| 1802 | - $where['status'] = $status;  | 
                                                        |
| 1803 | - }  | 
                                                        |
| 1804 | - //categories?  | 
                                                        |
| 1805 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0  | 
                                                        |
| 1806 | - ? $this->_req_data['EVT_CAT'] : null;  | 
                                                        |
| 1807 | -        if ( ! empty ($category)) { | 
                                                        |
| 1808 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';  | 
                                                        |
| 1809 | - $where['Term_Taxonomy.term_id'] = $category;  | 
                                                        |
| 1810 | - }  | 
                                                        |
| 1811 | - //date where conditions  | 
                                                        |
| 1812 | -        $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); | 
                                                        |
| 1813 | -        if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { | 
                                                        |
| 1814 | - $DateTime = new DateTime(  | 
                                                        |
| 1815 | - $year_r . '-' . $month_r . '-01 00:00:00',  | 
                                                        |
| 1816 | - new DateTimeZone(EEM_Datetime::instance()->get_timezone())  | 
                                                        |
| 1817 | - );  | 
                                                        |
| 1818 | -            $start = $DateTime->format(implode(' ', $start_formats)); | 
                                                        |
| 1819 | - $end = $DateTime->setDate($year_r, $month_r, $DateTime  | 
                                                        |
| 1820 | -                ->format('t'))->setTime(23, 59, 59) | 
                                                        |
| 1821 | -                            ->format(implode(' ', $start_formats)); | 
                                                        |
| 1822 | -            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1823 | -        } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { | 
                                                        |
| 1824 | -            $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); | 
                                                        |
| 1825 | -            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); | 
                                                        |
| 1826 | -            $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); | 
                                                        |
| 1827 | -            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1828 | -        } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { | 
                                                        |
| 1829 | -            $now = date('Y-m-01'); | 
                                                        |
| 1830 | - $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));  | 
                                                        |
| 1831 | -            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); | 
                                                        |
| 1832 | -            $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) | 
                                                        |
| 1833 | - ->setTime(23, 59, 59)  | 
                                                        |
| 1834 | -                            ->format(implode(' ', $start_formats)); | 
                                                        |
| 1835 | -            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1836 | - }  | 
                                                        |
| 1837 | -        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { | 
                                                        |
| 1838 | - $where['EVT_wp_user'] = get_current_user_id();  | 
                                                        |
| 1839 | -        } else { | 
                                                        |
| 1840 | -            if ( ! isset($where['status'])) { | 
                                                        |
| 1841 | -                if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { | 
                                                        |
| 1842 | - $where['OR'] = array(  | 
                                                        |
| 1843 | -                        'status*restrict_private' => array('!=', 'private'), | 
                                                        |
| 1844 | - 'AND' => array(  | 
                                                        |
| 1845 | -                            'status*inclusive' => array('=', 'private'), | 
                                                        |
| 1846 | - 'EVT_wp_user' => get_current_user_id(),  | 
                                                        |
| 1847 | - ),  | 
                                                        |
| 1848 | - );  | 
                                                        |
| 1849 | - }  | 
                                                        |
| 1850 | - }  | 
                                                        |
| 1851 | - }  | 
                                                        |
| 1852 | -        if (isset($this->_req_data['EVT_wp_user'])) { | 
                                                        |
| 1853 | - if ($this->_req_data['EVT_wp_user'] != get_current_user_id()  | 
                                                        |
| 1854 | -                && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') | 
                                                        |
| 1855 | -            ) { | 
                                                        |
| 1856 | - $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];  | 
                                                        |
| 1857 | - }  | 
                                                        |
| 1858 | - }  | 
                                                        |
| 1859 | - //search query handling  | 
                                                        |
| 1860 | -        if (isset($this->_req_data['s'])) { | 
                                                        |
| 1861 | - $search_string = '%' . $this->_req_data['s'] . '%';  | 
                                                        |
| 1862 | - $where['OR'] = array(  | 
                                                        |
| 1863 | -                'EVT_name'       => array('LIKE', $search_string), | 
                                                        |
| 1864 | -                'EVT_desc'       => array('LIKE', $search_string), | 
                                                        |
| 1865 | -                'EVT_short_desc' => array('LIKE', $search_string), | 
                                                        |
| 1866 | - );  | 
                                                        |
| 1867 | - }  | 
                                                        |
| 1868 | -        $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); | 
                                                        |
| 1869 | - $query_params = apply_filters(  | 
                                                        |
| 1870 | - 'FHEE__Events_Admin_Page__get_events__query_params',  | 
                                                        |
| 1871 | - array(  | 
                                                        |
| 1872 | - $where,  | 
                                                        |
| 1873 | - 'limit' => $limit,  | 
                                                        |
| 1874 | - 'order_by' => $orderby,  | 
                                                        |
| 1875 | - 'order' => $order,  | 
                                                        |
| 1876 | - 'group_by' => 'EVT_ID',  | 
                                                        |
| 1877 | - ),  | 
                                                        |
| 1878 | - $this->_req_data  | 
                                                        |
| 1879 | - );  | 
                                                        |
| 1880 | - //let's first check if we have special requests coming in.  | 
                                                        |
| 1881 | -        if (isset($this->_req_data['active_status'])) { | 
                                                        |
| 1882 | -            switch ($this->_req_data['active_status']) { | 
                                                        |
| 1883 | - case 'upcoming' :  | 
                                                        |
| 1884 | - return $EEME->get_upcoming_events($query_params, $count);  | 
                                                        |
| 1885 | - break;  | 
                                                        |
| 1886 | - case 'expired' :  | 
                                                        |
| 1887 | - return $EEME->get_expired_events($query_params, $count);  | 
                                                        |
| 1888 | - break;  | 
                                                        |
| 1889 | - case 'active' :  | 
                                                        |
| 1890 | - return $EEME->get_active_events($query_params, $count);  | 
                                                        |
| 1891 | - break;  | 
                                                        |
| 1892 | - case 'inactive' :  | 
                                                        |
| 1893 | - return $EEME->get_inactive_events($query_params, $count);  | 
                                                        |
| 1894 | - break;  | 
                                                        |
| 1895 | - }  | 
                                                        |
| 1896 | - }  | 
                                                        |
| 1897 | - $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);  | 
                                                        |
| 1898 | - return $events;  | 
                                                        |
| 1899 | - }  | 
                                                        |
| 1900 | -  | 
                                                        |
| 1901 | -  | 
                                                        |
| 1902 | -  | 
                                                        |
| 1903 | - /**  | 
                                                        |
| 1904 | - * handling for WordPress CPT actions (trash, restore, delete)  | 
                                                        |
| 1905 | - *  | 
                                                        |
| 1906 | - * @param string $post_id  | 
                                                        |
| 1907 | - */  | 
                                                        |
| 1908 | - public function trash_cpt_item($post_id)  | 
                                                        |
| 1909 | -    { | 
                                                        |
| 1910 | - $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1911 | -        $this->_trash_or_restore_event('trash', false); | 
                                                        |
| 1912 | - }  | 
                                                        |
| 1913 | -  | 
                                                        |
| 1914 | -  | 
                                                        |
| 1915 | -  | 
                                                        |
| 1916 | - /**  | 
                                                        |
| 1917 | - * @param string $post_id  | 
                                                        |
| 1918 | - */  | 
                                                        |
| 1919 | - public function restore_cpt_item($post_id)  | 
                                                        |
| 1920 | -    { | 
                                                        |
| 1921 | - $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1922 | -        $this->_trash_or_restore_event('draft', false); | 
                                                        |
| 1923 | - }  | 
                                                        |
| 1924 | -  | 
                                                        |
| 1925 | -  | 
                                                        |
| 1926 | -  | 
                                                        |
| 1927 | - /**  | 
                                                        |
| 1928 | - * @param string $post_id  | 
                                                        |
| 1929 | - */  | 
                                                        |
| 1930 | - public function delete_cpt_item($post_id)  | 
                                                        |
| 1931 | -    { | 
                                                        |
| 1932 | - $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1933 | - $this->_delete_event(false);  | 
                                                        |
| 1934 | - }  | 
                                                        |
| 1935 | -  | 
                                                        |
| 1936 | -  | 
                                                        |
| 1937 | -  | 
                                                        |
| 1938 | - /**  | 
                                                        |
| 1939 | - * _trash_or_restore_event  | 
                                                        |
| 1940 | - *  | 
                                                        |
| 1941 | - * @access protected  | 
                                                        |
| 1942 | - * @param string $event_status  | 
                                                        |
| 1943 | - * @param bool $redirect_after  | 
                                                        |
| 1944 | - */  | 
                                                        |
| 1945 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)  | 
                                                        |
| 1946 | -    { | 
                                                        |
| 1947 | - //determine the event id and set to array.  | 
                                                        |
| 1948 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;  | 
                                                        |
| 1949 | - // loop thru events  | 
                                                        |
| 1950 | -        if ($EVT_ID) { | 
                                                        |
| 1951 | - // clean status  | 
                                                        |
| 1952 | - $event_status = sanitize_key($event_status);  | 
                                                        |
| 1953 | - // grab status  | 
                                                        |
| 1954 | -            if ( ! empty($event_status)) { | 
                                                        |
| 1955 | - $success = $this->_change_event_status($EVT_ID, $event_status);  | 
                                                        |
| 1956 | -            } else { | 
                                                        |
| 1957 | - $success = false;  | 
                                                        |
| 1958 | - $msg = esc_html__(  | 
                                                        |
| 1959 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',  | 
                                                        |
| 1960 | - 'event_espresso'  | 
                                                        |
| 1961 | - );  | 
                                                        |
| 1962 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1963 | - }  | 
                                                        |
| 1964 | -        } else { | 
                                                        |
| 1965 | - $success = false;  | 
                                                        |
| 1966 | - $msg = esc_html__(  | 
                                                        |
| 1967 | - 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',  | 
                                                        |
| 1968 | - 'event_espresso'  | 
                                                        |
| 1969 | - );  | 
                                                        |
| 1970 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1971 | - }  | 
                                                        |
| 1972 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';  | 
                                                        |
| 1973 | -        if ($redirect_after) { | 
                                                        |
| 1974 | -            $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); | 
                                                        |
| 1975 | - }  | 
                                                        |
| 1976 | - }  | 
                                                        |
| 1977 | -  | 
                                                        |
| 1978 | -  | 
                                                        |
| 1979 | -  | 
                                                        |
| 1980 | - /**  | 
                                                        |
| 1981 | - * _trash_or_restore_events  | 
                                                        |
| 1982 | - *  | 
                                                        |
| 1983 | - * @access protected  | 
                                                        |
| 1984 | - * @param string $event_status  | 
                                                        |
| 1985 | - * @return void  | 
                                                        |
| 1986 | - */  | 
                                                        |
| 1987 | - protected function _trash_or_restore_events($event_status = 'trash')  | 
                                                        |
| 1988 | -    { | 
                                                        |
| 1989 | - // clean status  | 
                                                        |
| 1990 | - $event_status = sanitize_key($event_status);  | 
                                                        |
| 1991 | - // grab status  | 
                                                        |
| 1992 | -        if ( ! empty($event_status)) { | 
                                                        |
| 1993 | - $success = true;  | 
                                                        |
| 1994 | - //determine the event id and set to array.  | 
                                                        |
| 1995 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();  | 
                                                        |
| 1996 | - // loop thru events  | 
                                                        |
| 1997 | -            foreach ($EVT_IDs as $EVT_ID) { | 
                                                        |
| 1998 | -                if ($EVT_ID = absint($EVT_ID)) { | 
                                                        |
| 1999 | - $results = $this->_change_event_status($EVT_ID, $event_status);  | 
                                                        |
| 2000 | - $success = $results !== false ? $success : false;  | 
                                                        |
| 2001 | -                } else { | 
                                                        |
| 2002 | - $msg = sprintf(  | 
                                                        |
| 2003 | - esc_html__(  | 
                                                        |
| 2004 | - 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',  | 
                                                        |
| 2005 | - 'event_espresso'  | 
                                                        |
| 2006 | - ),  | 
                                                        |
| 2007 | - $EVT_ID  | 
                                                        |
| 2008 | - );  | 
                                                        |
| 2009 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2010 | - $success = false;  | 
                                                        |
| 2011 | - }  | 
                                                        |
| 2012 | - }  | 
                                                        |
| 2013 | -        } else { | 
                                                        |
| 2014 | - $success = false;  | 
                                                        |
| 2015 | - $msg = esc_html__(  | 
                                                        |
| 2016 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',  | 
                                                        |
| 2017 | - 'event_espresso'  | 
                                                        |
| 2018 | - );  | 
                                                        |
| 2019 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2020 | - }  | 
                                                        |
| 2021 | - // in order to force a pluralized result message we need to send back a success status greater than 1  | 
                                                        |
| 2022 | - $success = $success ? 2 : false;  | 
                                                        |
| 2023 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';  | 
                                                        |
| 2024 | -        $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); | 
                                                        |
| 2025 | - }  | 
                                                        |
| 2026 | -  | 
                                                        |
| 2027 | -  | 
                                                        |
| 2028 | -  | 
                                                        |
| 2029 | - /**  | 
                                                        |
| 2030 | - * _trash_or_restore_events  | 
                                                        |
| 2031 | - *  | 
                                                        |
| 2032 | - * @access private  | 
                                                        |
| 2033 | - * @param int $EVT_ID  | 
                                                        |
| 2034 | - * @param string $event_status  | 
                                                        |
| 2035 | - * @return bool  | 
                                                        |
| 2036 | - */  | 
                                                        |
| 2037 | - private function _change_event_status($EVT_ID = 0, $event_status = '')  | 
                                                        |
| 2038 | -    { | 
                                                        |
| 2039 | - // grab event id  | 
                                                        |
| 2040 | -        if ( ! $EVT_ID) { | 
                                                        |
| 2041 | - $msg = esc_html__(  | 
                                                        |
| 2042 | - 'An error occurred. No Event ID or an invalid Event ID was received.',  | 
                                                        |
| 2043 | - 'event_espresso'  | 
                                                        |
| 2044 | - );  | 
                                                        |
| 2045 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2046 | - return false;  | 
                                                        |
| 2047 | - }  | 
                                                        |
| 2048 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);  | 
                                                        |
| 2049 | - // clean status  | 
                                                        |
| 2050 | - $event_status = sanitize_key($event_status);  | 
                                                        |
| 2051 | - // grab status  | 
                                                        |
| 2052 | -        if (empty($event_status)) { | 
                                                        |
| 2053 | - $msg = esc_html__(  | 
                                                        |
| 2054 | - 'An error occurred. No Event Status or an invalid Event Status was received.',  | 
                                                        |
| 2055 | - 'event_espresso'  | 
                                                        |
| 2056 | - );  | 
                                                        |
| 2057 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2058 | - return false;  | 
                                                        |
| 2059 | - }  | 
                                                        |
| 2060 | - // was event trashed or restored ?  | 
                                                        |
| 2061 | -        switch ($event_status) { | 
                                                        |
| 2062 | - case 'draft' :  | 
                                                        |
| 2063 | - $action = 'restored from the trash';  | 
                                                        |
| 2064 | - $hook = 'AHEE_event_restored_from_trash';  | 
                                                        |
| 2065 | - break;  | 
                                                        |
| 2066 | - case 'trash' :  | 
                                                        |
| 2067 | - $action = 'moved to the trash';  | 
                                                        |
| 2068 | - $hook = 'AHEE_event_moved_to_trash';  | 
                                                        |
| 2069 | - break;  | 
                                                        |
| 2070 | - default :  | 
                                                        |
| 2071 | - $action = 'updated';  | 
                                                        |
| 2072 | - $hook = false;  | 
                                                        |
| 2073 | - }  | 
                                                        |
| 2074 | - //use class to change status  | 
                                                        |
| 2075 | - $this->_cpt_model_obj->set_status($event_status);  | 
                                                        |
| 2076 | - $success = $this->_cpt_model_obj->save();  | 
                                                        |
| 2077 | -        if ($success === false) { | 
                                                        |
| 2078 | -            $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); | 
                                                        |
| 2079 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2080 | - return false;  | 
                                                        |
| 2081 | - }  | 
                                                        |
| 2082 | -        if ($hook) { | 
                                                        |
| 2083 | - do_action($hook);  | 
                                                        |
| 2084 | - }  | 
                                                        |
| 2085 | - return true;  | 
                                                        |
| 2086 | - }  | 
                                                        |
| 2087 | -  | 
                                                        |
| 2088 | -  | 
                                                        |
| 2089 | -  | 
                                                        |
| 2090 | - /**  | 
                                                        |
| 2091 | - * _delete_event  | 
                                                        |
| 2092 | - *  | 
                                                        |
| 2093 | - * @access protected  | 
                                                        |
| 2094 | - * @param bool $redirect_after  | 
                                                        |
| 2095 | - */  | 
                                                        |
| 2096 | - protected function _delete_event($redirect_after = true)  | 
                                                        |
| 2097 | -    { | 
                                                        |
| 2098 | - //determine the event id and set to array.  | 
                                                        |
| 2099 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;  | 
                                                        |
| 2100 | - $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;  | 
                                                        |
| 2101 | - // loop thru events  | 
                                                        |
| 2102 | -        if ($EVT_ID) { | 
                                                        |
| 2103 | - $success = $this->_permanently_delete_event($EVT_ID);  | 
                                                        |
| 2104 | - // get list of events with no prices  | 
                                                        |
| 2105 | -            $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); | 
                                                        |
| 2106 | - // remove this event from the list of events with no prices  | 
                                                        |
| 2107 | -            if (isset($espresso_no_ticket_prices[$EVT_ID])) { | 
                                                        |
| 2108 | - unset($espresso_no_ticket_prices[$EVT_ID]);  | 
                                                        |
| 2109 | - }  | 
                                                        |
| 2110 | -            update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); | 
                                                        |
| 2111 | -        } else { | 
                                                        |
| 2112 | - $success = false;  | 
                                                        |
| 2113 | - $msg = esc_html__(  | 
                                                        |
| 2114 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',  | 
                                                        |
| 2115 | - 'event_espresso'  | 
                                                        |
| 2116 | - );  | 
                                                        |
| 2117 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2118 | - }  | 
                                                        |
| 2119 | -        if ($redirect_after) { | 
                                                        |
| 2120 | - $this->_redirect_after_action(  | 
                                                        |
| 2121 | - $success,  | 
                                                        |
| 2122 | - 'Event',  | 
                                                        |
| 2123 | - 'deleted',  | 
                                                        |
| 2124 | -                array('action' => 'default', 'status' => 'trash') | 
                                                        |
| 2125 | - );  | 
                                                        |
| 2126 | - }  | 
                                                        |
| 2127 | - }  | 
                                                        |
| 2128 | -  | 
                                                        |
| 2129 | -  | 
                                                        |
| 2130 | -  | 
                                                        |
| 2131 | - /**  | 
                                                        |
| 2132 | - * _delete_events  | 
                                                        |
| 2133 | - *  | 
                                                        |
| 2134 | - * @access protected  | 
                                                        |
| 2135 | - * @return void  | 
                                                        |
| 2136 | - */  | 
                                                        |
| 2137 | - protected function _delete_events()  | 
                                                        |
| 2138 | -    { | 
                                                        |
| 2139 | - $success = true;  | 
                                                        |
| 2140 | - // get list of events with no prices  | 
                                                        |
| 2141 | -        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); | 
                                                        |
| 2142 | - //determine the event id and set to array.  | 
                                                        |
| 2143 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();  | 
                                                        |
| 2144 | - // loop thru events  | 
                                                        |
| 2145 | -        foreach ($EVT_IDs as $EVT_ID) { | 
                                                        |
| 2146 | - $EVT_ID = absint($EVT_ID);  | 
                                                        |
| 2147 | -            if ($EVT_ID) { | 
                                                        |
| 2148 | - $results = $this->_permanently_delete_event($EVT_ID);  | 
                                                        |
| 2149 | - $success = $results !== false ? $success : false;  | 
                                                        |
| 2150 | - // remove this event from the list of events with no prices  | 
                                                        |
| 2151 | - unset($espresso_no_ticket_prices[$EVT_ID]);  | 
                                                        |
| 2152 | -            } else { | 
                                                        |
| 2153 | - $success = false;  | 
                                                        |
| 2154 | - $msg = esc_html__(  | 
                                                        |
| 2155 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',  | 
                                                        |
| 2156 | - 'event_espresso'  | 
                                                        |
| 2157 | - );  | 
                                                        |
| 2158 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2159 | - }  | 
                                                        |
| 2160 | - }  | 
                                                        |
| 2161 | -        update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); | 
                                                        |
| 2162 | - // in order to force a pluralized result message we need to send back a success status greater than 1  | 
                                                        |
| 2163 | - $success = $success ? 2 : false;  | 
                                                        |
| 2164 | -        $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); | 
                                                        |
| 2165 | - }  | 
                                                        |
| 2166 | -  | 
                                                        |
| 2167 | -  | 
                                                        |
| 2168 | -  | 
                                                        |
| 2169 | - /**  | 
                                                        |
| 2170 | - * _permanently_delete_event  | 
                                                        |
| 2171 | - *  | 
                                                        |
| 2172 | - * @access private  | 
                                                        |
| 2173 | - * @param int $EVT_ID  | 
                                                        |
| 2174 | - * @return bool  | 
                                                        |
| 2175 | - */  | 
                                                        |
| 2176 | - private function _permanently_delete_event($EVT_ID = 0)  | 
                                                        |
| 2177 | -    { | 
                                                        |
| 2178 | - // grab event id  | 
                                                        |
| 2179 | -        if ( ! $EVT_ID) { | 
                                                        |
| 2180 | - $msg = esc_html__(  | 
                                                        |
| 2181 | - 'An error occurred. No Event ID or an invalid Event ID was received.',  | 
                                                        |
| 2182 | - 'event_espresso'  | 
                                                        |
| 2183 | - );  | 
                                                        |
| 2184 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2185 | - return false;  | 
                                                        |
| 2186 | - }  | 
                                                        |
| 2187 | - if (  | 
                                                        |
| 2188 | - ! $this->_cpt_model_obj instanceof EE_Event  | 
                                                        |
| 2189 | - || $this->_cpt_model_obj->ID() !== $EVT_ID  | 
                                                        |
| 2190 | -        ) { | 
                                                        |
| 2191 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);  | 
                                                        |
| 2192 | - }  | 
                                                        |
| 2193 | -        if ( ! $this->_cpt_model_obj instanceof EE_Event) { | 
                                                        |
| 2194 | - return false;  | 
                                                        |
| 2195 | - }  | 
                                                        |
| 2196 | - //need to delete related tickets and prices first.  | 
                                                        |
| 2197 | -        $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); | 
                                                        |
| 2198 | -        foreach ($datetimes as $datetime) { | 
                                                        |
| 2199 | - $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');  | 
                                                        |
| 2200 | -            $tickets = $datetime->get_many_related('Ticket'); | 
                                                        |
| 2201 | -            foreach ($tickets as $ticket) { | 
                                                        |
| 2202 | - $ticket->_remove_relation_to($datetime, 'Datetime');  | 
                                                        |
| 2203 | -                $ticket->delete_related_permanently('Price'); | 
                                                        |
| 2204 | - $ticket->delete_permanently();  | 
                                                        |
| 2205 | - }  | 
                                                        |
| 2206 | - $datetime->delete();  | 
                                                        |
| 2207 | - }  | 
                                                        |
| 2208 | - //what about related venues or terms?  | 
                                                        |
| 2209 | -        $venues = $this->_cpt_model_obj->get_many_related('Venue'); | 
                                                        |
| 2210 | -        foreach ($venues as $venue) { | 
                                                        |
| 2211 | - $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');  | 
                                                        |
| 2212 | - }  | 
                                                        |
| 2213 | - //any attached question groups?  | 
                                                        |
| 2214 | -        $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); | 
                                                        |
| 2215 | -        if ( ! empty($question_groups)) { | 
                                                        |
| 2216 | -            foreach ($question_groups as $question_group) { | 
                                                        |
| 2217 | - $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');  | 
                                                        |
| 2218 | - }  | 
                                                        |
| 2219 | - }  | 
                                                        |
| 2220 | - //Message Template Groups  | 
                                                        |
| 2221 | -        $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); | 
                                                        |
| 2222 | - /** @type EE_Term_Taxonomy[] $term_taxonomies */  | 
                                                        |
| 2223 | - $term_taxonomies = $this->_cpt_model_obj->term_taxonomies();  | 
                                                        |
| 2224 | -        foreach ($term_taxonomies as $term_taxonomy) { | 
                                                        |
| 2225 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);  | 
                                                        |
| 2226 | - }  | 
                                                        |
| 2227 | - $success = $this->_cpt_model_obj->delete_permanently();  | 
                                                        |
| 2228 | - // did it all go as planned ?  | 
                                                        |
| 2229 | -        if ($success) { | 
                                                        |
| 2230 | -            $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); | 
                                                        |
| 2231 | - EE_Error::add_success($msg);  | 
                                                        |
| 2232 | -        } else { | 
                                                        |
| 2233 | - $msg = sprintf(  | 
                                                        |
| 2234 | -                esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), | 
                                                        |
| 2235 | - $EVT_ID  | 
                                                        |
| 2236 | - );  | 
                                                        |
| 2237 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2238 | - return false;  | 
                                                        |
| 2239 | - }  | 
                                                        |
| 2240 | -        do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); | 
                                                        |
| 2241 | - return true;  | 
                                                        |
| 2242 | - }  | 
                                                        |
| 2243 | -  | 
                                                        |
| 2244 | -  | 
                                                        |
| 2245 | -  | 
                                                        |
| 2246 | - /**  | 
                                                        |
| 2247 | - * get total number of events  | 
                                                        |
| 2248 | - *  | 
                                                        |
| 2249 | - * @access public  | 
                                                        |
| 2250 | - * @return int  | 
                                                        |
| 2251 | - */  | 
                                                        |
| 2252 | - public function total_events()  | 
                                                        |
| 2253 | -    { | 
                                                        |
| 2254 | -        $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); | 
                                                        |
| 2255 | - return $count;  | 
                                                        |
| 2256 | - }  | 
                                                        |
| 2257 | -  | 
                                                        |
| 2258 | -  | 
                                                        |
| 2259 | -  | 
                                                        |
| 2260 | - /**  | 
                                                        |
| 2261 | - * get total number of draft events  | 
                                                        |
| 2262 | - *  | 
                                                        |
| 2263 | - * @access public  | 
                                                        |
| 2264 | - * @return int  | 
                                                        |
| 2265 | - */  | 
                                                        |
| 2266 | - public function total_events_draft()  | 
                                                        |
| 2267 | -    { | 
                                                        |
| 2268 | - $where = array(  | 
                                                        |
| 2269 | -            'status' => array('IN', array('draft', 'auto-draft')), | 
                                                        |
| 2270 | - );  | 
                                                        |
| 2271 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);  | 
                                                        |
| 2272 | - return $count;  | 
                                                        |
| 2273 | - }  | 
                                                        |
| 2274 | -  | 
                                                        |
| 2275 | -  | 
                                                        |
| 2276 | -  | 
                                                        |
| 2277 | - /**  | 
                                                        |
| 2278 | - * get total number of trashed events  | 
                                                        |
| 2279 | - *  | 
                                                        |
| 2280 | - * @access public  | 
                                                        |
| 2281 | - * @return int  | 
                                                        |
| 2282 | - */  | 
                                                        |
| 2283 | - public function total_trashed_events()  | 
                                                        |
| 2284 | -    { | 
                                                        |
| 2285 | - $where = array(  | 
                                                        |
| 2286 | - 'status' => 'trash',  | 
                                                        |
| 2287 | - );  | 
                                                        |
| 2288 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);  | 
                                                        |
| 2289 | - return $count;  | 
                                                        |
| 2290 | - }  | 
                                                        |
| 2291 | -  | 
                                                        |
| 2292 | -  | 
                                                        |
| 2293 | - /**  | 
                                                        |
| 2294 | - * _default_event_settings  | 
                                                        |
| 2295 | - * This generates the Default Settings Tab  | 
                                                        |
| 2296 | - *  | 
                                                        |
| 2297 | - * @return void  | 
                                                        |
| 2298 | - * @throws EE_Error  | 
                                                        |
| 2299 | - */  | 
                                                        |
| 2300 | - protected function _default_event_settings()  | 
                                                        |
| 2301 | -    { | 
                                                        |
| 2302 | -        $this->_set_add_edit_form_tags('update_default_event_settings'); | 
                                                        |
| 2303 | - $this->_set_publish_post_box_vars(null, false, false, null, false);  | 
                                                        |
| 2304 | - $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();  | 
                                                        |
| 2305 | - $this->display_admin_page_with_sidebar();  | 
                                                        |
| 2306 | - }  | 
                                                        |
| 2307 | -  | 
                                                        |
| 2308 | -  | 
                                                        |
| 2309 | - /**  | 
                                                        |
| 2310 | - * Return the form for event settings.  | 
                                                        |
| 2311 | - * @return EE_Form_Section_Proper  | 
                                                        |
| 2312 | - */  | 
                                                        |
| 2313 | - protected function _default_event_settings_form()  | 
                                                        |
| 2314 | -    { | 
                                                        |
| 2315 | - $registration_config = EE_Registry::instance()->CFG->registration;  | 
                                                        |
| 2316 | - $registration_stati_for_selection = EEM_Registration::reg_status_array(  | 
                                                        |
| 2317 | - //exclude  | 
                                                        |
| 2318 | - array(  | 
                                                        |
| 2319 | - EEM_Registration::status_id_cancelled,  | 
                                                        |
| 2320 | - EEM_Registration::status_id_declined,  | 
                                                        |
| 2321 | - EEM_Registration::status_id_incomplete,  | 
                                                        |
| 2322 | - EEM_Registration::status_id_wait_list,  | 
                                                        |
| 2323 | - ),  | 
                                                        |
| 2324 | - true  | 
                                                        |
| 2325 | - );  | 
                                                        |
| 2326 | - return new EE_Form_Section_Proper(  | 
                                                        |
| 2327 | - array(  | 
                                                        |
| 2328 | - 'name' => 'update_default_event_settings',  | 
                                                        |
| 2329 | - 'html_id' => 'update_default_event_settings',  | 
                                                        |
| 2330 | - 'html_class' => 'form-table',  | 
                                                        |
| 2331 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(),  | 
                                                        |
| 2332 | - 'subsections' => apply_filters(  | 
                                                        |
| 2333 | - 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',  | 
                                                        |
| 2334 | - array(  | 
                                                        |
| 2335 | - 'default_reg_status' => new EE_Select_Input(  | 
                                                        |
| 2336 | - $registration_stati_for_selection,  | 
                                                        |
| 2337 | - array(  | 
                                                        |
| 2338 | - 'default' => isset($registration_config->default_STS_ID)  | 
                                                        |
| 2339 | - && array_key_exists(  | 
                                                        |
| 2340 | - $registration_config->default_STS_ID,  | 
                                                        |
| 2341 | - $registration_stati_for_selection  | 
                                                        |
| 2342 | - )  | 
                                                        |
| 2343 | - ? sanitize_text_field($registration_config->default_STS_ID)  | 
                                                        |
| 2344 | - : EEM_Registration::status_id_pending_payment,  | 
                                                        |
| 2345 | -                                'html_label_text' => esc_html__('Default Registration Status', 'event_espresso') | 
                                                        |
| 2346 | - . EEH_Template::get_help_tab_link(  | 
                                                        |
| 2347 | - 'default_settings_status_help_tab'  | 
                                                        |
| 2348 | - ),  | 
                                                        |
| 2349 | - 'html_help_text' => esc_html__(  | 
                                                        |
| 2350 | - '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.',  | 
                                                        |
| 2351 | - 'event_espresso'  | 
                                                        |
| 2352 | - )  | 
                                                        |
| 2353 | - )  | 
                                                        |
| 2354 | - ),  | 
                                                        |
| 2355 | - 'default_max_tickets' => new EE_Integer_Input(  | 
                                                        |
| 2356 | - array(  | 
                                                        |
| 2357 | - 'default' => isset($registration_config->default_maximum_number_of_tickets)  | 
                                                        |
| 2358 | - ? $registration_config->default_maximum_number_of_tickets  | 
                                                        |
| 2359 | - : EEM_Event::get_default_additional_limit(),  | 
                                                        |
| 2360 | - 'html_label_text' => esc_html__(  | 
                                                        |
| 2361 | - 'Default Maximum Tickets Allowed Per Order:',  | 
                                                        |
| 2362 | - 'event_espresso'  | 
                                                        |
| 2363 | - ) . EEH_Template::get_help_tab_link(  | 
                                                        |
| 2364 | - 'default_maximum_tickets_help_tab"'  | 
                                                        |
| 2365 | - ),  | 
                                                        |
| 2366 | - 'html_help_text' => esc_html__(  | 
                                                        |
| 2367 | - 'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',  | 
                                                        |
| 2368 | - 'event_espresso'  | 
                                                        |
| 2369 | - )  | 
                                                        |
| 2370 | - )  | 
                                                        |
| 2371 | - )  | 
                                                        |
| 2372 | - )  | 
                                                        |
| 2373 | - )  | 
                                                        |
| 2374 | - )  | 
                                                        |
| 2375 | - );  | 
                                                        |
| 2376 | - }  | 
                                                        |
| 2377 | -  | 
                                                        |
| 2378 | -  | 
                                                        |
| 2379 | - /**  | 
                                                        |
| 2380 | - * _update_default_event_settings  | 
                                                        |
| 2381 | - *  | 
                                                        |
| 2382 | - * @access protected  | 
                                                        |
| 2383 | - * @return void  | 
                                                        |
| 2384 | - * @throws EE_Error  | 
                                                        |
| 2385 | - */  | 
                                                        |
| 2386 | - protected function _update_default_event_settings()  | 
                                                        |
| 2387 | -    { | 
                                                        |
| 2388 | - $registration_config = EE_Registry::instance()->CFG->registration;  | 
                                                        |
| 2389 | - $form = $this->_default_event_settings_form();  | 
                                                        |
| 2390 | -        if ($form->was_submitted()) { | 
                                                        |
| 2391 | - $form->receive_form_submission();  | 
                                                        |
| 2392 | -            if ($form->is_valid()) { | 
                                                        |
| 2393 | - $valid_data = $form->valid_data();  | 
                                                        |
| 2394 | -                if (isset($valid_data['default_reg_status'])) { | 
                                                        |
| 2395 | - $registration_config->default_STS_ID = $valid_data['default_reg_status'];  | 
                                                        |
| 2396 | - }  | 
                                                        |
| 2397 | -                if (isset($valid_data['default_max_tickets'])) { | 
                                                        |
| 2398 | - $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];  | 
                                                        |
| 2399 | - }  | 
                                                        |
| 2400 | - //update because data was valid!  | 
                                                        |
| 2401 | - EE_Registry::instance()->CFG->update_espresso_config();  | 
                                                        |
| 2402 | - EE_Error::overwrite_success();  | 
                                                        |
| 2403 | - EE_Error::add_success(  | 
                                                        |
| 2404 | -                    __('Default Event Settings were updated', 'event_espresso') | 
                                                        |
| 2405 | - );  | 
                                                        |
| 2406 | - }  | 
                                                        |
| 2407 | - }  | 
                                                        |
| 2408 | -        $this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true); | 
                                                        |
| 2409 | - }  | 
                                                        |
| 2410 | -  | 
                                                        |
| 2411 | -  | 
                                                        |
| 2412 | -  | 
                                                        |
| 2413 | - /************* Templates *************/  | 
                                                        |
| 2414 | - protected function _template_settings()  | 
                                                        |
| 2415 | -    { | 
                                                        |
| 2416 | -        $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); | 
                                                        |
| 2417 | - $this->_template_args['preview_img'] = '<img src="'  | 
                                                        |
| 2418 | - . EVENTS_ASSETS_URL  | 
                                                        |
| 2419 | - . DS  | 
                                                        |
| 2420 | - . 'images'  | 
                                                        |
| 2421 | - . DS  | 
                                                        |
| 2422 | - . 'caffeinated_template_features.jpg" alt="'  | 
                                                        |
| 2423 | -                                               . esc_attr__('Template Settings Preview screenshot', 'event_espresso') | 
                                                        |
| 2424 | - . '" />';  | 
                                                        |
| 2425 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__(  | 
                                                        |
| 2426 | - '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.',  | 
                                                        |
| 2427 | - 'event_espresso'  | 
                                                        |
| 2428 | - ) . '</strong>';  | 
                                                        |
| 2429 | -        $this->display_admin_caf_preview_page('template_settings_tab'); | 
                                                        |
| 2430 | - }  | 
                                                        |
| 2431 | -  | 
                                                        |
| 2432 | -  | 
                                                        |
| 2433 | - /** Event Category Stuff **/  | 
                                                        |
| 2434 | - /**  | 
                                                        |
| 2435 | - * set the _category property with the category object for the loaded page.  | 
                                                        |
| 2436 | - *  | 
                                                        |
| 2437 | - * @access private  | 
                                                        |
| 2438 | - * @return void  | 
                                                        |
| 2439 | - */  | 
                                                        |
| 2440 | - private function _set_category_object()  | 
                                                        |
| 2441 | -    { | 
                                                        |
| 2442 | -        if (isset($this->_category->id) && ! empty($this->_category->id)) { | 
                                                        |
| 2443 | - return;  | 
                                                        |
| 2444 | - } //already have the category object so get out.  | 
                                                        |
| 2445 | - //set default category object  | 
                                                        |
| 2446 | - $this->_set_empty_category_object();  | 
                                                        |
| 2447 | - //only set if we've got an id  | 
                                                        |
| 2448 | -        if ( ! isset($this->_req_data['EVT_CAT_ID'])) { | 
                                                        |
| 2449 | - return;  | 
                                                        |
| 2450 | - }  | 
                                                        |
| 2451 | - $category_id = absint($this->_req_data['EVT_CAT_ID']);  | 
                                                        |
| 2452 | - $term = get_term($category_id, 'espresso_event_categories');  | 
                                                        |
| 2453 | -        if ( ! empty($term)) { | 
                                                        |
| 2454 | - $this->_category->category_name = $term->name;  | 
                                                        |
| 2455 | - $this->_category->category_identifier = $term->slug;  | 
                                                        |
| 2456 | - $this->_category->category_desc = $term->description;  | 
                                                        |
| 2457 | - $this->_category->id = $term->term_id;  | 
                                                        |
| 2458 | - $this->_category->parent = $term->parent;  | 
                                                        |
| 2459 | - }  | 
                                                        |
| 2460 | - }  | 
                                                        |
| 2461 | -  | 
                                                        |
| 2462 | -  | 
                                                        |
| 2463 | - /**  | 
                                                        |
| 2464 | - * Clears out category properties.  | 
                                                        |
| 2465 | - */  | 
                                                        |
| 2466 | - private function _set_empty_category_object()  | 
                                                        |
| 2467 | -    { | 
                                                        |
| 2468 | - $this->_category = new stdClass();  | 
                                                        |
| 2469 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';  | 
                                                        |
| 2470 | - $this->_category->id = $this->_category->parent = 0;  | 
                                                        |
| 2471 | - }  | 
                                                        |
| 2472 | -  | 
                                                        |
| 2473 | -  | 
                                                        |
| 2474 | - /**  | 
                                                        |
| 2475 | - * @throws EE_Error  | 
                                                        |
| 2476 | - */  | 
                                                        |
| 2477 | - protected function _category_list_table()  | 
                                                        |
| 2478 | -    { | 
                                                        |
| 2479 | -        do_action('AHEE_log', __FILE__, __FUNCTION__, ''); | 
                                                        |
| 2480 | -        $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); | 
                                                        |
| 2481 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(  | 
                                                        |
| 2482 | - 'add_category',  | 
                                                        |
| 2483 | - 'add_category',  | 
                                                        |
| 2484 | - array(),  | 
                                                        |
| 2485 | - 'add-new-h2'  | 
                                                        |
| 2486 | - );  | 
                                                        |
| 2487 | - $this->display_admin_list_table_page_with_sidebar();  | 
                                                        |
| 2488 | - }  | 
                                                        |
| 2489 | -  | 
                                                        |
| 2490 | -  | 
                                                        |
| 2491 | -  | 
                                                        |
| 2492 | - /**  | 
                                                        |
| 2493 | - * Output category details view.  | 
                                                        |
| 2494 | - */  | 
                                                        |
| 2495 | - protected function _category_details($view)  | 
                                                        |
| 2496 | -    { | 
                                                        |
| 2497 | - //load formatter helper  | 
                                                        |
| 2498 | - //load field generator helper  | 
                                                        |
| 2499 | - $route = $view == 'edit' ? 'update_category' : 'insert_category';  | 
                                                        |
| 2500 | - $this->_set_add_edit_form_tags($route);  | 
                                                        |
| 2501 | - $this->_set_category_object();  | 
                                                        |
| 2502 | - $id = ! empty($this->_category->id) ? $this->_category->id : '';  | 
                                                        |
| 2503 | - $delete_action = 'delete_category';  | 
                                                        |
| 2504 | - //custom redirect  | 
                                                        |
| 2505 | - $redirect = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 2506 | -            array('action' => 'category_list'), | 
                                                        |
| 2507 | - $this->_admin_base_url  | 
                                                        |
| 2508 | - );  | 
                                                        |
| 2509 | -        $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); | 
                                                        |
| 2510 | - //take care of contents  | 
                                                        |
| 2511 | - $this->_template_args['admin_page_content'] = $this->_category_details_content();  | 
                                                        |
| 2512 | - $this->display_admin_page_with_sidebar();  | 
                                                        |
| 2513 | - }  | 
                                                        |
| 2514 | -  | 
                                                        |
| 2515 | -  | 
                                                        |
| 2516 | -  | 
                                                        |
| 2517 | - /**  | 
                                                        |
| 2518 | - * Output category details content.  | 
                                                        |
| 2519 | - */  | 
                                                        |
| 2520 | - protected function _category_details_content()  | 
                                                        |
| 2521 | -    { | 
                                                        |
| 2522 | - $editor_args['category_desc'] = array(  | 
                                                        |
| 2523 | - 'type' => 'wp_editor',  | 
                                                        |
| 2524 | - 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc),  | 
                                                        |
| 2525 | - 'class' => 'my_editor_custom',  | 
                                                        |
| 2526 | -            'wpeditor_args' => array('media_buttons' => false), | 
                                                        |
| 2527 | - );  | 
                                                        |
| 2528 | - $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');  | 
                                                        |
| 2529 | - $all_terms = get_terms(  | 
                                                        |
| 2530 | -            array('espresso_event_categories'), | 
                                                        |
| 2531 | -            array('hide_empty' => 0, 'exclude' => array($this->_category->id)) | 
                                                        |
| 2532 | - );  | 
                                                        |
| 2533 | - //setup category select for term parents.  | 
                                                        |
| 2534 | - $category_select_values[] = array(  | 
                                                        |
| 2535 | -            'text' => esc_html__('No Parent', 'event_espresso'), | 
                                                        |
| 2536 | - 'id' => 0,  | 
                                                        |
| 2537 | - );  | 
                                                        |
| 2538 | -        foreach ($all_terms as $term) { | 
                                                        |
| 2539 | - $category_select_values[] = array(  | 
                                                        |
| 2540 | - 'text' => $term->name,  | 
                                                        |
| 2541 | - 'id' => $term->term_id,  | 
                                                        |
| 2542 | - );  | 
                                                        |
| 2543 | - }  | 
                                                        |
| 2544 | - $category_select = EEH_Form_Fields::select_input(  | 
                                                        |
| 2545 | - 'category_parent',  | 
                                                        |
| 2546 | - $category_select_values,  | 
                                                        |
| 2547 | - $this->_category->parent  | 
                                                        |
| 2548 | - );  | 
                                                        |
| 2549 | - $template_args = array(  | 
                                                        |
| 2550 | - 'category' => $this->_category,  | 
                                                        |
| 2551 | - 'category_select' => $category_select,  | 
                                                        |
| 2552 | -            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), | 
                                                        |
| 2553 | - 'category_desc_editor' => $_wp_editor['category_desc']['field'],  | 
                                                        |
| 2554 | - 'disable' => '',  | 
                                                        |
| 2555 | - 'disabled_message' => false,  | 
                                                        |
| 2556 | - );  | 
                                                        |
| 2557 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';  | 
                                                        |
| 2558 | - return EEH_Template::display_template($template, $template_args, true);  | 
                                                        |
| 2559 | - }  | 
                                                        |
| 2560 | -  | 
                                                        |
| 2561 | -  | 
                                                        |
| 2562 | - /**  | 
                                                        |
| 2563 | - * Handles deleting categories.  | 
                                                        |
| 2564 | - */  | 
                                                        |
| 2565 | - protected function _delete_categories()  | 
                                                        |
| 2566 | -    { | 
                                                        |
| 2567 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID']  | 
                                                        |
| 2568 | - : (array)$this->_req_data['category_id'];  | 
                                                        |
| 2569 | -        foreach ($cat_ids as $cat_id) { | 
                                                        |
| 2570 | - $this->_delete_category($cat_id);  | 
                                                        |
| 2571 | - }  | 
                                                        |
| 2572 | - //doesn't matter what page we're coming from... we're going to the same place after delete.  | 
                                                        |
| 2573 | - $query_args = array(  | 
                                                        |
| 2574 | - 'action' => 'category_list',  | 
                                                        |
| 2575 | - );  | 
                                                        |
| 2576 | - $this->_redirect_after_action(0, '', '', $query_args);  | 
                                                        |
| 2577 | - }  | 
                                                        |
| 2578 | -  | 
                                                        |
| 2579 | -  | 
                                                        |
| 2580 | -  | 
                                                        |
| 2581 | - /**  | 
                                                        |
| 2582 | - * Handles deleting specific category.  | 
                                                        |
| 2583 | - * @param int $cat_id  | 
                                                        |
| 2584 | - */  | 
                                                        |
| 2585 | - protected function _delete_category($cat_id)  | 
                                                        |
| 2586 | -    { | 
                                                        |
| 2587 | - $cat_id = absint($cat_id);  | 
                                                        |
| 2588 | - wp_delete_term($cat_id, 'espresso_event_categories');  | 
                                                        |
| 2589 | - }  | 
                                                        |
| 2590 | -  | 
                                                        |
| 2591 | -  | 
                                                        |
| 2592 | -  | 
                                                        |
| 2593 | - /**  | 
                                                        |
| 2594 | - * Handles triggering the update or insertion of a new category.  | 
                                                        |
| 2595 | - * @param bool $new_category true means we're triggering the insert of a new category.  | 
                                                        |
| 2596 | - */  | 
                                                        |
| 2597 | - protected function _insert_or_update_category($new_category)  | 
                                                        |
| 2598 | -    { | 
                                                        |
| 2599 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);  | 
                                                        |
| 2600 | - $success = 0; //we already have a success message so lets not send another.  | 
                                                        |
| 2601 | -        if ($cat_id) { | 
                                                        |
| 2602 | - $query_args = array(  | 
                                                        |
| 2603 | - 'action' => 'edit_category',  | 
                                                        |
| 2604 | - 'EVT_CAT_ID' => $cat_id,  | 
                                                        |
| 2605 | - );  | 
                                                        |
| 2606 | -        } else { | 
                                                        |
| 2607 | -            $query_args = array('action' => 'add_category'); | 
                                                        |
| 2608 | - }  | 
                                                        |
| 2609 | - $this->_redirect_after_action($success, '', '', $query_args, true);  | 
                                                        |
| 2610 | - }  | 
                                                        |
| 2611 | -  | 
                                                        |
| 2612 | -  | 
                                                        |
| 2613 | -  | 
                                                        |
| 2614 | - /**  | 
                                                        |
| 2615 | - * Inserts or updates category  | 
                                                        |
| 2616 | - * @param bool $update (true indicates we're updating a category).  | 
                                                        |
| 2617 | - * @return bool|mixed|string  | 
                                                        |
| 2618 | - */  | 
                                                        |
| 2619 | - private function _insert_category($update = false)  | 
                                                        |
| 2620 | -    { | 
                                                        |
| 2621 | - $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';  | 
                                                        |
| 2622 | - $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';  | 
                                                        |
| 2623 | - $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';  | 
                                                        |
| 2624 | - $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;  | 
                                                        |
| 2625 | -        if (empty($category_name)) { | 
                                                        |
| 2626 | -            $msg = esc_html__('You must add a name for the category.', 'event_espresso'); | 
                                                        |
| 2627 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2628 | - return false;  | 
                                                        |
| 2629 | - }  | 
                                                        |
| 2630 | - $term_args = array(  | 
                                                        |
| 2631 | - 'name' => $category_name,  | 
                                                        |
| 2632 | - 'description' => $category_desc,  | 
                                                        |
| 2633 | - 'parent' => $category_parent,  | 
                                                        |
| 2634 | - );  | 
                                                        |
| 2635 | - //was the category_identifier input disabled?  | 
                                                        |
| 2636 | -        if (isset($this->_req_data['category_identifier'])) { | 
                                                        |
| 2637 | - $term_args['slug'] = $this->_req_data['category_identifier'];  | 
                                                        |
| 2638 | - }  | 
                                                        |
| 2639 | - $insert_ids = $update  | 
                                                        |
| 2640 | - ? wp_update_term($cat_id, 'espresso_event_categories', $term_args)  | 
                                                        |
| 2641 | - : wp_insert_term($category_name, 'espresso_event_categories', $term_args);  | 
                                                        |
| 2642 | -        if ( ! is_array($insert_ids)) { | 
                                                        |
| 2643 | - $msg = esc_html__(  | 
                                                        |
| 2644 | - 'An error occurred and the category has not been saved to the database.',  | 
                                                        |
| 2645 | - 'event_espresso'  | 
                                                        |
| 2646 | - );  | 
                                                        |
| 2647 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2648 | -        } else { | 
                                                        |
| 2649 | - $cat_id = $insert_ids['term_id'];  | 
                                                        |
| 2650 | -            $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); | 
                                                        |
| 2651 | - EE_Error::add_success($msg);  | 
                                                        |
| 2652 | - }  | 
                                                        |
| 2653 | - return $cat_id;  | 
                                                        |
| 2654 | - }  | 
                                                        |
| 2655 | -  | 
                                                        |
| 2656 | -  | 
                                                        |
| 2657 | -  | 
                                                        |
| 2658 | - /**  | 
                                                        |
| 2659 | - * Gets categories or count of categories matching the arguments in the request.  | 
                                                        |
| 2660 | - * @param int $per_page  | 
                                                        |
| 2661 | - * @param int $current_page  | 
                                                        |
| 2662 | - * @param bool $count  | 
                                                        |
| 2663 | - * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int  | 
                                                        |
| 2664 | - */  | 
                                                        |
| 2665 | - public function get_categories($per_page = 10, $current_page = 1, $count = false)  | 
                                                        |
| 2666 | -    { | 
                                                        |
| 2667 | - //testing term stuff  | 
                                                        |
| 2668 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';  | 
                                                        |
| 2669 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';  | 
                                                        |
| 2670 | - $limit = ($current_page - 1) * $per_page;  | 
                                                        |
| 2671 | -        $where = array('taxonomy' => 'espresso_event_categories'); | 
                                                        |
| 2672 | -        if (isset($this->_req_data['s'])) { | 
                                                        |
| 2673 | - $sstr = '%' . $this->_req_data['s'] . '%';  | 
                                                        |
| 2674 | - $where['OR'] = array(  | 
                                                        |
| 2675 | -                'Term.name'   => array('LIKE', $sstr), | 
                                                        |
| 2676 | -                'description' => array('LIKE', $sstr), | 
                                                        |
| 2677 | - );  | 
                                                        |
| 2678 | - }  | 
                                                        |
| 2679 | - $query_params = array(  | 
                                                        |
| 2680 | - $where,  | 
                                                        |
| 2681 | - 'order_by' => array($orderby => $order),  | 
                                                        |
| 2682 | - 'limit' => $limit . ',' . $per_page,  | 
                                                        |
| 2683 | -            'force_join' => array('Term'), | 
                                                        |
| 2684 | - );  | 
                                                        |
| 2685 | - $categories = $count  | 
                                                        |
| 2686 | - ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')  | 
                                                        |
| 2687 | - : EEM_Term_Taxonomy::instance()->get_all($query_params);  | 
                                                        |
| 2688 | - return $categories;  | 
                                                        |
| 2689 | - }  | 
                                                        |
| 2690 | -  | 
                                                        |
| 2691 | - /* end category stuff */  | 
                                                        |
| 2692 | - /**************/  | 
                                                        |
| 2693 | -  | 
                                                        |
| 2694 | -  | 
                                                        |
| 2695 | - /**  | 
                                                        |
| 2696 | - * Callback for the `ee_save_timezone_setting` ajax action.  | 
                                                        |
| 2697 | - * @throws EE_Error  | 
                                                        |
| 2698 | - */  | 
                                                        |
| 2699 | - public function save_timezonestring_setting()  | 
                                                        |
| 2700 | -    { | 
                                                        |
| 2701 | - $timezone_string = isset($this->_req_data['timezone_selected'])  | 
                                                        |
| 2702 | - ? $this->_req_data['timezone_selected']  | 
                                                        |
| 2703 | - : '';  | 
                                                        |
| 2704 | - if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false))  | 
                                                        |
| 2705 | -        { | 
                                                        |
| 2706 | - EE_Error::add_error(  | 
                                                        |
| 2707 | -                esc_html('An invalid timezone string submitted.', 'event_espresso'), | 
                                                        |
| 2708 | - __FILE__, __FUNCTION__, __LINE__  | 
                                                        |
| 2709 | - );  | 
                                                        |
| 2710 | - $this->_template_args['error'] = true;  | 
                                                        |
| 2711 | - $this->_return_json();  | 
                                                        |
| 2712 | - }  | 
                                                        |
| 2713 | -  | 
                                                        |
| 2714 | -        update_option('timezone_string', $timezone_string); | 
                                                        |
| 2715 | - EE_Error::add_success(  | 
                                                        |
| 2716 | -            esc_html__('Your timezone string was updated.', 'event_espresso') | 
                                                        |
| 2717 | - );  | 
                                                        |
| 2718 | - $this->_template_args['success'] = true;  | 
                                                        |
| 2719 | -        $this->_return_json(true, array('action' => 'create_new')); | 
                                                        |
| 2720 | - }  | 
                                                        |
| 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_args['upsell_notice'] = sprintf(  | 
                                                        |
| 1613 | + esc_html__(  | 
                                                        |
| 1614 | + '%sCreate multiple occurrences of this event; required tickets and more with %sEvent Espresso 4 Caffienated%s.%s',  | 
                                                        |
| 1615 | + 'event_espresso'  | 
                                                        |
| 1616 | + ),  | 
                                                        |
| 1617 | + '<div class="notice inline notice-info "><p>',  | 
                                                        |
| 1618 | + '<a href="#">',  | 
                                                        |
| 1619 | + '</a>',  | 
                                                        |
| 1620 | + '</p></div>'  | 
                                                        |
| 1621 | + );  | 
                                                        |
| 1622 | + $template_args = apply_filters(  | 
                                                        |
| 1623 | + 'FHEE__Events_Admin_Page__ticket_metabox__template_args__decaf',  | 
                                                        |
| 1624 | + $template_args  | 
                                                        |
| 1625 | + );  | 
                                                        |
| 1626 | + $template = apply_filters(  | 
                                                        |
| 1627 | + 'FHEE__Events_Admin_Page__ticket_metabox__template',  | 
                                                        |
| 1628 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'  | 
                                                        |
| 1629 | + );  | 
                                                        |
| 1630 | + EEH_Template::display_template($template, $template_args);  | 
                                                        |
| 1631 | + }  | 
                                                        |
| 1632 | +  | 
                                                        |
| 1633 | +  | 
                                                        |
| 1634 | +  | 
                                                        |
| 1635 | + /**  | 
                                                        |
| 1636 | + * Setup an individual ticket form for the decaf event editor page  | 
                                                        |
| 1637 | + *  | 
                                                        |
| 1638 | + * @access private  | 
                                                        |
| 1639 | + * @param EE_Ticket $ticket the ticket object  | 
                                                        |
| 1640 | + * @param boolean $skeleton whether we're generating a skeleton for js manipulation  | 
                                                        |
| 1641 | + * @param int $row  | 
                                                        |
| 1642 | + * @return string generated html for the ticket row.  | 
                                                        |
| 1643 | + */  | 
                                                        |
| 1644 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0)  | 
                                                        |
| 1645 | +	{ | 
                                                        |
| 1646 | + $template_args = array(  | 
                                                        |
| 1647 | + 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(),  | 
                                                        |
| 1648 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'  | 
                                                        |
| 1649 | + : '',  | 
                                                        |
| 1650 | + 'ticketrow' => $skeleton ? 'TICKETNUM' : $row,  | 
                                                        |
| 1651 | +			'TKT_ID'              => $ticket->get('TKT_ID'), | 
                                                        |
| 1652 | +			'TKT_name'            => $ticket->get('TKT_name'), | 
                                                        |
| 1653 | +			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), | 
                                                        |
| 1654 | +			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), | 
                                                        |
| 1655 | +			'TKT_is_default'      => $ticket->get('TKT_is_default'), | 
                                                        |
| 1656 | +			'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'), | 
                                                        |
| 1657 | + 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',  | 
                                                        |
| 1658 | +			'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'), | 
                                                        |
| 1659 | +			'trash_icon'          => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) | 
                                                        |
| 1660 | +									 && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) | 
                                                        |
| 1661 | + ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',  | 
                                                        |
| 1662 | +			'disabled'            => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' | 
                                                        |
| 1663 | + : ' disabled=disabled',  | 
                                                        |
| 1664 | + );  | 
                                                        |
| 1665 | + $price = $ticket->ID() !== 0  | 
                                                        |
| 1666 | +			? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) | 
                                                        |
| 1667 | +			: EE_Registry::instance()->load_model('Price')->create_default_object(); | 
                                                        |
| 1668 | + $price_args = array(  | 
                                                        |
| 1669 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,  | 
                                                        |
| 1670 | +			'PRC_amount'            => $price->get('PRC_amount'), | 
                                                        |
| 1671 | +			'PRT_ID'                => $price->get('PRT_ID'), | 
                                                        |
| 1672 | +			'PRC_ID'                => $price->get('PRC_ID'), | 
                                                        |
| 1673 | +			'PRC_is_default'        => $price->get('PRC_is_default'), | 
                                                        |
| 1674 | + );  | 
                                                        |
| 1675 | + //make sure we have default start and end dates if skeleton  | 
                                                        |
| 1676 | + //handle rows that should NOT be empty  | 
                                                        |
| 1677 | +		if (empty($template_args['TKT_start_date'])) { | 
                                                        |
| 1678 | + //if empty then the start date will be now.  | 
                                                        |
| 1679 | +			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); | 
                                                        |
| 1680 | + }  | 
                                                        |
| 1681 | +		if (empty($template_args['TKT_end_date'])) { | 
                                                        |
| 1682 | + //get the earliest datetime (if present);  | 
                                                        |
| 1683 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0  | 
                                                        |
| 1684 | + ? $this->_cpt_model_obj->get_first_related(  | 
                                                        |
| 1685 | + 'Datetime',  | 
                                                        |
| 1686 | +					array('order_by' => array('DTT_EVT_start' => 'ASC')) | 
                                                        |
| 1687 | + )  | 
                                                        |
| 1688 | + : null;  | 
                                                        |
| 1689 | +			if ( ! empty($earliest_dtt)) { | 
                                                        |
| 1690 | +				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); | 
                                                        |
| 1691 | +			} else { | 
                                                        |
| 1692 | + $template_args['TKT_end_date'] = date(  | 
                                                        |
| 1693 | + 'Y-m-d h:i a',  | 
                                                        |
| 1694 | +					mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) | 
                                                        |
| 1695 | + );  | 
                                                        |
| 1696 | + }  | 
                                                        |
| 1697 | + }  | 
                                                        |
| 1698 | + $template_args = array_merge($template_args, $price_args);  | 
                                                        |
| 1699 | + $template = apply_filters(  | 
                                                        |
| 1700 | + 'FHEE__Events_Admin_Page__get_ticket_row__template',  | 
                                                        |
| 1701 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',  | 
                                                        |
| 1702 | + $ticket  | 
                                                        |
| 1703 | + );  | 
                                                        |
| 1704 | + return EEH_Template::display_template($template, $template_args, true);  | 
                                                        |
| 1705 | + }  | 
                                                        |
| 1706 | +  | 
                                                        |
| 1707 | +  | 
                                                        |
| 1708 | + /**  | 
                                                        |
| 1709 | + * @throws DomainException  | 
                                                        |
| 1710 | + */  | 
                                                        |
| 1711 | + public function registration_options_meta_box()  | 
                                                        |
| 1712 | +	{ | 
                                                        |
| 1713 | + $yes_no_values = array(  | 
                                                        |
| 1714 | +			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), | 
                                                        |
| 1715 | +			array('id' => false, 'text' => esc_html__('No', 'event_espresso')), | 
                                                        |
| 1716 | + );  | 
                                                        |
| 1717 | + $default_reg_status_values = EEM_Registration::reg_status_array(  | 
                                                        |
| 1718 | + array(  | 
                                                        |
| 1719 | + EEM_Registration::status_id_cancelled,  | 
                                                        |
| 1720 | + EEM_Registration::status_id_declined,  | 
                                                        |
| 1721 | + EEM_Registration::status_id_incomplete,  | 
                                                        |
| 1722 | + ),  | 
                                                        |
| 1723 | + true  | 
                                                        |
| 1724 | + );  | 
                                                        |
| 1725 | +		//$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); | 
                                                        |
| 1726 | + $template_args['_event'] = $this->_cpt_model_obj;  | 
                                                        |
| 1727 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);  | 
                                                        |
| 1728 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();  | 
                                                        |
| 1729 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1730 | + 'default_reg_status',  | 
                                                        |
| 1731 | + $default_reg_status_values,  | 
                                                        |
| 1732 | + $this->_cpt_model_obj->default_registration_status()  | 
                                                        |
| 1733 | + );  | 
                                                        |
| 1734 | + $template_args['display_description'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1735 | + 'display_desc',  | 
                                                        |
| 1736 | + $yes_no_values,  | 
                                                        |
| 1737 | + $this->_cpt_model_obj->display_description()  | 
                                                        |
| 1738 | + );  | 
                                                        |
| 1739 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1740 | + 'display_ticket_selector',  | 
                                                        |
| 1741 | + $yes_no_values,  | 
                                                        |
| 1742 | + $this->_cpt_model_obj->display_ticket_selector(),  | 
                                                        |
| 1743 | + '',  | 
                                                        |
| 1744 | + '',  | 
                                                        |
| 1745 | + false  | 
                                                        |
| 1746 | + );  | 
                                                        |
| 1747 | + $template_args['additional_registration_options'] = apply_filters(  | 
                                                        |
| 1748 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',  | 
                                                        |
| 1749 | + '',  | 
                                                        |
| 1750 | + $template_args,  | 
                                                        |
| 1751 | + $yes_no_values,  | 
                                                        |
| 1752 | + $default_reg_status_values  | 
                                                        |
| 1753 | + );  | 
                                                        |
| 1754 | + EEH_Template::display_template(  | 
                                                        |
| 1755 | + EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',  | 
                                                        |
| 1756 | + $template_args  | 
                                                        |
| 1757 | + );  | 
                                                        |
| 1758 | + }  | 
                                                        |
| 1759 | +  | 
                                                        |
| 1760 | +  | 
                                                        |
| 1761 | +  | 
                                                        |
| 1762 | + /**  | 
                                                        |
| 1763 | + * _get_events()  | 
                                                        |
| 1764 | + * This method simply returns all the events (for the given _view and paging)  | 
                                                        |
| 1765 | + *  | 
                                                        |
| 1766 | + * @access public  | 
                                                        |
| 1767 | + * @param int $per_page count of items per page (20 default);  | 
                                                        |
| 1768 | + * @param int $current_page what is the current page being viewed.  | 
                                                        |
| 1769 | + * @param bool $count if TRUE then we just return a count of ALL events matching the given _view.  | 
                                                        |
| 1770 | + * If FALSE then we return an array of event objects  | 
                                                        |
| 1771 | + * that match the given _view and paging parameters.  | 
                                                        |
| 1772 | + * @return array an array of event objects.  | 
                                                        |
| 1773 | + */  | 
                                                        |
| 1774 | + public function get_events($per_page = 10, $current_page = 1, $count = false)  | 
                                                        |
| 1775 | +	{ | 
                                                        |
| 1776 | + $EEME = $this->_event_model();  | 
                                                        |
| 1777 | + $offset = ($current_page - 1) * $per_page;  | 
                                                        |
| 1778 | + $limit = $count ? null : $offset . ',' . $per_page;  | 
                                                        |
| 1779 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';  | 
                                                        |
| 1780 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";  | 
                                                        |
| 1781 | +		if (isset($this->_req_data['month_range'])) { | 
                                                        |
| 1782 | +			$pieces = explode(' ', $this->_req_data['month_range'], 3); | 
                                                        |
| 1783 | + //simulate the FIRST day of the month, that fixes issues for months like February  | 
                                                        |
| 1784 | + //where PHP doesn't know what to assume for date.  | 
                                                        |
| 1785 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10437  | 
                                                        |
| 1786 | +			$month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; | 
                                                        |
| 1787 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : '';  | 
                                                        |
| 1788 | + }  | 
                                                        |
| 1789 | + $where = array();  | 
                                                        |
| 1790 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;  | 
                                                        |
| 1791 | + //determine what post_status our condition will have for the query.  | 
                                                        |
| 1792 | +		switch ($status) { | 
                                                        |
| 1793 | + case 'month' :  | 
                                                        |
| 1794 | + case 'today' :  | 
                                                        |
| 1795 | + case null :  | 
                                                        |
| 1796 | + case 'all' :  | 
                                                        |
| 1797 | + break;  | 
                                                        |
| 1798 | + case 'draft' :  | 
                                                        |
| 1799 | +				$where['status'] = array('IN', array('draft', 'auto-draft')); | 
                                                        |
| 1800 | + break;  | 
                                                        |
| 1801 | + default :  | 
                                                        |
| 1802 | + $where['status'] = $status;  | 
                                                        |
| 1803 | + }  | 
                                                        |
| 1804 | + //categories?  | 
                                                        |
| 1805 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0  | 
                                                        |
| 1806 | + ? $this->_req_data['EVT_CAT'] : null;  | 
                                                        |
| 1807 | +		if ( ! empty ($category)) { | 
                                                        |
| 1808 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';  | 
                                                        |
| 1809 | + $where['Term_Taxonomy.term_id'] = $category;  | 
                                                        |
| 1810 | + }  | 
                                                        |
| 1811 | + //date where conditions  | 
                                                        |
| 1812 | +		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); | 
                                                        |
| 1813 | +		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { | 
                                                        |
| 1814 | + $DateTime = new DateTime(  | 
                                                        |
| 1815 | + $year_r . '-' . $month_r . '-01 00:00:00',  | 
                                                        |
| 1816 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone())  | 
                                                        |
| 1817 | + );  | 
                                                        |
| 1818 | +			$start = $DateTime->format(implode(' ', $start_formats)); | 
                                                        |
| 1819 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime  | 
                                                        |
| 1820 | +				->format('t'))->setTime(23, 59, 59) | 
                                                        |
| 1821 | +							->format(implode(' ', $start_formats)); | 
                                                        |
| 1822 | +			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1823 | +		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { | 
                                                        |
| 1824 | +			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); | 
                                                        |
| 1825 | +			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); | 
                                                        |
| 1826 | +			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); | 
                                                        |
| 1827 | +			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1828 | +		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { | 
                                                        |
| 1829 | +			$now = date('Y-m-01'); | 
                                                        |
| 1830 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));  | 
                                                        |
| 1831 | +			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); | 
                                                        |
| 1832 | +			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) | 
                                                        |
| 1833 | + ->setTime(23, 59, 59)  | 
                                                        |
| 1834 | +							->format(implode(' ', $start_formats)); | 
                                                        |
| 1835 | +			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1836 | + }  | 
                                                        |
| 1837 | +		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { | 
                                                        |
| 1838 | + $where['EVT_wp_user'] = get_current_user_id();  | 
                                                        |
| 1839 | +		} else { | 
                                                        |
| 1840 | +			if ( ! isset($where['status'])) { | 
                                                        |
| 1841 | +				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { | 
                                                        |
| 1842 | + $where['OR'] = array(  | 
                                                        |
| 1843 | +						'status*restrict_private' => array('!=', 'private'), | 
                                                        |
| 1844 | + 'AND' => array(  | 
                                                        |
| 1845 | +							'status*inclusive' => array('=', 'private'), | 
                                                        |
| 1846 | + 'EVT_wp_user' => get_current_user_id(),  | 
                                                        |
| 1847 | + ),  | 
                                                        |
| 1848 | + );  | 
                                                        |
| 1849 | + }  | 
                                                        |
| 1850 | + }  | 
                                                        |
| 1851 | + }  | 
                                                        |
| 1852 | +		if (isset($this->_req_data['EVT_wp_user'])) { | 
                                                        |
| 1853 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id()  | 
                                                        |
| 1854 | +				&& EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') | 
                                                        |
| 1855 | +			) { | 
                                                        |
| 1856 | + $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];  | 
                                                        |
| 1857 | + }  | 
                                                        |
| 1858 | + }  | 
                                                        |
| 1859 | + //search query handling  | 
                                                        |
| 1860 | +		if (isset($this->_req_data['s'])) { | 
                                                        |
| 1861 | + $search_string = '%' . $this->_req_data['s'] . '%';  | 
                                                        |
| 1862 | + $where['OR'] = array(  | 
                                                        |
| 1863 | +				'EVT_name'       => array('LIKE', $search_string), | 
                                                        |
| 1864 | +				'EVT_desc'       => array('LIKE', $search_string), | 
                                                        |
| 1865 | +				'EVT_short_desc' => array('LIKE', $search_string), | 
                                                        |
| 1866 | + );  | 
                                                        |
| 1867 | + }  | 
                                                        |
| 1868 | +		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); | 
                                                        |
| 1869 | + $query_params = apply_filters(  | 
                                                        |
| 1870 | + 'FHEE__Events_Admin_Page__get_events__query_params',  | 
                                                        |
| 1871 | + array(  | 
                                                        |
| 1872 | + $where,  | 
                                                        |
| 1873 | + 'limit' => $limit,  | 
                                                        |
| 1874 | + 'order_by' => $orderby,  | 
                                                        |
| 1875 | + 'order' => $order,  | 
                                                        |
| 1876 | + 'group_by' => 'EVT_ID',  | 
                                                        |
| 1877 | + ),  | 
                                                        |
| 1878 | + $this->_req_data  | 
                                                        |
| 1879 | + );  | 
                                                        |
| 1880 | + //let's first check if we have special requests coming in.  | 
                                                        |
| 1881 | +		if (isset($this->_req_data['active_status'])) { | 
                                                        |
| 1882 | +			switch ($this->_req_data['active_status']) { | 
                                                        |
| 1883 | + case 'upcoming' :  | 
                                                        |
| 1884 | + return $EEME->get_upcoming_events($query_params, $count);  | 
                                                        |
| 1885 | + break;  | 
                                                        |
| 1886 | + case 'expired' :  | 
                                                        |
| 1887 | + return $EEME->get_expired_events($query_params, $count);  | 
                                                        |
| 1888 | + break;  | 
                                                        |
| 1889 | + case 'active' :  | 
                                                        |
| 1890 | + return $EEME->get_active_events($query_params, $count);  | 
                                                        |
| 1891 | + break;  | 
                                                        |
| 1892 | + case 'inactive' :  | 
                                                        |
| 1893 | + return $EEME->get_inactive_events($query_params, $count);  | 
                                                        |
| 1894 | + break;  | 
                                                        |
| 1895 | + }  | 
                                                        |
| 1896 | + }  | 
                                                        |
| 1897 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);  | 
                                                        |
| 1898 | + return $events;  | 
                                                        |
| 1899 | + }  | 
                                                        |
| 1900 | +  | 
                                                        |
| 1901 | +  | 
                                                        |
| 1902 | +  | 
                                                        |
| 1903 | + /**  | 
                                                        |
| 1904 | + * handling for WordPress CPT actions (trash, restore, delete)  | 
                                                        |
| 1905 | + *  | 
                                                        |
| 1906 | + * @param string $post_id  | 
                                                        |
| 1907 | + */  | 
                                                        |
| 1908 | + public function trash_cpt_item($post_id)  | 
                                                        |
| 1909 | +	{ | 
                                                        |
| 1910 | + $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1911 | +		$this->_trash_or_restore_event('trash', false); | 
                                                        |
| 1912 | + }  | 
                                                        |
| 1913 | +  | 
                                                        |
| 1914 | +  | 
                                                        |
| 1915 | +  | 
                                                        |
| 1916 | + /**  | 
                                                        |
| 1917 | + * @param string $post_id  | 
                                                        |
| 1918 | + */  | 
                                                        |
| 1919 | + public function restore_cpt_item($post_id)  | 
                                                        |
| 1920 | +	{ | 
                                                        |
| 1921 | + $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1922 | +		$this->_trash_or_restore_event('draft', false); | 
                                                        |
| 1923 | + }  | 
                                                        |
| 1924 | +  | 
                                                        |
| 1925 | +  | 
                                                        |
| 1926 | +  | 
                                                        |
| 1927 | + /**  | 
                                                        |
| 1928 | + * @param string $post_id  | 
                                                        |
| 1929 | + */  | 
                                                        |
| 1930 | + public function delete_cpt_item($post_id)  | 
                                                        |
| 1931 | +	{ | 
                                                        |
| 1932 | + $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1933 | + $this->_delete_event(false);  | 
                                                        |
| 1934 | + }  | 
                                                        |
| 1935 | +  | 
                                                        |
| 1936 | +  | 
                                                        |
| 1937 | +  | 
                                                        |
| 1938 | + /**  | 
                                                        |
| 1939 | + * _trash_or_restore_event  | 
                                                        |
| 1940 | + *  | 
                                                        |
| 1941 | + * @access protected  | 
                                                        |
| 1942 | + * @param string $event_status  | 
                                                        |
| 1943 | + * @param bool $redirect_after  | 
                                                        |
| 1944 | + */  | 
                                                        |
| 1945 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)  | 
                                                        |
| 1946 | +	{ | 
                                                        |
| 1947 | + //determine the event id and set to array.  | 
                                                        |
| 1948 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;  | 
                                                        |
| 1949 | + // loop thru events  | 
                                                        |
| 1950 | +		if ($EVT_ID) { | 
                                                        |
| 1951 | + // clean status  | 
                                                        |
| 1952 | + $event_status = sanitize_key($event_status);  | 
                                                        |
| 1953 | + // grab status  | 
                                                        |
| 1954 | +			if ( ! empty($event_status)) { | 
                                                        |
| 1955 | + $success = $this->_change_event_status($EVT_ID, $event_status);  | 
                                                        |
| 1956 | +			} else { | 
                                                        |
| 1957 | + $success = false;  | 
                                                        |
| 1958 | + $msg = esc_html__(  | 
                                                        |
| 1959 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',  | 
                                                        |
| 1960 | + 'event_espresso'  | 
                                                        |
| 1961 | + );  | 
                                                        |
| 1962 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1963 | + }  | 
                                                        |
| 1964 | +		} else { | 
                                                        |
| 1965 | + $success = false;  | 
                                                        |
| 1966 | + $msg = esc_html__(  | 
                                                        |
| 1967 | + 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',  | 
                                                        |
| 1968 | + 'event_espresso'  | 
                                                        |
| 1969 | + );  | 
                                                        |
| 1970 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1971 | + }  | 
                                                        |
| 1972 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';  | 
                                                        |
| 1973 | +		if ($redirect_after) { | 
                                                        |
| 1974 | +			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); | 
                                                        |
| 1975 | + }  | 
                                                        |
| 1976 | + }  | 
                                                        |
| 1977 | +  | 
                                                        |
| 1978 | +  | 
                                                        |
| 1979 | +  | 
                                                        |
| 1980 | + /**  | 
                                                        |
| 1981 | + * _trash_or_restore_events  | 
                                                        |
| 1982 | + *  | 
                                                        |
| 1983 | + * @access protected  | 
                                                        |
| 1984 | + * @param string $event_status  | 
                                                        |
| 1985 | + * @return void  | 
                                                        |
| 1986 | + */  | 
                                                        |
| 1987 | + protected function _trash_or_restore_events($event_status = 'trash')  | 
                                                        |
| 1988 | +	{ | 
                                                        |
| 1989 | + // clean status  | 
                                                        |
| 1990 | + $event_status = sanitize_key($event_status);  | 
                                                        |
| 1991 | + // grab status  | 
                                                        |
| 1992 | +		if ( ! empty($event_status)) { | 
                                                        |
| 1993 | + $success = true;  | 
                                                        |
| 1994 | + //determine the event id and set to array.  | 
                                                        |
| 1995 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();  | 
                                                        |
| 1996 | + // loop thru events  | 
                                                        |
| 1997 | +			foreach ($EVT_IDs as $EVT_ID) { | 
                                                        |
| 1998 | +				if ($EVT_ID = absint($EVT_ID)) { | 
                                                        |
| 1999 | + $results = $this->_change_event_status($EVT_ID, $event_status);  | 
                                                        |
| 2000 | + $success = $results !== false ? $success : false;  | 
                                                        |
| 2001 | +				} else { | 
                                                        |
| 2002 | + $msg = sprintf(  | 
                                                        |
| 2003 | + esc_html__(  | 
                                                        |
| 2004 | + 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',  | 
                                                        |
| 2005 | + 'event_espresso'  | 
                                                        |
| 2006 | + ),  | 
                                                        |
| 2007 | + $EVT_ID  | 
                                                        |
| 2008 | + );  | 
                                                        |
| 2009 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2010 | + $success = false;  | 
                                                        |
| 2011 | + }  | 
                                                        |
| 2012 | + }  | 
                                                        |
| 2013 | +		} else { | 
                                                        |
| 2014 | + $success = false;  | 
                                                        |
| 2015 | + $msg = esc_html__(  | 
                                                        |
| 2016 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',  | 
                                                        |
| 2017 | + 'event_espresso'  | 
                                                        |
| 2018 | + );  | 
                                                        |
| 2019 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2020 | + }  | 
                                                        |
| 2021 | + // in order to force a pluralized result message we need to send back a success status greater than 1  | 
                                                        |
| 2022 | + $success = $success ? 2 : false;  | 
                                                        |
| 2023 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';  | 
                                                        |
| 2024 | +		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); | 
                                                        |
| 2025 | + }  | 
                                                        |
| 2026 | +  | 
                                                        |
| 2027 | +  | 
                                                        |
| 2028 | +  | 
                                                        |
| 2029 | + /**  | 
                                                        |
| 2030 | + * _trash_or_restore_events  | 
                                                        |
| 2031 | + *  | 
                                                        |
| 2032 | + * @access private  | 
                                                        |
| 2033 | + * @param int $EVT_ID  | 
                                                        |
| 2034 | + * @param string $event_status  | 
                                                        |
| 2035 | + * @return bool  | 
                                                        |
| 2036 | + */  | 
                                                        |
| 2037 | + private function _change_event_status($EVT_ID = 0, $event_status = '')  | 
                                                        |
| 2038 | +	{ | 
                                                        |
| 2039 | + // grab event id  | 
                                                        |
| 2040 | +		if ( ! $EVT_ID) { | 
                                                        |
| 2041 | + $msg = esc_html__(  | 
                                                        |
| 2042 | + 'An error occurred. No Event ID or an invalid Event ID was received.',  | 
                                                        |
| 2043 | + 'event_espresso'  | 
                                                        |
| 2044 | + );  | 
                                                        |
| 2045 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2046 | + return false;  | 
                                                        |
| 2047 | + }  | 
                                                        |
| 2048 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);  | 
                                                        |
| 2049 | + // clean status  | 
                                                        |
| 2050 | + $event_status = sanitize_key($event_status);  | 
                                                        |
| 2051 | + // grab status  | 
                                                        |
| 2052 | +		if (empty($event_status)) { | 
                                                        |
| 2053 | + $msg = esc_html__(  | 
                                                        |
| 2054 | + 'An error occurred. No Event Status or an invalid Event Status was received.',  | 
                                                        |
| 2055 | + 'event_espresso'  | 
                                                        |
| 2056 | + );  | 
                                                        |
| 2057 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2058 | + return false;  | 
                                                        |
| 2059 | + }  | 
                                                        |
| 2060 | + // was event trashed or restored ?  | 
                                                        |
| 2061 | +		switch ($event_status) { | 
                                                        |
| 2062 | + case 'draft' :  | 
                                                        |
| 2063 | + $action = 'restored from the trash';  | 
                                                        |
| 2064 | + $hook = 'AHEE_event_restored_from_trash';  | 
                                                        |
| 2065 | + break;  | 
                                                        |
| 2066 | + case 'trash' :  | 
                                                        |
| 2067 | + $action = 'moved to the trash';  | 
                                                        |
| 2068 | + $hook = 'AHEE_event_moved_to_trash';  | 
                                                        |
| 2069 | + break;  | 
                                                        |
| 2070 | + default :  | 
                                                        |
| 2071 | + $action = 'updated';  | 
                                                        |
| 2072 | + $hook = false;  | 
                                                        |
| 2073 | + }  | 
                                                        |
| 2074 | + //use class to change status  | 
                                                        |
| 2075 | + $this->_cpt_model_obj->set_status($event_status);  | 
                                                        |
| 2076 | + $success = $this->_cpt_model_obj->save();  | 
                                                        |
| 2077 | +		if ($success === false) { | 
                                                        |
| 2078 | +			$msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); | 
                                                        |
| 2079 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2080 | + return false;  | 
                                                        |
| 2081 | + }  | 
                                                        |
| 2082 | +		if ($hook) { | 
                                                        |
| 2083 | + do_action($hook);  | 
                                                        |
| 2084 | + }  | 
                                                        |
| 2085 | + return true;  | 
                                                        |
| 2086 | + }  | 
                                                        |
| 2087 | +  | 
                                                        |
| 2088 | +  | 
                                                        |
| 2089 | +  | 
                                                        |
| 2090 | + /**  | 
                                                        |
| 2091 | + * _delete_event  | 
                                                        |
| 2092 | + *  | 
                                                        |
| 2093 | + * @access protected  | 
                                                        |
| 2094 | + * @param bool $redirect_after  | 
                                                        |
| 2095 | + */  | 
                                                        |
| 2096 | + protected function _delete_event($redirect_after = true)  | 
                                                        |
| 2097 | +	{ | 
                                                        |
| 2098 | + //determine the event id and set to array.  | 
                                                        |
| 2099 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;  | 
                                                        |
| 2100 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;  | 
                                                        |
| 2101 | + // loop thru events  | 
                                                        |
| 2102 | +		if ($EVT_ID) { | 
                                                        |
| 2103 | + $success = $this->_permanently_delete_event($EVT_ID);  | 
                                                        |
| 2104 | + // get list of events with no prices  | 
                                                        |
| 2105 | +			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); | 
                                                        |
| 2106 | + // remove this event from the list of events with no prices  | 
                                                        |
| 2107 | +			if (isset($espresso_no_ticket_prices[$EVT_ID])) { | 
                                                        |
| 2108 | + unset($espresso_no_ticket_prices[$EVT_ID]);  | 
                                                        |
| 2109 | + }  | 
                                                        |
| 2110 | +			update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); | 
                                                        |
| 2111 | +		} else { | 
                                                        |
| 2112 | + $success = false;  | 
                                                        |
| 2113 | + $msg = esc_html__(  | 
                                                        |
| 2114 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',  | 
                                                        |
| 2115 | + 'event_espresso'  | 
                                                        |
| 2116 | + );  | 
                                                        |
| 2117 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2118 | + }  | 
                                                        |
| 2119 | +		if ($redirect_after) { | 
                                                        |
| 2120 | + $this->_redirect_after_action(  | 
                                                        |
| 2121 | + $success,  | 
                                                        |
| 2122 | + 'Event',  | 
                                                        |
| 2123 | + 'deleted',  | 
                                                        |
| 2124 | +				array('action' => 'default', 'status' => 'trash') | 
                                                        |
| 2125 | + );  | 
                                                        |
| 2126 | + }  | 
                                                        |
| 2127 | + }  | 
                                                        |
| 2128 | +  | 
                                                        |
| 2129 | +  | 
                                                        |
| 2130 | +  | 
                                                        |
| 2131 | + /**  | 
                                                        |
| 2132 | + * _delete_events  | 
                                                        |
| 2133 | + *  | 
                                                        |
| 2134 | + * @access protected  | 
                                                        |
| 2135 | + * @return void  | 
                                                        |
| 2136 | + */  | 
                                                        |
| 2137 | + protected function _delete_events()  | 
                                                        |
| 2138 | +	{ | 
                                                        |
| 2139 | + $success = true;  | 
                                                        |
| 2140 | + // get list of events with no prices  | 
                                                        |
| 2141 | +		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); | 
                                                        |
| 2142 | + //determine the event id and set to array.  | 
                                                        |
| 2143 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();  | 
                                                        |
| 2144 | + // loop thru events  | 
                                                        |
| 2145 | +		foreach ($EVT_IDs as $EVT_ID) { | 
                                                        |
| 2146 | + $EVT_ID = absint($EVT_ID);  | 
                                                        |
| 2147 | +			if ($EVT_ID) { | 
                                                        |
| 2148 | + $results = $this->_permanently_delete_event($EVT_ID);  | 
                                                        |
| 2149 | + $success = $results !== false ? $success : false;  | 
                                                        |
| 2150 | + // remove this event from the list of events with no prices  | 
                                                        |
| 2151 | + unset($espresso_no_ticket_prices[$EVT_ID]);  | 
                                                        |
| 2152 | +			} else { | 
                                                        |
| 2153 | + $success = false;  | 
                                                        |
| 2154 | + $msg = esc_html__(  | 
                                                        |
| 2155 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',  | 
                                                        |
| 2156 | + 'event_espresso'  | 
                                                        |
| 2157 | + );  | 
                                                        |
| 2158 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2159 | + }  | 
                                                        |
| 2160 | + }  | 
                                                        |
| 2161 | +		update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); | 
                                                        |
| 2162 | + // in order to force a pluralized result message we need to send back a success status greater than 1  | 
                                                        |
| 2163 | + $success = $success ? 2 : false;  | 
                                                        |
| 2164 | +		$this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); | 
                                                        |
| 2165 | + }  | 
                                                        |
| 2166 | +  | 
                                                        |
| 2167 | +  | 
                                                        |
| 2168 | +  | 
                                                        |
| 2169 | + /**  | 
                                                        |
| 2170 | + * _permanently_delete_event  | 
                                                        |
| 2171 | + *  | 
                                                        |
| 2172 | + * @access private  | 
                                                        |
| 2173 | + * @param int $EVT_ID  | 
                                                        |
| 2174 | + * @return bool  | 
                                                        |
| 2175 | + */  | 
                                                        |
| 2176 | + private function _permanently_delete_event($EVT_ID = 0)  | 
                                                        |
| 2177 | +	{ | 
                                                        |
| 2178 | + // grab event id  | 
                                                        |
| 2179 | +		if ( ! $EVT_ID) { | 
                                                        |
| 2180 | + $msg = esc_html__(  | 
                                                        |
| 2181 | + 'An error occurred. No Event ID or an invalid Event ID was received.',  | 
                                                        |
| 2182 | + 'event_espresso'  | 
                                                        |
| 2183 | + );  | 
                                                        |
| 2184 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2185 | + return false;  | 
                                                        |
| 2186 | + }  | 
                                                        |
| 2187 | + if (  | 
                                                        |
| 2188 | + ! $this->_cpt_model_obj instanceof EE_Event  | 
                                                        |
| 2189 | + || $this->_cpt_model_obj->ID() !== $EVT_ID  | 
                                                        |
| 2190 | +		) { | 
                                                        |
| 2191 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);  | 
                                                        |
| 2192 | + }  | 
                                                        |
| 2193 | +		if ( ! $this->_cpt_model_obj instanceof EE_Event) { | 
                                                        |
| 2194 | + return false;  | 
                                                        |
| 2195 | + }  | 
                                                        |
| 2196 | + //need to delete related tickets and prices first.  | 
                                                        |
| 2197 | +		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); | 
                                                        |
| 2198 | +		foreach ($datetimes as $datetime) { | 
                                                        |
| 2199 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');  | 
                                                        |
| 2200 | +			$tickets = $datetime->get_many_related('Ticket'); | 
                                                        |
| 2201 | +			foreach ($tickets as $ticket) { | 
                                                        |
| 2202 | + $ticket->_remove_relation_to($datetime, 'Datetime');  | 
                                                        |
| 2203 | +				$ticket->delete_related_permanently('Price'); | 
                                                        |
| 2204 | + $ticket->delete_permanently();  | 
                                                        |
| 2205 | + }  | 
                                                        |
| 2206 | + $datetime->delete();  | 
                                                        |
| 2207 | + }  | 
                                                        |
| 2208 | + //what about related venues or terms?  | 
                                                        |
| 2209 | +		$venues = $this->_cpt_model_obj->get_many_related('Venue'); | 
                                                        |
| 2210 | +		foreach ($venues as $venue) { | 
                                                        |
| 2211 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');  | 
                                                        |
| 2212 | + }  | 
                                                        |
| 2213 | + //any attached question groups?  | 
                                                        |
| 2214 | +		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); | 
                                                        |
| 2215 | +		if ( ! empty($question_groups)) { | 
                                                        |
| 2216 | +			foreach ($question_groups as $question_group) { | 
                                                        |
| 2217 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');  | 
                                                        |
| 2218 | + }  | 
                                                        |
| 2219 | + }  | 
                                                        |
| 2220 | + //Message Template Groups  | 
                                                        |
| 2221 | +		$this->_cpt_model_obj->_remove_relations('Message_Template_Group'); | 
                                                        |
| 2222 | + /** @type EE_Term_Taxonomy[] $term_taxonomies */  | 
                                                        |
| 2223 | + $term_taxonomies = $this->_cpt_model_obj->term_taxonomies();  | 
                                                        |
| 2224 | +		foreach ($term_taxonomies as $term_taxonomy) { | 
                                                        |
| 2225 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);  | 
                                                        |
| 2226 | + }  | 
                                                        |
| 2227 | + $success = $this->_cpt_model_obj->delete_permanently();  | 
                                                        |
| 2228 | + // did it all go as planned ?  | 
                                                        |
| 2229 | +		if ($success) { | 
                                                        |
| 2230 | +			$msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); | 
                                                        |
| 2231 | + EE_Error::add_success($msg);  | 
                                                        |
| 2232 | +		} else { | 
                                                        |
| 2233 | + $msg = sprintf(  | 
                                                        |
| 2234 | +				esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), | 
                                                        |
| 2235 | + $EVT_ID  | 
                                                        |
| 2236 | + );  | 
                                                        |
| 2237 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2238 | + return false;  | 
                                                        |
| 2239 | + }  | 
                                                        |
| 2240 | +		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); | 
                                                        |
| 2241 | + return true;  | 
                                                        |
| 2242 | + }  | 
                                                        |
| 2243 | +  | 
                                                        |
| 2244 | +  | 
                                                        |
| 2245 | +  | 
                                                        |
| 2246 | + /**  | 
                                                        |
| 2247 | + * get total number of events  | 
                                                        |
| 2248 | + *  | 
                                                        |
| 2249 | + * @access public  | 
                                                        |
| 2250 | + * @return int  | 
                                                        |
| 2251 | + */  | 
                                                        |
| 2252 | + public function total_events()  | 
                                                        |
| 2253 | +	{ | 
                                                        |
| 2254 | +		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); | 
                                                        |
| 2255 | + return $count;  | 
                                                        |
| 2256 | + }  | 
                                                        |
| 2257 | +  | 
                                                        |
| 2258 | +  | 
                                                        |
| 2259 | +  | 
                                                        |
| 2260 | + /**  | 
                                                        |
| 2261 | + * get total number of draft events  | 
                                                        |
| 2262 | + *  | 
                                                        |
| 2263 | + * @access public  | 
                                                        |
| 2264 | + * @return int  | 
                                                        |
| 2265 | + */  | 
                                                        |
| 2266 | + public function total_events_draft()  | 
                                                        |
| 2267 | +	{ | 
                                                        |
| 2268 | + $where = array(  | 
                                                        |
| 2269 | +			'status' => array('IN', array('draft', 'auto-draft')), | 
                                                        |
| 2270 | + );  | 
                                                        |
| 2271 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);  | 
                                                        |
| 2272 | + return $count;  | 
                                                        |
| 2273 | + }  | 
                                                        |
| 2274 | +  | 
                                                        |
| 2275 | +  | 
                                                        |
| 2276 | +  | 
                                                        |
| 2277 | + /**  | 
                                                        |
| 2278 | + * get total number of trashed events  | 
                                                        |
| 2279 | + *  | 
                                                        |
| 2280 | + * @access public  | 
                                                        |
| 2281 | + * @return int  | 
                                                        |
| 2282 | + */  | 
                                                        |
| 2283 | + public function total_trashed_events()  | 
                                                        |
| 2284 | +	{ | 
                                                        |
| 2285 | + $where = array(  | 
                                                        |
| 2286 | + 'status' => 'trash',  | 
                                                        |
| 2287 | + );  | 
                                                        |
| 2288 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);  | 
                                                        |
| 2289 | + return $count;  | 
                                                        |
| 2290 | + }  | 
                                                        |
| 2291 | +  | 
                                                        |
| 2292 | +  | 
                                                        |
| 2293 | + /**  | 
                                                        |
| 2294 | + * _default_event_settings  | 
                                                        |
| 2295 | + * This generates the Default Settings Tab  | 
                                                        |
| 2296 | + *  | 
                                                        |
| 2297 | + * @return void  | 
                                                        |
| 2298 | + * @throws EE_Error  | 
                                                        |
| 2299 | + */  | 
                                                        |
| 2300 | + protected function _default_event_settings()  | 
                                                        |
| 2301 | +	{ | 
                                                        |
| 2302 | +		$this->_set_add_edit_form_tags('update_default_event_settings'); | 
                                                        |
| 2303 | + $this->_set_publish_post_box_vars(null, false, false, null, false);  | 
                                                        |
| 2304 | + $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();  | 
                                                        |
| 2305 | + $this->display_admin_page_with_sidebar();  | 
                                                        |
| 2306 | + }  | 
                                                        |
| 2307 | +  | 
                                                        |
| 2308 | +  | 
                                                        |
| 2309 | + /**  | 
                                                        |
| 2310 | + * Return the form for event settings.  | 
                                                        |
| 2311 | + * @return EE_Form_Section_Proper  | 
                                                        |
| 2312 | + */  | 
                                                        |
| 2313 | + protected function _default_event_settings_form()  | 
                                                        |
| 2314 | +	{ | 
                                                        |
| 2315 | + $registration_config = EE_Registry::instance()->CFG->registration;  | 
                                                        |
| 2316 | + $registration_stati_for_selection = EEM_Registration::reg_status_array(  | 
                                                        |
| 2317 | + //exclude  | 
                                                        |
| 2318 | + array(  | 
                                                        |
| 2319 | + EEM_Registration::status_id_cancelled,  | 
                                                        |
| 2320 | + EEM_Registration::status_id_declined,  | 
                                                        |
| 2321 | + EEM_Registration::status_id_incomplete,  | 
                                                        |
| 2322 | + EEM_Registration::status_id_wait_list,  | 
                                                        |
| 2323 | + ),  | 
                                                        |
| 2324 | + true  | 
                                                        |
| 2325 | + );  | 
                                                        |
| 2326 | + return new EE_Form_Section_Proper(  | 
                                                        |
| 2327 | + array(  | 
                                                        |
| 2328 | + 'name' => 'update_default_event_settings',  | 
                                                        |
| 2329 | + 'html_id' => 'update_default_event_settings',  | 
                                                        |
| 2330 | + 'html_class' => 'form-table',  | 
                                                        |
| 2331 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(),  | 
                                                        |
| 2332 | + 'subsections' => apply_filters(  | 
                                                        |
| 2333 | + 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',  | 
                                                        |
| 2334 | + array(  | 
                                                        |
| 2335 | + 'default_reg_status' => new EE_Select_Input(  | 
                                                        |
| 2336 | + $registration_stati_for_selection,  | 
                                                        |
| 2337 | + array(  | 
                                                        |
| 2338 | + 'default' => isset($registration_config->default_STS_ID)  | 
                                                        |
| 2339 | + && array_key_exists(  | 
                                                        |
| 2340 | + $registration_config->default_STS_ID,  | 
                                                        |
| 2341 | + $registration_stati_for_selection  | 
                                                        |
| 2342 | + )  | 
                                                        |
| 2343 | + ? sanitize_text_field($registration_config->default_STS_ID)  | 
                                                        |
| 2344 | + : EEM_Registration::status_id_pending_payment,  | 
                                                        |
| 2345 | +								'html_label_text' => esc_html__('Default Registration Status', 'event_espresso') | 
                                                        |
| 2346 | + . EEH_Template::get_help_tab_link(  | 
                                                        |
| 2347 | + 'default_settings_status_help_tab'  | 
                                                        |
| 2348 | + ),  | 
                                                        |
| 2349 | + 'html_help_text' => esc_html__(  | 
                                                        |
| 2350 | + '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.',  | 
                                                        |
| 2351 | + 'event_espresso'  | 
                                                        |
| 2352 | + )  | 
                                                        |
| 2353 | + )  | 
                                                        |
| 2354 | + ),  | 
                                                        |
| 2355 | + 'default_max_tickets' => new EE_Integer_Input(  | 
                                                        |
| 2356 | + array(  | 
                                                        |
| 2357 | + 'default' => isset($registration_config->default_maximum_number_of_tickets)  | 
                                                        |
| 2358 | + ? $registration_config->default_maximum_number_of_tickets  | 
                                                        |
| 2359 | + : EEM_Event::get_default_additional_limit(),  | 
                                                        |
| 2360 | + 'html_label_text' => esc_html__(  | 
                                                        |
| 2361 | + 'Default Maximum Tickets Allowed Per Order:',  | 
                                                        |
| 2362 | + 'event_espresso'  | 
                                                        |
| 2363 | + ) . EEH_Template::get_help_tab_link(  | 
                                                        |
| 2364 | + 'default_maximum_tickets_help_tab"'  | 
                                                        |
| 2365 | + ),  | 
                                                        |
| 2366 | + 'html_help_text' => esc_html__(  | 
                                                        |
| 2367 | + 'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',  | 
                                                        |
| 2368 | + 'event_espresso'  | 
                                                        |
| 2369 | + )  | 
                                                        |
| 2370 | + )  | 
                                                        |
| 2371 | + )  | 
                                                        |
| 2372 | + )  | 
                                                        |
| 2373 | + )  | 
                                                        |
| 2374 | + )  | 
                                                        |
| 2375 | + );  | 
                                                        |
| 2376 | + }  | 
                                                        |
| 2377 | +  | 
                                                        |
| 2378 | +  | 
                                                        |
| 2379 | + /**  | 
                                                        |
| 2380 | + * _update_default_event_settings  | 
                                                        |
| 2381 | + *  | 
                                                        |
| 2382 | + * @access protected  | 
                                                        |
| 2383 | + * @return void  | 
                                                        |
| 2384 | + * @throws EE_Error  | 
                                                        |
| 2385 | + */  | 
                                                        |
| 2386 | + protected function _update_default_event_settings()  | 
                                                        |
| 2387 | +	{ | 
                                                        |
| 2388 | + $registration_config = EE_Registry::instance()->CFG->registration;  | 
                                                        |
| 2389 | + $form = $this->_default_event_settings_form();  | 
                                                        |
| 2390 | +		if ($form->was_submitted()) { | 
                                                        |
| 2391 | + $form->receive_form_submission();  | 
                                                        |
| 2392 | +			if ($form->is_valid()) { | 
                                                        |
| 2393 | + $valid_data = $form->valid_data();  | 
                                                        |
| 2394 | +				if (isset($valid_data['default_reg_status'])) { | 
                                                        |
| 2395 | + $registration_config->default_STS_ID = $valid_data['default_reg_status'];  | 
                                                        |
| 2396 | + }  | 
                                                        |
| 2397 | +				if (isset($valid_data['default_max_tickets'])) { | 
                                                        |
| 2398 | + $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];  | 
                                                        |
| 2399 | + }  | 
                                                        |
| 2400 | + //update because data was valid!  | 
                                                        |
| 2401 | + EE_Registry::instance()->CFG->update_espresso_config();  | 
                                                        |
| 2402 | + EE_Error::overwrite_success();  | 
                                                        |
| 2403 | + EE_Error::add_success(  | 
                                                        |
| 2404 | +					__('Default Event Settings were updated', 'event_espresso') | 
                                                        |
| 2405 | + );  | 
                                                        |
| 2406 | + }  | 
                                                        |
| 2407 | + }  | 
                                                        |
| 2408 | +		$this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true); | 
                                                        |
| 2409 | + }  | 
                                                        |
| 2410 | +  | 
                                                        |
| 2411 | +  | 
                                                        |
| 2412 | +  | 
                                                        |
| 2413 | + /************* Templates *************/  | 
                                                        |
| 2414 | + protected function _template_settings()  | 
                                                        |
| 2415 | +	{ | 
                                                        |
| 2416 | +		$this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); | 
                                                        |
| 2417 | + $this->_template_args['preview_img'] = '<img src="'  | 
                                                        |
| 2418 | + . EVENTS_ASSETS_URL  | 
                                                        |
| 2419 | + . DS  | 
                                                        |
| 2420 | + . 'images'  | 
                                                        |
| 2421 | + . DS  | 
                                                        |
| 2422 | + . 'caffeinated_template_features.jpg" alt="'  | 
                                                        |
| 2423 | +											   . esc_attr__('Template Settings Preview screenshot', 'event_espresso') | 
                                                        |
| 2424 | + . '" />';  | 
                                                        |
| 2425 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__(  | 
                                                        |
| 2426 | + '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.',  | 
                                                        |
| 2427 | + 'event_espresso'  | 
                                                        |
| 2428 | + ) . '</strong>';  | 
                                                        |
| 2429 | +		$this->display_admin_caf_preview_page('template_settings_tab'); | 
                                                        |
| 2430 | + }  | 
                                                        |
| 2431 | +  | 
                                                        |
| 2432 | +  | 
                                                        |
| 2433 | + /** Event Category Stuff **/  | 
                                                        |
| 2434 | + /**  | 
                                                        |
| 2435 | + * set the _category property with the category object for the loaded page.  | 
                                                        |
| 2436 | + *  | 
                                                        |
| 2437 | + * @access private  | 
                                                        |
| 2438 | + * @return void  | 
                                                        |
| 2439 | + */  | 
                                                        |
| 2440 | + private function _set_category_object()  | 
                                                        |
| 2441 | +	{ | 
                                                        |
| 2442 | +		if (isset($this->_category->id) && ! empty($this->_category->id)) { | 
                                                        |
| 2443 | + return;  | 
                                                        |
| 2444 | + } //already have the category object so get out.  | 
                                                        |
| 2445 | + //set default category object  | 
                                                        |
| 2446 | + $this->_set_empty_category_object();  | 
                                                        |
| 2447 | + //only set if we've got an id  | 
                                                        |
| 2448 | +		if ( ! isset($this->_req_data['EVT_CAT_ID'])) { | 
                                                        |
| 2449 | + return;  | 
                                                        |
| 2450 | + }  | 
                                                        |
| 2451 | + $category_id = absint($this->_req_data['EVT_CAT_ID']);  | 
                                                        |
| 2452 | + $term = get_term($category_id, 'espresso_event_categories');  | 
                                                        |
| 2453 | +		if ( ! empty($term)) { | 
                                                        |
| 2454 | + $this->_category->category_name = $term->name;  | 
                                                        |
| 2455 | + $this->_category->category_identifier = $term->slug;  | 
                                                        |
| 2456 | + $this->_category->category_desc = $term->description;  | 
                                                        |
| 2457 | + $this->_category->id = $term->term_id;  | 
                                                        |
| 2458 | + $this->_category->parent = $term->parent;  | 
                                                        |
| 2459 | + }  | 
                                                        |
| 2460 | + }  | 
                                                        |
| 2461 | +  | 
                                                        |
| 2462 | +  | 
                                                        |
| 2463 | + /**  | 
                                                        |
| 2464 | + * Clears out category properties.  | 
                                                        |
| 2465 | + */  | 
                                                        |
| 2466 | + private function _set_empty_category_object()  | 
                                                        |
| 2467 | +	{ | 
                                                        |
| 2468 | + $this->_category = new stdClass();  | 
                                                        |
| 2469 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';  | 
                                                        |
| 2470 | + $this->_category->id = $this->_category->parent = 0;  | 
                                                        |
| 2471 | + }  | 
                                                        |
| 2472 | +  | 
                                                        |
| 2473 | +  | 
                                                        |
| 2474 | + /**  | 
                                                        |
| 2475 | + * @throws EE_Error  | 
                                                        |
| 2476 | + */  | 
                                                        |
| 2477 | + protected function _category_list_table()  | 
                                                        |
| 2478 | +	{ | 
                                                        |
| 2479 | +		do_action('AHEE_log', __FILE__, __FUNCTION__, ''); | 
                                                        |
| 2480 | +		$this->_search_btn_label = esc_html__('Categories', 'event_espresso'); | 
                                                        |
| 2481 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(  | 
                                                        |
| 2482 | + 'add_category',  | 
                                                        |
| 2483 | + 'add_category',  | 
                                                        |
| 2484 | + array(),  | 
                                                        |
| 2485 | + 'add-new-h2'  | 
                                                        |
| 2486 | + );  | 
                                                        |
| 2487 | + $this->display_admin_list_table_page_with_sidebar();  | 
                                                        |
| 2488 | + }  | 
                                                        |
| 2489 | +  | 
                                                        |
| 2490 | +  | 
                                                        |
| 2491 | +  | 
                                                        |
| 2492 | + /**  | 
                                                        |
| 2493 | + * Output category details view.  | 
                                                        |
| 2494 | + */  | 
                                                        |
| 2495 | + protected function _category_details($view)  | 
                                                        |
| 2496 | +	{ | 
                                                        |
| 2497 | + //load formatter helper  | 
                                                        |
| 2498 | + //load field generator helper  | 
                                                        |
| 2499 | + $route = $view == 'edit' ? 'update_category' : 'insert_category';  | 
                                                        |
| 2500 | + $this->_set_add_edit_form_tags($route);  | 
                                                        |
| 2501 | + $this->_set_category_object();  | 
                                                        |
| 2502 | + $id = ! empty($this->_category->id) ? $this->_category->id : '';  | 
                                                        |
| 2503 | + $delete_action = 'delete_category';  | 
                                                        |
| 2504 | + //custom redirect  | 
                                                        |
| 2505 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 2506 | +			array('action' => 'category_list'), | 
                                                        |
| 2507 | + $this->_admin_base_url  | 
                                                        |
| 2508 | + );  | 
                                                        |
| 2509 | +		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); | 
                                                        |
| 2510 | + //take care of contents  | 
                                                        |
| 2511 | + $this->_template_args['admin_page_content'] = $this->_category_details_content();  | 
                                                        |
| 2512 | + $this->display_admin_page_with_sidebar();  | 
                                                        |
| 2513 | + }  | 
                                                        |
| 2514 | +  | 
                                                        |
| 2515 | +  | 
                                                        |
| 2516 | +  | 
                                                        |
| 2517 | + /**  | 
                                                        |
| 2518 | + * Output category details content.  | 
                                                        |
| 2519 | + */  | 
                                                        |
| 2520 | + protected function _category_details_content()  | 
                                                        |
| 2521 | +	{ | 
                                                        |
| 2522 | + $editor_args['category_desc'] = array(  | 
                                                        |
| 2523 | + 'type' => 'wp_editor',  | 
                                                        |
| 2524 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc),  | 
                                                        |
| 2525 | + 'class' => 'my_editor_custom',  | 
                                                        |
| 2526 | +			'wpeditor_args' => array('media_buttons' => false), | 
                                                        |
| 2527 | + );  | 
                                                        |
| 2528 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');  | 
                                                        |
| 2529 | + $all_terms = get_terms(  | 
                                                        |
| 2530 | +			array('espresso_event_categories'), | 
                                                        |
| 2531 | +			array('hide_empty' => 0, 'exclude' => array($this->_category->id)) | 
                                                        |
| 2532 | + );  | 
                                                        |
| 2533 | + //setup category select for term parents.  | 
                                                        |
| 2534 | + $category_select_values[] = array(  | 
                                                        |
| 2535 | +			'text' => esc_html__('No Parent', 'event_espresso'), | 
                                                        |
| 2536 | + 'id' => 0,  | 
                                                        |
| 2537 | + );  | 
                                                        |
| 2538 | +		foreach ($all_terms as $term) { | 
                                                        |
| 2539 | + $category_select_values[] = array(  | 
                                                        |
| 2540 | + 'text' => $term->name,  | 
                                                        |
| 2541 | + 'id' => $term->term_id,  | 
                                                        |
| 2542 | + );  | 
                                                        |
| 2543 | + }  | 
                                                        |
| 2544 | + $category_select = EEH_Form_Fields::select_input(  | 
                                                        |
| 2545 | + 'category_parent',  | 
                                                        |
| 2546 | + $category_select_values,  | 
                                                        |
| 2547 | + $this->_category->parent  | 
                                                        |
| 2548 | + );  | 
                                                        |
| 2549 | + $template_args = array(  | 
                                                        |
| 2550 | + 'category' => $this->_category,  | 
                                                        |
| 2551 | + 'category_select' => $category_select,  | 
                                                        |
| 2552 | +			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), | 
                                                        |
| 2553 | + 'category_desc_editor' => $_wp_editor['category_desc']['field'],  | 
                                                        |
| 2554 | + 'disable' => '',  | 
                                                        |
| 2555 | + 'disabled_message' => false,  | 
                                                        |
| 2556 | + );  | 
                                                        |
| 2557 | + $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';  | 
                                                        |
| 2558 | + return EEH_Template::display_template($template, $template_args, true);  | 
                                                        |
| 2559 | + }  | 
                                                        |
| 2560 | +  | 
                                                        |
| 2561 | +  | 
                                                        |
| 2562 | + /**  | 
                                                        |
| 2563 | + * Handles deleting categories.  | 
                                                        |
| 2564 | + */  | 
                                                        |
| 2565 | + protected function _delete_categories()  | 
                                                        |
| 2566 | +	{ | 
                                                        |
| 2567 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID']  | 
                                                        |
| 2568 | + : (array)$this->_req_data['category_id'];  | 
                                                        |
| 2569 | +		foreach ($cat_ids as $cat_id) { | 
                                                        |
| 2570 | + $this->_delete_category($cat_id);  | 
                                                        |
| 2571 | + }  | 
                                                        |
| 2572 | + //doesn't matter what page we're coming from... we're going to the same place after delete.  | 
                                                        |
| 2573 | + $query_args = array(  | 
                                                        |
| 2574 | + 'action' => 'category_list',  | 
                                                        |
| 2575 | + );  | 
                                                        |
| 2576 | + $this->_redirect_after_action(0, '', '', $query_args);  | 
                                                        |
| 2577 | + }  | 
                                                        |
| 2578 | +  | 
                                                        |
| 2579 | +  | 
                                                        |
| 2580 | +  | 
                                                        |
| 2581 | + /**  | 
                                                        |
| 2582 | + * Handles deleting specific category.  | 
                                                        |
| 2583 | + * @param int $cat_id  | 
                                                        |
| 2584 | + */  | 
                                                        |
| 2585 | + protected function _delete_category($cat_id)  | 
                                                        |
| 2586 | +	{ | 
                                                        |
| 2587 | + $cat_id = absint($cat_id);  | 
                                                        |
| 2588 | + wp_delete_term($cat_id, 'espresso_event_categories');  | 
                                                        |
| 2589 | + }  | 
                                                        |
| 2590 | +  | 
                                                        |
| 2591 | +  | 
                                                        |
| 2592 | +  | 
                                                        |
| 2593 | + /**  | 
                                                        |
| 2594 | + * Handles triggering the update or insertion of a new category.  | 
                                                        |
| 2595 | + * @param bool $new_category true means we're triggering the insert of a new category.  | 
                                                        |
| 2596 | + */  | 
                                                        |
| 2597 | + protected function _insert_or_update_category($new_category)  | 
                                                        |
| 2598 | +	{ | 
                                                        |
| 2599 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);  | 
                                                        |
| 2600 | + $success = 0; //we already have a success message so lets not send another.  | 
                                                        |
| 2601 | +		if ($cat_id) { | 
                                                        |
| 2602 | + $query_args = array(  | 
                                                        |
| 2603 | + 'action' => 'edit_category',  | 
                                                        |
| 2604 | + 'EVT_CAT_ID' => $cat_id,  | 
                                                        |
| 2605 | + );  | 
                                                        |
| 2606 | +		} else { | 
                                                        |
| 2607 | +			$query_args = array('action' => 'add_category'); | 
                                                        |
| 2608 | + }  | 
                                                        |
| 2609 | + $this->_redirect_after_action($success, '', '', $query_args, true);  | 
                                                        |
| 2610 | + }  | 
                                                        |
| 2611 | +  | 
                                                        |
| 2612 | +  | 
                                                        |
| 2613 | +  | 
                                                        |
| 2614 | + /**  | 
                                                        |
| 2615 | + * Inserts or updates category  | 
                                                        |
| 2616 | + * @param bool $update (true indicates we're updating a category).  | 
                                                        |
| 2617 | + * @return bool|mixed|string  | 
                                                        |
| 2618 | + */  | 
                                                        |
| 2619 | + private function _insert_category($update = false)  | 
                                                        |
| 2620 | +	{ | 
                                                        |
| 2621 | + $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';  | 
                                                        |
| 2622 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';  | 
                                                        |
| 2623 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';  | 
                                                        |
| 2624 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;  | 
                                                        |
| 2625 | +		if (empty($category_name)) { | 
                                                        |
| 2626 | +			$msg = esc_html__('You must add a name for the category.', 'event_espresso'); | 
                                                        |
| 2627 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2628 | + return false;  | 
                                                        |
| 2629 | + }  | 
                                                        |
| 2630 | + $term_args = array(  | 
                                                        |
| 2631 | + 'name' => $category_name,  | 
                                                        |
| 2632 | + 'description' => $category_desc,  | 
                                                        |
| 2633 | + 'parent' => $category_parent,  | 
                                                        |
| 2634 | + );  | 
                                                        |
| 2635 | + //was the category_identifier input disabled?  | 
                                                        |
| 2636 | +		if (isset($this->_req_data['category_identifier'])) { | 
                                                        |
| 2637 | + $term_args['slug'] = $this->_req_data['category_identifier'];  | 
                                                        |
| 2638 | + }  | 
                                                        |
| 2639 | + $insert_ids = $update  | 
                                                        |
| 2640 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args)  | 
                                                        |
| 2641 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args);  | 
                                                        |
| 2642 | +		if ( ! is_array($insert_ids)) { | 
                                                        |
| 2643 | + $msg = esc_html__(  | 
                                                        |
| 2644 | + 'An error occurred and the category has not been saved to the database.',  | 
                                                        |
| 2645 | + 'event_espresso'  | 
                                                        |
| 2646 | + );  | 
                                                        |
| 2647 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2648 | +		} else { | 
                                                        |
| 2649 | + $cat_id = $insert_ids['term_id'];  | 
                                                        |
| 2650 | +			$msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); | 
                                                        |
| 2651 | + EE_Error::add_success($msg);  | 
                                                        |
| 2652 | + }  | 
                                                        |
| 2653 | + return $cat_id;  | 
                                                        |
| 2654 | + }  | 
                                                        |
| 2655 | +  | 
                                                        |
| 2656 | +  | 
                                                        |
| 2657 | +  | 
                                                        |
| 2658 | + /**  | 
                                                        |
| 2659 | + * Gets categories or count of categories matching the arguments in the request.  | 
                                                        |
| 2660 | + * @param int $per_page  | 
                                                        |
| 2661 | + * @param int $current_page  | 
                                                        |
| 2662 | + * @param bool $count  | 
                                                        |
| 2663 | + * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int  | 
                                                        |
| 2664 | + */  | 
                                                        |
| 2665 | + public function get_categories($per_page = 10, $current_page = 1, $count = false)  | 
                                                        |
| 2666 | +	{ | 
                                                        |
| 2667 | + //testing term stuff  | 
                                                        |
| 2668 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';  | 
                                                        |
| 2669 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';  | 
                                                        |
| 2670 | + $limit = ($current_page - 1) * $per_page;  | 
                                                        |
| 2671 | +		$where = array('taxonomy' => 'espresso_event_categories'); | 
                                                        |
| 2672 | +		if (isset($this->_req_data['s'])) { | 
                                                        |
| 2673 | + $sstr = '%' . $this->_req_data['s'] . '%';  | 
                                                        |
| 2674 | + $where['OR'] = array(  | 
                                                        |
| 2675 | +				'Term.name'   => array('LIKE', $sstr), | 
                                                        |
| 2676 | +				'description' => array('LIKE', $sstr), | 
                                                        |
| 2677 | + );  | 
                                                        |
| 2678 | + }  | 
                                                        |
| 2679 | + $query_params = array(  | 
                                                        |
| 2680 | + $where,  | 
                                                        |
| 2681 | + 'order_by' => array($orderby => $order),  | 
                                                        |
| 2682 | + 'limit' => $limit . ',' . $per_page,  | 
                                                        |
| 2683 | +			'force_join' => array('Term'), | 
                                                        |
| 2684 | + );  | 
                                                        |
| 2685 | + $categories = $count  | 
                                                        |
| 2686 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')  | 
                                                        |
| 2687 | + : EEM_Term_Taxonomy::instance()->get_all($query_params);  | 
                                                        |
| 2688 | + return $categories;  | 
                                                        |
| 2689 | + }  | 
                                                        |
| 2690 | +  | 
                                                        |
| 2691 | + /* end category stuff */  | 
                                                        |
| 2692 | + /**************/  | 
                                                        |
| 2693 | +  | 
                                                        |
| 2694 | +  | 
                                                        |
| 2695 | + /**  | 
                                                        |
| 2696 | + * Callback for the `ee_save_timezone_setting` ajax action.  | 
                                                        |
| 2697 | + * @throws EE_Error  | 
                                                        |
| 2698 | + */  | 
                                                        |
| 2699 | + public function save_timezonestring_setting()  | 
                                                        |
| 2700 | +	{ | 
                                                        |
| 2701 | + $timezone_string = isset($this->_req_data['timezone_selected'])  | 
                                                        |
| 2702 | + ? $this->_req_data['timezone_selected']  | 
                                                        |
| 2703 | + : '';  | 
                                                        |
| 2704 | + if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false))  | 
                                                        |
| 2705 | +		{ | 
                                                        |
| 2706 | + EE_Error::add_error(  | 
                                                        |
| 2707 | +				esc_html('An invalid timezone string submitted.', 'event_espresso'), | 
                                                        |
| 2708 | + __FILE__, __FUNCTION__, __LINE__  | 
                                                        |
| 2709 | + );  | 
                                                        |
| 2710 | + $this->_template_args['error'] = true;  | 
                                                        |
| 2711 | + $this->_return_json();  | 
                                                        |
| 2712 | + }  | 
                                                        |
| 2713 | +  | 
                                                        |
| 2714 | +		update_option('timezone_string', $timezone_string); | 
                                                        |
| 2715 | + EE_Error::add_success(  | 
                                                        |
| 2716 | +			esc_html__('Your timezone string was updated.', 'event_espresso') | 
                                                        |
| 2717 | + );  | 
                                                        |
| 2718 | + $this->_template_args['success'] = true;  | 
                                                        |
| 2719 | +		$this->_return_json(true, array('action' => 'create_new')); | 
                                                        |
| 2720 | + }  | 
                                                        |
| 2721 | 2721 | }  | 
                                                        
| 2722 | 2722 | //end class Events_Admin_Page  | 
                                                        
@@ -1,4 +1,4 @@ discard block  | 
                                                    ||
| 1 | -<?php do_action( 'AHEE__event_tickets_metabox_main__before_content' ); ?>  | 
                                                        |
| 1 | +<?php do_action('AHEE__event_tickets_metabox_main__before_content'); ?> | 
                                                        |
| 2 | 2 | <?php echo $upsell_notice; ?>  | 
                                                        
| 3 | 3 | <div id="event-and-ticket-form-content">  | 
                                                        
| 4 | 4 |  	<h4 class="event-tickets-datetimes-title"><?php _e('Event Datetime', 'event_espresso'); ?></h4><?php echo $event_datetime_help_link; ?> | 
                                                        
@@ -30,11 +30,11 @@ discard block  | 
                                                    ||
| 30 | 30 | </td>  | 
                                                        
| 31 | 31 | <td class="event-datetime-column reg-limit-column">  | 
                                                        
| 32 | 32 | <?php  | 
                                                        
| 33 | -								$reg_limit = $time->get_pretty('DTT_reg_limit','input'); | 
                                                        |
| 33 | +								$reg_limit = $time->get_pretty('DTT_reg_limit', 'input'); | 
                                                        |
| 34 | 34 | ?>  | 
                                                        
| 35 | 35 | <input type="text" name="edit_event_datetimes[1][DTT_reg_limit]" id="event-datetime-DTT_reg_limit-1" class="ee-small-text-inp ee-inp-right event-datetime-DTT_reg_limit" value="<?php echo $reg_limit; ?>">  | 
                                                        
| 36 | 36 | </td>  | 
                                                        
| 37 | -						<td class="datetime-tickets-sold"><?php printf( __('Tickets Sold: %s', 'event_espresso'), $time->get('DTT_sold') ); ?></td> | 
                                                        |
| 37 | +						<td class="datetime-tickets-sold"><?php printf(__('Tickets Sold: %s', 'event_espresso'), $time->get('DTT_sold')); ?></td> | 
                                                        |
| 38 | 38 | </tr>  | 
                                                        
| 39 | 39 | </tbody>  | 
                                                        
| 40 | 40 | </table>  | 
                                                        
@@ -73,7 +73,7 @@ discard block  | 
                                                    ||
| 73 | 73 | <div style="clear:both"></div>  | 
                                                        
| 74 | 74 | </div> <!-- end #event-and-ticket-form-content -->  | 
                                                        
| 75 | 75 | |
| 76 | -<?php do_action( 'AHEE__event_tickets_metabox_main__after_content' ); ?>  | 
                                                        |
| 76 | +<?php do_action('AHEE__event_tickets_metabox_main__after_content'); ?> | 
                                                        |
| 77 | 77 | |
| 78 | 78 | <table id="new-ticket-row-form" class="hidden">  | 
                                                        
| 79 | 79 | <tbody><?php echo $ticket_js_structure; ?></tbody>  |