@@ -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.4.0'); |
|
| 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.4.0'); |
|
| 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.2.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.2.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 | } |
@@ -18,224 +18,224 @@ |
||
| 18 | 18 | class EE_Recipient_List_Shortcodes extends EE_Shortcodes |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - public function __construct() |
|
| 22 | - { |
|
| 23 | - parent::__construct(); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - protected function _init_props() |
|
| 28 | - { |
|
| 29 | - $this->label = __('Recipient List Shortcodes', 'event_espresso'); |
|
| 30 | - $this->description = __('All shortcodes specific to registrant recipients list type data.', 'event_espresso'); |
|
| 31 | - $this->_shortcodes = array( |
|
| 32 | - '[RECIPIENT_TICKET_LIST]' => __( |
|
| 33 | - 'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.', |
|
| 34 | - 'event_espresso' |
|
| 35 | - ), |
|
| 36 | - '[RECIPIENT_DATETIME_LIST]' => __( |
|
| 37 | - 'Will output a list of datetimes that the person receiving this message has been registered for.', |
|
| 38 | - 'event_espresso' |
|
| 39 | - ), |
|
| 40 | - ); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - protected function _parser($shortcode) |
|
| 45 | - { |
|
| 46 | - switch ($shortcode) { |
|
| 47 | - case '[RECIPIENT_TICKET_LIST]': |
|
| 48 | - return $this->_get_recipient_ticket_list(); |
|
| 49 | - break; |
|
| 50 | - |
|
| 51 | - case '[RECIPIENT_DATETIME_LIST]': |
|
| 52 | - return $this->_get_recipient_datetime_list(); |
|
| 53 | - break; |
|
| 54 | - } |
|
| 55 | - return ''; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * figure out what the incoming data is and then return the appropriate parsed value |
|
| 61 | - * |
|
| 62 | - * @return string |
|
| 63 | - */ |
|
| 64 | - private function _get_recipient_ticket_list() |
|
| 65 | - { |
|
| 66 | - $this->_validate_list_requirements(); |
|
| 67 | - |
|
| 68 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
| 69 | - return $this->_get_recipient_ticket_list_parsed($this->_data['data']); |
|
| 70 | - } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
| 71 | - return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']); |
|
| 72 | - } else { |
|
| 73 | - return ''; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data) |
|
| 79 | - { |
|
| 80 | - // first get registrations just for this attendee. |
|
| 81 | - $att = $data->att_obj; |
|
| 82 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
| 83 | - $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
| 84 | - ? array($data->reg_obj) : $registrations_on_attendee; |
|
| 85 | - $tkts = array(); |
|
| 86 | - |
|
| 87 | - // if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee. |
|
| 88 | - // which means we want to get tickets for all events this addressee is a part of. |
|
| 89 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
| 90 | - $valid_shortcodes = array( |
|
| 91 | - 'ticket', |
|
| 92 | - 'event_list', |
|
| 93 | - 'attendee_list', |
|
| 94 | - 'datetime_list', |
|
| 95 | - 'registration_details', |
|
| 96 | - 'attendee', |
|
| 97 | - 'recipient_details', |
|
| 98 | - ); |
|
| 99 | - $template = $this->_data['template']; |
|
| 100 | - |
|
| 101 | - // tickets will be tickets for all registrations on this attendee. |
|
| 102 | - foreach ($registrations_on_attendee as $reg) { |
|
| 103 | - if ($reg instanceof EE_Registration) { |
|
| 104 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 105 | - $data->registrations[ $reg->ID() ] |
|
| 106 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
| 107 | - ) ]['tkt_obj'] : null; |
|
| 108 | - if ($ticket instanceof EE_Ticket) { |
|
| 109 | - $tkts[ $ticket->ID() ] = $ticket; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - // if coming from the context of the event list parser, then let's return just the tickets for that event. |
|
| 116 | - $event = $this->_data['data']; |
|
| 117 | - if ($event instanceof EE_Event) { |
|
| 118 | - $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details'); |
|
| 119 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
| 120 | - ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list']; |
|
| 121 | - // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
| 122 | - $template = str_replace('[EVENT_LIST]', '', $template); |
|
| 123 | - // data will be tickets for this event for this recipient. |
|
| 124 | - foreach ($registrations_on_attendee as $reg) { |
|
| 125 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
| 126 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 127 | - $data->registrations[ $reg->ID() ] |
|
| 128 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
| 129 | - ) ]['tkt_obj'] : null; |
|
| 130 | - if ($ticket instanceof EE_Ticket) { |
|
| 131 | - $tkts[ $ticket->ID() ] = $ticket; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - $tkt_parsed = ''; |
|
| 138 | - foreach ($tkts as $ticket) { |
|
| 139 | - $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
| 140 | - $template, |
|
| 141 | - $ticket, |
|
| 142 | - $valid_shortcodes, |
|
| 143 | - $this->_extra_data |
|
| 144 | - ); |
|
| 145 | - } |
|
| 146 | - return $tkt_parsed; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * figure out what the incoming data is and then return the appropriate parsed value |
|
| 152 | - * |
|
| 153 | - * @return string |
|
| 154 | - */ |
|
| 155 | - private function _get_recipient_datetime_list() |
|
| 156 | - { |
|
| 157 | - $this->_validate_list_requirements(); |
|
| 158 | - |
|
| 159 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
| 160 | - return $this->_get_recipient_datetime_list_parsed($this->_data['data']); |
|
| 161 | - } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
| 162 | - return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']); |
|
| 163 | - } else { |
|
| 164 | - return ''; |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data) |
|
| 170 | - { |
|
| 171 | - // first get registrations just for this attendee. |
|
| 172 | - $att = $data->att_obj; |
|
| 173 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
| 174 | - $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
| 175 | - ? array($data->reg_obj) : $registrations_on_attendee; |
|
| 176 | - $valid_shortcodes = array('datetime', 'attendee', 'recipient_details'); |
|
| 177 | - $template = ''; |
|
| 178 | - $dtts = array(); |
|
| 179 | - |
|
| 180 | - // setup valid shortcodes depending on what the status of the $this->_data property is |
|
| 181 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
| 182 | - $template = $this->_data['template']; |
|
| 183 | - |
|
| 184 | - // dtts will be datetimes for all registrations on this attendee |
|
| 185 | - foreach ($registrations_on_attendee as $reg) { |
|
| 186 | - if ($reg instanceof EE_Registration) { |
|
| 187 | - $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 188 | - $data->registrations[ $reg->ID() ] |
|
| 189 | - ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID( |
|
| 190 | - ) ]['dtt_objs'] : array(); |
|
| 191 | - $dtt_objs = (array) $dtt_objs; |
|
| 192 | - foreach ($dtt_objs as $dtt_obj) { |
|
| 193 | - if ($dtt_obj instanceof EE_Datetime) { |
|
| 194 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - // if coming from the context of the event list parser, then let's just return the datetimes for the specific event. |
|
| 202 | - $event = $this->_data['data']; |
|
| 203 | - if ($event instanceof EE_Event) { |
|
| 204 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
| 205 | - ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list']; |
|
| 206 | - |
|
| 207 | - // data will be datetimes for this event for this recipient |
|
| 208 | - foreach ($registrations_on_attendee as $reg) { |
|
| 209 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
| 210 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 211 | - $data->registrations[ $reg->ID() ] |
|
| 212 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
| 213 | - ) ]['tkt_obj'] : null; |
|
| 214 | - if ($ticket instanceof EE_Ticket) { |
|
| 215 | - $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array( |
|
| 216 | - $data->tickets[ $ticket->ID() ] |
|
| 217 | - ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID( |
|
| 218 | - ) ]['dtt_objs'] : array(); |
|
| 219 | - $dtt_objs = (array) $dtt_objs; |
|
| 220 | - foreach ($dtt_objs as $dtt_obj) { |
|
| 221 | - if ($dtt_obj instanceof EE_Datetime) { |
|
| 222 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - $dtt_parsed = ''; |
|
| 231 | - foreach ($dtts as $datetime) { |
|
| 232 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
| 233 | - $template, |
|
| 234 | - $datetime, |
|
| 235 | - $valid_shortcodes, |
|
| 236 | - $this->_extra_data |
|
| 237 | - ); |
|
| 238 | - } |
|
| 239 | - return $dtt_parsed; |
|
| 240 | - } |
|
| 21 | + public function __construct() |
|
| 22 | + { |
|
| 23 | + parent::__construct(); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + protected function _init_props() |
|
| 28 | + { |
|
| 29 | + $this->label = __('Recipient List Shortcodes', 'event_espresso'); |
|
| 30 | + $this->description = __('All shortcodes specific to registrant recipients list type data.', 'event_espresso'); |
|
| 31 | + $this->_shortcodes = array( |
|
| 32 | + '[RECIPIENT_TICKET_LIST]' => __( |
|
| 33 | + 'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.', |
|
| 34 | + 'event_espresso' |
|
| 35 | + ), |
|
| 36 | + '[RECIPIENT_DATETIME_LIST]' => __( |
|
| 37 | + 'Will output a list of datetimes that the person receiving this message has been registered for.', |
|
| 38 | + 'event_espresso' |
|
| 39 | + ), |
|
| 40 | + ); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + protected function _parser($shortcode) |
|
| 45 | + { |
|
| 46 | + switch ($shortcode) { |
|
| 47 | + case '[RECIPIENT_TICKET_LIST]': |
|
| 48 | + return $this->_get_recipient_ticket_list(); |
|
| 49 | + break; |
|
| 50 | + |
|
| 51 | + case '[RECIPIENT_DATETIME_LIST]': |
|
| 52 | + return $this->_get_recipient_datetime_list(); |
|
| 53 | + break; |
|
| 54 | + } |
|
| 55 | + return ''; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * figure out what the incoming data is and then return the appropriate parsed value |
|
| 61 | + * |
|
| 62 | + * @return string |
|
| 63 | + */ |
|
| 64 | + private function _get_recipient_ticket_list() |
|
| 65 | + { |
|
| 66 | + $this->_validate_list_requirements(); |
|
| 67 | + |
|
| 68 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
| 69 | + return $this->_get_recipient_ticket_list_parsed($this->_data['data']); |
|
| 70 | + } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
| 71 | + return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']); |
|
| 72 | + } else { |
|
| 73 | + return ''; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data) |
|
| 79 | + { |
|
| 80 | + // first get registrations just for this attendee. |
|
| 81 | + $att = $data->att_obj; |
|
| 82 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
| 83 | + $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
| 84 | + ? array($data->reg_obj) : $registrations_on_attendee; |
|
| 85 | + $tkts = array(); |
|
| 86 | + |
|
| 87 | + // if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee. |
|
| 88 | + // which means we want to get tickets for all events this addressee is a part of. |
|
| 89 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
| 90 | + $valid_shortcodes = array( |
|
| 91 | + 'ticket', |
|
| 92 | + 'event_list', |
|
| 93 | + 'attendee_list', |
|
| 94 | + 'datetime_list', |
|
| 95 | + 'registration_details', |
|
| 96 | + 'attendee', |
|
| 97 | + 'recipient_details', |
|
| 98 | + ); |
|
| 99 | + $template = $this->_data['template']; |
|
| 100 | + |
|
| 101 | + // tickets will be tickets for all registrations on this attendee. |
|
| 102 | + foreach ($registrations_on_attendee as $reg) { |
|
| 103 | + if ($reg instanceof EE_Registration) { |
|
| 104 | + $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 105 | + $data->registrations[ $reg->ID() ] |
|
| 106 | + ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
| 107 | + ) ]['tkt_obj'] : null; |
|
| 108 | + if ($ticket instanceof EE_Ticket) { |
|
| 109 | + $tkts[ $ticket->ID() ] = $ticket; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + // if coming from the context of the event list parser, then let's return just the tickets for that event. |
|
| 116 | + $event = $this->_data['data']; |
|
| 117 | + if ($event instanceof EE_Event) { |
|
| 118 | + $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details'); |
|
| 119 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
| 120 | + ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list']; |
|
| 121 | + // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
| 122 | + $template = str_replace('[EVENT_LIST]', '', $template); |
|
| 123 | + // data will be tickets for this event for this recipient. |
|
| 124 | + foreach ($registrations_on_attendee as $reg) { |
|
| 125 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
| 126 | + $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 127 | + $data->registrations[ $reg->ID() ] |
|
| 128 | + ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
| 129 | + ) ]['tkt_obj'] : null; |
|
| 130 | + if ($ticket instanceof EE_Ticket) { |
|
| 131 | + $tkts[ $ticket->ID() ] = $ticket; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + $tkt_parsed = ''; |
|
| 138 | + foreach ($tkts as $ticket) { |
|
| 139 | + $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
| 140 | + $template, |
|
| 141 | + $ticket, |
|
| 142 | + $valid_shortcodes, |
|
| 143 | + $this->_extra_data |
|
| 144 | + ); |
|
| 145 | + } |
|
| 146 | + return $tkt_parsed; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * figure out what the incoming data is and then return the appropriate parsed value |
|
| 152 | + * |
|
| 153 | + * @return string |
|
| 154 | + */ |
|
| 155 | + private function _get_recipient_datetime_list() |
|
| 156 | + { |
|
| 157 | + $this->_validate_list_requirements(); |
|
| 158 | + |
|
| 159 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
| 160 | + return $this->_get_recipient_datetime_list_parsed($this->_data['data']); |
|
| 161 | + } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
| 162 | + return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']); |
|
| 163 | + } else { |
|
| 164 | + return ''; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data) |
|
| 170 | + { |
|
| 171 | + // first get registrations just for this attendee. |
|
| 172 | + $att = $data->att_obj; |
|
| 173 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
| 174 | + $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
| 175 | + ? array($data->reg_obj) : $registrations_on_attendee; |
|
| 176 | + $valid_shortcodes = array('datetime', 'attendee', 'recipient_details'); |
|
| 177 | + $template = ''; |
|
| 178 | + $dtts = array(); |
|
| 179 | + |
|
| 180 | + // setup valid shortcodes depending on what the status of the $this->_data property is |
|
| 181 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
| 182 | + $template = $this->_data['template']; |
|
| 183 | + |
|
| 184 | + // dtts will be datetimes for all registrations on this attendee |
|
| 185 | + foreach ($registrations_on_attendee as $reg) { |
|
| 186 | + if ($reg instanceof EE_Registration) { |
|
| 187 | + $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 188 | + $data->registrations[ $reg->ID() ] |
|
| 189 | + ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID( |
|
| 190 | + ) ]['dtt_objs'] : array(); |
|
| 191 | + $dtt_objs = (array) $dtt_objs; |
|
| 192 | + foreach ($dtt_objs as $dtt_obj) { |
|
| 193 | + if ($dtt_obj instanceof EE_Datetime) { |
|
| 194 | + $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + // if coming from the context of the event list parser, then let's just return the datetimes for the specific event. |
|
| 202 | + $event = $this->_data['data']; |
|
| 203 | + if ($event instanceof EE_Event) { |
|
| 204 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
| 205 | + ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list']; |
|
| 206 | + |
|
| 207 | + // data will be datetimes for this event for this recipient |
|
| 208 | + foreach ($registrations_on_attendee as $reg) { |
|
| 209 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
| 210 | + $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 211 | + $data->registrations[ $reg->ID() ] |
|
| 212 | + ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
| 213 | + ) ]['tkt_obj'] : null; |
|
| 214 | + if ($ticket instanceof EE_Ticket) { |
|
| 215 | + $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array( |
|
| 216 | + $data->tickets[ $ticket->ID() ] |
|
| 217 | + ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID( |
|
| 218 | + ) ]['dtt_objs'] : array(); |
|
| 219 | + $dtt_objs = (array) $dtt_objs; |
|
| 220 | + foreach ($dtt_objs as $dtt_obj) { |
|
| 221 | + if ($dtt_obj instanceof EE_Datetime) { |
|
| 222 | + $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + $dtt_parsed = ''; |
|
| 231 | + foreach ($dtts as $datetime) { |
|
| 232 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
| 233 | + $template, |
|
| 234 | + $datetime, |
|
| 235 | + $valid_shortcodes, |
|
| 236 | + $this->_extra_data |
|
| 237 | + ); |
|
| 238 | + } |
|
| 239 | + return $dtt_parsed; |
|
| 240 | + } |
|
| 241 | 241 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | // first get registrations just for this attendee. |
| 81 | 81 | $att = $data->att_obj; |
| 82 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
| 82 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array(); |
|
| 83 | 83 | $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
| 84 | 84 | ? array($data->reg_obj) : $registrations_on_attendee; |
| 85 | 85 | $tkts = array(); |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | // tickets will be tickets for all registrations on this attendee. |
| 102 | 102 | foreach ($registrations_on_attendee as $reg) { |
| 103 | 103 | if ($reg instanceof EE_Registration) { |
| 104 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 105 | - $data->registrations[ $reg->ID() ] |
|
| 106 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
| 107 | - ) ]['tkt_obj'] : null; |
|
| 104 | + $ticket = isset($data->registrations[$reg->ID()]) && is_array( |
|
| 105 | + $data->registrations[$reg->ID()] |
|
| 106 | + ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID( |
|
| 107 | + )]['tkt_obj'] : null; |
|
| 108 | 108 | if ($ticket instanceof EE_Ticket) { |
| 109 | - $tkts[ $ticket->ID() ] = $ticket; |
|
| 109 | + $tkts[$ticket->ID()] = $ticket; |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -123,12 +123,12 @@ discard block |
||
| 123 | 123 | // data will be tickets for this event for this recipient. |
| 124 | 124 | foreach ($registrations_on_attendee as $reg) { |
| 125 | 125 | if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
| 126 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 127 | - $data->registrations[ $reg->ID() ] |
|
| 128 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
| 129 | - ) ]['tkt_obj'] : null; |
|
| 126 | + $ticket = isset($data->registrations[$reg->ID()]) && is_array( |
|
| 127 | + $data->registrations[$reg->ID()] |
|
| 128 | + ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID( |
|
| 129 | + )]['tkt_obj'] : null; |
|
| 130 | 130 | if ($ticket instanceof EE_Ticket) { |
| 131 | - $tkts[ $ticket->ID() ] = $ticket; |
|
| 131 | + $tkts[$ticket->ID()] = $ticket; |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | // first get registrations just for this attendee. |
| 172 | 172 | $att = $data->att_obj; |
| 173 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
| 173 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array(); |
|
| 174 | 174 | $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
| 175 | 175 | ? array($data->reg_obj) : $registrations_on_attendee; |
| 176 | 176 | $valid_shortcodes = array('datetime', 'attendee', 'recipient_details'); |
@@ -184,14 +184,14 @@ discard block |
||
| 184 | 184 | // dtts will be datetimes for all registrations on this attendee |
| 185 | 185 | foreach ($registrations_on_attendee as $reg) { |
| 186 | 186 | if ($reg instanceof EE_Registration) { |
| 187 | - $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 188 | - $data->registrations[ $reg->ID() ] |
|
| 189 | - ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID( |
|
| 190 | - ) ]['dtt_objs'] : array(); |
|
| 187 | + $dtt_objs = isset($data->registrations[$reg->ID()]) && is_array( |
|
| 188 | + $data->registrations[$reg->ID()] |
|
| 189 | + ) && isset($data->registrations[$reg->ID()]['dtt_objs']) ? $data->registrations[$reg->ID( |
|
| 190 | + )]['dtt_objs'] : array(); |
|
| 191 | 191 | $dtt_objs = (array) $dtt_objs; |
| 192 | 192 | foreach ($dtt_objs as $dtt_obj) { |
| 193 | 193 | if ($dtt_obj instanceof EE_Datetime) { |
| 194 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
| 194 | + $dtts[$dtt_obj->ID()] = $dtt_obj; |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | } |
@@ -207,19 +207,19 @@ discard block |
||
| 207 | 207 | // data will be datetimes for this event for this recipient |
| 208 | 208 | foreach ($registrations_on_attendee as $reg) { |
| 209 | 209 | if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
| 210 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
| 211 | - $data->registrations[ $reg->ID() ] |
|
| 212 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
| 213 | - ) ]['tkt_obj'] : null; |
|
| 210 | + $ticket = isset($data->registrations[$reg->ID()]) && is_array( |
|
| 211 | + $data->registrations[$reg->ID()] |
|
| 212 | + ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID( |
|
| 213 | + )]['tkt_obj'] : null; |
|
| 214 | 214 | if ($ticket instanceof EE_Ticket) { |
| 215 | - $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array( |
|
| 216 | - $data->tickets[ $ticket->ID() ] |
|
| 217 | - ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID( |
|
| 218 | - ) ]['dtt_objs'] : array(); |
|
| 215 | + $dtt_objs = isset($data->tickets[$ticket->ID()]) && is_array( |
|
| 216 | + $data->tickets[$ticket->ID()] |
|
| 217 | + ) && isset($data->tickets[$ticket->ID()]['dtt_objs']) ? $data->tickets[$ticket->ID( |
|
| 218 | + )]['dtt_objs'] : array(); |
|
| 219 | 219 | $dtt_objs = (array) $dtt_objs; |
| 220 | 220 | foreach ($dtt_objs as $dtt_obj) { |
| 221 | 221 | if ($dtt_obj instanceof EE_Datetime) { |
| 222 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
| 222 | + $dtts[$dtt_obj->ID()] = $dtt_obj; |
|
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -17,196 +17,196 @@ |
||
| 17 | 17 | class EE_Log |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - private $_log = ''; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Used for remote logging |
|
| 27 | - * |
|
| 28 | - * @var string |
|
| 29 | - */ |
|
| 30 | - private $_remote_logging_url = ''; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - private $_remote_log = ''; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var EE_Log |
|
| 39 | - */ |
|
| 40 | - private static $_instance; |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @return EE_Log |
|
| 45 | - */ |
|
| 46 | - public static function instance() |
|
| 47 | - { |
|
| 48 | - if (! self::$_instance instanceof EE_Log) { |
|
| 49 | - self::$_instance = new self(); |
|
| 50 | - } |
|
| 51 | - return self::$_instance; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @access private |
|
| 56 | - * @return EE_Log |
|
| 57 | - */ |
|
| 58 | - private function __construct() |
|
| 59 | - { |
|
| 60 | - |
|
| 61 | - if (! EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
| 62 | - return; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - $this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url; |
|
| 66 | - $this->_remote_log = ''; |
|
| 67 | - |
|
| 68 | - if (EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
| 69 | - add_action('shutdown', array($this, 'send_log'), 9999); |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * verify_filesystem |
|
| 76 | - * tests that the required files and folders exist and are writable |
|
| 77 | - * |
|
| 78 | - */ |
|
| 79 | - public function verify_filesystem() |
|
| 80 | - { |
|
| 81 | - $msg = esc_html__( |
|
| 82 | - 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
| 83 | - 'event_espresso' |
|
| 84 | - ); |
|
| 85 | - EE_Error::doing_it_wrong( |
|
| 86 | - __METHOD__, |
|
| 87 | - $msg, |
|
| 88 | - '4.10.1.p' |
|
| 89 | - ); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * _format_message |
|
| 95 | - * makes yer log entries look all purdy |
|
| 96 | - * |
|
| 97 | - * @param string $file |
|
| 98 | - * @param string $function |
|
| 99 | - * @param string $message |
|
| 100 | - * @param string $type |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - private function _format_message($file = '', $function = '', $message = '', $type = '') |
|
| 104 | - { |
|
| 105 | - $msg = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
| 106 | - $msg .= '[' . current_time('mysql') . '] '; |
|
| 107 | - $msg .= ! empty($file) ? basename($file) : ''; |
|
| 108 | - $msg .= ! empty($file) && ! empty($function) ? ' -> ' : ''; |
|
| 109 | - $msg .= ! empty($function) ? $function . '()' : ''; |
|
| 110 | - $msg .= PHP_EOL; |
|
| 111 | - $type = ! empty($type) ? $type : 'log message'; |
|
| 112 | - $msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : ''; |
|
| 113 | - return $msg; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * log |
|
| 119 | - * adds content to the EE_Log->_log property which gets written to file during the WP 'shutdown' hookpoint via the |
|
| 120 | - * EE_Log::write_log() callback |
|
| 121 | - * |
|
| 122 | - * @param string $file |
|
| 123 | - * @param string $function |
|
| 124 | - * @param string $message |
|
| 125 | - * @param string $type |
|
| 126 | - */ |
|
| 127 | - public function log($file = '', $function = '', $message = '', $type = '') |
|
| 128 | - { |
|
| 129 | - $this->_log .= $this->_format_message($file, $function, $message, $type); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * write_log |
|
| 135 | - * appends the results of the 'AHEE_log' filter to the espresso log file |
|
| 136 | - */ |
|
| 137 | - public function write_log() |
|
| 138 | - { |
|
| 139 | - $msg = esc_html__( |
|
| 140 | - 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
| 141 | - 'event_espresso' |
|
| 142 | - ); |
|
| 143 | - EE_Error::doing_it_wrong( |
|
| 144 | - __METHOD__, |
|
| 145 | - $msg, |
|
| 146 | - '4.10.1.p' |
|
| 147 | - ); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * send_log |
|
| 153 | - * sends the espresso log to a remote URL via a PHP cURL request |
|
| 154 | - */ |
|
| 155 | - public function send_log() |
|
| 156 | - { |
|
| 157 | - |
|
| 158 | - if (empty($this->_remote_logging_url)) { |
|
| 159 | - return; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - $data = 'domain=' . $_SERVER['HTTP_HOST']; |
|
| 163 | - $data .= '&ip=' . $_SERVER['SERVER_ADDR']; |
|
| 164 | - $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE']; |
|
| 165 | - $data .= '&time=' . time(); |
|
| 166 | - $data .= '&remote_log=' . $this->_log; |
|
| 167 | - $data .= '&request_array=' . json_encode($_REQUEST); |
|
| 168 | - $data .= '&action=save'; |
|
| 169 | - |
|
| 170 | - if (defined('EELOGGING_PASS')) { |
|
| 171 | - $data .= '&pass=' . EELOGGING_PASS; |
|
| 172 | - } |
|
| 173 | - if (defined('EELOGGING_KEY')) { |
|
| 174 | - $data .= '&key=' . EELOGGING_KEY; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - $c = curl_init($this->_remote_logging_url); |
|
| 178 | - curl_setopt($c, CURLOPT_POST, true); |
|
| 179 | - curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
|
| 180 | - curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
| 181 | - curl_exec($c); |
|
| 182 | - curl_close($c); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * write_debug |
|
| 188 | - * writes the contents of the current request's $_GET and $_POST arrays to a log file. |
|
| 189 | - * previous entries are overwritten |
|
| 190 | - */ |
|
| 191 | - public function write_debug() |
|
| 192 | - { |
|
| 193 | - $msg = esc_html__( |
|
| 194 | - 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
| 195 | - 'event_espresso' |
|
| 196 | - ); |
|
| 197 | - EE_Error::doing_it_wrong( |
|
| 198 | - __METHOD__, |
|
| 199 | - $msg, |
|
| 200 | - '4.10.1.p' |
|
| 201 | - ); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * __clone |
|
| 207 | - */ |
|
| 208 | - public function __clone() |
|
| 209 | - { |
|
| 210 | - trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR); |
|
| 211 | - } |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + private $_log = ''; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Used for remote logging |
|
| 27 | + * |
|
| 28 | + * @var string |
|
| 29 | + */ |
|
| 30 | + private $_remote_logging_url = ''; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + private $_remote_log = ''; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var EE_Log |
|
| 39 | + */ |
|
| 40 | + private static $_instance; |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @return EE_Log |
|
| 45 | + */ |
|
| 46 | + public static function instance() |
|
| 47 | + { |
|
| 48 | + if (! self::$_instance instanceof EE_Log) { |
|
| 49 | + self::$_instance = new self(); |
|
| 50 | + } |
|
| 51 | + return self::$_instance; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @access private |
|
| 56 | + * @return EE_Log |
|
| 57 | + */ |
|
| 58 | + private function __construct() |
|
| 59 | + { |
|
| 60 | + |
|
| 61 | + if (! EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + $this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url; |
|
| 66 | + $this->_remote_log = ''; |
|
| 67 | + |
|
| 68 | + if (EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
| 69 | + add_action('shutdown', array($this, 'send_log'), 9999); |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * verify_filesystem |
|
| 76 | + * tests that the required files and folders exist and are writable |
|
| 77 | + * |
|
| 78 | + */ |
|
| 79 | + public function verify_filesystem() |
|
| 80 | + { |
|
| 81 | + $msg = esc_html__( |
|
| 82 | + 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
| 83 | + 'event_espresso' |
|
| 84 | + ); |
|
| 85 | + EE_Error::doing_it_wrong( |
|
| 86 | + __METHOD__, |
|
| 87 | + $msg, |
|
| 88 | + '4.10.1.p' |
|
| 89 | + ); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * _format_message |
|
| 95 | + * makes yer log entries look all purdy |
|
| 96 | + * |
|
| 97 | + * @param string $file |
|
| 98 | + * @param string $function |
|
| 99 | + * @param string $message |
|
| 100 | + * @param string $type |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + private function _format_message($file = '', $function = '', $message = '', $type = '') |
|
| 104 | + { |
|
| 105 | + $msg = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
| 106 | + $msg .= '[' . current_time('mysql') . '] '; |
|
| 107 | + $msg .= ! empty($file) ? basename($file) : ''; |
|
| 108 | + $msg .= ! empty($file) && ! empty($function) ? ' -> ' : ''; |
|
| 109 | + $msg .= ! empty($function) ? $function . '()' : ''; |
|
| 110 | + $msg .= PHP_EOL; |
|
| 111 | + $type = ! empty($type) ? $type : 'log message'; |
|
| 112 | + $msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : ''; |
|
| 113 | + return $msg; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * log |
|
| 119 | + * adds content to the EE_Log->_log property which gets written to file during the WP 'shutdown' hookpoint via the |
|
| 120 | + * EE_Log::write_log() callback |
|
| 121 | + * |
|
| 122 | + * @param string $file |
|
| 123 | + * @param string $function |
|
| 124 | + * @param string $message |
|
| 125 | + * @param string $type |
|
| 126 | + */ |
|
| 127 | + public function log($file = '', $function = '', $message = '', $type = '') |
|
| 128 | + { |
|
| 129 | + $this->_log .= $this->_format_message($file, $function, $message, $type); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * write_log |
|
| 135 | + * appends the results of the 'AHEE_log' filter to the espresso log file |
|
| 136 | + */ |
|
| 137 | + public function write_log() |
|
| 138 | + { |
|
| 139 | + $msg = esc_html__( |
|
| 140 | + 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
| 141 | + 'event_espresso' |
|
| 142 | + ); |
|
| 143 | + EE_Error::doing_it_wrong( |
|
| 144 | + __METHOD__, |
|
| 145 | + $msg, |
|
| 146 | + '4.10.1.p' |
|
| 147 | + ); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * send_log |
|
| 153 | + * sends the espresso log to a remote URL via a PHP cURL request |
|
| 154 | + */ |
|
| 155 | + public function send_log() |
|
| 156 | + { |
|
| 157 | + |
|
| 158 | + if (empty($this->_remote_logging_url)) { |
|
| 159 | + return; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + $data = 'domain=' . $_SERVER['HTTP_HOST']; |
|
| 163 | + $data .= '&ip=' . $_SERVER['SERVER_ADDR']; |
|
| 164 | + $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE']; |
|
| 165 | + $data .= '&time=' . time(); |
|
| 166 | + $data .= '&remote_log=' . $this->_log; |
|
| 167 | + $data .= '&request_array=' . json_encode($_REQUEST); |
|
| 168 | + $data .= '&action=save'; |
|
| 169 | + |
|
| 170 | + if (defined('EELOGGING_PASS')) { |
|
| 171 | + $data .= '&pass=' . EELOGGING_PASS; |
|
| 172 | + } |
|
| 173 | + if (defined('EELOGGING_KEY')) { |
|
| 174 | + $data .= '&key=' . EELOGGING_KEY; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + $c = curl_init($this->_remote_logging_url); |
|
| 178 | + curl_setopt($c, CURLOPT_POST, true); |
|
| 179 | + curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
|
| 180 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
|
| 181 | + curl_exec($c); |
|
| 182 | + curl_close($c); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * write_debug |
|
| 188 | + * writes the contents of the current request's $_GET and $_POST arrays to a log file. |
|
| 189 | + * previous entries are overwritten |
|
| 190 | + */ |
|
| 191 | + public function write_debug() |
|
| 192 | + { |
|
| 193 | + $msg = esc_html__( |
|
| 194 | + 'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.', |
|
| 195 | + 'event_espresso' |
|
| 196 | + ); |
|
| 197 | + EE_Error::doing_it_wrong( |
|
| 198 | + __METHOD__, |
|
| 199 | + $msg, |
|
| 200 | + '4.10.1.p' |
|
| 201 | + ); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * __clone |
|
| 207 | + */ |
|
| 208 | + public function __clone() |
|
| 209 | + { |
|
| 210 | + trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR); |
|
| 211 | + } |
|
| 212 | 212 | } |