@@ -20,111 +20,111 @@  | 
                                                    ||
| 20 | 20 | abstract class TicketSelector  | 
                                                        
| 21 | 21 |  { | 
                                                        
| 22 | 22 | |
| 23 | - /**  | 
                                                        |
| 24 | - * @var EE_Event  | 
                                                        |
| 25 | - */  | 
                                                        |
| 26 | - protected $event;  | 
                                                        |
| 27 | -  | 
                                                        |
| 28 | - /**  | 
                                                        |
| 29 | - * @var EE_Ticket[]  | 
                                                        |
| 30 | - */  | 
                                                        |
| 31 | - protected $tickets;  | 
                                                        |
| 32 | -  | 
                                                        |
| 33 | - /**  | 
                                                        |
| 34 | - * @var int  | 
                                                        |
| 35 | - */  | 
                                                        |
| 36 | - protected $max_attendees;  | 
                                                        |
| 37 | -  | 
                                                        |
| 38 | - /**  | 
                                                        |
| 39 | - * @var array  | 
                                                        |
| 40 | - */  | 
                                                        |
| 41 | - protected $template_args;  | 
                                                        |
| 42 | -  | 
                                                        |
| 43 | - /**  | 
                                                        |
| 44 | - * @var int  | 
                                                        |
| 45 | - */  | 
                                                        |
| 46 | - protected $ticket_rows = 0;  | 
                                                        |
| 47 | -  | 
                                                        |
| 48 | -  | 
                                                        |
| 49 | - /**  | 
                                                        |
| 50 | - * TicketSelectorSimple constructor.  | 
                                                        |
| 51 | - *  | 
                                                        |
| 52 | - * @param EE_Event $event  | 
                                                        |
| 53 | - * @param EE_Ticket[] $tickets  | 
                                                        |
| 54 | - * @param int $max_attendees  | 
                                                        |
| 55 | - * @param array $template_args  | 
                                                        |
| 56 | - */  | 
                                                        |
| 57 | - public function __construct(EE_Event $event, array $tickets, $max_attendees, array $template_args)  | 
                                                        |
| 58 | -    { | 
                                                        |
| 59 | - $this->event = $event;  | 
                                                        |
| 60 | - $this->tickets = $tickets;  | 
                                                        |
| 61 | - $this->max_attendees = $max_attendees;  | 
                                                        |
| 62 | - $this->template_args = $template_args;  | 
                                                        |
| 63 | - $this->addTemplateArgs();  | 
                                                        |
| 64 | - }  | 
                                                        |
| 65 | -  | 
                                                        |
| 66 | -  | 
                                                        |
| 67 | - /**  | 
                                                        |
| 68 | - * sets any and all template args that are required for this Ticket Selector  | 
                                                        |
| 69 | - *  | 
                                                        |
| 70 | - * @return void  | 
                                                        |
| 71 | - */  | 
                                                        |
| 72 | - abstract protected function addTemplateArgs();  | 
                                                        |
| 73 | -  | 
                                                        |
| 74 | -  | 
                                                        |
| 75 | - /**  | 
                                                        |
| 76 | - * loadTicketSelectorTemplate  | 
                                                        |
| 77 | - *  | 
                                                        |
| 78 | - * @return string  | 
                                                        |
| 79 | - */  | 
                                                        |
| 80 | - protected function loadTicketSelectorTemplate()  | 
                                                        |
| 81 | -    { | 
                                                        |
| 82 | -        try { | 
                                                        |
| 83 | - $this->template_args['hidden_inputs'] = $this->getHiddenInputs();  | 
                                                        |
| 84 | - return EEH_Template::locate_template(  | 
                                                        |
| 85 | - apply_filters(  | 
                                                        |
| 86 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path',  | 
                                                        |
| 87 | - $this->template_args['template_path'],  | 
                                                        |
| 88 | - $this->event  | 
                                                        |
| 89 | - ),  | 
                                                        |
| 90 | - $this->template_args  | 
                                                        |
| 91 | - );  | 
                                                        |
| 92 | -        } catch (Exception $e) { | 
                                                        |
| 93 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 94 | - }  | 
                                                        |
| 95 | - return '';  | 
                                                        |
| 96 | - }  | 
                                                        |
| 97 | -  | 
                                                        |
| 98 | -  | 
                                                        |
| 99 | - /**  | 
                                                        |
| 100 | - * The __toString method allows a class to decide how it will react when it is converted to a string.  | 
                                                        |
| 101 | - *  | 
                                                        |
| 102 | - * @return string  | 
                                                        |
| 103 | - * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring  | 
                                                        |
| 104 | - */  | 
                                                        |
| 105 | - public function __toString()  | 
                                                        |
| 106 | -    { | 
                                                        |
| 107 | - return $this->loadTicketSelectorTemplate();  | 
                                                        |
| 108 | - }  | 
                                                        |
| 109 | -  | 
                                                        |
| 110 | -  | 
                                                        |
| 111 | - /**  | 
                                                        |
| 112 | - * getHiddenInputs  | 
                                                        |
| 113 | - *  | 
                                                        |
| 114 | - * @return string  | 
                                                        |
| 115 | - * @throws EE_Error  | 
                                                        |
| 116 | - * @throws ReflectionException  | 
                                                        |
| 117 | - */  | 
                                                        |
| 118 | - public function getHiddenInputs()  | 
                                                        |
| 119 | -    { | 
                                                        |
| 120 | - $html = '<input type="hidden" name="noheader" value="true"/>';  | 
                                                        |
| 121 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"';  | 
                                                        |
| 122 | - $html .= ' value="' . EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>';  | 
                                                        |
| 123 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID();  | 
                                                        |
| 124 | - $html .= '" value="' . $this->ticket_rows . '"/>';  | 
                                                        |
| 125 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID();  | 
                                                        |
| 126 | - $html .= '" value="' . $this->template_args['max_atndz'] . '"/>';  | 
                                                        |
| 127 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>';  | 
                                                        |
| 128 | - return $html;  | 
                                                        |
| 129 | - }  | 
                                                        |
| 23 | + /**  | 
                                                        |
| 24 | + * @var EE_Event  | 
                                                        |
| 25 | + */  | 
                                                        |
| 26 | + protected $event;  | 
                                                        |
| 27 | +  | 
                                                        |
| 28 | + /**  | 
                                                        |
| 29 | + * @var EE_Ticket[]  | 
                                                        |
| 30 | + */  | 
                                                        |
| 31 | + protected $tickets;  | 
                                                        |
| 32 | +  | 
                                                        |
| 33 | + /**  | 
                                                        |
| 34 | + * @var int  | 
                                                        |
| 35 | + */  | 
                                                        |
| 36 | + protected $max_attendees;  | 
                                                        |
| 37 | +  | 
                                                        |
| 38 | + /**  | 
                                                        |
| 39 | + * @var array  | 
                                                        |
| 40 | + */  | 
                                                        |
| 41 | + protected $template_args;  | 
                                                        |
| 42 | +  | 
                                                        |
| 43 | + /**  | 
                                                        |
| 44 | + * @var int  | 
                                                        |
| 45 | + */  | 
                                                        |
| 46 | + protected $ticket_rows = 0;  | 
                                                        |
| 47 | +  | 
                                                        |
| 48 | +  | 
                                                        |
| 49 | + /**  | 
                                                        |
| 50 | + * TicketSelectorSimple constructor.  | 
                                                        |
| 51 | + *  | 
                                                        |
| 52 | + * @param EE_Event $event  | 
                                                        |
| 53 | + * @param EE_Ticket[] $tickets  | 
                                                        |
| 54 | + * @param int $max_attendees  | 
                                                        |
| 55 | + * @param array $template_args  | 
                                                        |
| 56 | + */  | 
                                                        |
| 57 | + public function __construct(EE_Event $event, array $tickets, $max_attendees, array $template_args)  | 
                                                        |
| 58 | +	{ | 
                                                        |
| 59 | + $this->event = $event;  | 
                                                        |
| 60 | + $this->tickets = $tickets;  | 
                                                        |
| 61 | + $this->max_attendees = $max_attendees;  | 
                                                        |
| 62 | + $this->template_args = $template_args;  | 
                                                        |
| 63 | + $this->addTemplateArgs();  | 
                                                        |
| 64 | + }  | 
                                                        |
| 65 | +  | 
                                                        |
| 66 | +  | 
                                                        |
| 67 | + /**  | 
                                                        |
| 68 | + * sets any and all template args that are required for this Ticket Selector  | 
                                                        |
| 69 | + *  | 
                                                        |
| 70 | + * @return void  | 
                                                        |
| 71 | + */  | 
                                                        |
| 72 | + abstract protected function addTemplateArgs();  | 
                                                        |
| 73 | +  | 
                                                        |
| 74 | +  | 
                                                        |
| 75 | + /**  | 
                                                        |
| 76 | + * loadTicketSelectorTemplate  | 
                                                        |
| 77 | + *  | 
                                                        |
| 78 | + * @return string  | 
                                                        |
| 79 | + */  | 
                                                        |
| 80 | + protected function loadTicketSelectorTemplate()  | 
                                                        |
| 81 | +	{ | 
                                                        |
| 82 | +		try { | 
                                                        |
| 83 | + $this->template_args['hidden_inputs'] = $this->getHiddenInputs();  | 
                                                        |
| 84 | + return EEH_Template::locate_template(  | 
                                                        |
| 85 | + apply_filters(  | 
                                                        |
| 86 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path',  | 
                                                        |
| 87 | + $this->template_args['template_path'],  | 
                                                        |
| 88 | + $this->event  | 
                                                        |
| 89 | + ),  | 
                                                        |
| 90 | + $this->template_args  | 
                                                        |
| 91 | + );  | 
                                                        |
| 92 | +		} catch (Exception $e) { | 
                                                        |
| 93 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 94 | + }  | 
                                                        |
| 95 | + return '';  | 
                                                        |
| 96 | + }  | 
                                                        |
| 97 | +  | 
                                                        |
| 98 | +  | 
                                                        |
| 99 | + /**  | 
                                                        |
| 100 | + * The __toString method allows a class to decide how it will react when it is converted to a string.  | 
                                                        |
| 101 | + *  | 
                                                        |
| 102 | + * @return string  | 
                                                        |
| 103 | + * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring  | 
                                                        |
| 104 | + */  | 
                                                        |
| 105 | + public function __toString()  | 
                                                        |
| 106 | +	{ | 
                                                        |
| 107 | + return $this->loadTicketSelectorTemplate();  | 
                                                        |
| 108 | + }  | 
                                                        |
| 109 | +  | 
                                                        |
| 110 | +  | 
                                                        |
| 111 | + /**  | 
                                                        |
| 112 | + * getHiddenInputs  | 
                                                        |
| 113 | + *  | 
                                                        |
| 114 | + * @return string  | 
                                                        |
| 115 | + * @throws EE_Error  | 
                                                        |
| 116 | + * @throws ReflectionException  | 
                                                        |
| 117 | + */  | 
                                                        |
| 118 | + public function getHiddenInputs()  | 
                                                        |
| 119 | +	{ | 
                                                        |
| 120 | + $html = '<input type="hidden" name="noheader" value="true"/>';  | 
                                                        |
| 121 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"';  | 
                                                        |
| 122 | + $html .= ' value="' . EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>';  | 
                                                        |
| 123 | + $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID();  | 
                                                        |
| 124 | + $html .= '" value="' . $this->ticket_rows . '"/>';  | 
                                                        |
| 125 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID();  | 
                                                        |
| 126 | + $html .= '" value="' . $this->template_args['max_atndz'] . '"/>';  | 
                                                        |
| 127 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>';  | 
                                                        |
| 128 | + return $html;  | 
                                                        |
| 129 | + }  | 
                                                        |
| 130 | 130 | }  | 
                                                        
@@ -118,13 +118,13 @@  | 
                                                    ||
| 118 | 118 | public function getHiddenInputs()  | 
                                                        
| 119 | 119 |      { | 
                                                        
| 120 | 120 | $html = '<input type="hidden" name="noheader" value="true"/>';  | 
                                                        
| 121 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"';  | 
                                                        |
| 122 | - $html .= ' value="' . EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>';  | 
                                                        |
| 123 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID();  | 
                                                        |
| 124 | - $html .= '" value="' . $this->ticket_rows . '"/>';  | 
                                                        |
| 125 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID();  | 
                                                        |
| 126 | - $html .= '" value="' . $this->template_args['max_atndz'] . '"/>';  | 
                                                        |
| 127 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>';  | 
                                                        |
| 121 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-'.$this->event->ID().'"';  | 
                                                        |
| 122 | + $html .= ' value="'.EEH_URL::current_url().$this->template_args['anchor_id'].'"/>';  | 
                                                        |
| 123 | + $html .= '<input type="hidden" name="tkt-slctr-rows-'.$this->event->ID();  | 
                                                        |
| 124 | + $html .= '" value="'.$this->ticket_rows.'"/>';  | 
                                                        |
| 125 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-'.$this->event->ID();  | 
                                                        |
| 126 | + $html .= '" value="'.$this->template_args['max_atndz'].'"/>';  | 
                                                        |
| 127 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="'.$this->event->ID().'"/>';  | 
                                                        |
| 128 | 128 | return $html;  | 
                                                        
| 129 | 129 | }  | 
                                                        
| 130 | 130 | }  | 
                                                        
@@ -20,125 +20,125 @@  | 
                                                    ||
| 20 | 20 | class TicketSelectorStandard extends TicketSelector  | 
                                                        
| 21 | 21 |  { | 
                                                        
| 22 | 22 | |
| 23 | - /**  | 
                                                        |
| 24 | - * @var string $date_format  | 
                                                        |
| 25 | - */  | 
                                                        |
| 26 | - protected $date_format;  | 
                                                        |
| 23 | + /**  | 
                                                        |
| 24 | + * @var string $date_format  | 
                                                        |
| 25 | + */  | 
                                                        |
| 26 | + protected $date_format;  | 
                                                        |
| 27 | 27 | |
| 28 | - /**  | 
                                                        |
| 29 | - * @var string $time_format  | 
                                                        |
| 30 | - */  | 
                                                        |
| 31 | - protected $time_format;  | 
                                                        |
| 28 | + /**  | 
                                                        |
| 29 | + * @var string $time_format  | 
                                                        |
| 30 | + */  | 
                                                        |
| 31 | + protected $time_format;  | 
                                                        |
| 32 | 32 | |
| 33 | - /**  | 
                                                        |
| 34 | - * @var EE_Ticket_Selector_Config $ticket_selector_config  | 
                                                        |
| 35 | - */  | 
                                                        |
| 36 | - protected $ticket_selector_config;  | 
                                                        |
| 33 | + /**  | 
                                                        |
| 34 | + * @var EE_Ticket_Selector_Config $ticket_selector_config  | 
                                                        |
| 35 | + */  | 
                                                        |
| 36 | + protected $ticket_selector_config;  | 
                                                        |
| 37 | 37 | |
| 38 | - /**  | 
                                                        |
| 39 | - * @var EE_Tax_Config $tax_config  | 
                                                        |
| 40 | - */  | 
                                                        |
| 41 | - protected $tax_config;  | 
                                                        |
| 38 | + /**  | 
                                                        |
| 39 | + * @var EE_Tax_Config $tax_config  | 
                                                        |
| 40 | + */  | 
                                                        |
| 41 | + protected $tax_config;  | 
                                                        |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /**  | 
                                                        |
| 45 | - * TicketSelectorSimple constructor.  | 
                                                        |
| 46 | - *  | 
                                                        |
| 47 | - * @param EE_Ticket_Selector_Config $ticket_selector_config  | 
                                                        |
| 48 | - * @param EE_Tax_Config $tax_config  | 
                                                        |
| 49 | - * @param EE_Event $event  | 
                                                        |
| 50 | - * @param EE_Ticket[] $tickets  | 
                                                        |
| 51 | - * @param int $max_attendees  | 
                                                        |
| 52 | - * @param array $template_args  | 
                                                        |
| 53 | - * @param string $date_format  | 
                                                        |
| 54 | - * @param string $time_format  | 
                                                        |
| 55 | - * @throws EE_Error  | 
                                                        |
| 56 | - */  | 
                                                        |
| 57 | - public function __construct(  | 
                                                        |
| 58 | - EE_Ticket_Selector_Config $ticket_selector_config,  | 
                                                        |
| 59 | - EE_Tax_Config $tax_config,  | 
                                                        |
| 60 | - EE_Event $event,  | 
                                                        |
| 61 | - array $tickets,  | 
                                                        |
| 62 | - $max_attendees,  | 
                                                        |
| 63 | - array $template_args,  | 
                                                        |
| 64 | - $date_format = 'Y-m-d',  | 
                                                        |
| 65 | - $time_format = 'g:i a'  | 
                                                        |
| 66 | -    ) { | 
                                                        |
| 67 | - $this->ticket_selector_config = $ticket_selector_config;  | 
                                                        |
| 68 | - $this->tax_config = $tax_config;  | 
                                                        |
| 69 | - $this->date_format = $date_format;  | 
                                                        |
| 70 | - $this->time_format = $time_format;  | 
                                                        |
| 71 | - parent::__construct($event, $tickets, $max_attendees, $template_args);  | 
                                                        |
| 72 | - }  | 
                                                        |
| 44 | + /**  | 
                                                        |
| 45 | + * TicketSelectorSimple constructor.  | 
                                                        |
| 46 | + *  | 
                                                        |
| 47 | + * @param EE_Ticket_Selector_Config $ticket_selector_config  | 
                                                        |
| 48 | + * @param EE_Tax_Config $tax_config  | 
                                                        |
| 49 | + * @param EE_Event $event  | 
                                                        |
| 50 | + * @param EE_Ticket[] $tickets  | 
                                                        |
| 51 | + * @param int $max_attendees  | 
                                                        |
| 52 | + * @param array $template_args  | 
                                                        |
| 53 | + * @param string $date_format  | 
                                                        |
| 54 | + * @param string $time_format  | 
                                                        |
| 55 | + * @throws EE_Error  | 
                                                        |
| 56 | + */  | 
                                                        |
| 57 | + public function __construct(  | 
                                                        |
| 58 | + EE_Ticket_Selector_Config $ticket_selector_config,  | 
                                                        |
| 59 | + EE_Tax_Config $tax_config,  | 
                                                        |
| 60 | + EE_Event $event,  | 
                                                        |
| 61 | + array $tickets,  | 
                                                        |
| 62 | + $max_attendees,  | 
                                                        |
| 63 | + array $template_args,  | 
                                                        |
| 64 | + $date_format = 'Y-m-d',  | 
                                                        |
| 65 | + $time_format = 'g:i a'  | 
                                                        |
| 66 | +	) { | 
                                                        |
| 67 | + $this->ticket_selector_config = $ticket_selector_config;  | 
                                                        |
| 68 | + $this->tax_config = $tax_config;  | 
                                                        |
| 69 | + $this->date_format = $date_format;  | 
                                                        |
| 70 | + $this->time_format = $time_format;  | 
                                                        |
| 71 | + parent::__construct($event, $tickets, $max_attendees, $template_args);  | 
                                                        |
| 72 | + }  | 
                                                        |
| 73 | 73 | |
| 74 | 74 | |
| 75 | - /**  | 
                                                        |
| 76 | - * sets any and all template args that are required for this Ticket Selector  | 
                                                        |
| 77 | - *  | 
                                                        |
| 78 | - * @return void  | 
                                                        |
| 79 | - * @throws EE_Error  | 
                                                        |
| 80 | - */  | 
                                                        |
| 81 | - protected function addTemplateArgs()  | 
                                                        |
| 82 | -    { | 
                                                        |
| 83 | - $this->ticket_rows = 0;  | 
                                                        |
| 84 | - $all_ticket_rows_html = '';  | 
                                                        |
| 85 | - $required_ticket_sold_out = false;  | 
                                                        |
| 86 | - // flag to indicate that at least one taxable ticket has been encountered  | 
                                                        |
| 87 | - $taxable_tickets = false;  | 
                                                        |
| 88 | - $datetime_selector = null;  | 
                                                        |
| 89 | - $this->template_args['datetime_selector'] = '';  | 
                                                        |
| 90 | - if (  | 
                                                        |
| 91 | - $this->ticket_selector_config->getShowDatetimeSelector()  | 
                                                        |
| 92 | - !== EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR  | 
                                                        |
| 93 | -        ) { | 
                                                        |
| 94 | - $datetime_selector = new DatetimeSelector(  | 
                                                        |
| 95 | - $this->event,  | 
                                                        |
| 96 | - $this->tickets,  | 
                                                        |
| 97 | - $this->ticket_selector_config,  | 
                                                        |
| 98 | - $this->date_format,  | 
                                                        |
| 99 | - $this->time_format  | 
                                                        |
| 100 | - );  | 
                                                        |
| 101 | - $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector();  | 
                                                        |
| 102 | - }  | 
                                                        |
| 103 | - $total_tickets = count($this->tickets);  | 
                                                        |
| 104 | - // loop through tickets  | 
                                                        |
| 105 | -        foreach ($this->tickets as $ticket) { | 
                                                        |
| 106 | -            if ($ticket instanceof EE_Ticket) { | 
                                                        |
| 107 | - $this->ticket_rows++;  | 
                                                        |
| 108 | - $cols = 2;  | 
                                                        |
| 109 | - $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets;  | 
                                                        |
| 110 | - $ticket_selector_row = new TicketSelectorRowStandard(  | 
                                                        |
| 111 | - new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args),  | 
                                                        |
| 112 | - $this->tax_config,  | 
                                                        |
| 113 | - $total_tickets,  | 
                                                        |
| 114 | - $this->max_attendees,  | 
                                                        |
| 115 | - $this->ticket_rows,  | 
                                                        |
| 116 | - $cols,  | 
                                                        |
| 117 | - $required_ticket_sold_out,  | 
                                                        |
| 118 | - $this->template_args['event_status'],  | 
                                                        |
| 119 | - $datetime_selector instanceof DatetimeSelector  | 
                                                        |
| 120 | - ? $datetime_selector->getTicketDatetimeClasses($ticket)  | 
                                                        |
| 121 | - : ''  | 
                                                        |
| 122 | - );  | 
                                                        |
| 123 | - $ticket_row_html = $ticket_selector_row->getHtml();  | 
                                                        |
| 124 | - // check if something was actually returned  | 
                                                        |
| 125 | -                if (! empty($ticket_row_html)) { | 
                                                        |
| 126 | - // add any output to the cumulative HTML  | 
                                                        |
| 127 | - $all_ticket_rows_html .= $ticket_row_html;  | 
                                                        |
| 128 | -                } else { | 
                                                        |
| 129 | - // or decrement the ticket row count since it looks like one has been removed  | 
                                                        |
| 130 | - $this->ticket_rows--;  | 
                                                        |
| 131 | - }  | 
                                                        |
| 75 | + /**  | 
                                                        |
| 76 | + * sets any and all template args that are required for this Ticket Selector  | 
                                                        |
| 77 | + *  | 
                                                        |
| 78 | + * @return void  | 
                                                        |
| 79 | + * @throws EE_Error  | 
                                                        |
| 80 | + */  | 
                                                        |
| 81 | + protected function addTemplateArgs()  | 
                                                        |
| 82 | +	{ | 
                                                        |
| 83 | + $this->ticket_rows = 0;  | 
                                                        |
| 84 | + $all_ticket_rows_html = '';  | 
                                                        |
| 85 | + $required_ticket_sold_out = false;  | 
                                                        |
| 86 | + // flag to indicate that at least one taxable ticket has been encountered  | 
                                                        |
| 87 | + $taxable_tickets = false;  | 
                                                        |
| 88 | + $datetime_selector = null;  | 
                                                        |
| 89 | + $this->template_args['datetime_selector'] = '';  | 
                                                        |
| 90 | + if (  | 
                                                        |
| 91 | + $this->ticket_selector_config->getShowDatetimeSelector()  | 
                                                        |
| 92 | + !== EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR  | 
                                                        |
| 93 | +		) { | 
                                                        |
| 94 | + $datetime_selector = new DatetimeSelector(  | 
                                                        |
| 95 | + $this->event,  | 
                                                        |
| 96 | + $this->tickets,  | 
                                                        |
| 97 | + $this->ticket_selector_config,  | 
                                                        |
| 98 | + $this->date_format,  | 
                                                        |
| 99 | + $this->time_format  | 
                                                        |
| 100 | + );  | 
                                                        |
| 101 | + $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector();  | 
                                                        |
| 102 | + }  | 
                                                        |
| 103 | + $total_tickets = count($this->tickets);  | 
                                                        |
| 104 | + // loop through tickets  | 
                                                        |
| 105 | +		foreach ($this->tickets as $ticket) { | 
                                                        |
| 106 | +			if ($ticket instanceof EE_Ticket) { | 
                                                        |
| 107 | + $this->ticket_rows++;  | 
                                                        |
| 108 | + $cols = 2;  | 
                                                        |
| 109 | + $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets;  | 
                                                        |
| 110 | + $ticket_selector_row = new TicketSelectorRowStandard(  | 
                                                        |
| 111 | + new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args),  | 
                                                        |
| 112 | + $this->tax_config,  | 
                                                        |
| 113 | + $total_tickets,  | 
                                                        |
| 114 | + $this->max_attendees,  | 
                                                        |
| 115 | + $this->ticket_rows,  | 
                                                        |
| 116 | + $cols,  | 
                                                        |
| 117 | + $required_ticket_sold_out,  | 
                                                        |
| 118 | + $this->template_args['event_status'],  | 
                                                        |
| 119 | + $datetime_selector instanceof DatetimeSelector  | 
                                                        |
| 120 | + ? $datetime_selector->getTicketDatetimeClasses($ticket)  | 
                                                        |
| 121 | + : ''  | 
                                                        |
| 122 | + );  | 
                                                        |
| 123 | + $ticket_row_html = $ticket_selector_row->getHtml();  | 
                                                        |
| 124 | + // check if something was actually returned  | 
                                                        |
| 125 | +				if (! empty($ticket_row_html)) { | 
                                                        |
| 126 | + // add any output to the cumulative HTML  | 
                                                        |
| 127 | + $all_ticket_rows_html .= $ticket_row_html;  | 
                                                        |
| 128 | +				} else { | 
                                                        |
| 129 | + // or decrement the ticket row count since it looks like one has been removed  | 
                                                        |
| 130 | + $this->ticket_rows--;  | 
                                                        |
| 131 | + }  | 
                                                        |
| 132 | 132 | |
| 133 | - $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut();  | 
                                                        |
| 134 | - }  | 
                                                        |
| 135 | - }  | 
                                                        |
| 136 | - $this->template_args['row'] = $this->ticket_rows;  | 
                                                        |
| 137 | - $this->template_args['ticket_row_html'] = $all_ticket_rows_html;  | 
                                                        |
| 138 | - $this->template_args['taxable_tickets'] = $taxable_tickets;  | 
                                                        |
| 139 | - $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;  | 
                                                        |
| 140 | - $this->template_args['template_path'] =  | 
                                                        |
| 141 | - TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';  | 
                                                        |
| 142 | -        remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); | 
                                                        |
| 143 | - }  | 
                                                        |
| 133 | + $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut();  | 
                                                        |
| 134 | + }  | 
                                                        |
| 135 | + }  | 
                                                        |
| 136 | + $this->template_args['row'] = $this->ticket_rows;  | 
                                                        |
| 137 | + $this->template_args['ticket_row_html'] = $all_ticket_rows_html;  | 
                                                        |
| 138 | + $this->template_args['taxable_tickets'] = $taxable_tickets;  | 
                                                        |
| 139 | + $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;  | 
                                                        |
| 140 | + $this->template_args['template_path'] =  | 
                                                        |
| 141 | + TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';  | 
                                                        |
| 142 | +		remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); | 
                                                        |
| 143 | + }  | 
                                                        |
| 144 | 144 | }  | 
                                                        
@@ -91,7 +91,7 @@ discard block  | 
                                                    ||
| 91 | 91 | $this->ticket_selector_config->getShowDatetimeSelector()  | 
                                                        
| 92 | 92 | !== EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR  | 
                                                        
| 93 | 93 |          ) { | 
                                                        
| 94 | - $datetime_selector = new DatetimeSelector(  | 
                                                        |
| 94 | + $datetime_selector = new DatetimeSelector(  | 
                                                        |
| 95 | 95 | $this->event,  | 
                                                        
| 96 | 96 | $this->tickets,  | 
                                                        
| 97 | 97 | $this->ticket_selector_config,  | 
                                                        
@@ -122,7 +122,7 @@ discard block  | 
                                                    ||
| 122 | 122 | );  | 
                                                        
| 123 | 123 | $ticket_row_html = $ticket_selector_row->getHtml();  | 
                                                        
| 124 | 124 | // check if something was actually returned  | 
                                                        
| 125 | -                if (! empty($ticket_row_html)) { | 
                                                        |
| 125 | +                if ( ! empty($ticket_row_html)) { | 
                                                        |
| 126 | 126 | // add any output to the cumulative HTML  | 
                                                        
| 127 | 127 | $all_ticket_rows_html .= $ticket_row_html;  | 
                                                        
| 128 | 128 |                  } else { | 
                                                        
@@ -138,7 +138,7 @@ discard block  | 
                                                    ||
| 138 | 138 | $this->template_args['taxable_tickets'] = $taxable_tickets;  | 
                                                        
| 139 | 139 | $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;  | 
                                                        
| 140 | 140 | $this->template_args['template_path'] =  | 
                                                        
| 141 | - TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';  | 
                                                        |
| 141 | + TICKET_SELECTOR_TEMPLATES_PATH.'standard_ticket_selector.template.php';  | 
                                                        |
| 142 | 142 |          remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); | 
                                                        
| 143 | 143 | }  | 
                                                        
| 144 | 144 | }  | 
                                                        
@@ -20,59 +20,59 @@  | 
                                                    ||
| 20 | 20 | class TicketSelectorSimple extends TicketSelector  | 
                                                        
| 21 | 21 |  { | 
                                                        
| 22 | 22 | |
| 23 | - /**  | 
                                                        |
| 24 | - * @var EE_Ticket $ticket  | 
                                                        |
| 25 | - */  | 
                                                        |
| 26 | - protected $ticket;  | 
                                                        |
| 23 | + /**  | 
                                                        |
| 24 | + * @var EE_Ticket $ticket  | 
                                                        |
| 25 | + */  | 
                                                        |
| 26 | + protected $ticket;  | 
                                                        |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /**  | 
                                                        |
| 30 | - * TicketSelectorSimple constructor.  | 
                                                        |
| 31 | - *  | 
                                                        |
| 32 | - * @param EE_Event $event  | 
                                                        |
| 33 | - * @param EE_Ticket $ticket  | 
                                                        |
| 34 | - * @param int $max_attendees  | 
                                                        |
| 35 | - * @param array $template_args  | 
                                                        |
| 36 | - * @throws EE_Error  | 
                                                        |
| 37 | - */  | 
                                                        |
| 38 | - public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)  | 
                                                        |
| 39 | -    { | 
                                                        |
| 40 | - $this->ticket = $ticket;  | 
                                                        |
| 41 | - parent::__construct(  | 
                                                        |
| 42 | - $event,  | 
                                                        |
| 43 | - [$this->ticket],  | 
                                                        |
| 44 | - $max_attendees,  | 
                                                        |
| 45 | - $template_args  | 
                                                        |
| 46 | - );  | 
                                                        |
| 47 | - }  | 
                                                        |
| 29 | + /**  | 
                                                        |
| 30 | + * TicketSelectorSimple constructor.  | 
                                                        |
| 31 | + *  | 
                                                        |
| 32 | + * @param EE_Event $event  | 
                                                        |
| 33 | + * @param EE_Ticket $ticket  | 
                                                        |
| 34 | + * @param int $max_attendees  | 
                                                        |
| 35 | + * @param array $template_args  | 
                                                        |
| 36 | + * @throws EE_Error  | 
                                                        |
| 37 | + */  | 
                                                        |
| 38 | + public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)  | 
                                                        |
| 39 | +	{ | 
                                                        |
| 40 | + $this->ticket = $ticket;  | 
                                                        |
| 41 | + parent::__construct(  | 
                                                        |
| 42 | + $event,  | 
                                                        |
| 43 | + [$this->ticket],  | 
                                                        |
| 44 | + $max_attendees,  | 
                                                        |
| 45 | + $template_args  | 
                                                        |
| 46 | + );  | 
                                                        |
| 47 | + }  | 
                                                        |
| 48 | 48 | |
| 49 | 49 | |
| 50 | - /**  | 
                                                        |
| 51 | - * sets any and all template args that are required for this Ticket Selector  | 
                                                        |
| 52 | - *  | 
                                                        |
| 53 | - * @return void  | 
                                                        |
| 54 | - * @throws UnexpectedEntityException  | 
                                                        |
| 55 | - * @throws EE_Error  | 
                                                        |
| 56 | - */  | 
                                                        |
| 57 | - protected function addTemplateArgs()  | 
                                                        |
| 58 | -    { | 
                                                        |
| 59 | - $this->ticket_rows = 1;  | 
                                                        |
| 60 | - unset($this->template_args['tickets']);  | 
                                                        |
| 61 | - $this->template_args['ticket'] = $this->ticket;  | 
                                                        |
| 62 | - $ticket_selector_row = new TicketSelectorRowSimple(  | 
                                                        |
| 63 | - $this->ticket,  | 
                                                        |
| 64 | - $this->max_attendees,  | 
                                                        |
| 65 | - $this->template_args['date_format'],  | 
                                                        |
| 66 | - $this->template_args['event_status']  | 
                                                        |
| 67 | - );  | 
                                                        |
| 68 | - $this->template_args['TKT_ID'] = $this->ticket->ID();  | 
                                                        |
| 69 | - $ticket_selector_row->setupTicketStatusDisplay();  | 
                                                        |
| 70 | - $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();  | 
                                                        |
| 71 | -        if (empty($this->template_args['ticket_status_display'])) { | 
                                                        |
| 72 | -            add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); | 
                                                        |
| 73 | - }  | 
                                                        |
| 74 | - $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();  | 
                                                        |
| 75 | - $this->template_args['template_path'] =  | 
                                                        |
| 76 | - TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';  | 
                                                        |
| 77 | - }  | 
                                                        |
| 50 | + /**  | 
                                                        |
| 51 | + * sets any and all template args that are required for this Ticket Selector  | 
                                                        |
| 52 | + *  | 
                                                        |
| 53 | + * @return void  | 
                                                        |
| 54 | + * @throws UnexpectedEntityException  | 
                                                        |
| 55 | + * @throws EE_Error  | 
                                                        |
| 56 | + */  | 
                                                        |
| 57 | + protected function addTemplateArgs()  | 
                                                        |
| 58 | +	{ | 
                                                        |
| 59 | + $this->ticket_rows = 1;  | 
                                                        |
| 60 | + unset($this->template_args['tickets']);  | 
                                                        |
| 61 | + $this->template_args['ticket'] = $this->ticket;  | 
                                                        |
| 62 | + $ticket_selector_row = new TicketSelectorRowSimple(  | 
                                                        |
| 63 | + $this->ticket,  | 
                                                        |
| 64 | + $this->max_attendees,  | 
                                                        |
| 65 | + $this->template_args['date_format'],  | 
                                                        |
| 66 | + $this->template_args['event_status']  | 
                                                        |
| 67 | + );  | 
                                                        |
| 68 | + $this->template_args['TKT_ID'] = $this->ticket->ID();  | 
                                                        |
| 69 | + $ticket_selector_row->setupTicketStatusDisplay();  | 
                                                        |
| 70 | + $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();  | 
                                                        |
| 71 | +		if (empty($this->template_args['ticket_status_display'])) { | 
                                                        |
| 72 | +			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); | 
                                                        |
| 73 | + }  | 
                                                        |
| 74 | + $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();  | 
                                                        |
| 75 | + $this->template_args['template_path'] =  | 
                                                        |
| 76 | + TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';  | 
                                                        |
| 77 | + }  | 
                                                        |
| 78 | 78 | }  | 
                                                        
@@ -24,430 +24,430 @@  | 
                                                    ||
| 24 | 24 | */  | 
                                                        
| 25 | 25 | class LegacyShortcodesManager  | 
                                                        
| 26 | 26 |  { | 
                                                        
| 27 | - /**  | 
                                                        |
| 28 | - * @type CurrentPage  | 
                                                        |
| 29 | - */  | 
                                                        |
| 30 | - protected $current_page;  | 
                                                        |
| 31 | -  | 
                                                        |
| 32 | - /**  | 
                                                        |
| 33 | - * @var EE_Registry $registry  | 
                                                        |
| 34 | - */  | 
                                                        |
| 35 | - private $registry;  | 
                                                        |
| 36 | -  | 
                                                        |
| 37 | -  | 
                                                        |
| 38 | - /**  | 
                                                        |
| 39 | - * LegacyShortcodesManager constructor.  | 
                                                        |
| 40 | - *  | 
                                                        |
| 41 | - * @param EE_Registry $registry  | 
                                                        |
| 42 | - * @param CurrentPage $current_page  | 
                                                        |
| 43 | - */  | 
                                                        |
| 44 | - public function __construct(EE_Registry $registry, CurrentPage $current_page)  | 
                                                        |
| 45 | -    { | 
                                                        |
| 46 | - $this->registry = $registry;  | 
                                                        |
| 47 | - $this->current_page = $current_page;  | 
                                                        |
| 48 | - }  | 
                                                        |
| 49 | -  | 
                                                        |
| 50 | -  | 
                                                        |
| 51 | - /**  | 
                                                        |
| 52 | - * @return EE_Registry  | 
                                                        |
| 53 | - */  | 
                                                        |
| 54 | - public function registry()  | 
                                                        |
| 55 | -    { | 
                                                        |
| 56 | - return $this->registry;  | 
                                                        |
| 57 | - }  | 
                                                        |
| 58 | -  | 
                                                        |
| 59 | -  | 
                                                        |
| 60 | - /**  | 
                                                        |
| 61 | - * registerShortcodes  | 
                                                        |
| 62 | - *  | 
                                                        |
| 63 | - * @return void  | 
                                                        |
| 64 | - */  | 
                                                        |
| 65 | - public function registerShortcodes()  | 
                                                        |
| 66 | -    { | 
                                                        |
| 67 | - $this->registry->shortcodes = $this->getShortcodes();  | 
                                                        |
| 68 | - }  | 
                                                        |
| 69 | -  | 
                                                        |
| 70 | -  | 
                                                        |
| 71 | - /**  | 
                                                        |
| 72 | - * getShortcodes  | 
                                                        |
| 73 | - *  | 
                                                        |
| 74 | - * @return array  | 
                                                        |
| 75 | - */  | 
                                                        |
| 76 | - public function getShortcodes()  | 
                                                        |
| 77 | -    { | 
                                                        |
| 78 | - // previously this method would glob the shortcodes directory  | 
                                                        |
| 79 | - // then filter that list of shortcodes to register,  | 
                                                        |
| 80 | - // but now we are going to just supply an empty array.  | 
                                                        |
| 81 | - // this allows any shortcodes that have not yet been converted to the new system  | 
                                                        |
| 82 | - // to still get loaded and processed, albeit using the same legacy logic as before  | 
                                                        |
| 83 | - $shortcodes_to_register = apply_filters(  | 
                                                        |
| 84 | - 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',  | 
                                                        |
| 85 | - array()  | 
                                                        |
| 86 | - );  | 
                                                        |
| 87 | -        if (! empty($shortcodes_to_register)) { | 
                                                        |
| 88 | - // cycle thru shortcode folders  | 
                                                        |
| 89 | -            foreach ($shortcodes_to_register as $shortcode_path) { | 
                                                        |
| 90 | - // add to list of installed shortcode modules  | 
                                                        |
| 91 | - $this->registerShortcode($shortcode_path);  | 
                                                        |
| 92 | - }  | 
                                                        |
| 93 | - }  | 
                                                        |
| 94 | - // filter list of installed modules  | 
                                                        |
| 95 | - return apply_filters(  | 
                                                        |
| 96 | - 'FHEE__EE_Config___register_shortcodes__installed_shortcodes',  | 
                                                        |
| 97 | - ! empty($this->registry->shortcodes)  | 
                                                        |
| 98 | - ? $this->registry->shortcodes  | 
                                                        |
| 99 | - : array()  | 
                                                        |
| 100 | - );  | 
                                                        |
| 101 | - }  | 
                                                        |
| 102 | -  | 
                                                        |
| 103 | -  | 
                                                        |
| 104 | - /**  | 
                                                        |
| 105 | - * register_shortcode - makes core aware of this shortcode  | 
                                                        |
| 106 | - *  | 
                                                        |
| 107 | - * @param string $shortcode_path - full path up to and including shortcode folder  | 
                                                        |
| 108 | - * @return bool  | 
                                                        |
| 109 | - */  | 
                                                        |
| 110 | - public function registerShortcode($shortcode_path = null)  | 
                                                        |
| 111 | -    { | 
                                                        |
| 112 | -        do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); | 
                                                        |
| 113 | - $shortcode_ext = '.shortcode.php';  | 
                                                        |
| 114 | - // make all separators match  | 
                                                        |
| 115 | -        $shortcode_path = str_replace(array('\\', '/'), '/', $shortcode_path); | 
                                                        |
| 116 | - // does the file path INCLUDE the actual file name as part of the path ?  | 
                                                        |
| 117 | -        if (strpos($shortcode_path, $shortcode_ext) !== false) { | 
                                                        |
| 118 | - // grab shortcode file name from directory name and break apart at dots  | 
                                                        |
| 119 | -            $shortcode_file = explode('.', basename($shortcode_path)); | 
                                                        |
| 120 | - // take first segment from file name pieces and remove class prefix if it exists  | 
                                                        |
| 121 | - $shortcode = strpos($shortcode_file[0], 'EES_') === 0  | 
                                                        |
| 122 | - ? substr($shortcode_file[0], 4)  | 
                                                        |
| 123 | - : $shortcode_file[0];  | 
                                                        |
| 124 | - // sanitize shortcode directory name  | 
                                                        |
| 125 | - $shortcode = sanitize_key($shortcode);  | 
                                                        |
| 126 | - // now we need to rebuild the shortcode path  | 
                                                        |
| 127 | -            $shortcode_path = explode('/', $shortcode_path); | 
                                                        |
| 128 | - // remove last segment  | 
                                                        |
| 129 | - array_pop($shortcode_path);  | 
                                                        |
| 130 | - // glue it back together  | 
                                                        |
| 131 | -            $shortcode_path = implode('/', $shortcode_path) . '/'; | 
                                                        |
| 132 | -        } else { | 
                                                        |
| 133 | - // we need to generate the filename based off of the folder name  | 
                                                        |
| 134 | - // grab and sanitize shortcode directory name  | 
                                                        |
| 135 | - $shortcode = sanitize_key(basename($shortcode_path));  | 
                                                        |
| 136 | - $shortcode_path = rtrim($shortcode_path, '/') . '/';  | 
                                                        |
| 137 | - }  | 
                                                        |
| 138 | - // create classname from shortcode directory or file name  | 
                                                        |
| 139 | -        $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); | 
                                                        |
| 140 | - // add class prefix  | 
                                                        |
| 141 | - $shortcode_class = 'EES_' . $shortcode;  | 
                                                        |
| 142 | - // does the shortcode exist ?  | 
                                                        |
| 143 | -        if (! is_readable($shortcode_path . '/' . $shortcode_class . $shortcode_ext)) { | 
                                                        |
| 144 | - $msg = sprintf(  | 
                                                        |
| 145 | - esc_html__(  | 
                                                        |
| 146 | - 'The requested %1$s shortcode file could not be found or is not readable due to file permissions. It should be in %2$s',  | 
                                                        |
| 147 | - 'event_espresso'  | 
                                                        |
| 148 | - ),  | 
                                                        |
| 149 | - $shortcode_class,  | 
                                                        |
| 150 | - $shortcode_path . '/' . $shortcode_class . $shortcode_ext  | 
                                                        |
| 151 | - );  | 
                                                        |
| 152 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 153 | - return false;  | 
                                                        |
| 154 | - }  | 
                                                        |
| 155 | - // load the shortcode class file  | 
                                                        |
| 156 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext);  | 
                                                        |
| 157 | - // verify that class exists  | 
                                                        |
| 158 | -        if (! class_exists($shortcode_class)) { | 
                                                        |
| 159 | - $msg = sprintf(  | 
                                                        |
| 160 | -                esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), | 
                                                        |
| 161 | - $shortcode_class  | 
                                                        |
| 162 | - );  | 
                                                        |
| 163 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 164 | - return false;  | 
                                                        |
| 165 | - }  | 
                                                        |
| 166 | - $shortcode = strtoupper($shortcode);  | 
                                                        |
| 167 | - // add to array of registered shortcodes  | 
                                                        |
| 168 | -        $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; | 
                                                        |
| 169 | - return true;  | 
                                                        |
| 170 | - }  | 
                                                        |
| 171 | -  | 
                                                        |
| 172 | -  | 
                                                        |
| 173 | - /**  | 
                                                        |
| 174 | - * _initialize_shortcodes  | 
                                                        |
| 175 | - * allow shortcodes to set hooks for the rest of the system  | 
                                                        |
| 176 | - *  | 
                                                        |
| 177 | - * @return void  | 
                                                        |
| 178 | - */  | 
                                                        |
| 179 | - public function addShortcodes()  | 
                                                        |
| 180 | -    { | 
                                                        |
| 181 | - // cycle thru shortcode folders  | 
                                                        |
| 182 | -        foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { | 
                                                        |
| 183 | - // add class prefix  | 
                                                        |
| 184 | - $shortcode_class = 'EES_' . $shortcode;  | 
                                                        |
| 185 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system  | 
                                                        |
| 186 | - // which set hooks ?  | 
                                                        |
| 187 | -            if (is_admin()) { | 
                                                        |
| 188 | - // fire immediately  | 
                                                        |
| 189 | - call_user_func(array($shortcode_class, 'set_hooks_admin'));  | 
                                                        |
| 190 | -            } else { | 
                                                        |
| 191 | - // delay until other systems are online  | 
                                                        |
| 192 | - add_action(  | 
                                                        |
| 193 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',  | 
                                                        |
| 194 | - array($shortcode_class, 'set_hooks')  | 
                                                        |
| 195 | - );  | 
                                                        |
| 196 | - // convert classname to UPPERCASE and create WP shortcode.  | 
                                                        |
| 197 | - $shortcode_tag = strtoupper($shortcode);  | 
                                                        |
| 198 | - // but first check if the shortcode has already  | 
                                                        |
| 199 | - // been added before assigning 'fallback_shortcode_processor'  | 
                                                        |
| 200 | -                if (! shortcode_exists($shortcode_tag)) { | 
                                                        |
| 201 | - // NOTE: this shortcode declaration will get overridden if the shortcode  | 
                                                        |
| 202 | - // is successfully detected in the post content in initializeShortcode()  | 
                                                        |
| 203 | - add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));  | 
                                                        |
| 204 | - }  | 
                                                        |
| 205 | - }  | 
                                                        |
| 206 | - }  | 
                                                        |
| 207 | - }  | 
                                                        |
| 208 | -  | 
                                                        |
| 209 | -  | 
                                                        |
| 210 | - /**  | 
                                                        |
| 211 | - * callback for the WP "get_header" hook point  | 
                                                        |
| 212 | - * checks posts for EE shortcodes, and initializes them,  | 
                                                        |
| 213 | - * then toggles filter switch that loads core default assets  | 
                                                        |
| 214 | - *  | 
                                                        |
| 215 | - * @param WP_Query $wp_query  | 
                                                        |
| 216 | - * @return void  | 
                                                        |
| 217 | - * @throws ReflectionException  | 
                                                        |
| 218 | - */  | 
                                                        |
| 219 | - public function initializeShortcodes(WP_Query $wp_query)  | 
                                                        |
| 220 | -    { | 
                                                        |
| 221 | -        if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) { | 
                                                        |
| 222 | - return;  | 
                                                        |
| 223 | - }  | 
                                                        |
| 224 | - global $wp;  | 
                                                        |
| 225 | - /** @var EE_Front_controller $Front_Controller */  | 
                                                        |
| 226 | -        $Front_Controller = LoaderFactory::getLoader()->getShared('EE_Front_Controller'); | 
                                                        |
| 227 | -        do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller); | 
                                                        |
| 228 | - $this->current_page->parseQueryVars();  | 
                                                        |
| 229 | - // grab post_name from request  | 
                                                        |
| 230 | - $current_post = apply_filters(  | 
                                                        |
| 231 | - 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name',  | 
                                                        |
| 232 | - $this->current_page->postName()  | 
                                                        |
| 233 | - );  | 
                                                        |
| 234 | -        $show_on_front = get_option('show_on_front'); | 
                                                        |
| 235 | - // if it's not set, then check if frontpage is blog  | 
                                                        |
| 236 | -        if (empty($current_post)) { | 
                                                        |
| 237 | - // yup.. this is the posts page, prepare to load all shortcode modules  | 
                                                        |
| 238 | - $current_post = 'posts';  | 
                                                        |
| 239 | - // unless..  | 
                                                        |
| 240 | -            if ($show_on_front === 'page') { | 
                                                        |
| 241 | - // some other page is set as the homepage  | 
                                                        |
| 242 | -                $page_on_front = get_option('page_on_front'); | 
                                                        |
| 243 | -                if ($page_on_front) { | 
                                                        |
| 244 | - // k now we need to find the post_name for this page  | 
                                                        |
| 245 | - global $wpdb;  | 
                                                        |
| 246 | - $page_on_front = $wpdb->get_var(  | 
                                                        |
| 247 | - $wpdb->prepare(  | 
                                                        |
| 248 | -                            "SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d", | 
                                                        |
| 249 | - $page_on_front  | 
                                                        |
| 250 | - )  | 
                                                        |
| 251 | - );  | 
                                                        |
| 252 | - // set the current post slug to what it actually is  | 
                                                        |
| 253 | - $current_post = $page_on_front ?: $current_post;  | 
                                                        |
| 254 | - }  | 
                                                        |
| 255 | - }  | 
                                                        |
| 256 | - }  | 
                                                        |
| 257 | - // in case $current_post is hierarchical like: /parent-page/current-page  | 
                                                        |
| 258 | - $current_post = basename($current_post);  | 
                                                        |
| 259 | - if (  | 
                                                        |
| 260 | - // is current page/post the "blog" page ?  | 
                                                        |
| 261 | - $current_post === EE_Config::get_page_for_posts()  | 
                                                        |
| 262 | - // or are we on a category page?  | 
                                                        |
| 263 | - || (  | 
                                                        |
| 264 | - is_array(term_exists($current_post, 'category'))  | 
                                                        |
| 265 | -                || array_key_exists('category_name', $wp->query_vars) | 
                                                        |
| 266 | - )  | 
                                                        |
| 267 | -        ) { | 
                                                        |
| 268 | - // initialize all legacy shortcodes  | 
                                                        |
| 269 | -            $load_assets = $this->parseContentForShortcodes('', true); | 
                                                        |
| 270 | -        } else { | 
                                                        |
| 271 | - global $post;  | 
                                                        |
| 272 | -            if ($post instanceof WP_Post) { | 
                                                        |
| 273 | - $post_content = $post->post_content;  | 
                                                        |
| 274 | -            } else { | 
                                                        |
| 275 | - global $wpdb;  | 
                                                        |
| 276 | - $post_content = $wpdb->get_var(  | 
                                                        |
| 277 | - $wpdb->prepare(  | 
                                                        |
| 278 | -                        "SELECT post_content from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s", | 
                                                        |
| 279 | - $current_post  | 
                                                        |
| 280 | - )  | 
                                                        |
| 281 | - );  | 
                                                        |
| 282 | - }  | 
                                                        |
| 283 | - $load_assets = $this->parseContentForShortcodes($post_content);  | 
                                                        |
| 284 | - }  | 
                                                        |
| 285 | -        if ($load_assets) { | 
                                                        |
| 286 | - $this->current_page->setEspressoPage(true);  | 
                                                        |
| 287 | -            add_filter('FHEE_load_css', '__return_true'); | 
                                                        |
| 288 | -            add_filter('FHEE_load_js', '__return_true'); | 
                                                        |
| 289 | - }  | 
                                                        |
| 290 | -        do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller); | 
                                                        |
| 291 | - }  | 
                                                        |
| 292 | -  | 
                                                        |
| 293 | -  | 
                                                        |
| 294 | - /**  | 
                                                        |
| 295 | - * checks supplied content against list of legacy shortcodes,  | 
                                                        |
| 296 | - * then initializes any found shortcodes, and returns true.  | 
                                                        |
| 297 | - * returns false if no shortcodes found.  | 
                                                        |
| 298 | - *  | 
                                                        |
| 299 | - * @param string $content  | 
                                                        |
| 300 | - * @param bool $load_all if true, then ALL active legacy shortcodes will be initialized  | 
                                                        |
| 301 | - * @return bool  | 
                                                        |
| 302 | - * @throws ReflectionException  | 
                                                        |
| 303 | - */  | 
                                                        |
| 304 | - public function parseContentForShortcodes($content = '', $load_all = false)  | 
                                                        |
| 305 | -    { | 
                                                        |
| 306 | - $has_shortcode = false;  | 
                                                        |
| 307 | -        foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { | 
                                                        |
| 308 | -            if ($load_all || has_shortcode($content, $shortcode_class)) { | 
                                                        |
| 309 | - // load up the shortcode  | 
                                                        |
| 310 | - $this->initializeShortcode($shortcode_class);  | 
                                                        |
| 311 | - $has_shortcode = true;  | 
                                                        |
| 312 | - }  | 
                                                        |
| 313 | - }  | 
                                                        |
| 314 | - // one last test for an [espresso_*] shortcode  | 
                                                        |
| 315 | -        if (! $has_shortcode) { | 
                                                        |
| 316 | - $has_shortcode = strpos($content, '[espresso_') !== false;  | 
                                                        |
| 317 | - }  | 
                                                        |
| 318 | - return $has_shortcode;  | 
                                                        |
| 319 | - }  | 
                                                        |
| 320 | -  | 
                                                        |
| 321 | -  | 
                                                        |
| 322 | - /**  | 
                                                        |
| 323 | - * given a shortcode name, will instantiate the shortcode and call it's run() method  | 
                                                        |
| 324 | - *  | 
                                                        |
| 325 | - * @param string $shortcode_class  | 
                                                        |
| 326 | - * @param WP $wp  | 
                                                        |
| 327 | - * @throws ReflectionException  | 
                                                        |
| 328 | - */  | 
                                                        |
| 329 | - public function initializeShortcode($shortcode_class = '', WP $wp = null)  | 
                                                        |
| 330 | -    { | 
                                                        |
| 331 | - // don't do anything if shortcode is already initialized  | 
                                                        |
| 332 | - if (  | 
                                                        |
| 333 | -            empty($this->registry->shortcodes->{$shortcode_class}) | 
                                                        |
| 334 | -            || ! is_string($this->registry->shortcodes->{$shortcode_class}) | 
                                                        |
| 335 | -        ) { | 
                                                        |
| 336 | - return;  | 
                                                        |
| 337 | - }  | 
                                                        |
| 338 | - // let's pause to reflect on this...  | 
                                                        |
| 339 | - $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class));  | 
                                                        |
| 340 | - // ensure that class is actually a shortcode  | 
                                                        |
| 341 | - if (  | 
                                                        |
| 342 | -            defined('WP_DEBUG') | 
                                                        |
| 343 | - && WP_DEBUG === true  | 
                                                        |
| 344 | -            && ! $sc_reflector->isSubclassOf('EES_Shortcode') | 
                                                        |
| 345 | -        ) { | 
                                                        |
| 346 | - EE_Error::add_error(  | 
                                                        |
| 347 | - sprintf(  | 
                                                        |
| 348 | - esc_html__(  | 
                                                        |
| 349 | - 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.',  | 
                                                        |
| 350 | - 'event_espresso'  | 
                                                        |
| 351 | - ),  | 
                                                        |
| 352 | - $shortcode_class  | 
                                                        |
| 353 | - ),  | 
                                                        |
| 354 | - __FILE__,  | 
                                                        |
| 355 | - __FUNCTION__,  | 
                                                        |
| 356 | - __LINE__  | 
                                                        |
| 357 | - );  | 
                                                        |
| 358 | -            add_filter('FHEE_run_EE_the_content', '__return_true'); | 
                                                        |
| 359 | - return;  | 
                                                        |
| 360 | - }  | 
                                                        |
| 361 | - global $wp;  | 
                                                        |
| 362 | - // and pass the request object to the run method  | 
                                                        |
| 363 | -        $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); | 
                                                        |
| 364 | - // fire the shortcode class's run method, so that it can activate resources  | 
                                                        |
| 365 | -        $this->registry->shortcodes->{$shortcode_class}->run($wp); | 
                                                        |
| 366 | - }  | 
                                                        |
| 367 | -  | 
                                                        |
| 368 | -  | 
                                                        |
| 369 | - /**  | 
                                                        |
| 370 | - * get classname, remove EES_prefix, and convert to UPPERCASE  | 
                                                        |
| 371 | - *  | 
                                                        |
| 372 | - * @param string $class_name  | 
                                                        |
| 373 | - * @return string  | 
                                                        |
| 374 | - */  | 
                                                        |
| 375 | - public static function generateShortcodeTagFromClassName($class_name)  | 
                                                        |
| 376 | -    { | 
                                                        |
| 377 | -        return strtoupper(str_replace('EES_', '', $class_name)); | 
                                                        |
| 378 | - }  | 
                                                        |
| 379 | -  | 
                                                        |
| 380 | -  | 
                                                        |
| 381 | - /**  | 
                                                        |
| 382 | - * add EES_prefix and Capitalize words  | 
                                                        |
| 383 | - *  | 
                                                        |
| 384 | - * @param string $tag  | 
                                                        |
| 385 | - * @return string  | 
                                                        |
| 386 | - */  | 
                                                        |
| 387 | - public static function generateShortcodeClassNameFromTag($tag)  | 
                                                        |
| 388 | -    { | 
                                                        |
| 389 | - // order of operation runs from inside to out  | 
                                                        |
| 390 | - // 5) maybe add prefix  | 
                                                        |
| 391 | - return LegacyShortcodesManager::addShortcodeClassPrefix(  | 
                                                        |
| 392 | - // 4) find spaces, replace with underscores  | 
                                                        |
| 393 | - str_replace(  | 
                                                        |
| 394 | - ' ',  | 
                                                        |
| 395 | - '_',  | 
                                                        |
| 396 | - // 3) capitalize first letter of each word  | 
                                                        |
| 397 | - ucwords(  | 
                                                        |
| 398 | - // 2) also change to lowercase so ucwords() will work  | 
                                                        |
| 399 | - strtolower(  | 
                                                        |
| 400 | - // 1) find underscores, replace with spaces so ucwords() will work  | 
                                                        |
| 401 | - str_replace(  | 
                                                        |
| 402 | - '_',  | 
                                                        |
| 403 | - ' ',  | 
                                                        |
| 404 | - $tag  | 
                                                        |
| 405 | - )  | 
                                                        |
| 406 | - )  | 
                                                        |
| 407 | - )  | 
                                                        |
| 408 | - )  | 
                                                        |
| 409 | - );  | 
                                                        |
| 410 | - }  | 
                                                        |
| 411 | -  | 
                                                        |
| 412 | -  | 
                                                        |
| 413 | - /**  | 
                                                        |
| 414 | - * maybe add EES_prefix  | 
                                                        |
| 415 | - *  | 
                                                        |
| 416 | - * @param string $class_name  | 
                                                        |
| 417 | - * @return string  | 
                                                        |
| 418 | - */  | 
                                                        |
| 419 | - public static function addShortcodeClassPrefix($class_name)  | 
                                                        |
| 420 | -    { | 
                                                        |
| 421 | - return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name;  | 
                                                        |
| 422 | - }  | 
                                                        |
| 423 | -  | 
                                                        |
| 424 | -  | 
                                                        |
| 425 | - /**  | 
                                                        |
| 426 | - * @return array  | 
                                                        |
| 427 | - */  | 
                                                        |
| 428 | - public function getEspressoShortcodeTags()  | 
                                                        |
| 429 | -    { | 
                                                        |
| 430 | - static $shortcode_tags = array();  | 
                                                        |
| 431 | -        if (empty($shortcode_tags)) { | 
                                                        |
| 432 | - $shortcode_tags = array_keys((array) $this->registry->shortcodes);  | 
                                                        |
| 433 | - }  | 
                                                        |
| 434 | - return $shortcode_tags;  | 
                                                        |
| 435 | - }  | 
                                                        |
| 436 | -  | 
                                                        |
| 437 | -  | 
                                                        |
| 438 | - /**  | 
                                                        |
| 439 | - * @param string $content  | 
                                                        |
| 440 | - * @return string  | 
                                                        |
| 441 | - * @throws ReflectionException  | 
                                                        |
| 442 | - */  | 
                                                        |
| 443 | - public function doShortcode($content)  | 
                                                        |
| 444 | -    { | 
                                                        |
| 445 | -        foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) { | 
                                                        |
| 446 | -            if (strpos($content, $shortcode_tag) !== false) { | 
                                                        |
| 447 | - $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag);  | 
                                                        |
| 448 | - $this->initializeShortcode($shortcode_class);  | 
                                                        |
| 449 | - }  | 
                                                        |
| 450 | - }  | 
                                                        |
| 451 | - return do_shortcode($content);  | 
                                                        |
| 452 | - }  | 
                                                        |
| 27 | + /**  | 
                                                        |
| 28 | + * @type CurrentPage  | 
                                                        |
| 29 | + */  | 
                                                        |
| 30 | + protected $current_page;  | 
                                                        |
| 31 | +  | 
                                                        |
| 32 | + /**  | 
                                                        |
| 33 | + * @var EE_Registry $registry  | 
                                                        |
| 34 | + */  | 
                                                        |
| 35 | + private $registry;  | 
                                                        |
| 36 | +  | 
                                                        |
| 37 | +  | 
                                                        |
| 38 | + /**  | 
                                                        |
| 39 | + * LegacyShortcodesManager constructor.  | 
                                                        |
| 40 | + *  | 
                                                        |
| 41 | + * @param EE_Registry $registry  | 
                                                        |
| 42 | + * @param CurrentPage $current_page  | 
                                                        |
| 43 | + */  | 
                                                        |
| 44 | + public function __construct(EE_Registry $registry, CurrentPage $current_page)  | 
                                                        |
| 45 | +	{ | 
                                                        |
| 46 | + $this->registry = $registry;  | 
                                                        |
| 47 | + $this->current_page = $current_page;  | 
                                                        |
| 48 | + }  | 
                                                        |
| 49 | +  | 
                                                        |
| 50 | +  | 
                                                        |
| 51 | + /**  | 
                                                        |
| 52 | + * @return EE_Registry  | 
                                                        |
| 53 | + */  | 
                                                        |
| 54 | + public function registry()  | 
                                                        |
| 55 | +	{ | 
                                                        |
| 56 | + return $this->registry;  | 
                                                        |
| 57 | + }  | 
                                                        |
| 58 | +  | 
                                                        |
| 59 | +  | 
                                                        |
| 60 | + /**  | 
                                                        |
| 61 | + * registerShortcodes  | 
                                                        |
| 62 | + *  | 
                                                        |
| 63 | + * @return void  | 
                                                        |
| 64 | + */  | 
                                                        |
| 65 | + public function registerShortcodes()  | 
                                                        |
| 66 | +	{ | 
                                                        |
| 67 | + $this->registry->shortcodes = $this->getShortcodes();  | 
                                                        |
| 68 | + }  | 
                                                        |
| 69 | +  | 
                                                        |
| 70 | +  | 
                                                        |
| 71 | + /**  | 
                                                        |
| 72 | + * getShortcodes  | 
                                                        |
| 73 | + *  | 
                                                        |
| 74 | + * @return array  | 
                                                        |
| 75 | + */  | 
                                                        |
| 76 | + public function getShortcodes()  | 
                                                        |
| 77 | +	{ | 
                                                        |
| 78 | + // previously this method would glob the shortcodes directory  | 
                                                        |
| 79 | + // then filter that list of shortcodes to register,  | 
                                                        |
| 80 | + // but now we are going to just supply an empty array.  | 
                                                        |
| 81 | + // this allows any shortcodes that have not yet been converted to the new system  | 
                                                        |
| 82 | + // to still get loaded and processed, albeit using the same legacy logic as before  | 
                                                        |
| 83 | + $shortcodes_to_register = apply_filters(  | 
                                                        |
| 84 | + 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',  | 
                                                        |
| 85 | + array()  | 
                                                        |
| 86 | + );  | 
                                                        |
| 87 | +		if (! empty($shortcodes_to_register)) { | 
                                                        |
| 88 | + // cycle thru shortcode folders  | 
                                                        |
| 89 | +			foreach ($shortcodes_to_register as $shortcode_path) { | 
                                                        |
| 90 | + // add to list of installed shortcode modules  | 
                                                        |
| 91 | + $this->registerShortcode($shortcode_path);  | 
                                                        |
| 92 | + }  | 
                                                        |
| 93 | + }  | 
                                                        |
| 94 | + // filter list of installed modules  | 
                                                        |
| 95 | + return apply_filters(  | 
                                                        |
| 96 | + 'FHEE__EE_Config___register_shortcodes__installed_shortcodes',  | 
                                                        |
| 97 | + ! empty($this->registry->shortcodes)  | 
                                                        |
| 98 | + ? $this->registry->shortcodes  | 
                                                        |
| 99 | + : array()  | 
                                                        |
| 100 | + );  | 
                                                        |
| 101 | + }  | 
                                                        |
| 102 | +  | 
                                                        |
| 103 | +  | 
                                                        |
| 104 | + /**  | 
                                                        |
| 105 | + * register_shortcode - makes core aware of this shortcode  | 
                                                        |
| 106 | + *  | 
                                                        |
| 107 | + * @param string $shortcode_path - full path up to and including shortcode folder  | 
                                                        |
| 108 | + * @return bool  | 
                                                        |
| 109 | + */  | 
                                                        |
| 110 | + public function registerShortcode($shortcode_path = null)  | 
                                                        |
| 111 | +	{ | 
                                                        |
| 112 | +		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); | 
                                                        |
| 113 | + $shortcode_ext = '.shortcode.php';  | 
                                                        |
| 114 | + // make all separators match  | 
                                                        |
| 115 | +		$shortcode_path = str_replace(array('\\', '/'), '/', $shortcode_path); | 
                                                        |
| 116 | + // does the file path INCLUDE the actual file name as part of the path ?  | 
                                                        |
| 117 | +		if (strpos($shortcode_path, $shortcode_ext) !== false) { | 
                                                        |
| 118 | + // grab shortcode file name from directory name and break apart at dots  | 
                                                        |
| 119 | +			$shortcode_file = explode('.', basename($shortcode_path)); | 
                                                        |
| 120 | + // take first segment from file name pieces and remove class prefix if it exists  | 
                                                        |
| 121 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0  | 
                                                        |
| 122 | + ? substr($shortcode_file[0], 4)  | 
                                                        |
| 123 | + : $shortcode_file[0];  | 
                                                        |
| 124 | + // sanitize shortcode directory name  | 
                                                        |
| 125 | + $shortcode = sanitize_key($shortcode);  | 
                                                        |
| 126 | + // now we need to rebuild the shortcode path  | 
                                                        |
| 127 | +			$shortcode_path = explode('/', $shortcode_path); | 
                                                        |
| 128 | + // remove last segment  | 
                                                        |
| 129 | + array_pop($shortcode_path);  | 
                                                        |
| 130 | + // glue it back together  | 
                                                        |
| 131 | +			$shortcode_path = implode('/', $shortcode_path) . '/'; | 
                                                        |
| 132 | +		} else { | 
                                                        |
| 133 | + // we need to generate the filename based off of the folder name  | 
                                                        |
| 134 | + // grab and sanitize shortcode directory name  | 
                                                        |
| 135 | + $shortcode = sanitize_key(basename($shortcode_path));  | 
                                                        |
| 136 | + $shortcode_path = rtrim($shortcode_path, '/') . '/';  | 
                                                        |
| 137 | + }  | 
                                                        |
| 138 | + // create classname from shortcode directory or file name  | 
                                                        |
| 139 | +		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); | 
                                                        |
| 140 | + // add class prefix  | 
                                                        |
| 141 | + $shortcode_class = 'EES_' . $shortcode;  | 
                                                        |
| 142 | + // does the shortcode exist ?  | 
                                                        |
| 143 | +		if (! is_readable($shortcode_path . '/' . $shortcode_class . $shortcode_ext)) { | 
                                                        |
| 144 | + $msg = sprintf(  | 
                                                        |
| 145 | + esc_html__(  | 
                                                        |
| 146 | + 'The requested %1$s shortcode file could not be found or is not readable due to file permissions. It should be in %2$s',  | 
                                                        |
| 147 | + 'event_espresso'  | 
                                                        |
| 148 | + ),  | 
                                                        |
| 149 | + $shortcode_class,  | 
                                                        |
| 150 | + $shortcode_path . '/' . $shortcode_class . $shortcode_ext  | 
                                                        |
| 151 | + );  | 
                                                        |
| 152 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 153 | + return false;  | 
                                                        |
| 154 | + }  | 
                                                        |
| 155 | + // load the shortcode class file  | 
                                                        |
| 156 | + require_once($shortcode_path . $shortcode_class . $shortcode_ext);  | 
                                                        |
| 157 | + // verify that class exists  | 
                                                        |
| 158 | +		if (! class_exists($shortcode_class)) { | 
                                                        |
| 159 | + $msg = sprintf(  | 
                                                        |
| 160 | +				esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), | 
                                                        |
| 161 | + $shortcode_class  | 
                                                        |
| 162 | + );  | 
                                                        |
| 163 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 164 | + return false;  | 
                                                        |
| 165 | + }  | 
                                                        |
| 166 | + $shortcode = strtoupper($shortcode);  | 
                                                        |
| 167 | + // add to array of registered shortcodes  | 
                                                        |
| 168 | +		$this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; | 
                                                        |
| 169 | + return true;  | 
                                                        |
| 170 | + }  | 
                                                        |
| 171 | +  | 
                                                        |
| 172 | +  | 
                                                        |
| 173 | + /**  | 
                                                        |
| 174 | + * _initialize_shortcodes  | 
                                                        |
| 175 | + * allow shortcodes to set hooks for the rest of the system  | 
                                                        |
| 176 | + *  | 
                                                        |
| 177 | + * @return void  | 
                                                        |
| 178 | + */  | 
                                                        |
| 179 | + public function addShortcodes()  | 
                                                        |
| 180 | +	{ | 
                                                        |
| 181 | + // cycle thru shortcode folders  | 
                                                        |
| 182 | +		foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { | 
                                                        |
| 183 | + // add class prefix  | 
                                                        |
| 184 | + $shortcode_class = 'EES_' . $shortcode;  | 
                                                        |
| 185 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system  | 
                                                        |
| 186 | + // which set hooks ?  | 
                                                        |
| 187 | +			if (is_admin()) { | 
                                                        |
| 188 | + // fire immediately  | 
                                                        |
| 189 | + call_user_func(array($shortcode_class, 'set_hooks_admin'));  | 
                                                        |
| 190 | +			} else { | 
                                                        |
| 191 | + // delay until other systems are online  | 
                                                        |
| 192 | + add_action(  | 
                                                        |
| 193 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',  | 
                                                        |
| 194 | + array($shortcode_class, 'set_hooks')  | 
                                                        |
| 195 | + );  | 
                                                        |
| 196 | + // convert classname to UPPERCASE and create WP shortcode.  | 
                                                        |
| 197 | + $shortcode_tag = strtoupper($shortcode);  | 
                                                        |
| 198 | + // but first check if the shortcode has already  | 
                                                        |
| 199 | + // been added before assigning 'fallback_shortcode_processor'  | 
                                                        |
| 200 | +				if (! shortcode_exists($shortcode_tag)) { | 
                                                        |
| 201 | + // NOTE: this shortcode declaration will get overridden if the shortcode  | 
                                                        |
| 202 | + // is successfully detected in the post content in initializeShortcode()  | 
                                                        |
| 203 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));  | 
                                                        |
| 204 | + }  | 
                                                        |
| 205 | + }  | 
                                                        |
| 206 | + }  | 
                                                        |
| 207 | + }  | 
                                                        |
| 208 | +  | 
                                                        |
| 209 | +  | 
                                                        |
| 210 | + /**  | 
                                                        |
| 211 | + * callback for the WP "get_header" hook point  | 
                                                        |
| 212 | + * checks posts for EE shortcodes, and initializes them,  | 
                                                        |
| 213 | + * then toggles filter switch that loads core default assets  | 
                                                        |
| 214 | + *  | 
                                                        |
| 215 | + * @param WP_Query $wp_query  | 
                                                        |
| 216 | + * @return void  | 
                                                        |
| 217 | + * @throws ReflectionException  | 
                                                        |
| 218 | + */  | 
                                                        |
| 219 | + public function initializeShortcodes(WP_Query $wp_query)  | 
                                                        |
| 220 | +	{ | 
                                                        |
| 221 | +		if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) { | 
                                                        |
| 222 | + return;  | 
                                                        |
| 223 | + }  | 
                                                        |
| 224 | + global $wp;  | 
                                                        |
| 225 | + /** @var EE_Front_controller $Front_Controller */  | 
                                                        |
| 226 | +		$Front_Controller = LoaderFactory::getLoader()->getShared('EE_Front_Controller'); | 
                                                        |
| 227 | +		do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller); | 
                                                        |
| 228 | + $this->current_page->parseQueryVars();  | 
                                                        |
| 229 | + // grab post_name from request  | 
                                                        |
| 230 | + $current_post = apply_filters(  | 
                                                        |
| 231 | + 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name',  | 
                                                        |
| 232 | + $this->current_page->postName()  | 
                                                        |
| 233 | + );  | 
                                                        |
| 234 | +		$show_on_front = get_option('show_on_front'); | 
                                                        |
| 235 | + // if it's not set, then check if frontpage is blog  | 
                                                        |
| 236 | +		if (empty($current_post)) { | 
                                                        |
| 237 | + // yup.. this is the posts page, prepare to load all shortcode modules  | 
                                                        |
| 238 | + $current_post = 'posts';  | 
                                                        |
| 239 | + // unless..  | 
                                                        |
| 240 | +			if ($show_on_front === 'page') { | 
                                                        |
| 241 | + // some other page is set as the homepage  | 
                                                        |
| 242 | +				$page_on_front = get_option('page_on_front'); | 
                                                        |
| 243 | +				if ($page_on_front) { | 
                                                        |
| 244 | + // k now we need to find the post_name for this page  | 
                                                        |
| 245 | + global $wpdb;  | 
                                                        |
| 246 | + $page_on_front = $wpdb->get_var(  | 
                                                        |
| 247 | + $wpdb->prepare(  | 
                                                        |
| 248 | +							"SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d", | 
                                                        |
| 249 | + $page_on_front  | 
                                                        |
| 250 | + )  | 
                                                        |
| 251 | + );  | 
                                                        |
| 252 | + // set the current post slug to what it actually is  | 
                                                        |
| 253 | + $current_post = $page_on_front ?: $current_post;  | 
                                                        |
| 254 | + }  | 
                                                        |
| 255 | + }  | 
                                                        |
| 256 | + }  | 
                                                        |
| 257 | + // in case $current_post is hierarchical like: /parent-page/current-page  | 
                                                        |
| 258 | + $current_post = basename($current_post);  | 
                                                        |
| 259 | + if (  | 
                                                        |
| 260 | + // is current page/post the "blog" page ?  | 
                                                        |
| 261 | + $current_post === EE_Config::get_page_for_posts()  | 
                                                        |
| 262 | + // or are we on a category page?  | 
                                                        |
| 263 | + || (  | 
                                                        |
| 264 | + is_array(term_exists($current_post, 'category'))  | 
                                                        |
| 265 | +				|| array_key_exists('category_name', $wp->query_vars) | 
                                                        |
| 266 | + )  | 
                                                        |
| 267 | +		) { | 
                                                        |
| 268 | + // initialize all legacy shortcodes  | 
                                                        |
| 269 | +			$load_assets = $this->parseContentForShortcodes('', true); | 
                                                        |
| 270 | +		} else { | 
                                                        |
| 271 | + global $post;  | 
                                                        |
| 272 | +			if ($post instanceof WP_Post) { | 
                                                        |
| 273 | + $post_content = $post->post_content;  | 
                                                        |
| 274 | +			} else { | 
                                                        |
| 275 | + global $wpdb;  | 
                                                        |
| 276 | + $post_content = $wpdb->get_var(  | 
                                                        |
| 277 | + $wpdb->prepare(  | 
                                                        |
| 278 | +						"SELECT post_content from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s", | 
                                                        |
| 279 | + $current_post  | 
                                                        |
| 280 | + )  | 
                                                        |
| 281 | + );  | 
                                                        |
| 282 | + }  | 
                                                        |
| 283 | + $load_assets = $this->parseContentForShortcodes($post_content);  | 
                                                        |
| 284 | + }  | 
                                                        |
| 285 | +		if ($load_assets) { | 
                                                        |
| 286 | + $this->current_page->setEspressoPage(true);  | 
                                                        |
| 287 | +			add_filter('FHEE_load_css', '__return_true'); | 
                                                        |
| 288 | +			add_filter('FHEE_load_js', '__return_true'); | 
                                                        |
| 289 | + }  | 
                                                        |
| 290 | +		do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller); | 
                                                        |
| 291 | + }  | 
                                                        |
| 292 | +  | 
                                                        |
| 293 | +  | 
                                                        |
| 294 | + /**  | 
                                                        |
| 295 | + * checks supplied content against list of legacy shortcodes,  | 
                                                        |
| 296 | + * then initializes any found shortcodes, and returns true.  | 
                                                        |
| 297 | + * returns false if no shortcodes found.  | 
                                                        |
| 298 | + *  | 
                                                        |
| 299 | + * @param string $content  | 
                                                        |
| 300 | + * @param bool $load_all if true, then ALL active legacy shortcodes will be initialized  | 
                                                        |
| 301 | + * @return bool  | 
                                                        |
| 302 | + * @throws ReflectionException  | 
                                                        |
| 303 | + */  | 
                                                        |
| 304 | + public function parseContentForShortcodes($content = '', $load_all = false)  | 
                                                        |
| 305 | +	{ | 
                                                        |
| 306 | + $has_shortcode = false;  | 
                                                        |
| 307 | +		foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { | 
                                                        |
| 308 | +			if ($load_all || has_shortcode($content, $shortcode_class)) { | 
                                                        |
| 309 | + // load up the shortcode  | 
                                                        |
| 310 | + $this->initializeShortcode($shortcode_class);  | 
                                                        |
| 311 | + $has_shortcode = true;  | 
                                                        |
| 312 | + }  | 
                                                        |
| 313 | + }  | 
                                                        |
| 314 | + // one last test for an [espresso_*] shortcode  | 
                                                        |
| 315 | +		if (! $has_shortcode) { | 
                                                        |
| 316 | + $has_shortcode = strpos($content, '[espresso_') !== false;  | 
                                                        |
| 317 | + }  | 
                                                        |
| 318 | + return $has_shortcode;  | 
                                                        |
| 319 | + }  | 
                                                        |
| 320 | +  | 
                                                        |
| 321 | +  | 
                                                        |
| 322 | + /**  | 
                                                        |
| 323 | + * given a shortcode name, will instantiate the shortcode and call it's run() method  | 
                                                        |
| 324 | + *  | 
                                                        |
| 325 | + * @param string $shortcode_class  | 
                                                        |
| 326 | + * @param WP $wp  | 
                                                        |
| 327 | + * @throws ReflectionException  | 
                                                        |
| 328 | + */  | 
                                                        |
| 329 | + public function initializeShortcode($shortcode_class = '', WP $wp = null)  | 
                                                        |
| 330 | +	{ | 
                                                        |
| 331 | + // don't do anything if shortcode is already initialized  | 
                                                        |
| 332 | + if (  | 
                                                        |
| 333 | +			empty($this->registry->shortcodes->{$shortcode_class}) | 
                                                        |
| 334 | +			|| ! is_string($this->registry->shortcodes->{$shortcode_class}) | 
                                                        |
| 335 | +		) { | 
                                                        |
| 336 | + return;  | 
                                                        |
| 337 | + }  | 
                                                        |
| 338 | + // let's pause to reflect on this...  | 
                                                        |
| 339 | + $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class));  | 
                                                        |
| 340 | + // ensure that class is actually a shortcode  | 
                                                        |
| 341 | + if (  | 
                                                        |
| 342 | +			defined('WP_DEBUG') | 
                                                        |
| 343 | + && WP_DEBUG === true  | 
                                                        |
| 344 | +			&& ! $sc_reflector->isSubclassOf('EES_Shortcode') | 
                                                        |
| 345 | +		) { | 
                                                        |
| 346 | + EE_Error::add_error(  | 
                                                        |
| 347 | + sprintf(  | 
                                                        |
| 348 | + esc_html__(  | 
                                                        |
| 349 | + 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.',  | 
                                                        |
| 350 | + 'event_espresso'  | 
                                                        |
| 351 | + ),  | 
                                                        |
| 352 | + $shortcode_class  | 
                                                        |
| 353 | + ),  | 
                                                        |
| 354 | + __FILE__,  | 
                                                        |
| 355 | + __FUNCTION__,  | 
                                                        |
| 356 | + __LINE__  | 
                                                        |
| 357 | + );  | 
                                                        |
| 358 | +			add_filter('FHEE_run_EE_the_content', '__return_true'); | 
                                                        |
| 359 | + return;  | 
                                                        |
| 360 | + }  | 
                                                        |
| 361 | + global $wp;  | 
                                                        |
| 362 | + // and pass the request object to the run method  | 
                                                        |
| 363 | +		$this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); | 
                                                        |
| 364 | + // fire the shortcode class's run method, so that it can activate resources  | 
                                                        |
| 365 | +		$this->registry->shortcodes->{$shortcode_class}->run($wp); | 
                                                        |
| 366 | + }  | 
                                                        |
| 367 | +  | 
                                                        |
| 368 | +  | 
                                                        |
| 369 | + /**  | 
                                                        |
| 370 | + * get classname, remove EES_prefix, and convert to UPPERCASE  | 
                                                        |
| 371 | + *  | 
                                                        |
| 372 | + * @param string $class_name  | 
                                                        |
| 373 | + * @return string  | 
                                                        |
| 374 | + */  | 
                                                        |
| 375 | + public static function generateShortcodeTagFromClassName($class_name)  | 
                                                        |
| 376 | +	{ | 
                                                        |
| 377 | +		return strtoupper(str_replace('EES_', '', $class_name)); | 
                                                        |
| 378 | + }  | 
                                                        |
| 379 | +  | 
                                                        |
| 380 | +  | 
                                                        |
| 381 | + /**  | 
                                                        |
| 382 | + * add EES_prefix and Capitalize words  | 
                                                        |
| 383 | + *  | 
                                                        |
| 384 | + * @param string $tag  | 
                                                        |
| 385 | + * @return string  | 
                                                        |
| 386 | + */  | 
                                                        |
| 387 | + public static function generateShortcodeClassNameFromTag($tag)  | 
                                                        |
| 388 | +	{ | 
                                                        |
| 389 | + // order of operation runs from inside to out  | 
                                                        |
| 390 | + // 5) maybe add prefix  | 
                                                        |
| 391 | + return LegacyShortcodesManager::addShortcodeClassPrefix(  | 
                                                        |
| 392 | + // 4) find spaces, replace with underscores  | 
                                                        |
| 393 | + str_replace(  | 
                                                        |
| 394 | + ' ',  | 
                                                        |
| 395 | + '_',  | 
                                                        |
| 396 | + // 3) capitalize first letter of each word  | 
                                                        |
| 397 | + ucwords(  | 
                                                        |
| 398 | + // 2) also change to lowercase so ucwords() will work  | 
                                                        |
| 399 | + strtolower(  | 
                                                        |
| 400 | + // 1) find underscores, replace with spaces so ucwords() will work  | 
                                                        |
| 401 | + str_replace(  | 
                                                        |
| 402 | + '_',  | 
                                                        |
| 403 | + ' ',  | 
                                                        |
| 404 | + $tag  | 
                                                        |
| 405 | + )  | 
                                                        |
| 406 | + )  | 
                                                        |
| 407 | + )  | 
                                                        |
| 408 | + )  | 
                                                        |
| 409 | + );  | 
                                                        |
| 410 | + }  | 
                                                        |
| 411 | +  | 
                                                        |
| 412 | +  | 
                                                        |
| 413 | + /**  | 
                                                        |
| 414 | + * maybe add EES_prefix  | 
                                                        |
| 415 | + *  | 
                                                        |
| 416 | + * @param string $class_name  | 
                                                        |
| 417 | + * @return string  | 
                                                        |
| 418 | + */  | 
                                                        |
| 419 | + public static function addShortcodeClassPrefix($class_name)  | 
                                                        |
| 420 | +	{ | 
                                                        |
| 421 | + return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name;  | 
                                                        |
| 422 | + }  | 
                                                        |
| 423 | +  | 
                                                        |
| 424 | +  | 
                                                        |
| 425 | + /**  | 
                                                        |
| 426 | + * @return array  | 
                                                        |
| 427 | + */  | 
                                                        |
| 428 | + public function getEspressoShortcodeTags()  | 
                                                        |
| 429 | +	{ | 
                                                        |
| 430 | + static $shortcode_tags = array();  | 
                                                        |
| 431 | +		if (empty($shortcode_tags)) { | 
                                                        |
| 432 | + $shortcode_tags = array_keys((array) $this->registry->shortcodes);  | 
                                                        |
| 433 | + }  | 
                                                        |
| 434 | + return $shortcode_tags;  | 
                                                        |
| 435 | + }  | 
                                                        |
| 436 | +  | 
                                                        |
| 437 | +  | 
                                                        |
| 438 | + /**  | 
                                                        |
| 439 | + * @param string $content  | 
                                                        |
| 440 | + * @return string  | 
                                                        |
| 441 | + * @throws ReflectionException  | 
                                                        |
| 442 | + */  | 
                                                        |
| 443 | + public function doShortcode($content)  | 
                                                        |
| 444 | +	{ | 
                                                        |
| 445 | +		foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) { | 
                                                        |
| 446 | +			if (strpos($content, $shortcode_tag) !== false) { | 
                                                        |
| 447 | + $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag);  | 
                                                        |
| 448 | + $this->initializeShortcode($shortcode_class);  | 
                                                        |
| 449 | + }  | 
                                                        |
| 450 | + }  | 
                                                        |
| 451 | + return do_shortcode($content);  | 
                                                        |
| 452 | + }  | 
                                                        |
| 453 | 453 | }  | 
                                                        
@@ -84,7 +84,7 @@ discard block  | 
                                                    ||
| 84 | 84 | 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',  | 
                                                        
| 85 | 85 | array()  | 
                                                        
| 86 | 86 | );  | 
                                                        
| 87 | -        if (! empty($shortcodes_to_register)) { | 
                                                        |
| 87 | +        if ( ! empty($shortcodes_to_register)) { | 
                                                        |
| 88 | 88 | // cycle thru shortcode folders  | 
                                                        
| 89 | 89 |              foreach ($shortcodes_to_register as $shortcode_path) { | 
                                                        
| 90 | 90 | // add to list of installed shortcode modules  | 
                                                        
@@ -128,44 +128,44 @@ discard block  | 
                                                    ||
| 128 | 128 | // remove last segment  | 
                                                        
| 129 | 129 | array_pop($shortcode_path);  | 
                                                        
| 130 | 130 | // glue it back together  | 
                                                        
| 131 | -            $shortcode_path = implode('/', $shortcode_path) . '/'; | 
                                                        |
| 131 | +            $shortcode_path = implode('/', $shortcode_path).'/'; | 
                                                        |
| 132 | 132 |          } else { | 
                                                        
| 133 | 133 | // we need to generate the filename based off of the folder name  | 
                                                        
| 134 | 134 | // grab and sanitize shortcode directory name  | 
                                                        
| 135 | 135 | $shortcode = sanitize_key(basename($shortcode_path));  | 
                                                        
| 136 | - $shortcode_path = rtrim($shortcode_path, '/') . '/';  | 
                                                        |
| 136 | + $shortcode_path = rtrim($shortcode_path, '/').'/';  | 
                                                        |
| 137 | 137 | }  | 
                                                        
| 138 | 138 | // create classname from shortcode directory or file name  | 
                                                        
| 139 | 139 |          $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); | 
                                                        
| 140 | 140 | // add class prefix  | 
                                                        
| 141 | - $shortcode_class = 'EES_' . $shortcode;  | 
                                                        |
| 141 | + $shortcode_class = 'EES_'.$shortcode;  | 
                                                        |
| 142 | 142 | // does the shortcode exist ?  | 
                                                        
| 143 | -        if (! is_readable($shortcode_path . '/' . $shortcode_class . $shortcode_ext)) { | 
                                                        |
| 143 | +        if ( ! is_readable($shortcode_path.'/'.$shortcode_class.$shortcode_ext)) { | 
                                                        |
| 144 | 144 | $msg = sprintf(  | 
                                                        
| 145 | 145 | esc_html__(  | 
                                                        
| 146 | 146 | 'The requested %1$s shortcode file could not be found or is not readable due to file permissions. It should be in %2$s',  | 
                                                        
| 147 | 147 | 'event_espresso'  | 
                                                        
| 148 | 148 | ),  | 
                                                        
| 149 | 149 | $shortcode_class,  | 
                                                        
| 150 | - $shortcode_path . '/' . $shortcode_class . $shortcode_ext  | 
                                                        |
| 150 | + $shortcode_path.'/'.$shortcode_class.$shortcode_ext  | 
                                                        |
| 151 | 151 | );  | 
                                                        
| 152 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 152 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 153 | 153 | return false;  | 
                                                        
| 154 | 154 | }  | 
                                                        
| 155 | 155 | // load the shortcode class file  | 
                                                        
| 156 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext);  | 
                                                        |
| 156 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext);  | 
                                                        |
| 157 | 157 | // verify that class exists  | 
                                                        
| 158 | -        if (! class_exists($shortcode_class)) { | 
                                                        |
| 158 | +        if ( ! class_exists($shortcode_class)) { | 
                                                        |
| 159 | 159 | $msg = sprintf(  | 
                                                        
| 160 | 160 |                  esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), | 
                                                        
| 161 | 161 | $shortcode_class  | 
                                                        
| 162 | 162 | );  | 
                                                        
| 163 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 163 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 164 | 164 | return false;  | 
                                                        
| 165 | 165 | }  | 
                                                        
| 166 | 166 | $shortcode = strtoupper($shortcode);  | 
                                                        
| 167 | 167 | // add to array of registered shortcodes  | 
                                                        
| 168 | -        $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; | 
                                                        |
| 168 | +        $this->registry->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; | 
                                                        |
| 169 | 169 | return true;  | 
                                                        
| 170 | 170 | }  | 
                                                        
| 171 | 171 | |
@@ -181,7 +181,7 @@ discard block  | 
                                                    ||
| 181 | 181 | // cycle thru shortcode folders  | 
                                                        
| 182 | 182 |          foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { | 
                                                        
| 183 | 183 | // add class prefix  | 
                                                        
| 184 | - $shortcode_class = 'EES_' . $shortcode;  | 
                                                        |
| 184 | + $shortcode_class = 'EES_'.$shortcode;  | 
                                                        |
| 185 | 185 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system  | 
                                                        
| 186 | 186 | // which set hooks ?  | 
                                                        
| 187 | 187 |              if (is_admin()) { | 
                                                        
@@ -197,7 +197,7 @@ discard block  | 
                                                    ||
| 197 | 197 | $shortcode_tag = strtoupper($shortcode);  | 
                                                        
| 198 | 198 | // but first check if the shortcode has already  | 
                                                        
| 199 | 199 | // been added before assigning 'fallback_shortcode_processor'  | 
                                                        
| 200 | -                if (! shortcode_exists($shortcode_tag)) { | 
                                                        |
| 200 | +                if ( ! shortcode_exists($shortcode_tag)) { | 
                                                        |
| 201 | 201 | // NOTE: this shortcode declaration will get overridden if the shortcode  | 
                                                        
| 202 | 202 | // is successfully detected in the post content in initializeShortcode()  | 
                                                        
| 203 | 203 | add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));  | 
                                                        
@@ -312,7 +312,7 @@ discard block  | 
                                                    ||
| 312 | 312 | }  | 
                                                        
| 313 | 313 | }  | 
                                                        
| 314 | 314 | // one last test for an [espresso_*] shortcode  | 
                                                        
| 315 | -        if (! $has_shortcode) { | 
                                                        |
| 315 | +        if ( ! $has_shortcode) { | 
                                                        |
| 316 | 316 | $has_shortcode = strpos($content, '[espresso_') !== false;  | 
                                                        
| 317 | 317 | }  | 
                                                        
| 318 | 318 | return $has_shortcode;  | 
                                                        
@@ -418,7 +418,7 @@ discard block  | 
                                                    ||
| 418 | 418 | */  | 
                                                        
| 419 | 419 | public static function addShortcodeClassPrefix($class_name)  | 
                                                        
| 420 | 420 |      { | 
                                                        
| 421 | - return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name;  | 
                                                        |
| 421 | + return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_'.$class_name;  | 
                                                        |
| 422 | 422 | }  | 
                                                        
| 423 | 423 | |
| 424 | 424 | |
@@ -23,321 +23,321 @@  | 
                                                    ||
| 23 | 23 | */  | 
                                                        
| 24 | 24 | class CurrentPage  | 
                                                        
| 25 | 25 |  { | 
                                                        
| 26 | - /**  | 
                                                        |
| 27 | - * @var EE_CPT_Strategy  | 
                                                        |
| 28 | - */  | 
                                                        |
| 29 | - private $cpt_strategy;  | 
                                                        |
| 30 | -  | 
                                                        |
| 31 | - /**  | 
                                                        |
| 32 | - * @var bool  | 
                                                        |
| 33 | - */  | 
                                                        |
| 34 | - private $initialized;  | 
                                                        |
| 35 | -  | 
                                                        |
| 36 | - /**  | 
                                                        |
| 37 | - * @var bool  | 
                                                        |
| 38 | - */  | 
                                                        |
| 39 | - private $is_espresso_page;  | 
                                                        |
| 40 | -  | 
                                                        |
| 41 | - /**  | 
                                                        |
| 42 | - * @var int  | 
                                                        |
| 43 | - */  | 
                                                        |
| 44 | - private $post_id = 0;  | 
                                                        |
| 45 | -  | 
                                                        |
| 46 | - /**  | 
                                                        |
| 47 | - * @var string  | 
                                                        |
| 48 | - */  | 
                                                        |
| 49 | - private $post_name = '';  | 
                                                        |
| 50 | -  | 
                                                        |
| 51 | - /**  | 
                                                        |
| 52 | - * @var array  | 
                                                        |
| 53 | - */  | 
                                                        |
| 54 | - private $post_type = [];  | 
                                                        |
| 55 | -  | 
                                                        |
| 56 | - /**  | 
                                                        |
| 57 | - * @var RequestInterface $request  | 
                                                        |
| 58 | - */  | 
                                                        |
| 59 | - private $request;  | 
                                                        |
| 60 | -  | 
                                                        |
| 61 | -  | 
                                                        |
| 62 | - /**  | 
                                                        |
| 63 | - * CurrentPage constructor.  | 
                                                        |
| 64 | - *  | 
                                                        |
| 65 | - * @param EE_CPT_Strategy $cpt_strategy  | 
                                                        |
| 66 | - * @param RequestInterface $request  | 
                                                        |
| 67 | - */  | 
                                                        |
| 68 | - public function __construct(EE_CPT_Strategy $cpt_strategy, RequestInterface $request)  | 
                                                        |
| 69 | -    { | 
                                                        |
| 70 | - $this->cpt_strategy = $cpt_strategy;  | 
                                                        |
| 71 | - $this->request = $request;  | 
                                                        |
| 72 | - $this->initialized = is_admin();  | 
                                                        |
| 73 | - // analyse the incoming WP request  | 
                                                        |
| 74 | -        add_action('parse_request', [$this, 'parseQueryVars'], 2, 1); | 
                                                        |
| 75 | - }  | 
                                                        |
| 76 | -  | 
                                                        |
| 77 | -  | 
                                                        |
| 78 | - /**  | 
                                                        |
| 79 | - * @param WP $WP  | 
                                                        |
| 80 | - * @return void  | 
                                                        |
| 81 | - */  | 
                                                        |
| 82 | - public function parseQueryVars(WP $WP = null)  | 
                                                        |
| 83 | -    { | 
                                                        |
| 84 | -        if ($this->initialized) { | 
                                                        |
| 85 | - return;  | 
                                                        |
| 86 | - }  | 
                                                        |
| 87 | - // if somebody forgot to provide us with WP, that's ok because its global  | 
                                                        |
| 88 | -        if (! $WP instanceof WP) { | 
                                                        |
| 89 | - global $WP;  | 
                                                        |
| 90 | - }  | 
                                                        |
| 91 | - $this->post_id = $this->getPostId($WP);  | 
                                                        |
| 92 | - $this->post_name = $this->getPostName($WP);  | 
                                                        |
| 93 | - $this->post_type = $this->getPostType($WP);  | 
                                                        |
| 94 | - // true or false ? is this page being used by EE ?  | 
                                                        |
| 95 | - $this->setEspressoPage();  | 
                                                        |
| 96 | -        remove_action('parse_request', [$this, 'parseRequest'], 2); | 
                                                        |
| 97 | - $this->initialized = true;  | 
                                                        |
| 98 | - }  | 
                                                        |
| 99 | -  | 
                                                        |
| 100 | -  | 
                                                        |
| 101 | - /**  | 
                                                        |
| 102 | - * Just a helper method for getting the url for the displayed page.  | 
                                                        |
| 103 | - *  | 
                                                        |
| 104 | - * @param WP|null $WP  | 
                                                        |
| 105 | - * @return string  | 
                                                        |
| 106 | - */  | 
                                                        |
| 107 | - public function getPermalink(WP $WP = null)  | 
                                                        |
| 108 | -    { | 
                                                        |
| 109 | - $post_id = $this->post_id ?: $this->getPostId($WP);  | 
                                                        |
| 110 | -        if ($post_id) { | 
                                                        |
| 111 | - return get_permalink($post_id);  | 
                                                        |
| 112 | - }  | 
                                                        |
| 113 | -        if (! $WP instanceof WP) { | 
                                                        |
| 114 | - global $WP;  | 
                                                        |
| 115 | - }  | 
                                                        |
| 116 | -        if ($WP instanceof WP && $WP->request) { | 
                                                        |
| 117 | - return site_url($WP->request);  | 
                                                        |
| 118 | - }  | 
                                                        |
| 119 | - return esc_url_raw(site_url($_SERVER['REQUEST_URI']));  | 
                                                        |
| 120 | - }  | 
                                                        |
| 121 | -  | 
                                                        |
| 122 | -  | 
                                                        |
| 123 | - /**  | 
                                                        |
| 124 | - * @return array  | 
                                                        |
| 125 | - */  | 
                                                        |
| 126 | - public function espressoPostType()  | 
                                                        |
| 127 | -    { | 
                                                        |
| 128 | - return array_filter(  | 
                                                        |
| 129 | - $this->post_type,  | 
                                                        |
| 130 | -            function ($post_type) { | 
                                                        |
| 131 | - return strpos($post_type, 'espresso_') === 0;  | 
                                                        |
| 132 | - }  | 
                                                        |
| 133 | - );  | 
                                                        |
| 134 | - }  | 
                                                        |
| 135 | -  | 
                                                        |
| 136 | -  | 
                                                        |
| 137 | - /**  | 
                                                        |
| 138 | - * pokes and prods the WP object query_vars in an attempt to shake out a page/post ID  | 
                                                        |
| 139 | - *  | 
                                                        |
| 140 | - * @param WP $WP  | 
                                                        |
| 141 | - * @return int  | 
                                                        |
| 142 | - */  | 
                                                        |
| 143 | - private function getPostId(WP $WP = null)  | 
                                                        |
| 144 | -    { | 
                                                        |
| 145 | - $post_id = null;  | 
                                                        |
| 146 | -        if ($WP instanceof WP) { | 
                                                        |
| 147 | - // look for the post ID in the aptly named 'p' query var  | 
                                                        |
| 148 | -            if (isset($WP->query_vars['p'])) { | 
                                                        |
| 149 | - $post_id = $WP->query_vars['p'];  | 
                                                        |
| 150 | - }  | 
                                                        |
| 151 | - // not a post? what about a page?  | 
                                                        |
| 152 | -            if (! $post_id && isset($WP->query_vars['page_id'])) { | 
                                                        |
| 153 | - $post_id = $WP->query_vars['page_id'];  | 
                                                        |
| 154 | - }  | 
                                                        |
| 155 | - // ok... maybe pretty permalinks are off and the ID is set in the raw request...  | 
                                                        |
| 156 | - // but hasn't been processed yet ie: this method is being called too early :\  | 
                                                        |
| 157 | -            if (! $post_id && $WP->request !== null && is_numeric(basename($WP->request))) { | 
                                                        |
| 158 | - $post_id = basename($WP->request);  | 
                                                        |
| 159 | - }  | 
                                                        |
| 160 | - }  | 
                                                        |
| 161 | - // none of the above? ok what about an explicit "post_id" URL parameter?  | 
                                                        |
| 162 | -        if (! $post_id && $this->request->requestParamIsSet('post_id')) { | 
                                                        |
| 163 | -            $post_id = $this->request->getRequestParam('post_id'); | 
                                                        |
| 164 | - }  | 
                                                        |
| 165 | - return $post_id;  | 
                                                        |
| 166 | - }  | 
                                                        |
| 167 | -  | 
                                                        |
| 168 | -  | 
                                                        |
| 169 | - /**  | 
                                                        |
| 170 | - * similar to getPostId() above but attempts to obtain the "name" for the current page/post  | 
                                                        |
| 171 | - *  | 
                                                        |
| 172 | - * @param WP $WP  | 
                                                        |
| 173 | - * @return string  | 
                                                        |
| 174 | - */  | 
                                                        |
| 175 | - private function getPostName(WP $WP = null)  | 
                                                        |
| 176 | -    { | 
                                                        |
| 177 | - global $wpdb;  | 
                                                        |
| 178 | - $post_name = null;  | 
                                                        |
| 179 | -        if ($WP instanceof WP) { | 
                                                        |
| 180 | - // if this is a post, then is the post name set?  | 
                                                        |
| 181 | -            if (isset($WP->query_vars['name']) && ! empty($WP->query_vars['name'])) { | 
                                                        |
| 182 | - $post_name = $WP->query_vars['name'];  | 
                                                        |
| 183 | - }  | 
                                                        |
| 184 | - // what about the page name?  | 
                                                        |
| 185 | -            if (! $post_name && isset($WP->query_vars['pagename']) && ! empty($WP->query_vars['pagename'])) { | 
                                                        |
| 186 | - $post_name = $WP->query_vars['pagename'];  | 
                                                        |
| 187 | - }  | 
                                                        |
| 188 | - // this stinks but let's run a query to try and get the post name from the URL  | 
                                                        |
| 189 | - // (assuming pretty permalinks are on)  | 
                                                        |
| 190 | -            if (! $post_name && ! empty($WP->request)) { | 
                                                        |
| 191 | - $possible_post_name = basename($WP->request);  | 
                                                        |
| 192 | -                if (! is_numeric($possible_post_name)) { | 
                                                        |
| 193 | -                    $SQL                = "SELECT ID from {$wpdb->posts}"; | 
                                                        |
| 194 | -                    $SQL                .= " WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash')"; | 
                                                        |
| 195 | - $SQL .= ' AND post_name=%s';  | 
                                                        |
| 196 | - $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name));  | 
                                                        |
| 197 | -                    if ($possible_post_name) { | 
                                                        |
| 198 | - $post_name = $possible_post_name;  | 
                                                        |
| 199 | - }  | 
                                                        |
| 200 | - }  | 
                                                        |
| 201 | - }  | 
                                                        |
| 202 | - }  | 
                                                        |
| 203 | - // ug... ok... nothing yet... but do we have a post ID?  | 
                                                        |
| 204 | - // if so then... sigh... run a query to get the post name :\  | 
                                                        |
| 205 | -        if (! $post_name && $this->post_id) { | 
                                                        |
| 206 | -            $SQL                = "SELECT post_name from {$wpdb->posts}"; | 
                                                        |
| 207 | -            $SQL                .= " WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash')"; | 
                                                        |
| 208 | - $SQL .= ' AND ID=%d';  | 
                                                        |
| 209 | - $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->post_id));  | 
                                                        |
| 210 | -            if ($possible_post_name) { | 
                                                        |
| 211 | - $post_name = $possible_post_name;  | 
                                                        |
| 212 | - }  | 
                                                        |
| 213 | - }  | 
                                                        |
| 214 | - // still nothing? ok what about an explicit 'post_name' URL parameter?  | 
                                                        |
| 215 | -        if (! $post_name && $this->request->requestParamIsSet('post_name')) { | 
                                                        |
| 216 | -            $post_name = $this->request->getRequestParam('post_name'); | 
                                                        |
| 217 | - }  | 
                                                        |
| 218 | - return $post_name;  | 
                                                        |
| 219 | - }  | 
                                                        |
| 220 | -  | 
                                                        |
| 221 | -  | 
                                                        |
| 222 | - /**  | 
                                                        |
| 223 | - * also similar to getPostId() and getPostName() above but not as insane  | 
                                                        |
| 224 | - *  | 
                                                        |
| 225 | - * @param WP $WP  | 
                                                        |
| 226 | - * @return array  | 
                                                        |
| 227 | - */  | 
                                                        |
| 228 | - private function getPostType(WP $WP = null)  | 
                                                        |
| 229 | -    { | 
                                                        |
| 230 | - $post_types = [];  | 
                                                        |
| 231 | -        if ($WP instanceof WP) { | 
                                                        |
| 232 | - $post_types = isset($WP->query_vars['post_type'])  | 
                                                        |
| 233 | - ? (array) $WP->query_vars['post_type']  | 
                                                        |
| 234 | - : [];  | 
                                                        |
| 235 | - }  | 
                                                        |
| 236 | -        if (empty($post_types) && $this->request->requestParamIsSet('post_type')) { | 
                                                        |
| 237 | -            $post_types = $this->request->getRequestParam('post_type', [], 'string', true); | 
                                                        |
| 238 | - }  | 
                                                        |
| 239 | - return (array) $post_types;  | 
                                                        |
| 240 | - }  | 
                                                        |
| 241 | -  | 
                                                        |
| 242 | -  | 
                                                        |
| 243 | - /**  | 
                                                        |
| 244 | - * if TRUE, then the current page is somehow utilizing EE logic  | 
                                                        |
| 245 | - *  | 
                                                        |
| 246 | - * @return bool  | 
                                                        |
| 247 | - */  | 
                                                        |
| 248 | - public function isEspressoPage()  | 
                                                        |
| 249 | -    { | 
                                                        |
| 250 | -        if ($this->is_espresso_page === null) { | 
                                                        |
| 251 | - $this->setEspressoPage();  | 
                                                        |
| 252 | - }  | 
                                                        |
| 253 | - return $this->is_espresso_page;  | 
                                                        |
| 254 | - }  | 
                                                        |
| 255 | -  | 
                                                        |
| 256 | -  | 
                                                        |
| 257 | - /**  | 
                                                        |
| 258 | - * @return int  | 
                                                        |
| 259 | - */  | 
                                                        |
| 260 | - public function postId()  | 
                                                        |
| 261 | -    { | 
                                                        |
| 262 | - return $this->post_id;  | 
                                                        |
| 263 | - }  | 
                                                        |
| 264 | -  | 
                                                        |
| 265 | -  | 
                                                        |
| 266 | - /**  | 
                                                        |
| 267 | - * @return string  | 
                                                        |
| 268 | - */  | 
                                                        |
| 269 | - public function postName()  | 
                                                        |
| 270 | -    { | 
                                                        |
| 271 | - return $this->post_name;  | 
                                                        |
| 272 | - }  | 
                                                        |
| 273 | -  | 
                                                        |
| 274 | -  | 
                                                        |
| 275 | - /**  | 
                                                        |
| 276 | - * @return array  | 
                                                        |
| 277 | - */  | 
                                                        |
| 278 | - public function postType()  | 
                                                        |
| 279 | -    { | 
                                                        |
| 280 | - return $this->post_type;  | 
                                                        |
| 281 | - }  | 
                                                        |
| 282 | -  | 
                                                        |
| 283 | -  | 
                                                        |
| 284 | - /**  | 
                                                        |
| 285 | - * for manually indicating the current page will utilize EE logic  | 
                                                        |
| 286 | - *  | 
                                                        |
| 287 | - * @param null|bool $value  | 
                                                        |
| 288 | - * @return void  | 
                                                        |
| 289 | - */  | 
                                                        |
| 290 | - public function setEspressoPage($value = null)  | 
                                                        |
| 291 | -    { | 
                                                        |
| 292 | - $this->is_espresso_page = $value !== null  | 
                                                        |
| 293 | - ? filter_var($value, FILTER_VALIDATE_BOOLEAN)  | 
                                                        |
| 294 | - : $this->testForEspressoPage();  | 
                                                        |
| 295 | - }  | 
                                                        |
| 296 | -  | 
                                                        |
| 297 | -  | 
                                                        |
| 298 | - /**  | 
                                                        |
| 299 | - * attempts to determine if the current page/post is an EE related page/post  | 
                                                        |
| 300 | - * because it utilizes one of our CPT taxonomies, endpoints, or post types  | 
                                                        |
| 301 | - *  | 
                                                        |
| 302 | - * @return bool  | 
                                                        |
| 303 | - */  | 
                                                        |
| 304 | - private function testForEspressoPage()  | 
                                                        |
| 305 | -    { | 
                                                        |
| 306 | - // in case it has already been set  | 
                                                        |
| 307 | -        if ($this->is_espresso_page) { | 
                                                        |
| 308 | - return true;  | 
                                                        |
| 309 | - }  | 
                                                        |
| 310 | - global $WP;  | 
                                                        |
| 311 | - $espresso_CPT_taxonomies = $this->cpt_strategy->get_CPT_taxonomies();  | 
                                                        |
| 312 | -        if (is_array($espresso_CPT_taxonomies)) { | 
                                                        |
| 313 | -            foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy => $details) { | 
                                                        |
| 314 | -                if (isset($WP->query_vars, $WP->query_vars[ $espresso_CPT_taxonomy ])) { | 
                                                        |
| 315 | - return true;  | 
                                                        |
| 316 | - }  | 
                                                        |
| 317 | - }  | 
                                                        |
| 318 | - }  | 
                                                        |
| 319 | - // load espresso CPT endpoints  | 
                                                        |
| 320 | - $espresso_CPT_endpoints = $this->cpt_strategy->get_CPT_endpoints();  | 
                                                        |
| 321 | - $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);  | 
                                                        |
| 322 | -        foreach ($this->post_type as $post_type) { | 
                                                        |
| 323 | - // was a post name passed ?  | 
                                                        |
| 324 | -            if (isset($post_type_CPT_endpoints[ $post_type ])) { | 
                                                        |
| 325 | - // kk we know this is an espresso page, but is it a specific post ?  | 
                                                        |
| 326 | -                if (! $this->post_name) { | 
                                                        |
| 327 | -                    $espresso_post_type = $this->request->getRequestParam('post_type'); | 
                                                        |
| 328 | - // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events  | 
                                                        |
| 329 | - // this essentially sets the post_name to "events" (or whatever EE CPT)  | 
                                                        |
| 330 | - $post_name = isset($post_type_CPT_endpoints[ $espresso_post_type ])  | 
                                                        |
| 331 | - ? $post_type_CPT_endpoints[ $espresso_post_type ]  | 
                                                        |
| 332 | - : '';  | 
                                                        |
| 333 | - // if the post type matches one of ours then set the post name to the endpoint  | 
                                                        |
| 334 | -                    if ($post_name) { | 
                                                        |
| 335 | - $this->post_name = $post_name;  | 
                                                        |
| 336 | - }  | 
                                                        |
| 337 | - }  | 
                                                        |
| 338 | - return true;  | 
                                                        |
| 339 | - }  | 
                                                        |
| 340 | - }  | 
                                                        |
| 341 | - return false;  | 
                                                        |
| 342 | - }  | 
                                                        |
| 26 | + /**  | 
                                                        |
| 27 | + * @var EE_CPT_Strategy  | 
                                                        |
| 28 | + */  | 
                                                        |
| 29 | + private $cpt_strategy;  | 
                                                        |
| 30 | +  | 
                                                        |
| 31 | + /**  | 
                                                        |
| 32 | + * @var bool  | 
                                                        |
| 33 | + */  | 
                                                        |
| 34 | + private $initialized;  | 
                                                        |
| 35 | +  | 
                                                        |
| 36 | + /**  | 
                                                        |
| 37 | + * @var bool  | 
                                                        |
| 38 | + */  | 
                                                        |
| 39 | + private $is_espresso_page;  | 
                                                        |
| 40 | +  | 
                                                        |
| 41 | + /**  | 
                                                        |
| 42 | + * @var int  | 
                                                        |
| 43 | + */  | 
                                                        |
| 44 | + private $post_id = 0;  | 
                                                        |
| 45 | +  | 
                                                        |
| 46 | + /**  | 
                                                        |
| 47 | + * @var string  | 
                                                        |
| 48 | + */  | 
                                                        |
| 49 | + private $post_name = '';  | 
                                                        |
| 50 | +  | 
                                                        |
| 51 | + /**  | 
                                                        |
| 52 | + * @var array  | 
                                                        |
| 53 | + */  | 
                                                        |
| 54 | + private $post_type = [];  | 
                                                        |
| 55 | +  | 
                                                        |
| 56 | + /**  | 
                                                        |
| 57 | + * @var RequestInterface $request  | 
                                                        |
| 58 | + */  | 
                                                        |
| 59 | + private $request;  | 
                                                        |
| 60 | +  | 
                                                        |
| 61 | +  | 
                                                        |
| 62 | + /**  | 
                                                        |
| 63 | + * CurrentPage constructor.  | 
                                                        |
| 64 | + *  | 
                                                        |
| 65 | + * @param EE_CPT_Strategy $cpt_strategy  | 
                                                        |
| 66 | + * @param RequestInterface $request  | 
                                                        |
| 67 | + */  | 
                                                        |
| 68 | + public function __construct(EE_CPT_Strategy $cpt_strategy, RequestInterface $request)  | 
                                                        |
| 69 | +	{ | 
                                                        |
| 70 | + $this->cpt_strategy = $cpt_strategy;  | 
                                                        |
| 71 | + $this->request = $request;  | 
                                                        |
| 72 | + $this->initialized = is_admin();  | 
                                                        |
| 73 | + // analyse the incoming WP request  | 
                                                        |
| 74 | +		add_action('parse_request', [$this, 'parseQueryVars'], 2, 1); | 
                                                        |
| 75 | + }  | 
                                                        |
| 76 | +  | 
                                                        |
| 77 | +  | 
                                                        |
| 78 | + /**  | 
                                                        |
| 79 | + * @param WP $WP  | 
                                                        |
| 80 | + * @return void  | 
                                                        |
| 81 | + */  | 
                                                        |
| 82 | + public function parseQueryVars(WP $WP = null)  | 
                                                        |
| 83 | +	{ | 
                                                        |
| 84 | +		if ($this->initialized) { | 
                                                        |
| 85 | + return;  | 
                                                        |
| 86 | + }  | 
                                                        |
| 87 | + // if somebody forgot to provide us with WP, that's ok because its global  | 
                                                        |
| 88 | +		if (! $WP instanceof WP) { | 
                                                        |
| 89 | + global $WP;  | 
                                                        |
| 90 | + }  | 
                                                        |
| 91 | + $this->post_id = $this->getPostId($WP);  | 
                                                        |
| 92 | + $this->post_name = $this->getPostName($WP);  | 
                                                        |
| 93 | + $this->post_type = $this->getPostType($WP);  | 
                                                        |
| 94 | + // true or false ? is this page being used by EE ?  | 
                                                        |
| 95 | + $this->setEspressoPage();  | 
                                                        |
| 96 | +		remove_action('parse_request', [$this, 'parseRequest'], 2); | 
                                                        |
| 97 | + $this->initialized = true;  | 
                                                        |
| 98 | + }  | 
                                                        |
| 99 | +  | 
                                                        |
| 100 | +  | 
                                                        |
| 101 | + /**  | 
                                                        |
| 102 | + * Just a helper method for getting the url for the displayed page.  | 
                                                        |
| 103 | + *  | 
                                                        |
| 104 | + * @param WP|null $WP  | 
                                                        |
| 105 | + * @return string  | 
                                                        |
| 106 | + */  | 
                                                        |
| 107 | + public function getPermalink(WP $WP = null)  | 
                                                        |
| 108 | +	{ | 
                                                        |
| 109 | + $post_id = $this->post_id ?: $this->getPostId($WP);  | 
                                                        |
| 110 | +		if ($post_id) { | 
                                                        |
| 111 | + return get_permalink($post_id);  | 
                                                        |
| 112 | + }  | 
                                                        |
| 113 | +		if (! $WP instanceof WP) { | 
                                                        |
| 114 | + global $WP;  | 
                                                        |
| 115 | + }  | 
                                                        |
| 116 | +		if ($WP instanceof WP && $WP->request) { | 
                                                        |
| 117 | + return site_url($WP->request);  | 
                                                        |
| 118 | + }  | 
                                                        |
| 119 | + return esc_url_raw(site_url($_SERVER['REQUEST_URI']));  | 
                                                        |
| 120 | + }  | 
                                                        |
| 121 | +  | 
                                                        |
| 122 | +  | 
                                                        |
| 123 | + /**  | 
                                                        |
| 124 | + * @return array  | 
                                                        |
| 125 | + */  | 
                                                        |
| 126 | + public function espressoPostType()  | 
                                                        |
| 127 | +	{ | 
                                                        |
| 128 | + return array_filter(  | 
                                                        |
| 129 | + $this->post_type,  | 
                                                        |
| 130 | +			function ($post_type) { | 
                                                        |
| 131 | + return strpos($post_type, 'espresso_') === 0;  | 
                                                        |
| 132 | + }  | 
                                                        |
| 133 | + );  | 
                                                        |
| 134 | + }  | 
                                                        |
| 135 | +  | 
                                                        |
| 136 | +  | 
                                                        |
| 137 | + /**  | 
                                                        |
| 138 | + * pokes and prods the WP object query_vars in an attempt to shake out a page/post ID  | 
                                                        |
| 139 | + *  | 
                                                        |
| 140 | + * @param WP $WP  | 
                                                        |
| 141 | + * @return int  | 
                                                        |
| 142 | + */  | 
                                                        |
| 143 | + private function getPostId(WP $WP = null)  | 
                                                        |
| 144 | +	{ | 
                                                        |
| 145 | + $post_id = null;  | 
                                                        |
| 146 | +		if ($WP instanceof WP) { | 
                                                        |
| 147 | + // look for the post ID in the aptly named 'p' query var  | 
                                                        |
| 148 | +			if (isset($WP->query_vars['p'])) { | 
                                                        |
| 149 | + $post_id = $WP->query_vars['p'];  | 
                                                        |
| 150 | + }  | 
                                                        |
| 151 | + // not a post? what about a page?  | 
                                                        |
| 152 | +			if (! $post_id && isset($WP->query_vars['page_id'])) { | 
                                                        |
| 153 | + $post_id = $WP->query_vars['page_id'];  | 
                                                        |
| 154 | + }  | 
                                                        |
| 155 | + // ok... maybe pretty permalinks are off and the ID is set in the raw request...  | 
                                                        |
| 156 | + // but hasn't been processed yet ie: this method is being called too early :\  | 
                                                        |
| 157 | +			if (! $post_id && $WP->request !== null && is_numeric(basename($WP->request))) { | 
                                                        |
| 158 | + $post_id = basename($WP->request);  | 
                                                        |
| 159 | + }  | 
                                                        |
| 160 | + }  | 
                                                        |
| 161 | + // none of the above? ok what about an explicit "post_id" URL parameter?  | 
                                                        |
| 162 | +		if (! $post_id && $this->request->requestParamIsSet('post_id')) { | 
                                                        |
| 163 | +			$post_id = $this->request->getRequestParam('post_id'); | 
                                                        |
| 164 | + }  | 
                                                        |
| 165 | + return $post_id;  | 
                                                        |
| 166 | + }  | 
                                                        |
| 167 | +  | 
                                                        |
| 168 | +  | 
                                                        |
| 169 | + /**  | 
                                                        |
| 170 | + * similar to getPostId() above but attempts to obtain the "name" for the current page/post  | 
                                                        |
| 171 | + *  | 
                                                        |
| 172 | + * @param WP $WP  | 
                                                        |
| 173 | + * @return string  | 
                                                        |
| 174 | + */  | 
                                                        |
| 175 | + private function getPostName(WP $WP = null)  | 
                                                        |
| 176 | +	{ | 
                                                        |
| 177 | + global $wpdb;  | 
                                                        |
| 178 | + $post_name = null;  | 
                                                        |
| 179 | +		if ($WP instanceof WP) { | 
                                                        |
| 180 | + // if this is a post, then is the post name set?  | 
                                                        |
| 181 | +			if (isset($WP->query_vars['name']) && ! empty($WP->query_vars['name'])) { | 
                                                        |
| 182 | + $post_name = $WP->query_vars['name'];  | 
                                                        |
| 183 | + }  | 
                                                        |
| 184 | + // what about the page name?  | 
                                                        |
| 185 | +			if (! $post_name && isset($WP->query_vars['pagename']) && ! empty($WP->query_vars['pagename'])) { | 
                                                        |
| 186 | + $post_name = $WP->query_vars['pagename'];  | 
                                                        |
| 187 | + }  | 
                                                        |
| 188 | + // this stinks but let's run a query to try and get the post name from the URL  | 
                                                        |
| 189 | + // (assuming pretty permalinks are on)  | 
                                                        |
| 190 | +			if (! $post_name && ! empty($WP->request)) { | 
                                                        |
| 191 | + $possible_post_name = basename($WP->request);  | 
                                                        |
| 192 | +				if (! is_numeric($possible_post_name)) { | 
                                                        |
| 193 | +					$SQL                = "SELECT ID from {$wpdb->posts}"; | 
                                                        |
| 194 | +					$SQL                .= " WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash')"; | 
                                                        |
| 195 | + $SQL .= ' AND post_name=%s';  | 
                                                        |
| 196 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name));  | 
                                                        |
| 197 | +					if ($possible_post_name) { | 
                                                        |
| 198 | + $post_name = $possible_post_name;  | 
                                                        |
| 199 | + }  | 
                                                        |
| 200 | + }  | 
                                                        |
| 201 | + }  | 
                                                        |
| 202 | + }  | 
                                                        |
| 203 | + // ug... ok... nothing yet... but do we have a post ID?  | 
                                                        |
| 204 | + // if so then... sigh... run a query to get the post name :\  | 
                                                        |
| 205 | +		if (! $post_name && $this->post_id) { | 
                                                        |
| 206 | +			$SQL                = "SELECT post_name from {$wpdb->posts}"; | 
                                                        |
| 207 | +			$SQL                .= " WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash')"; | 
                                                        |
| 208 | + $SQL .= ' AND ID=%d';  | 
                                                        |
| 209 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->post_id));  | 
                                                        |
| 210 | +			if ($possible_post_name) { | 
                                                        |
| 211 | + $post_name = $possible_post_name;  | 
                                                        |
| 212 | + }  | 
                                                        |
| 213 | + }  | 
                                                        |
| 214 | + // still nothing? ok what about an explicit 'post_name' URL parameter?  | 
                                                        |
| 215 | +		if (! $post_name && $this->request->requestParamIsSet('post_name')) { | 
                                                        |
| 216 | +			$post_name = $this->request->getRequestParam('post_name'); | 
                                                        |
| 217 | + }  | 
                                                        |
| 218 | + return $post_name;  | 
                                                        |
| 219 | + }  | 
                                                        |
| 220 | +  | 
                                                        |
| 221 | +  | 
                                                        |
| 222 | + /**  | 
                                                        |
| 223 | + * also similar to getPostId() and getPostName() above but not as insane  | 
                                                        |
| 224 | + *  | 
                                                        |
| 225 | + * @param WP $WP  | 
                                                        |
| 226 | + * @return array  | 
                                                        |
| 227 | + */  | 
                                                        |
| 228 | + private function getPostType(WP $WP = null)  | 
                                                        |
| 229 | +	{ | 
                                                        |
| 230 | + $post_types = [];  | 
                                                        |
| 231 | +		if ($WP instanceof WP) { | 
                                                        |
| 232 | + $post_types = isset($WP->query_vars['post_type'])  | 
                                                        |
| 233 | + ? (array) $WP->query_vars['post_type']  | 
                                                        |
| 234 | + : [];  | 
                                                        |
| 235 | + }  | 
                                                        |
| 236 | +		if (empty($post_types) && $this->request->requestParamIsSet('post_type')) { | 
                                                        |
| 237 | +			$post_types = $this->request->getRequestParam('post_type', [], 'string', true); | 
                                                        |
| 238 | + }  | 
                                                        |
| 239 | + return (array) $post_types;  | 
                                                        |
| 240 | + }  | 
                                                        |
| 241 | +  | 
                                                        |
| 242 | +  | 
                                                        |
| 243 | + /**  | 
                                                        |
| 244 | + * if TRUE, then the current page is somehow utilizing EE logic  | 
                                                        |
| 245 | + *  | 
                                                        |
| 246 | + * @return bool  | 
                                                        |
| 247 | + */  | 
                                                        |
| 248 | + public function isEspressoPage()  | 
                                                        |
| 249 | +	{ | 
                                                        |
| 250 | +		if ($this->is_espresso_page === null) { | 
                                                        |
| 251 | + $this->setEspressoPage();  | 
                                                        |
| 252 | + }  | 
                                                        |
| 253 | + return $this->is_espresso_page;  | 
                                                        |
| 254 | + }  | 
                                                        |
| 255 | +  | 
                                                        |
| 256 | +  | 
                                                        |
| 257 | + /**  | 
                                                        |
| 258 | + * @return int  | 
                                                        |
| 259 | + */  | 
                                                        |
| 260 | + public function postId()  | 
                                                        |
| 261 | +	{ | 
                                                        |
| 262 | + return $this->post_id;  | 
                                                        |
| 263 | + }  | 
                                                        |
| 264 | +  | 
                                                        |
| 265 | +  | 
                                                        |
| 266 | + /**  | 
                                                        |
| 267 | + * @return string  | 
                                                        |
| 268 | + */  | 
                                                        |
| 269 | + public function postName()  | 
                                                        |
| 270 | +	{ | 
                                                        |
| 271 | + return $this->post_name;  | 
                                                        |
| 272 | + }  | 
                                                        |
| 273 | +  | 
                                                        |
| 274 | +  | 
                                                        |
| 275 | + /**  | 
                                                        |
| 276 | + * @return array  | 
                                                        |
| 277 | + */  | 
                                                        |
| 278 | + public function postType()  | 
                                                        |
| 279 | +	{ | 
                                                        |
| 280 | + return $this->post_type;  | 
                                                        |
| 281 | + }  | 
                                                        |
| 282 | +  | 
                                                        |
| 283 | +  | 
                                                        |
| 284 | + /**  | 
                                                        |
| 285 | + * for manually indicating the current page will utilize EE logic  | 
                                                        |
| 286 | + *  | 
                                                        |
| 287 | + * @param null|bool $value  | 
                                                        |
| 288 | + * @return void  | 
                                                        |
| 289 | + */  | 
                                                        |
| 290 | + public function setEspressoPage($value = null)  | 
                                                        |
| 291 | +	{ | 
                                                        |
| 292 | + $this->is_espresso_page = $value !== null  | 
                                                        |
| 293 | + ? filter_var($value, FILTER_VALIDATE_BOOLEAN)  | 
                                                        |
| 294 | + : $this->testForEspressoPage();  | 
                                                        |
| 295 | + }  | 
                                                        |
| 296 | +  | 
                                                        |
| 297 | +  | 
                                                        |
| 298 | + /**  | 
                                                        |
| 299 | + * attempts to determine if the current page/post is an EE related page/post  | 
                                                        |
| 300 | + * because it utilizes one of our CPT taxonomies, endpoints, or post types  | 
                                                        |
| 301 | + *  | 
                                                        |
| 302 | + * @return bool  | 
                                                        |
| 303 | + */  | 
                                                        |
| 304 | + private function testForEspressoPage()  | 
                                                        |
| 305 | +	{ | 
                                                        |
| 306 | + // in case it has already been set  | 
                                                        |
| 307 | +		if ($this->is_espresso_page) { | 
                                                        |
| 308 | + return true;  | 
                                                        |
| 309 | + }  | 
                                                        |
| 310 | + global $WP;  | 
                                                        |
| 311 | + $espresso_CPT_taxonomies = $this->cpt_strategy->get_CPT_taxonomies();  | 
                                                        |
| 312 | +		if (is_array($espresso_CPT_taxonomies)) { | 
                                                        |
| 313 | +			foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy => $details) { | 
                                                        |
| 314 | +				if (isset($WP->query_vars, $WP->query_vars[ $espresso_CPT_taxonomy ])) { | 
                                                        |
| 315 | + return true;  | 
                                                        |
| 316 | + }  | 
                                                        |
| 317 | + }  | 
                                                        |
| 318 | + }  | 
                                                        |
| 319 | + // load espresso CPT endpoints  | 
                                                        |
| 320 | + $espresso_CPT_endpoints = $this->cpt_strategy->get_CPT_endpoints();  | 
                                                        |
| 321 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);  | 
                                                        |
| 322 | +		foreach ($this->post_type as $post_type) { | 
                                                        |
| 323 | + // was a post name passed ?  | 
                                                        |
| 324 | +			if (isset($post_type_CPT_endpoints[ $post_type ])) { | 
                                                        |
| 325 | + // kk we know this is an espresso page, but is it a specific post ?  | 
                                                        |
| 326 | +				if (! $this->post_name) { | 
                                                        |
| 327 | +					$espresso_post_type = $this->request->getRequestParam('post_type'); | 
                                                        |
| 328 | + // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events  | 
                                                        |
| 329 | + // this essentially sets the post_name to "events" (or whatever EE CPT)  | 
                                                        |
| 330 | + $post_name = isset($post_type_CPT_endpoints[ $espresso_post_type ])  | 
                                                        |
| 331 | + ? $post_type_CPT_endpoints[ $espresso_post_type ]  | 
                                                        |
| 332 | + : '';  | 
                                                        |
| 333 | + // if the post type matches one of ours then set the post name to the endpoint  | 
                                                        |
| 334 | +					if ($post_name) { | 
                                                        |
| 335 | + $this->post_name = $post_name;  | 
                                                        |
| 336 | + }  | 
                                                        |
| 337 | + }  | 
                                                        |
| 338 | + return true;  | 
                                                        |
| 339 | + }  | 
                                                        |
| 340 | + }  | 
                                                        |
| 341 | + return false;  | 
                                                        |
| 342 | + }  | 
                                                        |
| 343 | 343 | }  | 
                                                        
@@ -85,7 +85,7 @@ discard block  | 
                                                    ||
| 85 | 85 | return;  | 
                                                        
| 86 | 86 | }  | 
                                                        
| 87 | 87 | // if somebody forgot to provide us with WP, that's ok because its global  | 
                                                        
| 88 | -        if (! $WP instanceof WP) { | 
                                                        |
| 88 | +        if ( ! $WP instanceof WP) { | 
                                                        |
| 89 | 89 | global $WP;  | 
                                                        
| 90 | 90 | }  | 
                                                        
| 91 | 91 | $this->post_id = $this->getPostId($WP);  | 
                                                        
@@ -110,7 +110,7 @@ discard block  | 
                                                    ||
| 110 | 110 |          if ($post_id) { | 
                                                        
| 111 | 111 | return get_permalink($post_id);  | 
                                                        
| 112 | 112 | }  | 
                                                        
| 113 | -        if (! $WP instanceof WP) { | 
                                                        |
| 113 | +        if ( ! $WP instanceof WP) { | 
                                                        |
| 114 | 114 | global $WP;  | 
                                                        
| 115 | 115 | }  | 
                                                        
| 116 | 116 |          if ($WP instanceof WP && $WP->request) { | 
                                                        
@@ -127,7 +127,7 @@ discard block  | 
                                                    ||
| 127 | 127 |      { | 
                                                        
| 128 | 128 | return array_filter(  | 
                                                        
| 129 | 129 | $this->post_type,  | 
                                                        
| 130 | -            function ($post_type) { | 
                                                        |
| 130 | +            function($post_type) { | 
                                                        |
| 131 | 131 | return strpos($post_type, 'espresso_') === 0;  | 
                                                        
| 132 | 132 | }  | 
                                                        
| 133 | 133 | );  | 
                                                        
@@ -149,17 +149,17 @@ discard block  | 
                                                    ||
| 149 | 149 | $post_id = $WP->query_vars['p'];  | 
                                                        
| 150 | 150 | }  | 
                                                        
| 151 | 151 | // not a post? what about a page?  | 
                                                        
| 152 | -            if (! $post_id && isset($WP->query_vars['page_id'])) { | 
                                                        |
| 152 | +            if ( ! $post_id && isset($WP->query_vars['page_id'])) { | 
                                                        |
| 153 | 153 | $post_id = $WP->query_vars['page_id'];  | 
                                                        
| 154 | 154 | }  | 
                                                        
| 155 | 155 | // ok... maybe pretty permalinks are off and the ID is set in the raw request...  | 
                                                        
| 156 | 156 | // but hasn't been processed yet ie: this method is being called too early :\  | 
                                                        
| 157 | -            if (! $post_id && $WP->request !== null && is_numeric(basename($WP->request))) { | 
                                                        |
| 157 | +            if ( ! $post_id && $WP->request !== null && is_numeric(basename($WP->request))) { | 
                                                        |
| 158 | 158 | $post_id = basename($WP->request);  | 
                                                        
| 159 | 159 | }  | 
                                                        
| 160 | 160 | }  | 
                                                        
| 161 | 161 | // none of the above? ok what about an explicit "post_id" URL parameter?  | 
                                                        
| 162 | -        if (! $post_id && $this->request->requestParamIsSet('post_id')) { | 
                                                        |
| 162 | +        if ( ! $post_id && $this->request->requestParamIsSet('post_id')) { | 
                                                        |
| 163 | 163 |              $post_id = $this->request->getRequestParam('post_id'); | 
                                                        
| 164 | 164 | }  | 
                                                        
| 165 | 165 | return $post_id;  | 
                                                        
@@ -182,14 +182,14 @@ discard block  | 
                                                    ||
| 182 | 182 | $post_name = $WP->query_vars['name'];  | 
                                                        
| 183 | 183 | }  | 
                                                        
| 184 | 184 | // what about the page name?  | 
                                                        
| 185 | -            if (! $post_name && isset($WP->query_vars['pagename']) && ! empty($WP->query_vars['pagename'])) { | 
                                                        |
| 185 | +            if ( ! $post_name && isset($WP->query_vars['pagename']) && ! empty($WP->query_vars['pagename'])) { | 
                                                        |
| 186 | 186 | $post_name = $WP->query_vars['pagename'];  | 
                                                        
| 187 | 187 | }  | 
                                                        
| 188 | 188 | // this stinks but let's run a query to try and get the post name from the URL  | 
                                                        
| 189 | 189 | // (assuming pretty permalinks are on)  | 
                                                        
| 190 | -            if (! $post_name && ! empty($WP->request)) { | 
                                                        |
| 190 | +            if ( ! $post_name && ! empty($WP->request)) { | 
                                                        |
| 191 | 191 | $possible_post_name = basename($WP->request);  | 
                                                        
| 192 | -                if (! is_numeric($possible_post_name)) { | 
                                                        |
| 192 | +                if ( ! is_numeric($possible_post_name)) { | 
                                                        |
| 193 | 193 |                      $SQL                = "SELECT ID from {$wpdb->posts}"; | 
                                                        
| 194 | 194 |                      $SQL                .= " WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash')"; | 
                                                        
| 195 | 195 | $SQL .= ' AND post_name=%s';  | 
                                                        
@@ -202,7 +202,7 @@ discard block  | 
                                                    ||
| 202 | 202 | }  | 
                                                        
| 203 | 203 | // ug... ok... nothing yet... but do we have a post ID?  | 
                                                        
| 204 | 204 | // if so then... sigh... run a query to get the post name :\  | 
                                                        
| 205 | -        if (! $post_name && $this->post_id) { | 
                                                        |
| 205 | +        if ( ! $post_name && $this->post_id) { | 
                                                        |
| 206 | 206 |              $SQL                = "SELECT post_name from {$wpdb->posts}"; | 
                                                        
| 207 | 207 |              $SQL                .= " WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash')"; | 
                                                        
| 208 | 208 | $SQL .= ' AND ID=%d';  | 
                                                        
@@ -212,7 +212,7 @@ discard block  | 
                                                    ||
| 212 | 212 | }  | 
                                                        
| 213 | 213 | }  | 
                                                        
| 214 | 214 | // still nothing? ok what about an explicit 'post_name' URL parameter?  | 
                                                        
| 215 | -        if (! $post_name && $this->request->requestParamIsSet('post_name')) { | 
                                                        |
| 215 | +        if ( ! $post_name && $this->request->requestParamIsSet('post_name')) { | 
                                                        |
| 216 | 216 |              $post_name = $this->request->getRequestParam('post_name'); | 
                                                        
| 217 | 217 | }  | 
                                                        
| 218 | 218 | return $post_name;  | 
                                                        
@@ -311,7 +311,7 @@ discard block  | 
                                                    ||
| 311 | 311 | $espresso_CPT_taxonomies = $this->cpt_strategy->get_CPT_taxonomies();  | 
                                                        
| 312 | 312 |          if (is_array($espresso_CPT_taxonomies)) { | 
                                                        
| 313 | 313 |              foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy => $details) { | 
                                                        
| 314 | -                if (isset($WP->query_vars, $WP->query_vars[ $espresso_CPT_taxonomy ])) { | 
                                                        |
| 314 | +                if (isset($WP->query_vars, $WP->query_vars[$espresso_CPT_taxonomy])) { | 
                                                        |
| 315 | 315 | return true;  | 
                                                        
| 316 | 316 | }  | 
                                                        
| 317 | 317 | }  | 
                                                        
@@ -321,14 +321,14 @@ discard block  | 
                                                    ||
| 321 | 321 | $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);  | 
                                                        
| 322 | 322 |          foreach ($this->post_type as $post_type) { | 
                                                        
| 323 | 323 | // was a post name passed ?  | 
                                                        
| 324 | -            if (isset($post_type_CPT_endpoints[ $post_type ])) { | 
                                                        |
| 324 | +            if (isset($post_type_CPT_endpoints[$post_type])) { | 
                                                        |
| 325 | 325 | // kk we know this is an espresso page, but is it a specific post ?  | 
                                                        
| 326 | -                if (! $this->post_name) { | 
                                                        |
| 326 | +                if ( ! $this->post_name) { | 
                                                        |
| 327 | 327 |                      $espresso_post_type = $this->request->getRequestParam('post_type'); | 
                                                        
| 328 | 328 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events  | 
                                                        
| 329 | 329 | // this essentially sets the post_name to "events" (or whatever EE CPT)  | 
                                                        
| 330 | - $post_name = isset($post_type_CPT_endpoints[ $espresso_post_type ])  | 
                                                        |
| 331 | - ? $post_type_CPT_endpoints[ $espresso_post_type ]  | 
                                                        |
| 330 | + $post_name = isset($post_type_CPT_endpoints[$espresso_post_type])  | 
                                                        |
| 331 | + ? $post_type_CPT_endpoints[$espresso_post_type]  | 
                                                        |
| 332 | 332 | : '';  | 
                                                        
| 333 | 333 | // if the post type matches one of ours then set the post name to the endpoint  | 
                                                        
| 334 | 334 |                      if ($post_name) { | 
                                                        
@@ -17,486 +17,486 @@  | 
                                                    ||
| 17 | 17 | final class EE_Front_Controller  | 
                                                        
| 18 | 18 |  { | 
                                                        
| 19 | 19 | |
| 20 | - /**  | 
                                                        |
| 21 | - * @var string  | 
                                                        |
| 22 | - */  | 
                                                        |
| 23 | - private $_template_path;  | 
                                                        |
| 24 | -  | 
                                                        |
| 25 | - /**  | 
                                                        |
| 26 | - * @var string  | 
                                                        |
| 27 | - */  | 
                                                        |
| 28 | - private $_template;  | 
                                                        |
| 29 | -  | 
                                                        |
| 30 | - /**  | 
                                                        |
| 31 | - * @type EE_Registry  | 
                                                        |
| 32 | - */  | 
                                                        |
| 33 | - protected $Registry;  | 
                                                        |
| 34 | -  | 
                                                        |
| 35 | - /**  | 
                                                        |
| 36 | - * @type EE_Request_Handler  | 
                                                        |
| 37 | - */  | 
                                                        |
| 38 | - protected $Request_Handler;  | 
                                                        |
| 39 | -  | 
                                                        |
| 40 | - /**  | 
                                                        |
| 41 | - * @type EE_Module_Request_Router  | 
                                                        |
| 42 | - */  | 
                                                        |
| 43 | - protected $Module_Request_Router;  | 
                                                        |
| 44 | -  | 
                                                        |
| 45 | - /**  | 
                                                        |
| 46 | - * @type CurrentPage  | 
                                                        |
| 47 | - */  | 
                                                        |
| 48 | - protected $current_page;  | 
                                                        |
| 49 | -  | 
                                                        |
| 50 | -  | 
                                                        |
| 51 | - /**  | 
                                                        |
| 52 | - * class constructor  | 
                                                        |
| 53 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run  | 
                                                        |
| 54 | - *  | 
                                                        |
| 55 | - * @access public  | 
                                                        |
| 56 | - * @param EE_Registry $Registry  | 
                                                        |
| 57 | - * @param CurrentPage $EspressoPage  | 
                                                        |
| 58 | - * @param EE_Module_Request_Router $Module_Request_Router  | 
                                                        |
| 59 | - */  | 
                                                        |
| 60 | - public function __construct(  | 
                                                        |
| 61 | - EE_Registry $Registry,  | 
                                                        |
| 62 | - CurrentPage $EspressoPage,  | 
                                                        |
| 63 | - EE_Module_Request_Router $Module_Request_Router  | 
                                                        |
| 64 | -    ) { | 
                                                        |
| 65 | - $this->Registry = $Registry;  | 
                                                        |
| 66 | - $this->current_page = $EspressoPage;  | 
                                                        |
| 67 | - $this->Module_Request_Router = $Module_Request_Router;  | 
                                                        |
| 68 | - // load other resources and begin to actually run shortcodes and modules  | 
                                                        |
| 69 | - // analyse the incoming WP request  | 
                                                        |
| 70 | -        add_action('parse_request', array($this, 'get_request'), 1, 1); | 
                                                        |
| 71 | - // process request with module factory  | 
                                                        |
| 72 | -        add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); | 
                                                        |
| 73 | - // before headers sent  | 
                                                        |
| 74 | -        add_action('wp', array($this, 'wp'), 5); | 
                                                        |
| 75 | - // primarily used to process any content shortcodes  | 
                                                        |
| 76 | -        add_action('template_redirect', array($this, 'templateRedirect'), 999); | 
                                                        |
| 77 | - // header  | 
                                                        |
| 78 | -        add_action('wp_head', array($this, 'header_meta_tag'), 5); | 
                                                        |
| 79 | -        add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); | 
                                                        |
| 80 | -        add_filter('template_include', array($this, 'template_include'), 1); | 
                                                        |
| 81 | - // display errors  | 
                                                        |
| 82 | -        add_action('loop_start', array($this, 'display_errors'), 2); | 
                                                        |
| 83 | - // the content  | 
                                                        |
| 84 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );  | 
                                                        |
| 85 | - // exclude our private cpt comments  | 
                                                        |
| 86 | -        add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); | 
                                                        |
| 87 | - // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://)  | 
                                                        |
| 88 | -        add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); | 
                                                        |
| 89 | - // action hook EE  | 
                                                        |
| 90 | -        do_action('AHEE__EE_Front_Controller__construct__done', $this); | 
                                                        |
| 91 | - }  | 
                                                        |
| 92 | -  | 
                                                        |
| 93 | -  | 
                                                        |
| 94 | - /**  | 
                                                        |
| 95 | - * @return EE_Request_Handler  | 
                                                        |
| 96 | - * @deprecated 4.10.14.p  | 
                                                        |
| 97 | - */  | 
                                                        |
| 98 | - public function Request_Handler()  | 
                                                        |
| 99 | -    { | 
                                                        |
| 100 | -        if (! $this->Request_Handler instanceof EE_Request_Handler) { | 
                                                        |
| 101 | -            $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler'); | 
                                                        |
| 102 | - }  | 
                                                        |
| 103 | - return $this->Request_Handler;  | 
                                                        |
| 104 | - }  | 
                                                        |
| 105 | -  | 
                                                        |
| 106 | -  | 
                                                        |
| 107 | - /**  | 
                                                        |
| 108 | - * @return EE_Module_Request_Router  | 
                                                        |
| 109 | - */  | 
                                                        |
| 110 | - public function Module_Request_Router()  | 
                                                        |
| 111 | -    { | 
                                                        |
| 112 | - return $this->Module_Request_Router;  | 
                                                        |
| 113 | - }  | 
                                                        |
| 114 | -  | 
                                                        |
| 115 | -  | 
                                                        |
| 116 | - /**  | 
                                                        |
| 117 | - * @return LegacyShortcodesManager  | 
                                                        |
| 118 | - * @deprecated 4.10.14.p  | 
                                                        |
| 119 | - */  | 
                                                        |
| 120 | - public function getLegacyShortcodesManager()  | 
                                                        |
| 121 | -    { | 
                                                        |
| 122 | - return EE_Config::getLegacyShortcodesManager();  | 
                                                        |
| 123 | - }  | 
                                                        |
| 124 | -  | 
                                                        |
| 125 | -  | 
                                                        |
| 126 | -  | 
                                                        |
| 127 | -  | 
                                                        |
| 128 | -  | 
                                                        |
| 129 | - /*********************************************** INIT ACTION HOOK ***********************************************/  | 
                                                        |
| 130 | - /**  | 
                                                        |
| 131 | - * filter_wp_comments  | 
                                                        |
| 132 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment  | 
                                                        |
| 133 | - * widgets/queries done on frontend  | 
                                                        |
| 134 | - *  | 
                                                        |
| 135 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query  | 
                                                        |
| 136 | - * @return array array of comment clauses with modifications.  | 
                                                        |
| 137 | - * @throws InvalidArgumentException  | 
                                                        |
| 138 | - * @throws InvalidDataTypeException  | 
                                                        |
| 139 | - * @throws InvalidInterfaceException  | 
                                                        |
| 140 | - */  | 
                                                        |
| 141 | - public function filter_wp_comments($clauses)  | 
                                                        |
| 142 | -    { | 
                                                        |
| 143 | - global $wpdb;  | 
                                                        |
| 144 | -        if (strpos($clauses['join'], $wpdb->posts) !== false) { | 
                                                        |
| 145 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */  | 
                                                        |
| 146 | - $custom_post_types = LoaderFactory::getLoader()->getShared(  | 
                                                        |
| 147 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'  | 
                                                        |
| 148 | - );  | 
                                                        |
| 149 | - $cpts = $custom_post_types->getPrivateCustomPostTypes();  | 
                                                        |
| 150 | -            foreach ($cpts as $cpt => $details) { | 
                                                        |
| 151 | -                $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); | 
                                                        |
| 152 | - }  | 
                                                        |
| 153 | - }  | 
                                                        |
| 154 | - return $clauses;  | 
                                                        |
| 155 | - }  | 
                                                        |
| 156 | -  | 
                                                        |
| 157 | -  | 
                                                        |
| 158 | - /**  | 
                                                        |
| 159 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend  | 
                                                        |
| 160 | - *  | 
                                                        |
| 161 | - * @param string $url incoming url  | 
                                                        |
| 162 | - * @return string final assembled url  | 
                                                        |
| 163 | - */  | 
                                                        |
| 164 | - public function maybe_force_admin_ajax_ssl($url)  | 
                                                        |
| 165 | -    { | 
                                                        |
| 166 | -        if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { | 
                                                        |
| 167 | -            $url = str_replace('http://', 'https://', $url); | 
                                                        |
| 168 | - }  | 
                                                        |
| 169 | - return $url;  | 
                                                        |
| 170 | - }  | 
                                                        |
| 171 | -  | 
                                                        |
| 172 | -  | 
                                                        |
| 173 | -  | 
                                                        |
| 174 | -  | 
                                                        |
| 175 | -  | 
                                                        |
| 176 | -  | 
                                                        |
| 177 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/  | 
                                                        |
| 178 | -  | 
                                                        |
| 179 | -  | 
                                                        |
| 180 | - /**  | 
                                                        |
| 181 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their  | 
                                                        |
| 182 | - * default priority init phases have run  | 
                                                        |
| 183 | - *  | 
                                                        |
| 184 | - * @access public  | 
                                                        |
| 185 | - * @return void  | 
                                                        |
| 186 | - */  | 
                                                        |
| 187 | - public function wp_loaded()  | 
                                                        |
| 188 | -    { | 
                                                        |
| 189 | - }  | 
                                                        |
| 190 | -  | 
                                                        |
| 191 | -  | 
                                                        |
| 192 | -  | 
                                                        |
| 193 | -  | 
                                                        |
| 194 | -  | 
                                                        |
| 195 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/  | 
                                                        |
| 196 | - /**  | 
                                                        |
| 197 | - * _get_request  | 
                                                        |
| 198 | - *  | 
                                                        |
| 199 | - * @access public  | 
                                                        |
| 200 | - * @param WP $WP  | 
                                                        |
| 201 | - * @return void  | 
                                                        |
| 202 | - */  | 
                                                        |
| 203 | - public function get_request(WP $WP)  | 
                                                        |
| 204 | -    { | 
                                                        |
| 205 | -        do_action('AHEE__EE_Front_Controller__get_request__start'); | 
                                                        |
| 206 | - $this->current_page->parseQueryVars($WP);  | 
                                                        |
| 207 | -        do_action('AHEE__EE_Front_Controller__get_request__complete'); | 
                                                        |
| 208 | -        remove_action('parse_request', [$this, 'get_request'], 1); | 
                                                        |
| 209 | - }  | 
                                                        |
| 210 | -  | 
                                                        |
| 211 | -  | 
                                                        |
| 212 | - /**  | 
                                                        |
| 213 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template  | 
                                                        |
| 214 | - *  | 
                                                        |
| 215 | - * @access public  | 
                                                        |
| 216 | - * @param WP_Query $WP_Query  | 
                                                        |
| 217 | - * @return void  | 
                                                        |
| 218 | - * @throws EE_Error  | 
                                                        |
| 219 | - * @throws ReflectionException  | 
                                                        |
| 220 | - */  | 
                                                        |
| 221 | - public function pre_get_posts($WP_Query)  | 
                                                        |
| 222 | -    { | 
                                                        |
| 223 | - // only load Module_Request_Router if this is the main query  | 
                                                        |
| 224 | - if (  | 
                                                        |
| 225 | - $this->Module_Request_Router instanceof EE_Module_Request_Router  | 
                                                        |
| 226 | - && $WP_Query->is_main_query()  | 
                                                        |
| 227 | -        ) { | 
                                                        |
| 228 | - // cycle thru module routes  | 
                                                        |
| 229 | -            while ($route = $this->Module_Request_Router->get_route($WP_Query)) { | 
                                                        |
| 230 | - // determine module and method for route  | 
                                                        |
| 231 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);  | 
                                                        |
| 232 | -                if ($module instanceof EED_Module) { | 
                                                        |
| 233 | - // get registered view for route  | 
                                                        |
| 234 | - $this->_template_path = $this->Module_Request_Router->get_view($route);  | 
                                                        |
| 235 | - // grab module name  | 
                                                        |
| 236 | - $module_name = $module->module_name();  | 
                                                        |
| 237 | - // map the module to the module objects  | 
                                                        |
| 238 | -                    $this->Registry->modules->{$module_name} = $module; | 
                                                        |
| 239 | - }  | 
                                                        |
| 240 | - }  | 
                                                        |
| 241 | - }  | 
                                                        |
| 242 | - }  | 
                                                        |
| 243 | -  | 
                                                        |
| 244 | -  | 
                                                        |
| 245 | -  | 
                                                        |
| 246 | -  | 
                                                        |
| 247 | -  | 
                                                        |
| 248 | - /*********************************************** WP HOOK ***********************************************/  | 
                                                        |
| 249 | -  | 
                                                        |
| 250 | -  | 
                                                        |
| 251 | - /**  | 
                                                        |
| 252 | - * wp - basically last chance to do stuff before headers sent  | 
                                                        |
| 253 | - *  | 
                                                        |
| 254 | - * @access public  | 
                                                        |
| 255 | - * @return void  | 
                                                        |
| 256 | - */  | 
                                                        |
| 257 | - public function wp()  | 
                                                        |
| 258 | -    { | 
                                                        |
| 259 | - }  | 
                                                        |
| 260 | -  | 
                                                        |
| 261 | -  | 
                                                        |
| 262 | -  | 
                                                        |
| 263 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/  | 
                                                        |
| 264 | -  | 
                                                        |
| 265 | -  | 
                                                        |
| 266 | - /**  | 
                                                        |
| 267 | - * callback for the "template_redirect" hook point  | 
                                                        |
| 268 | - * checks sidebars for EE widgets  | 
                                                        |
| 269 | - * loads resources and assets accordingly  | 
                                                        |
| 270 | - *  | 
                                                        |
| 271 | - * @return void  | 
                                                        |
| 272 | - */  | 
                                                        |
| 273 | - public function templateRedirect()  | 
                                                        |
| 274 | -    { | 
                                                        |
| 275 | - global $wp_query;  | 
                                                        |
| 276 | -        if (empty($wp_query->posts)) { | 
                                                        |
| 277 | - return;  | 
                                                        |
| 278 | - }  | 
                                                        |
| 279 | - // if we already know this is an espresso page, then load assets  | 
                                                        |
| 280 | - $load_assets = $this->current_page->isEspressoPage();  | 
                                                        |
| 281 | - // if we are already loading assets then just move along, otherwise check for widgets  | 
                                                        |
| 282 | - $load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars();  | 
                                                        |
| 283 | -        if ($load_assets) { | 
                                                        |
| 284 | -            add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); | 
                                                        |
| 285 | -            add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); | 
                                                        |
| 286 | - }  | 
                                                        |
| 287 | - }  | 
                                                        |
| 288 | -  | 
                                                        |
| 289 | -  | 
                                                        |
| 290 | - /**  | 
                                                        |
| 291 | - * builds list of active widgets then scans active sidebars looking for them  | 
                                                        |
| 292 | - * returns true is an EE widget is found in an active sidebar  | 
                                                        |
| 293 | - * Please Note: this does NOT mean that the sidebar or widget  | 
                                                        |
| 294 | - * is actually in use in a given template, as that is unfortunately not known  | 
                                                        |
| 295 | - * until a sidebar and it's widgets are actually loaded  | 
                                                        |
| 296 | - *  | 
                                                        |
| 297 | - * @return boolean  | 
                                                        |
| 298 | - */  | 
                                                        |
| 299 | - private function espresso_widgets_in_active_sidebars()  | 
                                                        |
| 300 | -    { | 
                                                        |
| 301 | - $espresso_widgets = array();  | 
                                                        |
| 302 | -        foreach ($this->Registry->widgets as $widget_class => $widget) { | 
                                                        |
| 303 | - $id_base = EspressoWidget::getIdBase($widget_class);  | 
                                                        |
| 304 | -            if (is_active_widget(false, false, $id_base)) { | 
                                                        |
| 305 | - $espresso_widgets[] = $id_base;  | 
                                                        |
| 306 | - }  | 
                                                        |
| 307 | - }  | 
                                                        |
| 308 | - $all_sidebar_widgets = wp_get_sidebars_widgets();  | 
                                                        |
| 309 | -        foreach ($all_sidebar_widgets as $sidebar_widgets) { | 
                                                        |
| 310 | -            if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { | 
                                                        |
| 311 | -                foreach ($sidebar_widgets as $sidebar_widget) { | 
                                                        |
| 312 | -                    foreach ($espresso_widgets as $espresso_widget) { | 
                                                        |
| 313 | -                        if (strpos($sidebar_widget, $espresso_widget) !== false) { | 
                                                        |
| 314 | - return true;  | 
                                                        |
| 315 | - }  | 
                                                        |
| 316 | - }  | 
                                                        |
| 317 | - }  | 
                                                        |
| 318 | - }  | 
                                                        |
| 319 | - }  | 
                                                        |
| 320 | - return false;  | 
                                                        |
| 321 | - }  | 
                                                        |
| 322 | -  | 
                                                        |
| 323 | -  | 
                                                        |
| 324 | - /**  | 
                                                        |
| 325 | - * header_meta_tag  | 
                                                        |
| 326 | - *  | 
                                                        |
| 327 | - * @access public  | 
                                                        |
| 328 | - * @return void  | 
                                                        |
| 329 | - */  | 
                                                        |
| 330 | - public function header_meta_tag()  | 
                                                        |
| 331 | -    { | 
                                                        |
| 332 | - print(  | 
                                                        |
| 333 | - apply_filters(  | 
                                                        |
| 334 | - 'FHEE__EE_Front_Controller__header_meta_tag',  | 
                                                        |
| 335 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"  | 
                                                        |
| 336 | - )  | 
                                                        |
| 337 | - );  | 
                                                        |
| 338 | -  | 
                                                        |
| 339 | - // let's exclude all event type taxonomy term archive pages from search engine indexing  | 
                                                        |
| 340 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249  | 
                                                        |
| 341 | - // also exclude all critical pages from indexing  | 
                                                        |
| 342 | - if (  | 
                                                        |
| 343 | - (  | 
                                                        |
| 344 | -                is_tax('espresso_event_type') | 
                                                        |
| 345 | -                && get_option('blog_public') !== '0' | 
                                                        |
| 346 | - )  | 
                                                        |
| 347 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())  | 
                                                        |
| 348 | -        ) { | 
                                                        |
| 349 | - print(  | 
                                                        |
| 350 | - apply_filters(  | 
                                                        |
| 351 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',  | 
                                                        |
| 352 | - '<meta name="robots" content="noindex,follow" />' . "\n"  | 
                                                        |
| 353 | - )  | 
                                                        |
| 354 | - );  | 
                                                        |
| 355 | - }  | 
                                                        |
| 356 | - }  | 
                                                        |
| 357 | -  | 
                                                        |
| 358 | -  | 
                                                        |
| 359 | - /**  | 
                                                        |
| 360 | - * wp_print_scripts  | 
                                                        |
| 361 | - *  | 
                                                        |
| 362 | - * @return void  | 
                                                        |
| 363 | - * @throws EE_Error  | 
                                                        |
| 364 | - */  | 
                                                        |
| 365 | - public function wp_print_scripts()  | 
                                                        |
| 366 | -    { | 
                                                        |
| 367 | - global $post;  | 
                                                        |
| 368 | - if (  | 
                                                        |
| 369 | - isset($post->EE_Event)  | 
                                                        |
| 370 | - && $post->EE_Event instanceof EE_Event  | 
                                                        |
| 371 | - && get_post_type() === 'espresso_events'  | 
                                                        |
| 372 | - && is_singular()  | 
                                                        |
| 373 | -        ) { | 
                                                        |
| 374 | - EEH_Schema::add_json_linked_data_for_event($post->EE_Event);  | 
                                                        |
| 375 | - }  | 
                                                        |
| 376 | - }  | 
                                                        |
| 377 | -  | 
                                                        |
| 378 | -  | 
                                                        |
| 379 | - public function enqueueStyle()  | 
                                                        |
| 380 | -    { | 
                                                        |
| 381 | -        wp_enqueue_style('espresso_default'); | 
                                                        |
| 382 | -        wp_enqueue_style('espresso_custom_css'); | 
                                                        |
| 383 | - }  | 
                                                        |
| 384 | -  | 
                                                        |
| 385 | -  | 
                                                        |
| 386 | -  | 
                                                        |
| 387 | - /*********************************************** WP_FOOTER ***********************************************/  | 
                                                        |
| 388 | -  | 
                                                        |
| 389 | -  | 
                                                        |
| 390 | - public function enqueueScripts()  | 
                                                        |
| 391 | -    { | 
                                                        |
| 392 | -        wp_enqueue_script('espresso_core'); | 
                                                        |
| 393 | - }  | 
                                                        |
| 394 | -  | 
                                                        |
| 395 | -  | 
                                                        |
| 396 | - /**  | 
                                                        |
| 397 | - * display_errors  | 
                                                        |
| 398 | - *  | 
                                                        |
| 399 | - * @access public  | 
                                                        |
| 400 | - * @return void  | 
                                                        |
| 401 | - * @throws DomainException  | 
                                                        |
| 402 | - */  | 
                                                        |
| 403 | - public function display_errors()  | 
                                                        |
| 404 | -    { | 
                                                        |
| 405 | - static $shown_already = false;  | 
                                                        |
| 406 | -        do_action('AHEE__EE_Front_Controller__display_errors__begin'); | 
                                                        |
| 407 | - if (  | 
                                                        |
| 408 | - ! $shown_already  | 
                                                        |
| 409 | -            && apply_filters('FHEE__EE_Front_Controller__display_errors', true) | 
                                                        |
| 410 | - && is_main_query()  | 
                                                        |
| 411 | - && ! is_feed()  | 
                                                        |
| 412 | - && in_the_loop()  | 
                                                        |
| 413 | -            && did_action('wp_head') | 
                                                        |
| 414 | - && $this->current_page->isEspressoPage()  | 
                                                        |
| 415 | -        ) { | 
                                                        |
| 416 | - echo EE_Error::get_notices();  | 
                                                        |
| 417 | - $shown_already = true;  | 
                                                        |
| 418 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');  | 
                                                        |
| 419 | - }  | 
                                                        |
| 420 | -        do_action('AHEE__EE_Front_Controller__display_errors__end'); | 
                                                        |
| 421 | - }  | 
                                                        |
| 422 | -  | 
                                                        |
| 423 | -  | 
                                                        |
| 424 | -  | 
                                                        |
| 425 | -  | 
                                                        |
| 426 | -  | 
                                                        |
| 427 | - /*********************************************** UTILITIES ***********************************************/  | 
                                                        |
| 428 | -  | 
                                                        |
| 429 | -  | 
                                                        |
| 430 | - /**  | 
                                                        |
| 431 | - * @param string $template_include_path  | 
                                                        |
| 432 | - * @return string  | 
                                                        |
| 433 | - * @throws EE_Error  | 
                                                        |
| 434 | - * @throws ReflectionException  | 
                                                        |
| 435 | - */  | 
                                                        |
| 436 | - public function template_include($template_include_path = null)  | 
                                                        |
| 437 | -    { | 
                                                        |
| 438 | -        if ($this->current_page->isEspressoPage()) { | 
                                                        |
| 439 | - // despite all helpers having autoloaders set, we need to manually load the template loader  | 
                                                        |
| 440 | - // because there are some side effects in that class for triggering template tag functions  | 
                                                        |
| 441 | -            $this->Registry->load_helper('EEH_Template'); | 
                                                        |
| 442 | - $this->_template_path = ! empty($this->_template_path)  | 
                                                        |
| 443 | - ? basename($this->_template_path)  | 
                                                        |
| 444 | - : basename(  | 
                                                        |
| 445 | - $template_include_path  | 
                                                        |
| 446 | - );  | 
                                                        |
| 447 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false);  | 
                                                        |
| 448 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;  | 
                                                        |
| 449 | - $this->_template = basename($this->_template_path);  | 
                                                        |
| 450 | - return $this->_template_path;  | 
                                                        |
| 451 | - }  | 
                                                        |
| 452 | - return $template_include_path;  | 
                                                        |
| 453 | - }  | 
                                                        |
| 454 | -  | 
                                                        |
| 455 | -  | 
                                                        |
| 456 | - /**  | 
                                                        |
| 457 | - * @param bool $with_path  | 
                                                        |
| 458 | - * @return string  | 
                                                        |
| 459 | - */  | 
                                                        |
| 460 | - public function get_selected_template($with_path = false)  | 
                                                        |
| 461 | -    { | 
                                                        |
| 462 | - return $with_path ? $this->_template_path : $this->_template;  | 
                                                        |
| 463 | - }  | 
                                                        |
| 464 | -  | 
                                                        |
| 465 | -  | 
                                                        |
| 466 | - /**  | 
                                                        |
| 467 | - * @param string $shortcode_class  | 
                                                        |
| 468 | - * @param WP $wp  | 
                                                        |
| 469 | - * @throws ReflectionException  | 
                                                        |
| 470 | - * @deprecated 4.9.26  | 
                                                        |
| 471 | - */  | 
                                                        |
| 472 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null)  | 
                                                        |
| 473 | -    { | 
                                                        |
| 474 | - EE_Error::doing_it_wrong(  | 
                                                        |
| 475 | - __METHOD__,  | 
                                                        |
| 476 | - esc_html__(  | 
                                                        |
| 477 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',  | 
                                                        |
| 478 | - 'event_espresso'  | 
                                                        |
| 479 | - ),  | 
                                                        |
| 480 | - '4.9.26'  | 
                                                        |
| 481 | - );  | 
                                                        |
| 482 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);  | 
                                                        |
| 483 | - }  | 
                                                        |
| 484 | -  | 
                                                        |
| 485 | -  | 
                                                        |
| 486 | - /**  | 
                                                        |
| 487 | - * @return void  | 
                                                        |
| 488 | - * @deprecated 4.9.57.p  | 
                                                        |
| 489 | - */  | 
                                                        |
| 490 | - public function loadPersistentAdminNoticeManager()  | 
                                                        |
| 491 | -    { | 
                                                        |
| 492 | - }  | 
                                                        |
| 493 | -  | 
                                                        |
| 494 | -  | 
                                                        |
| 495 | - /**  | 
                                                        |
| 496 | - * @return void  | 
                                                        |
| 497 | - * @deprecated 4.9.64.p  | 
                                                        |
| 498 | - */  | 
                                                        |
| 499 | - public function employ_CPT_Strategy()  | 
                                                        |
| 500 | -    { | 
                                                        |
| 501 | - }  | 
                                                        |
| 20 | + /**  | 
                                                        |
| 21 | + * @var string  | 
                                                        |
| 22 | + */  | 
                                                        |
| 23 | + private $_template_path;  | 
                                                        |
| 24 | +  | 
                                                        |
| 25 | + /**  | 
                                                        |
| 26 | + * @var string  | 
                                                        |
| 27 | + */  | 
                                                        |
| 28 | + private $_template;  | 
                                                        |
| 29 | +  | 
                                                        |
| 30 | + /**  | 
                                                        |
| 31 | + * @type EE_Registry  | 
                                                        |
| 32 | + */  | 
                                                        |
| 33 | + protected $Registry;  | 
                                                        |
| 34 | +  | 
                                                        |
| 35 | + /**  | 
                                                        |
| 36 | + * @type EE_Request_Handler  | 
                                                        |
| 37 | + */  | 
                                                        |
| 38 | + protected $Request_Handler;  | 
                                                        |
| 39 | +  | 
                                                        |
| 40 | + /**  | 
                                                        |
| 41 | + * @type EE_Module_Request_Router  | 
                                                        |
| 42 | + */  | 
                                                        |
| 43 | + protected $Module_Request_Router;  | 
                                                        |
| 44 | +  | 
                                                        |
| 45 | + /**  | 
                                                        |
| 46 | + * @type CurrentPage  | 
                                                        |
| 47 | + */  | 
                                                        |
| 48 | + protected $current_page;  | 
                                                        |
| 49 | +  | 
                                                        |
| 50 | +  | 
                                                        |
| 51 | + /**  | 
                                                        |
| 52 | + * class constructor  | 
                                                        |
| 53 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run  | 
                                                        |
| 54 | + *  | 
                                                        |
| 55 | + * @access public  | 
                                                        |
| 56 | + * @param EE_Registry $Registry  | 
                                                        |
| 57 | + * @param CurrentPage $EspressoPage  | 
                                                        |
| 58 | + * @param EE_Module_Request_Router $Module_Request_Router  | 
                                                        |
| 59 | + */  | 
                                                        |
| 60 | + public function __construct(  | 
                                                        |
| 61 | + EE_Registry $Registry,  | 
                                                        |
| 62 | + CurrentPage $EspressoPage,  | 
                                                        |
| 63 | + EE_Module_Request_Router $Module_Request_Router  | 
                                                        |
| 64 | +	) { | 
                                                        |
| 65 | + $this->Registry = $Registry;  | 
                                                        |
| 66 | + $this->current_page = $EspressoPage;  | 
                                                        |
| 67 | + $this->Module_Request_Router = $Module_Request_Router;  | 
                                                        |
| 68 | + // load other resources and begin to actually run shortcodes and modules  | 
                                                        |
| 69 | + // analyse the incoming WP request  | 
                                                        |
| 70 | +		add_action('parse_request', array($this, 'get_request'), 1, 1); | 
                                                        |
| 71 | + // process request with module factory  | 
                                                        |
| 72 | +		add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); | 
                                                        |
| 73 | + // before headers sent  | 
                                                        |
| 74 | +		add_action('wp', array($this, 'wp'), 5); | 
                                                        |
| 75 | + // primarily used to process any content shortcodes  | 
                                                        |
| 76 | +		add_action('template_redirect', array($this, 'templateRedirect'), 999); | 
                                                        |
| 77 | + // header  | 
                                                        |
| 78 | +		add_action('wp_head', array($this, 'header_meta_tag'), 5); | 
                                                        |
| 79 | +		add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); | 
                                                        |
| 80 | +		add_filter('template_include', array($this, 'template_include'), 1); | 
                                                        |
| 81 | + // display errors  | 
                                                        |
| 82 | +		add_action('loop_start', array($this, 'display_errors'), 2); | 
                                                        |
| 83 | + // the content  | 
                                                        |
| 84 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );  | 
                                                        |
| 85 | + // exclude our private cpt comments  | 
                                                        |
| 86 | +		add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); | 
                                                        |
| 87 | + // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://)  | 
                                                        |
| 88 | +		add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); | 
                                                        |
| 89 | + // action hook EE  | 
                                                        |
| 90 | +		do_action('AHEE__EE_Front_Controller__construct__done', $this); | 
                                                        |
| 91 | + }  | 
                                                        |
| 92 | +  | 
                                                        |
| 93 | +  | 
                                                        |
| 94 | + /**  | 
                                                        |
| 95 | + * @return EE_Request_Handler  | 
                                                        |
| 96 | + * @deprecated 4.10.14.p  | 
                                                        |
| 97 | + */  | 
                                                        |
| 98 | + public function Request_Handler()  | 
                                                        |
| 99 | +	{ | 
                                                        |
| 100 | +		if (! $this->Request_Handler instanceof EE_Request_Handler) { | 
                                                        |
| 101 | +			$this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler'); | 
                                                        |
| 102 | + }  | 
                                                        |
| 103 | + return $this->Request_Handler;  | 
                                                        |
| 104 | + }  | 
                                                        |
| 105 | +  | 
                                                        |
| 106 | +  | 
                                                        |
| 107 | + /**  | 
                                                        |
| 108 | + * @return EE_Module_Request_Router  | 
                                                        |
| 109 | + */  | 
                                                        |
| 110 | + public function Module_Request_Router()  | 
                                                        |
| 111 | +	{ | 
                                                        |
| 112 | + return $this->Module_Request_Router;  | 
                                                        |
| 113 | + }  | 
                                                        |
| 114 | +  | 
                                                        |
| 115 | +  | 
                                                        |
| 116 | + /**  | 
                                                        |
| 117 | + * @return LegacyShortcodesManager  | 
                                                        |
| 118 | + * @deprecated 4.10.14.p  | 
                                                        |
| 119 | + */  | 
                                                        |
| 120 | + public function getLegacyShortcodesManager()  | 
                                                        |
| 121 | +	{ | 
                                                        |
| 122 | + return EE_Config::getLegacyShortcodesManager();  | 
                                                        |
| 123 | + }  | 
                                                        |
| 124 | +  | 
                                                        |
| 125 | +  | 
                                                        |
| 126 | +  | 
                                                        |
| 127 | +  | 
                                                        |
| 128 | +  | 
                                                        |
| 129 | + /*********************************************** INIT ACTION HOOK ***********************************************/  | 
                                                        |
| 130 | + /**  | 
                                                        |
| 131 | + * filter_wp_comments  | 
                                                        |
| 132 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment  | 
                                                        |
| 133 | + * widgets/queries done on frontend  | 
                                                        |
| 134 | + *  | 
                                                        |
| 135 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query  | 
                                                        |
| 136 | + * @return array array of comment clauses with modifications.  | 
                                                        |
| 137 | + * @throws InvalidArgumentException  | 
                                                        |
| 138 | + * @throws InvalidDataTypeException  | 
                                                        |
| 139 | + * @throws InvalidInterfaceException  | 
                                                        |
| 140 | + */  | 
                                                        |
| 141 | + public function filter_wp_comments($clauses)  | 
                                                        |
| 142 | +	{ | 
                                                        |
| 143 | + global $wpdb;  | 
                                                        |
| 144 | +		if (strpos($clauses['join'], $wpdb->posts) !== false) { | 
                                                        |
| 145 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */  | 
                                                        |
| 146 | + $custom_post_types = LoaderFactory::getLoader()->getShared(  | 
                                                        |
| 147 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'  | 
                                                        |
| 148 | + );  | 
                                                        |
| 149 | + $cpts = $custom_post_types->getPrivateCustomPostTypes();  | 
                                                        |
| 150 | +			foreach ($cpts as $cpt => $details) { | 
                                                        |
| 151 | +				$clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); | 
                                                        |
| 152 | + }  | 
                                                        |
| 153 | + }  | 
                                                        |
| 154 | + return $clauses;  | 
                                                        |
| 155 | + }  | 
                                                        |
| 156 | +  | 
                                                        |
| 157 | +  | 
                                                        |
| 158 | + /**  | 
                                                        |
| 159 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend  | 
                                                        |
| 160 | + *  | 
                                                        |
| 161 | + * @param string $url incoming url  | 
                                                        |
| 162 | + * @return string final assembled url  | 
                                                        |
| 163 | + */  | 
                                                        |
| 164 | + public function maybe_force_admin_ajax_ssl($url)  | 
                                                        |
| 165 | +	{ | 
                                                        |
| 166 | +		if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { | 
                                                        |
| 167 | +			$url = str_replace('http://', 'https://', $url); | 
                                                        |
| 168 | + }  | 
                                                        |
| 169 | + return $url;  | 
                                                        |
| 170 | + }  | 
                                                        |
| 171 | +  | 
                                                        |
| 172 | +  | 
                                                        |
| 173 | +  | 
                                                        |
| 174 | +  | 
                                                        |
| 175 | +  | 
                                                        |
| 176 | +  | 
                                                        |
| 177 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/  | 
                                                        |
| 178 | +  | 
                                                        |
| 179 | +  | 
                                                        |
| 180 | + /**  | 
                                                        |
| 181 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their  | 
                                                        |
| 182 | + * default priority init phases have run  | 
                                                        |
| 183 | + *  | 
                                                        |
| 184 | + * @access public  | 
                                                        |
| 185 | + * @return void  | 
                                                        |
| 186 | + */  | 
                                                        |
| 187 | + public function wp_loaded()  | 
                                                        |
| 188 | +	{ | 
                                                        |
| 189 | + }  | 
                                                        |
| 190 | +  | 
                                                        |
| 191 | +  | 
                                                        |
| 192 | +  | 
                                                        |
| 193 | +  | 
                                                        |
| 194 | +  | 
                                                        |
| 195 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/  | 
                                                        |
| 196 | + /**  | 
                                                        |
| 197 | + * _get_request  | 
                                                        |
| 198 | + *  | 
                                                        |
| 199 | + * @access public  | 
                                                        |
| 200 | + * @param WP $WP  | 
                                                        |
| 201 | + * @return void  | 
                                                        |
| 202 | + */  | 
                                                        |
| 203 | + public function get_request(WP $WP)  | 
                                                        |
| 204 | +	{ | 
                                                        |
| 205 | +		do_action('AHEE__EE_Front_Controller__get_request__start'); | 
                                                        |
| 206 | + $this->current_page->parseQueryVars($WP);  | 
                                                        |
| 207 | +		do_action('AHEE__EE_Front_Controller__get_request__complete'); | 
                                                        |
| 208 | +		remove_action('parse_request', [$this, 'get_request'], 1); | 
                                                        |
| 209 | + }  | 
                                                        |
| 210 | +  | 
                                                        |
| 211 | +  | 
                                                        |
| 212 | + /**  | 
                                                        |
| 213 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template  | 
                                                        |
| 214 | + *  | 
                                                        |
| 215 | + * @access public  | 
                                                        |
| 216 | + * @param WP_Query $WP_Query  | 
                                                        |
| 217 | + * @return void  | 
                                                        |
| 218 | + * @throws EE_Error  | 
                                                        |
| 219 | + * @throws ReflectionException  | 
                                                        |
| 220 | + */  | 
                                                        |
| 221 | + public function pre_get_posts($WP_Query)  | 
                                                        |
| 222 | +	{ | 
                                                        |
| 223 | + // only load Module_Request_Router if this is the main query  | 
                                                        |
| 224 | + if (  | 
                                                        |
| 225 | + $this->Module_Request_Router instanceof EE_Module_Request_Router  | 
                                                        |
| 226 | + && $WP_Query->is_main_query()  | 
                                                        |
| 227 | +		) { | 
                                                        |
| 228 | + // cycle thru module routes  | 
                                                        |
| 229 | +			while ($route = $this->Module_Request_Router->get_route($WP_Query)) { | 
                                                        |
| 230 | + // determine module and method for route  | 
                                                        |
| 231 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);  | 
                                                        |
| 232 | +				if ($module instanceof EED_Module) { | 
                                                        |
| 233 | + // get registered view for route  | 
                                                        |
| 234 | + $this->_template_path = $this->Module_Request_Router->get_view($route);  | 
                                                        |
| 235 | + // grab module name  | 
                                                        |
| 236 | + $module_name = $module->module_name();  | 
                                                        |
| 237 | + // map the module to the module objects  | 
                                                        |
| 238 | +					$this->Registry->modules->{$module_name} = $module; | 
                                                        |
| 239 | + }  | 
                                                        |
| 240 | + }  | 
                                                        |
| 241 | + }  | 
                                                        |
| 242 | + }  | 
                                                        |
| 243 | +  | 
                                                        |
| 244 | +  | 
                                                        |
| 245 | +  | 
                                                        |
| 246 | +  | 
                                                        |
| 247 | +  | 
                                                        |
| 248 | + /*********************************************** WP HOOK ***********************************************/  | 
                                                        |
| 249 | +  | 
                                                        |
| 250 | +  | 
                                                        |
| 251 | + /**  | 
                                                        |
| 252 | + * wp - basically last chance to do stuff before headers sent  | 
                                                        |
| 253 | + *  | 
                                                        |
| 254 | + * @access public  | 
                                                        |
| 255 | + * @return void  | 
                                                        |
| 256 | + */  | 
                                                        |
| 257 | + public function wp()  | 
                                                        |
| 258 | +	{ | 
                                                        |
| 259 | + }  | 
                                                        |
| 260 | +  | 
                                                        |
| 261 | +  | 
                                                        |
| 262 | +  | 
                                                        |
| 263 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/  | 
                                                        |
| 264 | +  | 
                                                        |
| 265 | +  | 
                                                        |
| 266 | + /**  | 
                                                        |
| 267 | + * callback for the "template_redirect" hook point  | 
                                                        |
| 268 | + * checks sidebars for EE widgets  | 
                                                        |
| 269 | + * loads resources and assets accordingly  | 
                                                        |
| 270 | + *  | 
                                                        |
| 271 | + * @return void  | 
                                                        |
| 272 | + */  | 
                                                        |
| 273 | + public function templateRedirect()  | 
                                                        |
| 274 | +	{ | 
                                                        |
| 275 | + global $wp_query;  | 
                                                        |
| 276 | +		if (empty($wp_query->posts)) { | 
                                                        |
| 277 | + return;  | 
                                                        |
| 278 | + }  | 
                                                        |
| 279 | + // if we already know this is an espresso page, then load assets  | 
                                                        |
| 280 | + $load_assets = $this->current_page->isEspressoPage();  | 
                                                        |
| 281 | + // if we are already loading assets then just move along, otherwise check for widgets  | 
                                                        |
| 282 | + $load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars();  | 
                                                        |
| 283 | +		if ($load_assets) { | 
                                                        |
| 284 | +			add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); | 
                                                        |
| 285 | +			add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); | 
                                                        |
| 286 | + }  | 
                                                        |
| 287 | + }  | 
                                                        |
| 288 | +  | 
                                                        |
| 289 | +  | 
                                                        |
| 290 | + /**  | 
                                                        |
| 291 | + * builds list of active widgets then scans active sidebars looking for them  | 
                                                        |
| 292 | + * returns true is an EE widget is found in an active sidebar  | 
                                                        |
| 293 | + * Please Note: this does NOT mean that the sidebar or widget  | 
                                                        |
| 294 | + * is actually in use in a given template, as that is unfortunately not known  | 
                                                        |
| 295 | + * until a sidebar and it's widgets are actually loaded  | 
                                                        |
| 296 | + *  | 
                                                        |
| 297 | + * @return boolean  | 
                                                        |
| 298 | + */  | 
                                                        |
| 299 | + private function espresso_widgets_in_active_sidebars()  | 
                                                        |
| 300 | +	{ | 
                                                        |
| 301 | + $espresso_widgets = array();  | 
                                                        |
| 302 | +		foreach ($this->Registry->widgets as $widget_class => $widget) { | 
                                                        |
| 303 | + $id_base = EspressoWidget::getIdBase($widget_class);  | 
                                                        |
| 304 | +			if (is_active_widget(false, false, $id_base)) { | 
                                                        |
| 305 | + $espresso_widgets[] = $id_base;  | 
                                                        |
| 306 | + }  | 
                                                        |
| 307 | + }  | 
                                                        |
| 308 | + $all_sidebar_widgets = wp_get_sidebars_widgets();  | 
                                                        |
| 309 | +		foreach ($all_sidebar_widgets as $sidebar_widgets) { | 
                                                        |
| 310 | +			if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { | 
                                                        |
| 311 | +				foreach ($sidebar_widgets as $sidebar_widget) { | 
                                                        |
| 312 | +					foreach ($espresso_widgets as $espresso_widget) { | 
                                                        |
| 313 | +						if (strpos($sidebar_widget, $espresso_widget) !== false) { | 
                                                        |
| 314 | + return true;  | 
                                                        |
| 315 | + }  | 
                                                        |
| 316 | + }  | 
                                                        |
| 317 | + }  | 
                                                        |
| 318 | + }  | 
                                                        |
| 319 | + }  | 
                                                        |
| 320 | + return false;  | 
                                                        |
| 321 | + }  | 
                                                        |
| 322 | +  | 
                                                        |
| 323 | +  | 
                                                        |
| 324 | + /**  | 
                                                        |
| 325 | + * header_meta_tag  | 
                                                        |
| 326 | + *  | 
                                                        |
| 327 | + * @access public  | 
                                                        |
| 328 | + * @return void  | 
                                                        |
| 329 | + */  | 
                                                        |
| 330 | + public function header_meta_tag()  | 
                                                        |
| 331 | +	{ | 
                                                        |
| 332 | + print(  | 
                                                        |
| 333 | + apply_filters(  | 
                                                        |
| 334 | + 'FHEE__EE_Front_Controller__header_meta_tag',  | 
                                                        |
| 335 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"  | 
                                                        |
| 336 | + )  | 
                                                        |
| 337 | + );  | 
                                                        |
| 338 | +  | 
                                                        |
| 339 | + // let's exclude all event type taxonomy term archive pages from search engine indexing  | 
                                                        |
| 340 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249  | 
                                                        |
| 341 | + // also exclude all critical pages from indexing  | 
                                                        |
| 342 | + if (  | 
                                                        |
| 343 | + (  | 
                                                        |
| 344 | +				is_tax('espresso_event_type') | 
                                                        |
| 345 | +				&& get_option('blog_public') !== '0' | 
                                                        |
| 346 | + )  | 
                                                        |
| 347 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())  | 
                                                        |
| 348 | +		) { | 
                                                        |
| 349 | + print(  | 
                                                        |
| 350 | + apply_filters(  | 
                                                        |
| 351 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',  | 
                                                        |
| 352 | + '<meta name="robots" content="noindex,follow" />' . "\n"  | 
                                                        |
| 353 | + )  | 
                                                        |
| 354 | + );  | 
                                                        |
| 355 | + }  | 
                                                        |
| 356 | + }  | 
                                                        |
| 357 | +  | 
                                                        |
| 358 | +  | 
                                                        |
| 359 | + /**  | 
                                                        |
| 360 | + * wp_print_scripts  | 
                                                        |
| 361 | + *  | 
                                                        |
| 362 | + * @return void  | 
                                                        |
| 363 | + * @throws EE_Error  | 
                                                        |
| 364 | + */  | 
                                                        |
| 365 | + public function wp_print_scripts()  | 
                                                        |
| 366 | +	{ | 
                                                        |
| 367 | + global $post;  | 
                                                        |
| 368 | + if (  | 
                                                        |
| 369 | + isset($post->EE_Event)  | 
                                                        |
| 370 | + && $post->EE_Event instanceof EE_Event  | 
                                                        |
| 371 | + && get_post_type() === 'espresso_events'  | 
                                                        |
| 372 | + && is_singular()  | 
                                                        |
| 373 | +		) { | 
                                                        |
| 374 | + EEH_Schema::add_json_linked_data_for_event($post->EE_Event);  | 
                                                        |
| 375 | + }  | 
                                                        |
| 376 | + }  | 
                                                        |
| 377 | +  | 
                                                        |
| 378 | +  | 
                                                        |
| 379 | + public function enqueueStyle()  | 
                                                        |
| 380 | +	{ | 
                                                        |
| 381 | +		wp_enqueue_style('espresso_default'); | 
                                                        |
| 382 | +		wp_enqueue_style('espresso_custom_css'); | 
                                                        |
| 383 | + }  | 
                                                        |
| 384 | +  | 
                                                        |
| 385 | +  | 
                                                        |
| 386 | +  | 
                                                        |
| 387 | + /*********************************************** WP_FOOTER ***********************************************/  | 
                                                        |
| 388 | +  | 
                                                        |
| 389 | +  | 
                                                        |
| 390 | + public function enqueueScripts()  | 
                                                        |
| 391 | +	{ | 
                                                        |
| 392 | +		wp_enqueue_script('espresso_core'); | 
                                                        |
| 393 | + }  | 
                                                        |
| 394 | +  | 
                                                        |
| 395 | +  | 
                                                        |
| 396 | + /**  | 
                                                        |
| 397 | + * display_errors  | 
                                                        |
| 398 | + *  | 
                                                        |
| 399 | + * @access public  | 
                                                        |
| 400 | + * @return void  | 
                                                        |
| 401 | + * @throws DomainException  | 
                                                        |
| 402 | + */  | 
                                                        |
| 403 | + public function display_errors()  | 
                                                        |
| 404 | +	{ | 
                                                        |
| 405 | + static $shown_already = false;  | 
                                                        |
| 406 | +		do_action('AHEE__EE_Front_Controller__display_errors__begin'); | 
                                                        |
| 407 | + if (  | 
                                                        |
| 408 | + ! $shown_already  | 
                                                        |
| 409 | +			&& apply_filters('FHEE__EE_Front_Controller__display_errors', true) | 
                                                        |
| 410 | + && is_main_query()  | 
                                                        |
| 411 | + && ! is_feed()  | 
                                                        |
| 412 | + && in_the_loop()  | 
                                                        |
| 413 | +			&& did_action('wp_head') | 
                                                        |
| 414 | + && $this->current_page->isEspressoPage()  | 
                                                        |
| 415 | +		) { | 
                                                        |
| 416 | + echo EE_Error::get_notices();  | 
                                                        |
| 417 | + $shown_already = true;  | 
                                                        |
| 418 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');  | 
                                                        |
| 419 | + }  | 
                                                        |
| 420 | +		do_action('AHEE__EE_Front_Controller__display_errors__end'); | 
                                                        |
| 421 | + }  | 
                                                        |
| 422 | +  | 
                                                        |
| 423 | +  | 
                                                        |
| 424 | +  | 
                                                        |
| 425 | +  | 
                                                        |
| 426 | +  | 
                                                        |
| 427 | + /*********************************************** UTILITIES ***********************************************/  | 
                                                        |
| 428 | +  | 
                                                        |
| 429 | +  | 
                                                        |
| 430 | + /**  | 
                                                        |
| 431 | + * @param string $template_include_path  | 
                                                        |
| 432 | + * @return string  | 
                                                        |
| 433 | + * @throws EE_Error  | 
                                                        |
| 434 | + * @throws ReflectionException  | 
                                                        |
| 435 | + */  | 
                                                        |
| 436 | + public function template_include($template_include_path = null)  | 
                                                        |
| 437 | +	{ | 
                                                        |
| 438 | +		if ($this->current_page->isEspressoPage()) { | 
                                                        |
| 439 | + // despite all helpers having autoloaders set, we need to manually load the template loader  | 
                                                        |
| 440 | + // because there are some side effects in that class for triggering template tag functions  | 
                                                        |
| 441 | +			$this->Registry->load_helper('EEH_Template'); | 
                                                        |
| 442 | + $this->_template_path = ! empty($this->_template_path)  | 
                                                        |
| 443 | + ? basename($this->_template_path)  | 
                                                        |
| 444 | + : basename(  | 
                                                        |
| 445 | + $template_include_path  | 
                                                        |
| 446 | + );  | 
                                                        |
| 447 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false);  | 
                                                        |
| 448 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;  | 
                                                        |
| 449 | + $this->_template = basename($this->_template_path);  | 
                                                        |
| 450 | + return $this->_template_path;  | 
                                                        |
| 451 | + }  | 
                                                        |
| 452 | + return $template_include_path;  | 
                                                        |
| 453 | + }  | 
                                                        |
| 454 | +  | 
                                                        |
| 455 | +  | 
                                                        |
| 456 | + /**  | 
                                                        |
| 457 | + * @param bool $with_path  | 
                                                        |
| 458 | + * @return string  | 
                                                        |
| 459 | + */  | 
                                                        |
| 460 | + public function get_selected_template($with_path = false)  | 
                                                        |
| 461 | +	{ | 
                                                        |
| 462 | + return $with_path ? $this->_template_path : $this->_template;  | 
                                                        |
| 463 | + }  | 
                                                        |
| 464 | +  | 
                                                        |
| 465 | +  | 
                                                        |
| 466 | + /**  | 
                                                        |
| 467 | + * @param string $shortcode_class  | 
                                                        |
| 468 | + * @param WP $wp  | 
                                                        |
| 469 | + * @throws ReflectionException  | 
                                                        |
| 470 | + * @deprecated 4.9.26  | 
                                                        |
| 471 | + */  | 
                                                        |
| 472 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null)  | 
                                                        |
| 473 | +	{ | 
                                                        |
| 474 | + EE_Error::doing_it_wrong(  | 
                                                        |
| 475 | + __METHOD__,  | 
                                                        |
| 476 | + esc_html__(  | 
                                                        |
| 477 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',  | 
                                                        |
| 478 | + 'event_espresso'  | 
                                                        |
| 479 | + ),  | 
                                                        |
| 480 | + '4.9.26'  | 
                                                        |
| 481 | + );  | 
                                                        |
| 482 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);  | 
                                                        |
| 483 | + }  | 
                                                        |
| 484 | +  | 
                                                        |
| 485 | +  | 
                                                        |
| 486 | + /**  | 
                                                        |
| 487 | + * @return void  | 
                                                        |
| 488 | + * @deprecated 4.9.57.p  | 
                                                        |
| 489 | + */  | 
                                                        |
| 490 | + public function loadPersistentAdminNoticeManager()  | 
                                                        |
| 491 | +	{ | 
                                                        |
| 492 | + }  | 
                                                        |
| 493 | +  | 
                                                        |
| 494 | +  | 
                                                        |
| 495 | + /**  | 
                                                        |
| 496 | + * @return void  | 
                                                        |
| 497 | + * @deprecated 4.9.64.p  | 
                                                        |
| 498 | + */  | 
                                                        |
| 499 | + public function employ_CPT_Strategy()  | 
                                                        |
| 500 | +	{ | 
                                                        |
| 501 | + }  | 
                                                        |
| 502 | 502 | }  | 
                                                        
@@ -38,103 +38,103 @@  | 
                                                    ||
| 38 | 38 | * @since 4.0  | 
                                                        
| 39 | 39 | */  | 
                                                        
| 40 | 40 |  if (function_exists('espresso_version')) { | 
                                                        
| 41 | -    if (! function_exists('espresso_duplicate_plugin_error')) { | 
                                                        |
| 42 | - /**  | 
                                                        |
| 43 | - * espresso_duplicate_plugin_error  | 
                                                        |
| 44 | - * displays if more than one version of EE is activated at the same time  | 
                                                        |
| 45 | - */  | 
                                                        |
| 46 | - function espresso_duplicate_plugin_error()  | 
                                                        |
| 47 | -        { | 
                                                        |
| 48 | - ?>  | 
                                                        |
| 41 | +	if (! function_exists('espresso_duplicate_plugin_error')) { | 
                                                        |
| 42 | + /**  | 
                                                        |
| 43 | + * espresso_duplicate_plugin_error  | 
                                                        |
| 44 | + * displays if more than one version of EE is activated at the same time  | 
                                                        |
| 45 | + */  | 
                                                        |
| 46 | + function espresso_duplicate_plugin_error()  | 
                                                        |
| 47 | +		{ | 
                                                        |
| 48 | + ?>  | 
                                                        |
| 49 | 49 | <div class="error">  | 
                                                        
| 50 | 50 | <p>  | 
                                                        
| 51 | 51 | <?php  | 
                                                        
| 52 | - 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 | - ); ?>  | 
                                                        |
| 52 | + 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 | + ); ?>  | 
                                                        |
| 56 | 56 | </p>  | 
                                                        
| 57 | 57 | </div>  | 
                                                        
| 58 | 58 | <?php  | 
                                                        
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__));  | 
                                                        |
| 60 | - }  | 
                                                        |
| 61 | - }  | 
                                                        |
| 62 | -    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); | 
                                                        |
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__));  | 
                                                        |
| 60 | + }  | 
                                                        |
| 61 | + }  | 
                                                        |
| 62 | +	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); | 
                                                        |
| 63 | 63 |  } else { | 
                                                        
| 64 | -    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); | 
                                                        |
| 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.6.2'); | 
                                                        |
| 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 | -        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); | 
                                                        |
| 97 | - /**  | 
                                                        |
| 98 | - * espresso_version  | 
                                                        |
| 99 | - * Returns the plugin version  | 
                                                        |
| 100 | - *  | 
                                                        |
| 101 | - * @return string  | 
                                                        |
| 102 | - */  | 
                                                        |
| 103 | - function espresso_version()  | 
                                                        |
| 104 | -        { | 
                                                        |
| 105 | -            return apply_filters('FHEE__espresso__espresso_version', '4.10.23.rc.000'); | 
                                                        |
| 106 | - }  | 
                                                        |
| 94 | +		add_action('admin_notices', 'espresso_minimum_php_version_error', 1); | 
                                                        |
| 95 | +	} else { | 
                                                        |
| 96 | +		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); | 
                                                        |
| 97 | + /**  | 
                                                        |
| 98 | + * espresso_version  | 
                                                        |
| 99 | + * Returns the plugin version  | 
                                                        |
| 100 | + *  | 
                                                        |
| 101 | + * @return string  | 
                                                        |
| 102 | + */  | 
                                                        |
| 103 | + function espresso_version()  | 
                                                        |
| 104 | +		{ | 
                                                        |
| 105 | +			return apply_filters('FHEE__espresso__espresso_version', '4.10.23.rc.000'); | 
                                                        |
| 106 | + }  | 
                                                        |
| 107 | 107 | |
| 108 | - /**  | 
                                                        |
| 109 | - * espresso_plugin_activation  | 
                                                        |
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page  | 
                                                        |
| 111 | - */  | 
                                                        |
| 112 | - function espresso_plugin_activation()  | 
                                                        |
| 113 | -        { | 
                                                        |
| 114 | -            update_option('ee_espresso_activation', true); | 
                                                        |
| 115 | - }  | 
                                                        |
| 108 | + /**  | 
                                                        |
| 109 | + * espresso_plugin_activation  | 
                                                        |
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page  | 
                                                        |
| 111 | + */  | 
                                                        |
| 112 | + function espresso_plugin_activation()  | 
                                                        |
| 113 | +		{ | 
                                                        |
| 114 | +			update_option('ee_espresso_activation', true); | 
                                                        |
| 115 | + }  | 
                                                        |
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');  | 
                                                        |
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');  | 
                                                        |
| 118 | 118 | |
| 119 | - require_once __DIR__ . '/core/bootstrap_espresso.php';  | 
                                                        |
| 120 | - bootstrap_espresso();  | 
                                                        |
| 121 | - }  | 
                                                        |
| 119 | + require_once __DIR__ . '/core/bootstrap_espresso.php';  | 
                                                        |
| 120 | + bootstrap_espresso();  | 
                                                        |
| 121 | + }  | 
                                                        |
| 122 | 122 | }  | 
                                                        
| 123 | 123 |  if (! function_exists('espresso_deactivate_plugin')) { | 
                                                        
| 124 | - /**  | 
                                                        |
| 125 | - * deactivate_plugin  | 
                                                        |
| 126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ ));  | 
                                                        |
| 127 | - *  | 
                                                        |
| 128 | - * @access public  | 
                                                        |
| 129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file  | 
                                                        |
| 130 | - * @return void  | 
                                                        |
| 131 | - */  | 
                                                        |
| 132 | - function espresso_deactivate_plugin($plugin_basename = '')  | 
                                                        |
| 133 | -    { | 
                                                        |
| 134 | -        if (! function_exists('deactivate_plugins')) { | 
                                                        |
| 135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php';  | 
                                                        |
| 136 | - }  | 
                                                        |
| 137 | - unset($_GET['activate'], $_REQUEST['activate']);  | 
                                                        |
| 138 | - deactivate_plugins($plugin_basename);  | 
                                                        |
| 139 | - }  | 
                                                        |
| 124 | + /**  | 
                                                        |
| 125 | + * deactivate_plugin  | 
                                                        |
| 126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ ));  | 
                                                        |
| 127 | + *  | 
                                                        |
| 128 | + * @access public  | 
                                                        |
| 129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file  | 
                                                        |
| 130 | + * @return void  | 
                                                        |
| 131 | + */  | 
                                                        |
| 132 | + function espresso_deactivate_plugin($plugin_basename = '')  | 
                                                        |
| 133 | +	{ | 
                                                        |
| 134 | +		if (! function_exists('deactivate_plugins')) { | 
                                                        |
| 135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php';  | 
                                                        |
| 136 | + }  | 
                                                        |
| 137 | + unset($_GET['activate'], $_REQUEST['activate']);  | 
                                                        |
| 138 | + deactivate_plugins($plugin_basename);  | 
                                                        |
| 139 | + }  | 
                                                        |
| 140 | 140 | }  |