@@ -15,115 +15,115 @@ |
||
15 | 15 | class Extend_EE_Registrations_List_Table extends EE_Registrations_List_Table |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param EE_Registration $item |
|
20 | - * @return string |
|
21 | - * @throws EE_Error |
|
22 | - * @throws InvalidArgumentException |
|
23 | - * @throws ReflectionException |
|
24 | - * @throws InvalidDataTypeException |
|
25 | - * @throws InvalidInterfaceException |
|
26 | - */ |
|
27 | - function column__REG_date(EE_Registration $item) |
|
28 | - { |
|
29 | - $date_linked = parent::column__REG_date($item); |
|
30 | - $actions = array(); |
|
31 | - //Build row actions |
|
32 | - $check_in_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
33 | - 'action' => 'event_registrations', |
|
34 | - 'event_id' => $item->event_ID(), |
|
35 | - ), REG_ADMIN_URL); |
|
36 | - $actions['check_in'] = EE_Registry::instance()->CAP->current_user_can( |
|
37 | - 'ee_read_registration', |
|
38 | - 'espresso_registrations_registration_checkins', |
|
39 | - $item->ID() |
|
40 | - ) && EE_Registry::instance()->CAP->current_user_can( |
|
41 | - 'ee_read_checkins', |
|
42 | - 'espresso_registrations_registration_checkins' |
|
43 | - ) |
|
44 | - ? '<a href="' . $check_in_url . '"' |
|
45 | - . ' title="' . esc_attr__( |
|
46 | - 'The Check-In List allows you to easily toggle check-in status for this event', |
|
47 | - 'event_espresso' |
|
48 | - ) |
|
49 | - . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>' |
|
50 | - : esc_html__('View Check-ins', 'event_espresso'); |
|
18 | + /** |
|
19 | + * @param EE_Registration $item |
|
20 | + * @return string |
|
21 | + * @throws EE_Error |
|
22 | + * @throws InvalidArgumentException |
|
23 | + * @throws ReflectionException |
|
24 | + * @throws InvalidDataTypeException |
|
25 | + * @throws InvalidInterfaceException |
|
26 | + */ |
|
27 | + function column__REG_date(EE_Registration $item) |
|
28 | + { |
|
29 | + $date_linked = parent::column__REG_date($item); |
|
30 | + $actions = array(); |
|
31 | + //Build row actions |
|
32 | + $check_in_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
33 | + 'action' => 'event_registrations', |
|
34 | + 'event_id' => $item->event_ID(), |
|
35 | + ), REG_ADMIN_URL); |
|
36 | + $actions['check_in'] = EE_Registry::instance()->CAP->current_user_can( |
|
37 | + 'ee_read_registration', |
|
38 | + 'espresso_registrations_registration_checkins', |
|
39 | + $item->ID() |
|
40 | + ) && EE_Registry::instance()->CAP->current_user_can( |
|
41 | + 'ee_read_checkins', |
|
42 | + 'espresso_registrations_registration_checkins' |
|
43 | + ) |
|
44 | + ? '<a href="' . $check_in_url . '"' |
|
45 | + . ' title="' . esc_attr__( |
|
46 | + 'The Check-In List allows you to easily toggle check-in status for this event', |
|
47 | + 'event_espresso' |
|
48 | + ) |
|
49 | + . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>' |
|
50 | + : esc_html__('View Check-ins', 'event_espresso'); |
|
51 | 51 | |
52 | - return sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
|
53 | - } |
|
52 | + return sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * column_default |
|
58 | - * |
|
59 | - * @param \EE_Registration $item |
|
60 | - * @return string |
|
61 | - * @throws EE_Error |
|
62 | - * @throws InvalidArgumentException |
|
63 | - * @throws InvalidDataTypeException |
|
64 | - * @throws InvalidInterfaceException |
|
65 | - * @throws ReflectionException |
|
66 | - */ |
|
67 | - public function column_DTT_EVT_start(EE_Registration $item) |
|
68 | - { |
|
69 | - $remove_defaults = array('default_where_conditions' => 'none'); |
|
70 | - $ticket = $item->ticket(); |
|
71 | - $datetimes = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array(); |
|
72 | - $EVT_ID = $item->event_ID(); |
|
73 | - $datetimes_for_display = array(); |
|
74 | - foreach ($datetimes as $datetime) { |
|
75 | - $datetime_string = ''; |
|
76 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
77 | - 'ee_read_checkin', |
|
78 | - 'espresso_registrations_registration_checkins', |
|
79 | - $item->ID() |
|
80 | - )) { |
|
81 | - // open "a" tag and "href" |
|
82 | - $datetime_string .= '<a href="'; |
|
83 | - // checkin URL |
|
84 | - $datetime_string .= EE_Admin_Page::add_query_args_and_nonce( |
|
85 | - array( |
|
86 | - 'action' => 'event_registrations', |
|
87 | - 'event_id' => $EVT_ID, |
|
88 | - 'DTT_ID' => $datetime->ID(), |
|
89 | - ), |
|
90 | - REG_ADMIN_URL |
|
91 | - ); |
|
92 | - // close "href" |
|
93 | - $datetime_string .= '"'; |
|
94 | - // open "title" tag |
|
95 | - $datetime_string .= ' title="'; |
|
96 | - // link title text |
|
97 | - $datetime_string .= esc_attr__('View Checkins for this Event', 'event_espresso'); |
|
98 | - // close "title" tag and end of "a" tag opening |
|
99 | - $datetime_string .= '">'; |
|
100 | - // link text |
|
101 | - $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
102 | - // close "a" tag |
|
103 | - $datetime_string .= '</a>'; |
|
104 | - } else { |
|
105 | - $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
106 | - } |
|
107 | - // add a "View Registrations" link that filters list by event AND datetime |
|
108 | - $datetime_string .= $this->row_actions( |
|
109 | - array( |
|
110 | - 'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
111 | - array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()), |
|
112 | - REG_ADMIN_URL |
|
113 | - ) |
|
114 | - . '" title="' . sprintf( |
|
115 | - esc_attr__( |
|
116 | - 'Filter this list to only show registrations for this datetime %s', |
|
117 | - 'event_espresso' |
|
118 | - ), |
|
119 | - $datetime->name() |
|
120 | - ) . '">' |
|
121 | - . esc_html__('View Registrations', 'event_espresso') |
|
122 | - . '</a>', |
|
123 | - ) |
|
124 | - ); |
|
125 | - $datetimes_for_display[] = $datetime_string; |
|
126 | - } |
|
127 | - return $this->generateDisplayForDateTimes($datetimes_for_display); |
|
128 | - } |
|
56 | + /** |
|
57 | + * column_default |
|
58 | + * |
|
59 | + * @param \EE_Registration $item |
|
60 | + * @return string |
|
61 | + * @throws EE_Error |
|
62 | + * @throws InvalidArgumentException |
|
63 | + * @throws InvalidDataTypeException |
|
64 | + * @throws InvalidInterfaceException |
|
65 | + * @throws ReflectionException |
|
66 | + */ |
|
67 | + public function column_DTT_EVT_start(EE_Registration $item) |
|
68 | + { |
|
69 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
70 | + $ticket = $item->ticket(); |
|
71 | + $datetimes = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array(); |
|
72 | + $EVT_ID = $item->event_ID(); |
|
73 | + $datetimes_for_display = array(); |
|
74 | + foreach ($datetimes as $datetime) { |
|
75 | + $datetime_string = ''; |
|
76 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
77 | + 'ee_read_checkin', |
|
78 | + 'espresso_registrations_registration_checkins', |
|
79 | + $item->ID() |
|
80 | + )) { |
|
81 | + // open "a" tag and "href" |
|
82 | + $datetime_string .= '<a href="'; |
|
83 | + // checkin URL |
|
84 | + $datetime_string .= EE_Admin_Page::add_query_args_and_nonce( |
|
85 | + array( |
|
86 | + 'action' => 'event_registrations', |
|
87 | + 'event_id' => $EVT_ID, |
|
88 | + 'DTT_ID' => $datetime->ID(), |
|
89 | + ), |
|
90 | + REG_ADMIN_URL |
|
91 | + ); |
|
92 | + // close "href" |
|
93 | + $datetime_string .= '"'; |
|
94 | + // open "title" tag |
|
95 | + $datetime_string .= ' title="'; |
|
96 | + // link title text |
|
97 | + $datetime_string .= esc_attr__('View Checkins for this Event', 'event_espresso'); |
|
98 | + // close "title" tag and end of "a" tag opening |
|
99 | + $datetime_string .= '">'; |
|
100 | + // link text |
|
101 | + $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
102 | + // close "a" tag |
|
103 | + $datetime_string .= '</a>'; |
|
104 | + } else { |
|
105 | + $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
106 | + } |
|
107 | + // add a "View Registrations" link that filters list by event AND datetime |
|
108 | + $datetime_string .= $this->row_actions( |
|
109 | + array( |
|
110 | + 'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
111 | + array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()), |
|
112 | + REG_ADMIN_URL |
|
113 | + ) |
|
114 | + . '" title="' . sprintf( |
|
115 | + esc_attr__( |
|
116 | + 'Filter this list to only show registrations for this datetime %s', |
|
117 | + 'event_espresso' |
|
118 | + ), |
|
119 | + $datetime->name() |
|
120 | + ) . '">' |
|
121 | + . esc_html__('View Registrations', 'event_espresso') |
|
122 | + . '</a>', |
|
123 | + ) |
|
124 | + ); |
|
125 | + $datetimes_for_display[] = $datetime_string; |
|
126 | + } |
|
127 | + return $this->generateDisplayForDateTimes($datetimes_for_display); |
|
128 | + } |
|
129 | 129 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | 'ee_read_checkins', |
42 | 42 | 'espresso_registrations_registration_checkins' |
43 | 43 | ) |
44 | - ? '<a href="' . $check_in_url . '"' |
|
45 | - . ' title="' . esc_attr__( |
|
44 | + ? '<a href="'.$check_in_url.'"' |
|
45 | + . ' title="'.esc_attr__( |
|
46 | 46 | 'The Check-In List allows you to easily toggle check-in status for this event', |
47 | 47 | 'event_espresso' |
48 | 48 | ) |
49 | - . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>' |
|
49 | + . '">'.esc_html__('View Check-ins', 'event_espresso').'</a>' |
|
50 | 50 | : esc_html__('View Check-ins', 'event_espresso'); |
51 | 51 | |
52 | 52 | return sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
@@ -107,17 +107,17 @@ discard block |
||
107 | 107 | // add a "View Registrations" link that filters list by event AND datetime |
108 | 108 | $datetime_string .= $this->row_actions( |
109 | 109 | array( |
110 | - 'event_datetime_filter' => '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
110 | + 'event_datetime_filter' => '<a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
111 | 111 | array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()), |
112 | 112 | REG_ADMIN_URL |
113 | 113 | ) |
114 | - . '" title="' . sprintf( |
|
114 | + . '" title="'.sprintf( |
|
115 | 115 | esc_attr__( |
116 | 116 | 'Filter this list to only show registrations for this datetime %s', |
117 | 117 | 'event_espresso' |
118 | 118 | ), |
119 | 119 | $datetime->name() |
120 | - ) . '">' |
|
120 | + ).'">' |
|
121 | 121 | . esc_html__('View Registrations', 'event_espresso') |
122 | 122 | . '</a>', |
123 | 123 | ) |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
4 | 4 | |
5 | 5 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
6 | - exit('No direct script access allowed'); |
|
6 | + exit('No direct script access allowed'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | |
@@ -28,1006 +28,1006 @@ discard block |
||
28 | 28 | { |
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @var array |
|
33 | - */ |
|
34 | - private $_status; |
|
31 | + /** |
|
32 | + * @var array |
|
33 | + */ |
|
34 | + private $_status; |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * An array of transaction details for the related transaction to the registration being processed. |
|
39 | - * This is set via the _set_related_details method. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - protected $_transaction_details = array(); |
|
37 | + /** |
|
38 | + * An array of transaction details for the related transaction to the registration being processed. |
|
39 | + * This is set via the _set_related_details method. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + protected $_transaction_details = array(); |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * An array of event details for the related event to the registration being processed. |
|
48 | - * This is set via the _set_related_details method. |
|
49 | - * |
|
50 | - * @var array |
|
51 | - */ |
|
52 | - protected $_event_details = array(); |
|
46 | + /** |
|
47 | + * An array of event details for the related event to the registration being processed. |
|
48 | + * This is set via the _set_related_details method. |
|
49 | + * |
|
50 | + * @var array |
|
51 | + */ |
|
52 | + protected $_event_details = array(); |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * @param \Registrations_Admin_Page $admin_page |
|
57 | - */ |
|
58 | - public function __construct(Registrations_Admin_Page $admin_page) |
|
59 | - { |
|
60 | - if (! empty($_GET['event_id'])) { |
|
61 | - $extra_query_args = array(); |
|
62 | - foreach ($admin_page->get_views() as $key => $view_details) { |
|
63 | - $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
64 | - } |
|
65 | - $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
66 | - } |
|
67 | - parent::__construct($admin_page); |
|
68 | - $this->_status = $this->_admin_page->get_registration_status_array(); |
|
69 | - } |
|
55 | + /** |
|
56 | + * @param \Registrations_Admin_Page $admin_page |
|
57 | + */ |
|
58 | + public function __construct(Registrations_Admin_Page $admin_page) |
|
59 | + { |
|
60 | + if (! empty($_GET['event_id'])) { |
|
61 | + $extra_query_args = array(); |
|
62 | + foreach ($admin_page->get_views() as $key => $view_details) { |
|
63 | + $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
64 | + } |
|
65 | + $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
66 | + } |
|
67 | + parent::__construct($admin_page); |
|
68 | + $this->_status = $this->_admin_page->get_registration_status_array(); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * _setup_data |
|
74 | - * |
|
75 | - * @access protected |
|
76 | - * @return void |
|
77 | - */ |
|
78 | - protected function _setup_data() |
|
79 | - { |
|
80 | - $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
81 | - $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false); |
|
82 | - } |
|
72 | + /** |
|
73 | + * _setup_data |
|
74 | + * |
|
75 | + * @access protected |
|
76 | + * @return void |
|
77 | + */ |
|
78 | + protected function _setup_data() |
|
79 | + { |
|
80 | + $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
81 | + $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false); |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * _set_properties |
|
87 | - * |
|
88 | - * @access protected |
|
89 | - * @return void |
|
90 | - */ |
|
91 | - protected function _set_properties() |
|
92 | - { |
|
93 | - $this->_wp_list_args = array( |
|
94 | - 'singular' => __('registration', 'event_espresso'), |
|
95 | - 'plural' => __('registrations', 'event_espresso'), |
|
96 | - 'ajax' => true, |
|
97 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
98 | - ); |
|
99 | - $ID_column_name = __('ID', 'event_espresso'); |
|
100 | - $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
101 | - $ID_column_name .= __('Registrant Name', 'event_espresso'); |
|
102 | - $ID_column_name .= '</span> '; |
|
103 | - if (isset($_GET['event_id'])) { |
|
104 | - $this->_columns = array( |
|
105 | - 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
106 | - '_REG_ID' => $ID_column_name, |
|
107 | - 'ATT_fname' => __('Name', 'event_espresso'), |
|
108 | - 'ATT_email' => __('Email', 'event_espresso'), |
|
109 | - '_REG_date' => __('Reg Date', 'event_espresso'), |
|
110 | - 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
111 | - '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
112 | - 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
113 | - 'TXN_paid' => __('Paid', 'event_espresso'), |
|
114 | - 'actions' => __('Actions', 'event_espresso'), |
|
115 | - ); |
|
116 | - $this->_bottom_buttons = array( |
|
117 | - 'report' => array( |
|
118 | - 'route' => 'registrations_report', |
|
119 | - 'extra_request' => array( |
|
120 | - 'EVT_ID' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
121 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
122 | - ), |
|
123 | - ), |
|
124 | - ); |
|
125 | - } else { |
|
126 | - $this->_columns = array( |
|
127 | - 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
128 | - '_REG_ID' => $ID_column_name, |
|
129 | - 'ATT_fname' => __('Name', 'event_espresso'), |
|
130 | - '_REG_date' => __('TXN Date', 'event_espresso'), |
|
131 | - 'event_name' => __('Event', 'event_espresso'), |
|
132 | - 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
133 | - '_REG_final_price' => __('Price', 'event_espresso'), |
|
134 | - '_REG_paid' => __('Paid', 'event_espresso'), |
|
135 | - 'actions' => __('Actions', 'event_espresso'), |
|
136 | - ); |
|
137 | - $this->_bottom_buttons = array( |
|
138 | - 'report_all' => array( |
|
139 | - 'route' => 'registrations_report', |
|
140 | - 'extra_request' => array( |
|
141 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
142 | - ), |
|
143 | - ), |
|
144 | - ); |
|
145 | - } |
|
146 | - $this->_bottom_buttons['report_filtered'] = array( |
|
147 | - 'route' => 'registrations_report', |
|
148 | - 'extra_request' => array( |
|
149 | - 'use_filters' => true, |
|
150 | - 'filters' => array_diff_key($this->_req_data, array_flip(array( |
|
151 | - 'page', |
|
152 | - 'action', |
|
153 | - 'default_nonce', |
|
154 | - ))), |
|
155 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
156 | - ), |
|
157 | - ); |
|
158 | - $this->_primary_column = '_REG_ID'; |
|
159 | - $this->_sortable_columns = array( |
|
160 | - '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
161 | - /** |
|
162 | - * Allows users to change the default sort if they wish. |
|
163 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last |
|
164 | - * name. |
|
165 | - */ |
|
166 | - 'ATT_fname' => array( |
|
167 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
168 | - true, |
|
169 | - $this, |
|
170 | - ) |
|
171 | - ? array('ATT_lname' => false) |
|
172 | - : array('ATT_fname' => false), |
|
173 | - 'event_name' => array('event_name' => false), |
|
174 | - 'DTT_EVT_start' => array('DTT_EVT_start' => false), |
|
175 | - '_REG_ID' => array('_REG_ID' => false), |
|
176 | - ); |
|
177 | - $this->_hidden_columns = array(); |
|
178 | - } |
|
85 | + /** |
|
86 | + * _set_properties |
|
87 | + * |
|
88 | + * @access protected |
|
89 | + * @return void |
|
90 | + */ |
|
91 | + protected function _set_properties() |
|
92 | + { |
|
93 | + $this->_wp_list_args = array( |
|
94 | + 'singular' => __('registration', 'event_espresso'), |
|
95 | + 'plural' => __('registrations', 'event_espresso'), |
|
96 | + 'ajax' => true, |
|
97 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
98 | + ); |
|
99 | + $ID_column_name = __('ID', 'event_espresso'); |
|
100 | + $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
101 | + $ID_column_name .= __('Registrant Name', 'event_espresso'); |
|
102 | + $ID_column_name .= '</span> '; |
|
103 | + if (isset($_GET['event_id'])) { |
|
104 | + $this->_columns = array( |
|
105 | + 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
106 | + '_REG_ID' => $ID_column_name, |
|
107 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
108 | + 'ATT_email' => __('Email', 'event_espresso'), |
|
109 | + '_REG_date' => __('Reg Date', 'event_espresso'), |
|
110 | + 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
111 | + '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
112 | + 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
113 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
114 | + 'actions' => __('Actions', 'event_espresso'), |
|
115 | + ); |
|
116 | + $this->_bottom_buttons = array( |
|
117 | + 'report' => array( |
|
118 | + 'route' => 'registrations_report', |
|
119 | + 'extra_request' => array( |
|
120 | + 'EVT_ID' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
121 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
122 | + ), |
|
123 | + ), |
|
124 | + ); |
|
125 | + } else { |
|
126 | + $this->_columns = array( |
|
127 | + 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
128 | + '_REG_ID' => $ID_column_name, |
|
129 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
130 | + '_REG_date' => __('TXN Date', 'event_espresso'), |
|
131 | + 'event_name' => __('Event', 'event_espresso'), |
|
132 | + 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
133 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
134 | + '_REG_paid' => __('Paid', 'event_espresso'), |
|
135 | + 'actions' => __('Actions', 'event_espresso'), |
|
136 | + ); |
|
137 | + $this->_bottom_buttons = array( |
|
138 | + 'report_all' => array( |
|
139 | + 'route' => 'registrations_report', |
|
140 | + 'extra_request' => array( |
|
141 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
142 | + ), |
|
143 | + ), |
|
144 | + ); |
|
145 | + } |
|
146 | + $this->_bottom_buttons['report_filtered'] = array( |
|
147 | + 'route' => 'registrations_report', |
|
148 | + 'extra_request' => array( |
|
149 | + 'use_filters' => true, |
|
150 | + 'filters' => array_diff_key($this->_req_data, array_flip(array( |
|
151 | + 'page', |
|
152 | + 'action', |
|
153 | + 'default_nonce', |
|
154 | + ))), |
|
155 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
156 | + ), |
|
157 | + ); |
|
158 | + $this->_primary_column = '_REG_ID'; |
|
159 | + $this->_sortable_columns = array( |
|
160 | + '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
161 | + /** |
|
162 | + * Allows users to change the default sort if they wish. |
|
163 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last |
|
164 | + * name. |
|
165 | + */ |
|
166 | + 'ATT_fname' => array( |
|
167 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
168 | + true, |
|
169 | + $this, |
|
170 | + ) |
|
171 | + ? array('ATT_lname' => false) |
|
172 | + : array('ATT_fname' => false), |
|
173 | + 'event_name' => array('event_name' => false), |
|
174 | + 'DTT_EVT_start' => array('DTT_EVT_start' => false), |
|
175 | + '_REG_ID' => array('_REG_ID' => false), |
|
176 | + ); |
|
177 | + $this->_hidden_columns = array(); |
|
178 | + } |
|
179 | 179 | |
180 | 180 | |
181 | - /** |
|
182 | - * This simply sets up the row class for the table rows. |
|
183 | - * Allows for easier overriding of child methods for setting up sorting. |
|
184 | - * |
|
185 | - * @param EE_Registration $item the current item |
|
186 | - * @return string |
|
187 | - */ |
|
188 | - protected function _get_row_class($item) |
|
189 | - { |
|
190 | - $class = parent::_get_row_class($item); |
|
191 | - //add status class |
|
192 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
193 | - if ($this->_has_checkbox_column) { |
|
194 | - $class .= ' has-checkbox-column'; |
|
195 | - } |
|
196 | - return $class; |
|
197 | - } |
|
181 | + /** |
|
182 | + * This simply sets up the row class for the table rows. |
|
183 | + * Allows for easier overriding of child methods for setting up sorting. |
|
184 | + * |
|
185 | + * @param EE_Registration $item the current item |
|
186 | + * @return string |
|
187 | + */ |
|
188 | + protected function _get_row_class($item) |
|
189 | + { |
|
190 | + $class = parent::_get_row_class($item); |
|
191 | + //add status class |
|
192 | + $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
193 | + if ($this->_has_checkbox_column) { |
|
194 | + $class .= ' has-checkbox-column'; |
|
195 | + } |
|
196 | + return $class; |
|
197 | + } |
|
198 | 198 | |
199 | 199 | |
200 | - /** |
|
201 | - * Set the $_transaction_details property if not set yet. |
|
202 | - * |
|
203 | - * @param EE_Registration $registration |
|
204 | - * @throws EE_Error |
|
205 | - * @throws InvalidArgumentException |
|
206 | - * @throws ReflectionException |
|
207 | - * @throws InvalidDataTypeException |
|
208 | - * @throws InvalidInterfaceException |
|
209 | - */ |
|
210 | - protected function _set_related_details(EE_Registration $registration) |
|
211 | - { |
|
212 | - $transaction = $registration->get_first_related('Transaction'); |
|
213 | - $status = $transaction instanceof EE_Transaction ? $transaction->status_ID() |
|
214 | - : EEM_Transaction::failed_status_code; |
|
215 | - $this->_transaction_details = array( |
|
216 | - 'transaction' => $transaction, |
|
217 | - 'status' => $status, |
|
218 | - 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
|
219 | - 'title_attr' => sprintf( |
|
220 | - __('View Transaction Details (%s)', 'event_espresso'), |
|
221 | - EEH_Template::pretty_status($status, false, 'sentence') |
|
222 | - ), |
|
223 | - ); |
|
224 | - try { |
|
225 | - $event = $registration->event(); |
|
226 | - } catch (EntityNotFoundException $e) { |
|
227 | - $event = null; |
|
228 | - } |
|
229 | - $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive; |
|
230 | - $this->_event_details = array( |
|
231 | - 'event' => $event, |
|
232 | - 'status' => $status, |
|
233 | - 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
|
234 | - 'title_attr' => sprintf( |
|
235 | - __('Edit Event (%s)', 'event_espresso'), |
|
236 | - EEH_Template::pretty_status($status, false, 'sentence') |
|
237 | - ), |
|
238 | - ); |
|
239 | - } |
|
200 | + /** |
|
201 | + * Set the $_transaction_details property if not set yet. |
|
202 | + * |
|
203 | + * @param EE_Registration $registration |
|
204 | + * @throws EE_Error |
|
205 | + * @throws InvalidArgumentException |
|
206 | + * @throws ReflectionException |
|
207 | + * @throws InvalidDataTypeException |
|
208 | + * @throws InvalidInterfaceException |
|
209 | + */ |
|
210 | + protected function _set_related_details(EE_Registration $registration) |
|
211 | + { |
|
212 | + $transaction = $registration->get_first_related('Transaction'); |
|
213 | + $status = $transaction instanceof EE_Transaction ? $transaction->status_ID() |
|
214 | + : EEM_Transaction::failed_status_code; |
|
215 | + $this->_transaction_details = array( |
|
216 | + 'transaction' => $transaction, |
|
217 | + 'status' => $status, |
|
218 | + 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
|
219 | + 'title_attr' => sprintf( |
|
220 | + __('View Transaction Details (%s)', 'event_espresso'), |
|
221 | + EEH_Template::pretty_status($status, false, 'sentence') |
|
222 | + ), |
|
223 | + ); |
|
224 | + try { |
|
225 | + $event = $registration->event(); |
|
226 | + } catch (EntityNotFoundException $e) { |
|
227 | + $event = null; |
|
228 | + } |
|
229 | + $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive; |
|
230 | + $this->_event_details = array( |
|
231 | + 'event' => $event, |
|
232 | + 'status' => $status, |
|
233 | + 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
|
234 | + 'title_attr' => sprintf( |
|
235 | + __('Edit Event (%s)', 'event_espresso'), |
|
236 | + EEH_Template::pretty_status($status, false, 'sentence') |
|
237 | + ), |
|
238 | + ); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | |
242 | - /** |
|
243 | - * _get_table_filters |
|
244 | - * |
|
245 | - * @access protected |
|
246 | - * @return array |
|
247 | - */ |
|
248 | - protected function _get_table_filters() |
|
249 | - { |
|
250 | - $filters = array(); |
|
251 | - //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as |
|
252 | - // methods. |
|
253 | - $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
254 | - $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
255 | - $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
256 | - $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
257 | - $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
258 | - $status = array(); |
|
259 | - $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
260 | - foreach ($this->_status as $key => $value) { |
|
261 | - $status[] = array('id' => $key, 'text' => $value); |
|
262 | - } |
|
263 | - if ($this->_view !== 'incomplete') { |
|
264 | - $filters[] = EEH_Form_Fields::select_input( |
|
265 | - '_reg_status', |
|
266 | - $status, |
|
267 | - isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
268 | - : '' |
|
269 | - ); |
|
270 | - } |
|
271 | - if (isset($this->_req_data['event_id'])) { |
|
272 | - $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
273 | - } |
|
274 | - return $filters; |
|
275 | - } |
|
242 | + /** |
|
243 | + * _get_table_filters |
|
244 | + * |
|
245 | + * @access protected |
|
246 | + * @return array |
|
247 | + */ |
|
248 | + protected function _get_table_filters() |
|
249 | + { |
|
250 | + $filters = array(); |
|
251 | + //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as |
|
252 | + // methods. |
|
253 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
254 | + $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
255 | + $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
256 | + $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
257 | + $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
258 | + $status = array(); |
|
259 | + $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
260 | + foreach ($this->_status as $key => $value) { |
|
261 | + $status[] = array('id' => $key, 'text' => $value); |
|
262 | + } |
|
263 | + if ($this->_view !== 'incomplete') { |
|
264 | + $filters[] = EEH_Form_Fields::select_input( |
|
265 | + '_reg_status', |
|
266 | + $status, |
|
267 | + isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
268 | + : '' |
|
269 | + ); |
|
270 | + } |
|
271 | + if (isset($this->_req_data['event_id'])) { |
|
272 | + $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
273 | + } |
|
274 | + return $filters; |
|
275 | + } |
|
276 | 276 | |
277 | 277 | |
278 | - /** |
|
279 | - * _add_view_counts |
|
280 | - * |
|
281 | - * @access protected |
|
282 | - * @return void |
|
283 | - * @throws EE_Error |
|
284 | - * @throws InvalidArgumentException |
|
285 | - * @throws InvalidDataTypeException |
|
286 | - * @throws InvalidInterfaceException |
|
287 | - */ |
|
288 | - protected function _add_view_counts() |
|
289 | - { |
|
290 | - $this->_views['all']['count'] = $this->_total_registrations(); |
|
291 | - $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
292 | - $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
293 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
294 | - 'ee_delete_registrations', |
|
295 | - 'espresso_registrations_trash_registrations' |
|
296 | - )) { |
|
297 | - $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
298 | - $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
299 | - } |
|
300 | - } |
|
278 | + /** |
|
279 | + * _add_view_counts |
|
280 | + * |
|
281 | + * @access protected |
|
282 | + * @return void |
|
283 | + * @throws EE_Error |
|
284 | + * @throws InvalidArgumentException |
|
285 | + * @throws InvalidDataTypeException |
|
286 | + * @throws InvalidInterfaceException |
|
287 | + */ |
|
288 | + protected function _add_view_counts() |
|
289 | + { |
|
290 | + $this->_views['all']['count'] = $this->_total_registrations(); |
|
291 | + $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
292 | + $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
293 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
294 | + 'ee_delete_registrations', |
|
295 | + 'espresso_registrations_trash_registrations' |
|
296 | + )) { |
|
297 | + $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
298 | + $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
299 | + } |
|
300 | + } |
|
301 | 301 | |
302 | 302 | |
303 | - /** |
|
304 | - * _total_registrations |
|
305 | - * |
|
306 | - * @access protected |
|
307 | - * @param string $view |
|
308 | - * @return int |
|
309 | - * @throws EE_Error |
|
310 | - * @throws InvalidArgumentException |
|
311 | - * @throws InvalidDataTypeException |
|
312 | - * @throws InvalidInterfaceException |
|
313 | - */ |
|
314 | - protected function _total_registrations($view = '') |
|
315 | - { |
|
316 | - $_where = array(); |
|
317 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
318 | - if ($EVT_ID) { |
|
319 | - $_where['EVT_ID'] = $EVT_ID; |
|
320 | - } |
|
321 | - switch ($view) { |
|
322 | - case 'trash': |
|
323 | - return EEM_Registration::instance()->count_deleted(array($_where)); |
|
324 | - break; |
|
325 | - case 'incomplete': |
|
326 | - $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
327 | - break; |
|
328 | - default: |
|
329 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
330 | - } |
|
331 | - return EEM_Registration::instance()->count(array($_where)); |
|
332 | - } |
|
303 | + /** |
|
304 | + * _total_registrations |
|
305 | + * |
|
306 | + * @access protected |
|
307 | + * @param string $view |
|
308 | + * @return int |
|
309 | + * @throws EE_Error |
|
310 | + * @throws InvalidArgumentException |
|
311 | + * @throws InvalidDataTypeException |
|
312 | + * @throws InvalidInterfaceException |
|
313 | + */ |
|
314 | + protected function _total_registrations($view = '') |
|
315 | + { |
|
316 | + $_where = array(); |
|
317 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
318 | + if ($EVT_ID) { |
|
319 | + $_where['EVT_ID'] = $EVT_ID; |
|
320 | + } |
|
321 | + switch ($view) { |
|
322 | + case 'trash': |
|
323 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
324 | + break; |
|
325 | + case 'incomplete': |
|
326 | + $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
327 | + break; |
|
328 | + default: |
|
329 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
330 | + } |
|
331 | + return EEM_Registration::instance()->count(array($_where)); |
|
332 | + } |
|
333 | 333 | |
334 | 334 | |
335 | - /** |
|
336 | - * _total_registrations_this_month |
|
337 | - * |
|
338 | - * @access protected |
|
339 | - * @return int |
|
340 | - * @throws EE_Error |
|
341 | - * @throws InvalidArgumentException |
|
342 | - * @throws InvalidDataTypeException |
|
343 | - * @throws InvalidInterfaceException |
|
344 | - */ |
|
345 | - protected function _total_registrations_this_month() |
|
346 | - { |
|
347 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
348 | - $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
349 | - $this_year_r = date('Y', current_time('timestamp')); |
|
350 | - $time_start = ' 00:00:00'; |
|
351 | - $time_end = ' 23:59:59'; |
|
352 | - $this_month_r = date('m', current_time('timestamp')); |
|
353 | - $days_this_month = date('t', current_time('timestamp')); |
|
354 | - //setup date query. |
|
355 | - $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
356 | - 'REG_date', |
|
357 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
358 | - 'Y-m-d H:i:s' |
|
359 | - ); |
|
360 | - $end_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
361 | - 'REG_date', |
|
362 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
363 | - 'Y-m-d H:i:s' |
|
364 | - ); |
|
365 | - $_where['REG_date'] = array( |
|
366 | - 'BETWEEN', |
|
367 | - array( |
|
368 | - $beginning_string, |
|
369 | - $end_string, |
|
370 | - ), |
|
371 | - ); |
|
372 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
373 | - return EEM_Registration::instance()->count(array($_where)); |
|
374 | - } |
|
335 | + /** |
|
336 | + * _total_registrations_this_month |
|
337 | + * |
|
338 | + * @access protected |
|
339 | + * @return int |
|
340 | + * @throws EE_Error |
|
341 | + * @throws InvalidArgumentException |
|
342 | + * @throws InvalidDataTypeException |
|
343 | + * @throws InvalidInterfaceException |
|
344 | + */ |
|
345 | + protected function _total_registrations_this_month() |
|
346 | + { |
|
347 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
348 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
349 | + $this_year_r = date('Y', current_time('timestamp')); |
|
350 | + $time_start = ' 00:00:00'; |
|
351 | + $time_end = ' 23:59:59'; |
|
352 | + $this_month_r = date('m', current_time('timestamp')); |
|
353 | + $days_this_month = date('t', current_time('timestamp')); |
|
354 | + //setup date query. |
|
355 | + $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
356 | + 'REG_date', |
|
357 | + $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
358 | + 'Y-m-d H:i:s' |
|
359 | + ); |
|
360 | + $end_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
361 | + 'REG_date', |
|
362 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
363 | + 'Y-m-d H:i:s' |
|
364 | + ); |
|
365 | + $_where['REG_date'] = array( |
|
366 | + 'BETWEEN', |
|
367 | + array( |
|
368 | + $beginning_string, |
|
369 | + $end_string, |
|
370 | + ), |
|
371 | + ); |
|
372 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
373 | + return EEM_Registration::instance()->count(array($_where)); |
|
374 | + } |
|
375 | 375 | |
376 | 376 | |
377 | - /** |
|
378 | - * _total_registrations_today |
|
379 | - * |
|
380 | - * @access protected |
|
381 | - * @return int |
|
382 | - * @throws EE_Error |
|
383 | - * @throws InvalidArgumentException |
|
384 | - * @throws InvalidDataTypeException |
|
385 | - * @throws InvalidInterfaceException |
|
386 | - */ |
|
387 | - protected function _total_registrations_today() |
|
388 | - { |
|
389 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
390 | - $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
391 | - $current_date = date('Y-m-d', current_time('timestamp')); |
|
392 | - $time_start = ' 00:00:00'; |
|
393 | - $time_end = ' 23:59:59'; |
|
394 | - $_where['REG_date'] = array( |
|
395 | - 'BETWEEN', |
|
396 | - array( |
|
397 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
398 | - 'REG_date', |
|
399 | - $current_date . $time_start, |
|
400 | - 'Y-m-d H:i:s' |
|
401 | - ), |
|
402 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
403 | - 'REG_date', |
|
404 | - $current_date . $time_end, |
|
405 | - 'Y-m-d H:i:s' |
|
406 | - ), |
|
407 | - ), |
|
408 | - ); |
|
409 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
410 | - return EEM_Registration::instance()->count(array($_where)); |
|
411 | - } |
|
377 | + /** |
|
378 | + * _total_registrations_today |
|
379 | + * |
|
380 | + * @access protected |
|
381 | + * @return int |
|
382 | + * @throws EE_Error |
|
383 | + * @throws InvalidArgumentException |
|
384 | + * @throws InvalidDataTypeException |
|
385 | + * @throws InvalidInterfaceException |
|
386 | + */ |
|
387 | + protected function _total_registrations_today() |
|
388 | + { |
|
389 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
390 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
391 | + $current_date = date('Y-m-d', current_time('timestamp')); |
|
392 | + $time_start = ' 00:00:00'; |
|
393 | + $time_end = ' 23:59:59'; |
|
394 | + $_where['REG_date'] = array( |
|
395 | + 'BETWEEN', |
|
396 | + array( |
|
397 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
398 | + 'REG_date', |
|
399 | + $current_date . $time_start, |
|
400 | + 'Y-m-d H:i:s' |
|
401 | + ), |
|
402 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
403 | + 'REG_date', |
|
404 | + $current_date . $time_end, |
|
405 | + 'Y-m-d H:i:s' |
|
406 | + ), |
|
407 | + ), |
|
408 | + ); |
|
409 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
410 | + return EEM_Registration::instance()->count(array($_where)); |
|
411 | + } |
|
412 | 412 | |
413 | 413 | |
414 | - /** |
|
415 | - * column_cb |
|
416 | - * |
|
417 | - * @access public |
|
418 | - * @param \EE_Registration $item |
|
419 | - * @return string |
|
420 | - * @throws EE_Error |
|
421 | - * @throws InvalidArgumentException |
|
422 | - * @throws InvalidDataTypeException |
|
423 | - * @throws InvalidInterfaceException |
|
424 | - * @throws ReflectionException |
|
425 | - */ |
|
426 | - public function column_cb($item) |
|
427 | - { |
|
428 | - /** checkbox/lock **/ |
|
429 | - $transaction = $item->get_first_related('Transaction'); |
|
430 | - $payment_count = $transaction instanceof EE_Transaction |
|
431 | - ? $transaction->count_related('Payment') |
|
432 | - : 0; |
|
433 | - return $payment_count > 0 |
|
434 | - || ! EE_Registry::instance()->CAP->current_user_can( |
|
435 | - 'ee_edit_registration', |
|
436 | - 'registration_list_table_checkbox_input', |
|
437 | - $item->ID() |
|
438 | - ) |
|
439 | - ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()) |
|
440 | - . '<span class="ee-lock-icon"></span>' |
|
441 | - : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()); |
|
442 | - } |
|
414 | + /** |
|
415 | + * column_cb |
|
416 | + * |
|
417 | + * @access public |
|
418 | + * @param \EE_Registration $item |
|
419 | + * @return string |
|
420 | + * @throws EE_Error |
|
421 | + * @throws InvalidArgumentException |
|
422 | + * @throws InvalidDataTypeException |
|
423 | + * @throws InvalidInterfaceException |
|
424 | + * @throws ReflectionException |
|
425 | + */ |
|
426 | + public function column_cb($item) |
|
427 | + { |
|
428 | + /** checkbox/lock **/ |
|
429 | + $transaction = $item->get_first_related('Transaction'); |
|
430 | + $payment_count = $transaction instanceof EE_Transaction |
|
431 | + ? $transaction->count_related('Payment') |
|
432 | + : 0; |
|
433 | + return $payment_count > 0 |
|
434 | + || ! EE_Registry::instance()->CAP->current_user_can( |
|
435 | + 'ee_edit_registration', |
|
436 | + 'registration_list_table_checkbox_input', |
|
437 | + $item->ID() |
|
438 | + ) |
|
439 | + ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()) |
|
440 | + . '<span class="ee-lock-icon"></span>' |
|
441 | + : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()); |
|
442 | + } |
|
443 | 443 | |
444 | 444 | |
445 | - /** |
|
446 | - * column__REG_ID |
|
447 | - * |
|
448 | - * @access public |
|
449 | - * @param \EE_Registration $item |
|
450 | - * @return string |
|
451 | - * @throws EE_Error |
|
452 | - * @throws InvalidArgumentException |
|
453 | - * @throws InvalidDataTypeException |
|
454 | - * @throws InvalidInterfaceException |
|
455 | - * @throws ReflectionException |
|
456 | - */ |
|
457 | - public function column__REG_ID(EE_Registration $item) |
|
458 | - { |
|
459 | - $attendee = $item->attendee(); |
|
460 | - $content = $item->ID(); |
|
461 | - $content .= '<div class="show-on-mobile-view-only">'; |
|
462 | - $content .= '<br>'; |
|
463 | - $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
464 | - $content .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
465 | - $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
466 | - $content .= '</div>'; |
|
467 | - return $content; |
|
468 | - } |
|
445 | + /** |
|
446 | + * column__REG_ID |
|
447 | + * |
|
448 | + * @access public |
|
449 | + * @param \EE_Registration $item |
|
450 | + * @return string |
|
451 | + * @throws EE_Error |
|
452 | + * @throws InvalidArgumentException |
|
453 | + * @throws InvalidDataTypeException |
|
454 | + * @throws InvalidInterfaceException |
|
455 | + * @throws ReflectionException |
|
456 | + */ |
|
457 | + public function column__REG_ID(EE_Registration $item) |
|
458 | + { |
|
459 | + $attendee = $item->attendee(); |
|
460 | + $content = $item->ID(); |
|
461 | + $content .= '<div class="show-on-mobile-view-only">'; |
|
462 | + $content .= '<br>'; |
|
463 | + $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
464 | + $content .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
465 | + $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
466 | + $content .= '</div>'; |
|
467 | + return $content; |
|
468 | + } |
|
469 | 469 | |
470 | 470 | |
471 | - /** |
|
472 | - * column__REG_date |
|
473 | - * |
|
474 | - * @access public |
|
475 | - * @param \EE_Registration $item |
|
476 | - * @return string |
|
477 | - * @throws EE_Error |
|
478 | - * @throws InvalidArgumentException |
|
479 | - * @throws InvalidDataTypeException |
|
480 | - * @throws InvalidInterfaceException |
|
481 | - * @throws ReflectionException |
|
482 | - */ |
|
483 | - public function column__REG_date(EE_Registration $item) |
|
484 | - { |
|
485 | - $this->_set_related_details($item); |
|
486 | - //Build row actions |
|
487 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
488 | - 'action' => 'view_transaction', |
|
489 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
490 | - ), TXN_ADMIN_URL); |
|
491 | - $view_link = EE_Registry::instance()->CAP->current_user_can( |
|
492 | - 'ee_read_transaction', |
|
493 | - 'espresso_transactions_view_transaction' |
|
494 | - ) |
|
495 | - ? '<a class="ee-status-color-' |
|
496 | - . $this->_transaction_details['status'] |
|
497 | - . '" href="' |
|
498 | - . $view_lnk_url |
|
499 | - . '" title="' |
|
500 | - . esc_attr($this->_transaction_details['title_attr']) |
|
501 | - . '">' |
|
502 | - . $item->get_i18n_datetime('REG_date') |
|
503 | - . '</a>' : $item->get_i18n_datetime('REG_date'); |
|
504 | - $view_link .= '<br><span class="ee-status-text-small">' |
|
505 | - . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence') |
|
506 | - . '</span>'; |
|
507 | - return $view_link; |
|
508 | - } |
|
471 | + /** |
|
472 | + * column__REG_date |
|
473 | + * |
|
474 | + * @access public |
|
475 | + * @param \EE_Registration $item |
|
476 | + * @return string |
|
477 | + * @throws EE_Error |
|
478 | + * @throws InvalidArgumentException |
|
479 | + * @throws InvalidDataTypeException |
|
480 | + * @throws InvalidInterfaceException |
|
481 | + * @throws ReflectionException |
|
482 | + */ |
|
483 | + public function column__REG_date(EE_Registration $item) |
|
484 | + { |
|
485 | + $this->_set_related_details($item); |
|
486 | + //Build row actions |
|
487 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
488 | + 'action' => 'view_transaction', |
|
489 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
490 | + ), TXN_ADMIN_URL); |
|
491 | + $view_link = EE_Registry::instance()->CAP->current_user_can( |
|
492 | + 'ee_read_transaction', |
|
493 | + 'espresso_transactions_view_transaction' |
|
494 | + ) |
|
495 | + ? '<a class="ee-status-color-' |
|
496 | + . $this->_transaction_details['status'] |
|
497 | + . '" href="' |
|
498 | + . $view_lnk_url |
|
499 | + . '" title="' |
|
500 | + . esc_attr($this->_transaction_details['title_attr']) |
|
501 | + . '">' |
|
502 | + . $item->get_i18n_datetime('REG_date') |
|
503 | + . '</a>' : $item->get_i18n_datetime('REG_date'); |
|
504 | + $view_link .= '<br><span class="ee-status-text-small">' |
|
505 | + . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence') |
|
506 | + . '</span>'; |
|
507 | + return $view_link; |
|
508 | + } |
|
509 | 509 | |
510 | 510 | |
511 | - /** |
|
512 | - * column_event_name |
|
513 | - * |
|
514 | - * @access public |
|
515 | - * @param \EE_Registration $item |
|
516 | - * @return string |
|
517 | - * @throws EE_Error |
|
518 | - * @throws InvalidArgumentException |
|
519 | - * @throws InvalidDataTypeException |
|
520 | - * @throws InvalidInterfaceException |
|
521 | - * @throws ReflectionException |
|
522 | - */ |
|
523 | - public function column_event_name(EE_Registration $item) |
|
524 | - { |
|
525 | - $this->_set_related_details($item); |
|
526 | - // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
527 | - $EVT_ID = $item->event_ID(); |
|
528 | - $event_name = $item->event_name(); |
|
529 | - $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
|
530 | - $event_name = wp_trim_words($event_name, 30, '...'); |
|
531 | - if ($EVT_ID) { |
|
532 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
|
533 | - array('action' => 'edit', 'post' => $EVT_ID), |
|
534 | - EVENTS_ADMIN_URL |
|
535 | - ); |
|
536 | - $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID) |
|
537 | - ? '<a class="ee-status-color-' |
|
538 | - . $this->_event_details['status'] |
|
539 | - . '" href="' |
|
540 | - . $edit_event_url |
|
541 | - . '" title="' |
|
542 | - . esc_attr($this->_event_details['title_attr']) |
|
543 | - . '">' |
|
544 | - . $event_name |
|
545 | - . '</a>' : $event_name; |
|
546 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL); |
|
547 | - $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
548 | - $actions['event_filter'] .= sprintf( |
|
549 | - esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
|
550 | - $event_name |
|
551 | - ); |
|
552 | - $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>'; |
|
553 | - } else { |
|
554 | - $edit_event = $event_name; |
|
555 | - $actions['event_filter'] = ''; |
|
556 | - } |
|
557 | - return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
558 | - } |
|
511 | + /** |
|
512 | + * column_event_name |
|
513 | + * |
|
514 | + * @access public |
|
515 | + * @param \EE_Registration $item |
|
516 | + * @return string |
|
517 | + * @throws EE_Error |
|
518 | + * @throws InvalidArgumentException |
|
519 | + * @throws InvalidDataTypeException |
|
520 | + * @throws InvalidInterfaceException |
|
521 | + * @throws ReflectionException |
|
522 | + */ |
|
523 | + public function column_event_name(EE_Registration $item) |
|
524 | + { |
|
525 | + $this->_set_related_details($item); |
|
526 | + // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
527 | + $EVT_ID = $item->event_ID(); |
|
528 | + $event_name = $item->event_name(); |
|
529 | + $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
|
530 | + $event_name = wp_trim_words($event_name, 30, '...'); |
|
531 | + if ($EVT_ID) { |
|
532 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
|
533 | + array('action' => 'edit', 'post' => $EVT_ID), |
|
534 | + EVENTS_ADMIN_URL |
|
535 | + ); |
|
536 | + $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID) |
|
537 | + ? '<a class="ee-status-color-' |
|
538 | + . $this->_event_details['status'] |
|
539 | + . '" href="' |
|
540 | + . $edit_event_url |
|
541 | + . '" title="' |
|
542 | + . esc_attr($this->_event_details['title_attr']) |
|
543 | + . '">' |
|
544 | + . $event_name |
|
545 | + . '</a>' : $event_name; |
|
546 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL); |
|
547 | + $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
548 | + $actions['event_filter'] .= sprintf( |
|
549 | + esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
|
550 | + $event_name |
|
551 | + ); |
|
552 | + $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>'; |
|
553 | + } else { |
|
554 | + $edit_event = $event_name; |
|
555 | + $actions['event_filter'] = ''; |
|
556 | + } |
|
557 | + return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
558 | + } |
|
559 | 559 | |
560 | 560 | |
561 | - /** |
|
562 | - * column_DTT_EVT_start |
|
563 | - * |
|
564 | - * @access public |
|
565 | - * @param \EE_Registration $item |
|
566 | - * @return string |
|
567 | - * @throws EE_Error |
|
568 | - * @throws InvalidArgumentException |
|
569 | - * @throws InvalidDataTypeException |
|
570 | - * @throws InvalidInterfaceException |
|
571 | - * @throws ReflectionException |
|
572 | - */ |
|
573 | - public function column_DTT_EVT_start(EE_Registration $item) |
|
574 | - { |
|
575 | - $datetime_strings = array(); |
|
576 | - $ticket = $item->ticket(true); |
|
577 | - if ($ticket instanceof EE_Ticket) { |
|
578 | - $remove_defaults = array('default_where_conditions' => 'none'); |
|
579 | - $datetimes = $ticket->datetimes($remove_defaults); |
|
580 | - foreach ($datetimes as $datetime) { |
|
581 | - $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
582 | - } |
|
583 | - return $this->generateDisplayForDatetimes($datetime_strings); |
|
584 | - } |
|
585 | - return __('There is no ticket on this registration', 'event_espresso'); |
|
586 | - } |
|
561 | + /** |
|
562 | + * column_DTT_EVT_start |
|
563 | + * |
|
564 | + * @access public |
|
565 | + * @param \EE_Registration $item |
|
566 | + * @return string |
|
567 | + * @throws EE_Error |
|
568 | + * @throws InvalidArgumentException |
|
569 | + * @throws InvalidDataTypeException |
|
570 | + * @throws InvalidInterfaceException |
|
571 | + * @throws ReflectionException |
|
572 | + */ |
|
573 | + public function column_DTT_EVT_start(EE_Registration $item) |
|
574 | + { |
|
575 | + $datetime_strings = array(); |
|
576 | + $ticket = $item->ticket(true); |
|
577 | + if ($ticket instanceof EE_Ticket) { |
|
578 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
579 | + $datetimes = $ticket->datetimes($remove_defaults); |
|
580 | + foreach ($datetimes as $datetime) { |
|
581 | + $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
582 | + } |
|
583 | + return $this->generateDisplayForDatetimes($datetime_strings); |
|
584 | + } |
|
585 | + return __('There is no ticket on this registration', 'event_espresso'); |
|
586 | + } |
|
587 | 587 | |
588 | 588 | |
589 | - /** |
|
590 | - * Receives an array of datetime strings to display and converts them to the html container for the column. |
|
591 | - * |
|
592 | - * @param array $datetime_strings |
|
593 | - * @return string |
|
594 | - */ |
|
595 | - public function generateDisplayForDateTimes(array $datetime_strings) |
|
596 | - { |
|
597 | - $content = '<div class="ee-registration-event-datetimes-container">'; |
|
598 | - $expand_toggle = count($datetime_strings) > 1 |
|
599 | - ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso') |
|
600 | - . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>' |
|
601 | - : ''; |
|
602 | - //get first item for initial visibility |
|
603 | - $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>'; |
|
604 | - $content .= $expand_toggle; |
|
605 | - if ($datetime_strings) { |
|
606 | - $content .= '<div style="clear:both"></div>'; |
|
607 | - $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">'; |
|
608 | - $content .= implode("<br />", $datetime_strings); |
|
609 | - $content .= '</div>'; |
|
610 | - } |
|
611 | - $content .= '</div>'; |
|
612 | - return $content; |
|
613 | - } |
|
589 | + /** |
|
590 | + * Receives an array of datetime strings to display and converts them to the html container for the column. |
|
591 | + * |
|
592 | + * @param array $datetime_strings |
|
593 | + * @return string |
|
594 | + */ |
|
595 | + public function generateDisplayForDateTimes(array $datetime_strings) |
|
596 | + { |
|
597 | + $content = '<div class="ee-registration-event-datetimes-container">'; |
|
598 | + $expand_toggle = count($datetime_strings) > 1 |
|
599 | + ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso') |
|
600 | + . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>' |
|
601 | + : ''; |
|
602 | + //get first item for initial visibility |
|
603 | + $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>'; |
|
604 | + $content .= $expand_toggle; |
|
605 | + if ($datetime_strings) { |
|
606 | + $content .= '<div style="clear:both"></div>'; |
|
607 | + $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">'; |
|
608 | + $content .= implode("<br />", $datetime_strings); |
|
609 | + $content .= '</div>'; |
|
610 | + } |
|
611 | + $content .= '</div>'; |
|
612 | + return $content; |
|
613 | + } |
|
614 | 614 | |
615 | 615 | |
616 | - /** |
|
617 | - * column_ATT_fname |
|
618 | - * |
|
619 | - * @access public |
|
620 | - * @param \EE_Registration $item |
|
621 | - * @return string |
|
622 | - * @throws EE_Error |
|
623 | - * @throws InvalidArgumentException |
|
624 | - * @throws InvalidDataTypeException |
|
625 | - * @throws InvalidInterfaceException |
|
626 | - * @throws ReflectionException |
|
627 | - */ |
|
628 | - public function column_ATT_fname(EE_Registration $item) |
|
629 | - { |
|
630 | - $attendee = $item->attendee(); |
|
631 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
632 | - 'action' => 'view_registration', |
|
633 | - '_REG_ID' => $item->ID(), |
|
634 | - ), REG_ADMIN_URL); |
|
635 | - $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
636 | - $link = EE_Registry::instance()->CAP->current_user_can( |
|
637 | - 'ee_read_registration', |
|
638 | - 'espresso_registrations_view_registration', |
|
639 | - $item->ID() |
|
640 | - ) |
|
641 | - ? '<a href="' |
|
642 | - . $edit_lnk_url |
|
643 | - . '" title="' |
|
644 | - . esc_attr__('View Registration Details', 'event_espresso') |
|
645 | - . '">' |
|
646 | - . $attendee_name |
|
647 | - . '</a>' : $attendee_name; |
|
648 | - $link .= $item->count() === 1 |
|
649 | - ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
|
650 | - $t = $item->get_first_related('Transaction'); |
|
651 | - $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
|
652 | - //append group count to name |
|
653 | - $link .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
654 | - //append reg_code |
|
655 | - $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
656 | - //reg status text for accessibility |
|
657 | - $link .= '<br><span class="ee-status-text-small">' |
|
658 | - . EEH_Template::pretty_status($item->status_ID(), false, 'sentence') |
|
659 | - . '</span>'; |
|
660 | - //trash/restore/delete actions |
|
661 | - $actions = array(); |
|
662 | - if ($this->_view !== 'trash' |
|
663 | - && $payment_count === 0 |
|
664 | - && EE_Registry::instance()->CAP->current_user_can( |
|
665 | - 'ee_delete_registration', |
|
666 | - 'espresso_registrations_trash_registrations', |
|
667 | - $item->ID() |
|
668 | - )) { |
|
669 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
670 | - 'action' => 'trash_registrations', |
|
671 | - '_REG_ID' => $item->ID(), |
|
672 | - ), REG_ADMIN_URL); |
|
673 | - $actions['trash'] = '<a href="' |
|
674 | - . $trash_lnk_url |
|
675 | - . '" title="' |
|
676 | - . esc_attr__('Trash Registration', 'event_espresso') |
|
677 | - . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
678 | - } elseif ($this->_view === 'trash') { |
|
679 | - // restore registration link |
|
680 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
681 | - 'ee_delete_registration', |
|
682 | - 'espresso_registrations_restore_registrations', |
|
683 | - $item->ID() |
|
684 | - )) { |
|
685 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
686 | - 'action' => 'restore_registrations', |
|
687 | - '_REG_ID' => $item->ID(), |
|
688 | - ), REG_ADMIN_URL); |
|
689 | - $actions['restore'] = '<a href="' |
|
690 | - . $restore_lnk_url |
|
691 | - . '" title="' |
|
692 | - . esc_attr__('Restore Registration', 'event_espresso') . '">' |
|
693 | - . __('Restore', 'event_espresso') . '</a>'; |
|
694 | - } |
|
695 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
696 | - 'ee_delete_registration', |
|
697 | - 'espresso_registrations_ee_delete_registrations', |
|
698 | - $item->ID() |
|
699 | - )) { |
|
700 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
701 | - 'action' => 'delete_registrations', |
|
702 | - '_REG_ID' => $item->ID(), |
|
703 | - ), REG_ADMIN_URL); |
|
704 | - $actions['delete'] = '<a href="' |
|
705 | - . $delete_lnk_url |
|
706 | - . '" title="' |
|
707 | - . esc_attr__('Delete Registration Permanently', 'event_espresso') |
|
708 | - . '">' |
|
709 | - . __('Delete', 'event_espresso') |
|
710 | - . '</a>'; |
|
711 | - } |
|
712 | - } |
|
713 | - return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
714 | - } |
|
616 | + /** |
|
617 | + * column_ATT_fname |
|
618 | + * |
|
619 | + * @access public |
|
620 | + * @param \EE_Registration $item |
|
621 | + * @return string |
|
622 | + * @throws EE_Error |
|
623 | + * @throws InvalidArgumentException |
|
624 | + * @throws InvalidDataTypeException |
|
625 | + * @throws InvalidInterfaceException |
|
626 | + * @throws ReflectionException |
|
627 | + */ |
|
628 | + public function column_ATT_fname(EE_Registration $item) |
|
629 | + { |
|
630 | + $attendee = $item->attendee(); |
|
631 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
632 | + 'action' => 'view_registration', |
|
633 | + '_REG_ID' => $item->ID(), |
|
634 | + ), REG_ADMIN_URL); |
|
635 | + $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
636 | + $link = EE_Registry::instance()->CAP->current_user_can( |
|
637 | + 'ee_read_registration', |
|
638 | + 'espresso_registrations_view_registration', |
|
639 | + $item->ID() |
|
640 | + ) |
|
641 | + ? '<a href="' |
|
642 | + . $edit_lnk_url |
|
643 | + . '" title="' |
|
644 | + . esc_attr__('View Registration Details', 'event_espresso') |
|
645 | + . '">' |
|
646 | + . $attendee_name |
|
647 | + . '</a>' : $attendee_name; |
|
648 | + $link .= $item->count() === 1 |
|
649 | + ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
|
650 | + $t = $item->get_first_related('Transaction'); |
|
651 | + $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
|
652 | + //append group count to name |
|
653 | + $link .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
654 | + //append reg_code |
|
655 | + $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
656 | + //reg status text for accessibility |
|
657 | + $link .= '<br><span class="ee-status-text-small">' |
|
658 | + . EEH_Template::pretty_status($item->status_ID(), false, 'sentence') |
|
659 | + . '</span>'; |
|
660 | + //trash/restore/delete actions |
|
661 | + $actions = array(); |
|
662 | + if ($this->_view !== 'trash' |
|
663 | + && $payment_count === 0 |
|
664 | + && EE_Registry::instance()->CAP->current_user_can( |
|
665 | + 'ee_delete_registration', |
|
666 | + 'espresso_registrations_trash_registrations', |
|
667 | + $item->ID() |
|
668 | + )) { |
|
669 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
670 | + 'action' => 'trash_registrations', |
|
671 | + '_REG_ID' => $item->ID(), |
|
672 | + ), REG_ADMIN_URL); |
|
673 | + $actions['trash'] = '<a href="' |
|
674 | + . $trash_lnk_url |
|
675 | + . '" title="' |
|
676 | + . esc_attr__('Trash Registration', 'event_espresso') |
|
677 | + . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
678 | + } elseif ($this->_view === 'trash') { |
|
679 | + // restore registration link |
|
680 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
681 | + 'ee_delete_registration', |
|
682 | + 'espresso_registrations_restore_registrations', |
|
683 | + $item->ID() |
|
684 | + )) { |
|
685 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
686 | + 'action' => 'restore_registrations', |
|
687 | + '_REG_ID' => $item->ID(), |
|
688 | + ), REG_ADMIN_URL); |
|
689 | + $actions['restore'] = '<a href="' |
|
690 | + . $restore_lnk_url |
|
691 | + . '" title="' |
|
692 | + . esc_attr__('Restore Registration', 'event_espresso') . '">' |
|
693 | + . __('Restore', 'event_espresso') . '</a>'; |
|
694 | + } |
|
695 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
696 | + 'ee_delete_registration', |
|
697 | + 'espresso_registrations_ee_delete_registrations', |
|
698 | + $item->ID() |
|
699 | + )) { |
|
700 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
701 | + 'action' => 'delete_registrations', |
|
702 | + '_REG_ID' => $item->ID(), |
|
703 | + ), REG_ADMIN_URL); |
|
704 | + $actions['delete'] = '<a href="' |
|
705 | + . $delete_lnk_url |
|
706 | + . '" title="' |
|
707 | + . esc_attr__('Delete Registration Permanently', 'event_espresso') |
|
708 | + . '">' |
|
709 | + . __('Delete', 'event_espresso') |
|
710 | + . '</a>'; |
|
711 | + } |
|
712 | + } |
|
713 | + return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
714 | + } |
|
715 | 715 | |
716 | 716 | |
717 | - /** |
|
718 | - * column_ATT_email |
|
719 | - * |
|
720 | - * @access public |
|
721 | - * @param \EE_Registration $item |
|
722 | - * @return string |
|
723 | - * @throws EE_Error |
|
724 | - * @throws InvalidArgumentException |
|
725 | - * @throws InvalidDataTypeException |
|
726 | - * @throws InvalidInterfaceException |
|
727 | - * @throws ReflectionException |
|
728 | - */ |
|
729 | - public function column_ATT_email(EE_Registration $item) |
|
730 | - { |
|
731 | - $attendee = $item->get_first_related('Attendee'); |
|
732 | - return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') |
|
733 | - : $attendee->email(); |
|
734 | - } |
|
717 | + /** |
|
718 | + * column_ATT_email |
|
719 | + * |
|
720 | + * @access public |
|
721 | + * @param \EE_Registration $item |
|
722 | + * @return string |
|
723 | + * @throws EE_Error |
|
724 | + * @throws InvalidArgumentException |
|
725 | + * @throws InvalidDataTypeException |
|
726 | + * @throws InvalidInterfaceException |
|
727 | + * @throws ReflectionException |
|
728 | + */ |
|
729 | + public function column_ATT_email(EE_Registration $item) |
|
730 | + { |
|
731 | + $attendee = $item->get_first_related('Attendee'); |
|
732 | + return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') |
|
733 | + : $attendee->email(); |
|
734 | + } |
|
735 | 735 | |
736 | 736 | |
737 | - /** |
|
738 | - * column__REG_count |
|
739 | - * |
|
740 | - * @access public |
|
741 | - * @param \EE_Registration $item |
|
742 | - * @return string |
|
743 | - */ |
|
744 | - public function column__REG_count(EE_Registration $item) |
|
745 | - { |
|
746 | - return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
747 | - } |
|
737 | + /** |
|
738 | + * column__REG_count |
|
739 | + * |
|
740 | + * @access public |
|
741 | + * @param \EE_Registration $item |
|
742 | + * @return string |
|
743 | + */ |
|
744 | + public function column__REG_count(EE_Registration $item) |
|
745 | + { |
|
746 | + return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
747 | + } |
|
748 | 748 | |
749 | 749 | |
750 | - /** |
|
751 | - * column_PRC_amount |
|
752 | - * |
|
753 | - * @access public |
|
754 | - * @param \EE_Registration $item |
|
755 | - * @return string |
|
756 | - * @throws EE_Error |
|
757 | - */ |
|
758 | - public function column_PRC_amount(EE_Registration $item) |
|
759 | - { |
|
760 | - $ticket = $item->ticket(); |
|
761 | - $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' |
|
762 | - . $ticket->name() |
|
763 | - . '</span><br />' : ''; |
|
764 | - if ($item->final_price() > 0) { |
|
765 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
766 | - } else { |
|
767 | - // free event |
|
768 | - $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
|
769 | - . __('free', 'event_espresso') |
|
770 | - . '</span>'; |
|
771 | - } |
|
772 | - return $content; |
|
773 | - } |
|
750 | + /** |
|
751 | + * column_PRC_amount |
|
752 | + * |
|
753 | + * @access public |
|
754 | + * @param \EE_Registration $item |
|
755 | + * @return string |
|
756 | + * @throws EE_Error |
|
757 | + */ |
|
758 | + public function column_PRC_amount(EE_Registration $item) |
|
759 | + { |
|
760 | + $ticket = $item->ticket(); |
|
761 | + $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' |
|
762 | + . $ticket->name() |
|
763 | + . '</span><br />' : ''; |
|
764 | + if ($item->final_price() > 0) { |
|
765 | + $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
766 | + } else { |
|
767 | + // free event |
|
768 | + $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
|
769 | + . __('free', 'event_espresso') |
|
770 | + . '</span>'; |
|
771 | + } |
|
772 | + return $content; |
|
773 | + } |
|
774 | 774 | |
775 | 775 | |
776 | - /** |
|
777 | - * column__REG_final_price |
|
778 | - * |
|
779 | - * @access public |
|
780 | - * @param \EE_Registration $item |
|
781 | - * @return string |
|
782 | - * @throws EE_Error |
|
783 | - */ |
|
784 | - public function column__REG_final_price(EE_Registration $item) |
|
785 | - { |
|
786 | - $ticket = $item->ticket(); |
|
787 | - $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket |
|
788 | - ? '' |
|
789 | - : '<span class="TKT_name">' |
|
790 | - . $ticket->name() |
|
791 | - . '</span><br />'; |
|
792 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
793 | - return $content; |
|
794 | - } |
|
776 | + /** |
|
777 | + * column__REG_final_price |
|
778 | + * |
|
779 | + * @access public |
|
780 | + * @param \EE_Registration $item |
|
781 | + * @return string |
|
782 | + * @throws EE_Error |
|
783 | + */ |
|
784 | + public function column__REG_final_price(EE_Registration $item) |
|
785 | + { |
|
786 | + $ticket = $item->ticket(); |
|
787 | + $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket |
|
788 | + ? '' |
|
789 | + : '<span class="TKT_name">' |
|
790 | + . $ticket->name() |
|
791 | + . '</span><br />'; |
|
792 | + $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
793 | + return $content; |
|
794 | + } |
|
795 | 795 | |
796 | 796 | |
797 | - /** |
|
798 | - * column__REG_paid |
|
799 | - * |
|
800 | - * @access public |
|
801 | - * @param \EE_Registration $item |
|
802 | - * @return string |
|
803 | - * @throws EE_Error |
|
804 | - */ |
|
805 | - public function column__REG_paid(EE_Registration $item) |
|
806 | - { |
|
807 | - $payment_method = $item->payment_method(); |
|
808 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() |
|
809 | - : __('Unknown', 'event_espresso'); |
|
810 | - $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
811 | - if ($item->paid() > 0) { |
|
812 | - $content .= '<br><span class="ee-status-text-small">' |
|
813 | - . sprintf( |
|
814 | - __('...via %s', 'event_espresso'), |
|
815 | - $payment_method_name |
|
816 | - ) |
|
817 | - . '</span>'; |
|
818 | - } |
|
819 | - return $content; |
|
820 | - } |
|
797 | + /** |
|
798 | + * column__REG_paid |
|
799 | + * |
|
800 | + * @access public |
|
801 | + * @param \EE_Registration $item |
|
802 | + * @return string |
|
803 | + * @throws EE_Error |
|
804 | + */ |
|
805 | + public function column__REG_paid(EE_Registration $item) |
|
806 | + { |
|
807 | + $payment_method = $item->payment_method(); |
|
808 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() |
|
809 | + : __('Unknown', 'event_espresso'); |
|
810 | + $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
811 | + if ($item->paid() > 0) { |
|
812 | + $content .= '<br><span class="ee-status-text-small">' |
|
813 | + . sprintf( |
|
814 | + __('...via %s', 'event_espresso'), |
|
815 | + $payment_method_name |
|
816 | + ) |
|
817 | + . '</span>'; |
|
818 | + } |
|
819 | + return $content; |
|
820 | + } |
|
821 | 821 | |
822 | 822 | |
823 | - /** |
|
824 | - * column_TXN_total |
|
825 | - * |
|
826 | - * @access public |
|
827 | - * @param \EE_Registration $item |
|
828 | - * @return string |
|
829 | - * @throws EE_Error |
|
830 | - * @throws EntityNotFoundException |
|
831 | - * @throws InvalidArgumentException |
|
832 | - * @throws InvalidDataTypeException |
|
833 | - * @throws InvalidInterfaceException |
|
834 | - */ |
|
835 | - public function column_TXN_total(EE_Registration $item) |
|
836 | - { |
|
837 | - if ($item->transaction()) { |
|
838 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
839 | - 'action' => 'view_transaction', |
|
840 | - 'TXN_ID' => $item->transaction_ID(), |
|
841 | - ), TXN_ADMIN_URL); |
|
842 | - return EE_Registry::instance()->CAP->current_user_can( |
|
843 | - 'ee_read_transaction', |
|
844 | - 'espresso_transactions_view_transaction', |
|
845 | - $item->transaction_ID() |
|
846 | - ) |
|
847 | - ? '<span class="reg-pad-rght"><a class="status-' |
|
848 | - . $item->transaction()->status_ID() |
|
849 | - . '" href="' |
|
850 | - . $view_txn_lnk_url |
|
851 | - . '" title="' |
|
852 | - . esc_attr__('View Transaction', 'event_espresso') |
|
853 | - . '">' |
|
854 | - . $item->transaction()->pretty_total() |
|
855 | - . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
856 | - } else { |
|
857 | - return __("None", "event_espresso"); |
|
858 | - } |
|
859 | - } |
|
823 | + /** |
|
824 | + * column_TXN_total |
|
825 | + * |
|
826 | + * @access public |
|
827 | + * @param \EE_Registration $item |
|
828 | + * @return string |
|
829 | + * @throws EE_Error |
|
830 | + * @throws EntityNotFoundException |
|
831 | + * @throws InvalidArgumentException |
|
832 | + * @throws InvalidDataTypeException |
|
833 | + * @throws InvalidInterfaceException |
|
834 | + */ |
|
835 | + public function column_TXN_total(EE_Registration $item) |
|
836 | + { |
|
837 | + if ($item->transaction()) { |
|
838 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
839 | + 'action' => 'view_transaction', |
|
840 | + 'TXN_ID' => $item->transaction_ID(), |
|
841 | + ), TXN_ADMIN_URL); |
|
842 | + return EE_Registry::instance()->CAP->current_user_can( |
|
843 | + 'ee_read_transaction', |
|
844 | + 'espresso_transactions_view_transaction', |
|
845 | + $item->transaction_ID() |
|
846 | + ) |
|
847 | + ? '<span class="reg-pad-rght"><a class="status-' |
|
848 | + . $item->transaction()->status_ID() |
|
849 | + . '" href="' |
|
850 | + . $view_txn_lnk_url |
|
851 | + . '" title="' |
|
852 | + . esc_attr__('View Transaction', 'event_espresso') |
|
853 | + . '">' |
|
854 | + . $item->transaction()->pretty_total() |
|
855 | + . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
856 | + } else { |
|
857 | + return __("None", "event_espresso"); |
|
858 | + } |
|
859 | + } |
|
860 | 860 | |
861 | 861 | |
862 | - /** |
|
863 | - * column_TXN_paid |
|
864 | - * |
|
865 | - * @access public |
|
866 | - * @param \EE_Registration $item |
|
867 | - * @return string |
|
868 | - * @throws EE_Error |
|
869 | - * @throws EntityNotFoundException |
|
870 | - * @throws InvalidArgumentException |
|
871 | - * @throws InvalidDataTypeException |
|
872 | - * @throws InvalidInterfaceException |
|
873 | - */ |
|
874 | - public function column_TXN_paid(EE_Registration $item) |
|
875 | - { |
|
876 | - if ($item->count() === 1) { |
|
877 | - $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
|
878 | - if ($transaction->paid() >= $transaction->total()) { |
|
879 | - return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
880 | - } else { |
|
881 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
882 | - 'action' => 'view_transaction', |
|
883 | - 'TXN_ID' => $item->transaction_ID(), |
|
884 | - ), TXN_ADMIN_URL); |
|
885 | - return EE_Registry::instance()->CAP->current_user_can( |
|
886 | - 'ee_read_transaction', |
|
887 | - 'espresso_transactions_view_transaction', |
|
888 | - $item->transaction_ID() |
|
889 | - ) |
|
890 | - ? '<span class="reg-pad-rght"><a class="status-' |
|
891 | - . $transaction->status_ID() |
|
892 | - . '" href="' |
|
893 | - . $view_txn_lnk_url |
|
894 | - . '" title="' |
|
895 | - . esc_attr__('View Transaction', 'event_espresso') |
|
896 | - . '">' |
|
897 | - . $item->transaction()->pretty_paid() |
|
898 | - . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
899 | - } |
|
900 | - } |
|
901 | - return ' '; |
|
902 | - } |
|
862 | + /** |
|
863 | + * column_TXN_paid |
|
864 | + * |
|
865 | + * @access public |
|
866 | + * @param \EE_Registration $item |
|
867 | + * @return string |
|
868 | + * @throws EE_Error |
|
869 | + * @throws EntityNotFoundException |
|
870 | + * @throws InvalidArgumentException |
|
871 | + * @throws InvalidDataTypeException |
|
872 | + * @throws InvalidInterfaceException |
|
873 | + */ |
|
874 | + public function column_TXN_paid(EE_Registration $item) |
|
875 | + { |
|
876 | + if ($item->count() === 1) { |
|
877 | + $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
|
878 | + if ($transaction->paid() >= $transaction->total()) { |
|
879 | + return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
880 | + } else { |
|
881 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
882 | + 'action' => 'view_transaction', |
|
883 | + 'TXN_ID' => $item->transaction_ID(), |
|
884 | + ), TXN_ADMIN_URL); |
|
885 | + return EE_Registry::instance()->CAP->current_user_can( |
|
886 | + 'ee_read_transaction', |
|
887 | + 'espresso_transactions_view_transaction', |
|
888 | + $item->transaction_ID() |
|
889 | + ) |
|
890 | + ? '<span class="reg-pad-rght"><a class="status-' |
|
891 | + . $transaction->status_ID() |
|
892 | + . '" href="' |
|
893 | + . $view_txn_lnk_url |
|
894 | + . '" title="' |
|
895 | + . esc_attr__('View Transaction', 'event_espresso') |
|
896 | + . '">' |
|
897 | + . $item->transaction()->pretty_paid() |
|
898 | + . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
899 | + } |
|
900 | + } |
|
901 | + return ' '; |
|
902 | + } |
|
903 | 903 | |
904 | 904 | |
905 | - /** |
|
906 | - * column_actions |
|
907 | - * |
|
908 | - * @access public |
|
909 | - * @param \EE_Registration $item |
|
910 | - * @return string |
|
911 | - * @throws EE_Error |
|
912 | - * @throws InvalidArgumentException |
|
913 | - * @throws InvalidDataTypeException |
|
914 | - * @throws InvalidInterfaceException |
|
915 | - * @throws ReflectionException |
|
916 | - */ |
|
917 | - public function column_actions(EE_Registration $item) |
|
918 | - { |
|
919 | - $actions = array(); |
|
920 | - $attendee = $item->attendee(); |
|
921 | - $this->_set_related_details($item); |
|
922 | - //Build row actions |
|
923 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
924 | - 'action' => 'view_registration', |
|
925 | - '_REG_ID' => $item->ID(), |
|
926 | - ), REG_ADMIN_URL); |
|
927 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
928 | - 'action' => 'edit_attendee', |
|
929 | - 'post' => $item->attendee_ID(), |
|
930 | - ), REG_ADMIN_URL); |
|
931 | - // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
|
932 | - //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
|
933 | - $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
934 | - 'action' => 'resend_registration', |
|
935 | - '_REG_ID' => $item->ID(), |
|
936 | - ), REG_ADMIN_URL, true); |
|
937 | - //Build row actions |
|
938 | - $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can( |
|
939 | - 'ee_read_registration', |
|
940 | - 'espresso_registrations_view_registration', |
|
941 | - $item->ID() |
|
942 | - ) ? '<li><a href="' |
|
943 | - . $view_lnk_url |
|
944 | - . '" title="' |
|
945 | - . esc_attr__('View Registration Details', 'event_espresso') |
|
946 | - . '" class="tiny-text"> |
|
905 | + /** |
|
906 | + * column_actions |
|
907 | + * |
|
908 | + * @access public |
|
909 | + * @param \EE_Registration $item |
|
910 | + * @return string |
|
911 | + * @throws EE_Error |
|
912 | + * @throws InvalidArgumentException |
|
913 | + * @throws InvalidDataTypeException |
|
914 | + * @throws InvalidInterfaceException |
|
915 | + * @throws ReflectionException |
|
916 | + */ |
|
917 | + public function column_actions(EE_Registration $item) |
|
918 | + { |
|
919 | + $actions = array(); |
|
920 | + $attendee = $item->attendee(); |
|
921 | + $this->_set_related_details($item); |
|
922 | + //Build row actions |
|
923 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
924 | + 'action' => 'view_registration', |
|
925 | + '_REG_ID' => $item->ID(), |
|
926 | + ), REG_ADMIN_URL); |
|
927 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
928 | + 'action' => 'edit_attendee', |
|
929 | + 'post' => $item->attendee_ID(), |
|
930 | + ), REG_ADMIN_URL); |
|
931 | + // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
|
932 | + //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
|
933 | + $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
934 | + 'action' => 'resend_registration', |
|
935 | + '_REG_ID' => $item->ID(), |
|
936 | + ), REG_ADMIN_URL, true); |
|
937 | + //Build row actions |
|
938 | + $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can( |
|
939 | + 'ee_read_registration', |
|
940 | + 'espresso_registrations_view_registration', |
|
941 | + $item->ID() |
|
942 | + ) ? '<li><a href="' |
|
943 | + . $view_lnk_url |
|
944 | + . '" title="' |
|
945 | + . esc_attr__('View Registration Details', 'event_espresso') |
|
946 | + . '" class="tiny-text"> |
|
947 | 947 | <div class="dashicons dashicons-clipboard"></div> |
948 | 948 | </a> |
949 | 949 | </li>' |
950 | - : ''; |
|
951 | - $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can( |
|
952 | - 'ee_edit_contacts', |
|
953 | - 'espresso_registrations_edit_attendee' |
|
954 | - ) |
|
955 | - && $attendee instanceof EE_Attendee |
|
956 | - ? ' |
|
950 | + : ''; |
|
951 | + $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can( |
|
952 | + 'ee_edit_contacts', |
|
953 | + 'espresso_registrations_edit_attendee' |
|
954 | + ) |
|
955 | + && $attendee instanceof EE_Attendee |
|
956 | + ? ' |
|
957 | 957 | <li> |
958 | 958 | <a href="' . $edit_lnk_url . '" title="' |
959 | - . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text"> |
|
959 | + . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text"> |
|
960 | 960 | <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div> |
961 | 961 | </a> |
962 | 962 | </li>' : ''; |
963 | - $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee |
|
964 | - && EE_Registry::instance()->CAP->current_user_can( |
|
965 | - 'ee_send_message', |
|
966 | - 'espresso_registrations_resend_registration', |
|
967 | - $item->ID() |
|
968 | - ) |
|
969 | - ? ' |
|
963 | + $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee |
|
964 | + && EE_Registry::instance()->CAP->current_user_can( |
|
965 | + 'ee_send_message', |
|
966 | + 'espresso_registrations_resend_registration', |
|
967 | + $item->ID() |
|
968 | + ) |
|
969 | + ? ' |
|
970 | 970 | <li> |
971 | 971 | <a href="' |
972 | - . $resend_reg_lnk_url |
|
973 | - . '" title="' |
|
974 | - . esc_attr__('Resend Registration Details', 'event_espresso') |
|
975 | - . '" class="tiny-text"> |
|
972 | + . $resend_reg_lnk_url |
|
973 | + . '" title="' |
|
974 | + . esc_attr__('Resend Registration Details', 'event_espresso') |
|
975 | + . '" class="tiny-text"> |
|
976 | 976 | <div class="dashicons dashicons-email-alt"></div> |
977 | 977 | </a> |
978 | 978 | </li>' : ''; |
979 | - // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
|
980 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
981 | - 'action' => 'view_transaction', |
|
982 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
983 | - ), TXN_ADMIN_URL); |
|
984 | - $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can( |
|
985 | - 'ee_read_transaction', |
|
986 | - 'espresso_transactions_view_transaction', |
|
987 | - $this->_transaction_details['id'] |
|
988 | - ) |
|
989 | - ? ' |
|
979 | + // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
|
980 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
981 | + 'action' => 'view_transaction', |
|
982 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
983 | + ), TXN_ADMIN_URL); |
|
984 | + $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can( |
|
985 | + 'ee_read_transaction', |
|
986 | + 'espresso_transactions_view_transaction', |
|
987 | + $this->_transaction_details['id'] |
|
988 | + ) |
|
989 | + ? ' |
|
990 | 990 | <li> |
991 | 991 | <a class="ee-status-color-' |
992 | - . $this->_transaction_details['status'] |
|
993 | - . ' tiny-text" href="' |
|
994 | - . $view_txn_lnk_url |
|
995 | - . '" title="' |
|
996 | - . $this->_transaction_details['title_attr'] |
|
997 | - . '"> |
|
992 | + . $this->_transaction_details['status'] |
|
993 | + . ' tiny-text" href="' |
|
994 | + . $view_txn_lnk_url |
|
995 | + . '" title="' |
|
996 | + . $this->_transaction_details['title_attr'] |
|
997 | + . '"> |
|
998 | 998 | <div class="dashicons dashicons-cart"></div> |
999 | 999 | </a> |
1000 | 1000 | </li>' : ''; |
1001 | - //invoice link |
|
1002 | - $actions['dl_invoice_lnk'] = ''; |
|
1003 | - $dl_invoice_lnk_url = $item->invoice_url(); |
|
1004 | - //only show invoice link if message type is active. |
|
1005 | - if ($attendee instanceof EE_Attendee |
|
1006 | - && $item->is_primary_registrant() |
|
1007 | - && EEH_MSG_Template::is_mt_active('invoice') |
|
1008 | - ) { |
|
1009 | - $actions['dl_invoice_lnk'] = ' |
|
1001 | + //invoice link |
|
1002 | + $actions['dl_invoice_lnk'] = ''; |
|
1003 | + $dl_invoice_lnk_url = $item->invoice_url(); |
|
1004 | + //only show invoice link if message type is active. |
|
1005 | + if ($attendee instanceof EE_Attendee |
|
1006 | + && $item->is_primary_registrant() |
|
1007 | + && EEH_MSG_Template::is_mt_active('invoice') |
|
1008 | + ) { |
|
1009 | + $actions['dl_invoice_lnk'] = ' |
|
1010 | 1010 | <li> |
1011 | 1011 | <a title="' |
1012 | - . esc_attr__('View Transaction Invoice', 'event_espresso') |
|
1013 | - . '" target="_blank" href="' |
|
1014 | - . $dl_invoice_lnk_url |
|
1015 | - . '" class="tiny-text"> |
|
1012 | + . esc_attr__('View Transaction Invoice', 'event_espresso') |
|
1013 | + . '" target="_blank" href="' |
|
1014 | + . $dl_invoice_lnk_url |
|
1015 | + . '" class="tiny-text"> |
|
1016 | 1016 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
1017 | 1017 | </a> |
1018 | 1018 | </li>'; |
1019 | - } |
|
1020 | - $actions['filtered_messages_link'] = ''; |
|
1021 | - //message list table link (filtered by REG_ID |
|
1022 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
1023 | - $actions['filtered_messages_link'] = '<li>' |
|
1024 | - . EEH_MSG_Template::get_message_action_link( |
|
1025 | - 'see_notifications_for', |
|
1026 | - null, |
|
1027 | - array('_REG_ID' => $item->ID()) |
|
1028 | - ) . '</li>'; |
|
1029 | - } |
|
1030 | - $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
|
1031 | - return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
|
1032 | - } |
|
1019 | + } |
|
1020 | + $actions['filtered_messages_link'] = ''; |
|
1021 | + //message list table link (filtered by REG_ID |
|
1022 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
1023 | + $actions['filtered_messages_link'] = '<li>' |
|
1024 | + . EEH_MSG_Template::get_message_action_link( |
|
1025 | + 'see_notifications_for', |
|
1026 | + null, |
|
1027 | + array('_REG_ID' => $item->ID()) |
|
1028 | + ) . '</li>'; |
|
1029 | + } |
|
1030 | + $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
|
1031 | + return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
|
1032 | + } |
|
1033 | 1033 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
3 | 3 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
4 | 4 | |
5 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | 6 | exit('No direct script access allowed'); |
7 | 7 | } |
8 | 8 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct(Registrations_Admin_Page $admin_page) |
59 | 59 | { |
60 | - if (! empty($_GET['event_id'])) { |
|
60 | + if ( ! empty($_GET['event_id'])) { |
|
61 | 61 | $extra_query_args = array(); |
62 | 62 | foreach ($admin_page->get_views() as $key => $view_details) { |
63 | 63 | $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | ); |
158 | 158 | $this->_primary_column = '_REG_ID'; |
159 | 159 | $this->_sortable_columns = array( |
160 | - '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
160 | + '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
161 | 161 | /** |
162 | 162 | * Allows users to change the default sort if they wish. |
163 | 163 | * Returning a falsey on this filter will result in the default sort to be by firstname rather than last |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | { |
190 | 190 | $class = parent::_get_row_class($item); |
191 | 191 | //add status class |
192 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
192 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
193 | 193 | if ($this->_has_checkbox_column) { |
194 | 194 | $class .= ' has-checkbox-column'; |
195 | 195 | } |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | //setup date query. |
355 | 355 | $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( |
356 | 356 | 'REG_date', |
357 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
357 | + $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, |
|
358 | 358 | 'Y-m-d H:i:s' |
359 | 359 | ); |
360 | 360 | $end_string = EEM_Registration::instance()->convert_datetime_for_query( |
361 | 361 | 'REG_date', |
362 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
362 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, |
|
363 | 363 | 'Y-m-d H:i:s' |
364 | 364 | ); |
365 | 365 | $_where['REG_date'] = array( |
@@ -396,12 +396,12 @@ discard block |
||
396 | 396 | array( |
397 | 397 | EEM_Registration::instance()->convert_datetime_for_query( |
398 | 398 | 'REG_date', |
399 | - $current_date . $time_start, |
|
399 | + $current_date.$time_start, |
|
400 | 400 | 'Y-m-d H:i:s' |
401 | 401 | ), |
402 | 402 | EEM_Registration::instance()->convert_datetime_for_query( |
403 | 403 | 'REG_date', |
404 | - $current_date . $time_end, |
|
404 | + $current_date.$time_end, |
|
405 | 405 | 'Y-m-d H:i:s' |
406 | 406 | ), |
407 | 407 | ), |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | $content .= '<div class="show-on-mobile-view-only">'; |
462 | 462 | $content .= '<br>'; |
463 | 463 | $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
464 | - $content .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
465 | - $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
464 | + $content .= ' '.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
465 | + $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
466 | 466 | $content .= '</div>'; |
467 | 467 | return $content; |
468 | 468 | } |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | . $event_name |
545 | 545 | . '</a>' : $event_name; |
546 | 546 | $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL); |
547 | - $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
547 | + $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="'; |
|
548 | 548 | $actions['event_filter'] .= sprintf( |
549 | 549 | esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
550 | 550 | $event_name |
551 | 551 | ); |
552 | - $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>'; |
|
552 | + $actions['event_filter'] .= '">'.__('View Registrations', 'event_espresso').'</a>'; |
|
553 | 553 | } else { |
554 | 554 | $edit_event = $event_name; |
555 | 555 | $actions['event_filter'] = ''; |
@@ -596,11 +596,11 @@ discard block |
||
596 | 596 | { |
597 | 597 | $content = '<div class="ee-registration-event-datetimes-container">'; |
598 | 598 | $expand_toggle = count($datetime_strings) > 1 |
599 | - ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso') |
|
599 | + ? ' <span title="'.esc_attr__('Click to view all dates', 'event_espresso') |
|
600 | 600 | . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>' |
601 | 601 | : ''; |
602 | 602 | //get first item for initial visibility |
603 | - $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>'; |
|
603 | + $content .= '<div class="left">'.array_shift($datetime_strings).'</div>'; |
|
604 | 604 | $content .= $expand_toggle; |
605 | 605 | if ($datetime_strings) { |
606 | 606 | $content .= '<div style="clear:both"></div>'; |
@@ -650,9 +650,9 @@ discard block |
||
650 | 650 | $t = $item->get_first_related('Transaction'); |
651 | 651 | $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
652 | 652 | //append group count to name |
653 | - $link .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
653 | + $link .= ' '.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
654 | 654 | //append reg_code |
655 | - $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
655 | + $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
656 | 656 | //reg status text for accessibility |
657 | 657 | $link .= '<br><span class="ee-status-text-small">' |
658 | 658 | . EEH_Template::pretty_status($item->status_ID(), false, 'sentence') |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | . $trash_lnk_url |
675 | 675 | . '" title="' |
676 | 676 | . esc_attr__('Trash Registration', 'event_espresso') |
677 | - . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
677 | + . '">'.__('Trash', 'event_espresso').'</a>'; |
|
678 | 678 | } elseif ($this->_view === 'trash') { |
679 | 679 | // restore registration link |
680 | 680 | if (EE_Registry::instance()->CAP->current_user_can( |
@@ -689,8 +689,8 @@ discard block |
||
689 | 689 | $actions['restore'] = '<a href="' |
690 | 690 | . $restore_lnk_url |
691 | 691 | . '" title="' |
692 | - . esc_attr__('Restore Registration', 'event_espresso') . '">' |
|
693 | - . __('Restore', 'event_espresso') . '</a>'; |
|
692 | + . esc_attr__('Restore Registration', 'event_espresso').'">' |
|
693 | + . __('Restore', 'event_espresso').'</a>'; |
|
694 | 694 | } |
695 | 695 | if (EE_Registry::instance()->CAP->current_user_can( |
696 | 696 | 'ee_delete_registration', |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | . $ticket->name() |
763 | 763 | . '</span><br />' : ''; |
764 | 764 | if ($item->final_price() > 0) { |
765 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
765 | + $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>'; |
|
766 | 766 | } else { |
767 | 767 | // free event |
768 | 768 | $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | : '<span class="TKT_name">' |
790 | 790 | . $ticket->name() |
791 | 791 | . '</span><br />'; |
792 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
792 | + $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>'; |
|
793 | 793 | return $content; |
794 | 794 | } |
795 | 795 | |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | $payment_method = $item->payment_method(); |
808 | 808 | $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() |
809 | 809 | : __('Unknown', 'event_espresso'); |
810 | - $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
810 | + $content = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>'; |
|
811 | 811 | if ($item->paid() > 0) { |
812 | 812 | $content .= '<br><span class="ee-status-text-small">' |
813 | 813 | . sprintf( |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | . esc_attr__('View Transaction', 'event_espresso') |
853 | 853 | . '">' |
854 | 854 | . $item->transaction()->pretty_total() |
855 | - . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
855 | + . '</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>'; |
|
856 | 856 | } else { |
857 | 857 | return __("None", "event_espresso"); |
858 | 858 | } |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | . esc_attr__('View Transaction', 'event_espresso') |
896 | 896 | . '">' |
897 | 897 | . $item->transaction()->pretty_paid() |
898 | - . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
898 | + . '</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
899 | 899 | } |
900 | 900 | } |
901 | 901 | return ' '; |
@@ -955,8 +955,8 @@ discard block |
||
955 | 955 | && $attendee instanceof EE_Attendee |
956 | 956 | ? ' |
957 | 957 | <li> |
958 | - <a href="' . $edit_lnk_url . '" title="' |
|
959 | - . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text"> |
|
958 | + <a href="' . $edit_lnk_url.'" title="' |
|
959 | + . esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text"> |
|
960 | 960 | <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div> |
961 | 961 | </a> |
962 | 962 | </li>' : ''; |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | 'see_notifications_for', |
1026 | 1026 | null, |
1027 | 1027 | array('_REG_ID' => $item->ID()) |
1028 | - ) . '</li>'; |
|
1028 | + ).'</li>'; |
|
1029 | 1029 | } |
1030 | 1030 | $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
1031 | 1031 | return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
@@ -21,199 +21,199 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * converts a Request to a Response |
|
26 | - * |
|
27 | - * @param EE_Request $request |
|
28 | - * @param EE_Response $response |
|
29 | - * @return EE_Response |
|
30 | - * @throws InvalidDataTypeException |
|
31 | - */ |
|
32 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
33 | - { |
|
34 | - $this->_request = $request; |
|
35 | - $this->_response = $response; |
|
36 | - //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
|
37 | - //$this->_response->set_notice( 1, 'hey look at this' ); |
|
38 | - // check required WP version |
|
39 | - if (! $this->_minimum_wp_version_required()) { |
|
40 | - $this->_request->un_set('activate', true); |
|
41 | - add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
42 | - //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
|
43 | - $this->_response->terminate_request(); |
|
44 | - $this->_response->deactivate_plugin(); |
|
45 | - } |
|
46 | - // check recommended PHP version |
|
47 | - if (! $this->_minimum_php_version_recommended()) { |
|
48 | - $this->_display_minimum_recommended_php_version_notice(); |
|
49 | - } |
|
50 | - |
|
51 | - //upcoming required version |
|
52 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
53 | - $this->displayUpcomingRequiredVersion(); |
|
54 | - } |
|
55 | - $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
56 | - //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
|
57 | - return $this->_response; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * Helper method to assess installed wp version against given values. |
|
63 | - * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
64 | - * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
65 | - * against) so consider that when sending in your values. |
|
66 | - * |
|
67 | - * @param string $version_to_check |
|
68 | - * @param string $operator |
|
69 | - * @return bool |
|
70 | - */ |
|
71 | - public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
72 | - { |
|
73 | - global $wp_version; |
|
74 | - return version_compare( |
|
75 | - // first account for wp_version being pre-release |
|
76 | - // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
77 | - strpos($wp_version, '-') > 0 |
|
78 | - ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
79 | - : $wp_version, |
|
80 | - $version_to_check, |
|
81 | - $operator |
|
82 | - ); |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * _minimum_wp_version_required |
|
89 | - * |
|
90 | - * @access private |
|
91 | - * @return boolean |
|
92 | - */ |
|
93 | - private function _minimum_wp_version_required() |
|
94 | - { |
|
95 | - return EE_Recommended_Versions::check_wp_version(); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * _check_php_version |
|
102 | - * |
|
103 | - * @access private |
|
104 | - * @param string $min_version |
|
105 | - * @return boolean |
|
106 | - */ |
|
107 | - private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
108 | - { |
|
109 | - return version_compare(PHP_VERSION, $min_version, '>='); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * _minimum_php_version_recommended |
|
116 | - * |
|
117 | - * @access private |
|
118 | - * @return boolean |
|
119 | - */ |
|
120 | - private function _minimum_php_version_recommended() |
|
121 | - { |
|
122 | - return $this->_check_php_version(); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns whether the provided php version number is greater than the current version of php installed on the server. |
|
128 | - * @param string $version_required |
|
129 | - * @return bool |
|
130 | - */ |
|
131 | - private function upcomingRequiredPhpVersion($version_required = '5.5') |
|
132 | - { |
|
133 | - return $this->_check_php_version($version_required); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * minimum_wp_version_error |
|
140 | - * |
|
141 | - * @return void |
|
142 | - */ |
|
143 | - public function minimum_wp_version_error() |
|
144 | - { |
|
145 | - global $wp_version; |
|
146 | - ?> |
|
24 | + /** |
|
25 | + * converts a Request to a Response |
|
26 | + * |
|
27 | + * @param EE_Request $request |
|
28 | + * @param EE_Response $response |
|
29 | + * @return EE_Response |
|
30 | + * @throws InvalidDataTypeException |
|
31 | + */ |
|
32 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
33 | + { |
|
34 | + $this->_request = $request; |
|
35 | + $this->_response = $response; |
|
36 | + //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
|
37 | + //$this->_response->set_notice( 1, 'hey look at this' ); |
|
38 | + // check required WP version |
|
39 | + if (! $this->_minimum_wp_version_required()) { |
|
40 | + $this->_request->un_set('activate', true); |
|
41 | + add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
42 | + //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
|
43 | + $this->_response->terminate_request(); |
|
44 | + $this->_response->deactivate_plugin(); |
|
45 | + } |
|
46 | + // check recommended PHP version |
|
47 | + if (! $this->_minimum_php_version_recommended()) { |
|
48 | + $this->_display_minimum_recommended_php_version_notice(); |
|
49 | + } |
|
50 | + |
|
51 | + //upcoming required version |
|
52 | + if (! $this->upcomingRequiredPhpVersion()) { |
|
53 | + $this->displayUpcomingRequiredVersion(); |
|
54 | + } |
|
55 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
56 | + //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
|
57 | + return $this->_response; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * Helper method to assess installed wp version against given values. |
|
63 | + * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
64 | + * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
65 | + * against) so consider that when sending in your values. |
|
66 | + * |
|
67 | + * @param string $version_to_check |
|
68 | + * @param string $operator |
|
69 | + * @return bool |
|
70 | + */ |
|
71 | + public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
72 | + { |
|
73 | + global $wp_version; |
|
74 | + return version_compare( |
|
75 | + // first account for wp_version being pre-release |
|
76 | + // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
77 | + strpos($wp_version, '-') > 0 |
|
78 | + ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
79 | + : $wp_version, |
|
80 | + $version_to_check, |
|
81 | + $operator |
|
82 | + ); |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * _minimum_wp_version_required |
|
89 | + * |
|
90 | + * @access private |
|
91 | + * @return boolean |
|
92 | + */ |
|
93 | + private function _minimum_wp_version_required() |
|
94 | + { |
|
95 | + return EE_Recommended_Versions::check_wp_version(); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * _check_php_version |
|
102 | + * |
|
103 | + * @access private |
|
104 | + * @param string $min_version |
|
105 | + * @return boolean |
|
106 | + */ |
|
107 | + private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
108 | + { |
|
109 | + return version_compare(PHP_VERSION, $min_version, '>='); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * _minimum_php_version_recommended |
|
116 | + * |
|
117 | + * @access private |
|
118 | + * @return boolean |
|
119 | + */ |
|
120 | + private function _minimum_php_version_recommended() |
|
121 | + { |
|
122 | + return $this->_check_php_version(); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * Returns whether the provided php version number is greater than the current version of php installed on the server. |
|
128 | + * @param string $version_required |
|
129 | + * @return bool |
|
130 | + */ |
|
131 | + private function upcomingRequiredPhpVersion($version_required = '5.5') |
|
132 | + { |
|
133 | + return $this->_check_php_version($version_required); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * minimum_wp_version_error |
|
140 | + * |
|
141 | + * @return void |
|
142 | + */ |
|
143 | + public function minimum_wp_version_error() |
|
144 | + { |
|
145 | + global $wp_version; |
|
146 | + ?> |
|
147 | 147 | <div class="error"> |
148 | 148 | <p> |
149 | 149 | <?php |
150 | - printf( |
|
151 | - __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
152 | - 'event_espresso'), |
|
153 | - EE_MIN_WP_VER_REQUIRED, |
|
154 | - $wp_version, |
|
155 | - '<br/>', |
|
156 | - '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
157 | - ); |
|
158 | - ?> |
|
150 | + printf( |
|
151 | + __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
152 | + 'event_espresso'), |
|
153 | + EE_MIN_WP_VER_REQUIRED, |
|
154 | + $wp_version, |
|
155 | + '<br/>', |
|
156 | + '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
157 | + ); |
|
158 | + ?> |
|
159 | 159 | </p> |
160 | 160 | </div> |
161 | 161 | <?php |
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * _display_minimum_recommended_php_version_notice |
|
168 | - * |
|
169 | - * @access private |
|
170 | - * @return void |
|
171 | - * @throws InvalidDataTypeException |
|
172 | - */ |
|
173 | - private function _display_minimum_recommended_php_version_notice() |
|
174 | - { |
|
175 | - if($this->_request->isAdmin()){ |
|
176 | - new PersistentAdminNotice( |
|
177 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
178 | - sprintf( |
|
179 | - __( |
|
180 | - 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
|
181 | - 'event_espresso' |
|
182 | - ), |
|
183 | - EE_MIN_PHP_VER_RECOMMENDED, |
|
184 | - PHP_VERSION, |
|
185 | - '<br/>', |
|
186 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
187 | - ) |
|
188 | - ); |
|
189 | - } |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
195 | - */ |
|
196 | - private function displayUpcomingRequiredVersion() |
|
197 | - { |
|
198 | - if ($this->_request->isAdmin() |
|
199 | - && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->_request) |
|
200 | - && current_user_can('update_plugins') |
|
201 | - ) { |
|
202 | - add_action('admin_notices', function () { |
|
203 | - echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
204 | - . sprintf( |
|
205 | - esc_html__( |
|
206 | - 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
207 | - 'event_espresso' |
|
208 | - ), |
|
209 | - '<strong>', |
|
210 | - '</strong>', |
|
211 | - PHP_VERSION, |
|
212 | - '<a href="https://wordpress.org/support/upgrade-php/">', |
|
213 | - '</a>' |
|
214 | - ) |
|
215 | - . '</p></div>'; |
|
216 | - }); |
|
217 | - } |
|
218 | - } |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * _display_minimum_recommended_php_version_notice |
|
168 | + * |
|
169 | + * @access private |
|
170 | + * @return void |
|
171 | + * @throws InvalidDataTypeException |
|
172 | + */ |
|
173 | + private function _display_minimum_recommended_php_version_notice() |
|
174 | + { |
|
175 | + if($this->_request->isAdmin()){ |
|
176 | + new PersistentAdminNotice( |
|
177 | + 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
178 | + sprintf( |
|
179 | + __( |
|
180 | + 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
|
181 | + 'event_espresso' |
|
182 | + ), |
|
183 | + EE_MIN_PHP_VER_RECOMMENDED, |
|
184 | + PHP_VERSION, |
|
185 | + '<br/>', |
|
186 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
187 | + ) |
|
188 | + ); |
|
189 | + } |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
195 | + */ |
|
196 | + private function displayUpcomingRequiredVersion() |
|
197 | + { |
|
198 | + if ($this->_request->isAdmin() |
|
199 | + && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->_request) |
|
200 | + && current_user_can('update_plugins') |
|
201 | + ) { |
|
202 | + add_action('admin_notices', function () { |
|
203 | + echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
204 | + . sprintf( |
|
205 | + esc_html__( |
|
206 | + 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
207 | + 'event_espresso' |
|
208 | + ), |
|
209 | + '<strong>', |
|
210 | + '</strong>', |
|
211 | + PHP_VERSION, |
|
212 | + '<a href="https://wordpress.org/support/upgrade-php/">', |
|
213 | + '</a>' |
|
214 | + ) |
|
215 | + . '</p></div>'; |
|
216 | + }); |
|
217 | + } |
|
218 | + } |
|
219 | 219 | } |
@@ -8,644 +8,644 @@ |
||
8 | 8 | class EE_Email_messenger extends EE_messenger |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * To field for email |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $_to = ''; |
|
16 | - |
|
17 | - |
|
18 | - /** |
|
19 | - * CC field for email. |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $_cc = ''; |
|
23 | - |
|
24 | - /** |
|
25 | - * From field for email |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $_from = ''; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * Subject field for email |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - protected $_subject = ''; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * Content field for email |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - protected $_content = ''; |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * constructor |
|
47 | - * |
|
48 | - * @access public |
|
49 | - */ |
|
50 | - public function __construct() |
|
51 | - { |
|
52 | - //set name and description properties |
|
53 | - $this->name = 'email'; |
|
54 | - $this->description = sprintf( |
|
55 | - esc_html__( |
|
56 | - 'This messenger delivers messages via email using the built-in %s function included with WordPress', |
|
57 | - 'event_espresso' |
|
58 | - ), |
|
59 | - '<code>wp_mail</code>' |
|
60 | - ); |
|
61 | - $this->label = array( |
|
62 | - 'singular' => esc_html__('email', 'event_espresso'), |
|
63 | - 'plural' => esc_html__('emails', 'event_espresso'), |
|
64 | - ); |
|
65 | - $this->activate_on_install = true; |
|
66 | - |
|
67 | - //we're using defaults so let's call parent constructor that will take care of setting up all the other |
|
68 | - // properties |
|
69 | - parent::__construct(); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * see abstract declaration in parent class for details. |
|
75 | - */ |
|
76 | - protected function _set_admin_pages() |
|
77 | - { |
|
78 | - $this->admin_registered_pages = array( |
|
79 | - 'events_edit' => true, |
|
80 | - ); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * see abstract declaration in parent class for details |
|
86 | - */ |
|
87 | - protected function _set_valid_shortcodes() |
|
88 | - { |
|
89 | - //remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the |
|
90 | - // message type. |
|
91 | - $this->_valid_shortcodes = array( |
|
92 | - 'to' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
93 | - 'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
94 | - 'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
95 | - ); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * see abstract declaration in parent class for details |
|
101 | - * |
|
102 | - * @access protected |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - protected function _set_validator_config() |
|
106 | - { |
|
107 | - $valid_shortcodes = $this->get_valid_shortcodes(); |
|
108 | - |
|
109 | - $this->_validator_config = array( |
|
110 | - 'to' => array( |
|
111 | - 'shortcodes' => $valid_shortcodes['to'], |
|
112 | - 'type' => 'email', |
|
113 | - ), |
|
114 | - 'cc' => array( |
|
115 | - 'shortcodes' => $valid_shortcodes['to'], |
|
116 | - 'type' => 'email', |
|
117 | - ), |
|
118 | - 'from' => array( |
|
119 | - 'shortcodes' => $valid_shortcodes['from'], |
|
120 | - 'type' => 'email', |
|
121 | - ), |
|
122 | - 'subject' => array( |
|
123 | - 'shortcodes' => array( |
|
124 | - 'organization', |
|
125 | - 'primary_registration_details', |
|
126 | - 'event_author', |
|
127 | - 'primary_registration_details', |
|
128 | - 'recipient_details', |
|
129 | - ), |
|
130 | - ), |
|
131 | - 'content' => array( |
|
132 | - 'shortcodes' => array( |
|
133 | - 'event_list', |
|
134 | - 'attendee_list', |
|
135 | - 'ticket_list', |
|
136 | - 'organization', |
|
137 | - 'primary_registration_details', |
|
138 | - 'primary_registration_list', |
|
139 | - 'event_author', |
|
140 | - 'recipient_details', |
|
141 | - 'recipient_list', |
|
142 | - 'transaction', |
|
143 | - 'messenger', |
|
144 | - ), |
|
145 | - ), |
|
146 | - 'attendee_list' => array( |
|
147 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
148 | - 'required' => array('[ATTENDEE_LIST]'), |
|
149 | - ), |
|
150 | - 'event_list' => array( |
|
151 | - 'shortcodes' => array( |
|
152 | - 'event', |
|
153 | - 'attendee_list', |
|
154 | - 'ticket_list', |
|
155 | - 'venue', |
|
156 | - 'datetime_list', |
|
157 | - 'attendee', |
|
158 | - 'primary_registration_details', |
|
159 | - 'primary_registration_list', |
|
160 | - 'event_author', |
|
161 | - 'recipient_details', |
|
162 | - 'recipient_list', |
|
163 | - ), |
|
164 | - 'required' => array('[EVENT_LIST]'), |
|
165 | - ), |
|
166 | - 'ticket_list' => array( |
|
167 | - 'shortcodes' => array( |
|
168 | - 'event_list', |
|
169 | - 'attendee_list', |
|
170 | - 'ticket', |
|
171 | - 'datetime_list', |
|
172 | - 'primary_registration_details', |
|
173 | - 'recipient_details', |
|
174 | - ), |
|
175 | - 'required' => array('[TICKET_LIST]'), |
|
176 | - ), |
|
177 | - 'datetime_list' => array( |
|
178 | - 'shortcodes' => array('datetime'), |
|
179 | - 'required' => array('[DATETIME_LIST]'), |
|
180 | - ), |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * @see parent EE_messenger class for docs |
|
187 | - * @since 4.5.0 |
|
188 | - */ |
|
189 | - public function do_secondary_messenger_hooks($sending_messenger_name) |
|
190 | - { |
|
191 | - if ($sending_messenger_name = 'html') { |
|
192 | - add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - public function add_email_css( |
|
198 | - $variation_path, |
|
199 | - $messenger, |
|
200 | - $message_type, |
|
201 | - $type, |
|
202 | - $variation, |
|
203 | - $file_extension, |
|
204 | - $url, |
|
205 | - EE_Messages_Template_Pack $template_pack |
|
206 | - ) { |
|
207 | - //prevent recursion on this callback. |
|
208 | - remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10); |
|
209 | - $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false); |
|
210 | - |
|
211 | - add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
212 | - return $variation; |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * See parent for details |
|
218 | - * |
|
219 | - * @access protected |
|
220 | - * @return void |
|
221 | - */ |
|
222 | - protected function _set_test_settings_fields() |
|
223 | - { |
|
224 | - $this->_test_settings_fields = array( |
|
225 | - 'to' => array( |
|
226 | - 'input' => 'text', |
|
227 | - 'label' => esc_html__('Send a test email to', 'event_espresso'), |
|
228 | - 'type' => 'email', |
|
229 | - 'required' => true, |
|
230 | - 'validation' => true, |
|
231 | - 'css_class' => 'large-text', |
|
232 | - 'format' => '%s', |
|
233 | - 'default' => get_bloginfo('admin_email'), |
|
234 | - ), |
|
235 | - 'subject' => array( |
|
236 | - 'input' => 'hidden', |
|
237 | - 'label' => '', |
|
238 | - 'type' => 'string', |
|
239 | - 'required' => false, |
|
240 | - 'validation' => false, |
|
241 | - 'format' => '%s', |
|
242 | - 'value' => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')), |
|
243 | - 'default' => '', |
|
244 | - 'css_class' => '', |
|
245 | - ), |
|
246 | - ); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * _set_template_fields |
|
252 | - * This sets up the fields that a messenger requires for the message to go out. |
|
253 | - * |
|
254 | - * @access protected |
|
255 | - * @return void |
|
256 | - */ |
|
257 | - protected function _set_template_fields() |
|
258 | - { |
|
259 | - // any extra template fields that are NOT used by the messenger but will get used by a messenger field for |
|
260 | - // shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field |
|
261 | - // they relate to. This is important for the Messages_admin to know what fields to display to the user. |
|
262 | - // Also, notice that the "values" are equal to the field type that messages admin will use to know what |
|
263 | - // kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array |
|
264 | - // indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be |
|
265 | - // displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and |
|
266 | - // will not be displayed/parsed. |
|
267 | - $this->_template_fields = array( |
|
268 | - 'to' => array( |
|
269 | - 'input' => 'text', |
|
270 | - 'label' => esc_html_x( |
|
271 | - 'To', |
|
272 | - 'Label for the "To" field for email addresses', |
|
273 | - 'event_espresso' |
|
274 | - ), |
|
275 | - 'type' => 'string', |
|
276 | - 'required' => true, |
|
277 | - 'validation' => true, |
|
278 | - 'css_class' => 'large-text', |
|
279 | - 'format' => '%s', |
|
280 | - ), |
|
281 | - 'cc' => array( |
|
282 | - 'input' => 'text', |
|
283 | - 'label' => esc_html_x( |
|
284 | - 'CC', |
|
285 | - 'Label for the "Carbon Copy" field used for additional email addresses', |
|
286 | - 'event_espresso' |
|
287 | - ), |
|
288 | - 'type' => 'string', |
|
289 | - 'required' => false, |
|
290 | - 'validation' => true, |
|
291 | - 'css_class' => 'large-text', |
|
292 | - 'format' => '%s', |
|
293 | - ), |
|
294 | - 'from' => array( |
|
295 | - 'input' => 'text', |
|
296 | - 'label' => esc_html_x( |
|
297 | - 'From', |
|
298 | - 'Label for the "From" field for email addresses.', |
|
299 | - 'event_espresso' |
|
300 | - ), |
|
301 | - 'type' => 'string', |
|
302 | - 'required' => true, |
|
303 | - 'validation' => true, |
|
304 | - 'css_class' => 'large-text', |
|
305 | - 'format' => '%s', |
|
306 | - ), |
|
307 | - 'subject' => array( |
|
308 | - 'input' => 'text', |
|
309 | - 'label' => esc_html_x( |
|
310 | - 'Subject', |
|
311 | - 'Label for the "Subject" field (short description of contents) for emails.', |
|
312 | - 'event_espresso' |
|
313 | - ), |
|
314 | - 'type' => 'string', |
|
315 | - 'required' => true, |
|
316 | - 'validation' => true, |
|
317 | - 'css_class' => 'large-text', |
|
318 | - 'format' => '%s', |
|
319 | - ), |
|
320 | - 'content' => '', |
|
321 | - //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
322 | - 'extra' => array( |
|
323 | - 'content' => array( |
|
324 | - 'main' => array( |
|
325 | - 'input' => 'wp_editor', |
|
326 | - 'label' => esc_html__('Main Content', 'event_espresso'), |
|
327 | - 'type' => 'string', |
|
328 | - 'required' => true, |
|
329 | - 'validation' => true, |
|
330 | - 'format' => '%s', |
|
331 | - 'rows' => '15', |
|
332 | - ), |
|
333 | - 'event_list' => array( |
|
334 | - 'input' => 'wp_editor', |
|
335 | - 'label' => '[EVENT_LIST]', |
|
336 | - 'type' => 'string', |
|
337 | - 'required' => true, |
|
338 | - 'validation' => true, |
|
339 | - 'format' => '%s', |
|
340 | - 'rows' => '15', |
|
341 | - 'shortcodes_required' => array('[EVENT_LIST]'), |
|
342 | - ), |
|
343 | - 'attendee_list' => array( |
|
344 | - 'input' => 'textarea', |
|
345 | - 'label' => '[ATTENDEE_LIST]', |
|
346 | - 'type' => 'string', |
|
347 | - 'required' => true, |
|
348 | - 'validation' => true, |
|
349 | - 'format' => '%s', |
|
350 | - 'css_class' => 'large-text', |
|
351 | - 'rows' => '5', |
|
352 | - 'shortcodes_required' => array('[ATTENDEE_LIST]'), |
|
353 | - ), |
|
354 | - 'ticket_list' => array( |
|
355 | - 'input' => 'textarea', |
|
356 | - 'label' => '[TICKET_LIST]', |
|
357 | - 'type' => 'string', |
|
358 | - 'required' => true, |
|
359 | - 'validation' => true, |
|
360 | - 'format' => '%s', |
|
361 | - 'css_class' => 'large-text', |
|
362 | - 'rows' => '10', |
|
363 | - 'shortcodes_required' => array('[TICKET_LIST]'), |
|
364 | - ), |
|
365 | - 'datetime_list' => array( |
|
366 | - 'input' => 'textarea', |
|
367 | - 'label' => '[DATETIME_LIST]', |
|
368 | - 'type' => 'string', |
|
369 | - 'required' => true, |
|
370 | - 'validation' => true, |
|
371 | - 'format' => '%s', |
|
372 | - 'css_class' => 'large-text', |
|
373 | - 'rows' => '10', |
|
374 | - 'shortcodes_required' => array('[DATETIME_LIST]'), |
|
375 | - ), |
|
376 | - ), |
|
377 | - ), |
|
378 | - ); |
|
379 | - } |
|
380 | - |
|
381 | - |
|
382 | - /** |
|
383 | - * See definition of this class in parent |
|
384 | - */ |
|
385 | - protected function _set_default_message_types() |
|
386 | - { |
|
387 | - $this->_default_message_types = array( |
|
388 | - 'payment', |
|
389 | - 'payment_refund', |
|
390 | - 'registration', |
|
391 | - 'not_approved_registration', |
|
392 | - 'pending_approval', |
|
393 | - ); |
|
394 | - } |
|
395 | - |
|
396 | - |
|
397 | - /** |
|
398 | - * @see definition of this class in parent |
|
399 | - * @since 4.5.0 |
|
400 | - */ |
|
401 | - protected function _set_valid_message_types() |
|
402 | - { |
|
403 | - $this->_valid_message_types = array( |
|
404 | - 'payment', |
|
405 | - 'registration', |
|
406 | - 'not_approved_registration', |
|
407 | - 'declined_registration', |
|
408 | - 'cancelled_registration', |
|
409 | - 'pending_approval', |
|
410 | - 'registration_summary', |
|
411 | - 'payment_reminder', |
|
412 | - 'payment_declined', |
|
413 | - 'payment_refund', |
|
414 | - ); |
|
415 | - } |
|
416 | - |
|
417 | - |
|
418 | - /** |
|
419 | - * setting up admin_settings_fields for messenger. |
|
420 | - */ |
|
421 | - protected function _set_admin_settings_fields() |
|
422 | - { |
|
423 | - } |
|
424 | - |
|
425 | - /** |
|
426 | - * We just deliver the messages don't kill us!! |
|
427 | - * |
|
428 | - * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if |
|
429 | - * present. |
|
430 | - * @throws EE_Error |
|
431 | - * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
432 | - */ |
|
433 | - protected function _send_message() |
|
434 | - { |
|
435 | - $success = wp_mail( |
|
436 | - $this->_to, |
|
437 | - //some old values for subject may be expecting HTML entities to be decoded in the subject |
|
438 | - //and subjects aren't interpreted as HTML, so there should be no HTML in them |
|
439 | - wp_strip_all_tags(wp_specialchars_decode($this->_subject, ENT_QUOTES)), |
|
440 | - $this->_body(), |
|
441 | - $this->_headers() |
|
442 | - ); |
|
443 | - if (! $success) { |
|
444 | - EE_Error::add_error( |
|
445 | - sprintf( |
|
446 | - esc_html__( |
|
447 | - 'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', |
|
448 | - 'event_espresso' |
|
449 | - ), |
|
450 | - $this->_to, |
|
451 | - $this->_from, |
|
452 | - '<br />' |
|
453 | - ), |
|
454 | - __FILE__, |
|
455 | - __FUNCTION__, |
|
456 | - __LINE__ |
|
457 | - ); |
|
458 | - } |
|
459 | - return $success; |
|
460 | - } |
|
461 | - |
|
462 | - |
|
463 | - /** |
|
464 | - * see parent for definition |
|
465 | - * |
|
466 | - * @return string html body of the message content and the related css. |
|
467 | - * @throws EE_Error |
|
468 | - * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
469 | - */ |
|
470 | - protected function _preview() |
|
471 | - { |
|
472 | - return $this->_body(true); |
|
473 | - } |
|
474 | - |
|
475 | - |
|
476 | - /** |
|
477 | - * Setup headers for email |
|
478 | - * |
|
479 | - * @access protected |
|
480 | - * @return string formatted header for email |
|
481 | - */ |
|
482 | - protected function _headers() |
|
483 | - { |
|
484 | - $this->_ensure_has_from_email_address(); |
|
485 | - $from = $this->_from; |
|
486 | - $headers = array( |
|
487 | - 'From:' . $from, |
|
488 | - 'Reply-To:' . $from, |
|
489 | - 'Content-Type:text/html; charset=utf-8', |
|
490 | - ); |
|
491 | - |
|
492 | - if (! empty($this->_cc)) { |
|
493 | - $headers[] = 'cc: ' . $this->_cc; |
|
494 | - } |
|
495 | - |
|
496 | - //but wait! Header's for the from is NOT reliable because some plugins don't respect From: as set in the |
|
497 | - // header. |
|
498 | - add_filter('wp_mail_from', array($this, 'set_from_address'), 100); |
|
499 | - add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100); |
|
500 | - return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this); |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - /** |
|
505 | - * This simply ensures that the from address is not empty. If it is, then we use whatever is set as the site email |
|
506 | - * address for the from address to avoid problems with sending emails. |
|
507 | - */ |
|
508 | - protected function _ensure_has_from_email_address() |
|
509 | - { |
|
510 | - if (empty($this->_from)) { |
|
511 | - $this->_from = get_bloginfo('admin_email'); |
|
512 | - } |
|
513 | - } |
|
514 | - |
|
515 | - |
|
516 | - /** |
|
517 | - * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}> |
|
518 | - * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY* |
|
519 | - * be empty |
|
520 | - * |
|
521 | - * @since 4.3.1 |
|
522 | - * @return array |
|
523 | - */ |
|
524 | - private function _parse_from() |
|
525 | - { |
|
526 | - if (strpos($this->_from, '<') !== false) { |
|
527 | - $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1); |
|
528 | - $from_name = str_replace('"', '', $from_name); |
|
529 | - $from_name = trim($from_name); |
|
530 | - |
|
531 | - $from_email = substr($this->_from, strpos($this->_from, '<') + 1); |
|
532 | - $from_email = str_replace('>', '', $from_email); |
|
533 | - $from_email = trim($from_email); |
|
534 | - } elseif (trim($this->_from) !== '') { |
|
535 | - $from_name = ''; |
|
536 | - $from_email = trim($this->_from); |
|
537 | - } else { |
|
538 | - $from_name = $from_email = ''; |
|
539 | - } |
|
540 | - return array($from_name, $from_email); |
|
541 | - } |
|
542 | - |
|
543 | - |
|
544 | - /** |
|
545 | - * Callback for the wp_mail_from filter. |
|
546 | - * |
|
547 | - * @since 4.3.1 |
|
548 | - * @param string $from_email What the original from_email is. |
|
549 | - * @return string |
|
550 | - */ |
|
551 | - public function set_from_address($from_email) |
|
552 | - { |
|
553 | - $parsed_from = $this->_parse_from(); |
|
554 | - //includes fallback if the parsing failed. |
|
555 | - $from_email = is_array($parsed_from) && ! empty($parsed_from[1]) |
|
556 | - ? $parsed_from[1] |
|
557 | - : get_bloginfo('admin_email'); |
|
558 | - return $from_email; |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - /** |
|
563 | - * Callback fro the wp_mail_from_name filter. |
|
564 | - * |
|
565 | - * @since 4.3.1 |
|
566 | - * @param string $from_name The original from_name. |
|
567 | - * @return string |
|
568 | - */ |
|
569 | - public function set_from_name($from_name) |
|
570 | - { |
|
571 | - $parsed_from = $this->_parse_from(); |
|
572 | - if (is_array($parsed_from) && ! empty($parsed_from[0])) { |
|
573 | - $from_name = $parsed_from[0]; |
|
574 | - } |
|
575 | - |
|
576 | - //if from name is "WordPress" let's sub in the site name instead (more friendly!) |
|
577 | - //but realize the default name is HTML entity-encoded |
|
578 | - $from_name = $from_name == 'WordPress' ? wp_specialchars_decode(get_bloginfo(), ENT_QUOTES) : $from_name; |
|
579 | - |
|
580 | - return $from_name; |
|
581 | - } |
|
582 | - |
|
583 | - |
|
584 | - /** |
|
585 | - * setup body for email |
|
586 | - * |
|
587 | - * @param bool $preview will determine whether this is preview template or not. |
|
588 | - * @return string formatted body for email. |
|
589 | - * @throws EE_Error |
|
590 | - * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
591 | - */ |
|
592 | - protected function _body($preview = false) |
|
593 | - { |
|
594 | - //setup template args! |
|
595 | - $this->_template_args = array( |
|
596 | - 'subject' => $this->_subject, |
|
597 | - 'from' => $this->_from, |
|
598 | - 'main_body' => wpautop($this->_content), |
|
599 | - ); |
|
600 | - $body = $this->_get_main_template($preview); |
|
601 | - |
|
602 | - /** |
|
603 | - * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched. |
|
604 | - * |
|
605 | - * @type bool $preview Indicates whether a preview is being generated or not. |
|
606 | - * @return bool true indicates to use the inliner, false bypasses it. |
|
607 | - */ |
|
608 | - if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) { |
|
609 | - //require CssToInlineStyles library and its dependencies via composer autoloader |
|
610 | - require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php'; |
|
611 | - |
|
612 | - //now if this isn't a preview, let's setup the body so it has inline styles |
|
613 | - if (! $preview || ($preview && defined('DOING_AJAX'))) { |
|
614 | - $style = file_get_contents( |
|
615 | - $this->get_variation( |
|
616 | - $this->_tmp_pack, |
|
617 | - $this->_incoming_message_type->name, |
|
618 | - false, |
|
619 | - 'main', |
|
620 | - $this->_variation |
|
621 | - ), |
|
622 | - true |
|
623 | - ); |
|
624 | - $CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style); |
|
625 | - //for some reason the library has a bracket and new line at the beginning. This takes care of that. |
|
626 | - $body = ltrim($CSS->convert(true), ">\n"); |
|
627 | - //see https://events.codebasehq.com/projects/event-espresso/tickets/8609 |
|
628 | - $body = ltrim($body, "<?"); |
|
629 | - } |
|
630 | - |
|
631 | - } |
|
632 | - return $body; |
|
633 | - } |
|
634 | - |
|
635 | - |
|
636 | - /** |
|
637 | - * This just returns any existing test settings that might be saved in the database |
|
638 | - * |
|
639 | - * @access public |
|
640 | - * @return array |
|
641 | - */ |
|
642 | - public function get_existing_test_settings() |
|
643 | - { |
|
644 | - $settings = parent::get_existing_test_settings(); |
|
645 | - //override subject if present because we always want it to be fresh. |
|
646 | - if (is_array($settings) && ! empty($settings['subject'])) { |
|
647 | - $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')); |
|
648 | - } |
|
649 | - return $settings; |
|
650 | - } |
|
11 | + /** |
|
12 | + * To field for email |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $_to = ''; |
|
16 | + |
|
17 | + |
|
18 | + /** |
|
19 | + * CC field for email. |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $_cc = ''; |
|
23 | + |
|
24 | + /** |
|
25 | + * From field for email |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $_from = ''; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * Subject field for email |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + protected $_subject = ''; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * Content field for email |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + protected $_content = ''; |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * constructor |
|
47 | + * |
|
48 | + * @access public |
|
49 | + */ |
|
50 | + public function __construct() |
|
51 | + { |
|
52 | + //set name and description properties |
|
53 | + $this->name = 'email'; |
|
54 | + $this->description = sprintf( |
|
55 | + esc_html__( |
|
56 | + 'This messenger delivers messages via email using the built-in %s function included with WordPress', |
|
57 | + 'event_espresso' |
|
58 | + ), |
|
59 | + '<code>wp_mail</code>' |
|
60 | + ); |
|
61 | + $this->label = array( |
|
62 | + 'singular' => esc_html__('email', 'event_espresso'), |
|
63 | + 'plural' => esc_html__('emails', 'event_espresso'), |
|
64 | + ); |
|
65 | + $this->activate_on_install = true; |
|
66 | + |
|
67 | + //we're using defaults so let's call parent constructor that will take care of setting up all the other |
|
68 | + // properties |
|
69 | + parent::__construct(); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * see abstract declaration in parent class for details. |
|
75 | + */ |
|
76 | + protected function _set_admin_pages() |
|
77 | + { |
|
78 | + $this->admin_registered_pages = array( |
|
79 | + 'events_edit' => true, |
|
80 | + ); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * see abstract declaration in parent class for details |
|
86 | + */ |
|
87 | + protected function _set_valid_shortcodes() |
|
88 | + { |
|
89 | + //remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the |
|
90 | + // message type. |
|
91 | + $this->_valid_shortcodes = array( |
|
92 | + 'to' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
93 | + 'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
94 | + 'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
95 | + ); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * see abstract declaration in parent class for details |
|
101 | + * |
|
102 | + * @access protected |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + protected function _set_validator_config() |
|
106 | + { |
|
107 | + $valid_shortcodes = $this->get_valid_shortcodes(); |
|
108 | + |
|
109 | + $this->_validator_config = array( |
|
110 | + 'to' => array( |
|
111 | + 'shortcodes' => $valid_shortcodes['to'], |
|
112 | + 'type' => 'email', |
|
113 | + ), |
|
114 | + 'cc' => array( |
|
115 | + 'shortcodes' => $valid_shortcodes['to'], |
|
116 | + 'type' => 'email', |
|
117 | + ), |
|
118 | + 'from' => array( |
|
119 | + 'shortcodes' => $valid_shortcodes['from'], |
|
120 | + 'type' => 'email', |
|
121 | + ), |
|
122 | + 'subject' => array( |
|
123 | + 'shortcodes' => array( |
|
124 | + 'organization', |
|
125 | + 'primary_registration_details', |
|
126 | + 'event_author', |
|
127 | + 'primary_registration_details', |
|
128 | + 'recipient_details', |
|
129 | + ), |
|
130 | + ), |
|
131 | + 'content' => array( |
|
132 | + 'shortcodes' => array( |
|
133 | + 'event_list', |
|
134 | + 'attendee_list', |
|
135 | + 'ticket_list', |
|
136 | + 'organization', |
|
137 | + 'primary_registration_details', |
|
138 | + 'primary_registration_list', |
|
139 | + 'event_author', |
|
140 | + 'recipient_details', |
|
141 | + 'recipient_list', |
|
142 | + 'transaction', |
|
143 | + 'messenger', |
|
144 | + ), |
|
145 | + ), |
|
146 | + 'attendee_list' => array( |
|
147 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
148 | + 'required' => array('[ATTENDEE_LIST]'), |
|
149 | + ), |
|
150 | + 'event_list' => array( |
|
151 | + 'shortcodes' => array( |
|
152 | + 'event', |
|
153 | + 'attendee_list', |
|
154 | + 'ticket_list', |
|
155 | + 'venue', |
|
156 | + 'datetime_list', |
|
157 | + 'attendee', |
|
158 | + 'primary_registration_details', |
|
159 | + 'primary_registration_list', |
|
160 | + 'event_author', |
|
161 | + 'recipient_details', |
|
162 | + 'recipient_list', |
|
163 | + ), |
|
164 | + 'required' => array('[EVENT_LIST]'), |
|
165 | + ), |
|
166 | + 'ticket_list' => array( |
|
167 | + 'shortcodes' => array( |
|
168 | + 'event_list', |
|
169 | + 'attendee_list', |
|
170 | + 'ticket', |
|
171 | + 'datetime_list', |
|
172 | + 'primary_registration_details', |
|
173 | + 'recipient_details', |
|
174 | + ), |
|
175 | + 'required' => array('[TICKET_LIST]'), |
|
176 | + ), |
|
177 | + 'datetime_list' => array( |
|
178 | + 'shortcodes' => array('datetime'), |
|
179 | + 'required' => array('[DATETIME_LIST]'), |
|
180 | + ), |
|
181 | + ); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * @see parent EE_messenger class for docs |
|
187 | + * @since 4.5.0 |
|
188 | + */ |
|
189 | + public function do_secondary_messenger_hooks($sending_messenger_name) |
|
190 | + { |
|
191 | + if ($sending_messenger_name = 'html') { |
|
192 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + public function add_email_css( |
|
198 | + $variation_path, |
|
199 | + $messenger, |
|
200 | + $message_type, |
|
201 | + $type, |
|
202 | + $variation, |
|
203 | + $file_extension, |
|
204 | + $url, |
|
205 | + EE_Messages_Template_Pack $template_pack |
|
206 | + ) { |
|
207 | + //prevent recursion on this callback. |
|
208 | + remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10); |
|
209 | + $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false); |
|
210 | + |
|
211 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
212 | + return $variation; |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * See parent for details |
|
218 | + * |
|
219 | + * @access protected |
|
220 | + * @return void |
|
221 | + */ |
|
222 | + protected function _set_test_settings_fields() |
|
223 | + { |
|
224 | + $this->_test_settings_fields = array( |
|
225 | + 'to' => array( |
|
226 | + 'input' => 'text', |
|
227 | + 'label' => esc_html__('Send a test email to', 'event_espresso'), |
|
228 | + 'type' => 'email', |
|
229 | + 'required' => true, |
|
230 | + 'validation' => true, |
|
231 | + 'css_class' => 'large-text', |
|
232 | + 'format' => '%s', |
|
233 | + 'default' => get_bloginfo('admin_email'), |
|
234 | + ), |
|
235 | + 'subject' => array( |
|
236 | + 'input' => 'hidden', |
|
237 | + 'label' => '', |
|
238 | + 'type' => 'string', |
|
239 | + 'required' => false, |
|
240 | + 'validation' => false, |
|
241 | + 'format' => '%s', |
|
242 | + 'value' => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')), |
|
243 | + 'default' => '', |
|
244 | + 'css_class' => '', |
|
245 | + ), |
|
246 | + ); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * _set_template_fields |
|
252 | + * This sets up the fields that a messenger requires for the message to go out. |
|
253 | + * |
|
254 | + * @access protected |
|
255 | + * @return void |
|
256 | + */ |
|
257 | + protected function _set_template_fields() |
|
258 | + { |
|
259 | + // any extra template fields that are NOT used by the messenger but will get used by a messenger field for |
|
260 | + // shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field |
|
261 | + // they relate to. This is important for the Messages_admin to know what fields to display to the user. |
|
262 | + // Also, notice that the "values" are equal to the field type that messages admin will use to know what |
|
263 | + // kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array |
|
264 | + // indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be |
|
265 | + // displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and |
|
266 | + // will not be displayed/parsed. |
|
267 | + $this->_template_fields = array( |
|
268 | + 'to' => array( |
|
269 | + 'input' => 'text', |
|
270 | + 'label' => esc_html_x( |
|
271 | + 'To', |
|
272 | + 'Label for the "To" field for email addresses', |
|
273 | + 'event_espresso' |
|
274 | + ), |
|
275 | + 'type' => 'string', |
|
276 | + 'required' => true, |
|
277 | + 'validation' => true, |
|
278 | + 'css_class' => 'large-text', |
|
279 | + 'format' => '%s', |
|
280 | + ), |
|
281 | + 'cc' => array( |
|
282 | + 'input' => 'text', |
|
283 | + 'label' => esc_html_x( |
|
284 | + 'CC', |
|
285 | + 'Label for the "Carbon Copy" field used for additional email addresses', |
|
286 | + 'event_espresso' |
|
287 | + ), |
|
288 | + 'type' => 'string', |
|
289 | + 'required' => false, |
|
290 | + 'validation' => true, |
|
291 | + 'css_class' => 'large-text', |
|
292 | + 'format' => '%s', |
|
293 | + ), |
|
294 | + 'from' => array( |
|
295 | + 'input' => 'text', |
|
296 | + 'label' => esc_html_x( |
|
297 | + 'From', |
|
298 | + 'Label for the "From" field for email addresses.', |
|
299 | + 'event_espresso' |
|
300 | + ), |
|
301 | + 'type' => 'string', |
|
302 | + 'required' => true, |
|
303 | + 'validation' => true, |
|
304 | + 'css_class' => 'large-text', |
|
305 | + 'format' => '%s', |
|
306 | + ), |
|
307 | + 'subject' => array( |
|
308 | + 'input' => 'text', |
|
309 | + 'label' => esc_html_x( |
|
310 | + 'Subject', |
|
311 | + 'Label for the "Subject" field (short description of contents) for emails.', |
|
312 | + 'event_espresso' |
|
313 | + ), |
|
314 | + 'type' => 'string', |
|
315 | + 'required' => true, |
|
316 | + 'validation' => true, |
|
317 | + 'css_class' => 'large-text', |
|
318 | + 'format' => '%s', |
|
319 | + ), |
|
320 | + 'content' => '', |
|
321 | + //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
322 | + 'extra' => array( |
|
323 | + 'content' => array( |
|
324 | + 'main' => array( |
|
325 | + 'input' => 'wp_editor', |
|
326 | + 'label' => esc_html__('Main Content', 'event_espresso'), |
|
327 | + 'type' => 'string', |
|
328 | + 'required' => true, |
|
329 | + 'validation' => true, |
|
330 | + 'format' => '%s', |
|
331 | + 'rows' => '15', |
|
332 | + ), |
|
333 | + 'event_list' => array( |
|
334 | + 'input' => 'wp_editor', |
|
335 | + 'label' => '[EVENT_LIST]', |
|
336 | + 'type' => 'string', |
|
337 | + 'required' => true, |
|
338 | + 'validation' => true, |
|
339 | + 'format' => '%s', |
|
340 | + 'rows' => '15', |
|
341 | + 'shortcodes_required' => array('[EVENT_LIST]'), |
|
342 | + ), |
|
343 | + 'attendee_list' => array( |
|
344 | + 'input' => 'textarea', |
|
345 | + 'label' => '[ATTENDEE_LIST]', |
|
346 | + 'type' => 'string', |
|
347 | + 'required' => true, |
|
348 | + 'validation' => true, |
|
349 | + 'format' => '%s', |
|
350 | + 'css_class' => 'large-text', |
|
351 | + 'rows' => '5', |
|
352 | + 'shortcodes_required' => array('[ATTENDEE_LIST]'), |
|
353 | + ), |
|
354 | + 'ticket_list' => array( |
|
355 | + 'input' => 'textarea', |
|
356 | + 'label' => '[TICKET_LIST]', |
|
357 | + 'type' => 'string', |
|
358 | + 'required' => true, |
|
359 | + 'validation' => true, |
|
360 | + 'format' => '%s', |
|
361 | + 'css_class' => 'large-text', |
|
362 | + 'rows' => '10', |
|
363 | + 'shortcodes_required' => array('[TICKET_LIST]'), |
|
364 | + ), |
|
365 | + 'datetime_list' => array( |
|
366 | + 'input' => 'textarea', |
|
367 | + 'label' => '[DATETIME_LIST]', |
|
368 | + 'type' => 'string', |
|
369 | + 'required' => true, |
|
370 | + 'validation' => true, |
|
371 | + 'format' => '%s', |
|
372 | + 'css_class' => 'large-text', |
|
373 | + 'rows' => '10', |
|
374 | + 'shortcodes_required' => array('[DATETIME_LIST]'), |
|
375 | + ), |
|
376 | + ), |
|
377 | + ), |
|
378 | + ); |
|
379 | + } |
|
380 | + |
|
381 | + |
|
382 | + /** |
|
383 | + * See definition of this class in parent |
|
384 | + */ |
|
385 | + protected function _set_default_message_types() |
|
386 | + { |
|
387 | + $this->_default_message_types = array( |
|
388 | + 'payment', |
|
389 | + 'payment_refund', |
|
390 | + 'registration', |
|
391 | + 'not_approved_registration', |
|
392 | + 'pending_approval', |
|
393 | + ); |
|
394 | + } |
|
395 | + |
|
396 | + |
|
397 | + /** |
|
398 | + * @see definition of this class in parent |
|
399 | + * @since 4.5.0 |
|
400 | + */ |
|
401 | + protected function _set_valid_message_types() |
|
402 | + { |
|
403 | + $this->_valid_message_types = array( |
|
404 | + 'payment', |
|
405 | + 'registration', |
|
406 | + 'not_approved_registration', |
|
407 | + 'declined_registration', |
|
408 | + 'cancelled_registration', |
|
409 | + 'pending_approval', |
|
410 | + 'registration_summary', |
|
411 | + 'payment_reminder', |
|
412 | + 'payment_declined', |
|
413 | + 'payment_refund', |
|
414 | + ); |
|
415 | + } |
|
416 | + |
|
417 | + |
|
418 | + /** |
|
419 | + * setting up admin_settings_fields for messenger. |
|
420 | + */ |
|
421 | + protected function _set_admin_settings_fields() |
|
422 | + { |
|
423 | + } |
|
424 | + |
|
425 | + /** |
|
426 | + * We just deliver the messages don't kill us!! |
|
427 | + * |
|
428 | + * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if |
|
429 | + * present. |
|
430 | + * @throws EE_Error |
|
431 | + * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
432 | + */ |
|
433 | + protected function _send_message() |
|
434 | + { |
|
435 | + $success = wp_mail( |
|
436 | + $this->_to, |
|
437 | + //some old values for subject may be expecting HTML entities to be decoded in the subject |
|
438 | + //and subjects aren't interpreted as HTML, so there should be no HTML in them |
|
439 | + wp_strip_all_tags(wp_specialchars_decode($this->_subject, ENT_QUOTES)), |
|
440 | + $this->_body(), |
|
441 | + $this->_headers() |
|
442 | + ); |
|
443 | + if (! $success) { |
|
444 | + EE_Error::add_error( |
|
445 | + sprintf( |
|
446 | + esc_html__( |
|
447 | + 'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', |
|
448 | + 'event_espresso' |
|
449 | + ), |
|
450 | + $this->_to, |
|
451 | + $this->_from, |
|
452 | + '<br />' |
|
453 | + ), |
|
454 | + __FILE__, |
|
455 | + __FUNCTION__, |
|
456 | + __LINE__ |
|
457 | + ); |
|
458 | + } |
|
459 | + return $success; |
|
460 | + } |
|
461 | + |
|
462 | + |
|
463 | + /** |
|
464 | + * see parent for definition |
|
465 | + * |
|
466 | + * @return string html body of the message content and the related css. |
|
467 | + * @throws EE_Error |
|
468 | + * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
469 | + */ |
|
470 | + protected function _preview() |
|
471 | + { |
|
472 | + return $this->_body(true); |
|
473 | + } |
|
474 | + |
|
475 | + |
|
476 | + /** |
|
477 | + * Setup headers for email |
|
478 | + * |
|
479 | + * @access protected |
|
480 | + * @return string formatted header for email |
|
481 | + */ |
|
482 | + protected function _headers() |
|
483 | + { |
|
484 | + $this->_ensure_has_from_email_address(); |
|
485 | + $from = $this->_from; |
|
486 | + $headers = array( |
|
487 | + 'From:' . $from, |
|
488 | + 'Reply-To:' . $from, |
|
489 | + 'Content-Type:text/html; charset=utf-8', |
|
490 | + ); |
|
491 | + |
|
492 | + if (! empty($this->_cc)) { |
|
493 | + $headers[] = 'cc: ' . $this->_cc; |
|
494 | + } |
|
495 | + |
|
496 | + //but wait! Header's for the from is NOT reliable because some plugins don't respect From: as set in the |
|
497 | + // header. |
|
498 | + add_filter('wp_mail_from', array($this, 'set_from_address'), 100); |
|
499 | + add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100); |
|
500 | + return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this); |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + /** |
|
505 | + * This simply ensures that the from address is not empty. If it is, then we use whatever is set as the site email |
|
506 | + * address for the from address to avoid problems with sending emails. |
|
507 | + */ |
|
508 | + protected function _ensure_has_from_email_address() |
|
509 | + { |
|
510 | + if (empty($this->_from)) { |
|
511 | + $this->_from = get_bloginfo('admin_email'); |
|
512 | + } |
|
513 | + } |
|
514 | + |
|
515 | + |
|
516 | + /** |
|
517 | + * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}> |
|
518 | + * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY* |
|
519 | + * be empty |
|
520 | + * |
|
521 | + * @since 4.3.1 |
|
522 | + * @return array |
|
523 | + */ |
|
524 | + private function _parse_from() |
|
525 | + { |
|
526 | + if (strpos($this->_from, '<') !== false) { |
|
527 | + $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1); |
|
528 | + $from_name = str_replace('"', '', $from_name); |
|
529 | + $from_name = trim($from_name); |
|
530 | + |
|
531 | + $from_email = substr($this->_from, strpos($this->_from, '<') + 1); |
|
532 | + $from_email = str_replace('>', '', $from_email); |
|
533 | + $from_email = trim($from_email); |
|
534 | + } elseif (trim($this->_from) !== '') { |
|
535 | + $from_name = ''; |
|
536 | + $from_email = trim($this->_from); |
|
537 | + } else { |
|
538 | + $from_name = $from_email = ''; |
|
539 | + } |
|
540 | + return array($from_name, $from_email); |
|
541 | + } |
|
542 | + |
|
543 | + |
|
544 | + /** |
|
545 | + * Callback for the wp_mail_from filter. |
|
546 | + * |
|
547 | + * @since 4.3.1 |
|
548 | + * @param string $from_email What the original from_email is. |
|
549 | + * @return string |
|
550 | + */ |
|
551 | + public function set_from_address($from_email) |
|
552 | + { |
|
553 | + $parsed_from = $this->_parse_from(); |
|
554 | + //includes fallback if the parsing failed. |
|
555 | + $from_email = is_array($parsed_from) && ! empty($parsed_from[1]) |
|
556 | + ? $parsed_from[1] |
|
557 | + : get_bloginfo('admin_email'); |
|
558 | + return $from_email; |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + /** |
|
563 | + * Callback fro the wp_mail_from_name filter. |
|
564 | + * |
|
565 | + * @since 4.3.1 |
|
566 | + * @param string $from_name The original from_name. |
|
567 | + * @return string |
|
568 | + */ |
|
569 | + public function set_from_name($from_name) |
|
570 | + { |
|
571 | + $parsed_from = $this->_parse_from(); |
|
572 | + if (is_array($parsed_from) && ! empty($parsed_from[0])) { |
|
573 | + $from_name = $parsed_from[0]; |
|
574 | + } |
|
575 | + |
|
576 | + //if from name is "WordPress" let's sub in the site name instead (more friendly!) |
|
577 | + //but realize the default name is HTML entity-encoded |
|
578 | + $from_name = $from_name == 'WordPress' ? wp_specialchars_decode(get_bloginfo(), ENT_QUOTES) : $from_name; |
|
579 | + |
|
580 | + return $from_name; |
|
581 | + } |
|
582 | + |
|
583 | + |
|
584 | + /** |
|
585 | + * setup body for email |
|
586 | + * |
|
587 | + * @param bool $preview will determine whether this is preview template or not. |
|
588 | + * @return string formatted body for email. |
|
589 | + * @throws EE_Error |
|
590 | + * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
591 | + */ |
|
592 | + protected function _body($preview = false) |
|
593 | + { |
|
594 | + //setup template args! |
|
595 | + $this->_template_args = array( |
|
596 | + 'subject' => $this->_subject, |
|
597 | + 'from' => $this->_from, |
|
598 | + 'main_body' => wpautop($this->_content), |
|
599 | + ); |
|
600 | + $body = $this->_get_main_template($preview); |
|
601 | + |
|
602 | + /** |
|
603 | + * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched. |
|
604 | + * |
|
605 | + * @type bool $preview Indicates whether a preview is being generated or not. |
|
606 | + * @return bool true indicates to use the inliner, false bypasses it. |
|
607 | + */ |
|
608 | + if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) { |
|
609 | + //require CssToInlineStyles library and its dependencies via composer autoloader |
|
610 | + require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php'; |
|
611 | + |
|
612 | + //now if this isn't a preview, let's setup the body so it has inline styles |
|
613 | + if (! $preview || ($preview && defined('DOING_AJAX'))) { |
|
614 | + $style = file_get_contents( |
|
615 | + $this->get_variation( |
|
616 | + $this->_tmp_pack, |
|
617 | + $this->_incoming_message_type->name, |
|
618 | + false, |
|
619 | + 'main', |
|
620 | + $this->_variation |
|
621 | + ), |
|
622 | + true |
|
623 | + ); |
|
624 | + $CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style); |
|
625 | + //for some reason the library has a bracket and new line at the beginning. This takes care of that. |
|
626 | + $body = ltrim($CSS->convert(true), ">\n"); |
|
627 | + //see https://events.codebasehq.com/projects/event-espresso/tickets/8609 |
|
628 | + $body = ltrim($body, "<?"); |
|
629 | + } |
|
630 | + |
|
631 | + } |
|
632 | + return $body; |
|
633 | + } |
|
634 | + |
|
635 | + |
|
636 | + /** |
|
637 | + * This just returns any existing test settings that might be saved in the database |
|
638 | + * |
|
639 | + * @access public |
|
640 | + * @return array |
|
641 | + */ |
|
642 | + public function get_existing_test_settings() |
|
643 | + { |
|
644 | + $settings = parent::get_existing_test_settings(); |
|
645 | + //override subject if present because we always want it to be fresh. |
|
646 | + if (is_array($settings) && ! empty($settings['subject'])) { |
|
647 | + $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')); |
|
648 | + } |
|
649 | + return $settings; |
|
650 | + } |
|
651 | 651 | } |
@@ -38,216 +38,216 @@ |
||
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 | |
64 | 64 | } else { |
65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | - /** |
|
68 | - * espresso_minimum_php_version_error |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | + /** |
|
68 | + * espresso_minimum_php_version_error |
|
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.9.59.rc.001'); |
|
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.9.59.rc.001'); |
|
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'); |
|
118 | - /** |
|
119 | - * espresso_load_error_handling |
|
120 | - * this function loads EE's class for handling exceptions and errors |
|
121 | - */ |
|
122 | - function espresso_load_error_handling() |
|
123 | - { |
|
124 | - static $error_handling_loaded = false; |
|
125 | - if ($error_handling_loaded) { |
|
126 | - return; |
|
127 | - } |
|
128 | - // load debugging tools |
|
129 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
130 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
131 | - \EEH_Debug_Tools::instance(); |
|
132 | - } |
|
133 | - // load error handling |
|
134 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
135 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
136 | - } else { |
|
137 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
138 | - } |
|
139 | - $error_handling_loaded = true; |
|
140 | - } |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | + /** |
|
119 | + * espresso_load_error_handling |
|
120 | + * this function loads EE's class for handling exceptions and errors |
|
121 | + */ |
|
122 | + function espresso_load_error_handling() |
|
123 | + { |
|
124 | + static $error_handling_loaded = false; |
|
125 | + if ($error_handling_loaded) { |
|
126 | + return; |
|
127 | + } |
|
128 | + // load debugging tools |
|
129 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
130 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
131 | + \EEH_Debug_Tools::instance(); |
|
132 | + } |
|
133 | + // load error handling |
|
134 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
135 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
136 | + } else { |
|
137 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
138 | + } |
|
139 | + $error_handling_loaded = true; |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * espresso_load_required |
|
144 | - * given a class name and path, this function will load that file or throw an exception |
|
145 | - * |
|
146 | - * @param string $classname |
|
147 | - * @param string $full_path_to_file |
|
148 | - * @throws EE_Error |
|
149 | - */ |
|
150 | - function espresso_load_required($classname, $full_path_to_file) |
|
151 | - { |
|
152 | - if (is_readable($full_path_to_file)) { |
|
153 | - require_once $full_path_to_file; |
|
154 | - } else { |
|
155 | - throw new \EE_Error ( |
|
156 | - sprintf( |
|
157 | - esc_html__( |
|
158 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
159 | - 'event_espresso' |
|
160 | - ), |
|
161 | - $classname |
|
162 | - ) |
|
163 | - ); |
|
164 | - } |
|
165 | - } |
|
142 | + /** |
|
143 | + * espresso_load_required |
|
144 | + * given a class name and path, this function will load that file or throw an exception |
|
145 | + * |
|
146 | + * @param string $classname |
|
147 | + * @param string $full_path_to_file |
|
148 | + * @throws EE_Error |
|
149 | + */ |
|
150 | + function espresso_load_required($classname, $full_path_to_file) |
|
151 | + { |
|
152 | + if (is_readable($full_path_to_file)) { |
|
153 | + require_once $full_path_to_file; |
|
154 | + } else { |
|
155 | + throw new \EE_Error ( |
|
156 | + sprintf( |
|
157 | + esc_html__( |
|
158 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
159 | + 'event_espresso' |
|
160 | + ), |
|
161 | + $classname |
|
162 | + ) |
|
163 | + ); |
|
164 | + } |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @since 4.9.27 |
|
169 | - * @throws \EE_Error |
|
170 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
171 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
172 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
173 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
174 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
175 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
176 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
177 | - * @throws \OutOfBoundsException |
|
178 | - */ |
|
179 | - function bootstrap_espresso() |
|
180 | - { |
|
181 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
182 | - try { |
|
183 | - espresso_load_error_handling(); |
|
184 | - espresso_load_required( |
|
185 | - 'EEH_Base', |
|
186 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
187 | - ); |
|
188 | - espresso_load_required( |
|
189 | - 'EEH_File', |
|
190 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
191 | - ); |
|
192 | - espresso_load_required( |
|
193 | - 'EEH_File', |
|
194 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
195 | - ); |
|
196 | - espresso_load_required( |
|
197 | - 'EEH_Array', |
|
198 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
199 | - ); |
|
200 | - // instantiate and configure PSR4 autoloader |
|
201 | - espresso_load_required( |
|
202 | - 'Psr4Autoloader', |
|
203 | - EE_CORE . 'Psr4Autoloader.php' |
|
204 | - ); |
|
205 | - espresso_load_required( |
|
206 | - 'EE_Psr4AutoloaderInit', |
|
207 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
208 | - ); |
|
209 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
210 | - $AutoloaderInit->initializeAutoloader(); |
|
211 | - espresso_load_required( |
|
212 | - 'EE_Request', |
|
213 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
214 | - ); |
|
215 | - espresso_load_required( |
|
216 | - 'EE_Response', |
|
217 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
218 | - ); |
|
219 | - espresso_load_required( |
|
220 | - 'EE_Bootstrap', |
|
221 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
222 | - ); |
|
223 | - // bootstrap EE and the request stack |
|
224 | - new EE_Bootstrap( |
|
225 | - new EE_Request($_GET, $_POST, $_COOKIE), |
|
226 | - new EE_Response() |
|
227 | - ); |
|
228 | - } catch (Exception $e) { |
|
229 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
230 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
231 | - } |
|
232 | - } |
|
233 | - bootstrap_espresso(); |
|
234 | - } |
|
167 | + /** |
|
168 | + * @since 4.9.27 |
|
169 | + * @throws \EE_Error |
|
170 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
171 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
172 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
173 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
174 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
175 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
176 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
177 | + * @throws \OutOfBoundsException |
|
178 | + */ |
|
179 | + function bootstrap_espresso() |
|
180 | + { |
|
181 | + require_once __DIR__ . '/core/espresso_definitions.php'; |
|
182 | + try { |
|
183 | + espresso_load_error_handling(); |
|
184 | + espresso_load_required( |
|
185 | + 'EEH_Base', |
|
186 | + EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
187 | + ); |
|
188 | + espresso_load_required( |
|
189 | + 'EEH_File', |
|
190 | + EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
191 | + ); |
|
192 | + espresso_load_required( |
|
193 | + 'EEH_File', |
|
194 | + EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
195 | + ); |
|
196 | + espresso_load_required( |
|
197 | + 'EEH_Array', |
|
198 | + EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
199 | + ); |
|
200 | + // instantiate and configure PSR4 autoloader |
|
201 | + espresso_load_required( |
|
202 | + 'Psr4Autoloader', |
|
203 | + EE_CORE . 'Psr4Autoloader.php' |
|
204 | + ); |
|
205 | + espresso_load_required( |
|
206 | + 'EE_Psr4AutoloaderInit', |
|
207 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
208 | + ); |
|
209 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
210 | + $AutoloaderInit->initializeAutoloader(); |
|
211 | + espresso_load_required( |
|
212 | + 'EE_Request', |
|
213 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
214 | + ); |
|
215 | + espresso_load_required( |
|
216 | + 'EE_Response', |
|
217 | + EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
218 | + ); |
|
219 | + espresso_load_required( |
|
220 | + 'EE_Bootstrap', |
|
221 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
222 | + ); |
|
223 | + // bootstrap EE and the request stack |
|
224 | + new EE_Bootstrap( |
|
225 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
226 | + new EE_Response() |
|
227 | + ); |
|
228 | + } catch (Exception $e) { |
|
229 | + require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
230 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
231 | + } |
|
232 | + } |
|
233 | + bootstrap_espresso(); |
|
234 | + } |
|
235 | 235 | } |
236 | 236 | if (! function_exists('espresso_deactivate_plugin')) { |
237 | - /** |
|
238 | - * deactivate_plugin |
|
239 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
240 | - * |
|
241 | - * @access public |
|
242 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
243 | - * @return void |
|
244 | - */ |
|
245 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
246 | - { |
|
247 | - if (! function_exists('deactivate_plugins')) { |
|
248 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
249 | - } |
|
250 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
251 | - deactivate_plugins($plugin_basename); |
|
252 | - } |
|
237 | + /** |
|
238 | + * deactivate_plugin |
|
239 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
240 | + * |
|
241 | + * @access public |
|
242 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
243 | + * @return void |
|
244 | + */ |
|
245 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
246 | + { |
|
247 | + if (! function_exists('deactivate_plugins')) { |
|
248 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
249 | + } |
|
250 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
251 | + deactivate_plugins($plugin_basename); |
|
252 | + } |
|
253 | 253 | } |
@@ -21,306 +21,306 @@ |
||
21 | 21 | class EED_Recaptcha_Invisible extends EED_Module |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var EE_Registration_Config $config |
|
26 | - */ |
|
27 | - private static $config; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * @return EED_Module|EED_Recaptcha |
|
32 | - */ |
|
33 | - public static function instance() |
|
34 | - { |
|
35 | - return parent::get_instance(__CLASS__); |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * @return void |
|
41 | - * @throws InvalidInterfaceException |
|
42 | - * @throws InvalidDataTypeException |
|
43 | - * @throws InvalidArgumentException |
|
44 | - */ |
|
45 | - public static function set_hooks() |
|
46 | - { |
|
47 | - EED_Recaptcha_Invisible::setProperties(); |
|
48 | - if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) { |
|
49 | - // ticket selection |
|
50 | - add_filter( |
|
51 | - 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
52 | - array('EED_Recaptcha_Invisible', 'ticketSelectorForm'), |
|
53 | - 10, 3 |
|
54 | - ); |
|
55 | - add_action( |
|
56 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
57 | - array('EED_Recaptcha_Invisible', 'processTicketSelectorForm') |
|
58 | - ); |
|
59 | - // checkout |
|
60 | - add_action( |
|
61 | - 'AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', |
|
62 | - array('EED_Recaptcha_Invisible', 'spcoRegStepForm') |
|
63 | - ); |
|
64 | - add_filter( |
|
65 | - 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', |
|
66 | - array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'), |
|
67 | - 10, 2 |
|
68 | - ); |
|
69 | - add_action('loop_end', array('EED_Recaptcha_Invisible', 'localizeScriptVars')); |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @return void |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - * @throws InvalidDataTypeException |
|
78 | - * @throws InvalidArgumentException |
|
79 | - */ |
|
80 | - public static function set_hooks_admin() |
|
81 | - { |
|
82 | - add_action( |
|
83 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
84 | - array('EED_Recaptcha_Invisible', 'processTicketSelectorForm') |
|
85 | - ); |
|
86 | - add_filter( |
|
87 | - 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', |
|
88 | - array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'), |
|
89 | - 10, 2 |
|
90 | - ); |
|
91 | - // admin settings |
|
92 | - add_action( |
|
93 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
94 | - array('EED_Recaptcha_Invisible', 'adminSettings') |
|
95 | - ); |
|
96 | - add_filter( |
|
97 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
98 | - array('EED_Recaptcha_Invisible', 'updateAdminSettings') |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * @return void |
|
105 | - * @throws InvalidInterfaceException |
|
106 | - * @throws InvalidDataTypeException |
|
107 | - * @throws InvalidArgumentException |
|
108 | - */ |
|
109 | - public static function setProperties() |
|
110 | - { |
|
111 | - |
|
112 | - EED_Recaptcha_Invisible::$config = EE_Registry::instance()->CFG->registration; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @return boolean |
|
119 | - */ |
|
120 | - public static function useInvisibleRecaptcha() |
|
121 | - { |
|
122 | - return EED_Recaptcha_Invisible::$config->use_captcha |
|
123 | - && EED_Recaptcha_Invisible::$config->recaptcha_theme === 'invisible'; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * @return void |
|
131 | - * @throws InvalidInterfaceException |
|
132 | - * @throws InvalidDataTypeException |
|
133 | - * @throws InvalidArgumentException |
|
134 | - */ |
|
135 | - public static function localizeScriptVars() |
|
136 | - { |
|
137 | - wp_localize_script( |
|
138 | - EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA, |
|
139 | - 'eeRecaptcha', |
|
140 | - RecaptchaFactory::create()->getLocalizedVars() |
|
141 | - ); |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * @return string |
|
147 | - */ |
|
148 | - public static function assetsUrl() |
|
149 | - { |
|
150 | - return plugin_dir_url(__FILE__) . 'assets' . DS; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * @param \WP $WP |
|
156 | - */ |
|
157 | - public function run($WP) |
|
158 | - { |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * @param EE_Request $request |
|
165 | - * @return bool |
|
166 | - * @throws InvalidArgumentException |
|
167 | - * @throws InvalidDataTypeException |
|
168 | - * @throws InvalidInterfaceException |
|
169 | - * @throws RuntimeException |
|
170 | - */ |
|
171 | - public static function verifyToken(EE_Request $request) |
|
172 | - { |
|
173 | - return RecaptchaFactory::create()->verifyToken($request); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * @param EE_Form_Section_Proper $reg_form |
|
179 | - * @return void |
|
180 | - * @throws EE_Error |
|
181 | - * @throws InvalidArgumentException |
|
182 | - * @throws InvalidDataTypeException |
|
183 | - * @throws InvalidInterfaceException |
|
184 | - * @throws DomainException |
|
185 | - */ |
|
186 | - public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form) |
|
187 | - { |
|
188 | - // do nothing if form isn't for a reg step or test has already been passed |
|
189 | - if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
190 | - return; |
|
191 | - } |
|
192 | - $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs'); |
|
193 | - if ($default_hidden_inputs instanceof EE_Form_Section_Proper) { |
|
194 | - $invisible_recaptcha = RecaptchaFactory::create(); |
|
195 | - $invisible_recaptcha->addToFormSection($default_hidden_inputs); |
|
196 | - } |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * @param EE_Form_Section_Proper $reg_form |
|
202 | - * @return bool |
|
203 | - * @throws InvalidDataTypeException |
|
204 | - * @throws InvalidInterfaceException |
|
205 | - * @throws EE_Error |
|
206 | - * @throws InvalidArgumentException |
|
207 | - */ |
|
208 | - public static function processSpcoRegStepForm(EE_Form_Section_Proper $reg_form) |
|
209 | - { |
|
210 | - return strpos($reg_form->name(), 'reg-step-form') !== false |
|
211 | - && ! RecaptchaFactory::create()->recaptchaPassed(); |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * @param array|null $req_data |
|
217 | - * @param EE_Form_Section_Proper $reg_form |
|
218 | - * @return array |
|
219 | - * @throws EE_Error |
|
220 | - * @throws InvalidArgumentException |
|
221 | - * @throws InvalidDataTypeException |
|
222 | - * @throws InvalidInterfaceException |
|
223 | - * @throws RuntimeException |
|
224 | - */ |
|
225 | - public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form) |
|
226 | - { |
|
227 | - // do nothing if form isn't for a reg step or test has already been passed |
|
228 | - if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
229 | - return $req_data; |
|
230 | - } |
|
231 | - /** @var EE_Request $request */ |
|
232 | - $request = LoaderFactory::getLoader()->getShared('EE_Request'); |
|
233 | - if (! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
234 | - if ($request->isAjax()) { |
|
235 | - $json_response = new EE_SPCO_JSON_Response(); |
|
236 | - $json_response->echoAndExit(); |
|
237 | - } |
|
238 | - EEH_URL::safeRedirectAndExit( |
|
239 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
240 | - ); |
|
241 | - } |
|
242 | - return $req_data; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @param string $html |
|
248 | - * @param EE_Event $event |
|
249 | - * @param bool $iframe |
|
250 | - * @return string |
|
251 | - * @throws EE_Error |
|
252 | - * @throws InvalidArgumentException |
|
253 | - * @throws InvalidDataTypeException |
|
254 | - * @throws InvalidInterfaceException |
|
255 | - * @throws ReflectionException |
|
256 | - * @throws DomainException |
|
257 | - */ |
|
258 | - public static function ticketSelectorForm($html = '', EE_Event $event, $iframe = false) |
|
259 | - { |
|
260 | - $recaptcha = RecaptchaFactory::create(); |
|
261 | - // do nothing if test has already been passed |
|
262 | - if ($recaptcha->recaptchaPassed()) { |
|
263 | - return $html; |
|
264 | - } |
|
265 | - $html .= $recaptcha->getInputHtml( |
|
266 | - array( |
|
267 | - 'recaptcha_id' => $event->ID(), |
|
268 | - 'iframe' => $iframe, |
|
269 | - 'localized_vars' => $recaptcha->getLocalizedVars(), |
|
270 | - ) |
|
271 | - ); |
|
272 | - return $html; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * @return void |
|
278 | - * @throws InvalidArgumentException |
|
279 | - * @throws InvalidInterfaceException |
|
280 | - * @throws InvalidDataTypeException |
|
281 | - * @throws RuntimeException |
|
282 | - */ |
|
283 | - public static function processTicketSelectorForm() |
|
284 | - { |
|
285 | - // do nothing if test has already been passed |
|
286 | - if (RecaptchaFactory::create()->recaptchaPassed()) { |
|
287 | - return; |
|
288 | - } |
|
289 | - /** @var EE_Request $request */ |
|
290 | - $request = LoaderFactory::getLoader()->getShared('EE_Request'); |
|
291 | - if (! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
292 | - $event_id = $request->get('tkt-slctr-event-id'); |
|
293 | - $return_url = $request->is_set("tkt-slctr-return-url-{$event_id}") |
|
294 | - ? $request->get("tkt-slctr-return-url-{$event_id}") |
|
295 | - : get_permalink($event_id); |
|
296 | - EEH_URL::safeRedirectAndExit($return_url); |
|
297 | - } |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * @throws EE_Error |
|
303 | - * @throws InvalidArgumentException |
|
304 | - * @throws InvalidDataTypeException |
|
305 | - * @throws InvalidInterfaceException |
|
306 | - */ |
|
307 | - public static function adminSettings() |
|
308 | - { |
|
309 | - RecaptchaFactory::getAdminModule()->adminSettings(); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * @param EE_Registration_Config $EE_Registration_Config |
|
315 | - * @return EE_Registration_Config |
|
316 | - * @throws EE_Error |
|
317 | - * @throws InvalidArgumentException |
|
318 | - * @throws InvalidDataTypeException |
|
319 | - * @throws InvalidInterfaceException |
|
320 | - * @throws ReflectionException |
|
321 | - */ |
|
322 | - public static function updateAdminSettings(EE_Registration_Config $EE_Registration_Config) |
|
323 | - { |
|
324 | - return RecaptchaFactory::getAdminModule()->updateAdminSettings($EE_Registration_Config); |
|
325 | - } |
|
24 | + /** |
|
25 | + * @var EE_Registration_Config $config |
|
26 | + */ |
|
27 | + private static $config; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * @return EED_Module|EED_Recaptcha |
|
32 | + */ |
|
33 | + public static function instance() |
|
34 | + { |
|
35 | + return parent::get_instance(__CLASS__); |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * @return void |
|
41 | + * @throws InvalidInterfaceException |
|
42 | + * @throws InvalidDataTypeException |
|
43 | + * @throws InvalidArgumentException |
|
44 | + */ |
|
45 | + public static function set_hooks() |
|
46 | + { |
|
47 | + EED_Recaptcha_Invisible::setProperties(); |
|
48 | + if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) { |
|
49 | + // ticket selection |
|
50 | + add_filter( |
|
51 | + 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
52 | + array('EED_Recaptcha_Invisible', 'ticketSelectorForm'), |
|
53 | + 10, 3 |
|
54 | + ); |
|
55 | + add_action( |
|
56 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
57 | + array('EED_Recaptcha_Invisible', 'processTicketSelectorForm') |
|
58 | + ); |
|
59 | + // checkout |
|
60 | + add_action( |
|
61 | + 'AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', |
|
62 | + array('EED_Recaptcha_Invisible', 'spcoRegStepForm') |
|
63 | + ); |
|
64 | + add_filter( |
|
65 | + 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', |
|
66 | + array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'), |
|
67 | + 10, 2 |
|
68 | + ); |
|
69 | + add_action('loop_end', array('EED_Recaptcha_Invisible', 'localizeScriptVars')); |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @return void |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + * @throws InvalidDataTypeException |
|
78 | + * @throws InvalidArgumentException |
|
79 | + */ |
|
80 | + public static function set_hooks_admin() |
|
81 | + { |
|
82 | + add_action( |
|
83 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
84 | + array('EED_Recaptcha_Invisible', 'processTicketSelectorForm') |
|
85 | + ); |
|
86 | + add_filter( |
|
87 | + 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', |
|
88 | + array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'), |
|
89 | + 10, 2 |
|
90 | + ); |
|
91 | + // admin settings |
|
92 | + add_action( |
|
93 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
94 | + array('EED_Recaptcha_Invisible', 'adminSettings') |
|
95 | + ); |
|
96 | + add_filter( |
|
97 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
98 | + array('EED_Recaptcha_Invisible', 'updateAdminSettings') |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * @return void |
|
105 | + * @throws InvalidInterfaceException |
|
106 | + * @throws InvalidDataTypeException |
|
107 | + * @throws InvalidArgumentException |
|
108 | + */ |
|
109 | + public static function setProperties() |
|
110 | + { |
|
111 | + |
|
112 | + EED_Recaptcha_Invisible::$config = EE_Registry::instance()->CFG->registration; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @return boolean |
|
119 | + */ |
|
120 | + public static function useInvisibleRecaptcha() |
|
121 | + { |
|
122 | + return EED_Recaptcha_Invisible::$config->use_captcha |
|
123 | + && EED_Recaptcha_Invisible::$config->recaptcha_theme === 'invisible'; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * @return void |
|
131 | + * @throws InvalidInterfaceException |
|
132 | + * @throws InvalidDataTypeException |
|
133 | + * @throws InvalidArgumentException |
|
134 | + */ |
|
135 | + public static function localizeScriptVars() |
|
136 | + { |
|
137 | + wp_localize_script( |
|
138 | + EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA, |
|
139 | + 'eeRecaptcha', |
|
140 | + RecaptchaFactory::create()->getLocalizedVars() |
|
141 | + ); |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * @return string |
|
147 | + */ |
|
148 | + public static function assetsUrl() |
|
149 | + { |
|
150 | + return plugin_dir_url(__FILE__) . 'assets' . DS; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * @param \WP $WP |
|
156 | + */ |
|
157 | + public function run($WP) |
|
158 | + { |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * @param EE_Request $request |
|
165 | + * @return bool |
|
166 | + * @throws InvalidArgumentException |
|
167 | + * @throws InvalidDataTypeException |
|
168 | + * @throws InvalidInterfaceException |
|
169 | + * @throws RuntimeException |
|
170 | + */ |
|
171 | + public static function verifyToken(EE_Request $request) |
|
172 | + { |
|
173 | + return RecaptchaFactory::create()->verifyToken($request); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * @param EE_Form_Section_Proper $reg_form |
|
179 | + * @return void |
|
180 | + * @throws EE_Error |
|
181 | + * @throws InvalidArgumentException |
|
182 | + * @throws InvalidDataTypeException |
|
183 | + * @throws InvalidInterfaceException |
|
184 | + * @throws DomainException |
|
185 | + */ |
|
186 | + public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form) |
|
187 | + { |
|
188 | + // do nothing if form isn't for a reg step or test has already been passed |
|
189 | + if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
190 | + return; |
|
191 | + } |
|
192 | + $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs'); |
|
193 | + if ($default_hidden_inputs instanceof EE_Form_Section_Proper) { |
|
194 | + $invisible_recaptcha = RecaptchaFactory::create(); |
|
195 | + $invisible_recaptcha->addToFormSection($default_hidden_inputs); |
|
196 | + } |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * @param EE_Form_Section_Proper $reg_form |
|
202 | + * @return bool |
|
203 | + * @throws InvalidDataTypeException |
|
204 | + * @throws InvalidInterfaceException |
|
205 | + * @throws EE_Error |
|
206 | + * @throws InvalidArgumentException |
|
207 | + */ |
|
208 | + public static function processSpcoRegStepForm(EE_Form_Section_Proper $reg_form) |
|
209 | + { |
|
210 | + return strpos($reg_form->name(), 'reg-step-form') !== false |
|
211 | + && ! RecaptchaFactory::create()->recaptchaPassed(); |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * @param array|null $req_data |
|
217 | + * @param EE_Form_Section_Proper $reg_form |
|
218 | + * @return array |
|
219 | + * @throws EE_Error |
|
220 | + * @throws InvalidArgumentException |
|
221 | + * @throws InvalidDataTypeException |
|
222 | + * @throws InvalidInterfaceException |
|
223 | + * @throws RuntimeException |
|
224 | + */ |
|
225 | + public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form) |
|
226 | + { |
|
227 | + // do nothing if form isn't for a reg step or test has already been passed |
|
228 | + if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
229 | + return $req_data; |
|
230 | + } |
|
231 | + /** @var EE_Request $request */ |
|
232 | + $request = LoaderFactory::getLoader()->getShared('EE_Request'); |
|
233 | + if (! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
234 | + if ($request->isAjax()) { |
|
235 | + $json_response = new EE_SPCO_JSON_Response(); |
|
236 | + $json_response->echoAndExit(); |
|
237 | + } |
|
238 | + EEH_URL::safeRedirectAndExit( |
|
239 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
240 | + ); |
|
241 | + } |
|
242 | + return $req_data; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @param string $html |
|
248 | + * @param EE_Event $event |
|
249 | + * @param bool $iframe |
|
250 | + * @return string |
|
251 | + * @throws EE_Error |
|
252 | + * @throws InvalidArgumentException |
|
253 | + * @throws InvalidDataTypeException |
|
254 | + * @throws InvalidInterfaceException |
|
255 | + * @throws ReflectionException |
|
256 | + * @throws DomainException |
|
257 | + */ |
|
258 | + public static function ticketSelectorForm($html = '', EE_Event $event, $iframe = false) |
|
259 | + { |
|
260 | + $recaptcha = RecaptchaFactory::create(); |
|
261 | + // do nothing if test has already been passed |
|
262 | + if ($recaptcha->recaptchaPassed()) { |
|
263 | + return $html; |
|
264 | + } |
|
265 | + $html .= $recaptcha->getInputHtml( |
|
266 | + array( |
|
267 | + 'recaptcha_id' => $event->ID(), |
|
268 | + 'iframe' => $iframe, |
|
269 | + 'localized_vars' => $recaptcha->getLocalizedVars(), |
|
270 | + ) |
|
271 | + ); |
|
272 | + return $html; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * @return void |
|
278 | + * @throws InvalidArgumentException |
|
279 | + * @throws InvalidInterfaceException |
|
280 | + * @throws InvalidDataTypeException |
|
281 | + * @throws RuntimeException |
|
282 | + */ |
|
283 | + public static function processTicketSelectorForm() |
|
284 | + { |
|
285 | + // do nothing if test has already been passed |
|
286 | + if (RecaptchaFactory::create()->recaptchaPassed()) { |
|
287 | + return; |
|
288 | + } |
|
289 | + /** @var EE_Request $request */ |
|
290 | + $request = LoaderFactory::getLoader()->getShared('EE_Request'); |
|
291 | + if (! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
292 | + $event_id = $request->get('tkt-slctr-event-id'); |
|
293 | + $return_url = $request->is_set("tkt-slctr-return-url-{$event_id}") |
|
294 | + ? $request->get("tkt-slctr-return-url-{$event_id}") |
|
295 | + : get_permalink($event_id); |
|
296 | + EEH_URL::safeRedirectAndExit($return_url); |
|
297 | + } |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * @throws EE_Error |
|
303 | + * @throws InvalidArgumentException |
|
304 | + * @throws InvalidDataTypeException |
|
305 | + * @throws InvalidInterfaceException |
|
306 | + */ |
|
307 | + public static function adminSettings() |
|
308 | + { |
|
309 | + RecaptchaFactory::getAdminModule()->adminSettings(); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * @param EE_Registration_Config $EE_Registration_Config |
|
315 | + * @return EE_Registration_Config |
|
316 | + * @throws EE_Error |
|
317 | + * @throws InvalidArgumentException |
|
318 | + * @throws InvalidDataTypeException |
|
319 | + * @throws InvalidInterfaceException |
|
320 | + * @throws ReflectionException |
|
321 | + */ |
|
322 | + public static function updateAdminSettings(EE_Registration_Config $EE_Registration_Config) |
|
323 | + { |
|
324 | + return RecaptchaFactory::getAdminModule()->updateAdminSettings($EE_Registration_Config); |
|
325 | + } |
|
326 | 326 | } |
@@ -17,2452 +17,2452 @@ discard block |
||
17 | 17 | final class EE_Config implements ResettableInterface |
18 | 18 | { |
19 | 19 | |
20 | - const OPTION_NAME = 'ee_config'; |
|
20 | + const OPTION_NAME = 'ee_config'; |
|
21 | + |
|
22 | + const LOG_NAME = 'ee_config_log'; |
|
23 | + |
|
24 | + const LOG_LENGTH = 100; |
|
25 | + |
|
26 | + const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * instance of the EE_Config object |
|
31 | + * |
|
32 | + * @var EE_Config $_instance |
|
33 | + * @access private |
|
34 | + */ |
|
35 | + private static $_instance; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var boolean $_logging_enabled |
|
39 | + */ |
|
40 | + private static $_logging_enabled = false; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
44 | + */ |
|
45 | + private $legacy_shortcodes_manager; |
|
46 | + |
|
47 | + /** |
|
48 | + * An StdClass whose property names are addon slugs, |
|
49 | + * and values are their config classes |
|
50 | + * |
|
51 | + * @var StdClass |
|
52 | + */ |
|
53 | + public $addons; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var EE_Admin_Config |
|
57 | + */ |
|
58 | + public $admin; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var EE_Core_Config |
|
62 | + */ |
|
63 | + public $core; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var EE_Currency_Config |
|
67 | + */ |
|
68 | + public $currency; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var EE_Organization_Config |
|
72 | + */ |
|
73 | + public $organization; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var EE_Registration_Config |
|
77 | + */ |
|
78 | + public $registration; |
|
79 | + |
|
80 | + /** |
|
81 | + * @var EE_Template_Config |
|
82 | + */ |
|
83 | + public $template_settings; |
|
84 | + |
|
85 | + /** |
|
86 | + * Holds EE environment values. |
|
87 | + * |
|
88 | + * @var EE_Environment_Config |
|
89 | + */ |
|
90 | + public $environment; |
|
91 | + |
|
92 | + /** |
|
93 | + * settings pertaining to Google maps |
|
94 | + * |
|
95 | + * @var EE_Map_Config |
|
96 | + */ |
|
97 | + public $map_settings; |
|
98 | + |
|
99 | + /** |
|
100 | + * settings pertaining to Taxes |
|
101 | + * |
|
102 | + * @var EE_Tax_Config |
|
103 | + */ |
|
104 | + public $tax_settings; |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * Settings pertaining to global messages settings. |
|
109 | + * |
|
110 | + * @var EE_Messages_Config |
|
111 | + */ |
|
112 | + public $messages; |
|
113 | + |
|
114 | + /** |
|
115 | + * @deprecated |
|
116 | + * @var EE_Gateway_Config |
|
117 | + */ |
|
118 | + public $gateway; |
|
119 | + |
|
120 | + /** |
|
121 | + * @var array $_addon_option_names |
|
122 | + * @access private |
|
123 | + */ |
|
124 | + private $_addon_option_names = array(); |
|
125 | + |
|
126 | + /** |
|
127 | + * @var array $_module_route_map |
|
128 | + * @access private |
|
129 | + */ |
|
130 | + private static $_module_route_map = array(); |
|
131 | + |
|
132 | + /** |
|
133 | + * @var array $_module_forward_map |
|
134 | + * @access private |
|
135 | + */ |
|
136 | + private static $_module_forward_map = array(); |
|
137 | + |
|
138 | + /** |
|
139 | + * @var array $_module_view_map |
|
140 | + * @access private |
|
141 | + */ |
|
142 | + private static $_module_view_map = array(); |
|
143 | + |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @singleton method used to instantiate class object |
|
148 | + * @access public |
|
149 | + * @return EE_Config instance |
|
150 | + */ |
|
151 | + public static function instance() |
|
152 | + { |
|
153 | + // check if class object is instantiated, and instantiated properly |
|
154 | + if (! self::$_instance instanceof EE_Config) { |
|
155 | + self::$_instance = new self(); |
|
156 | + } |
|
157 | + return self::$_instance; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Resets the config |
|
164 | + * |
|
165 | + * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
166 | + * (default) leaves the database alone, and merely resets the EE_Config object to |
|
167 | + * reflect its state in the database |
|
168 | + * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
169 | + * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
170 | + * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
171 | + * site was put into maintenance mode) |
|
172 | + * @return EE_Config |
|
173 | + */ |
|
174 | + public static function reset($hard_reset = false, $reinstantiate = true) |
|
175 | + { |
|
176 | + if (self::$_instance instanceof EE_Config) { |
|
177 | + if ($hard_reset) { |
|
178 | + self::$_instance->legacy_shortcodes_manager = null; |
|
179 | + self::$_instance->_addon_option_names = array(); |
|
180 | + self::$_instance->_initialize_config(); |
|
181 | + self::$_instance->update_espresso_config(); |
|
182 | + } |
|
183 | + self::$_instance->update_addon_option_names(); |
|
184 | + } |
|
185 | + self::$_instance = null; |
|
186 | + //we don't need to reset the static properties imo because those should |
|
187 | + //only change when a module is added or removed. Currently we don't |
|
188 | + //support removing a module during a request when it previously existed |
|
189 | + if ($reinstantiate) { |
|
190 | + return self::instance(); |
|
191 | + } else { |
|
192 | + return null; |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + |
|
198 | + /** |
|
199 | + * class constructor |
|
200 | + * |
|
201 | + * @access private |
|
202 | + */ |
|
203 | + private function __construct() |
|
204 | + { |
|
205 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
206 | + EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
207 | + // setup empty config classes |
|
208 | + $this->_initialize_config(); |
|
209 | + // load existing EE site settings |
|
210 | + $this->_load_core_config(); |
|
211 | + // confirm everything loaded correctly and set filtered defaults if not |
|
212 | + $this->_verify_config(); |
|
213 | + // register shortcodes and modules |
|
214 | + add_action( |
|
215 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
216 | + array($this, 'register_shortcodes_and_modules'), |
|
217 | + 999 |
|
218 | + ); |
|
219 | + // initialize shortcodes and modules |
|
220 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
221 | + // register widgets |
|
222 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
223 | + // shutdown |
|
224 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
225 | + // construct__end hook |
|
226 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
227 | + // hardcoded hack |
|
228 | + $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * @return boolean |
|
235 | + */ |
|
236 | + public static function logging_enabled() |
|
237 | + { |
|
238 | + return self::$_logging_enabled; |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * use to get the current theme if needed from static context |
|
245 | + * |
|
246 | + * @return string current theme set. |
|
247 | + */ |
|
248 | + public static function get_current_theme() |
|
249 | + { |
|
250 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
251 | + ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * _initialize_config |
|
258 | + * |
|
259 | + * @access private |
|
260 | + * @return void |
|
261 | + */ |
|
262 | + private function _initialize_config() |
|
263 | + { |
|
264 | + EE_Config::trim_log(); |
|
265 | + //set defaults |
|
266 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
267 | + $this->addons = new stdClass(); |
|
268 | + // set _module_route_map |
|
269 | + EE_Config::$_module_route_map = array(); |
|
270 | + // set _module_forward_map |
|
271 | + EE_Config::$_module_forward_map = array(); |
|
272 | + // set _module_view_map |
|
273 | + EE_Config::$_module_view_map = array(); |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * load core plugin configuration |
|
280 | + * |
|
281 | + * @access private |
|
282 | + * @return void |
|
283 | + */ |
|
284 | + private function _load_core_config() |
|
285 | + { |
|
286 | + // load_core_config__start hook |
|
287 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
288 | + $espresso_config = $this->get_espresso_config(); |
|
289 | + foreach ($espresso_config as $config => $settings) { |
|
290 | + // load_core_config__start hook |
|
291 | + $settings = apply_filters( |
|
292 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
293 | + $settings, |
|
294 | + $config, |
|
295 | + $this |
|
296 | + ); |
|
297 | + if (is_object($settings) && property_exists($this, $config)) { |
|
298 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
299 | + //call configs populate method to ensure any defaults are set for empty values. |
|
300 | + if (method_exists($settings, 'populate')) { |
|
301 | + $this->{$config}->populate(); |
|
302 | + } |
|
303 | + if (method_exists($settings, 'do_hooks')) { |
|
304 | + $this->{$config}->do_hooks(); |
|
305 | + } |
|
306 | + } |
|
307 | + } |
|
308 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
309 | + $this->update_espresso_config(); |
|
310 | + } |
|
311 | + // load_core_config__end hook |
|
312 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * _verify_config |
|
319 | + * |
|
320 | + * @access protected |
|
321 | + * @return void |
|
322 | + */ |
|
323 | + protected function _verify_config() |
|
324 | + { |
|
325 | + $this->core = $this->core instanceof EE_Core_Config |
|
326 | + ? $this->core |
|
327 | + : new EE_Core_Config(); |
|
328 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
329 | + $this->organization = $this->organization instanceof EE_Organization_Config |
|
330 | + ? $this->organization |
|
331 | + : new EE_Organization_Config(); |
|
332 | + $this->organization = apply_filters( |
|
333 | + 'FHEE__EE_Config___initialize_config__organization', |
|
334 | + $this->organization |
|
335 | + ); |
|
336 | + $this->currency = $this->currency instanceof EE_Currency_Config |
|
337 | + ? $this->currency |
|
338 | + : new EE_Currency_Config(); |
|
339 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
340 | + $this->registration = $this->registration instanceof EE_Registration_Config |
|
341 | + ? $this->registration |
|
342 | + : new EE_Registration_Config(); |
|
343 | + $this->registration = apply_filters( |
|
344 | + 'FHEE__EE_Config___initialize_config__registration', |
|
345 | + $this->registration |
|
346 | + ); |
|
347 | + $this->admin = $this->admin instanceof EE_Admin_Config |
|
348 | + ? $this->admin |
|
349 | + : new EE_Admin_Config(); |
|
350 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
351 | + $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
352 | + ? $this->template_settings |
|
353 | + : new EE_Template_Config(); |
|
354 | + $this->template_settings = apply_filters( |
|
355 | + 'FHEE__EE_Config___initialize_config__template_settings', |
|
356 | + $this->template_settings |
|
357 | + ); |
|
358 | + $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
359 | + ? $this->map_settings |
|
360 | + : new EE_Map_Config(); |
|
361 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
362 | + $this->map_settings); |
|
363 | + $this->environment = $this->environment instanceof EE_Environment_Config |
|
364 | + ? $this->environment |
|
365 | + : new EE_Environment_Config(); |
|
366 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
367 | + $this->environment); |
|
368 | + $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
369 | + ? $this->tax_settings |
|
370 | + : new EE_Tax_Config(); |
|
371 | + $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
372 | + $this->tax_settings); |
|
373 | + $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
374 | + $this->messages = $this->messages instanceof EE_Messages_Config |
|
375 | + ? $this->messages |
|
376 | + : new EE_Messages_Config(); |
|
377 | + $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
378 | + ? $this->gateway |
|
379 | + : new EE_Gateway_Config(); |
|
380 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
381 | + $this->legacy_shortcodes_manager = null; |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * get_espresso_config |
|
387 | + * |
|
388 | + * @access public |
|
389 | + * @return array of espresso config stuff |
|
390 | + */ |
|
391 | + public function get_espresso_config() |
|
392 | + { |
|
393 | + // grab espresso configuration |
|
394 | + return apply_filters( |
|
395 | + 'FHEE__EE_Config__get_espresso_config__CFG', |
|
396 | + get_option(EE_Config::OPTION_NAME, array()) |
|
397 | + ); |
|
398 | + } |
|
399 | + |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * double_check_config_comparison |
|
404 | + * |
|
405 | + * @access public |
|
406 | + * @param string $option |
|
407 | + * @param $old_value |
|
408 | + * @param $value |
|
409 | + */ |
|
410 | + public function double_check_config_comparison($option = '', $old_value, $value) |
|
411 | + { |
|
412 | + // make sure we're checking the ee config |
|
413 | + if ($option === EE_Config::OPTION_NAME) { |
|
414 | + // run a loose comparison of the old value against the new value for type and properties, |
|
415 | + // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
416 | + if ($value != $old_value) { |
|
417 | + // if they are NOT the same, then remove the hook, |
|
418 | + // which means the subsequent update results will be based solely on the update query results |
|
419 | + // the reason we do this is because, as stated above, |
|
420 | + // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
421 | + // this happens PRIOR to serialization and any subsequent update. |
|
422 | + // If values are found to match their previous old value, |
|
423 | + // then WP bails before performing any update. |
|
424 | + // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
425 | + // it just pulled from the db, with the one being passed to it (which will not match). |
|
426 | + // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
427 | + // MySQL MAY ALSO NOT perform the update because |
|
428 | + // the string it sees in the db looks the same as the new one it has been passed!!! |
|
429 | + // This results in the query returning an "affected rows" value of ZERO, |
|
430 | + // which gets returned immediately by WP update_option and looks like an error. |
|
431 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
432 | + } |
|
433 | + } |
|
434 | + } |
|
435 | + |
|
436 | + |
|
437 | + |
|
438 | + /** |
|
439 | + * update_espresso_config |
|
440 | + * |
|
441 | + * @access public |
|
442 | + */ |
|
443 | + protected function _reset_espresso_addon_config() |
|
444 | + { |
|
445 | + $this->_addon_option_names = array(); |
|
446 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
447 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
448 | + if ($addon_config_obj instanceof EE_Config_Base) { |
|
449 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
450 | + } |
|
451 | + $this->addons->{$addon_name} = null; |
|
452 | + } |
|
453 | + } |
|
454 | + |
|
455 | + |
|
456 | + |
|
457 | + /** |
|
458 | + * update_espresso_config |
|
459 | + * |
|
460 | + * @access public |
|
461 | + * @param bool $add_success |
|
462 | + * @param bool $add_error |
|
463 | + * @return bool |
|
464 | + */ |
|
465 | + public function update_espresso_config($add_success = false, $add_error = true) |
|
466 | + { |
|
467 | + // don't allow config updates during WP heartbeats |
|
468 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
469 | + return false; |
|
470 | + } |
|
471 | + // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
472 | + //$clone = clone( self::$_instance ); |
|
473 | + //self::$_instance = NULL; |
|
474 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
475 | + $this->_reset_espresso_addon_config(); |
|
476 | + // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
477 | + // but BEFORE the actual update occurs |
|
478 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
479 | + // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
480 | + $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
481 | + $this->legacy_shortcodes_manager = null; |
|
482 | + // now update "ee_config" |
|
483 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
484 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
485 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
486 | + // if not saved... check if the hook we just added still exists; |
|
487 | + // if it does, it means one of two things: |
|
488 | + // that update_option bailed at the ( $value === $old_value ) conditional, |
|
489 | + // or... |
|
490 | + // the db update query returned 0 rows affected |
|
491 | + // (probably because the data value was the same from it's perspective) |
|
492 | + // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
493 | + // but just means no update occurred, so don't display an error to the user. |
|
494 | + // BUT... if update_option returns FALSE, AND the hook is missing, |
|
495 | + // then it means that something truly went wrong |
|
496 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
497 | + // remove our action since we don't want it in the system anymore |
|
498 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
499 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
500 | + //self::$_instance = $clone; |
|
501 | + //unset( $clone ); |
|
502 | + // if config remains the same or was updated successfully |
|
503 | + if ($saved) { |
|
504 | + if ($add_success) { |
|
505 | + EE_Error::add_success( |
|
506 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
507 | + __FILE__, |
|
508 | + __FUNCTION__, |
|
509 | + __LINE__ |
|
510 | + ); |
|
511 | + } |
|
512 | + return true; |
|
513 | + } else { |
|
514 | + if ($add_error) { |
|
515 | + EE_Error::add_error( |
|
516 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
517 | + __FILE__, |
|
518 | + __FUNCTION__, |
|
519 | + __LINE__ |
|
520 | + ); |
|
521 | + } |
|
522 | + return false; |
|
523 | + } |
|
524 | + } |
|
525 | + |
|
526 | + |
|
527 | + |
|
528 | + /** |
|
529 | + * _verify_config_params |
|
530 | + * |
|
531 | + * @access private |
|
532 | + * @param string $section |
|
533 | + * @param string $name |
|
534 | + * @param string $config_class |
|
535 | + * @param EE_Config_Base $config_obj |
|
536 | + * @param array $tests_to_run |
|
537 | + * @param bool $display_errors |
|
538 | + * @return bool TRUE on success, FALSE on fail |
|
539 | + */ |
|
540 | + private function _verify_config_params( |
|
541 | + $section = '', |
|
542 | + $name = '', |
|
543 | + $config_class = '', |
|
544 | + $config_obj = null, |
|
545 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
546 | + $display_errors = true |
|
547 | + ) { |
|
548 | + try { |
|
549 | + foreach ($tests_to_run as $test) { |
|
550 | + switch ($test) { |
|
551 | + // TEST #1 : check that section was set |
|
552 | + case 1 : |
|
553 | + if (empty($section)) { |
|
554 | + if ($display_errors) { |
|
555 | + throw new EE_Error( |
|
556 | + sprintf( |
|
557 | + __( |
|
558 | + 'No configuration section has been provided while attempting to save "%s".', |
|
559 | + 'event_espresso' |
|
560 | + ), |
|
561 | + $config_class |
|
562 | + ) |
|
563 | + ); |
|
564 | + } |
|
565 | + return false; |
|
566 | + } |
|
567 | + break; |
|
568 | + // TEST #2 : check that settings section exists |
|
569 | + case 2 : |
|
570 | + if (! isset($this->{$section})) { |
|
571 | + if ($display_errors) { |
|
572 | + throw new EE_Error( |
|
573 | + sprintf( |
|
574 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
575 | + $section |
|
576 | + ) |
|
577 | + ); |
|
578 | + } |
|
579 | + return false; |
|
580 | + } |
|
581 | + break; |
|
582 | + // TEST #3 : check that section is the proper format |
|
583 | + case 3 : |
|
584 | + if ( |
|
585 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
586 | + ) { |
|
587 | + if ($display_errors) { |
|
588 | + throw new EE_Error( |
|
589 | + sprintf( |
|
590 | + __( |
|
591 | + 'The "%s" configuration settings have not been formatted correctly.', |
|
592 | + 'event_espresso' |
|
593 | + ), |
|
594 | + $section |
|
595 | + ) |
|
596 | + ); |
|
597 | + } |
|
598 | + return false; |
|
599 | + } |
|
600 | + break; |
|
601 | + // TEST #4 : check that config section name has been set |
|
602 | + case 4 : |
|
603 | + if (empty($name)) { |
|
604 | + if ($display_errors) { |
|
605 | + throw new EE_Error( |
|
606 | + __( |
|
607 | + 'No name has been provided for the specific configuration section.', |
|
608 | + 'event_espresso' |
|
609 | + ) |
|
610 | + ); |
|
611 | + } |
|
612 | + return false; |
|
613 | + } |
|
614 | + break; |
|
615 | + // TEST #5 : check that a config class name has been set |
|
616 | + case 5 : |
|
617 | + if (empty($config_class)) { |
|
618 | + if ($display_errors) { |
|
619 | + throw new EE_Error( |
|
620 | + __( |
|
621 | + 'No class name has been provided for the specific configuration section.', |
|
622 | + 'event_espresso' |
|
623 | + ) |
|
624 | + ); |
|
625 | + } |
|
626 | + return false; |
|
627 | + } |
|
628 | + break; |
|
629 | + // TEST #6 : verify config class is accessible |
|
630 | + case 6 : |
|
631 | + if (! class_exists($config_class)) { |
|
632 | + if ($display_errors) { |
|
633 | + throw new EE_Error( |
|
634 | + sprintf( |
|
635 | + __( |
|
636 | + 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
637 | + 'event_espresso' |
|
638 | + ), |
|
639 | + $config_class |
|
640 | + ) |
|
641 | + ); |
|
642 | + } |
|
643 | + return false; |
|
644 | + } |
|
645 | + break; |
|
646 | + // TEST #7 : check that config has even been set |
|
647 | + case 7 : |
|
648 | + if (! isset($this->{$section}->{$name})) { |
|
649 | + if ($display_errors) { |
|
650 | + throw new EE_Error( |
|
651 | + sprintf( |
|
652 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
653 | + $section, |
|
654 | + $name |
|
655 | + ) |
|
656 | + ); |
|
657 | + } |
|
658 | + return false; |
|
659 | + } else { |
|
660 | + // and make sure it's not serialized |
|
661 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
662 | + } |
|
663 | + break; |
|
664 | + // TEST #8 : check that config is the requested type |
|
665 | + case 8 : |
|
666 | + if (! $this->{$section}->{$name} instanceof $config_class) { |
|
667 | + if ($display_errors) { |
|
668 | + throw new EE_Error( |
|
669 | + sprintf( |
|
670 | + __( |
|
671 | + 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
672 | + 'event_espresso' |
|
673 | + ), |
|
674 | + $section, |
|
675 | + $name, |
|
676 | + $config_class |
|
677 | + ) |
|
678 | + ); |
|
679 | + } |
|
680 | + return false; |
|
681 | + } |
|
682 | + break; |
|
683 | + // TEST #9 : verify config object |
|
684 | + case 9 : |
|
685 | + if (! $config_obj instanceof EE_Config_Base) { |
|
686 | + if ($display_errors) { |
|
687 | + throw new EE_Error( |
|
688 | + sprintf( |
|
689 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
690 | + print_r($config_obj, true) |
|
691 | + ) |
|
692 | + ); |
|
693 | + } |
|
694 | + return false; |
|
695 | + } |
|
696 | + break; |
|
697 | + } |
|
698 | + } |
|
699 | + } catch (EE_Error $e) { |
|
700 | + $e->get_error(); |
|
701 | + } |
|
702 | + // you have successfully run the gauntlet |
|
703 | + return true; |
|
704 | + } |
|
705 | + |
|
706 | + |
|
707 | + |
|
708 | + /** |
|
709 | + * _generate_config_option_name |
|
710 | + * |
|
711 | + * @access protected |
|
712 | + * @param string $section |
|
713 | + * @param string $name |
|
714 | + * @return string |
|
715 | + */ |
|
716 | + private function _generate_config_option_name($section = '', $name = '') |
|
717 | + { |
|
718 | + return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
719 | + } |
|
720 | + |
|
721 | + |
|
722 | + |
|
723 | + /** |
|
724 | + * _set_config_class |
|
725 | + * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
726 | + * |
|
727 | + * @access private |
|
728 | + * @param string $config_class |
|
729 | + * @param string $name |
|
730 | + * @return string |
|
731 | + */ |
|
732 | + private function _set_config_class($config_class = '', $name = '') |
|
733 | + { |
|
734 | + return ! empty($config_class) |
|
735 | + ? $config_class |
|
736 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
737 | + } |
|
738 | + |
|
739 | + |
|
740 | + |
|
741 | + /** |
|
742 | + * set_config |
|
743 | + * |
|
744 | + * @access protected |
|
745 | + * @param string $section |
|
746 | + * @param string $name |
|
747 | + * @param string $config_class |
|
748 | + * @param EE_Config_Base $config_obj |
|
749 | + * @return EE_Config_Base |
|
750 | + */ |
|
751 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
752 | + { |
|
753 | + // ensure config class is set to something |
|
754 | + $config_class = $this->_set_config_class($config_class, $name); |
|
755 | + // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
756 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
757 | + return null; |
|
758 | + } |
|
759 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
760 | + // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
761 | + if (! isset($this->_addon_option_names[$config_option_name])) { |
|
762 | + $this->_addon_option_names[$config_option_name] = $config_class; |
|
763 | + $this->update_addon_option_names(); |
|
764 | + } |
|
765 | + // verify the incoming config object but suppress errors |
|
766 | + if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
767 | + $config_obj = new $config_class(); |
|
768 | + } |
|
769 | + if (get_option($config_option_name)) { |
|
770 | + EE_Config::log($config_option_name); |
|
771 | + update_option($config_option_name, $config_obj); |
|
772 | + $this->{$section}->{$name} = $config_obj; |
|
773 | + return $this->{$section}->{$name}; |
|
774 | + } else { |
|
775 | + // create a wp-option for this config |
|
776 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
777 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
778 | + return $this->{$section}->{$name}; |
|
779 | + } else { |
|
780 | + EE_Error::add_error( |
|
781 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
782 | + __FILE__, |
|
783 | + __FUNCTION__, |
|
784 | + __LINE__ |
|
785 | + ); |
|
786 | + return null; |
|
787 | + } |
|
788 | + } |
|
789 | + } |
|
790 | + |
|
791 | + |
|
792 | + |
|
793 | + /** |
|
794 | + * update_config |
|
795 | + * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
796 | + * |
|
797 | + * @access public |
|
798 | + * @param string $section |
|
799 | + * @param string $name |
|
800 | + * @param EE_Config_Base|string $config_obj |
|
801 | + * @param bool $throw_errors |
|
802 | + * @return bool |
|
803 | + */ |
|
804 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
805 | + { |
|
806 | + // don't allow config updates during WP heartbeats |
|
807 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
808 | + return false; |
|
809 | + } |
|
810 | + $config_obj = maybe_unserialize($config_obj); |
|
811 | + // get class name of the incoming object |
|
812 | + $config_class = get_class($config_obj); |
|
813 | + // run tests 1-5 and 9 to verify config |
|
814 | + if (! $this->_verify_config_params( |
|
815 | + $section, |
|
816 | + $name, |
|
817 | + $config_class, |
|
818 | + $config_obj, |
|
819 | + array(1, 2, 3, 4, 7, 9) |
|
820 | + ) |
|
821 | + ) { |
|
822 | + return false; |
|
823 | + } |
|
824 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
825 | + // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
826 | + if (! isset($this->_addon_option_names[$config_option_name])) { |
|
827 | + // save new config to db |
|
828 | + if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
829 | + return true; |
|
830 | + } |
|
831 | + } else { |
|
832 | + // first check if the record already exists |
|
833 | + $existing_config = get_option($config_option_name); |
|
834 | + $config_obj = serialize($config_obj); |
|
835 | + // just return if db record is already up to date (NOT type safe comparison) |
|
836 | + if ($existing_config == $config_obj) { |
|
837 | + $this->{$section}->{$name} = $config_obj; |
|
838 | + return true; |
|
839 | + } else if (update_option($config_option_name, $config_obj)) { |
|
840 | + EE_Config::log($config_option_name); |
|
841 | + // update wp-option for this config class |
|
842 | + $this->{$section}->{$name} = $config_obj; |
|
843 | + return true; |
|
844 | + } elseif ($throw_errors) { |
|
845 | + EE_Error::add_error( |
|
846 | + sprintf( |
|
847 | + __( |
|
848 | + 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
849 | + 'event_espresso' |
|
850 | + ), |
|
851 | + $config_class, |
|
852 | + 'EE_Config->' . $section . '->' . $name |
|
853 | + ), |
|
854 | + __FILE__, |
|
855 | + __FUNCTION__, |
|
856 | + __LINE__ |
|
857 | + ); |
|
858 | + } |
|
859 | + } |
|
860 | + return false; |
|
861 | + } |
|
862 | + |
|
863 | + |
|
864 | + |
|
865 | + /** |
|
866 | + * get_config |
|
867 | + * |
|
868 | + * @access public |
|
869 | + * @param string $section |
|
870 | + * @param string $name |
|
871 | + * @param string $config_class |
|
872 | + * @return mixed EE_Config_Base | NULL |
|
873 | + */ |
|
874 | + public function get_config($section = '', $name = '', $config_class = '') |
|
875 | + { |
|
876 | + // ensure config class is set to something |
|
877 | + $config_class = $this->_set_config_class($config_class, $name); |
|
878 | + // run tests 1-4, 6 and 7 to verify that all params have been set |
|
879 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
880 | + return null; |
|
881 | + } |
|
882 | + // now test if the requested config object exists, but suppress errors |
|
883 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
884 | + // config already exists, so pass it back |
|
885 | + return $this->{$section}->{$name}; |
|
886 | + } |
|
887 | + // load config option from db if it exists |
|
888 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
889 | + // verify the newly retrieved config object, but suppress errors |
|
890 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
891 | + // config is good, so set it and pass it back |
|
892 | + $this->{$section}->{$name} = $config_obj; |
|
893 | + return $this->{$section}->{$name}; |
|
894 | + } |
|
895 | + // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
896 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
897 | + // verify the newly created config object |
|
898 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
899 | + return $this->{$section}->{$name}; |
|
900 | + } else { |
|
901 | + EE_Error::add_error( |
|
902 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
903 | + __FILE__, |
|
904 | + __FUNCTION__, |
|
905 | + __LINE__ |
|
906 | + ); |
|
907 | + } |
|
908 | + return null; |
|
909 | + } |
|
910 | + |
|
911 | + |
|
912 | + |
|
913 | + /** |
|
914 | + * get_config_option |
|
915 | + * |
|
916 | + * @access public |
|
917 | + * @param string $config_option_name |
|
918 | + * @return mixed EE_Config_Base | FALSE |
|
919 | + */ |
|
920 | + public function get_config_option($config_option_name = '') |
|
921 | + { |
|
922 | + // retrieve the wp-option for this config class. |
|
923 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
924 | + if (empty($config_option)) { |
|
925 | + EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
926 | + } |
|
927 | + return $config_option; |
|
928 | + } |
|
929 | + |
|
930 | + |
|
931 | + |
|
932 | + /** |
|
933 | + * log |
|
934 | + * |
|
935 | + * @param string $config_option_name |
|
936 | + */ |
|
937 | + public static function log($config_option_name = '') |
|
938 | + { |
|
939 | + if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
940 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
941 | + //copy incoming $_REQUEST and sanitize it so we can save it |
|
942 | + $_request = $_REQUEST; |
|
943 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
944 | + $config_log[(string)microtime(true)] = array( |
|
945 | + 'config_name' => $config_option_name, |
|
946 | + 'request' => $_request, |
|
947 | + ); |
|
948 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
949 | + } |
|
950 | + } |
|
951 | + |
|
952 | + |
|
953 | + |
|
954 | + /** |
|
955 | + * trim_log |
|
956 | + * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
957 | + */ |
|
958 | + public static function trim_log() |
|
959 | + { |
|
960 | + if (! EE_Config::logging_enabled()) { |
|
961 | + return; |
|
962 | + } |
|
963 | + $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
964 | + $log_length = count($config_log); |
|
965 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
966 | + ksort($config_log); |
|
967 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
968 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
969 | + } |
|
970 | + } |
|
971 | + |
|
972 | + |
|
973 | + |
|
974 | + /** |
|
975 | + * get_page_for_posts |
|
976 | + * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
977 | + * wp-option "page_for_posts", or "posts" if no page is selected |
|
978 | + * |
|
979 | + * @access public |
|
980 | + * @return string |
|
981 | + */ |
|
982 | + public static function get_page_for_posts() |
|
983 | + { |
|
984 | + $page_for_posts = get_option('page_for_posts'); |
|
985 | + if (! $page_for_posts) { |
|
986 | + return 'posts'; |
|
987 | + } |
|
988 | + /** @type WPDB $wpdb */ |
|
989 | + global $wpdb; |
|
990 | + $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
991 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
992 | + } |
|
993 | + |
|
994 | + |
|
995 | + |
|
996 | + /** |
|
997 | + * register_shortcodes_and_modules. |
|
998 | + * At this point, it's too early to tell if we're maintenance mode or not. |
|
999 | + * In fact, this is where we give modules a chance to let core know they exist |
|
1000 | + * so they can help trigger maintenance mode if it's needed |
|
1001 | + * |
|
1002 | + * @access public |
|
1003 | + * @return void |
|
1004 | + */ |
|
1005 | + public function register_shortcodes_and_modules() |
|
1006 | + { |
|
1007 | + // allow modules to set hooks for the rest of the system |
|
1008 | + EE_Registry::instance()->modules = $this->_register_modules(); |
|
1009 | + } |
|
1010 | + |
|
1011 | + |
|
1012 | + |
|
1013 | + /** |
|
1014 | + * initialize_shortcodes_and_modules |
|
1015 | + * meaning they can start adding their hooks to get stuff done |
|
1016 | + * |
|
1017 | + * @access public |
|
1018 | + * @return void |
|
1019 | + */ |
|
1020 | + public function initialize_shortcodes_and_modules() |
|
1021 | + { |
|
1022 | + // allow modules to set hooks for the rest of the system |
|
1023 | + $this->_initialize_modules(); |
|
1024 | + } |
|
1025 | + |
|
1026 | + |
|
1027 | + |
|
1028 | + /** |
|
1029 | + * widgets_init |
|
1030 | + * |
|
1031 | + * @access private |
|
1032 | + * @return void |
|
1033 | + */ |
|
1034 | + public function widgets_init() |
|
1035 | + { |
|
1036 | + //only init widgets on admin pages when not in complete maintenance, and |
|
1037 | + //on frontend when not in any maintenance mode |
|
1038 | + if ( |
|
1039 | + ! EE_Maintenance_Mode::instance()->level() |
|
1040 | + || ( |
|
1041 | + is_admin() |
|
1042 | + && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
1043 | + ) |
|
1044 | + ) { |
|
1045 | + // grab list of installed widgets |
|
1046 | + $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1047 | + // filter list of modules to register |
|
1048 | + $widgets_to_register = apply_filters( |
|
1049 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
1050 | + $widgets_to_register |
|
1051 | + ); |
|
1052 | + if (! empty($widgets_to_register)) { |
|
1053 | + // cycle thru widget folders |
|
1054 | + foreach ($widgets_to_register as $widget_path) { |
|
1055 | + // add to list of installed widget modules |
|
1056 | + EE_Config::register_ee_widget($widget_path); |
|
1057 | + } |
|
1058 | + } |
|
1059 | + // filter list of installed modules |
|
1060 | + EE_Registry::instance()->widgets = apply_filters( |
|
1061 | + 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
1062 | + EE_Registry::instance()->widgets |
|
1063 | + ); |
|
1064 | + } |
|
1065 | + } |
|
1066 | + |
|
1067 | + |
|
1068 | + |
|
1069 | + /** |
|
1070 | + * register_ee_widget - makes core aware of this widget |
|
1071 | + * |
|
1072 | + * @access public |
|
1073 | + * @param string $widget_path - full path up to and including widget folder |
|
1074 | + * @return void |
|
1075 | + */ |
|
1076 | + public static function register_ee_widget($widget_path = null) |
|
1077 | + { |
|
1078 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1079 | + $widget_ext = '.widget.php'; |
|
1080 | + // make all separators match |
|
1081 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1082 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1083 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
1084 | + // grab and shortcode file name from directory name and break apart at dots |
|
1085 | + $file_name = explode('.', basename($widget_path)); |
|
1086 | + // take first segment from file name pieces and remove class prefix if it exists |
|
1087 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1088 | + // sanitize shortcode directory name |
|
1089 | + $widget = sanitize_key($widget); |
|
1090 | + // now we need to rebuild the shortcode path |
|
1091 | + $widget_path = explode(DS, $widget_path); |
|
1092 | + // remove last segment |
|
1093 | + array_pop($widget_path); |
|
1094 | + // glue it back together |
|
1095 | + $widget_path = implode(DS, $widget_path); |
|
1096 | + } else { |
|
1097 | + // grab and sanitize widget directory name |
|
1098 | + $widget = sanitize_key(basename($widget_path)); |
|
1099 | + } |
|
1100 | + // create classname from widget directory name |
|
1101 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1102 | + // add class prefix |
|
1103 | + $widget_class = 'EEW_' . $widget; |
|
1104 | + // does the widget exist ? |
|
1105 | + if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1106 | + $msg = sprintf( |
|
1107 | + __( |
|
1108 | + 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
1109 | + 'event_espresso' |
|
1110 | + ), |
|
1111 | + $widget_class, |
|
1112 | + $widget_path . DS . $widget_class . $widget_ext |
|
1113 | + ); |
|
1114 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1115 | + return; |
|
1116 | + } |
|
1117 | + // load the widget class file |
|
1118 | + require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1119 | + // verify that class exists |
|
1120 | + if (! class_exists($widget_class)) { |
|
1121 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1122 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1123 | + return; |
|
1124 | + } |
|
1125 | + register_widget($widget_class); |
|
1126 | + // add to array of registered widgets |
|
1127 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1128 | + } |
|
1129 | + |
|
1130 | + |
|
1131 | + |
|
1132 | + /** |
|
1133 | + * _register_modules |
|
1134 | + * |
|
1135 | + * @access private |
|
1136 | + * @return array |
|
1137 | + */ |
|
1138 | + private function _register_modules() |
|
1139 | + { |
|
1140 | + // grab list of installed modules |
|
1141 | + $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1142 | + // filter list of modules to register |
|
1143 | + $modules_to_register = apply_filters( |
|
1144 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
1145 | + $modules_to_register |
|
1146 | + ); |
|
1147 | + if (! empty($modules_to_register)) { |
|
1148 | + // loop through folders |
|
1149 | + foreach ($modules_to_register as $module_path) { |
|
1150 | + /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1151 | + if ( |
|
1152 | + $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1153 | + && $module_path !== EE_MODULES . 'gateways' |
|
1154 | + ) { |
|
1155 | + // add to list of installed modules |
|
1156 | + EE_Config::register_module($module_path); |
|
1157 | + } |
|
1158 | + } |
|
1159 | + } |
|
1160 | + // filter list of installed modules |
|
1161 | + return apply_filters( |
|
1162 | + 'FHEE__EE_Config___register_modules__installed_modules', |
|
1163 | + EE_Registry::instance()->modules |
|
1164 | + ); |
|
1165 | + } |
|
1166 | + |
|
1167 | + |
|
1168 | + |
|
1169 | + /** |
|
1170 | + * register_module - makes core aware of this module |
|
1171 | + * |
|
1172 | + * @access public |
|
1173 | + * @param string $module_path - full path up to and including module folder |
|
1174 | + * @return bool |
|
1175 | + */ |
|
1176 | + public static function register_module($module_path = null) |
|
1177 | + { |
|
1178 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1179 | + $module_ext = '.module.php'; |
|
1180 | + // make all separators match |
|
1181 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1182 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1183 | + if (strpos($module_path, $module_ext) !== false) { |
|
1184 | + // grab and shortcode file name from directory name and break apart at dots |
|
1185 | + $module_file = explode('.', basename($module_path)); |
|
1186 | + // now we need to rebuild the shortcode path |
|
1187 | + $module_path = explode(DS, $module_path); |
|
1188 | + // remove last segment |
|
1189 | + array_pop($module_path); |
|
1190 | + // glue it back together |
|
1191 | + $module_path = implode(DS, $module_path) . DS; |
|
1192 | + // take first segment from file name pieces and sanitize it |
|
1193 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1194 | + // ensure class prefix is added |
|
1195 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1196 | + } else { |
|
1197 | + // we need to generate the filename based off of the folder name |
|
1198 | + // grab and sanitize module name |
|
1199 | + $module = strtolower(basename($module_path)); |
|
1200 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1201 | + // like trailingslashit() |
|
1202 | + $module_path = rtrim($module_path, DS) . DS; |
|
1203 | + // create classname from module directory name |
|
1204 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1205 | + // add class prefix |
|
1206 | + $module_class = 'EED_' . $module; |
|
1207 | + } |
|
1208 | + // does the module exist ? |
|
1209 | + if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1210 | + $msg = sprintf( |
|
1211 | + __( |
|
1212 | + 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
1213 | + 'event_espresso' |
|
1214 | + ), |
|
1215 | + $module |
|
1216 | + ); |
|
1217 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1218 | + return false; |
|
1219 | + } |
|
1220 | + // load the module class file |
|
1221 | + require_once($module_path . $module_class . $module_ext); |
|
1222 | + // verify that class exists |
|
1223 | + if (! class_exists($module_class)) { |
|
1224 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1225 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1226 | + return false; |
|
1227 | + } |
|
1228 | + // add to array of registered modules |
|
1229 | + EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1230 | + do_action( |
|
1231 | + 'AHEE__EE_Config__register_module__complete', |
|
1232 | + $module_class, |
|
1233 | + EE_Registry::instance()->modules->{$module_class} |
|
1234 | + ); |
|
1235 | + return true; |
|
1236 | + } |
|
1237 | + |
|
1238 | + |
|
1239 | + |
|
1240 | + /** |
|
1241 | + * _initialize_modules |
|
1242 | + * allow modules to set hooks for the rest of the system |
|
1243 | + * |
|
1244 | + * @access private |
|
1245 | + * @return void |
|
1246 | + */ |
|
1247 | + private function _initialize_modules() |
|
1248 | + { |
|
1249 | + // cycle thru shortcode folders |
|
1250 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1251 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1252 | + // which set hooks ? |
|
1253 | + if (is_admin()) { |
|
1254 | + // fire immediately |
|
1255 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
1256 | + } else { |
|
1257 | + // delay until other systems are online |
|
1258 | + add_action( |
|
1259 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1260 | + array($module_class, 'set_hooks') |
|
1261 | + ); |
|
1262 | + } |
|
1263 | + } |
|
1264 | + } |
|
1265 | + |
|
1266 | + |
|
1267 | + |
|
1268 | + /** |
|
1269 | + * register_route - adds module method routes to route_map |
|
1270 | + * |
|
1271 | + * @access public |
|
1272 | + * @param string $route - "pretty" public alias for module method |
|
1273 | + * @param string $module - module name (classname without EED_ prefix) |
|
1274 | + * @param string $method_name - the actual module method to be routed to |
|
1275 | + * @param string $key - url param key indicating a route is being called |
|
1276 | + * @return bool |
|
1277 | + */ |
|
1278 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
1279 | + { |
|
1280 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1281 | + $module = str_replace('EED_', '', $module); |
|
1282 | + $module_class = 'EED_' . $module; |
|
1283 | + if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1284 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1285 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1286 | + return false; |
|
1287 | + } |
|
1288 | + if (empty($route)) { |
|
1289 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1290 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1291 | + return false; |
|
1292 | + } |
|
1293 | + if (! method_exists('EED_' . $module, $method_name)) { |
|
1294 | + $msg = sprintf( |
|
1295 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1296 | + $route |
|
1297 | + ); |
|
1298 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1299 | + return false; |
|
1300 | + } |
|
1301 | + EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
1302 | + return true; |
|
1303 | + } |
|
1304 | + |
|
1305 | + |
|
1306 | + |
|
1307 | + /** |
|
1308 | + * get_route - get module method route |
|
1309 | + * |
|
1310 | + * @access public |
|
1311 | + * @param string $route - "pretty" public alias for module method |
|
1312 | + * @param string $key - url param key indicating a route is being called |
|
1313 | + * @return string |
|
1314 | + */ |
|
1315 | + public static function get_route($route = null, $key = 'ee') |
|
1316 | + { |
|
1317 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1318 | + $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
1319 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1320 | + return EE_Config::$_module_route_map[$key][$route]; |
|
1321 | + } |
|
1322 | + return null; |
|
1323 | + } |
|
1324 | + |
|
1325 | + |
|
1326 | + |
|
1327 | + /** |
|
1328 | + * get_routes - get ALL module method routes |
|
1329 | + * |
|
1330 | + * @access public |
|
1331 | + * @return array |
|
1332 | + */ |
|
1333 | + public static function get_routes() |
|
1334 | + { |
|
1335 | + return EE_Config::$_module_route_map; |
|
1336 | + } |
|
1337 | + |
|
1338 | + |
|
1339 | + |
|
1340 | + /** |
|
1341 | + * register_forward - allows modules to forward request to another module for further processing |
|
1342 | + * |
|
1343 | + * @access public |
|
1344 | + * @param string $route - "pretty" public alias for module method |
|
1345 | + * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
1346 | + * class, allows different forwards to be served based on status |
|
1347 | + * @param array|string $forward - function name or array( class, method ) |
|
1348 | + * @param string $key - url param key indicating a route is being called |
|
1349 | + * @return bool |
|
1350 | + */ |
|
1351 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
1352 | + { |
|
1353 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1354 | + if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1355 | + $msg = sprintf( |
|
1356 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1357 | + $route |
|
1358 | + ); |
|
1359 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1360 | + return false; |
|
1361 | + } |
|
1362 | + if (empty($forward)) { |
|
1363 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1364 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1365 | + return false; |
|
1366 | + } |
|
1367 | + if (is_array($forward)) { |
|
1368 | + if (! isset($forward[1])) { |
|
1369 | + $msg = sprintf( |
|
1370 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1371 | + $route |
|
1372 | + ); |
|
1373 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1374 | + return false; |
|
1375 | + } |
|
1376 | + if (! method_exists($forward[0], $forward[1])) { |
|
1377 | + $msg = sprintf( |
|
1378 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1379 | + $forward[1], |
|
1380 | + $route |
|
1381 | + ); |
|
1382 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1383 | + return false; |
|
1384 | + } |
|
1385 | + } else if (! function_exists($forward)) { |
|
1386 | + $msg = sprintf( |
|
1387 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1388 | + $forward, |
|
1389 | + $route |
|
1390 | + ); |
|
1391 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1392 | + return false; |
|
1393 | + } |
|
1394 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1395 | + return true; |
|
1396 | + } |
|
1397 | + |
|
1398 | + |
|
1399 | + |
|
1400 | + /** |
|
1401 | + * get_forward - get forwarding route |
|
1402 | + * |
|
1403 | + * @access public |
|
1404 | + * @param string $route - "pretty" public alias for module method |
|
1405 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1406 | + * allows different forwards to be served based on status |
|
1407 | + * @param string $key - url param key indicating a route is being called |
|
1408 | + * @return string |
|
1409 | + */ |
|
1410 | + public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
1411 | + { |
|
1412 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1413 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1414 | + return apply_filters( |
|
1415 | + 'FHEE__EE_Config__get_forward', |
|
1416 | + EE_Config::$_module_forward_map[$key][$route][$status], |
|
1417 | + $route, |
|
1418 | + $status |
|
1419 | + ); |
|
1420 | + } |
|
1421 | + return null; |
|
1422 | + } |
|
1423 | + |
|
1424 | + |
|
1425 | + |
|
1426 | + /** |
|
1427 | + * register_forward - allows modules to specify different view templates for different method routes and status |
|
1428 | + * results |
|
1429 | + * |
|
1430 | + * @access public |
|
1431 | + * @param string $route - "pretty" public alias for module method |
|
1432 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1433 | + * allows different views to be served based on status |
|
1434 | + * @param string $view |
|
1435 | + * @param string $key - url param key indicating a route is being called |
|
1436 | + * @return bool |
|
1437 | + */ |
|
1438 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
1439 | + { |
|
1440 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1441 | + if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1442 | + $msg = sprintf( |
|
1443 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1444 | + $route |
|
1445 | + ); |
|
1446 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1447 | + return false; |
|
1448 | + } |
|
1449 | + if (! is_readable($view)) { |
|
1450 | + $msg = sprintf( |
|
1451 | + __( |
|
1452 | + 'The %s view file could not be found or is not readable due to file permissions.', |
|
1453 | + 'event_espresso' |
|
1454 | + ), |
|
1455 | + $view |
|
1456 | + ); |
|
1457 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1458 | + return false; |
|
1459 | + } |
|
1460 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1461 | + return true; |
|
1462 | + } |
|
1463 | + |
|
1464 | + |
|
1465 | + |
|
1466 | + /** |
|
1467 | + * get_view - get view for route and status |
|
1468 | + * |
|
1469 | + * @access public |
|
1470 | + * @param string $route - "pretty" public alias for module method |
|
1471 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1472 | + * allows different views to be served based on status |
|
1473 | + * @param string $key - url param key indicating a route is being called |
|
1474 | + * @return string |
|
1475 | + */ |
|
1476 | + public static function get_view($route = null, $status = 0, $key = 'ee') |
|
1477 | + { |
|
1478 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1479 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1480 | + return apply_filters( |
|
1481 | + 'FHEE__EE_Config__get_view', |
|
1482 | + EE_Config::$_module_view_map[$key][$route][$status], |
|
1483 | + $route, |
|
1484 | + $status |
|
1485 | + ); |
|
1486 | + } |
|
1487 | + return null; |
|
1488 | + } |
|
1489 | + |
|
1490 | + |
|
1491 | + |
|
1492 | + public function update_addon_option_names() |
|
1493 | + { |
|
1494 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1495 | + } |
|
1496 | + |
|
1497 | + |
|
1498 | + |
|
1499 | + public function shutdown() |
|
1500 | + { |
|
1501 | + $this->update_addon_option_names(); |
|
1502 | + } |
|
1503 | + |
|
1504 | + |
|
1505 | + |
|
1506 | + /** |
|
1507 | + * @return LegacyShortcodesManager |
|
1508 | + */ |
|
1509 | + public static function getLegacyShortcodesManager() |
|
1510 | + { |
|
1511 | + |
|
1512 | + if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
1513 | + EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
1514 | + EE_Registry::instance() |
|
1515 | + ); |
|
1516 | + } |
|
1517 | + return EE_Config::instance()->legacy_shortcodes_manager; |
|
1518 | + } |
|
1519 | + |
|
1520 | + |
|
1521 | + |
|
1522 | + /** |
|
1523 | + * register_shortcode - makes core aware of this shortcode |
|
1524 | + * |
|
1525 | + * @deprecated 4.9.26 |
|
1526 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
1527 | + * @return bool |
|
1528 | + */ |
|
1529 | + public static function register_shortcode($shortcode_path = null) |
|
1530 | + { |
|
1531 | + EE_Error::doing_it_wrong( |
|
1532 | + __METHOD__, |
|
1533 | + __( |
|
1534 | + 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
1535 | + 'event_espresso' |
|
1536 | + ), |
|
1537 | + '4.9.26' |
|
1538 | + ); |
|
1539 | + return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
1540 | + } |
|
21 | 1541 | |
22 | - const LOG_NAME = 'ee_config_log'; |
|
23 | 1542 | |
24 | - const LOG_LENGTH = 100; |
|
25 | 1543 | |
26 | - const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * instance of the EE_Config object |
|
31 | - * |
|
32 | - * @var EE_Config $_instance |
|
33 | - * @access private |
|
34 | - */ |
|
35 | - private static $_instance; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var boolean $_logging_enabled |
|
39 | - */ |
|
40 | - private static $_logging_enabled = false; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
44 | - */ |
|
45 | - private $legacy_shortcodes_manager; |
|
46 | - |
|
47 | - /** |
|
48 | - * An StdClass whose property names are addon slugs, |
|
49 | - * and values are their config classes |
|
50 | - * |
|
51 | - * @var StdClass |
|
52 | - */ |
|
53 | - public $addons; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var EE_Admin_Config |
|
57 | - */ |
|
58 | - public $admin; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var EE_Core_Config |
|
62 | - */ |
|
63 | - public $core; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var EE_Currency_Config |
|
67 | - */ |
|
68 | - public $currency; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var EE_Organization_Config |
|
72 | - */ |
|
73 | - public $organization; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var EE_Registration_Config |
|
77 | - */ |
|
78 | - public $registration; |
|
79 | - |
|
80 | - /** |
|
81 | - * @var EE_Template_Config |
|
82 | - */ |
|
83 | - public $template_settings; |
|
84 | - |
|
85 | - /** |
|
86 | - * Holds EE environment values. |
|
87 | - * |
|
88 | - * @var EE_Environment_Config |
|
89 | - */ |
|
90 | - public $environment; |
|
91 | - |
|
92 | - /** |
|
93 | - * settings pertaining to Google maps |
|
94 | - * |
|
95 | - * @var EE_Map_Config |
|
96 | - */ |
|
97 | - public $map_settings; |
|
98 | - |
|
99 | - /** |
|
100 | - * settings pertaining to Taxes |
|
101 | - * |
|
102 | - * @var EE_Tax_Config |
|
103 | - */ |
|
104 | - public $tax_settings; |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * Settings pertaining to global messages settings. |
|
109 | - * |
|
110 | - * @var EE_Messages_Config |
|
111 | - */ |
|
112 | - public $messages; |
|
113 | - |
|
114 | - /** |
|
115 | - * @deprecated |
|
116 | - * @var EE_Gateway_Config |
|
117 | - */ |
|
118 | - public $gateway; |
|
119 | - |
|
120 | - /** |
|
121 | - * @var array $_addon_option_names |
|
122 | - * @access private |
|
123 | - */ |
|
124 | - private $_addon_option_names = array(); |
|
125 | - |
|
126 | - /** |
|
127 | - * @var array $_module_route_map |
|
128 | - * @access private |
|
129 | - */ |
|
130 | - private static $_module_route_map = array(); |
|
131 | - |
|
132 | - /** |
|
133 | - * @var array $_module_forward_map |
|
134 | - * @access private |
|
135 | - */ |
|
136 | - private static $_module_forward_map = array(); |
|
137 | - |
|
138 | - /** |
|
139 | - * @var array $_module_view_map |
|
140 | - * @access private |
|
141 | - */ |
|
142 | - private static $_module_view_map = array(); |
|
143 | - |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @singleton method used to instantiate class object |
|
148 | - * @access public |
|
149 | - * @return EE_Config instance |
|
150 | - */ |
|
151 | - public static function instance() |
|
152 | - { |
|
153 | - // check if class object is instantiated, and instantiated properly |
|
154 | - if (! self::$_instance instanceof EE_Config) { |
|
155 | - self::$_instance = new self(); |
|
156 | - } |
|
157 | - return self::$_instance; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Resets the config |
|
164 | - * |
|
165 | - * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
166 | - * (default) leaves the database alone, and merely resets the EE_Config object to |
|
167 | - * reflect its state in the database |
|
168 | - * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
169 | - * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
170 | - * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
171 | - * site was put into maintenance mode) |
|
172 | - * @return EE_Config |
|
173 | - */ |
|
174 | - public static function reset($hard_reset = false, $reinstantiate = true) |
|
175 | - { |
|
176 | - if (self::$_instance instanceof EE_Config) { |
|
177 | - if ($hard_reset) { |
|
178 | - self::$_instance->legacy_shortcodes_manager = null; |
|
179 | - self::$_instance->_addon_option_names = array(); |
|
180 | - self::$_instance->_initialize_config(); |
|
181 | - self::$_instance->update_espresso_config(); |
|
182 | - } |
|
183 | - self::$_instance->update_addon_option_names(); |
|
184 | - } |
|
185 | - self::$_instance = null; |
|
186 | - //we don't need to reset the static properties imo because those should |
|
187 | - //only change when a module is added or removed. Currently we don't |
|
188 | - //support removing a module during a request when it previously existed |
|
189 | - if ($reinstantiate) { |
|
190 | - return self::instance(); |
|
191 | - } else { |
|
192 | - return null; |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - |
|
198 | - /** |
|
199 | - * class constructor |
|
200 | - * |
|
201 | - * @access private |
|
202 | - */ |
|
203 | - private function __construct() |
|
204 | - { |
|
205 | - do_action('AHEE__EE_Config__construct__begin', $this); |
|
206 | - EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
207 | - // setup empty config classes |
|
208 | - $this->_initialize_config(); |
|
209 | - // load existing EE site settings |
|
210 | - $this->_load_core_config(); |
|
211 | - // confirm everything loaded correctly and set filtered defaults if not |
|
212 | - $this->_verify_config(); |
|
213 | - // register shortcodes and modules |
|
214 | - add_action( |
|
215 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
216 | - array($this, 'register_shortcodes_and_modules'), |
|
217 | - 999 |
|
218 | - ); |
|
219 | - // initialize shortcodes and modules |
|
220 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
221 | - // register widgets |
|
222 | - add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
223 | - // shutdown |
|
224 | - add_action('shutdown', array($this, 'shutdown'), 10); |
|
225 | - // construct__end hook |
|
226 | - do_action('AHEE__EE_Config__construct__end', $this); |
|
227 | - // hardcoded hack |
|
228 | - $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * @return boolean |
|
235 | - */ |
|
236 | - public static function logging_enabled() |
|
237 | - { |
|
238 | - return self::$_logging_enabled; |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * use to get the current theme if needed from static context |
|
245 | - * |
|
246 | - * @return string current theme set. |
|
247 | - */ |
|
248 | - public static function get_current_theme() |
|
249 | - { |
|
250 | - return isset(self::$_instance->template_settings->current_espresso_theme) |
|
251 | - ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * _initialize_config |
|
258 | - * |
|
259 | - * @access private |
|
260 | - * @return void |
|
261 | - */ |
|
262 | - private function _initialize_config() |
|
263 | - { |
|
264 | - EE_Config::trim_log(); |
|
265 | - //set defaults |
|
266 | - $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
267 | - $this->addons = new stdClass(); |
|
268 | - // set _module_route_map |
|
269 | - EE_Config::$_module_route_map = array(); |
|
270 | - // set _module_forward_map |
|
271 | - EE_Config::$_module_forward_map = array(); |
|
272 | - // set _module_view_map |
|
273 | - EE_Config::$_module_view_map = array(); |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * load core plugin configuration |
|
280 | - * |
|
281 | - * @access private |
|
282 | - * @return void |
|
283 | - */ |
|
284 | - private function _load_core_config() |
|
285 | - { |
|
286 | - // load_core_config__start hook |
|
287 | - do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
288 | - $espresso_config = $this->get_espresso_config(); |
|
289 | - foreach ($espresso_config as $config => $settings) { |
|
290 | - // load_core_config__start hook |
|
291 | - $settings = apply_filters( |
|
292 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
293 | - $settings, |
|
294 | - $config, |
|
295 | - $this |
|
296 | - ); |
|
297 | - if (is_object($settings) && property_exists($this, $config)) { |
|
298 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
299 | - //call configs populate method to ensure any defaults are set for empty values. |
|
300 | - if (method_exists($settings, 'populate')) { |
|
301 | - $this->{$config}->populate(); |
|
302 | - } |
|
303 | - if (method_exists($settings, 'do_hooks')) { |
|
304 | - $this->{$config}->do_hooks(); |
|
305 | - } |
|
306 | - } |
|
307 | - } |
|
308 | - if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
309 | - $this->update_espresso_config(); |
|
310 | - } |
|
311 | - // load_core_config__end hook |
|
312 | - do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * _verify_config |
|
319 | - * |
|
320 | - * @access protected |
|
321 | - * @return void |
|
322 | - */ |
|
323 | - protected function _verify_config() |
|
324 | - { |
|
325 | - $this->core = $this->core instanceof EE_Core_Config |
|
326 | - ? $this->core |
|
327 | - : new EE_Core_Config(); |
|
328 | - $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
329 | - $this->organization = $this->organization instanceof EE_Organization_Config |
|
330 | - ? $this->organization |
|
331 | - : new EE_Organization_Config(); |
|
332 | - $this->organization = apply_filters( |
|
333 | - 'FHEE__EE_Config___initialize_config__organization', |
|
334 | - $this->organization |
|
335 | - ); |
|
336 | - $this->currency = $this->currency instanceof EE_Currency_Config |
|
337 | - ? $this->currency |
|
338 | - : new EE_Currency_Config(); |
|
339 | - $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
340 | - $this->registration = $this->registration instanceof EE_Registration_Config |
|
341 | - ? $this->registration |
|
342 | - : new EE_Registration_Config(); |
|
343 | - $this->registration = apply_filters( |
|
344 | - 'FHEE__EE_Config___initialize_config__registration', |
|
345 | - $this->registration |
|
346 | - ); |
|
347 | - $this->admin = $this->admin instanceof EE_Admin_Config |
|
348 | - ? $this->admin |
|
349 | - : new EE_Admin_Config(); |
|
350 | - $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
351 | - $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
352 | - ? $this->template_settings |
|
353 | - : new EE_Template_Config(); |
|
354 | - $this->template_settings = apply_filters( |
|
355 | - 'FHEE__EE_Config___initialize_config__template_settings', |
|
356 | - $this->template_settings |
|
357 | - ); |
|
358 | - $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
359 | - ? $this->map_settings |
|
360 | - : new EE_Map_Config(); |
|
361 | - $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
362 | - $this->map_settings); |
|
363 | - $this->environment = $this->environment instanceof EE_Environment_Config |
|
364 | - ? $this->environment |
|
365 | - : new EE_Environment_Config(); |
|
366 | - $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
367 | - $this->environment); |
|
368 | - $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
369 | - ? $this->tax_settings |
|
370 | - : new EE_Tax_Config(); |
|
371 | - $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
372 | - $this->tax_settings); |
|
373 | - $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
374 | - $this->messages = $this->messages instanceof EE_Messages_Config |
|
375 | - ? $this->messages |
|
376 | - : new EE_Messages_Config(); |
|
377 | - $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
378 | - ? $this->gateway |
|
379 | - : new EE_Gateway_Config(); |
|
380 | - $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
381 | - $this->legacy_shortcodes_manager = null; |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * get_espresso_config |
|
387 | - * |
|
388 | - * @access public |
|
389 | - * @return array of espresso config stuff |
|
390 | - */ |
|
391 | - public function get_espresso_config() |
|
392 | - { |
|
393 | - // grab espresso configuration |
|
394 | - return apply_filters( |
|
395 | - 'FHEE__EE_Config__get_espresso_config__CFG', |
|
396 | - get_option(EE_Config::OPTION_NAME, array()) |
|
397 | - ); |
|
398 | - } |
|
399 | - |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * double_check_config_comparison |
|
404 | - * |
|
405 | - * @access public |
|
406 | - * @param string $option |
|
407 | - * @param $old_value |
|
408 | - * @param $value |
|
409 | - */ |
|
410 | - public function double_check_config_comparison($option = '', $old_value, $value) |
|
411 | - { |
|
412 | - // make sure we're checking the ee config |
|
413 | - if ($option === EE_Config::OPTION_NAME) { |
|
414 | - // run a loose comparison of the old value against the new value for type and properties, |
|
415 | - // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
416 | - if ($value != $old_value) { |
|
417 | - // if they are NOT the same, then remove the hook, |
|
418 | - // which means the subsequent update results will be based solely on the update query results |
|
419 | - // the reason we do this is because, as stated above, |
|
420 | - // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
421 | - // this happens PRIOR to serialization and any subsequent update. |
|
422 | - // If values are found to match their previous old value, |
|
423 | - // then WP bails before performing any update. |
|
424 | - // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
425 | - // it just pulled from the db, with the one being passed to it (which will not match). |
|
426 | - // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
427 | - // MySQL MAY ALSO NOT perform the update because |
|
428 | - // the string it sees in the db looks the same as the new one it has been passed!!! |
|
429 | - // This results in the query returning an "affected rows" value of ZERO, |
|
430 | - // which gets returned immediately by WP update_option and looks like an error. |
|
431 | - remove_action('update_option', array($this, 'check_config_updated')); |
|
432 | - } |
|
433 | - } |
|
434 | - } |
|
435 | - |
|
436 | - |
|
437 | - |
|
438 | - /** |
|
439 | - * update_espresso_config |
|
440 | - * |
|
441 | - * @access public |
|
442 | - */ |
|
443 | - protected function _reset_espresso_addon_config() |
|
444 | - { |
|
445 | - $this->_addon_option_names = array(); |
|
446 | - foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
447 | - $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
448 | - if ($addon_config_obj instanceof EE_Config_Base) { |
|
449 | - $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
450 | - } |
|
451 | - $this->addons->{$addon_name} = null; |
|
452 | - } |
|
453 | - } |
|
454 | - |
|
455 | - |
|
456 | - |
|
457 | - /** |
|
458 | - * update_espresso_config |
|
459 | - * |
|
460 | - * @access public |
|
461 | - * @param bool $add_success |
|
462 | - * @param bool $add_error |
|
463 | - * @return bool |
|
464 | - */ |
|
465 | - public function update_espresso_config($add_success = false, $add_error = true) |
|
466 | - { |
|
467 | - // don't allow config updates during WP heartbeats |
|
468 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
469 | - return false; |
|
470 | - } |
|
471 | - // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
472 | - //$clone = clone( self::$_instance ); |
|
473 | - //self::$_instance = NULL; |
|
474 | - do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
475 | - $this->_reset_espresso_addon_config(); |
|
476 | - // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
477 | - // but BEFORE the actual update occurs |
|
478 | - add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
479 | - // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
480 | - $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
481 | - $this->legacy_shortcodes_manager = null; |
|
482 | - // now update "ee_config" |
|
483 | - $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
484 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
485 | - EE_Config::log(EE_Config::OPTION_NAME); |
|
486 | - // if not saved... check if the hook we just added still exists; |
|
487 | - // if it does, it means one of two things: |
|
488 | - // that update_option bailed at the ( $value === $old_value ) conditional, |
|
489 | - // or... |
|
490 | - // the db update query returned 0 rows affected |
|
491 | - // (probably because the data value was the same from it's perspective) |
|
492 | - // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
493 | - // but just means no update occurred, so don't display an error to the user. |
|
494 | - // BUT... if update_option returns FALSE, AND the hook is missing, |
|
495 | - // then it means that something truly went wrong |
|
496 | - $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
497 | - // remove our action since we don't want it in the system anymore |
|
498 | - remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
499 | - do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
500 | - //self::$_instance = $clone; |
|
501 | - //unset( $clone ); |
|
502 | - // if config remains the same or was updated successfully |
|
503 | - if ($saved) { |
|
504 | - if ($add_success) { |
|
505 | - EE_Error::add_success( |
|
506 | - __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
507 | - __FILE__, |
|
508 | - __FUNCTION__, |
|
509 | - __LINE__ |
|
510 | - ); |
|
511 | - } |
|
512 | - return true; |
|
513 | - } else { |
|
514 | - if ($add_error) { |
|
515 | - EE_Error::add_error( |
|
516 | - __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
517 | - __FILE__, |
|
518 | - __FUNCTION__, |
|
519 | - __LINE__ |
|
520 | - ); |
|
521 | - } |
|
522 | - return false; |
|
523 | - } |
|
524 | - } |
|
525 | - |
|
526 | - |
|
527 | - |
|
528 | - /** |
|
529 | - * _verify_config_params |
|
530 | - * |
|
531 | - * @access private |
|
532 | - * @param string $section |
|
533 | - * @param string $name |
|
534 | - * @param string $config_class |
|
535 | - * @param EE_Config_Base $config_obj |
|
536 | - * @param array $tests_to_run |
|
537 | - * @param bool $display_errors |
|
538 | - * @return bool TRUE on success, FALSE on fail |
|
539 | - */ |
|
540 | - private function _verify_config_params( |
|
541 | - $section = '', |
|
542 | - $name = '', |
|
543 | - $config_class = '', |
|
544 | - $config_obj = null, |
|
545 | - $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
546 | - $display_errors = true |
|
547 | - ) { |
|
548 | - try { |
|
549 | - foreach ($tests_to_run as $test) { |
|
550 | - switch ($test) { |
|
551 | - // TEST #1 : check that section was set |
|
552 | - case 1 : |
|
553 | - if (empty($section)) { |
|
554 | - if ($display_errors) { |
|
555 | - throw new EE_Error( |
|
556 | - sprintf( |
|
557 | - __( |
|
558 | - 'No configuration section has been provided while attempting to save "%s".', |
|
559 | - 'event_espresso' |
|
560 | - ), |
|
561 | - $config_class |
|
562 | - ) |
|
563 | - ); |
|
564 | - } |
|
565 | - return false; |
|
566 | - } |
|
567 | - break; |
|
568 | - // TEST #2 : check that settings section exists |
|
569 | - case 2 : |
|
570 | - if (! isset($this->{$section})) { |
|
571 | - if ($display_errors) { |
|
572 | - throw new EE_Error( |
|
573 | - sprintf( |
|
574 | - __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
575 | - $section |
|
576 | - ) |
|
577 | - ); |
|
578 | - } |
|
579 | - return false; |
|
580 | - } |
|
581 | - break; |
|
582 | - // TEST #3 : check that section is the proper format |
|
583 | - case 3 : |
|
584 | - if ( |
|
585 | - ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
586 | - ) { |
|
587 | - if ($display_errors) { |
|
588 | - throw new EE_Error( |
|
589 | - sprintf( |
|
590 | - __( |
|
591 | - 'The "%s" configuration settings have not been formatted correctly.', |
|
592 | - 'event_espresso' |
|
593 | - ), |
|
594 | - $section |
|
595 | - ) |
|
596 | - ); |
|
597 | - } |
|
598 | - return false; |
|
599 | - } |
|
600 | - break; |
|
601 | - // TEST #4 : check that config section name has been set |
|
602 | - case 4 : |
|
603 | - if (empty($name)) { |
|
604 | - if ($display_errors) { |
|
605 | - throw new EE_Error( |
|
606 | - __( |
|
607 | - 'No name has been provided for the specific configuration section.', |
|
608 | - 'event_espresso' |
|
609 | - ) |
|
610 | - ); |
|
611 | - } |
|
612 | - return false; |
|
613 | - } |
|
614 | - break; |
|
615 | - // TEST #5 : check that a config class name has been set |
|
616 | - case 5 : |
|
617 | - if (empty($config_class)) { |
|
618 | - if ($display_errors) { |
|
619 | - throw new EE_Error( |
|
620 | - __( |
|
621 | - 'No class name has been provided for the specific configuration section.', |
|
622 | - 'event_espresso' |
|
623 | - ) |
|
624 | - ); |
|
625 | - } |
|
626 | - return false; |
|
627 | - } |
|
628 | - break; |
|
629 | - // TEST #6 : verify config class is accessible |
|
630 | - case 6 : |
|
631 | - if (! class_exists($config_class)) { |
|
632 | - if ($display_errors) { |
|
633 | - throw new EE_Error( |
|
634 | - sprintf( |
|
635 | - __( |
|
636 | - 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
637 | - 'event_espresso' |
|
638 | - ), |
|
639 | - $config_class |
|
640 | - ) |
|
641 | - ); |
|
642 | - } |
|
643 | - return false; |
|
644 | - } |
|
645 | - break; |
|
646 | - // TEST #7 : check that config has even been set |
|
647 | - case 7 : |
|
648 | - if (! isset($this->{$section}->{$name})) { |
|
649 | - if ($display_errors) { |
|
650 | - throw new EE_Error( |
|
651 | - sprintf( |
|
652 | - __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
653 | - $section, |
|
654 | - $name |
|
655 | - ) |
|
656 | - ); |
|
657 | - } |
|
658 | - return false; |
|
659 | - } else { |
|
660 | - // and make sure it's not serialized |
|
661 | - $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
662 | - } |
|
663 | - break; |
|
664 | - // TEST #8 : check that config is the requested type |
|
665 | - case 8 : |
|
666 | - if (! $this->{$section}->{$name} instanceof $config_class) { |
|
667 | - if ($display_errors) { |
|
668 | - throw new EE_Error( |
|
669 | - sprintf( |
|
670 | - __( |
|
671 | - 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
672 | - 'event_espresso' |
|
673 | - ), |
|
674 | - $section, |
|
675 | - $name, |
|
676 | - $config_class |
|
677 | - ) |
|
678 | - ); |
|
679 | - } |
|
680 | - return false; |
|
681 | - } |
|
682 | - break; |
|
683 | - // TEST #9 : verify config object |
|
684 | - case 9 : |
|
685 | - if (! $config_obj instanceof EE_Config_Base) { |
|
686 | - if ($display_errors) { |
|
687 | - throw new EE_Error( |
|
688 | - sprintf( |
|
689 | - __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
690 | - print_r($config_obj, true) |
|
691 | - ) |
|
692 | - ); |
|
693 | - } |
|
694 | - return false; |
|
695 | - } |
|
696 | - break; |
|
697 | - } |
|
698 | - } |
|
699 | - } catch (EE_Error $e) { |
|
700 | - $e->get_error(); |
|
701 | - } |
|
702 | - // you have successfully run the gauntlet |
|
703 | - return true; |
|
704 | - } |
|
705 | - |
|
706 | - |
|
707 | - |
|
708 | - /** |
|
709 | - * _generate_config_option_name |
|
710 | - * |
|
711 | - * @access protected |
|
712 | - * @param string $section |
|
713 | - * @param string $name |
|
714 | - * @return string |
|
715 | - */ |
|
716 | - private function _generate_config_option_name($section = '', $name = '') |
|
717 | - { |
|
718 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
719 | - } |
|
720 | - |
|
721 | - |
|
722 | - |
|
723 | - /** |
|
724 | - * _set_config_class |
|
725 | - * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
726 | - * |
|
727 | - * @access private |
|
728 | - * @param string $config_class |
|
729 | - * @param string $name |
|
730 | - * @return string |
|
731 | - */ |
|
732 | - private function _set_config_class($config_class = '', $name = '') |
|
733 | - { |
|
734 | - return ! empty($config_class) |
|
735 | - ? $config_class |
|
736 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
737 | - } |
|
738 | - |
|
739 | - |
|
740 | - |
|
741 | - /** |
|
742 | - * set_config |
|
743 | - * |
|
744 | - * @access protected |
|
745 | - * @param string $section |
|
746 | - * @param string $name |
|
747 | - * @param string $config_class |
|
748 | - * @param EE_Config_Base $config_obj |
|
749 | - * @return EE_Config_Base |
|
750 | - */ |
|
751 | - public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
752 | - { |
|
753 | - // ensure config class is set to something |
|
754 | - $config_class = $this->_set_config_class($config_class, $name); |
|
755 | - // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
756 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
757 | - return null; |
|
758 | - } |
|
759 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
760 | - // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
761 | - if (! isset($this->_addon_option_names[$config_option_name])) { |
|
762 | - $this->_addon_option_names[$config_option_name] = $config_class; |
|
763 | - $this->update_addon_option_names(); |
|
764 | - } |
|
765 | - // verify the incoming config object but suppress errors |
|
766 | - if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
767 | - $config_obj = new $config_class(); |
|
768 | - } |
|
769 | - if (get_option($config_option_name)) { |
|
770 | - EE_Config::log($config_option_name); |
|
771 | - update_option($config_option_name, $config_obj); |
|
772 | - $this->{$section}->{$name} = $config_obj; |
|
773 | - return $this->{$section}->{$name}; |
|
774 | - } else { |
|
775 | - // create a wp-option for this config |
|
776 | - if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
777 | - $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
778 | - return $this->{$section}->{$name}; |
|
779 | - } else { |
|
780 | - EE_Error::add_error( |
|
781 | - sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
782 | - __FILE__, |
|
783 | - __FUNCTION__, |
|
784 | - __LINE__ |
|
785 | - ); |
|
786 | - return null; |
|
787 | - } |
|
788 | - } |
|
789 | - } |
|
790 | - |
|
791 | - |
|
792 | - |
|
793 | - /** |
|
794 | - * update_config |
|
795 | - * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
796 | - * |
|
797 | - * @access public |
|
798 | - * @param string $section |
|
799 | - * @param string $name |
|
800 | - * @param EE_Config_Base|string $config_obj |
|
801 | - * @param bool $throw_errors |
|
802 | - * @return bool |
|
803 | - */ |
|
804 | - public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
805 | - { |
|
806 | - // don't allow config updates during WP heartbeats |
|
807 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
808 | - return false; |
|
809 | - } |
|
810 | - $config_obj = maybe_unserialize($config_obj); |
|
811 | - // get class name of the incoming object |
|
812 | - $config_class = get_class($config_obj); |
|
813 | - // run tests 1-5 and 9 to verify config |
|
814 | - if (! $this->_verify_config_params( |
|
815 | - $section, |
|
816 | - $name, |
|
817 | - $config_class, |
|
818 | - $config_obj, |
|
819 | - array(1, 2, 3, 4, 7, 9) |
|
820 | - ) |
|
821 | - ) { |
|
822 | - return false; |
|
823 | - } |
|
824 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
825 | - // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
826 | - if (! isset($this->_addon_option_names[$config_option_name])) { |
|
827 | - // save new config to db |
|
828 | - if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
829 | - return true; |
|
830 | - } |
|
831 | - } else { |
|
832 | - // first check if the record already exists |
|
833 | - $existing_config = get_option($config_option_name); |
|
834 | - $config_obj = serialize($config_obj); |
|
835 | - // just return if db record is already up to date (NOT type safe comparison) |
|
836 | - if ($existing_config == $config_obj) { |
|
837 | - $this->{$section}->{$name} = $config_obj; |
|
838 | - return true; |
|
839 | - } else if (update_option($config_option_name, $config_obj)) { |
|
840 | - EE_Config::log($config_option_name); |
|
841 | - // update wp-option for this config class |
|
842 | - $this->{$section}->{$name} = $config_obj; |
|
843 | - return true; |
|
844 | - } elseif ($throw_errors) { |
|
845 | - EE_Error::add_error( |
|
846 | - sprintf( |
|
847 | - __( |
|
848 | - 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
849 | - 'event_espresso' |
|
850 | - ), |
|
851 | - $config_class, |
|
852 | - 'EE_Config->' . $section . '->' . $name |
|
853 | - ), |
|
854 | - __FILE__, |
|
855 | - __FUNCTION__, |
|
856 | - __LINE__ |
|
857 | - ); |
|
858 | - } |
|
859 | - } |
|
860 | - return false; |
|
861 | - } |
|
862 | - |
|
863 | - |
|
864 | - |
|
865 | - /** |
|
866 | - * get_config |
|
867 | - * |
|
868 | - * @access public |
|
869 | - * @param string $section |
|
870 | - * @param string $name |
|
871 | - * @param string $config_class |
|
872 | - * @return mixed EE_Config_Base | NULL |
|
873 | - */ |
|
874 | - public function get_config($section = '', $name = '', $config_class = '') |
|
875 | - { |
|
876 | - // ensure config class is set to something |
|
877 | - $config_class = $this->_set_config_class($config_class, $name); |
|
878 | - // run tests 1-4, 6 and 7 to verify that all params have been set |
|
879 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
880 | - return null; |
|
881 | - } |
|
882 | - // now test if the requested config object exists, but suppress errors |
|
883 | - if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
884 | - // config already exists, so pass it back |
|
885 | - return $this->{$section}->{$name}; |
|
886 | - } |
|
887 | - // load config option from db if it exists |
|
888 | - $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
889 | - // verify the newly retrieved config object, but suppress errors |
|
890 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
891 | - // config is good, so set it and pass it back |
|
892 | - $this->{$section}->{$name} = $config_obj; |
|
893 | - return $this->{$section}->{$name}; |
|
894 | - } |
|
895 | - // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
896 | - $config_obj = $this->set_config($section, $name, $config_class); |
|
897 | - // verify the newly created config object |
|
898 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
899 | - return $this->{$section}->{$name}; |
|
900 | - } else { |
|
901 | - EE_Error::add_error( |
|
902 | - sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
903 | - __FILE__, |
|
904 | - __FUNCTION__, |
|
905 | - __LINE__ |
|
906 | - ); |
|
907 | - } |
|
908 | - return null; |
|
909 | - } |
|
910 | - |
|
911 | - |
|
912 | - |
|
913 | - /** |
|
914 | - * get_config_option |
|
915 | - * |
|
916 | - * @access public |
|
917 | - * @param string $config_option_name |
|
918 | - * @return mixed EE_Config_Base | FALSE |
|
919 | - */ |
|
920 | - public function get_config_option($config_option_name = '') |
|
921 | - { |
|
922 | - // retrieve the wp-option for this config class. |
|
923 | - $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
924 | - if (empty($config_option)) { |
|
925 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
926 | - } |
|
927 | - return $config_option; |
|
928 | - } |
|
929 | - |
|
930 | - |
|
931 | - |
|
932 | - /** |
|
933 | - * log |
|
934 | - * |
|
935 | - * @param string $config_option_name |
|
936 | - */ |
|
937 | - public static function log($config_option_name = '') |
|
938 | - { |
|
939 | - if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
940 | - $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
941 | - //copy incoming $_REQUEST and sanitize it so we can save it |
|
942 | - $_request = $_REQUEST; |
|
943 | - array_walk_recursive($_request, 'sanitize_text_field'); |
|
944 | - $config_log[(string)microtime(true)] = array( |
|
945 | - 'config_name' => $config_option_name, |
|
946 | - 'request' => $_request, |
|
947 | - ); |
|
948 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
949 | - } |
|
950 | - } |
|
951 | - |
|
952 | - |
|
953 | - |
|
954 | - /** |
|
955 | - * trim_log |
|
956 | - * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
957 | - */ |
|
958 | - public static function trim_log() |
|
959 | - { |
|
960 | - if (! EE_Config::logging_enabled()) { |
|
961 | - return; |
|
962 | - } |
|
963 | - $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
964 | - $log_length = count($config_log); |
|
965 | - if ($log_length > EE_Config::LOG_LENGTH) { |
|
966 | - ksort($config_log); |
|
967 | - $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
968 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
969 | - } |
|
970 | - } |
|
971 | - |
|
972 | - |
|
973 | - |
|
974 | - /** |
|
975 | - * get_page_for_posts |
|
976 | - * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
977 | - * wp-option "page_for_posts", or "posts" if no page is selected |
|
978 | - * |
|
979 | - * @access public |
|
980 | - * @return string |
|
981 | - */ |
|
982 | - public static function get_page_for_posts() |
|
983 | - { |
|
984 | - $page_for_posts = get_option('page_for_posts'); |
|
985 | - if (! $page_for_posts) { |
|
986 | - return 'posts'; |
|
987 | - } |
|
988 | - /** @type WPDB $wpdb */ |
|
989 | - global $wpdb; |
|
990 | - $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
991 | - return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
992 | - } |
|
993 | - |
|
994 | - |
|
995 | - |
|
996 | - /** |
|
997 | - * register_shortcodes_and_modules. |
|
998 | - * At this point, it's too early to tell if we're maintenance mode or not. |
|
999 | - * In fact, this is where we give modules a chance to let core know they exist |
|
1000 | - * so they can help trigger maintenance mode if it's needed |
|
1001 | - * |
|
1002 | - * @access public |
|
1003 | - * @return void |
|
1004 | - */ |
|
1005 | - public function register_shortcodes_and_modules() |
|
1006 | - { |
|
1007 | - // allow modules to set hooks for the rest of the system |
|
1008 | - EE_Registry::instance()->modules = $this->_register_modules(); |
|
1009 | - } |
|
1010 | - |
|
1011 | - |
|
1012 | - |
|
1013 | - /** |
|
1014 | - * initialize_shortcodes_and_modules |
|
1015 | - * meaning they can start adding their hooks to get stuff done |
|
1016 | - * |
|
1017 | - * @access public |
|
1018 | - * @return void |
|
1019 | - */ |
|
1020 | - public function initialize_shortcodes_and_modules() |
|
1021 | - { |
|
1022 | - // allow modules to set hooks for the rest of the system |
|
1023 | - $this->_initialize_modules(); |
|
1024 | - } |
|
1025 | - |
|
1026 | - |
|
1027 | - |
|
1028 | - /** |
|
1029 | - * widgets_init |
|
1030 | - * |
|
1031 | - * @access private |
|
1032 | - * @return void |
|
1033 | - */ |
|
1034 | - public function widgets_init() |
|
1035 | - { |
|
1036 | - //only init widgets on admin pages when not in complete maintenance, and |
|
1037 | - //on frontend when not in any maintenance mode |
|
1038 | - if ( |
|
1039 | - ! EE_Maintenance_Mode::instance()->level() |
|
1040 | - || ( |
|
1041 | - is_admin() |
|
1042 | - && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
1043 | - ) |
|
1044 | - ) { |
|
1045 | - // grab list of installed widgets |
|
1046 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1047 | - // filter list of modules to register |
|
1048 | - $widgets_to_register = apply_filters( |
|
1049 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
1050 | - $widgets_to_register |
|
1051 | - ); |
|
1052 | - if (! empty($widgets_to_register)) { |
|
1053 | - // cycle thru widget folders |
|
1054 | - foreach ($widgets_to_register as $widget_path) { |
|
1055 | - // add to list of installed widget modules |
|
1056 | - EE_Config::register_ee_widget($widget_path); |
|
1057 | - } |
|
1058 | - } |
|
1059 | - // filter list of installed modules |
|
1060 | - EE_Registry::instance()->widgets = apply_filters( |
|
1061 | - 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
1062 | - EE_Registry::instance()->widgets |
|
1063 | - ); |
|
1064 | - } |
|
1065 | - } |
|
1066 | - |
|
1067 | - |
|
1068 | - |
|
1069 | - /** |
|
1070 | - * register_ee_widget - makes core aware of this widget |
|
1071 | - * |
|
1072 | - * @access public |
|
1073 | - * @param string $widget_path - full path up to and including widget folder |
|
1074 | - * @return void |
|
1075 | - */ |
|
1076 | - public static function register_ee_widget($widget_path = null) |
|
1077 | - { |
|
1078 | - do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1079 | - $widget_ext = '.widget.php'; |
|
1080 | - // make all separators match |
|
1081 | - $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1082 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1083 | - if (strpos($widget_path, $widget_ext) !== false) { |
|
1084 | - // grab and shortcode file name from directory name and break apart at dots |
|
1085 | - $file_name = explode('.', basename($widget_path)); |
|
1086 | - // take first segment from file name pieces and remove class prefix if it exists |
|
1087 | - $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1088 | - // sanitize shortcode directory name |
|
1089 | - $widget = sanitize_key($widget); |
|
1090 | - // now we need to rebuild the shortcode path |
|
1091 | - $widget_path = explode(DS, $widget_path); |
|
1092 | - // remove last segment |
|
1093 | - array_pop($widget_path); |
|
1094 | - // glue it back together |
|
1095 | - $widget_path = implode(DS, $widget_path); |
|
1096 | - } else { |
|
1097 | - // grab and sanitize widget directory name |
|
1098 | - $widget = sanitize_key(basename($widget_path)); |
|
1099 | - } |
|
1100 | - // create classname from widget directory name |
|
1101 | - $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1102 | - // add class prefix |
|
1103 | - $widget_class = 'EEW_' . $widget; |
|
1104 | - // does the widget exist ? |
|
1105 | - if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1106 | - $msg = sprintf( |
|
1107 | - __( |
|
1108 | - 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
1109 | - 'event_espresso' |
|
1110 | - ), |
|
1111 | - $widget_class, |
|
1112 | - $widget_path . DS . $widget_class . $widget_ext |
|
1113 | - ); |
|
1114 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1115 | - return; |
|
1116 | - } |
|
1117 | - // load the widget class file |
|
1118 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1119 | - // verify that class exists |
|
1120 | - if (! class_exists($widget_class)) { |
|
1121 | - $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1122 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1123 | - return; |
|
1124 | - } |
|
1125 | - register_widget($widget_class); |
|
1126 | - // add to array of registered widgets |
|
1127 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1128 | - } |
|
1129 | - |
|
1130 | - |
|
1131 | - |
|
1132 | - /** |
|
1133 | - * _register_modules |
|
1134 | - * |
|
1135 | - * @access private |
|
1136 | - * @return array |
|
1137 | - */ |
|
1138 | - private function _register_modules() |
|
1139 | - { |
|
1140 | - // grab list of installed modules |
|
1141 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1142 | - // filter list of modules to register |
|
1143 | - $modules_to_register = apply_filters( |
|
1144 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
1145 | - $modules_to_register |
|
1146 | - ); |
|
1147 | - if (! empty($modules_to_register)) { |
|
1148 | - // loop through folders |
|
1149 | - foreach ($modules_to_register as $module_path) { |
|
1150 | - /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1151 | - if ( |
|
1152 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1153 | - && $module_path !== EE_MODULES . 'gateways' |
|
1154 | - ) { |
|
1155 | - // add to list of installed modules |
|
1156 | - EE_Config::register_module($module_path); |
|
1157 | - } |
|
1158 | - } |
|
1159 | - } |
|
1160 | - // filter list of installed modules |
|
1161 | - return apply_filters( |
|
1162 | - 'FHEE__EE_Config___register_modules__installed_modules', |
|
1163 | - EE_Registry::instance()->modules |
|
1164 | - ); |
|
1165 | - } |
|
1166 | - |
|
1167 | - |
|
1168 | - |
|
1169 | - /** |
|
1170 | - * register_module - makes core aware of this module |
|
1171 | - * |
|
1172 | - * @access public |
|
1173 | - * @param string $module_path - full path up to and including module folder |
|
1174 | - * @return bool |
|
1175 | - */ |
|
1176 | - public static function register_module($module_path = null) |
|
1177 | - { |
|
1178 | - do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1179 | - $module_ext = '.module.php'; |
|
1180 | - // make all separators match |
|
1181 | - $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1182 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1183 | - if (strpos($module_path, $module_ext) !== false) { |
|
1184 | - // grab and shortcode file name from directory name and break apart at dots |
|
1185 | - $module_file = explode('.', basename($module_path)); |
|
1186 | - // now we need to rebuild the shortcode path |
|
1187 | - $module_path = explode(DS, $module_path); |
|
1188 | - // remove last segment |
|
1189 | - array_pop($module_path); |
|
1190 | - // glue it back together |
|
1191 | - $module_path = implode(DS, $module_path) . DS; |
|
1192 | - // take first segment from file name pieces and sanitize it |
|
1193 | - $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1194 | - // ensure class prefix is added |
|
1195 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1196 | - } else { |
|
1197 | - // we need to generate the filename based off of the folder name |
|
1198 | - // grab and sanitize module name |
|
1199 | - $module = strtolower(basename($module_path)); |
|
1200 | - $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1201 | - // like trailingslashit() |
|
1202 | - $module_path = rtrim($module_path, DS) . DS; |
|
1203 | - // create classname from module directory name |
|
1204 | - $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1205 | - // add class prefix |
|
1206 | - $module_class = 'EED_' . $module; |
|
1207 | - } |
|
1208 | - // does the module exist ? |
|
1209 | - if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1210 | - $msg = sprintf( |
|
1211 | - __( |
|
1212 | - 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
1213 | - 'event_espresso' |
|
1214 | - ), |
|
1215 | - $module |
|
1216 | - ); |
|
1217 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1218 | - return false; |
|
1219 | - } |
|
1220 | - // load the module class file |
|
1221 | - require_once($module_path . $module_class . $module_ext); |
|
1222 | - // verify that class exists |
|
1223 | - if (! class_exists($module_class)) { |
|
1224 | - $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1225 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1226 | - return false; |
|
1227 | - } |
|
1228 | - // add to array of registered modules |
|
1229 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1230 | - do_action( |
|
1231 | - 'AHEE__EE_Config__register_module__complete', |
|
1232 | - $module_class, |
|
1233 | - EE_Registry::instance()->modules->{$module_class} |
|
1234 | - ); |
|
1235 | - return true; |
|
1236 | - } |
|
1237 | - |
|
1238 | - |
|
1239 | - |
|
1240 | - /** |
|
1241 | - * _initialize_modules |
|
1242 | - * allow modules to set hooks for the rest of the system |
|
1243 | - * |
|
1244 | - * @access private |
|
1245 | - * @return void |
|
1246 | - */ |
|
1247 | - private function _initialize_modules() |
|
1248 | - { |
|
1249 | - // cycle thru shortcode folders |
|
1250 | - foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1251 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1252 | - // which set hooks ? |
|
1253 | - if (is_admin()) { |
|
1254 | - // fire immediately |
|
1255 | - call_user_func(array($module_class, 'set_hooks_admin')); |
|
1256 | - } else { |
|
1257 | - // delay until other systems are online |
|
1258 | - add_action( |
|
1259 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1260 | - array($module_class, 'set_hooks') |
|
1261 | - ); |
|
1262 | - } |
|
1263 | - } |
|
1264 | - } |
|
1265 | - |
|
1266 | - |
|
1267 | - |
|
1268 | - /** |
|
1269 | - * register_route - adds module method routes to route_map |
|
1270 | - * |
|
1271 | - * @access public |
|
1272 | - * @param string $route - "pretty" public alias for module method |
|
1273 | - * @param string $module - module name (classname without EED_ prefix) |
|
1274 | - * @param string $method_name - the actual module method to be routed to |
|
1275 | - * @param string $key - url param key indicating a route is being called |
|
1276 | - * @return bool |
|
1277 | - */ |
|
1278 | - public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
1279 | - { |
|
1280 | - do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1281 | - $module = str_replace('EED_', '', $module); |
|
1282 | - $module_class = 'EED_' . $module; |
|
1283 | - if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1284 | - $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1285 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1286 | - return false; |
|
1287 | - } |
|
1288 | - if (empty($route)) { |
|
1289 | - $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1290 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1291 | - return false; |
|
1292 | - } |
|
1293 | - if (! method_exists('EED_' . $module, $method_name)) { |
|
1294 | - $msg = sprintf( |
|
1295 | - __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1296 | - $route |
|
1297 | - ); |
|
1298 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1299 | - return false; |
|
1300 | - } |
|
1301 | - EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
1302 | - return true; |
|
1303 | - } |
|
1304 | - |
|
1305 | - |
|
1306 | - |
|
1307 | - /** |
|
1308 | - * get_route - get module method route |
|
1309 | - * |
|
1310 | - * @access public |
|
1311 | - * @param string $route - "pretty" public alias for module method |
|
1312 | - * @param string $key - url param key indicating a route is being called |
|
1313 | - * @return string |
|
1314 | - */ |
|
1315 | - public static function get_route($route = null, $key = 'ee') |
|
1316 | - { |
|
1317 | - do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1318 | - $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
1319 | - if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1320 | - return EE_Config::$_module_route_map[$key][$route]; |
|
1321 | - } |
|
1322 | - return null; |
|
1323 | - } |
|
1324 | - |
|
1325 | - |
|
1326 | - |
|
1327 | - /** |
|
1328 | - * get_routes - get ALL module method routes |
|
1329 | - * |
|
1330 | - * @access public |
|
1331 | - * @return array |
|
1332 | - */ |
|
1333 | - public static function get_routes() |
|
1334 | - { |
|
1335 | - return EE_Config::$_module_route_map; |
|
1336 | - } |
|
1337 | - |
|
1338 | - |
|
1339 | - |
|
1340 | - /** |
|
1341 | - * register_forward - allows modules to forward request to another module for further processing |
|
1342 | - * |
|
1343 | - * @access public |
|
1344 | - * @param string $route - "pretty" public alias for module method |
|
1345 | - * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
1346 | - * class, allows different forwards to be served based on status |
|
1347 | - * @param array|string $forward - function name or array( class, method ) |
|
1348 | - * @param string $key - url param key indicating a route is being called |
|
1349 | - * @return bool |
|
1350 | - */ |
|
1351 | - public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
1352 | - { |
|
1353 | - do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1354 | - if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1355 | - $msg = sprintf( |
|
1356 | - __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1357 | - $route |
|
1358 | - ); |
|
1359 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1360 | - return false; |
|
1361 | - } |
|
1362 | - if (empty($forward)) { |
|
1363 | - $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1364 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1365 | - return false; |
|
1366 | - } |
|
1367 | - if (is_array($forward)) { |
|
1368 | - if (! isset($forward[1])) { |
|
1369 | - $msg = sprintf( |
|
1370 | - __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1371 | - $route |
|
1372 | - ); |
|
1373 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1374 | - return false; |
|
1375 | - } |
|
1376 | - if (! method_exists($forward[0], $forward[1])) { |
|
1377 | - $msg = sprintf( |
|
1378 | - __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1379 | - $forward[1], |
|
1380 | - $route |
|
1381 | - ); |
|
1382 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1383 | - return false; |
|
1384 | - } |
|
1385 | - } else if (! function_exists($forward)) { |
|
1386 | - $msg = sprintf( |
|
1387 | - __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1388 | - $forward, |
|
1389 | - $route |
|
1390 | - ); |
|
1391 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1392 | - return false; |
|
1393 | - } |
|
1394 | - EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1395 | - return true; |
|
1396 | - } |
|
1397 | - |
|
1398 | - |
|
1399 | - |
|
1400 | - /** |
|
1401 | - * get_forward - get forwarding route |
|
1402 | - * |
|
1403 | - * @access public |
|
1404 | - * @param string $route - "pretty" public alias for module method |
|
1405 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1406 | - * allows different forwards to be served based on status |
|
1407 | - * @param string $key - url param key indicating a route is being called |
|
1408 | - * @return string |
|
1409 | - */ |
|
1410 | - public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
1411 | - { |
|
1412 | - do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1413 | - if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1414 | - return apply_filters( |
|
1415 | - 'FHEE__EE_Config__get_forward', |
|
1416 | - EE_Config::$_module_forward_map[$key][$route][$status], |
|
1417 | - $route, |
|
1418 | - $status |
|
1419 | - ); |
|
1420 | - } |
|
1421 | - return null; |
|
1422 | - } |
|
1423 | - |
|
1424 | - |
|
1425 | - |
|
1426 | - /** |
|
1427 | - * register_forward - allows modules to specify different view templates for different method routes and status |
|
1428 | - * results |
|
1429 | - * |
|
1430 | - * @access public |
|
1431 | - * @param string $route - "pretty" public alias for module method |
|
1432 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1433 | - * allows different views to be served based on status |
|
1434 | - * @param string $view |
|
1435 | - * @param string $key - url param key indicating a route is being called |
|
1436 | - * @return bool |
|
1437 | - */ |
|
1438 | - public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
1439 | - { |
|
1440 | - do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1441 | - if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1442 | - $msg = sprintf( |
|
1443 | - __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1444 | - $route |
|
1445 | - ); |
|
1446 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1447 | - return false; |
|
1448 | - } |
|
1449 | - if (! is_readable($view)) { |
|
1450 | - $msg = sprintf( |
|
1451 | - __( |
|
1452 | - 'The %s view file could not be found or is not readable due to file permissions.', |
|
1453 | - 'event_espresso' |
|
1454 | - ), |
|
1455 | - $view |
|
1456 | - ); |
|
1457 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1458 | - return false; |
|
1459 | - } |
|
1460 | - EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1461 | - return true; |
|
1462 | - } |
|
1463 | - |
|
1464 | - |
|
1465 | - |
|
1466 | - /** |
|
1467 | - * get_view - get view for route and status |
|
1468 | - * |
|
1469 | - * @access public |
|
1470 | - * @param string $route - "pretty" public alias for module method |
|
1471 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1472 | - * allows different views to be served based on status |
|
1473 | - * @param string $key - url param key indicating a route is being called |
|
1474 | - * @return string |
|
1475 | - */ |
|
1476 | - public static function get_view($route = null, $status = 0, $key = 'ee') |
|
1477 | - { |
|
1478 | - do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1479 | - if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1480 | - return apply_filters( |
|
1481 | - 'FHEE__EE_Config__get_view', |
|
1482 | - EE_Config::$_module_view_map[$key][$route][$status], |
|
1483 | - $route, |
|
1484 | - $status |
|
1485 | - ); |
|
1486 | - } |
|
1487 | - return null; |
|
1488 | - } |
|
1489 | - |
|
1490 | - |
|
1491 | - |
|
1492 | - public function update_addon_option_names() |
|
1493 | - { |
|
1494 | - update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1495 | - } |
|
1496 | - |
|
1497 | - |
|
1498 | - |
|
1499 | - public function shutdown() |
|
1500 | - { |
|
1501 | - $this->update_addon_option_names(); |
|
1502 | - } |
|
1503 | - |
|
1504 | - |
|
1505 | - |
|
1506 | - /** |
|
1507 | - * @return LegacyShortcodesManager |
|
1508 | - */ |
|
1509 | - public static function getLegacyShortcodesManager() |
|
1510 | - { |
|
1511 | - |
|
1512 | - if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
1513 | - EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
1514 | - EE_Registry::instance() |
|
1515 | - ); |
|
1516 | - } |
|
1517 | - return EE_Config::instance()->legacy_shortcodes_manager; |
|
1518 | - } |
|
1519 | - |
|
1520 | - |
|
1521 | - |
|
1522 | - /** |
|
1523 | - * register_shortcode - makes core aware of this shortcode |
|
1524 | - * |
|
1525 | - * @deprecated 4.9.26 |
|
1526 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
1527 | - * @return bool |
|
1528 | - */ |
|
1529 | - public static function register_shortcode($shortcode_path = null) |
|
1530 | - { |
|
1531 | - EE_Error::doing_it_wrong( |
|
1532 | - __METHOD__, |
|
1533 | - __( |
|
1534 | - 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
1535 | - 'event_espresso' |
|
1536 | - ), |
|
1537 | - '4.9.26' |
|
1538 | - ); |
|
1539 | - return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
1540 | - } |
|
1541 | - |
|
1542 | - |
|
1543 | - |
|
1544 | -} |
|
1545 | - |
|
1546 | - |
|
1547 | - |
|
1548 | -/** |
|
1549 | - * Base class used for config classes. These classes should generally not have |
|
1550 | - * magic functions in use, except we'll allow them to magically set and get stuff... |
|
1551 | - * basically, they should just be well-defined stdClasses |
|
1552 | - */ |
|
1553 | -class EE_Config_Base |
|
1554 | -{ |
|
1555 | - |
|
1556 | - /** |
|
1557 | - * Utility function for escaping the value of a property and returning. |
|
1558 | - * |
|
1559 | - * @param string $property property name (checks to see if exists). |
|
1560 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1561 | - * @throws \EE_Error |
|
1562 | - */ |
|
1563 | - public function get_pretty($property) |
|
1564 | - { |
|
1565 | - if (! property_exists($this, $property)) { |
|
1566 | - throw new EE_Error( |
|
1567 | - sprintf( |
|
1568 | - __( |
|
1569 | - '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
1570 | - 'event_espresso' |
|
1571 | - ), |
|
1572 | - get_class($this), |
|
1573 | - $property |
|
1574 | - ) |
|
1575 | - ); |
|
1576 | - } |
|
1577 | - //just handling escaping of strings for now. |
|
1578 | - if (is_string($this->{$property})) { |
|
1579 | - return stripslashes($this->{$property}); |
|
1580 | - } |
|
1581 | - return $this->{$property}; |
|
1582 | - } |
|
1583 | - |
|
1584 | - |
|
1585 | - |
|
1586 | - public function populate() |
|
1587 | - { |
|
1588 | - //grab defaults via a new instance of this class. |
|
1589 | - $class_name = get_class($this); |
|
1590 | - $defaults = new $class_name; |
|
1591 | - //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1592 | - //default from our $defaults object. |
|
1593 | - foreach (get_object_vars($defaults) as $property => $value) { |
|
1594 | - if ($this->{$property} === null) { |
|
1595 | - $this->{$property} = $value; |
|
1596 | - } |
|
1597 | - } |
|
1598 | - //cleanup |
|
1599 | - unset($defaults); |
|
1600 | - } |
|
1601 | - |
|
1602 | - |
|
1603 | - |
|
1604 | - /** |
|
1605 | - * __isset |
|
1606 | - * |
|
1607 | - * @param $a |
|
1608 | - * @return bool |
|
1609 | - */ |
|
1610 | - public function __isset($a) |
|
1611 | - { |
|
1612 | - return false; |
|
1613 | - } |
|
1614 | - |
|
1615 | - |
|
1616 | - |
|
1617 | - /** |
|
1618 | - * __unset |
|
1619 | - * |
|
1620 | - * @param $a |
|
1621 | - * @return bool |
|
1622 | - */ |
|
1623 | - public function __unset($a) |
|
1624 | - { |
|
1625 | - return false; |
|
1626 | - } |
|
1627 | - |
|
1628 | - |
|
1629 | - |
|
1630 | - /** |
|
1631 | - * __clone |
|
1632 | - */ |
|
1633 | - public function __clone() |
|
1634 | - { |
|
1635 | - } |
|
1636 | - |
|
1637 | - |
|
1638 | - |
|
1639 | - /** |
|
1640 | - * __wakeup |
|
1641 | - */ |
|
1642 | - public function __wakeup() |
|
1643 | - { |
|
1644 | - } |
|
1645 | - |
|
1646 | - |
|
1647 | - |
|
1648 | - /** |
|
1649 | - * __destruct |
|
1650 | - */ |
|
1651 | - public function __destruct() |
|
1652 | - { |
|
1653 | - } |
|
1654 | -} |
|
1655 | - |
|
1656 | - |
|
1657 | - |
|
1658 | -/** |
|
1659 | - * Class for defining what's in the EE_Config relating to registration settings |
|
1660 | - */ |
|
1661 | -class EE_Core_Config extends EE_Config_Base |
|
1662 | -{ |
|
1663 | - |
|
1664 | - public $current_blog_id; |
|
1665 | - |
|
1666 | - public $ee_ueip_optin; |
|
1667 | - |
|
1668 | - public $ee_ueip_has_notified; |
|
1669 | - |
|
1670 | - /** |
|
1671 | - * Not to be confused with the 4 critical page variables (See |
|
1672 | - * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1673 | - * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1674 | - * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1675 | - * |
|
1676 | - * @var array |
|
1677 | - */ |
|
1678 | - public $post_shortcodes; |
|
1679 | - |
|
1680 | - public $module_route_map; |
|
1681 | - |
|
1682 | - public $module_forward_map; |
|
1683 | - |
|
1684 | - public $module_view_map; |
|
1685 | - |
|
1686 | - /** |
|
1687 | - * The next 4 vars are the IDs of critical EE pages. |
|
1688 | - * |
|
1689 | - * @var int |
|
1690 | - */ |
|
1691 | - public $reg_page_id; |
|
1692 | - |
|
1693 | - public $txn_page_id; |
|
1694 | - |
|
1695 | - public $thank_you_page_id; |
|
1696 | - |
|
1697 | - public $cancel_page_id; |
|
1698 | - |
|
1699 | - /** |
|
1700 | - * The next 4 vars are the URLs of critical EE pages. |
|
1701 | - * |
|
1702 | - * @var int |
|
1703 | - */ |
|
1704 | - public $reg_page_url; |
|
1705 | - |
|
1706 | - public $txn_page_url; |
|
1707 | - |
|
1708 | - public $thank_you_page_url; |
|
1709 | - |
|
1710 | - public $cancel_page_url; |
|
1711 | - |
|
1712 | - /** |
|
1713 | - * The next vars relate to the custom slugs for EE CPT routes |
|
1714 | - */ |
|
1715 | - public $event_cpt_slug; |
|
1716 | - |
|
1717 | - |
|
1718 | - /** |
|
1719 | - * This caches the _ee_ueip_option in case this config is reset in the same |
|
1720 | - * request across blog switches in a multisite context. |
|
1721 | - * Avoids extra queries to the db for this option. |
|
1722 | - * |
|
1723 | - * @var bool |
|
1724 | - */ |
|
1725 | - public static $ee_ueip_option; |
|
1726 | - |
|
1727 | - |
|
1728 | - |
|
1729 | - /** |
|
1730 | - * class constructor |
|
1731 | - * |
|
1732 | - * @access public |
|
1733 | - */ |
|
1734 | - public function __construct() |
|
1735 | - { |
|
1736 | - // set default organization settings |
|
1737 | - $this->current_blog_id = get_current_blog_id(); |
|
1738 | - $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
1739 | - $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
1740 | - $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1741 | - $this->post_shortcodes = array(); |
|
1742 | - $this->module_route_map = array(); |
|
1743 | - $this->module_forward_map = array(); |
|
1744 | - $this->module_view_map = array(); |
|
1745 | - // critical EE page IDs |
|
1746 | - $this->reg_page_id = 0; |
|
1747 | - $this->txn_page_id = 0; |
|
1748 | - $this->thank_you_page_id = 0; |
|
1749 | - $this->cancel_page_id = 0; |
|
1750 | - // critical EE page URLs |
|
1751 | - $this->reg_page_url = ''; |
|
1752 | - $this->txn_page_url = ''; |
|
1753 | - $this->thank_you_page_url = ''; |
|
1754 | - $this->cancel_page_url = ''; |
|
1755 | - //cpt slugs |
|
1756 | - $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1757 | - //ueip constant check |
|
1758 | - if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1759 | - $this->ee_ueip_optin = false; |
|
1760 | - $this->ee_ueip_has_notified = true; |
|
1761 | - } |
|
1762 | - } |
|
1763 | - |
|
1764 | - |
|
1765 | - |
|
1766 | - /** |
|
1767 | - * @return array |
|
1768 | - */ |
|
1769 | - public function get_critical_pages_array() |
|
1770 | - { |
|
1771 | - return array( |
|
1772 | - $this->reg_page_id, |
|
1773 | - $this->txn_page_id, |
|
1774 | - $this->thank_you_page_id, |
|
1775 | - $this->cancel_page_id, |
|
1776 | - ); |
|
1777 | - } |
|
1778 | - |
|
1779 | - |
|
1780 | - |
|
1781 | - /** |
|
1782 | - * @return array |
|
1783 | - */ |
|
1784 | - public function get_critical_pages_shortcodes_array() |
|
1785 | - { |
|
1786 | - return array( |
|
1787 | - $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1788 | - $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1789 | - $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1790 | - $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
1791 | - ); |
|
1792 | - } |
|
1793 | - |
|
1794 | - |
|
1795 | - |
|
1796 | - /** |
|
1797 | - * gets/returns URL for EE reg_page |
|
1798 | - * |
|
1799 | - * @access public |
|
1800 | - * @return string |
|
1801 | - */ |
|
1802 | - public function reg_page_url() |
|
1803 | - { |
|
1804 | - if (! $this->reg_page_url) { |
|
1805 | - $this->reg_page_url = add_query_arg( |
|
1806 | - array('uts' => time()), |
|
1807 | - get_permalink($this->reg_page_id) |
|
1808 | - ) . '#checkout'; |
|
1809 | - } |
|
1810 | - return $this->reg_page_url; |
|
1811 | - } |
|
1812 | - |
|
1813 | - |
|
1814 | - |
|
1815 | - /** |
|
1816 | - * gets/returns URL for EE txn_page |
|
1817 | - * |
|
1818 | - * @param array $query_args like what gets passed to |
|
1819 | - * add_query_arg() as the first argument |
|
1820 | - * @access public |
|
1821 | - * @return string |
|
1822 | - */ |
|
1823 | - public function txn_page_url($query_args = array()) |
|
1824 | - { |
|
1825 | - if (! $this->txn_page_url) { |
|
1826 | - $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1827 | - } |
|
1828 | - if ($query_args) { |
|
1829 | - return add_query_arg($query_args, $this->txn_page_url); |
|
1830 | - } else { |
|
1831 | - return $this->txn_page_url; |
|
1832 | - } |
|
1833 | - } |
|
1834 | - |
|
1835 | - |
|
1836 | - |
|
1837 | - /** |
|
1838 | - * gets/returns URL for EE thank_you_page |
|
1839 | - * |
|
1840 | - * @param array $query_args like what gets passed to |
|
1841 | - * add_query_arg() as the first argument |
|
1842 | - * @access public |
|
1843 | - * @return string |
|
1844 | - */ |
|
1845 | - public function thank_you_page_url($query_args = array()) |
|
1846 | - { |
|
1847 | - if (! $this->thank_you_page_url) { |
|
1848 | - $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1849 | - } |
|
1850 | - if ($query_args) { |
|
1851 | - return add_query_arg($query_args, $this->thank_you_page_url); |
|
1852 | - } else { |
|
1853 | - return $this->thank_you_page_url; |
|
1854 | - } |
|
1855 | - } |
|
1856 | - |
|
1857 | - |
|
1858 | - |
|
1859 | - /** |
|
1860 | - * gets/returns URL for EE cancel_page |
|
1861 | - * |
|
1862 | - * @access public |
|
1863 | - * @return string |
|
1864 | - */ |
|
1865 | - public function cancel_page_url() |
|
1866 | - { |
|
1867 | - if (! $this->cancel_page_url) { |
|
1868 | - $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1869 | - } |
|
1870 | - return $this->cancel_page_url; |
|
1871 | - } |
|
1872 | - |
|
1873 | - |
|
1874 | - |
|
1875 | - /** |
|
1876 | - * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1877 | - * |
|
1878 | - * @since 4.7.5 |
|
1879 | - */ |
|
1880 | - protected function _reset_urls() |
|
1881 | - { |
|
1882 | - $this->reg_page_url = ''; |
|
1883 | - $this->txn_page_url = ''; |
|
1884 | - $this->cancel_page_url = ''; |
|
1885 | - $this->thank_you_page_url = ''; |
|
1886 | - } |
|
1887 | - |
|
1888 | - |
|
1889 | - |
|
1890 | - /** |
|
1891 | - * Used to return what the optin value is set for the EE User Experience Program. |
|
1892 | - * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
1893 | - * on the main site only. |
|
1894 | - * |
|
1895 | - * @return mixed|void |
|
1896 | - */ |
|
1897 | - protected function _get_main_ee_ueip_optin() |
|
1898 | - { |
|
1899 | - //if this is the main site then we can just bypass our direct query. |
|
1900 | - if (is_main_site()) { |
|
1901 | - return get_option('ee_ueip_optin', false); |
|
1902 | - } |
|
1903 | - //is this already cached for this request? If so use it. |
|
1904 | - if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1905 | - return EE_Core_Config::$ee_ueip_option; |
|
1906 | - } |
|
1907 | - global $wpdb; |
|
1908 | - $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
1909 | - $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1910 | - $option = 'ee_ueip_optin'; |
|
1911 | - //set correct table for query |
|
1912 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1913 | - //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
1914 | - //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
1915 | - //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
1916 | - //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
1917 | - //for the purpose of caching. |
|
1918 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1919 | - if (false !== $pre) { |
|
1920 | - EE_Core_Config::$ee_ueip_option = $pre; |
|
1921 | - return EE_Core_Config::$ee_ueip_option; |
|
1922 | - } |
|
1923 | - $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
1924 | - $option)); |
|
1925 | - if (is_object($row)) { |
|
1926 | - $value = $row->option_value; |
|
1927 | - } else { //option does not exist so use default. |
|
1928 | - return apply_filters('default_option_' . $option, false, $option); |
|
1929 | - } |
|
1930 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
1931 | - return EE_Core_Config::$ee_ueip_option; |
|
1932 | - } |
|
1933 | - |
|
1934 | - |
|
1935 | - |
|
1936 | - /** |
|
1937 | - * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
1938 | - * on the object. |
|
1939 | - * |
|
1940 | - * @return array |
|
1941 | - */ |
|
1942 | - public function __sleep() |
|
1943 | - { |
|
1944 | - //reset all url properties |
|
1945 | - $this->_reset_urls(); |
|
1946 | - //return what to save to db |
|
1947 | - return array_keys(get_object_vars($this)); |
|
1948 | - } |
|
1949 | - |
|
1950 | -} |
|
1951 | - |
|
1952 | - |
|
1953 | - |
|
1954 | -/** |
|
1955 | - * Config class for storing info on the Organization |
|
1956 | - */ |
|
1957 | -class EE_Organization_Config extends EE_Config_Base |
|
1958 | -{ |
|
1959 | - |
|
1960 | - /** |
|
1961 | - * @var string $name |
|
1962 | - * eg EE4.1 |
|
1963 | - */ |
|
1964 | - public $name; |
|
1965 | - |
|
1966 | - /** |
|
1967 | - * @var string $address_1 |
|
1968 | - * eg 123 Onna Road |
|
1969 | - */ |
|
1970 | - public $address_1; |
|
1971 | - |
|
1972 | - /** |
|
1973 | - * @var string $address_2 |
|
1974 | - * eg PO Box 123 |
|
1975 | - */ |
|
1976 | - public $address_2; |
|
1977 | - |
|
1978 | - /** |
|
1979 | - * @var string $city |
|
1980 | - * eg Inna City |
|
1981 | - */ |
|
1982 | - public $city; |
|
1983 | - |
|
1984 | - /** |
|
1985 | - * @var int $STA_ID |
|
1986 | - * eg 4 |
|
1987 | - */ |
|
1988 | - public $STA_ID; |
|
1989 | - |
|
1990 | - /** |
|
1991 | - * @var string $CNT_ISO |
|
1992 | - * eg US |
|
1993 | - */ |
|
1994 | - public $CNT_ISO; |
|
1995 | - |
|
1996 | - /** |
|
1997 | - * @var string $zip |
|
1998 | - * eg 12345 or V1A 2B3 |
|
1999 | - */ |
|
2000 | - public $zip; |
|
2001 | - |
|
2002 | - /** |
|
2003 | - * @var string $email |
|
2004 | - * eg [email protected] |
|
2005 | - */ |
|
2006 | - public $email; |
|
2007 | - |
|
2008 | - |
|
2009 | - /** |
|
2010 | - * @var string $phone |
|
2011 | - * eg. 111-111-1111 |
|
2012 | - */ |
|
2013 | - public $phone; |
|
2014 | - |
|
2015 | - |
|
2016 | - /** |
|
2017 | - * @var string $vat |
|
2018 | - * VAT/Tax Number |
|
2019 | - */ |
|
2020 | - public $vat; |
|
2021 | - |
|
2022 | - /** |
|
2023 | - * @var string $logo_url |
|
2024 | - * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
2025 | - */ |
|
2026 | - public $logo_url; |
|
2027 | - |
|
2028 | - |
|
2029 | - /** |
|
2030 | - * The below are all various properties for holding links to organization social network profiles |
|
2031 | - * |
|
2032 | - * @var string |
|
2033 | - */ |
|
2034 | - /** |
|
2035 | - * facebook (facebook.com/profile.name) |
|
2036 | - * |
|
2037 | - * @var string |
|
2038 | - */ |
|
2039 | - public $facebook; |
|
2040 | - |
|
2041 | - |
|
2042 | - /** |
|
2043 | - * twitter (twitter.com/twitter_handle) |
|
2044 | - * |
|
2045 | - * @var string |
|
2046 | - */ |
|
2047 | - public $twitter; |
|
2048 | - |
|
2049 | - |
|
2050 | - /** |
|
2051 | - * linkedin (linkedin.com/in/profile_name) |
|
2052 | - * |
|
2053 | - * @var string |
|
2054 | - */ |
|
2055 | - public $linkedin; |
|
2056 | - |
|
2057 | - |
|
2058 | - /** |
|
2059 | - * pinterest (www.pinterest.com/profile_name) |
|
2060 | - * |
|
2061 | - * @var string |
|
2062 | - */ |
|
2063 | - public $pinterest; |
|
2064 | - |
|
2065 | - |
|
2066 | - /** |
|
2067 | - * google+ (google.com/+profileName) |
|
2068 | - * |
|
2069 | - * @var string |
|
2070 | - */ |
|
2071 | - public $google; |
|
2072 | - |
|
2073 | - |
|
2074 | - /** |
|
2075 | - * instagram (instagram.com/handle) |
|
2076 | - * |
|
2077 | - * @var string |
|
2078 | - */ |
|
2079 | - public $instagram; |
|
2080 | - |
|
2081 | - |
|
2082 | - |
|
2083 | - /** |
|
2084 | - * class constructor |
|
2085 | - * |
|
2086 | - * @access public |
|
2087 | - */ |
|
2088 | - public function __construct() |
|
2089 | - { |
|
2090 | - // set default organization settings |
|
2091 | - //decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded |
|
2092 | - $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
2093 | - $this->address_1 = '123 Onna Road'; |
|
2094 | - $this->address_2 = 'PO Box 123'; |
|
2095 | - $this->city = 'Inna City'; |
|
2096 | - $this->STA_ID = 4; |
|
2097 | - $this->CNT_ISO = 'US'; |
|
2098 | - $this->zip = '12345'; |
|
2099 | - $this->email = get_bloginfo('admin_email'); |
|
2100 | - $this->phone = ''; |
|
2101 | - $this->vat = '123456789'; |
|
2102 | - $this->logo_url = ''; |
|
2103 | - $this->facebook = ''; |
|
2104 | - $this->twitter = ''; |
|
2105 | - $this->linkedin = ''; |
|
2106 | - $this->pinterest = ''; |
|
2107 | - $this->google = ''; |
|
2108 | - $this->instagram = ''; |
|
2109 | - } |
|
2110 | - |
|
2111 | -} |
|
2112 | - |
|
2113 | - |
|
2114 | - |
|
2115 | -/** |
|
2116 | - * Class for defining what's in the EE_Config relating to currency |
|
2117 | - */ |
|
2118 | -class EE_Currency_Config extends EE_Config_Base |
|
2119 | -{ |
|
2120 | - |
|
2121 | - /** |
|
2122 | - * @var string $code |
|
2123 | - * eg 'US' |
|
2124 | - */ |
|
2125 | - public $code; |
|
2126 | - |
|
2127 | - /** |
|
2128 | - * @var string $name |
|
2129 | - * eg 'Dollar' |
|
2130 | - */ |
|
2131 | - public $name; |
|
2132 | - |
|
2133 | - /** |
|
2134 | - * plural name |
|
2135 | - * |
|
2136 | - * @var string $plural |
|
2137 | - * eg 'Dollars' |
|
2138 | - */ |
|
2139 | - public $plural; |
|
2140 | - |
|
2141 | - /** |
|
2142 | - * currency sign |
|
2143 | - * |
|
2144 | - * @var string $sign |
|
2145 | - * eg '$' |
|
2146 | - */ |
|
2147 | - public $sign; |
|
2148 | - |
|
2149 | - /** |
|
2150 | - * Whether the currency sign should come before the number or not |
|
2151 | - * |
|
2152 | - * @var boolean $sign_b4 |
|
2153 | - */ |
|
2154 | - public $sign_b4; |
|
2155 | - |
|
2156 | - /** |
|
2157 | - * How many digits should come after the decimal place |
|
2158 | - * |
|
2159 | - * @var int $dec_plc |
|
2160 | - */ |
|
2161 | - public $dec_plc; |
|
2162 | - |
|
2163 | - /** |
|
2164 | - * Symbol to use for decimal mark |
|
2165 | - * |
|
2166 | - * @var string $dec_mrk |
|
2167 | - * eg '.' |
|
2168 | - */ |
|
2169 | - public $dec_mrk; |
|
2170 | - |
|
2171 | - /** |
|
2172 | - * Symbol to use for thousands |
|
2173 | - * |
|
2174 | - * @var string $thsnds |
|
2175 | - * eg ',' |
|
2176 | - */ |
|
2177 | - public $thsnds; |
|
2178 | - |
|
2179 | - |
|
2180 | - |
|
2181 | - /** |
|
2182 | - * class constructor |
|
2183 | - * |
|
2184 | - * @access public |
|
2185 | - * @param string $CNT_ISO |
|
2186 | - * @throws \EE_Error |
|
2187 | - */ |
|
2188 | - public function __construct($CNT_ISO = '') |
|
2189 | - { |
|
2190 | - /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
2191 | - $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2192 | - // get country code from organization settings or use default |
|
2193 | - $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2194 | - && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2195 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
2196 | - : ''; |
|
2197 | - // but override if requested |
|
2198 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2199 | - // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
2200 | - if ( |
|
2201 | - ! empty($CNT_ISO) |
|
2202 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
2203 | - && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2204 | - ) { |
|
2205 | - // retrieve the country settings from the db, just in case they have been customized |
|
2206 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2207 | - if ($country instanceof EE_Country) { |
|
2208 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2209 | - $this->name = $country->currency_name_single(); // Dollar |
|
2210 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
2211 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
2212 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2213 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2214 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2215 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2216 | - } |
|
2217 | - } |
|
2218 | - // fallback to hardcoded defaults, in case the above failed |
|
2219 | - if (empty($this->code)) { |
|
2220 | - // set default currency settings |
|
2221 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2222 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2223 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2224 | - $this->sign = '$'; // currency sign: $ |
|
2225 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2226 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2227 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2228 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2229 | - } |
|
2230 | - } |
|
2231 | -} |
|
2232 | - |
|
2233 | - |
|
2234 | - |
|
2235 | -/** |
|
2236 | - * Class for defining what's in the EE_Config relating to registration settings |
|
2237 | - */ |
|
2238 | -class EE_Registration_Config extends EE_Config_Base |
|
2239 | -{ |
|
2240 | - |
|
2241 | - /** |
|
2242 | - * Default registration status |
|
2243 | - * |
|
2244 | - * @var string $default_STS_ID |
|
2245 | - * eg 'RPP' |
|
2246 | - */ |
|
2247 | - public $default_STS_ID; |
|
2248 | - |
|
2249 | - |
|
2250 | - /** |
|
2251 | - * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
2252 | - * registrations) |
|
2253 | - * @var int |
|
2254 | - */ |
|
2255 | - public $default_maximum_number_of_tickets; |
|
2256 | - |
|
2257 | - |
|
2258 | - /** |
|
2259 | - * level of validation to apply to email addresses |
|
2260 | - * |
|
2261 | - * @var string $email_validation_level |
|
2262 | - * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
2263 | - */ |
|
2264 | - public $email_validation_level; |
|
2265 | - |
|
2266 | - /** |
|
2267 | - * whether or not to show alternate payment options during the reg process if payment status is pending |
|
2268 | - * |
|
2269 | - * @var boolean $show_pending_payment_options |
|
2270 | - */ |
|
2271 | - public $show_pending_payment_options; |
|
2272 | - |
|
2273 | - /** |
|
2274 | - * Whether to skip the registration confirmation page |
|
2275 | - * |
|
2276 | - * @var boolean $skip_reg_confirmation |
|
2277 | - */ |
|
2278 | - public $skip_reg_confirmation; |
|
2279 | - |
|
2280 | - /** |
|
2281 | - * an array of SPCO reg steps where: |
|
2282 | - * the keys denotes the reg step order |
|
2283 | - * each element consists of an array with the following elements: |
|
2284 | - * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
2285 | - * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
2286 | - * "slug" => the URL param used to trigger the reg step |
|
2287 | - * |
|
2288 | - * @var array $reg_steps |
|
2289 | - */ |
|
2290 | - public $reg_steps; |
|
2291 | - |
|
2292 | - /** |
|
2293 | - * Whether registration confirmation should be the last page of SPCO |
|
2294 | - * |
|
2295 | - * @var boolean $reg_confirmation_last |
|
2296 | - */ |
|
2297 | - public $reg_confirmation_last; |
|
2298 | - |
|
2299 | - /** |
|
2300 | - * Whether or not to enable the EE Bot Trap |
|
2301 | - * |
|
2302 | - * @var boolean $use_bot_trap |
|
2303 | - */ |
|
2304 | - public $use_bot_trap; |
|
2305 | - |
|
2306 | - /** |
|
2307 | - * Whether or not to encrypt some data sent by the EE Bot Trap |
|
2308 | - * |
|
2309 | - * @var boolean $use_encryption |
|
2310 | - */ |
|
2311 | - public $use_encryption; |
|
2312 | - |
|
2313 | - /** |
|
2314 | - * Whether or not to use ReCaptcha |
|
2315 | - * |
|
2316 | - * @var boolean $use_captcha |
|
2317 | - */ |
|
2318 | - public $use_captcha; |
|
1544 | +} |
|
2319 | 1545 | |
2320 | - /** |
|
2321 | - * ReCaptcha Theme |
|
2322 | - * |
|
2323 | - * @var string $recaptcha_theme |
|
2324 | - * options: 'dark', 'light', 'invisible' |
|
2325 | - */ |
|
2326 | - public $recaptcha_theme; |
|
2327 | 1546 | |
2328 | - /** |
|
2329 | - * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha. |
|
2330 | - * |
|
2331 | - * @var string $recaptcha_badge |
|
2332 | - * options: 'bottomright', 'bottomleft', 'inline' |
|
2333 | - */ |
|
2334 | - public $recaptcha_badge; |
|
2335 | 1547 | |
2336 | - /** |
|
2337 | - * ReCaptcha Type |
|
2338 | - * |
|
2339 | - * @var string $recaptcha_type |
|
2340 | - * options: 'audio', 'image' |
|
2341 | - */ |
|
2342 | - public $recaptcha_type; |
|
1548 | +/** |
|
1549 | + * Base class used for config classes. These classes should generally not have |
|
1550 | + * magic functions in use, except we'll allow them to magically set and get stuff... |
|
1551 | + * basically, they should just be well-defined stdClasses |
|
1552 | + */ |
|
1553 | +class EE_Config_Base |
|
1554 | +{ |
|
2343 | 1555 | |
2344 | - /** |
|
2345 | - * ReCaptcha language |
|
2346 | - * |
|
2347 | - * @var string $recaptcha_language |
|
2348 | - * eg 'en' |
|
2349 | - */ |
|
2350 | - public $recaptcha_language; |
|
1556 | + /** |
|
1557 | + * Utility function for escaping the value of a property and returning. |
|
1558 | + * |
|
1559 | + * @param string $property property name (checks to see if exists). |
|
1560 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1561 | + * @throws \EE_Error |
|
1562 | + */ |
|
1563 | + public function get_pretty($property) |
|
1564 | + { |
|
1565 | + if (! property_exists($this, $property)) { |
|
1566 | + throw new EE_Error( |
|
1567 | + sprintf( |
|
1568 | + __( |
|
1569 | + '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
1570 | + 'event_espresso' |
|
1571 | + ), |
|
1572 | + get_class($this), |
|
1573 | + $property |
|
1574 | + ) |
|
1575 | + ); |
|
1576 | + } |
|
1577 | + //just handling escaping of strings for now. |
|
1578 | + if (is_string($this->{$property})) { |
|
1579 | + return stripslashes($this->{$property}); |
|
1580 | + } |
|
1581 | + return $this->{$property}; |
|
1582 | + } |
|
1583 | + |
|
1584 | + |
|
1585 | + |
|
1586 | + public function populate() |
|
1587 | + { |
|
1588 | + //grab defaults via a new instance of this class. |
|
1589 | + $class_name = get_class($this); |
|
1590 | + $defaults = new $class_name; |
|
1591 | + //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1592 | + //default from our $defaults object. |
|
1593 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
1594 | + if ($this->{$property} === null) { |
|
1595 | + $this->{$property} = $value; |
|
1596 | + } |
|
1597 | + } |
|
1598 | + //cleanup |
|
1599 | + unset($defaults); |
|
1600 | + } |
|
1601 | + |
|
1602 | + |
|
1603 | + |
|
1604 | + /** |
|
1605 | + * __isset |
|
1606 | + * |
|
1607 | + * @param $a |
|
1608 | + * @return bool |
|
1609 | + */ |
|
1610 | + public function __isset($a) |
|
1611 | + { |
|
1612 | + return false; |
|
1613 | + } |
|
1614 | + |
|
1615 | + |
|
1616 | + |
|
1617 | + /** |
|
1618 | + * __unset |
|
1619 | + * |
|
1620 | + * @param $a |
|
1621 | + * @return bool |
|
1622 | + */ |
|
1623 | + public function __unset($a) |
|
1624 | + { |
|
1625 | + return false; |
|
1626 | + } |
|
1627 | + |
|
1628 | + |
|
1629 | + |
|
1630 | + /** |
|
1631 | + * __clone |
|
1632 | + */ |
|
1633 | + public function __clone() |
|
1634 | + { |
|
1635 | + } |
|
1636 | + |
|
1637 | + |
|
1638 | + |
|
1639 | + /** |
|
1640 | + * __wakeup |
|
1641 | + */ |
|
1642 | + public function __wakeup() |
|
1643 | + { |
|
1644 | + } |
|
1645 | + |
|
1646 | + |
|
1647 | + |
|
1648 | + /** |
|
1649 | + * __destruct |
|
1650 | + */ |
|
1651 | + public function __destruct() |
|
1652 | + { |
|
1653 | + } |
|
1654 | +} |
|
2351 | 1655 | |
2352 | - /** |
|
2353 | - * ReCaptcha public key |
|
2354 | - * |
|
2355 | - * @var string $recaptcha_publickey |
|
2356 | - */ |
|
2357 | - public $recaptcha_publickey; |
|
2358 | 1656 | |
2359 | - /** |
|
2360 | - * ReCaptcha private key |
|
2361 | - * |
|
2362 | - * @var string $recaptcha_privatekey |
|
2363 | - */ |
|
2364 | - public $recaptcha_privatekey; |
|
2365 | 1657 | |
2366 | - /** |
|
2367 | - * ReCaptcha width |
|
2368 | - * |
|
2369 | - * @var int $recaptcha_width |
|
2370 | - * @deprecated |
|
2371 | - */ |
|
2372 | - public $recaptcha_width; |
|
1658 | +/** |
|
1659 | + * Class for defining what's in the EE_Config relating to registration settings |
|
1660 | + */ |
|
1661 | +class EE_Core_Config extends EE_Config_Base |
|
1662 | +{ |
|
2373 | 1663 | |
2374 | - /** |
|
2375 | - * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
2376 | - * |
|
2377 | - * @var boolean $track_invalid_checkout_access |
|
2378 | - */ |
|
2379 | - protected $track_invalid_checkout_access = true; |
|
1664 | + public $current_blog_id; |
|
1665 | + |
|
1666 | + public $ee_ueip_optin; |
|
1667 | + |
|
1668 | + public $ee_ueip_has_notified; |
|
1669 | + |
|
1670 | + /** |
|
1671 | + * Not to be confused with the 4 critical page variables (See |
|
1672 | + * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1673 | + * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1674 | + * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1675 | + * |
|
1676 | + * @var array |
|
1677 | + */ |
|
1678 | + public $post_shortcodes; |
|
1679 | + |
|
1680 | + public $module_route_map; |
|
1681 | + |
|
1682 | + public $module_forward_map; |
|
1683 | + |
|
1684 | + public $module_view_map; |
|
1685 | + |
|
1686 | + /** |
|
1687 | + * The next 4 vars are the IDs of critical EE pages. |
|
1688 | + * |
|
1689 | + * @var int |
|
1690 | + */ |
|
1691 | + public $reg_page_id; |
|
1692 | + |
|
1693 | + public $txn_page_id; |
|
1694 | + |
|
1695 | + public $thank_you_page_id; |
|
1696 | + |
|
1697 | + public $cancel_page_id; |
|
1698 | + |
|
1699 | + /** |
|
1700 | + * The next 4 vars are the URLs of critical EE pages. |
|
1701 | + * |
|
1702 | + * @var int |
|
1703 | + */ |
|
1704 | + public $reg_page_url; |
|
1705 | + |
|
1706 | + public $txn_page_url; |
|
1707 | + |
|
1708 | + public $thank_you_page_url; |
|
1709 | + |
|
1710 | + public $cancel_page_url; |
|
1711 | + |
|
1712 | + /** |
|
1713 | + * The next vars relate to the custom slugs for EE CPT routes |
|
1714 | + */ |
|
1715 | + public $event_cpt_slug; |
|
1716 | + |
|
1717 | + |
|
1718 | + /** |
|
1719 | + * This caches the _ee_ueip_option in case this config is reset in the same |
|
1720 | + * request across blog switches in a multisite context. |
|
1721 | + * Avoids extra queries to the db for this option. |
|
1722 | + * |
|
1723 | + * @var bool |
|
1724 | + */ |
|
1725 | + public static $ee_ueip_option; |
|
1726 | + |
|
1727 | + |
|
1728 | + |
|
1729 | + /** |
|
1730 | + * class constructor |
|
1731 | + * |
|
1732 | + * @access public |
|
1733 | + */ |
|
1734 | + public function __construct() |
|
1735 | + { |
|
1736 | + // set default organization settings |
|
1737 | + $this->current_blog_id = get_current_blog_id(); |
|
1738 | + $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
1739 | + $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
1740 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1741 | + $this->post_shortcodes = array(); |
|
1742 | + $this->module_route_map = array(); |
|
1743 | + $this->module_forward_map = array(); |
|
1744 | + $this->module_view_map = array(); |
|
1745 | + // critical EE page IDs |
|
1746 | + $this->reg_page_id = 0; |
|
1747 | + $this->txn_page_id = 0; |
|
1748 | + $this->thank_you_page_id = 0; |
|
1749 | + $this->cancel_page_id = 0; |
|
1750 | + // critical EE page URLs |
|
1751 | + $this->reg_page_url = ''; |
|
1752 | + $this->txn_page_url = ''; |
|
1753 | + $this->thank_you_page_url = ''; |
|
1754 | + $this->cancel_page_url = ''; |
|
1755 | + //cpt slugs |
|
1756 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1757 | + //ueip constant check |
|
1758 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1759 | + $this->ee_ueip_optin = false; |
|
1760 | + $this->ee_ueip_has_notified = true; |
|
1761 | + } |
|
1762 | + } |
|
1763 | + |
|
1764 | + |
|
1765 | + |
|
1766 | + /** |
|
1767 | + * @return array |
|
1768 | + */ |
|
1769 | + public function get_critical_pages_array() |
|
1770 | + { |
|
1771 | + return array( |
|
1772 | + $this->reg_page_id, |
|
1773 | + $this->txn_page_id, |
|
1774 | + $this->thank_you_page_id, |
|
1775 | + $this->cancel_page_id, |
|
1776 | + ); |
|
1777 | + } |
|
1778 | + |
|
1779 | + |
|
1780 | + |
|
1781 | + /** |
|
1782 | + * @return array |
|
1783 | + */ |
|
1784 | + public function get_critical_pages_shortcodes_array() |
|
1785 | + { |
|
1786 | + return array( |
|
1787 | + $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1788 | + $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1789 | + $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1790 | + $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
1791 | + ); |
|
1792 | + } |
|
1793 | + |
|
1794 | + |
|
1795 | + |
|
1796 | + /** |
|
1797 | + * gets/returns URL for EE reg_page |
|
1798 | + * |
|
1799 | + * @access public |
|
1800 | + * @return string |
|
1801 | + */ |
|
1802 | + public function reg_page_url() |
|
1803 | + { |
|
1804 | + if (! $this->reg_page_url) { |
|
1805 | + $this->reg_page_url = add_query_arg( |
|
1806 | + array('uts' => time()), |
|
1807 | + get_permalink($this->reg_page_id) |
|
1808 | + ) . '#checkout'; |
|
1809 | + } |
|
1810 | + return $this->reg_page_url; |
|
1811 | + } |
|
1812 | + |
|
1813 | + |
|
1814 | + |
|
1815 | + /** |
|
1816 | + * gets/returns URL for EE txn_page |
|
1817 | + * |
|
1818 | + * @param array $query_args like what gets passed to |
|
1819 | + * add_query_arg() as the first argument |
|
1820 | + * @access public |
|
1821 | + * @return string |
|
1822 | + */ |
|
1823 | + public function txn_page_url($query_args = array()) |
|
1824 | + { |
|
1825 | + if (! $this->txn_page_url) { |
|
1826 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1827 | + } |
|
1828 | + if ($query_args) { |
|
1829 | + return add_query_arg($query_args, $this->txn_page_url); |
|
1830 | + } else { |
|
1831 | + return $this->txn_page_url; |
|
1832 | + } |
|
1833 | + } |
|
1834 | + |
|
1835 | + |
|
1836 | + |
|
1837 | + /** |
|
1838 | + * gets/returns URL for EE thank_you_page |
|
1839 | + * |
|
1840 | + * @param array $query_args like what gets passed to |
|
1841 | + * add_query_arg() as the first argument |
|
1842 | + * @access public |
|
1843 | + * @return string |
|
1844 | + */ |
|
1845 | + public function thank_you_page_url($query_args = array()) |
|
1846 | + { |
|
1847 | + if (! $this->thank_you_page_url) { |
|
1848 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1849 | + } |
|
1850 | + if ($query_args) { |
|
1851 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
1852 | + } else { |
|
1853 | + return $this->thank_you_page_url; |
|
1854 | + } |
|
1855 | + } |
|
1856 | + |
|
1857 | + |
|
1858 | + |
|
1859 | + /** |
|
1860 | + * gets/returns URL for EE cancel_page |
|
1861 | + * |
|
1862 | + * @access public |
|
1863 | + * @return string |
|
1864 | + */ |
|
1865 | + public function cancel_page_url() |
|
1866 | + { |
|
1867 | + if (! $this->cancel_page_url) { |
|
1868 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1869 | + } |
|
1870 | + return $this->cancel_page_url; |
|
1871 | + } |
|
1872 | + |
|
1873 | + |
|
1874 | + |
|
1875 | + /** |
|
1876 | + * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1877 | + * |
|
1878 | + * @since 4.7.5 |
|
1879 | + */ |
|
1880 | + protected function _reset_urls() |
|
1881 | + { |
|
1882 | + $this->reg_page_url = ''; |
|
1883 | + $this->txn_page_url = ''; |
|
1884 | + $this->cancel_page_url = ''; |
|
1885 | + $this->thank_you_page_url = ''; |
|
1886 | + } |
|
1887 | + |
|
1888 | + |
|
1889 | + |
|
1890 | + /** |
|
1891 | + * Used to return what the optin value is set for the EE User Experience Program. |
|
1892 | + * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
1893 | + * on the main site only. |
|
1894 | + * |
|
1895 | + * @return mixed|void |
|
1896 | + */ |
|
1897 | + protected function _get_main_ee_ueip_optin() |
|
1898 | + { |
|
1899 | + //if this is the main site then we can just bypass our direct query. |
|
1900 | + if (is_main_site()) { |
|
1901 | + return get_option('ee_ueip_optin', false); |
|
1902 | + } |
|
1903 | + //is this already cached for this request? If so use it. |
|
1904 | + if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1905 | + return EE_Core_Config::$ee_ueip_option; |
|
1906 | + } |
|
1907 | + global $wpdb; |
|
1908 | + $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
1909 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1910 | + $option = 'ee_ueip_optin'; |
|
1911 | + //set correct table for query |
|
1912 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1913 | + //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
1914 | + //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
1915 | + //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
1916 | + //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
1917 | + //for the purpose of caching. |
|
1918 | + $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1919 | + if (false !== $pre) { |
|
1920 | + EE_Core_Config::$ee_ueip_option = $pre; |
|
1921 | + return EE_Core_Config::$ee_ueip_option; |
|
1922 | + } |
|
1923 | + $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
1924 | + $option)); |
|
1925 | + if (is_object($row)) { |
|
1926 | + $value = $row->option_value; |
|
1927 | + } else { //option does not exist so use default. |
|
1928 | + return apply_filters('default_option_' . $option, false, $option); |
|
1929 | + } |
|
1930 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
1931 | + return EE_Core_Config::$ee_ueip_option; |
|
1932 | + } |
|
1933 | + |
|
1934 | + |
|
1935 | + |
|
1936 | + /** |
|
1937 | + * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
1938 | + * on the object. |
|
1939 | + * |
|
1940 | + * @return array |
|
1941 | + */ |
|
1942 | + public function __sleep() |
|
1943 | + { |
|
1944 | + //reset all url properties |
|
1945 | + $this->_reset_urls(); |
|
1946 | + //return what to save to db |
|
1947 | + return array_keys(get_object_vars($this)); |
|
1948 | + } |
|
2380 | 1949 | |
1950 | +} |
|
2381 | 1951 | |
2382 | 1952 | |
2383 | - /** |
|
2384 | - * class constructor |
|
2385 | - * |
|
2386 | - * @access public |
|
2387 | - */ |
|
2388 | - public function __construct() |
|
2389 | - { |
|
2390 | - // set default registration settings |
|
2391 | - $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2392 | - $this->email_validation_level = 'wp_default'; |
|
2393 | - $this->show_pending_payment_options = true; |
|
2394 | - $this->skip_reg_confirmation = false; |
|
2395 | - $this->reg_steps = array(); |
|
2396 | - $this->reg_confirmation_last = false; |
|
2397 | - $this->use_bot_trap = true; |
|
2398 | - $this->use_encryption = true; |
|
2399 | - $this->use_captcha = false; |
|
2400 | - $this->recaptcha_theme = 'light'; |
|
2401 | - $this->recaptcha_badge = 'bottomleft'; |
|
2402 | - $this->recaptcha_type = 'image'; |
|
2403 | - $this->recaptcha_language = 'en'; |
|
2404 | - $this->recaptcha_publickey = null; |
|
2405 | - $this->recaptcha_privatekey = null; |
|
2406 | - $this->recaptcha_width = 500; |
|
2407 | - $this->default_maximum_number_of_tickets = 10; |
|
2408 | - } |
|
2409 | - |
|
2410 | - |
|
2411 | - |
|
2412 | - /** |
|
2413 | - * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2414 | - * |
|
2415 | - * @since 4.8.8.rc.019 |
|
2416 | - */ |
|
2417 | - public function do_hooks() |
|
2418 | - { |
|
2419 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2420 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
2421 | - } |
|
2422 | 1953 | |
1954 | +/** |
|
1955 | + * Config class for storing info on the Organization |
|
1956 | + */ |
|
1957 | +class EE_Organization_Config extends EE_Config_Base |
|
1958 | +{ |
|
2423 | 1959 | |
1960 | + /** |
|
1961 | + * @var string $name |
|
1962 | + * eg EE4.1 |
|
1963 | + */ |
|
1964 | + public $name; |
|
1965 | + |
|
1966 | + /** |
|
1967 | + * @var string $address_1 |
|
1968 | + * eg 123 Onna Road |
|
1969 | + */ |
|
1970 | + public $address_1; |
|
1971 | + |
|
1972 | + /** |
|
1973 | + * @var string $address_2 |
|
1974 | + * eg PO Box 123 |
|
1975 | + */ |
|
1976 | + public $address_2; |
|
1977 | + |
|
1978 | + /** |
|
1979 | + * @var string $city |
|
1980 | + * eg Inna City |
|
1981 | + */ |
|
1982 | + public $city; |
|
1983 | + |
|
1984 | + /** |
|
1985 | + * @var int $STA_ID |
|
1986 | + * eg 4 |
|
1987 | + */ |
|
1988 | + public $STA_ID; |
|
1989 | + |
|
1990 | + /** |
|
1991 | + * @var string $CNT_ISO |
|
1992 | + * eg US |
|
1993 | + */ |
|
1994 | + public $CNT_ISO; |
|
1995 | + |
|
1996 | + /** |
|
1997 | + * @var string $zip |
|
1998 | + * eg 12345 or V1A 2B3 |
|
1999 | + */ |
|
2000 | + public $zip; |
|
2001 | + |
|
2002 | + /** |
|
2003 | + * @var string $email |
|
2004 | + * eg [email protected] |
|
2005 | + */ |
|
2006 | + public $email; |
|
2007 | + |
|
2008 | + |
|
2009 | + /** |
|
2010 | + * @var string $phone |
|
2011 | + * eg. 111-111-1111 |
|
2012 | + */ |
|
2013 | + public $phone; |
|
2014 | + |
|
2015 | + |
|
2016 | + /** |
|
2017 | + * @var string $vat |
|
2018 | + * VAT/Tax Number |
|
2019 | + */ |
|
2020 | + public $vat; |
|
2021 | + |
|
2022 | + /** |
|
2023 | + * @var string $logo_url |
|
2024 | + * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
2025 | + */ |
|
2026 | + public $logo_url; |
|
2027 | + |
|
2028 | + |
|
2029 | + /** |
|
2030 | + * The below are all various properties for holding links to organization social network profiles |
|
2031 | + * |
|
2032 | + * @var string |
|
2033 | + */ |
|
2034 | + /** |
|
2035 | + * facebook (facebook.com/profile.name) |
|
2036 | + * |
|
2037 | + * @var string |
|
2038 | + */ |
|
2039 | + public $facebook; |
|
2040 | + |
|
2041 | + |
|
2042 | + /** |
|
2043 | + * twitter (twitter.com/twitter_handle) |
|
2044 | + * |
|
2045 | + * @var string |
|
2046 | + */ |
|
2047 | + public $twitter; |
|
2048 | + |
|
2049 | + |
|
2050 | + /** |
|
2051 | + * linkedin (linkedin.com/in/profile_name) |
|
2052 | + * |
|
2053 | + * @var string |
|
2054 | + */ |
|
2055 | + public $linkedin; |
|
2056 | + |
|
2057 | + |
|
2058 | + /** |
|
2059 | + * pinterest (www.pinterest.com/profile_name) |
|
2060 | + * |
|
2061 | + * @var string |
|
2062 | + */ |
|
2063 | + public $pinterest; |
|
2064 | + |
|
2065 | + |
|
2066 | + /** |
|
2067 | + * google+ (google.com/+profileName) |
|
2068 | + * |
|
2069 | + * @var string |
|
2070 | + */ |
|
2071 | + public $google; |
|
2072 | + |
|
2073 | + |
|
2074 | + /** |
|
2075 | + * instagram (instagram.com/handle) |
|
2076 | + * |
|
2077 | + * @var string |
|
2078 | + */ |
|
2079 | + public $instagram; |
|
2080 | + |
|
2081 | + |
|
2082 | + |
|
2083 | + /** |
|
2084 | + * class constructor |
|
2085 | + * |
|
2086 | + * @access public |
|
2087 | + */ |
|
2088 | + public function __construct() |
|
2089 | + { |
|
2090 | + // set default organization settings |
|
2091 | + //decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded |
|
2092 | + $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
2093 | + $this->address_1 = '123 Onna Road'; |
|
2094 | + $this->address_2 = 'PO Box 123'; |
|
2095 | + $this->city = 'Inna City'; |
|
2096 | + $this->STA_ID = 4; |
|
2097 | + $this->CNT_ISO = 'US'; |
|
2098 | + $this->zip = '12345'; |
|
2099 | + $this->email = get_bloginfo('admin_email'); |
|
2100 | + $this->phone = ''; |
|
2101 | + $this->vat = '123456789'; |
|
2102 | + $this->logo_url = ''; |
|
2103 | + $this->facebook = ''; |
|
2104 | + $this->twitter = ''; |
|
2105 | + $this->linkedin = ''; |
|
2106 | + $this->pinterest = ''; |
|
2107 | + $this->google = ''; |
|
2108 | + $this->instagram = ''; |
|
2109 | + } |
|
2424 | 2110 | |
2425 | - /** |
|
2426 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status |
|
2427 | - * field matches the config setting for default_STS_ID. |
|
2428 | - */ |
|
2429 | - public function set_default_reg_status_on_EEM_Event() |
|
2430 | - { |
|
2431 | - EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2432 | - } |
|
2111 | +} |
|
2433 | 2112 | |
2434 | 2113 | |
2435 | - /** |
|
2436 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
2437 | - * for Events matches the config setting for default_maximum_number_of_tickets |
|
2438 | - */ |
|
2439 | - public function set_default_max_ticket_on_EEM_Event() |
|
2440 | - { |
|
2441 | - EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
2442 | - } |
|
2443 | 2114 | |
2115 | +/** |
|
2116 | + * Class for defining what's in the EE_Config relating to currency |
|
2117 | + */ |
|
2118 | +class EE_Currency_Config extends EE_Config_Base |
|
2119 | +{ |
|
2444 | 2120 | |
2121 | + /** |
|
2122 | + * @var string $code |
|
2123 | + * eg 'US' |
|
2124 | + */ |
|
2125 | + public $code; |
|
2126 | + |
|
2127 | + /** |
|
2128 | + * @var string $name |
|
2129 | + * eg 'Dollar' |
|
2130 | + */ |
|
2131 | + public $name; |
|
2132 | + |
|
2133 | + /** |
|
2134 | + * plural name |
|
2135 | + * |
|
2136 | + * @var string $plural |
|
2137 | + * eg 'Dollars' |
|
2138 | + */ |
|
2139 | + public $plural; |
|
2140 | + |
|
2141 | + /** |
|
2142 | + * currency sign |
|
2143 | + * |
|
2144 | + * @var string $sign |
|
2145 | + * eg '$' |
|
2146 | + */ |
|
2147 | + public $sign; |
|
2148 | + |
|
2149 | + /** |
|
2150 | + * Whether the currency sign should come before the number or not |
|
2151 | + * |
|
2152 | + * @var boolean $sign_b4 |
|
2153 | + */ |
|
2154 | + public $sign_b4; |
|
2155 | + |
|
2156 | + /** |
|
2157 | + * How many digits should come after the decimal place |
|
2158 | + * |
|
2159 | + * @var int $dec_plc |
|
2160 | + */ |
|
2161 | + public $dec_plc; |
|
2162 | + |
|
2163 | + /** |
|
2164 | + * Symbol to use for decimal mark |
|
2165 | + * |
|
2166 | + * @var string $dec_mrk |
|
2167 | + * eg '.' |
|
2168 | + */ |
|
2169 | + public $dec_mrk; |
|
2170 | + |
|
2171 | + /** |
|
2172 | + * Symbol to use for thousands |
|
2173 | + * |
|
2174 | + * @var string $thsnds |
|
2175 | + * eg ',' |
|
2176 | + */ |
|
2177 | + public $thsnds; |
|
2178 | + |
|
2179 | + |
|
2180 | + |
|
2181 | + /** |
|
2182 | + * class constructor |
|
2183 | + * |
|
2184 | + * @access public |
|
2185 | + * @param string $CNT_ISO |
|
2186 | + * @throws \EE_Error |
|
2187 | + */ |
|
2188 | + public function __construct($CNT_ISO = '') |
|
2189 | + { |
|
2190 | + /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
2191 | + $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2192 | + // get country code from organization settings or use default |
|
2193 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2194 | + && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2195 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
2196 | + : ''; |
|
2197 | + // but override if requested |
|
2198 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2199 | + // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
2200 | + if ( |
|
2201 | + ! empty($CNT_ISO) |
|
2202 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
2203 | + && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2204 | + ) { |
|
2205 | + // retrieve the country settings from the db, just in case they have been customized |
|
2206 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2207 | + if ($country instanceof EE_Country) { |
|
2208 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2209 | + $this->name = $country->currency_name_single(); // Dollar |
|
2210 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
2211 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
2212 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2213 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2214 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2215 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2216 | + } |
|
2217 | + } |
|
2218 | + // fallback to hardcoded defaults, in case the above failed |
|
2219 | + if (empty($this->code)) { |
|
2220 | + // set default currency settings |
|
2221 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2222 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2223 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2224 | + $this->sign = '$'; // currency sign: $ |
|
2225 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2226 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2227 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2228 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2229 | + } |
|
2230 | + } |
|
2231 | +} |
|
2445 | 2232 | |
2446 | - /** |
|
2447 | - * @return boolean |
|
2448 | - */ |
|
2449 | - public function track_invalid_checkout_access() |
|
2450 | - { |
|
2451 | - return $this->track_invalid_checkout_access; |
|
2452 | - } |
|
2453 | 2233 | |
2454 | 2234 | |
2235 | +/** |
|
2236 | + * Class for defining what's in the EE_Config relating to registration settings |
|
2237 | + */ |
|
2238 | +class EE_Registration_Config extends EE_Config_Base |
|
2239 | +{ |
|
2455 | 2240 | |
2456 | - /** |
|
2457 | - * @param boolean $track_invalid_checkout_access |
|
2458 | - */ |
|
2459 | - public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
2460 | - { |
|
2461 | - $this->track_invalid_checkout_access = filter_var( |
|
2462 | - $track_invalid_checkout_access, |
|
2463 | - FILTER_VALIDATE_BOOLEAN |
|
2464 | - ); |
|
2465 | - } |
|
2241 | + /** |
|
2242 | + * Default registration status |
|
2243 | + * |
|
2244 | + * @var string $default_STS_ID |
|
2245 | + * eg 'RPP' |
|
2246 | + */ |
|
2247 | + public $default_STS_ID; |
|
2248 | + |
|
2249 | + |
|
2250 | + /** |
|
2251 | + * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
2252 | + * registrations) |
|
2253 | + * @var int |
|
2254 | + */ |
|
2255 | + public $default_maximum_number_of_tickets; |
|
2256 | + |
|
2257 | + |
|
2258 | + /** |
|
2259 | + * level of validation to apply to email addresses |
|
2260 | + * |
|
2261 | + * @var string $email_validation_level |
|
2262 | + * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
2263 | + */ |
|
2264 | + public $email_validation_level; |
|
2265 | + |
|
2266 | + /** |
|
2267 | + * whether or not to show alternate payment options during the reg process if payment status is pending |
|
2268 | + * |
|
2269 | + * @var boolean $show_pending_payment_options |
|
2270 | + */ |
|
2271 | + public $show_pending_payment_options; |
|
2272 | + |
|
2273 | + /** |
|
2274 | + * Whether to skip the registration confirmation page |
|
2275 | + * |
|
2276 | + * @var boolean $skip_reg_confirmation |
|
2277 | + */ |
|
2278 | + public $skip_reg_confirmation; |
|
2279 | + |
|
2280 | + /** |
|
2281 | + * an array of SPCO reg steps where: |
|
2282 | + * the keys denotes the reg step order |
|
2283 | + * each element consists of an array with the following elements: |
|
2284 | + * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
2285 | + * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
2286 | + * "slug" => the URL param used to trigger the reg step |
|
2287 | + * |
|
2288 | + * @var array $reg_steps |
|
2289 | + */ |
|
2290 | + public $reg_steps; |
|
2291 | + |
|
2292 | + /** |
|
2293 | + * Whether registration confirmation should be the last page of SPCO |
|
2294 | + * |
|
2295 | + * @var boolean $reg_confirmation_last |
|
2296 | + */ |
|
2297 | + public $reg_confirmation_last; |
|
2298 | + |
|
2299 | + /** |
|
2300 | + * Whether or not to enable the EE Bot Trap |
|
2301 | + * |
|
2302 | + * @var boolean $use_bot_trap |
|
2303 | + */ |
|
2304 | + public $use_bot_trap; |
|
2305 | + |
|
2306 | + /** |
|
2307 | + * Whether or not to encrypt some data sent by the EE Bot Trap |
|
2308 | + * |
|
2309 | + * @var boolean $use_encryption |
|
2310 | + */ |
|
2311 | + public $use_encryption; |
|
2312 | + |
|
2313 | + /** |
|
2314 | + * Whether or not to use ReCaptcha |
|
2315 | + * |
|
2316 | + * @var boolean $use_captcha |
|
2317 | + */ |
|
2318 | + public $use_captcha; |
|
2319 | + |
|
2320 | + /** |
|
2321 | + * ReCaptcha Theme |
|
2322 | + * |
|
2323 | + * @var string $recaptcha_theme |
|
2324 | + * options: 'dark', 'light', 'invisible' |
|
2325 | + */ |
|
2326 | + public $recaptcha_theme; |
|
2327 | + |
|
2328 | + /** |
|
2329 | + * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha. |
|
2330 | + * |
|
2331 | + * @var string $recaptcha_badge |
|
2332 | + * options: 'bottomright', 'bottomleft', 'inline' |
|
2333 | + */ |
|
2334 | + public $recaptcha_badge; |
|
2335 | + |
|
2336 | + /** |
|
2337 | + * ReCaptcha Type |
|
2338 | + * |
|
2339 | + * @var string $recaptcha_type |
|
2340 | + * options: 'audio', 'image' |
|
2341 | + */ |
|
2342 | + public $recaptcha_type; |
|
2343 | + |
|
2344 | + /** |
|
2345 | + * ReCaptcha language |
|
2346 | + * |
|
2347 | + * @var string $recaptcha_language |
|
2348 | + * eg 'en' |
|
2349 | + */ |
|
2350 | + public $recaptcha_language; |
|
2351 | + |
|
2352 | + /** |
|
2353 | + * ReCaptcha public key |
|
2354 | + * |
|
2355 | + * @var string $recaptcha_publickey |
|
2356 | + */ |
|
2357 | + public $recaptcha_publickey; |
|
2358 | + |
|
2359 | + /** |
|
2360 | + * ReCaptcha private key |
|
2361 | + * |
|
2362 | + * @var string $recaptcha_privatekey |
|
2363 | + */ |
|
2364 | + public $recaptcha_privatekey; |
|
2365 | + |
|
2366 | + /** |
|
2367 | + * ReCaptcha width |
|
2368 | + * |
|
2369 | + * @var int $recaptcha_width |
|
2370 | + * @deprecated |
|
2371 | + */ |
|
2372 | + public $recaptcha_width; |
|
2373 | + |
|
2374 | + /** |
|
2375 | + * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
2376 | + * |
|
2377 | + * @var boolean $track_invalid_checkout_access |
|
2378 | + */ |
|
2379 | + protected $track_invalid_checkout_access = true; |
|
2380 | + |
|
2381 | + |
|
2382 | + |
|
2383 | + /** |
|
2384 | + * class constructor |
|
2385 | + * |
|
2386 | + * @access public |
|
2387 | + */ |
|
2388 | + public function __construct() |
|
2389 | + { |
|
2390 | + // set default registration settings |
|
2391 | + $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2392 | + $this->email_validation_level = 'wp_default'; |
|
2393 | + $this->show_pending_payment_options = true; |
|
2394 | + $this->skip_reg_confirmation = false; |
|
2395 | + $this->reg_steps = array(); |
|
2396 | + $this->reg_confirmation_last = false; |
|
2397 | + $this->use_bot_trap = true; |
|
2398 | + $this->use_encryption = true; |
|
2399 | + $this->use_captcha = false; |
|
2400 | + $this->recaptcha_theme = 'light'; |
|
2401 | + $this->recaptcha_badge = 'bottomleft'; |
|
2402 | + $this->recaptcha_type = 'image'; |
|
2403 | + $this->recaptcha_language = 'en'; |
|
2404 | + $this->recaptcha_publickey = null; |
|
2405 | + $this->recaptcha_privatekey = null; |
|
2406 | + $this->recaptcha_width = 500; |
|
2407 | + $this->default_maximum_number_of_tickets = 10; |
|
2408 | + } |
|
2409 | + |
|
2410 | + |
|
2411 | + |
|
2412 | + /** |
|
2413 | + * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2414 | + * |
|
2415 | + * @since 4.8.8.rc.019 |
|
2416 | + */ |
|
2417 | + public function do_hooks() |
|
2418 | + { |
|
2419 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2420 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
2421 | + } |
|
2422 | + |
|
2423 | + |
|
2424 | + |
|
2425 | + /** |
|
2426 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status |
|
2427 | + * field matches the config setting for default_STS_ID. |
|
2428 | + */ |
|
2429 | + public function set_default_reg_status_on_EEM_Event() |
|
2430 | + { |
|
2431 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2432 | + } |
|
2433 | + |
|
2434 | + |
|
2435 | + /** |
|
2436 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
2437 | + * for Events matches the config setting for default_maximum_number_of_tickets |
|
2438 | + */ |
|
2439 | + public function set_default_max_ticket_on_EEM_Event() |
|
2440 | + { |
|
2441 | + EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
2442 | + } |
|
2443 | + |
|
2444 | + |
|
2445 | + |
|
2446 | + /** |
|
2447 | + * @return boolean |
|
2448 | + */ |
|
2449 | + public function track_invalid_checkout_access() |
|
2450 | + { |
|
2451 | + return $this->track_invalid_checkout_access; |
|
2452 | + } |
|
2453 | + |
|
2454 | + |
|
2455 | + |
|
2456 | + /** |
|
2457 | + * @param boolean $track_invalid_checkout_access |
|
2458 | + */ |
|
2459 | + public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
2460 | + { |
|
2461 | + $this->track_invalid_checkout_access = filter_var( |
|
2462 | + $track_invalid_checkout_access, |
|
2463 | + FILTER_VALIDATE_BOOLEAN |
|
2464 | + ); |
|
2465 | + } |
|
2466 | 2466 | |
2467 | 2467 | |
2468 | 2468 | |
@@ -2476,160 +2476,160 @@ discard block |
||
2476 | 2476 | class EE_Admin_Config extends EE_Config_Base |
2477 | 2477 | { |
2478 | 2478 | |
2479 | - /** |
|
2480 | - * @var boolean $use_personnel_manager |
|
2481 | - */ |
|
2482 | - public $use_personnel_manager; |
|
2483 | - |
|
2484 | - /** |
|
2485 | - * @var boolean $use_dashboard_widget |
|
2486 | - */ |
|
2487 | - public $use_dashboard_widget; |
|
2488 | - |
|
2489 | - /** |
|
2490 | - * @var int $events_in_dashboard |
|
2491 | - */ |
|
2492 | - public $events_in_dashboard; |
|
2493 | - |
|
2494 | - /** |
|
2495 | - * @var boolean $use_event_timezones |
|
2496 | - */ |
|
2497 | - public $use_event_timezones; |
|
2498 | - |
|
2499 | - /** |
|
2500 | - * @var boolean $use_full_logging |
|
2501 | - */ |
|
2502 | - public $use_full_logging; |
|
2503 | - |
|
2504 | - /** |
|
2505 | - * @var string $log_file_name |
|
2506 | - */ |
|
2507 | - public $log_file_name; |
|
2508 | - |
|
2509 | - /** |
|
2510 | - * @var string $debug_file_name |
|
2511 | - */ |
|
2512 | - public $debug_file_name; |
|
2513 | - |
|
2514 | - /** |
|
2515 | - * @var boolean $use_remote_logging |
|
2516 | - */ |
|
2517 | - public $use_remote_logging; |
|
2518 | - |
|
2519 | - /** |
|
2520 | - * @var string $remote_logging_url |
|
2521 | - */ |
|
2522 | - public $remote_logging_url; |
|
2523 | - |
|
2524 | - /** |
|
2525 | - * @var boolean $show_reg_footer |
|
2526 | - */ |
|
2527 | - public $show_reg_footer; |
|
2528 | - |
|
2529 | - /** |
|
2530 | - * @var string $affiliate_id |
|
2531 | - */ |
|
2532 | - public $affiliate_id; |
|
2533 | - |
|
2534 | - /** |
|
2535 | - * help tours on or off (global setting) |
|
2536 | - * |
|
2537 | - * @var boolean |
|
2538 | - */ |
|
2539 | - public $help_tour_activation; |
|
2540 | - |
|
2541 | - /** |
|
2542 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
2543 | - * but is incompatible with some server configuration errors |
|
2544 | - * if you get "500 internal server errors" during registration, try turning this on |
|
2545 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2546 | - * |
|
2547 | - * @var boolean $encode_session_data |
|
2548 | - */ |
|
2549 | - private $encode_session_data = false; |
|
2550 | - |
|
2551 | - |
|
2552 | - |
|
2553 | - /** |
|
2554 | - * class constructor |
|
2555 | - * |
|
2556 | - * @access public |
|
2557 | - */ |
|
2558 | - public function __construct() |
|
2559 | - { |
|
2560 | - // set default general admin settings |
|
2561 | - $this->use_personnel_manager = true; |
|
2562 | - $this->use_dashboard_widget = true; |
|
2563 | - $this->events_in_dashboard = 30; |
|
2564 | - $this->use_event_timezones = false; |
|
2565 | - $this->use_full_logging = false; |
|
2566 | - $this->use_remote_logging = false; |
|
2567 | - $this->remote_logging_url = null; |
|
2568 | - $this->show_reg_footer = true; |
|
2569 | - $this->affiliate_id = 'default'; |
|
2570 | - $this->help_tour_activation = true; |
|
2571 | - $this->encode_session_data = false; |
|
2572 | - } |
|
2573 | - |
|
2574 | - |
|
2575 | - |
|
2576 | - /** |
|
2577 | - * @param bool $reset |
|
2578 | - * @return string |
|
2579 | - */ |
|
2580 | - public function log_file_name($reset = false) |
|
2581 | - { |
|
2582 | - if (empty($this->log_file_name) || $reset) { |
|
2583 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2584 | - EE_Config::instance()->update_espresso_config(false, false); |
|
2585 | - } |
|
2586 | - return $this->log_file_name; |
|
2587 | - } |
|
2588 | - |
|
2589 | - |
|
2590 | - |
|
2591 | - /** |
|
2592 | - * @param bool $reset |
|
2593 | - * @return string |
|
2594 | - */ |
|
2595 | - public function debug_file_name($reset = false) |
|
2596 | - { |
|
2597 | - if (empty($this->debug_file_name) || $reset) { |
|
2598 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2599 | - EE_Config::instance()->update_espresso_config(false, false); |
|
2600 | - } |
|
2601 | - return $this->debug_file_name; |
|
2602 | - } |
|
2603 | - |
|
2604 | - |
|
2605 | - |
|
2606 | - /** |
|
2607 | - * @return string |
|
2608 | - */ |
|
2609 | - public function affiliate_id() |
|
2610 | - { |
|
2611 | - return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2612 | - } |
|
2613 | - |
|
2614 | - |
|
2615 | - |
|
2616 | - /** |
|
2617 | - * @return boolean |
|
2618 | - */ |
|
2619 | - public function encode_session_data() |
|
2620 | - { |
|
2621 | - return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2622 | - } |
|
2623 | - |
|
2624 | - |
|
2625 | - |
|
2626 | - /** |
|
2627 | - * @param boolean $encode_session_data |
|
2628 | - */ |
|
2629 | - public function set_encode_session_data($encode_session_data) |
|
2630 | - { |
|
2631 | - $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2632 | - } |
|
2479 | + /** |
|
2480 | + * @var boolean $use_personnel_manager |
|
2481 | + */ |
|
2482 | + public $use_personnel_manager; |
|
2483 | + |
|
2484 | + /** |
|
2485 | + * @var boolean $use_dashboard_widget |
|
2486 | + */ |
|
2487 | + public $use_dashboard_widget; |
|
2488 | + |
|
2489 | + /** |
|
2490 | + * @var int $events_in_dashboard |
|
2491 | + */ |
|
2492 | + public $events_in_dashboard; |
|
2493 | + |
|
2494 | + /** |
|
2495 | + * @var boolean $use_event_timezones |
|
2496 | + */ |
|
2497 | + public $use_event_timezones; |
|
2498 | + |
|
2499 | + /** |
|
2500 | + * @var boolean $use_full_logging |
|
2501 | + */ |
|
2502 | + public $use_full_logging; |
|
2503 | + |
|
2504 | + /** |
|
2505 | + * @var string $log_file_name |
|
2506 | + */ |
|
2507 | + public $log_file_name; |
|
2508 | + |
|
2509 | + /** |
|
2510 | + * @var string $debug_file_name |
|
2511 | + */ |
|
2512 | + public $debug_file_name; |
|
2513 | + |
|
2514 | + /** |
|
2515 | + * @var boolean $use_remote_logging |
|
2516 | + */ |
|
2517 | + public $use_remote_logging; |
|
2518 | + |
|
2519 | + /** |
|
2520 | + * @var string $remote_logging_url |
|
2521 | + */ |
|
2522 | + public $remote_logging_url; |
|
2523 | + |
|
2524 | + /** |
|
2525 | + * @var boolean $show_reg_footer |
|
2526 | + */ |
|
2527 | + public $show_reg_footer; |
|
2528 | + |
|
2529 | + /** |
|
2530 | + * @var string $affiliate_id |
|
2531 | + */ |
|
2532 | + public $affiliate_id; |
|
2533 | + |
|
2534 | + /** |
|
2535 | + * help tours on or off (global setting) |
|
2536 | + * |
|
2537 | + * @var boolean |
|
2538 | + */ |
|
2539 | + public $help_tour_activation; |
|
2540 | + |
|
2541 | + /** |
|
2542 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
2543 | + * but is incompatible with some server configuration errors |
|
2544 | + * if you get "500 internal server errors" during registration, try turning this on |
|
2545 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2546 | + * |
|
2547 | + * @var boolean $encode_session_data |
|
2548 | + */ |
|
2549 | + private $encode_session_data = false; |
|
2550 | + |
|
2551 | + |
|
2552 | + |
|
2553 | + /** |
|
2554 | + * class constructor |
|
2555 | + * |
|
2556 | + * @access public |
|
2557 | + */ |
|
2558 | + public function __construct() |
|
2559 | + { |
|
2560 | + // set default general admin settings |
|
2561 | + $this->use_personnel_manager = true; |
|
2562 | + $this->use_dashboard_widget = true; |
|
2563 | + $this->events_in_dashboard = 30; |
|
2564 | + $this->use_event_timezones = false; |
|
2565 | + $this->use_full_logging = false; |
|
2566 | + $this->use_remote_logging = false; |
|
2567 | + $this->remote_logging_url = null; |
|
2568 | + $this->show_reg_footer = true; |
|
2569 | + $this->affiliate_id = 'default'; |
|
2570 | + $this->help_tour_activation = true; |
|
2571 | + $this->encode_session_data = false; |
|
2572 | + } |
|
2573 | + |
|
2574 | + |
|
2575 | + |
|
2576 | + /** |
|
2577 | + * @param bool $reset |
|
2578 | + * @return string |
|
2579 | + */ |
|
2580 | + public function log_file_name($reset = false) |
|
2581 | + { |
|
2582 | + if (empty($this->log_file_name) || $reset) { |
|
2583 | + $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2584 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2585 | + } |
|
2586 | + return $this->log_file_name; |
|
2587 | + } |
|
2588 | + |
|
2589 | + |
|
2590 | + |
|
2591 | + /** |
|
2592 | + * @param bool $reset |
|
2593 | + * @return string |
|
2594 | + */ |
|
2595 | + public function debug_file_name($reset = false) |
|
2596 | + { |
|
2597 | + if (empty($this->debug_file_name) || $reset) { |
|
2598 | + $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2599 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2600 | + } |
|
2601 | + return $this->debug_file_name; |
|
2602 | + } |
|
2603 | + |
|
2604 | + |
|
2605 | + |
|
2606 | + /** |
|
2607 | + * @return string |
|
2608 | + */ |
|
2609 | + public function affiliate_id() |
|
2610 | + { |
|
2611 | + return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2612 | + } |
|
2613 | + |
|
2614 | + |
|
2615 | + |
|
2616 | + /** |
|
2617 | + * @return boolean |
|
2618 | + */ |
|
2619 | + public function encode_session_data() |
|
2620 | + { |
|
2621 | + return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2622 | + } |
|
2623 | + |
|
2624 | + |
|
2625 | + |
|
2626 | + /** |
|
2627 | + * @param boolean $encode_session_data |
|
2628 | + */ |
|
2629 | + public function set_encode_session_data($encode_session_data) |
|
2630 | + { |
|
2631 | + $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2632 | + } |
|
2633 | 2633 | |
2634 | 2634 | |
2635 | 2635 | |
@@ -2643,71 +2643,71 @@ discard block |
||
2643 | 2643 | class EE_Template_Config extends EE_Config_Base |
2644 | 2644 | { |
2645 | 2645 | |
2646 | - /** |
|
2647 | - * @var boolean $enable_default_style |
|
2648 | - */ |
|
2649 | - public $enable_default_style; |
|
2650 | - |
|
2651 | - /** |
|
2652 | - * @var string $custom_style_sheet |
|
2653 | - */ |
|
2654 | - public $custom_style_sheet; |
|
2655 | - |
|
2656 | - /** |
|
2657 | - * @var boolean $display_address_in_regform |
|
2658 | - */ |
|
2659 | - public $display_address_in_regform; |
|
2660 | - |
|
2661 | - /** |
|
2662 | - * @var int $display_description_on_multi_reg_page |
|
2663 | - */ |
|
2664 | - public $display_description_on_multi_reg_page; |
|
2665 | - |
|
2666 | - /** |
|
2667 | - * @var boolean $use_custom_templates |
|
2668 | - */ |
|
2669 | - public $use_custom_templates; |
|
2670 | - |
|
2671 | - /** |
|
2672 | - * @var string $current_espresso_theme |
|
2673 | - */ |
|
2674 | - public $current_espresso_theme; |
|
2675 | - |
|
2676 | - /** |
|
2677 | - * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2678 | - */ |
|
2679 | - public $EED_Ticket_Selector; |
|
2680 | - |
|
2681 | - /** |
|
2682 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
2683 | - */ |
|
2684 | - public $EED_Event_Single; |
|
2685 | - |
|
2686 | - /** |
|
2687 | - * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2688 | - */ |
|
2689 | - public $EED_Events_Archive; |
|
2690 | - |
|
2691 | - |
|
2692 | - |
|
2693 | - /** |
|
2694 | - * class constructor |
|
2695 | - * |
|
2696 | - * @access public |
|
2697 | - */ |
|
2698 | - public function __construct() |
|
2699 | - { |
|
2700 | - // set default template settings |
|
2701 | - $this->enable_default_style = true; |
|
2702 | - $this->custom_style_sheet = null; |
|
2703 | - $this->display_address_in_regform = true; |
|
2704 | - $this->display_description_on_multi_reg_page = false; |
|
2705 | - $this->use_custom_templates = false; |
|
2706 | - $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2707 | - $this->EED_Event_Single = null; |
|
2708 | - $this->EED_Events_Archive = null; |
|
2709 | - $this->EED_Ticket_Selector = null; |
|
2710 | - } |
|
2646 | + /** |
|
2647 | + * @var boolean $enable_default_style |
|
2648 | + */ |
|
2649 | + public $enable_default_style; |
|
2650 | + |
|
2651 | + /** |
|
2652 | + * @var string $custom_style_sheet |
|
2653 | + */ |
|
2654 | + public $custom_style_sheet; |
|
2655 | + |
|
2656 | + /** |
|
2657 | + * @var boolean $display_address_in_regform |
|
2658 | + */ |
|
2659 | + public $display_address_in_regform; |
|
2660 | + |
|
2661 | + /** |
|
2662 | + * @var int $display_description_on_multi_reg_page |
|
2663 | + */ |
|
2664 | + public $display_description_on_multi_reg_page; |
|
2665 | + |
|
2666 | + /** |
|
2667 | + * @var boolean $use_custom_templates |
|
2668 | + */ |
|
2669 | + public $use_custom_templates; |
|
2670 | + |
|
2671 | + /** |
|
2672 | + * @var string $current_espresso_theme |
|
2673 | + */ |
|
2674 | + public $current_espresso_theme; |
|
2675 | + |
|
2676 | + /** |
|
2677 | + * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2678 | + */ |
|
2679 | + public $EED_Ticket_Selector; |
|
2680 | + |
|
2681 | + /** |
|
2682 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
2683 | + */ |
|
2684 | + public $EED_Event_Single; |
|
2685 | + |
|
2686 | + /** |
|
2687 | + * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2688 | + */ |
|
2689 | + public $EED_Events_Archive; |
|
2690 | + |
|
2691 | + |
|
2692 | + |
|
2693 | + /** |
|
2694 | + * class constructor |
|
2695 | + * |
|
2696 | + * @access public |
|
2697 | + */ |
|
2698 | + public function __construct() |
|
2699 | + { |
|
2700 | + // set default template settings |
|
2701 | + $this->enable_default_style = true; |
|
2702 | + $this->custom_style_sheet = null; |
|
2703 | + $this->display_address_in_regform = true; |
|
2704 | + $this->display_description_on_multi_reg_page = false; |
|
2705 | + $this->use_custom_templates = false; |
|
2706 | + $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2707 | + $this->EED_Event_Single = null; |
|
2708 | + $this->EED_Events_Archive = null; |
|
2709 | + $this->EED_Ticket_Selector = null; |
|
2710 | + } |
|
2711 | 2711 | |
2712 | 2712 | } |
2713 | 2713 | |
@@ -2719,115 +2719,115 @@ discard block |
||
2719 | 2719 | class EE_Map_Config extends EE_Config_Base |
2720 | 2720 | { |
2721 | 2721 | |
2722 | - /** |
|
2723 | - * @var boolean $use_google_maps |
|
2724 | - */ |
|
2725 | - public $use_google_maps; |
|
2726 | - |
|
2727 | - /** |
|
2728 | - * @var string $api_key |
|
2729 | - */ |
|
2730 | - public $google_map_api_key; |
|
2731 | - |
|
2732 | - /** |
|
2733 | - * @var int $event_details_map_width |
|
2734 | - */ |
|
2735 | - public $event_details_map_width; |
|
2736 | - |
|
2737 | - /** |
|
2738 | - * @var int $event_details_map_height |
|
2739 | - */ |
|
2740 | - public $event_details_map_height; |
|
2741 | - |
|
2742 | - /** |
|
2743 | - * @var int $event_details_map_zoom |
|
2744 | - */ |
|
2745 | - public $event_details_map_zoom; |
|
2746 | - |
|
2747 | - /** |
|
2748 | - * @var boolean $event_details_display_nav |
|
2749 | - */ |
|
2750 | - public $event_details_display_nav; |
|
2751 | - |
|
2752 | - /** |
|
2753 | - * @var boolean $event_details_nav_size |
|
2754 | - */ |
|
2755 | - public $event_details_nav_size; |
|
2756 | - |
|
2757 | - /** |
|
2758 | - * @var string $event_details_control_type |
|
2759 | - */ |
|
2760 | - public $event_details_control_type; |
|
2761 | - |
|
2762 | - /** |
|
2763 | - * @var string $event_details_map_align |
|
2764 | - */ |
|
2765 | - public $event_details_map_align; |
|
2766 | - |
|
2767 | - /** |
|
2768 | - * @var int $event_list_map_width |
|
2769 | - */ |
|
2770 | - public $event_list_map_width; |
|
2771 | - |
|
2772 | - /** |
|
2773 | - * @var int $event_list_map_height |
|
2774 | - */ |
|
2775 | - public $event_list_map_height; |
|
2776 | - |
|
2777 | - /** |
|
2778 | - * @var int $event_list_map_zoom |
|
2779 | - */ |
|
2780 | - public $event_list_map_zoom; |
|
2781 | - |
|
2782 | - /** |
|
2783 | - * @var boolean $event_list_display_nav |
|
2784 | - */ |
|
2785 | - public $event_list_display_nav; |
|
2786 | - |
|
2787 | - /** |
|
2788 | - * @var boolean $event_list_nav_size |
|
2789 | - */ |
|
2790 | - public $event_list_nav_size; |
|
2791 | - |
|
2792 | - /** |
|
2793 | - * @var string $event_list_control_type |
|
2794 | - */ |
|
2795 | - public $event_list_control_type; |
|
2796 | - |
|
2797 | - /** |
|
2798 | - * @var string $event_list_map_align |
|
2799 | - */ |
|
2800 | - public $event_list_map_align; |
|
2801 | - |
|
2802 | - |
|
2803 | - |
|
2804 | - /** |
|
2805 | - * class constructor |
|
2806 | - * |
|
2807 | - * @access public |
|
2808 | - */ |
|
2809 | - public function __construct() |
|
2810 | - { |
|
2811 | - // set default map settings |
|
2812 | - $this->use_google_maps = true; |
|
2813 | - $this->google_map_api_key = ''; |
|
2814 | - // for event details pages (reg page) |
|
2815 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2816 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2817 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2818 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2819 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2820 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2821 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2822 | - // for event list pages |
|
2823 | - $this->event_list_map_width = 300; // ee_map_width |
|
2824 | - $this->event_list_map_height = 185; // ee_map_height |
|
2825 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2826 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
2827 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
2828 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2829 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2830 | - } |
|
2722 | + /** |
|
2723 | + * @var boolean $use_google_maps |
|
2724 | + */ |
|
2725 | + public $use_google_maps; |
|
2726 | + |
|
2727 | + /** |
|
2728 | + * @var string $api_key |
|
2729 | + */ |
|
2730 | + public $google_map_api_key; |
|
2731 | + |
|
2732 | + /** |
|
2733 | + * @var int $event_details_map_width |
|
2734 | + */ |
|
2735 | + public $event_details_map_width; |
|
2736 | + |
|
2737 | + /** |
|
2738 | + * @var int $event_details_map_height |
|
2739 | + */ |
|
2740 | + public $event_details_map_height; |
|
2741 | + |
|
2742 | + /** |
|
2743 | + * @var int $event_details_map_zoom |
|
2744 | + */ |
|
2745 | + public $event_details_map_zoom; |
|
2746 | + |
|
2747 | + /** |
|
2748 | + * @var boolean $event_details_display_nav |
|
2749 | + */ |
|
2750 | + public $event_details_display_nav; |
|
2751 | + |
|
2752 | + /** |
|
2753 | + * @var boolean $event_details_nav_size |
|
2754 | + */ |
|
2755 | + public $event_details_nav_size; |
|
2756 | + |
|
2757 | + /** |
|
2758 | + * @var string $event_details_control_type |
|
2759 | + */ |
|
2760 | + public $event_details_control_type; |
|
2761 | + |
|
2762 | + /** |
|
2763 | + * @var string $event_details_map_align |
|
2764 | + */ |
|
2765 | + public $event_details_map_align; |
|
2766 | + |
|
2767 | + /** |
|
2768 | + * @var int $event_list_map_width |
|
2769 | + */ |
|
2770 | + public $event_list_map_width; |
|
2771 | + |
|
2772 | + /** |
|
2773 | + * @var int $event_list_map_height |
|
2774 | + */ |
|
2775 | + public $event_list_map_height; |
|
2776 | + |
|
2777 | + /** |
|
2778 | + * @var int $event_list_map_zoom |
|
2779 | + */ |
|
2780 | + public $event_list_map_zoom; |
|
2781 | + |
|
2782 | + /** |
|
2783 | + * @var boolean $event_list_display_nav |
|
2784 | + */ |
|
2785 | + public $event_list_display_nav; |
|
2786 | + |
|
2787 | + /** |
|
2788 | + * @var boolean $event_list_nav_size |
|
2789 | + */ |
|
2790 | + public $event_list_nav_size; |
|
2791 | + |
|
2792 | + /** |
|
2793 | + * @var string $event_list_control_type |
|
2794 | + */ |
|
2795 | + public $event_list_control_type; |
|
2796 | + |
|
2797 | + /** |
|
2798 | + * @var string $event_list_map_align |
|
2799 | + */ |
|
2800 | + public $event_list_map_align; |
|
2801 | + |
|
2802 | + |
|
2803 | + |
|
2804 | + /** |
|
2805 | + * class constructor |
|
2806 | + * |
|
2807 | + * @access public |
|
2808 | + */ |
|
2809 | + public function __construct() |
|
2810 | + { |
|
2811 | + // set default map settings |
|
2812 | + $this->use_google_maps = true; |
|
2813 | + $this->google_map_api_key = ''; |
|
2814 | + // for event details pages (reg page) |
|
2815 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2816 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2817 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2818 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2819 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2820 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2821 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2822 | + // for event list pages |
|
2823 | + $this->event_list_map_width = 300; // ee_map_width |
|
2824 | + $this->event_list_map_height = 185; // ee_map_height |
|
2825 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2826 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
2827 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
2828 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2829 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2830 | + } |
|
2831 | 2831 | |
2832 | 2832 | } |
2833 | 2833 | |
@@ -2839,47 +2839,47 @@ discard block |
||
2839 | 2839 | class EE_Events_Archive_Config extends EE_Config_Base |
2840 | 2840 | { |
2841 | 2841 | |
2842 | - public $display_status_banner; |
|
2842 | + public $display_status_banner; |
|
2843 | 2843 | |
2844 | - public $display_description; |
|
2844 | + public $display_description; |
|
2845 | 2845 | |
2846 | - public $display_ticket_selector; |
|
2846 | + public $display_ticket_selector; |
|
2847 | 2847 | |
2848 | - public $display_datetimes; |
|
2848 | + public $display_datetimes; |
|
2849 | 2849 | |
2850 | - public $display_venue; |
|
2850 | + public $display_venue; |
|
2851 | 2851 | |
2852 | - public $display_expired_events; |
|
2852 | + public $display_expired_events; |
|
2853 | 2853 | |
2854 | - public $use_sortable_display_order; |
|
2854 | + public $use_sortable_display_order; |
|
2855 | 2855 | |
2856 | - public $display_order_tickets; |
|
2856 | + public $display_order_tickets; |
|
2857 | 2857 | |
2858 | - public $display_order_datetimes; |
|
2858 | + public $display_order_datetimes; |
|
2859 | 2859 | |
2860 | - public $display_order_event; |
|
2860 | + public $display_order_event; |
|
2861 | 2861 | |
2862 | - public $display_order_venue; |
|
2862 | + public $display_order_venue; |
|
2863 | 2863 | |
2864 | 2864 | |
2865 | 2865 | |
2866 | - /** |
|
2867 | - * class constructor |
|
2868 | - */ |
|
2869 | - public function __construct() |
|
2870 | - { |
|
2871 | - $this->display_status_banner = 0; |
|
2872 | - $this->display_description = 1; |
|
2873 | - $this->display_ticket_selector = 0; |
|
2874 | - $this->display_datetimes = 1; |
|
2875 | - $this->display_venue = 0; |
|
2876 | - $this->display_expired_events = 0; |
|
2877 | - $this->use_sortable_display_order = false; |
|
2878 | - $this->display_order_tickets = 100; |
|
2879 | - $this->display_order_datetimes = 110; |
|
2880 | - $this->display_order_event = 120; |
|
2881 | - $this->display_order_venue = 130; |
|
2882 | - } |
|
2866 | + /** |
|
2867 | + * class constructor |
|
2868 | + */ |
|
2869 | + public function __construct() |
|
2870 | + { |
|
2871 | + $this->display_status_banner = 0; |
|
2872 | + $this->display_description = 1; |
|
2873 | + $this->display_ticket_selector = 0; |
|
2874 | + $this->display_datetimes = 1; |
|
2875 | + $this->display_venue = 0; |
|
2876 | + $this->display_expired_events = 0; |
|
2877 | + $this->use_sortable_display_order = false; |
|
2878 | + $this->display_order_tickets = 100; |
|
2879 | + $this->display_order_datetimes = 110; |
|
2880 | + $this->display_order_event = 120; |
|
2881 | + $this->display_order_venue = 130; |
|
2882 | + } |
|
2883 | 2883 | } |
2884 | 2884 | |
2885 | 2885 | |
@@ -2890,35 +2890,35 @@ discard block |
||
2890 | 2890 | class EE_Event_Single_Config extends EE_Config_Base |
2891 | 2891 | { |
2892 | 2892 | |
2893 | - public $display_status_banner_single; |
|
2893 | + public $display_status_banner_single; |
|
2894 | 2894 | |
2895 | - public $display_venue; |
|
2895 | + public $display_venue; |
|
2896 | 2896 | |
2897 | - public $use_sortable_display_order; |
|
2897 | + public $use_sortable_display_order; |
|
2898 | 2898 | |
2899 | - public $display_order_tickets; |
|
2899 | + public $display_order_tickets; |
|
2900 | 2900 | |
2901 | - public $display_order_datetimes; |
|
2901 | + public $display_order_datetimes; |
|
2902 | 2902 | |
2903 | - public $display_order_event; |
|
2903 | + public $display_order_event; |
|
2904 | 2904 | |
2905 | - public $display_order_venue; |
|
2905 | + public $display_order_venue; |
|
2906 | 2906 | |
2907 | 2907 | |
2908 | 2908 | |
2909 | - /** |
|
2910 | - * class constructor |
|
2911 | - */ |
|
2912 | - public function __construct() |
|
2913 | - { |
|
2914 | - $this->display_status_banner_single = 0; |
|
2915 | - $this->display_venue = 1; |
|
2916 | - $this->use_sortable_display_order = false; |
|
2917 | - $this->display_order_tickets = 100; |
|
2918 | - $this->display_order_datetimes = 110; |
|
2919 | - $this->display_order_event = 120; |
|
2920 | - $this->display_order_venue = 130; |
|
2921 | - } |
|
2909 | + /** |
|
2910 | + * class constructor |
|
2911 | + */ |
|
2912 | + public function __construct() |
|
2913 | + { |
|
2914 | + $this->display_status_banner_single = 0; |
|
2915 | + $this->display_venue = 1; |
|
2916 | + $this->use_sortable_display_order = false; |
|
2917 | + $this->display_order_tickets = 100; |
|
2918 | + $this->display_order_datetimes = 110; |
|
2919 | + $this->display_order_event = 120; |
|
2920 | + $this->display_order_venue = 130; |
|
2921 | + } |
|
2922 | 2922 | } |
2923 | 2923 | |
2924 | 2924 | |
@@ -2929,152 +2929,152 @@ discard block |
||
2929 | 2929 | class EE_Ticket_Selector_Config extends EE_Config_Base |
2930 | 2930 | { |
2931 | 2931 | |
2932 | - /** |
|
2933 | - * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2934 | - */ |
|
2935 | - const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2936 | - |
|
2937 | - /** |
|
2938 | - * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2939 | - * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2940 | - */ |
|
2941 | - const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2942 | - |
|
2943 | - /** |
|
2944 | - * @var boolean $show_ticket_sale_columns |
|
2945 | - */ |
|
2946 | - public $show_ticket_sale_columns; |
|
2947 | - |
|
2948 | - /** |
|
2949 | - * @var boolean $show_ticket_details |
|
2950 | - */ |
|
2951 | - public $show_ticket_details; |
|
2952 | - |
|
2953 | - /** |
|
2954 | - * @var boolean $show_expired_tickets |
|
2955 | - */ |
|
2956 | - public $show_expired_tickets; |
|
2957 | - |
|
2958 | - /** |
|
2959 | - * whether or not to display a dropdown box populated with event datetimes |
|
2960 | - * that toggles which tickets are displayed for a ticket selector. |
|
2961 | - * uses one of the *_DATETIME_SELECTOR constants defined above |
|
2962 | - * |
|
2963 | - * @var string $show_datetime_selector |
|
2964 | - */ |
|
2965 | - private $show_datetime_selector = 'no_datetime_selector'; |
|
2966 | - |
|
2967 | - /** |
|
2968 | - * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
2969 | - * |
|
2970 | - * @var int $datetime_selector_threshold |
|
2971 | - */ |
|
2972 | - private $datetime_selector_threshold = 3; |
|
2973 | - |
|
2974 | - |
|
2975 | - |
|
2976 | - /** |
|
2977 | - * class constructor |
|
2978 | - */ |
|
2979 | - public function __construct() |
|
2980 | - { |
|
2981 | - $this->show_ticket_sale_columns = true; |
|
2982 | - $this->show_ticket_details = true; |
|
2983 | - $this->show_expired_tickets = true; |
|
2984 | - $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
2985 | - $this->datetime_selector_threshold = 3; |
|
2986 | - } |
|
2987 | - |
|
2988 | - |
|
2989 | - |
|
2990 | - /** |
|
2991 | - * returns true if a datetime selector should be displayed |
|
2992 | - * |
|
2993 | - * @param array $datetimes |
|
2994 | - * @return bool |
|
2995 | - */ |
|
2996 | - public function showDatetimeSelector(array $datetimes) |
|
2997 | - { |
|
2998 | - // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
2999 | - return ! ( |
|
3000 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
3001 | - || ( |
|
3002 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
3003 | - && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
3004 | - ) |
|
3005 | - ); |
|
3006 | - } |
|
3007 | - |
|
3008 | - |
|
3009 | - |
|
3010 | - /** |
|
3011 | - * @return string |
|
3012 | - */ |
|
3013 | - public function getShowDatetimeSelector() |
|
3014 | - { |
|
3015 | - return $this->show_datetime_selector; |
|
3016 | - } |
|
3017 | - |
|
3018 | - |
|
3019 | - |
|
3020 | - /** |
|
3021 | - * @param bool $keys_only |
|
3022 | - * @return array |
|
3023 | - */ |
|
3024 | - public function getShowDatetimeSelectorOptions($keys_only = true) |
|
3025 | - { |
|
3026 | - return $keys_only |
|
3027 | - ? array( |
|
3028 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
3029 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
3030 | - ) |
|
3031 | - : array( |
|
3032 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3033 | - 'Do not show date & time filter', 'event_espresso' |
|
3034 | - ), |
|
3035 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3036 | - 'Maybe show date & time filter', 'event_espresso' |
|
3037 | - ), |
|
3038 | - ); |
|
3039 | - } |
|
3040 | - |
|
3041 | - |
|
3042 | - |
|
3043 | - /** |
|
3044 | - * @param string $show_datetime_selector |
|
3045 | - */ |
|
3046 | - public function setShowDatetimeSelector($show_datetime_selector) |
|
3047 | - { |
|
3048 | - $this->show_datetime_selector = in_array( |
|
3049 | - $show_datetime_selector, |
|
3050 | - $this->getShowDatetimeSelectorOptions(), |
|
3051 | - true |
|
3052 | - ) |
|
3053 | - ? $show_datetime_selector |
|
3054 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3055 | - } |
|
3056 | - |
|
3057 | - |
|
3058 | - |
|
3059 | - /** |
|
3060 | - * @return int |
|
3061 | - */ |
|
3062 | - public function getDatetimeSelectorThreshold() |
|
3063 | - { |
|
3064 | - return $this->datetime_selector_threshold; |
|
3065 | - } |
|
3066 | - |
|
3067 | - |
|
3068 | - |
|
3069 | - |
|
3070 | - /** |
|
3071 | - * @param int $datetime_selector_threshold |
|
3072 | - */ |
|
3073 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3074 | - { |
|
3075 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3076 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3077 | - } |
|
2932 | + /** |
|
2933 | + * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2934 | + */ |
|
2935 | + const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2936 | + |
|
2937 | + /** |
|
2938 | + * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2939 | + * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2940 | + */ |
|
2941 | + const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2942 | + |
|
2943 | + /** |
|
2944 | + * @var boolean $show_ticket_sale_columns |
|
2945 | + */ |
|
2946 | + public $show_ticket_sale_columns; |
|
2947 | + |
|
2948 | + /** |
|
2949 | + * @var boolean $show_ticket_details |
|
2950 | + */ |
|
2951 | + public $show_ticket_details; |
|
2952 | + |
|
2953 | + /** |
|
2954 | + * @var boolean $show_expired_tickets |
|
2955 | + */ |
|
2956 | + public $show_expired_tickets; |
|
2957 | + |
|
2958 | + /** |
|
2959 | + * whether or not to display a dropdown box populated with event datetimes |
|
2960 | + * that toggles which tickets are displayed for a ticket selector. |
|
2961 | + * uses one of the *_DATETIME_SELECTOR constants defined above |
|
2962 | + * |
|
2963 | + * @var string $show_datetime_selector |
|
2964 | + */ |
|
2965 | + private $show_datetime_selector = 'no_datetime_selector'; |
|
2966 | + |
|
2967 | + /** |
|
2968 | + * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
2969 | + * |
|
2970 | + * @var int $datetime_selector_threshold |
|
2971 | + */ |
|
2972 | + private $datetime_selector_threshold = 3; |
|
2973 | + |
|
2974 | + |
|
2975 | + |
|
2976 | + /** |
|
2977 | + * class constructor |
|
2978 | + */ |
|
2979 | + public function __construct() |
|
2980 | + { |
|
2981 | + $this->show_ticket_sale_columns = true; |
|
2982 | + $this->show_ticket_details = true; |
|
2983 | + $this->show_expired_tickets = true; |
|
2984 | + $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
2985 | + $this->datetime_selector_threshold = 3; |
|
2986 | + } |
|
2987 | + |
|
2988 | + |
|
2989 | + |
|
2990 | + /** |
|
2991 | + * returns true if a datetime selector should be displayed |
|
2992 | + * |
|
2993 | + * @param array $datetimes |
|
2994 | + * @return bool |
|
2995 | + */ |
|
2996 | + public function showDatetimeSelector(array $datetimes) |
|
2997 | + { |
|
2998 | + // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
2999 | + return ! ( |
|
3000 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
3001 | + || ( |
|
3002 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
3003 | + && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
3004 | + ) |
|
3005 | + ); |
|
3006 | + } |
|
3007 | + |
|
3008 | + |
|
3009 | + |
|
3010 | + /** |
|
3011 | + * @return string |
|
3012 | + */ |
|
3013 | + public function getShowDatetimeSelector() |
|
3014 | + { |
|
3015 | + return $this->show_datetime_selector; |
|
3016 | + } |
|
3017 | + |
|
3018 | + |
|
3019 | + |
|
3020 | + /** |
|
3021 | + * @param bool $keys_only |
|
3022 | + * @return array |
|
3023 | + */ |
|
3024 | + public function getShowDatetimeSelectorOptions($keys_only = true) |
|
3025 | + { |
|
3026 | + return $keys_only |
|
3027 | + ? array( |
|
3028 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
3029 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
3030 | + ) |
|
3031 | + : array( |
|
3032 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3033 | + 'Do not show date & time filter', 'event_espresso' |
|
3034 | + ), |
|
3035 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3036 | + 'Maybe show date & time filter', 'event_espresso' |
|
3037 | + ), |
|
3038 | + ); |
|
3039 | + } |
|
3040 | + |
|
3041 | + |
|
3042 | + |
|
3043 | + /** |
|
3044 | + * @param string $show_datetime_selector |
|
3045 | + */ |
|
3046 | + public function setShowDatetimeSelector($show_datetime_selector) |
|
3047 | + { |
|
3048 | + $this->show_datetime_selector = in_array( |
|
3049 | + $show_datetime_selector, |
|
3050 | + $this->getShowDatetimeSelectorOptions(), |
|
3051 | + true |
|
3052 | + ) |
|
3053 | + ? $show_datetime_selector |
|
3054 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3055 | + } |
|
3056 | + |
|
3057 | + |
|
3058 | + |
|
3059 | + /** |
|
3060 | + * @return int |
|
3061 | + */ |
|
3062 | + public function getDatetimeSelectorThreshold() |
|
3063 | + { |
|
3064 | + return $this->datetime_selector_threshold; |
|
3065 | + } |
|
3066 | + |
|
3067 | + |
|
3068 | + |
|
3069 | + |
|
3070 | + /** |
|
3071 | + * @param int $datetime_selector_threshold |
|
3072 | + */ |
|
3073 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3074 | + { |
|
3075 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3076 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3077 | + } |
|
3078 | 3078 | |
3079 | 3079 | |
3080 | 3080 | |
@@ -3092,85 +3092,85 @@ discard block |
||
3092 | 3092 | class EE_Environment_Config extends EE_Config_Base |
3093 | 3093 | { |
3094 | 3094 | |
3095 | - /** |
|
3096 | - * Hold any php environment variables that we want to track. |
|
3097 | - * |
|
3098 | - * @var stdClass; |
|
3099 | - */ |
|
3100 | - public $php; |
|
3101 | - |
|
3102 | - |
|
3103 | - |
|
3104 | - /** |
|
3105 | - * constructor |
|
3106 | - */ |
|
3107 | - public function __construct() |
|
3108 | - { |
|
3109 | - $this->php = new stdClass(); |
|
3110 | - $this->_set_php_values(); |
|
3111 | - } |
|
3112 | - |
|
3113 | - |
|
3114 | - |
|
3115 | - /** |
|
3116 | - * This sets the php environment variables. |
|
3117 | - * |
|
3118 | - * @since 4.4.0 |
|
3119 | - * @return void |
|
3120 | - */ |
|
3121 | - protected function _set_php_values() |
|
3122 | - { |
|
3123 | - $this->php->max_input_vars = ini_get('max_input_vars'); |
|
3124 | - $this->php->version = phpversion(); |
|
3125 | - } |
|
3126 | - |
|
3127 | - |
|
3128 | - |
|
3129 | - /** |
|
3130 | - * helper method for determining whether input_count is |
|
3131 | - * reaching the potential maximum the server can handle |
|
3132 | - * according to max_input_vars |
|
3133 | - * |
|
3134 | - * @param int $input_count the count of input vars. |
|
3135 | - * @return array { |
|
3136 | - * An array that represents whether available space and if no available space the error |
|
3137 | - * message. |
|
3138 | - * @type bool $has_space whether more inputs can be added. |
|
3139 | - * @type string $msg Any message to be displayed. |
|
3140 | - * } |
|
3141 | - */ |
|
3142 | - public function max_input_vars_limit_check($input_count = 0) |
|
3143 | - { |
|
3144 | - if (! empty($this->php->max_input_vars) |
|
3145 | - && ($input_count >= $this->php->max_input_vars) |
|
3146 | - && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
3147 | - ) { |
|
3148 | - return sprintf( |
|
3149 | - __( |
|
3150 | - 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
3151 | - 'event_espresso' |
|
3152 | - ), |
|
3153 | - '<br>', |
|
3154 | - $input_count, |
|
3155 | - $this->php->max_input_vars |
|
3156 | - ); |
|
3157 | - } else { |
|
3158 | - return ''; |
|
3159 | - } |
|
3160 | - } |
|
3161 | - |
|
3162 | - |
|
3163 | - |
|
3164 | - /** |
|
3165 | - * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
3166 | - * |
|
3167 | - * @since 4.4.1 |
|
3168 | - * @return void |
|
3169 | - */ |
|
3170 | - public function recheck_values() |
|
3171 | - { |
|
3172 | - $this->_set_php_values(); |
|
3173 | - } |
|
3095 | + /** |
|
3096 | + * Hold any php environment variables that we want to track. |
|
3097 | + * |
|
3098 | + * @var stdClass; |
|
3099 | + */ |
|
3100 | + public $php; |
|
3101 | + |
|
3102 | + |
|
3103 | + |
|
3104 | + /** |
|
3105 | + * constructor |
|
3106 | + */ |
|
3107 | + public function __construct() |
|
3108 | + { |
|
3109 | + $this->php = new stdClass(); |
|
3110 | + $this->_set_php_values(); |
|
3111 | + } |
|
3112 | + |
|
3113 | + |
|
3114 | + |
|
3115 | + /** |
|
3116 | + * This sets the php environment variables. |
|
3117 | + * |
|
3118 | + * @since 4.4.0 |
|
3119 | + * @return void |
|
3120 | + */ |
|
3121 | + protected function _set_php_values() |
|
3122 | + { |
|
3123 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
3124 | + $this->php->version = phpversion(); |
|
3125 | + } |
|
3126 | + |
|
3127 | + |
|
3128 | + |
|
3129 | + /** |
|
3130 | + * helper method for determining whether input_count is |
|
3131 | + * reaching the potential maximum the server can handle |
|
3132 | + * according to max_input_vars |
|
3133 | + * |
|
3134 | + * @param int $input_count the count of input vars. |
|
3135 | + * @return array { |
|
3136 | + * An array that represents whether available space and if no available space the error |
|
3137 | + * message. |
|
3138 | + * @type bool $has_space whether more inputs can be added. |
|
3139 | + * @type string $msg Any message to be displayed. |
|
3140 | + * } |
|
3141 | + */ |
|
3142 | + public function max_input_vars_limit_check($input_count = 0) |
|
3143 | + { |
|
3144 | + if (! empty($this->php->max_input_vars) |
|
3145 | + && ($input_count >= $this->php->max_input_vars) |
|
3146 | + && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
3147 | + ) { |
|
3148 | + return sprintf( |
|
3149 | + __( |
|
3150 | + 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
3151 | + 'event_espresso' |
|
3152 | + ), |
|
3153 | + '<br>', |
|
3154 | + $input_count, |
|
3155 | + $this->php->max_input_vars |
|
3156 | + ); |
|
3157 | + } else { |
|
3158 | + return ''; |
|
3159 | + } |
|
3160 | + } |
|
3161 | + |
|
3162 | + |
|
3163 | + |
|
3164 | + /** |
|
3165 | + * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
3166 | + * |
|
3167 | + * @since 4.4.1 |
|
3168 | + * @return void |
|
3169 | + */ |
|
3170 | + public function recheck_values() |
|
3171 | + { |
|
3172 | + $this->_set_php_values(); |
|
3173 | + } |
|
3174 | 3174 | |
3175 | 3175 | |
3176 | 3176 | |
@@ -3188,22 +3188,22 @@ discard block |
||
3188 | 3188 | class EE_Tax_Config extends EE_Config_Base |
3189 | 3189 | { |
3190 | 3190 | |
3191 | - /* |
|
3191 | + /* |
|
3192 | 3192 | * flag to indicate whether or not to display ticket prices with the taxes included |
3193 | 3193 | * |
3194 | 3194 | * @var boolean $prices_displayed_including_taxes |
3195 | 3195 | */ |
3196 | - public $prices_displayed_including_taxes; |
|
3196 | + public $prices_displayed_including_taxes; |
|
3197 | 3197 | |
3198 | 3198 | |
3199 | 3199 | |
3200 | - /** |
|
3201 | - * class constructor |
|
3202 | - */ |
|
3203 | - public function __construct() |
|
3204 | - { |
|
3205 | - $this->prices_displayed_including_taxes = true; |
|
3206 | - } |
|
3200 | + /** |
|
3201 | + * class constructor |
|
3202 | + */ |
|
3203 | + public function __construct() |
|
3204 | + { |
|
3205 | + $this->prices_displayed_including_taxes = true; |
|
3206 | + } |
|
3207 | 3207 | } |
3208 | 3208 | |
3209 | 3209 | |
@@ -3218,17 +3218,17 @@ discard block |
||
3218 | 3218 | class EE_Messages_Config extends EE_Config_Base |
3219 | 3219 | { |
3220 | 3220 | |
3221 | - /** |
|
3222 | - * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
3223 | - * A value of 0 represents never deleting. Default is 0. |
|
3224 | - * |
|
3225 | - * @var integer |
|
3226 | - */ |
|
3227 | - public $delete_threshold; |
|
3228 | - |
|
3229 | - public function __construct() { |
|
3230 | - $this->delete_threshold = 0; |
|
3231 | - } |
|
3221 | + /** |
|
3222 | + * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
3223 | + * A value of 0 represents never deleting. Default is 0. |
|
3224 | + * |
|
3225 | + * @var integer |
|
3226 | + */ |
|
3227 | + public $delete_threshold; |
|
3228 | + |
|
3229 | + public function __construct() { |
|
3230 | + $this->delete_threshold = 0; |
|
3231 | + } |
|
3232 | 3232 | } |
3233 | 3233 | |
3234 | 3234 | |
@@ -3240,34 +3240,34 @@ discard block |
||
3240 | 3240 | class EE_Gateway_Config extends EE_Config_Base |
3241 | 3241 | { |
3242 | 3242 | |
3243 | - /** |
|
3244 | - * Array with keys that are payment gateways slugs, and values are arrays |
|
3245 | - * with any config info the gateway wants to store |
|
3246 | - * |
|
3247 | - * @var array |
|
3248 | - */ |
|
3249 | - public $payment_settings; |
|
3250 | - |
|
3251 | - /** |
|
3252 | - * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
3253 | - * the gateway is stored in the uploads directory |
|
3254 | - * |
|
3255 | - * @var array |
|
3256 | - */ |
|
3257 | - public $active_gateways; |
|
3258 | - |
|
3259 | - |
|
3260 | - |
|
3261 | - /** |
|
3262 | - * class constructor |
|
3263 | - * |
|
3264 | - * @deprecated |
|
3265 | - */ |
|
3266 | - public function __construct() |
|
3267 | - { |
|
3268 | - $this->payment_settings = array(); |
|
3269 | - $this->active_gateways = array('Invoice' => false); |
|
3270 | - } |
|
3243 | + /** |
|
3244 | + * Array with keys that are payment gateways slugs, and values are arrays |
|
3245 | + * with any config info the gateway wants to store |
|
3246 | + * |
|
3247 | + * @var array |
|
3248 | + */ |
|
3249 | + public $payment_settings; |
|
3250 | + |
|
3251 | + /** |
|
3252 | + * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
3253 | + * the gateway is stored in the uploads directory |
|
3254 | + * |
|
3255 | + * @var array |
|
3256 | + */ |
|
3257 | + public $active_gateways; |
|
3258 | + |
|
3259 | + |
|
3260 | + |
|
3261 | + /** |
|
3262 | + * class constructor |
|
3263 | + * |
|
3264 | + * @deprecated |
|
3265 | + */ |
|
3266 | + public function __construct() |
|
3267 | + { |
|
3268 | + $this->payment_settings = array(); |
|
3269 | + $this->active_gateways = array('Invoice' => false); |
|
3270 | + } |
|
3271 | 3271 | } |
3272 | 3272 | |
3273 | 3273 | // End of file EE_Config.core.php |