@@ -16,279 +16,279 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @var string $iframe_name |
|
21 | - */ |
|
22 | - private $iframe_name; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var string $route_name |
|
26 | - */ |
|
27 | - private $route_name; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $slug |
|
31 | - */ |
|
32 | - private $slug; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var boolean $append_filterable_content |
|
36 | - */ |
|
37 | - private $append_filterable_content; |
|
38 | - |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * IframeEmbedButton constructor. |
|
43 | - * |
|
44 | - * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
45 | - * @param string $route_name the name of the registered route |
|
46 | - * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
47 | - * will most likely be "event" since that's the only usage atm |
|
48 | - */ |
|
49 | - public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
50 | - { |
|
51 | - $this->iframe_name = $iframe_name; |
|
52 | - $this->route_name = $route_name; |
|
53 | - $this->slug = $slug; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Adds an iframe embed code button to the Event editor. |
|
60 | - */ |
|
61 | - public function addEventEditorIframeEmbedButtonFilter() |
|
62 | - { |
|
63 | - // add button for iframe code to event editor. |
|
64 | - add_filter( |
|
65 | - 'get_sample_permalink_html', |
|
66 | - array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
67 | - 10, |
|
68 | - 2 |
|
69 | - ); |
|
70 | - add_action( |
|
71 | - 'admin_enqueue_scripts', |
|
72 | - array( $this, 'embedButtonAssets' ), |
|
73 | - 10 |
|
74 | - ); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @param $permalink_string |
|
81 | - * @param $id |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
85 | - { |
|
86 | - return $this->eventEditorIframeEmbedButton( |
|
87 | - $permalink_string, |
|
88 | - $id |
|
89 | - ); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * iframe embed code button to the Event editor. |
|
96 | - * |
|
97 | - * @param string $permalink_string |
|
98 | - * @param int $id |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public function eventEditorIframeEmbedButton( |
|
102 | - $permalink_string, |
|
103 | - $id |
|
104 | - ) { |
|
105 | - //make sure this is ONLY when editing and the event id has been set. |
|
106 | - if ( ! empty( $id ) ) { |
|
107 | - $post = get_post( $id ); |
|
108 | - //if NOT event then let's get out. |
|
109 | - if ( $post->post_type !== 'espresso_events' ) { |
|
110 | - return $permalink_string; |
|
111 | - } |
|
112 | - $permalink_string .= $this->embedButtonHtml( |
|
113 | - array( $this->slug => $id ), |
|
114 | - 'button-small' |
|
115 | - ); |
|
116 | - } |
|
117 | - return $permalink_string; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
124 | - * |
|
125 | - * @param string $action name of the WP do_action() to hook into |
|
126 | - */ |
|
127 | - public function addActionIframeEmbedButton( $action ) |
|
128 | - { |
|
129 | - // add button for iframe code to event editor. |
|
130 | - add_action( |
|
131 | - $action, |
|
132 | - array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
133 | - 10, 2 |
|
134 | - ); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @return void |
|
141 | - */ |
|
142 | - public function addActionIframeEmbedButtonCallback() |
|
143 | - { |
|
144 | - echo $this->embedButtonHtml(); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
151 | - * |
|
152 | - * @param string $filter name of the WP apply_filters() to hook into |
|
153 | - * @param bool $append if true, will add iframe embed button to end of content, |
|
154 | - * else if false, will add to the beginning of the content |
|
155 | - */ |
|
156 | - public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
157 | - { |
|
158 | - $this->append_filterable_content = $append; |
|
159 | - // add button for iframe code to event editor. |
|
160 | - add_filter( |
|
161 | - $filter, |
|
162 | - array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
163 | - 10 |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @param array|string $filterable_content |
|
171 | - * @return array|string |
|
172 | - */ |
|
173 | - public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
174 | - { |
|
175 | - $embedButtonHtml = $this->embedButtonHtml(); |
|
176 | - if ( is_array( $filterable_content ) ) { |
|
177 | - $filterable_content = $this->append_filterable_content |
|
178 | - ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | - : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
180 | - } else { |
|
181 | - $filterable_content = $this->append_filterable_content |
|
182 | - ? $filterable_content . $embedButtonHtml |
|
183 | - : $embedButtonHtml . $filterable_content; |
|
184 | - } |
|
185 | - return $filterable_content; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * iframe_embed_html |
|
192 | - * |
|
193 | - * @param array $query_args |
|
194 | - * @param string $button_class |
|
195 | - * @return string |
|
196 | - */ |
|
197 | - public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
198 | - { |
|
199 | - // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
200 | - $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | - $query_args = (array)apply_filters( |
|
202 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
203 | - $query_args |
|
204 | - ); |
|
205 | - // add this route to our localized vars |
|
206 | - $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | - ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
208 | - : array(); |
|
209 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | - \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
211 | - $iframe_embed_html = \EEH_HTML::link( |
|
212 | - '#', |
|
213 | - sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
214 | - sprintf( |
|
215 | - esc_html__( |
|
216 | - 'click here to generate code for embedding %1$s iframe into another site.', |
|
217 | - 'event_espresso' |
|
218 | - ), |
|
219 | - \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
220 | - ), |
|
221 | - "{$this->route_name}-iframe-embed-trigger-js", |
|
222 | - 'iframe-embed-trigger-js button ' . $button_class, |
|
223 | - '', |
|
224 | - ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
225 | - ); |
|
226 | - $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | - 'display:none;' ); |
|
228 | - $iframe_embed_html .= esc_html( |
|
229 | - \EEH_HTML::div( |
|
230 | - '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
231 | - '', |
|
232 | - '', |
|
233 | - 'width:100%; height: 500px;' |
|
234 | - ) |
|
235 | - ); |
|
236 | - $iframe_embed_html .= \EEH_HTML::divx(); |
|
237 | - return $iframe_embed_html; |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * enqueue iframe button js |
|
244 | - */ |
|
245 | - public function embedButtonAssets() |
|
246 | - { |
|
247 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
248 | - 'copy and paste the following into any other site\'s content to display this event:', |
|
249 | - 'event_espresso' |
|
250 | - ); |
|
251 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
252 | - 'click anywhere outside of this window to close it.', |
|
253 | - 'event_espresso' |
|
254 | - ); |
|
255 | - wp_register_script( |
|
256 | - 'iframe_embed_button', |
|
257 | - plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | - array( 'ee-dialog' ), |
|
259 | - EVENT_ESPRESSO_VERSION, |
|
260 | - true |
|
261 | - ); |
|
262 | - wp_enqueue_script( 'iframe_embed_button' ); |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * generates embed button sections for admin pages |
|
269 | - * |
|
270 | - * @param array $embed_buttons |
|
271 | - * @return string |
|
272 | - */ |
|
273 | - public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
274 | - { |
|
275 | - $embed_buttons = (array)apply_filters( |
|
276 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
277 | - $embed_buttons |
|
278 | - ); |
|
279 | - // add button for iframe code to event editor. |
|
280 | - $html = \EEH_HTML::br( 2 ); |
|
281 | - $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
282 | - $html .= \EEH_HTML::p( |
|
283 | - esc_html__( |
|
284 | - 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
285 | - 'event_espresso' |
|
286 | - ) |
|
287 | - ); |
|
288 | - $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
289 | - $html .= \EEH_HTML::br( 2 ); |
|
290 | - return $html; |
|
291 | - } |
|
19 | + /** |
|
20 | + * @var string $iframe_name |
|
21 | + */ |
|
22 | + private $iframe_name; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var string $route_name |
|
26 | + */ |
|
27 | + private $route_name; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $slug |
|
31 | + */ |
|
32 | + private $slug; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var boolean $append_filterable_content |
|
36 | + */ |
|
37 | + private $append_filterable_content; |
|
38 | + |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * IframeEmbedButton constructor. |
|
43 | + * |
|
44 | + * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
45 | + * @param string $route_name the name of the registered route |
|
46 | + * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
47 | + * will most likely be "event" since that's the only usage atm |
|
48 | + */ |
|
49 | + public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
50 | + { |
|
51 | + $this->iframe_name = $iframe_name; |
|
52 | + $this->route_name = $route_name; |
|
53 | + $this->slug = $slug; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Adds an iframe embed code button to the Event editor. |
|
60 | + */ |
|
61 | + public function addEventEditorIframeEmbedButtonFilter() |
|
62 | + { |
|
63 | + // add button for iframe code to event editor. |
|
64 | + add_filter( |
|
65 | + 'get_sample_permalink_html', |
|
66 | + array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
67 | + 10, |
|
68 | + 2 |
|
69 | + ); |
|
70 | + add_action( |
|
71 | + 'admin_enqueue_scripts', |
|
72 | + array( $this, 'embedButtonAssets' ), |
|
73 | + 10 |
|
74 | + ); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @param $permalink_string |
|
81 | + * @param $id |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
85 | + { |
|
86 | + return $this->eventEditorIframeEmbedButton( |
|
87 | + $permalink_string, |
|
88 | + $id |
|
89 | + ); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * iframe embed code button to the Event editor. |
|
96 | + * |
|
97 | + * @param string $permalink_string |
|
98 | + * @param int $id |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public function eventEditorIframeEmbedButton( |
|
102 | + $permalink_string, |
|
103 | + $id |
|
104 | + ) { |
|
105 | + //make sure this is ONLY when editing and the event id has been set. |
|
106 | + if ( ! empty( $id ) ) { |
|
107 | + $post = get_post( $id ); |
|
108 | + //if NOT event then let's get out. |
|
109 | + if ( $post->post_type !== 'espresso_events' ) { |
|
110 | + return $permalink_string; |
|
111 | + } |
|
112 | + $permalink_string .= $this->embedButtonHtml( |
|
113 | + array( $this->slug => $id ), |
|
114 | + 'button-small' |
|
115 | + ); |
|
116 | + } |
|
117 | + return $permalink_string; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
124 | + * |
|
125 | + * @param string $action name of the WP do_action() to hook into |
|
126 | + */ |
|
127 | + public function addActionIframeEmbedButton( $action ) |
|
128 | + { |
|
129 | + // add button for iframe code to event editor. |
|
130 | + add_action( |
|
131 | + $action, |
|
132 | + array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
133 | + 10, 2 |
|
134 | + ); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @return void |
|
141 | + */ |
|
142 | + public function addActionIframeEmbedButtonCallback() |
|
143 | + { |
|
144 | + echo $this->embedButtonHtml(); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
151 | + * |
|
152 | + * @param string $filter name of the WP apply_filters() to hook into |
|
153 | + * @param bool $append if true, will add iframe embed button to end of content, |
|
154 | + * else if false, will add to the beginning of the content |
|
155 | + */ |
|
156 | + public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
157 | + { |
|
158 | + $this->append_filterable_content = $append; |
|
159 | + // add button for iframe code to event editor. |
|
160 | + add_filter( |
|
161 | + $filter, |
|
162 | + array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
163 | + 10 |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @param array|string $filterable_content |
|
171 | + * @return array|string |
|
172 | + */ |
|
173 | + public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
174 | + { |
|
175 | + $embedButtonHtml = $this->embedButtonHtml(); |
|
176 | + if ( is_array( $filterable_content ) ) { |
|
177 | + $filterable_content = $this->append_filterable_content |
|
178 | + ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | + : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
180 | + } else { |
|
181 | + $filterable_content = $this->append_filterable_content |
|
182 | + ? $filterable_content . $embedButtonHtml |
|
183 | + : $embedButtonHtml . $filterable_content; |
|
184 | + } |
|
185 | + return $filterable_content; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * iframe_embed_html |
|
192 | + * |
|
193 | + * @param array $query_args |
|
194 | + * @param string $button_class |
|
195 | + * @return string |
|
196 | + */ |
|
197 | + public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
198 | + { |
|
199 | + // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
200 | + $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | + $query_args = (array)apply_filters( |
|
202 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
203 | + $query_args |
|
204 | + ); |
|
205 | + // add this route to our localized vars |
|
206 | + $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | + ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
208 | + : array(); |
|
209 | + $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | + \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
211 | + $iframe_embed_html = \EEH_HTML::link( |
|
212 | + '#', |
|
213 | + sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
214 | + sprintf( |
|
215 | + esc_html__( |
|
216 | + 'click here to generate code for embedding %1$s iframe into another site.', |
|
217 | + 'event_espresso' |
|
218 | + ), |
|
219 | + \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
220 | + ), |
|
221 | + "{$this->route_name}-iframe-embed-trigger-js", |
|
222 | + 'iframe-embed-trigger-js button ' . $button_class, |
|
223 | + '', |
|
224 | + ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
225 | + ); |
|
226 | + $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | + 'display:none;' ); |
|
228 | + $iframe_embed_html .= esc_html( |
|
229 | + \EEH_HTML::div( |
|
230 | + '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
231 | + '', |
|
232 | + '', |
|
233 | + 'width:100%; height: 500px;' |
|
234 | + ) |
|
235 | + ); |
|
236 | + $iframe_embed_html .= \EEH_HTML::divx(); |
|
237 | + return $iframe_embed_html; |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * enqueue iframe button js |
|
244 | + */ |
|
245 | + public function embedButtonAssets() |
|
246 | + { |
|
247 | + \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
248 | + 'copy and paste the following into any other site\'s content to display this event:', |
|
249 | + 'event_espresso' |
|
250 | + ); |
|
251 | + \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
252 | + 'click anywhere outside of this window to close it.', |
|
253 | + 'event_espresso' |
|
254 | + ); |
|
255 | + wp_register_script( |
|
256 | + 'iframe_embed_button', |
|
257 | + plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | + array( 'ee-dialog' ), |
|
259 | + EVENT_ESPRESSO_VERSION, |
|
260 | + true |
|
261 | + ); |
|
262 | + wp_enqueue_script( 'iframe_embed_button' ); |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * generates embed button sections for admin pages |
|
269 | + * |
|
270 | + * @param array $embed_buttons |
|
271 | + * @return string |
|
272 | + */ |
|
273 | + public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
274 | + { |
|
275 | + $embed_buttons = (array)apply_filters( |
|
276 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
277 | + $embed_buttons |
|
278 | + ); |
|
279 | + // add button for iframe code to event editor. |
|
280 | + $html = \EEH_HTML::br( 2 ); |
|
281 | + $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
282 | + $html .= \EEH_HTML::p( |
|
283 | + esc_html__( |
|
284 | + 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
285 | + 'event_espresso' |
|
286 | + ) |
|
287 | + ); |
|
288 | + $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
289 | + $html .= \EEH_HTML::br( 2 ); |
|
290 | + return $html; |
|
291 | + } |
|
292 | 292 | |
293 | 293 | |
294 | 294 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
3 | 3 | |
4 | -defined( 'ABSPATH' ) || exit; |
|
4 | +defined('ABSPATH') || exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
47 | 47 | * will most likely be "event" since that's the only usage atm |
48 | 48 | */ |
49 | - public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
49 | + public function __construct($iframe_name, $route_name, $slug = 'event') |
|
50 | 50 | { |
51 | 51 | $this->iframe_name = $iframe_name; |
52 | 52 | $this->route_name = $route_name; |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | // add button for iframe code to event editor. |
64 | 64 | add_filter( |
65 | 65 | 'get_sample_permalink_html', |
66 | - array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
66 | + array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'), |
|
67 | 67 | 10, |
68 | 68 | 2 |
69 | 69 | ); |
70 | 70 | add_action( |
71 | 71 | 'admin_enqueue_scripts', |
72 | - array( $this, 'embedButtonAssets' ), |
|
72 | + array($this, 'embedButtonAssets'), |
|
73 | 73 | 10 |
74 | 74 | ); |
75 | 75 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param $id |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
84 | + public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id) |
|
85 | 85 | { |
86 | 86 | return $this->eventEditorIframeEmbedButton( |
87 | 87 | $permalink_string, |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | $id |
104 | 104 | ) { |
105 | 105 | //make sure this is ONLY when editing and the event id has been set. |
106 | - if ( ! empty( $id ) ) { |
|
107 | - $post = get_post( $id ); |
|
106 | + if ( ! empty($id)) { |
|
107 | + $post = get_post($id); |
|
108 | 108 | //if NOT event then let's get out. |
109 | - if ( $post->post_type !== 'espresso_events' ) { |
|
109 | + if ($post->post_type !== 'espresso_events') { |
|
110 | 110 | return $permalink_string; |
111 | 111 | } |
112 | 112 | $permalink_string .= $this->embedButtonHtml( |
113 | - array( $this->slug => $id ), |
|
113 | + array($this->slug => $id), |
|
114 | 114 | 'button-small' |
115 | 115 | ); |
116 | 116 | } |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param string $action name of the WP do_action() to hook into |
126 | 126 | */ |
127 | - public function addActionIframeEmbedButton( $action ) |
|
127 | + public function addActionIframeEmbedButton($action) |
|
128 | 128 | { |
129 | 129 | // add button for iframe code to event editor. |
130 | 130 | add_action( |
131 | 131 | $action, |
132 | - array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
132 | + array($this, 'addActionIframeEmbedButtonCallback'), |
|
133 | 133 | 10, 2 |
134 | 134 | ); |
135 | 135 | } |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | * @param bool $append if true, will add iframe embed button to end of content, |
154 | 154 | * else if false, will add to the beginning of the content |
155 | 155 | */ |
156 | - public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
156 | + public function addFilterIframeEmbedButton($filter, $append = true) |
|
157 | 157 | { |
158 | 158 | $this->append_filterable_content = $append; |
159 | 159 | // add button for iframe code to event editor. |
160 | 160 | add_filter( |
161 | 161 | $filter, |
162 | - array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
162 | + array($this, 'addFilterIframeEmbedButtonCallback'), |
|
163 | 163 | 10 |
164 | 164 | ); |
165 | 165 | } |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | * @param array|string $filterable_content |
171 | 171 | * @return array|string |
172 | 172 | */ |
173 | - public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
173 | + public function addFilterIframeEmbedButtonCallback($filterable_content) |
|
174 | 174 | { |
175 | 175 | $embedButtonHtml = $this->embedButtonHtml(); |
176 | - if ( is_array( $filterable_content ) ) { |
|
176 | + if (is_array($filterable_content)) { |
|
177 | 177 | $filterable_content = $this->append_filterable_content |
178 | - ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | - : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
178 | + ? $filterable_content + array($this->route_name => $embedButtonHtml) |
|
179 | + : array($this->route_name => $embedButtonHtml) + $filterable_content; |
|
180 | 180 | } else { |
181 | 181 | $filterable_content = $this->append_filterable_content |
182 | - ? $filterable_content . $embedButtonHtml |
|
183 | - : $embedButtonHtml . $filterable_content; |
|
182 | + ? $filterable_content.$embedButtonHtml |
|
183 | + : $embedButtonHtml.$filterable_content; |
|
184 | 184 | } |
185 | 185 | return $filterable_content; |
186 | 186 | } |
@@ -194,40 +194,40 @@ discard block |
||
194 | 194 | * @param string $button_class |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
197 | + public function embedButtonHtml($query_args = array(), $button_class = '') |
|
198 | 198 | { |
199 | 199 | // incoming args will replace the defaults listed here in the second array (union preserves first array) |
200 | - $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | - $query_args = (array)apply_filters( |
|
200 | + $query_args = (array) $query_args + array($this->route_name => 'iframe'); |
|
201 | + $query_args = (array) apply_filters( |
|
202 | 202 | 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
203 | 203 | $query_args |
204 | 204 | ); |
205 | 205 | // add this route to our localized vars |
206 | - $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | - ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
206 | + $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes']) |
|
207 | + ? \EE_Registry::$i18n_js_strings['iframe_module_routes'] |
|
208 | 208 | : array(); |
209 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | - \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
209 | + $iframe_module_routes[$this->route_name] = $this->route_name; |
|
210 | + \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes; |
|
211 | 211 | $iframe_embed_html = \EEH_HTML::link( |
212 | 212 | '#', |
213 | - sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
213 | + sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name), |
|
214 | 214 | sprintf( |
215 | 215 | esc_html__( |
216 | 216 | 'click here to generate code for embedding %1$s iframe into another site.', |
217 | 217 | 'event_espresso' |
218 | 218 | ), |
219 | - \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
219 | + \EEH_Inflector::add_indefinite_article($this->iframe_name) |
|
220 | 220 | ), |
221 | 221 | "{$this->route_name}-iframe-embed-trigger-js", |
222 | - 'iframe-embed-trigger-js button ' . $button_class, |
|
222 | + 'iframe-embed-trigger-js button '.$button_class, |
|
223 | 223 | '', |
224 | - ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
224 | + ' data-iframe_embed_button="#'.$this->route_name.'-iframe-js" tabindex="-1"' |
|
225 | 225 | ); |
226 | - $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | - 'display:none;' ); |
|
226 | + $iframe_embed_html .= \EEH_HTML::div('', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | + 'display:none;'); |
|
228 | 228 | $iframe_embed_html .= esc_html( |
229 | 229 | \EEH_HTML::div( |
230 | - '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
230 | + '<iframe src="'.add_query_arg($query_args, site_url()).'" width="100%" height="100%"></iframe>', |
|
231 | 231 | '', |
232 | 232 | '', |
233 | 233 | 'width:100%; height: 500px;' |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function embedButtonAssets() |
246 | 246 | { |
247 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
247 | + \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__( |
|
248 | 248 | 'copy and paste the following into any other site\'s content to display this event:', |
249 | 249 | 'event_espresso' |
250 | 250 | ); |
251 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
251 | + \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__( |
|
252 | 252 | 'click anywhere outside of this window to close it.', |
253 | 253 | 'event_espresso' |
254 | 254 | ); |
255 | 255 | wp_register_script( |
256 | 256 | 'iframe_embed_button', |
257 | - plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | - array( 'ee-dialog' ), |
|
257 | + plugin_dir_url(__FILE__).'iframe-embed-button.js', |
|
258 | + array('ee-dialog'), |
|
259 | 259 | EVENT_ESPRESSO_VERSION, |
260 | 260 | true |
261 | 261 | ); |
262 | - wp_enqueue_script( 'iframe_embed_button' ); |
|
262 | + wp_enqueue_script('iframe_embed_button'); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
@@ -270,23 +270,23 @@ discard block |
||
270 | 270 | * @param array $embed_buttons |
271 | 271 | * @return string |
272 | 272 | */ |
273 | - public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
273 | + public function addIframeEmbedButtonsSection(array $embed_buttons) |
|
274 | 274 | { |
275 | - $embed_buttons = (array)apply_filters( |
|
275 | + $embed_buttons = (array) apply_filters( |
|
276 | 276 | 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
277 | 277 | $embed_buttons |
278 | 278 | ); |
279 | 279 | // add button for iframe code to event editor. |
280 | - $html = \EEH_HTML::br( 2 ); |
|
281 | - $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
280 | + $html = \EEH_HTML::br(2); |
|
281 | + $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso')); |
|
282 | 282 | $html .= \EEH_HTML::p( |
283 | 283 | esc_html__( |
284 | 284 | 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
285 | 285 | 'event_espresso' |
286 | 286 | ) |
287 | 287 | ); |
288 | - $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
289 | - $html .= \EEH_HTML::br( 2 ); |
|
288 | + $html .= ' '.implode(' ', $embed_buttons).' '; |
|
289 | + $html .= \EEH_HTML::br(2); |
|
290 | 290 | return $html; |
291 | 291 | } |
292 | 292 |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | use EventEspresso\modules\ticket_selector\TicketSelectorIframe; |
4 | 4 | use EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | * @return EED_Ticket_Selector |
39 | 39 | */ |
40 | 40 | public static function instance() { |
41 | - return parent::get_instance( __CLASS__ ); |
|
41 | + return parent::get_instance(__CLASS__); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - protected function set_config(){ |
|
47 | - $this->set_config_section( 'template_settings' ); |
|
48 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
49 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
46 | + protected function set_config() { |
|
47 | + $this->set_config_section('template_settings'); |
|
48 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
49 | + $this->set_config_name('EED_Ticket_Selector'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public static function set_hooks() { |
61 | 61 | // routing |
62 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
63 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
64 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
65 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
66 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
62 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
63 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
64 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
65 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
66 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | // to load assets for "espresso_events" page on the "edit" route (action) |
80 | 80 | add_action( |
81 | 81 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit', |
82 | - array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ), |
|
82 | + array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'), |
|
83 | 83 | 10 |
84 | 84 | ); |
85 | 85 | } |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | * @return void |
94 | 94 | */ |
95 | 95 | public static function set_definitions() { |
96 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
97 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
96 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
97 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
98 | 98 | |
99 | 99 | //if config is not set, initialize |
100 | 100 | //If config is not set, set it. |
101 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) { |
|
101 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) { |
|
102 | 102 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
103 | 103 | } |
104 | 104 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param WP $WP |
125 | 125 | * @return void |
126 | 126 | */ |
127 | - public function run( $WP ) {} |
|
127 | + public function run($WP) {} |
|
128 | 128 | |
129 | 129 | |
130 | 130 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @return \EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton |
133 | 133 | */ |
134 | 134 | public static function getIframeEmbedButton() { |
135 | - if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton ) { |
|
135 | + if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) { |
|
136 | 136 | self::$iframe_embed_button = new TicketSelectorIframeEmbedButton(); |
137 | 137 | } |
138 | 138 | return self::$iframe_embed_button; |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @return string |
176 | 176 | * @throws \EE_Error |
177 | 177 | */ |
178 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
179 | - return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details ); |
|
178 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
179 | + return EED_Ticket_Selector::ticketSelector()->display($event, $view_details); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | * @return void |
204 | 204 | */ |
205 | 205 | public static function load_tckt_slctr_assets() { |
206 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
206 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
207 | 207 | // add some style |
208 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
208 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
209 | 209 | wp_enqueue_style('ticket_selector'); |
210 | 210 | // make it dance |
211 | 211 | // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | { |
336 | 336 | // todo add doing_it_wrong() notice during next major version |
337 | 337 | if ( |
338 | - \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
339 | - && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
338 | + \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
339 | + && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
340 | 340 | ) { |
341 | 341 | $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
342 | 342 | $iframe_embed_button::embedButtonAssets(); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @access public |
189 | 189 | * @access public |
190 | - * @return array or FALSE |
|
190 | + * @return boolean|null or FALSE |
|
191 | 191 | * @throws \EE_Error |
192 | 192 | */ |
193 | 193 | public function process_ticket_selections() { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * cancel_ticket_selections |
202 | 202 | * |
203 | 203 | * @access public |
204 | - * @return string |
|
204 | + * @return false|null |
|
205 | 205 | */ |
206 | 206 | public static function cancel_ticket_selections() |
207 | 207 | { |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class EED_Ticket_Selector extends EED_Module { |
24 | 24 | |
25 | - /** |
|
26 | - * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector |
|
27 | - */ |
|
28 | - private static $ticket_selector; |
|
25 | + /** |
|
26 | + * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector |
|
27 | + */ |
|
28 | + private static $ticket_selector; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button |
|
32 | - */ |
|
33 | - private static $iframe_embed_button; |
|
30 | + /** |
|
31 | + * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button |
|
32 | + */ |
|
33 | + private static $iframe_embed_button; |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ), |
83 | 83 | 10 |
84 | 84 | ); |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | 88 | |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | |
107 | 107 | |
108 | 108 | /** |
109 | - * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector |
|
110 | - */ |
|
111 | - public static function ticketSelector() |
|
112 | - { |
|
113 | - if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
114 | - EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(); |
|
115 | - } |
|
116 | - return EED_Ticket_Selector::$ticket_selector; |
|
117 | - } |
|
109 | + * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector |
|
110 | + */ |
|
111 | + public static function ticketSelector() |
|
112 | + { |
|
113 | + if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
114 | + EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(); |
|
115 | + } |
|
116 | + return EED_Ticket_Selector::$ticket_selector; |
|
117 | + } |
|
118 | 118 | |
119 | 119 | |
120 | 120 | /** |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | |
154 | 154 | |
155 | 155 | |
156 | - /** |
|
157 | - * ticket_selector_iframe |
|
158 | - * |
|
159 | - * @return void |
|
160 | - * @throws \DomainException |
|
161 | - * @throws \EE_Error |
|
162 | - */ |
|
156 | + /** |
|
157 | + * ticket_selector_iframe |
|
158 | + * |
|
159 | + * @return void |
|
160 | + * @throws \DomainException |
|
161 | + * @throws \EE_Error |
|
162 | + */ |
|
163 | 163 | public function ticket_selector_iframe() { |
164 | 164 | $ticket_selector_iframe = new TicketSelectorIframe(); |
165 | 165 | $ticket_selector_iframe->display(); |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | |
168 | 168 | |
169 | 169 | |
170 | - /** |
|
171 | - * creates buttons for selecting number of attendees for an event |
|
172 | - * |
|
173 | - * @access public |
|
174 | - * @param WP_Post|int $event |
|
175 | - * @param bool $view_details |
|
176 | - * @return string |
|
177 | - * @throws \EE_Error |
|
178 | - */ |
|
170 | + /** |
|
171 | + * creates buttons for selecting number of attendees for an event |
|
172 | + * |
|
173 | + * @access public |
|
174 | + * @param WP_Post|int $event |
|
175 | + * @param bool $view_details |
|
176 | + * @return string |
|
177 | + * @throws \EE_Error |
|
178 | + */ |
|
179 | 179 | public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
180 | 180 | return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details ); |
181 | 181 | } |
@@ -197,26 +197,26 @@ discard block |
||
197 | 197 | |
198 | 198 | |
199 | 199 | |
200 | - /** |
|
201 | - * cancel_ticket_selections |
|
202 | - * |
|
203 | - * @access public |
|
204 | - * @return string |
|
205 | - */ |
|
206 | - public static function cancel_ticket_selections() |
|
207 | - { |
|
208 | - $form = new ProcessTicketSelector(); |
|
209 | - return $form->cancelTicketSelections(); |
|
210 | - } |
|
200 | + /** |
|
201 | + * cancel_ticket_selections |
|
202 | + * |
|
203 | + * @access public |
|
204 | + * @return string |
|
205 | + */ |
|
206 | + public static function cancel_ticket_selections() |
|
207 | + { |
|
208 | + $form = new ProcessTicketSelector(); |
|
209 | + return $form->cancelTicketSelections(); |
|
210 | + } |
|
211 | 211 | |
212 | 212 | |
213 | 213 | |
214 | 214 | /** |
215 | - * load js |
|
216 | - * |
|
217 | - * @access public |
|
218 | - * @return void |
|
219 | - */ |
|
215 | + * load js |
|
216 | + * |
|
217 | + * @access public |
|
218 | + * @return void |
|
219 | + */ |
|
220 | 220 | public static function load_tckt_slctr_assets() { |
221 | 221 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
222 | 222 | // add some style |
@@ -234,129 +234,129 @@ discard block |
||
234 | 234 | |
235 | 235 | |
236 | 236 | |
237 | - /** |
|
238 | - * @deprecated |
|
239 | - * @return string |
|
240 | - * @throws \EE_Error |
|
241 | - */ |
|
242 | - public static function display_view_details_btn() |
|
243 | - { |
|
244 | - // todo add doing_it_wrong() notice during next major version |
|
245 | - return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * @deprecated |
|
252 | - * @return string |
|
253 | - * @throws \EE_Error |
|
254 | - */ |
|
255 | - public static function display_ticket_selector_submit() |
|
256 | - { |
|
257 | - // todo add doing_it_wrong() notice during next major version |
|
258 | - return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * @deprecated |
|
265 | - * @param string $permalink_string |
|
266 | - * @param int $id |
|
267 | - * @param string $new_title |
|
268 | - * @param string $new_slug |
|
269 | - * @return string |
|
270 | - */ |
|
271 | - public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
272 | - { |
|
273 | - // todo add doing_it_wrong() notice during next major version |
|
274 | - if ( |
|
275 | - \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
276 | - && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
277 | - ) { |
|
278 | - $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
279 | - $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
280 | - } |
|
281 | - return ''; |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * @deprecated |
|
288 | - * @param int $ID |
|
289 | - * @param string $external_url |
|
290 | - * @return string |
|
291 | - */ |
|
292 | - public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
293 | - { |
|
294 | - // todo add doing_it_wrong() notice during next major version |
|
295 | - return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * @deprecated |
|
302 | - * @return string |
|
303 | - */ |
|
304 | - public static function ticket_selector_form_close() |
|
305 | - { |
|
306 | - // todo add doing_it_wrong() notice during next major version |
|
307 | - return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * @deprecated |
|
314 | - * @return string |
|
315 | - */ |
|
316 | - public static function no_tkt_slctr_end_dv() |
|
317 | - { |
|
318 | - // todo add doing_it_wrong() notice during next major version |
|
319 | - return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * @deprecated 4.9.13 |
|
326 | - * @return string |
|
327 | - */ |
|
328 | - public static function tkt_slctr_end_dv() |
|
329 | - { |
|
330 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
331 | - } |
|
332 | - |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * @deprecated |
|
337 | - * @return string |
|
338 | - */ |
|
339 | - public static function clear_tkt_slctr() |
|
340 | - { |
|
341 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
342 | - } |
|
343 | - |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * @deprecated |
|
348 | - */ |
|
349 | - public static function load_tckt_slctr_assets_admin() |
|
350 | - { |
|
351 | - // todo add doing_it_wrong() notice during next major version |
|
352 | - if ( |
|
353 | - \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
354 | - && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
355 | - ) { |
|
356 | - $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
357 | - $iframe_embed_button->embedButtonAssets(); |
|
358 | - } |
|
359 | - } |
|
237 | + /** |
|
238 | + * @deprecated |
|
239 | + * @return string |
|
240 | + * @throws \EE_Error |
|
241 | + */ |
|
242 | + public static function display_view_details_btn() |
|
243 | + { |
|
244 | + // todo add doing_it_wrong() notice during next major version |
|
245 | + return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * @deprecated |
|
252 | + * @return string |
|
253 | + * @throws \EE_Error |
|
254 | + */ |
|
255 | + public static function display_ticket_selector_submit() |
|
256 | + { |
|
257 | + // todo add doing_it_wrong() notice during next major version |
|
258 | + return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * @deprecated |
|
265 | + * @param string $permalink_string |
|
266 | + * @param int $id |
|
267 | + * @param string $new_title |
|
268 | + * @param string $new_slug |
|
269 | + * @return string |
|
270 | + */ |
|
271 | + public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
272 | + { |
|
273 | + // todo add doing_it_wrong() notice during next major version |
|
274 | + if ( |
|
275 | + \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
276 | + && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
277 | + ) { |
|
278 | + $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
279 | + $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
280 | + } |
|
281 | + return ''; |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * @deprecated |
|
288 | + * @param int $ID |
|
289 | + * @param string $external_url |
|
290 | + * @return string |
|
291 | + */ |
|
292 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
293 | + { |
|
294 | + // todo add doing_it_wrong() notice during next major version |
|
295 | + return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * @deprecated |
|
302 | + * @return string |
|
303 | + */ |
|
304 | + public static function ticket_selector_form_close() |
|
305 | + { |
|
306 | + // todo add doing_it_wrong() notice during next major version |
|
307 | + return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * @deprecated |
|
314 | + * @return string |
|
315 | + */ |
|
316 | + public static function no_tkt_slctr_end_dv() |
|
317 | + { |
|
318 | + // todo add doing_it_wrong() notice during next major version |
|
319 | + return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * @deprecated 4.9.13 |
|
326 | + * @return string |
|
327 | + */ |
|
328 | + public static function tkt_slctr_end_dv() |
|
329 | + { |
|
330 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
331 | + } |
|
332 | + |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * @deprecated |
|
337 | + * @return string |
|
338 | + */ |
|
339 | + public static function clear_tkt_slctr() |
|
340 | + { |
|
341 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
342 | + } |
|
343 | + |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * @deprecated |
|
348 | + */ |
|
349 | + public static function load_tckt_slctr_assets_admin() |
|
350 | + { |
|
351 | + // todo add doing_it_wrong() notice during next major version |
|
352 | + if ( |
|
353 | + \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
354 | + && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
355 | + ) { |
|
356 | + $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
357 | + $iframe_embed_button->embedButtonAssets(); |
|
358 | + } |
|
359 | + } |
|
360 | 360 | |
361 | 361 | |
362 | 362 | } |
@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | class EventListIframeEmbedButton extends IframeEmbedButton |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * EventListIframeEmbedButton constructor. |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - parent::__construct( |
|
24 | - esc_html__( 'Event List', 'event_espresso' ), |
|
25 | - 'event_list' |
|
26 | - ); |
|
27 | - } |
|
18 | + /** |
|
19 | + * EventListIframeEmbedButton constructor. |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct( |
|
24 | + esc_html__( 'Event List', 'event_espresso' ), |
|
25 | + 'event_list' |
|
26 | + ); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | * @param array $after_list_table |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
53 | - { |
|
54 | - return \EEH_Array::insert_into_array( |
|
55 | - $after_list_table, |
|
56 | - array( |
|
57 | - 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
58 | - array( 'event_list' => $this->embedButtonHtml() ) |
|
59 | - ) |
|
60 | - ), |
|
61 | - 'legend' |
|
62 | - ); |
|
63 | - } |
|
52 | + public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
53 | + { |
|
54 | + return \EEH_Array::insert_into_array( |
|
55 | + $after_list_table, |
|
56 | + array( |
|
57 | + 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
58 | + array( 'event_list' => $this->embedButtonHtml() ) |
|
59 | + ) |
|
60 | + ), |
|
61 | + 'legend' |
|
62 | + ); |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
3 | 3 | |
4 | -defined( 'ABSPATH' ) || exit; |
|
4 | +defined('ABSPATH') || exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function __construct() |
22 | 22 | { |
23 | 23 | parent::__construct( |
24 | - esc_html__( 'Event List', 'event_espresso' ), |
|
24 | + esc_html__('Event List', 'event_espresso'), |
|
25 | 25 | 'event_list' |
26 | 26 | ); |
27 | 27 | } |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | public function addEmbedButton() { |
32 | 32 | add_filter( |
33 | 33 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg', |
34 | - array( $this, 'addEventListIframeEmbedButtonSection' ) |
|
34 | + array($this, 'addEventListIframeEmbedButtonSection') |
|
35 | 35 | ); |
36 | 36 | add_action( |
37 | 37 | 'admin_enqueue_scripts', |
38 | - array( $this, 'embedButtonAssets' ), |
|
38 | + array($this, 'embedButtonAssets'), |
|
39 | 39 | 10 |
40 | 40 | ); |
41 | 41 | } |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @param array $after_list_table |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
52 | + public function addEventListIframeEmbedButtonSection(array $after_list_table) |
|
53 | 53 | { |
54 | 54 | return \EEH_Array::insert_into_array( |
55 | 55 | $after_list_table, |
56 | 56 | array( |
57 | 57 | 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
58 | - array( 'event_list' => $this->embedButtonHtml() ) |
|
58 | + array('event_list' => $this->embedButtonHtml()) |
|
59 | 59 | ) |
60 | 60 | ), |
61 | 61 | 'legend' |
@@ -531,11 +531,11 @@ discard block |
||
531 | 531 | { |
532 | 532 | wp_register_style( |
533 | 533 | 'events-admin-css', |
534 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
534 | + EVENTS_ASSETS_URL.'events-admin-page.css', |
|
535 | 535 | array(), |
536 | 536 | EVENT_ESPRESSO_VERSION |
537 | 537 | ); |
538 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
538 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
539 | 539 | wp_enqueue_style('events-admin-css'); |
540 | 540 | wp_enqueue_style('ee-cat-admin'); |
541 | 541 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | //scripts |
544 | 544 | wp_register_script( |
545 | 545 | 'event_editor_js', |
546 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
546 | + EVENTS_ASSETS_URL.'event_editor.js', |
|
547 | 547 | array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
548 | 548 | EVENT_ESPRESSO_VERSION, |
549 | 549 | true |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | wp_enqueue_style('espresso-ui-theme'); |
576 | 576 | wp_register_style( |
577 | 577 | 'event-editor-css', |
578 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
578 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
579 | 579 | array('ee-admin-css'), |
580 | 580 | EVENT_ESPRESSO_VERSION |
581 | 581 | ); |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | //scripts |
584 | 584 | wp_register_script( |
585 | 585 | 'event-datetime-metabox', |
586 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
586 | + EVENTS_ASSETS_URL.'event-datetime-metabox.js', |
|
587 | 587 | array('event_editor_js', 'ee-datepicker'), |
588 | 588 | EVENT_ESPRESSO_VERSION |
589 | 589 | ); |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
749 | 749 | or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.' |
750 | 750 | ), |
751 | - '<a href="' . admin_url('options-general.php') . '">', |
|
751 | + '<a href="'.admin_url('options-general.php').'">', |
|
752 | 752 | '</a>' |
753 | 753 | ), |
754 | 754 | __FILE__, |
@@ -818,31 +818,31 @@ discard block |
||
818 | 818 | $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
819 | 819 | $statuses = array( |
820 | 820 | 'sold_out_status' => array( |
821 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
821 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
822 | 822 | 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
823 | 823 | ), |
824 | 824 | 'active_status' => array( |
825 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
825 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
826 | 826 | 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
827 | 827 | ), |
828 | 828 | 'upcoming_status' => array( |
829 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
829 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
830 | 830 | 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
831 | 831 | ), |
832 | 832 | 'postponed_status' => array( |
833 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
833 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
834 | 834 | 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
835 | 835 | ), |
836 | 836 | 'cancelled_status' => array( |
837 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
837 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
838 | 838 | 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
839 | 839 | ), |
840 | 840 | 'expired_status' => array( |
841 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
841 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
842 | 842 | 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
843 | 843 | ), |
844 | 844 | 'inactive_status' => array( |
845 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
845 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
846 | 846 | 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
847 | 847 | ), |
848 | 848 | ); |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | { |
907 | 907 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
908 | 908 | $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
909 | - ? (array)$this->_template_args['after_list_table'] |
|
909 | + ? (array) $this->_template_args['after_list_table'] |
|
910 | 910 | : array(); |
911 | 911 | $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
912 | 912 | . EEH_Template::get_button_or_link( |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | 'button' |
916 | 916 | ); |
917 | 917 | $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
918 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
918 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
919 | 919 | 'create_new', |
920 | 920 | 'add', |
921 | 921 | array(), |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | */ |
1046 | 1046 | protected function _default_venue_update(\EE_Event $evtobj, $data) |
1047 | 1047 | { |
1048 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1048 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
1049 | 1049 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
1050 | 1050 | $rows_affected = null; |
1051 | 1051 | $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | if (empty($tkt['TKT_start_date'])) { |
1170 | 1170 | //let's use now in the set timezone. |
1171 | 1171 | $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
1172 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1172 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1173 | 1173 | } |
1174 | 1174 | if (empty($tkt['TKT_end_date'])) { |
1175 | 1175 | //use the start date of the first datetime |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
1459 | 1459 | // load template |
1460 | 1460 | EEH_Template::display_template( |
1461 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1461 | + EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', |
|
1462 | 1462 | $publish_box_extra_args |
1463 | 1463 | ); |
1464 | 1464 | } |
@@ -1585,7 +1585,7 @@ discard block |
||
1585 | 1585 | ); |
1586 | 1586 | $template = apply_filters( |
1587 | 1587 | 'FHEE__Events_Admin_Page__ticket_metabox__template', |
1588 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1588 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php' |
|
1589 | 1589 | ); |
1590 | 1590 | EEH_Template::display_template($template, $template_args); |
1591 | 1591 | } |
@@ -1604,7 +1604,7 @@ discard block |
||
1604 | 1604 | private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
1605 | 1605 | { |
1606 | 1606 | $template_args = array( |
1607 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1607 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1608 | 1608 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
1609 | 1609 | : '', |
1610 | 1610 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
@@ -1658,7 +1658,7 @@ discard block |
||
1658 | 1658 | $template_args = array_merge($template_args, $price_args); |
1659 | 1659 | $template = apply_filters( |
1660 | 1660 | 'FHEE__Events_Admin_Page__get_ticket_row__template', |
1661 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1661 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', |
|
1662 | 1662 | $ticket |
1663 | 1663 | ); |
1664 | 1664 | return EEH_Template::display_template($template, $template_args, true); |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | $default_reg_status_values |
1711 | 1711 | ); |
1712 | 1712 | EEH_Template::display_template( |
1713 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1713 | + EVENTS_TEMPLATE_PATH.'event_registration_options.template.php', |
|
1714 | 1714 | $template_args |
1715 | 1715 | ); |
1716 | 1716 | } |
@@ -1733,7 +1733,7 @@ discard block |
||
1733 | 1733 | { |
1734 | 1734 | $EEME = $this->_event_model(); |
1735 | 1735 | $offset = ($current_page - 1) * $per_page; |
1736 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1736 | + $limit = $count ? null : $offset.','.$per_page; |
|
1737 | 1737 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1738 | 1738 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1739 | 1739 | if (isset($this->_req_data['month_range'])) { |
@@ -1767,7 +1767,7 @@ discard block |
||
1767 | 1767 | $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
1768 | 1768 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1769 | 1769 | $DateTime = new DateTime( |
1770 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1770 | + $year_r.'-'.$month_r.'-01 00:00:00', |
|
1771 | 1771 | new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
1772 | 1772 | ); |
1773 | 1773 | $start = $DateTime->format(implode(' ', $start_formats)); |
@@ -1813,7 +1813,7 @@ discard block |
||
1813 | 1813 | } |
1814 | 1814 | //search query handling |
1815 | 1815 | if (isset($this->_req_data['s'])) { |
1816 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1816 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1817 | 1817 | $where['OR'] = array( |
1818 | 1818 | 'EVT_name' => array('LIKE', $search_string), |
1819 | 1819 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1947,7 +1947,7 @@ discard block |
||
1947 | 1947 | if ( ! empty($event_status)) { |
1948 | 1948 | $success = true; |
1949 | 1949 | //determine the event id and set to array. |
1950 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1950 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
1951 | 1951 | // loop thru events |
1952 | 1952 | foreach ($EVT_IDs as $EVT_ID) { |
1953 | 1953 | if ($EVT_ID = absint($EVT_ID)) { |
@@ -2095,7 +2095,7 @@ discard block |
||
2095 | 2095 | // get list of events with no prices |
2096 | 2096 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
2097 | 2097 | //determine the event id and set to array. |
2098 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2098 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
2099 | 2099 | // loop thru events |
2100 | 2100 | foreach ($EVT_IDs as $EVT_ID) { |
2101 | 2101 | $EVT_ID = absint($EVT_ID); |
@@ -2278,7 +2278,7 @@ discard block |
||
2278 | 2278 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2279 | 2279 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
2280 | 2280 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
2281 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2281 | + EVENTS_TEMPLATE_PATH.'event_settings.template.php', |
|
2282 | 2282 | $this->_template_args, |
2283 | 2283 | true |
2284 | 2284 | ); |
@@ -2323,10 +2323,10 @@ discard block |
||
2323 | 2323 | . 'caffeinated_template_features.jpg" alt="' |
2324 | 2324 | . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
2325 | 2325 | . '" />'; |
2326 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2326 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__( |
|
2327 | 2327 | 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
2328 | 2328 | 'event_espresso' |
2329 | - ) . '</strong>'; |
|
2329 | + ).'</strong>'; |
|
2330 | 2330 | $this->display_admin_caf_preview_page('template_settings_tab'); |
2331 | 2331 | } |
2332 | 2332 | |
@@ -2375,7 +2375,7 @@ discard block |
||
2375 | 2375 | { |
2376 | 2376 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
2377 | 2377 | $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
2378 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2378 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
2379 | 2379 | 'add_category', |
2380 | 2380 | 'add_category', |
2381 | 2381 | array(), |
@@ -2451,7 +2451,7 @@ discard block |
||
2451 | 2451 | 'disable' => '', |
2452 | 2452 | 'disabled_message' => false, |
2453 | 2453 | ); |
2454 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2454 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2455 | 2455 | return EEH_Template::display_template($template, $template_args, true); |
2456 | 2456 | } |
2457 | 2457 | |
@@ -2459,8 +2459,8 @@ discard block |
||
2459 | 2459 | |
2460 | 2460 | protected function _delete_categories() |
2461 | 2461 | { |
2462 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2463 | - : (array)$this->_req_data['category_id']; |
|
2462 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
2463 | + : (array) $this->_req_data['category_id']; |
|
2464 | 2464 | foreach ($cat_ids as $cat_id) { |
2465 | 2465 | $this->_delete_category($cat_id); |
2466 | 2466 | } |
@@ -2561,7 +2561,7 @@ discard block |
||
2561 | 2561 | $limit = ($current_page - 1) * $per_page; |
2562 | 2562 | $where = array('taxonomy' => 'espresso_event_categories'); |
2563 | 2563 | if (isset($this->_req_data['s'])) { |
2564 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2564 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2565 | 2565 | $where['OR'] = array( |
2566 | 2566 | 'Term.name' => array('LIKE', $sstr), |
2567 | 2567 | 'description' => array('LIKE', $sstr), |
@@ -2570,7 +2570,7 @@ discard block |
||
2570 | 2570 | $query_params = array( |
2571 | 2571 | $where, |
2572 | 2572 | 'order_by' => array($orderby => $order), |
2573 | - 'limit' => $limit . ',' . $per_page, |
|
2573 | + 'limit' => $limit.','.$per_page, |
|
2574 | 2574 | 'force_join' => array('Term'), |
2575 | 2575 | ); |
2576 | 2576 | $categories = $count |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -17,2570 +17,2570 @@ discard block |
||
17 | 17 | class Events_Admin_Page extends EE_Admin_Page_CPT |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * This will hold the event object for event_details screen. |
|
22 | - * |
|
23 | - * @access protected |
|
24 | - * @var EE_Event $_event |
|
25 | - */ |
|
26 | - protected $_event; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * This will hold the category object for category_details screen. |
|
31 | - * |
|
32 | - * @var stdClass $_category |
|
33 | - */ |
|
34 | - protected $_category; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * This will hold the event model instance |
|
39 | - * |
|
40 | - * @var EEM_Event $_event_model |
|
41 | - */ |
|
42 | - protected $_event_model; |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @var EE_Event |
|
48 | - */ |
|
49 | - protected $_cpt_model_obj = false; |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - protected function _init_page_props() |
|
54 | - { |
|
55 | - $this->page_slug = EVENTS_PG_SLUG; |
|
56 | - $this->page_label = EVENTS_LABEL; |
|
57 | - $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
58 | - $this->_admin_base_path = EVENTS_ADMIN; |
|
59 | - $this->_cpt_model_names = array( |
|
60 | - 'create_new' => 'EEM_Event', |
|
61 | - 'edit' => 'EEM_Event', |
|
62 | - ); |
|
63 | - $this->_cpt_edit_routes = array( |
|
64 | - 'espresso_events' => 'edit', |
|
65 | - ); |
|
66 | - add_action( |
|
67 | - 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
68 | - array($this, 'verify_event_edit') |
|
69 | - ); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - |
|
74 | - protected function _ajax_hooks() |
|
75 | - { |
|
76 | - //todo: all hooks for events ajax goes in here. |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - protected function _define_page_props() |
|
82 | - { |
|
83 | - $this->_admin_page_title = EVENTS_LABEL; |
|
84 | - $this->_labels = array( |
|
85 | - 'buttons' => array( |
|
86 | - 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
87 | - 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
88 | - 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
89 | - 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
90 | - 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
91 | - 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
92 | - ), |
|
93 | - 'editor_title' => array( |
|
94 | - 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
95 | - ), |
|
96 | - 'publishbox' => array( |
|
97 | - 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
98 | - 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
99 | - 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
100 | - 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
101 | - 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
102 | - ), |
|
103 | - ); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - |
|
108 | - protected function _set_page_routes() |
|
109 | - { |
|
110 | - //load formatter helper |
|
111 | - //load field generator helper |
|
112 | - //is there a evt_id in the request? |
|
113 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
114 | - ? $this->_req_data['EVT_ID'] : 0; |
|
115 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
116 | - $this->_page_routes = array( |
|
117 | - 'default' => array( |
|
118 | - 'func' => '_events_overview_list_table', |
|
119 | - 'capability' => 'ee_read_events', |
|
120 | - ), |
|
121 | - 'create_new' => array( |
|
122 | - 'func' => '_create_new_cpt_item', |
|
123 | - 'capability' => 'ee_edit_events', |
|
124 | - ), |
|
125 | - 'edit' => array( |
|
126 | - 'func' => '_edit_cpt_item', |
|
127 | - 'capability' => 'ee_edit_event', |
|
128 | - 'obj_id' => $evt_id, |
|
129 | - ), |
|
130 | - 'copy_event' => array( |
|
131 | - 'func' => '_copy_events', |
|
132 | - 'capability' => 'ee_edit_event', |
|
133 | - 'obj_id' => $evt_id, |
|
134 | - 'noheader' => true, |
|
135 | - ), |
|
136 | - 'trash_event' => array( |
|
137 | - 'func' => '_trash_or_restore_event', |
|
138 | - 'args' => array('event_status' => 'trash'), |
|
139 | - 'capability' => 'ee_delete_event', |
|
140 | - 'obj_id' => $evt_id, |
|
141 | - 'noheader' => true, |
|
142 | - ), |
|
143 | - 'trash_events' => array( |
|
144 | - 'func' => '_trash_or_restore_events', |
|
145 | - 'args' => array('event_status' => 'trash'), |
|
146 | - 'capability' => 'ee_delete_events', |
|
147 | - 'noheader' => true, |
|
148 | - ), |
|
149 | - 'restore_event' => array( |
|
150 | - 'func' => '_trash_or_restore_event', |
|
151 | - 'args' => array('event_status' => 'draft'), |
|
152 | - 'capability' => 'ee_delete_event', |
|
153 | - 'obj_id' => $evt_id, |
|
154 | - 'noheader' => true, |
|
155 | - ), |
|
156 | - 'restore_events' => array( |
|
157 | - 'func' => '_trash_or_restore_events', |
|
158 | - 'args' => array('event_status' => 'draft'), |
|
159 | - 'capability' => 'ee_delete_events', |
|
160 | - 'noheader' => true, |
|
161 | - ), |
|
162 | - 'delete_event' => array( |
|
163 | - 'func' => '_delete_event', |
|
164 | - 'capability' => 'ee_delete_event', |
|
165 | - 'obj_id' => $evt_id, |
|
166 | - 'noheader' => true, |
|
167 | - ), |
|
168 | - 'delete_events' => array( |
|
169 | - 'func' => '_delete_events', |
|
170 | - 'capability' => 'ee_delete_events', |
|
171 | - 'noheader' => true, |
|
172 | - ), |
|
173 | - 'view_report' => array( |
|
174 | - 'func' => '_view_report', |
|
175 | - 'capablity' => 'ee_edit_events', |
|
176 | - ), |
|
177 | - 'default_event_settings' => array( |
|
178 | - 'func' => '_default_event_settings', |
|
179 | - 'capability' => 'manage_options', |
|
180 | - ), |
|
181 | - 'update_default_event_settings' => array( |
|
182 | - 'func' => '_update_default_event_settings', |
|
183 | - 'capability' => 'manage_options', |
|
184 | - 'noheader' => true, |
|
185 | - ), |
|
186 | - 'template_settings' => array( |
|
187 | - 'func' => '_template_settings', |
|
188 | - 'capability' => 'manage_options', |
|
189 | - ), |
|
190 | - //event category tab related |
|
191 | - 'add_category' => array( |
|
192 | - 'func' => '_category_details', |
|
193 | - 'capability' => 'ee_edit_event_category', |
|
194 | - 'args' => array('add'), |
|
195 | - ), |
|
196 | - 'edit_category' => array( |
|
197 | - 'func' => '_category_details', |
|
198 | - 'capability' => 'ee_edit_event_category', |
|
199 | - 'args' => array('edit'), |
|
200 | - ), |
|
201 | - 'delete_categories' => array( |
|
202 | - 'func' => '_delete_categories', |
|
203 | - 'capability' => 'ee_delete_event_category', |
|
204 | - 'noheader' => true, |
|
205 | - ), |
|
206 | - 'delete_category' => array( |
|
207 | - 'func' => '_delete_categories', |
|
208 | - 'capability' => 'ee_delete_event_category', |
|
209 | - 'noheader' => true, |
|
210 | - ), |
|
211 | - 'insert_category' => array( |
|
212 | - 'func' => '_insert_or_update_category', |
|
213 | - 'args' => array('new_category' => true), |
|
214 | - 'capability' => 'ee_edit_event_category', |
|
215 | - 'noheader' => true, |
|
216 | - ), |
|
217 | - 'update_category' => array( |
|
218 | - 'func' => '_insert_or_update_category', |
|
219 | - 'args' => array('new_category' => false), |
|
220 | - 'capability' => 'ee_edit_event_category', |
|
221 | - 'noheader' => true, |
|
222 | - ), |
|
223 | - 'category_list' => array( |
|
224 | - 'func' => '_category_list_table', |
|
225 | - 'capability' => 'ee_manage_event_categories', |
|
226 | - ), |
|
227 | - ); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - |
|
232 | - protected function _set_page_config() |
|
233 | - { |
|
234 | - $this->_page_config = array( |
|
235 | - 'default' => array( |
|
236 | - 'nav' => array( |
|
237 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
238 | - 'order' => 10, |
|
239 | - ), |
|
240 | - 'list_table' => 'Events_Admin_List_Table', |
|
241 | - 'help_tabs' => array( |
|
242 | - 'events_overview_help_tab' => array( |
|
243 | - 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
244 | - 'filename' => 'events_overview', |
|
245 | - ), |
|
246 | - 'events_overview_table_column_headings_help_tab' => array( |
|
247 | - 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
248 | - 'filename' => 'events_overview_table_column_headings', |
|
249 | - ), |
|
250 | - 'events_overview_filters_help_tab' => array( |
|
251 | - 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
252 | - 'filename' => 'events_overview_filters', |
|
253 | - ), |
|
254 | - 'events_overview_view_help_tab' => array( |
|
255 | - 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
256 | - 'filename' => 'events_overview_views', |
|
257 | - ), |
|
258 | - 'events_overview_other_help_tab' => array( |
|
259 | - 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
260 | - 'filename' => 'events_overview_other', |
|
261 | - ), |
|
262 | - ), |
|
263 | - 'help_tour' => array( |
|
264 | - 'Event_Overview_Help_Tour', |
|
265 | - //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
266 | - ), |
|
267 | - 'qtips' => array( |
|
268 | - 'EE_Event_List_Table_Tips', |
|
269 | - ), |
|
270 | - 'require_nonce' => false, |
|
271 | - ), |
|
272 | - 'create_new' => array( |
|
273 | - 'nav' => array( |
|
274 | - 'label' => esc_html__('Add Event', 'event_espresso'), |
|
275 | - 'order' => 5, |
|
276 | - 'persistent' => false, |
|
277 | - ), |
|
278 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
279 | - 'help_tabs' => array( |
|
280 | - 'event_editor_help_tab' => array( |
|
281 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
282 | - 'filename' => 'event_editor', |
|
283 | - ), |
|
284 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
285 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
286 | - 'filename' => 'event_editor_title_richtexteditor', |
|
287 | - ), |
|
288 | - 'event_editor_venue_details_help_tab' => array( |
|
289 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
290 | - 'filename' => 'event_editor_venue_details', |
|
291 | - ), |
|
292 | - 'event_editor_event_datetimes_help_tab' => array( |
|
293 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
294 | - 'filename' => 'event_editor_event_datetimes', |
|
295 | - ), |
|
296 | - 'event_editor_event_tickets_help_tab' => array( |
|
297 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
298 | - 'filename' => 'event_editor_event_tickets', |
|
299 | - ), |
|
300 | - 'event_editor_event_registration_options_help_tab' => array( |
|
301 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
302 | - 'filename' => 'event_editor_event_registration_options', |
|
303 | - ), |
|
304 | - 'event_editor_tags_categories_help_tab' => array( |
|
305 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
306 | - 'filename' => 'event_editor_tags_categories', |
|
307 | - ), |
|
308 | - 'event_editor_questions_registrants_help_tab' => array( |
|
309 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
310 | - 'filename' => 'event_editor_questions_registrants', |
|
311 | - ), |
|
312 | - 'event_editor_save_new_event_help_tab' => array( |
|
313 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
314 | - 'filename' => 'event_editor_save_new_event', |
|
315 | - ), |
|
316 | - 'event_editor_other_help_tab' => array( |
|
317 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
318 | - 'filename' => 'event_editor_other', |
|
319 | - ), |
|
320 | - ), |
|
321 | - 'help_tour' => array( |
|
322 | - 'Event_Editor_Help_Tour', |
|
323 | - ), |
|
324 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
325 | - 'require_nonce' => false, |
|
326 | - ), |
|
327 | - 'edit' => array( |
|
328 | - 'nav' => array( |
|
329 | - 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
330 | - 'order' => 5, |
|
331 | - 'persistent' => false, |
|
332 | - 'url' => isset($this->_req_data['post']) |
|
333 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
334 | - array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
335 | - $this->_current_page_view_url |
|
336 | - ) |
|
337 | - : $this->_admin_base_url, |
|
338 | - ), |
|
339 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
340 | - 'help_tabs' => array( |
|
341 | - 'event_editor_help_tab' => array( |
|
342 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
343 | - 'filename' => 'event_editor', |
|
344 | - ), |
|
345 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
346 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
347 | - 'filename' => 'event_editor_title_richtexteditor', |
|
348 | - ), |
|
349 | - 'event_editor_venue_details_help_tab' => array( |
|
350 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
351 | - 'filename' => 'event_editor_venue_details', |
|
352 | - ), |
|
353 | - 'event_editor_event_datetimes_help_tab' => array( |
|
354 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
355 | - 'filename' => 'event_editor_event_datetimes', |
|
356 | - ), |
|
357 | - 'event_editor_event_tickets_help_tab' => array( |
|
358 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
359 | - 'filename' => 'event_editor_event_tickets', |
|
360 | - ), |
|
361 | - 'event_editor_event_registration_options_help_tab' => array( |
|
362 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
363 | - 'filename' => 'event_editor_event_registration_options', |
|
364 | - ), |
|
365 | - 'event_editor_tags_categories_help_tab' => array( |
|
366 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
367 | - 'filename' => 'event_editor_tags_categories', |
|
368 | - ), |
|
369 | - 'event_editor_questions_registrants_help_tab' => array( |
|
370 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
371 | - 'filename' => 'event_editor_questions_registrants', |
|
372 | - ), |
|
373 | - 'event_editor_save_new_event_help_tab' => array( |
|
374 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
375 | - 'filename' => 'event_editor_save_new_event', |
|
376 | - ), |
|
377 | - 'event_editor_other_help_tab' => array( |
|
378 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
379 | - 'filename' => 'event_editor_other', |
|
380 | - ), |
|
381 | - ), |
|
382 | - /*'help_tour' => array( |
|
20 | + /** |
|
21 | + * This will hold the event object for event_details screen. |
|
22 | + * |
|
23 | + * @access protected |
|
24 | + * @var EE_Event $_event |
|
25 | + */ |
|
26 | + protected $_event; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * This will hold the category object for category_details screen. |
|
31 | + * |
|
32 | + * @var stdClass $_category |
|
33 | + */ |
|
34 | + protected $_category; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * This will hold the event model instance |
|
39 | + * |
|
40 | + * @var EEM_Event $_event_model |
|
41 | + */ |
|
42 | + protected $_event_model; |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @var EE_Event |
|
48 | + */ |
|
49 | + protected $_cpt_model_obj = false; |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + protected function _init_page_props() |
|
54 | + { |
|
55 | + $this->page_slug = EVENTS_PG_SLUG; |
|
56 | + $this->page_label = EVENTS_LABEL; |
|
57 | + $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
58 | + $this->_admin_base_path = EVENTS_ADMIN; |
|
59 | + $this->_cpt_model_names = array( |
|
60 | + 'create_new' => 'EEM_Event', |
|
61 | + 'edit' => 'EEM_Event', |
|
62 | + ); |
|
63 | + $this->_cpt_edit_routes = array( |
|
64 | + 'espresso_events' => 'edit', |
|
65 | + ); |
|
66 | + add_action( |
|
67 | + 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
68 | + array($this, 'verify_event_edit') |
|
69 | + ); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + |
|
74 | + protected function _ajax_hooks() |
|
75 | + { |
|
76 | + //todo: all hooks for events ajax goes in here. |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + protected function _define_page_props() |
|
82 | + { |
|
83 | + $this->_admin_page_title = EVENTS_LABEL; |
|
84 | + $this->_labels = array( |
|
85 | + 'buttons' => array( |
|
86 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
87 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
88 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
89 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
90 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
91 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
92 | + ), |
|
93 | + 'editor_title' => array( |
|
94 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
95 | + ), |
|
96 | + 'publishbox' => array( |
|
97 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
98 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
99 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
100 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
101 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
102 | + ), |
|
103 | + ); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + |
|
108 | + protected function _set_page_routes() |
|
109 | + { |
|
110 | + //load formatter helper |
|
111 | + //load field generator helper |
|
112 | + //is there a evt_id in the request? |
|
113 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
114 | + ? $this->_req_data['EVT_ID'] : 0; |
|
115 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
116 | + $this->_page_routes = array( |
|
117 | + 'default' => array( |
|
118 | + 'func' => '_events_overview_list_table', |
|
119 | + 'capability' => 'ee_read_events', |
|
120 | + ), |
|
121 | + 'create_new' => array( |
|
122 | + 'func' => '_create_new_cpt_item', |
|
123 | + 'capability' => 'ee_edit_events', |
|
124 | + ), |
|
125 | + 'edit' => array( |
|
126 | + 'func' => '_edit_cpt_item', |
|
127 | + 'capability' => 'ee_edit_event', |
|
128 | + 'obj_id' => $evt_id, |
|
129 | + ), |
|
130 | + 'copy_event' => array( |
|
131 | + 'func' => '_copy_events', |
|
132 | + 'capability' => 'ee_edit_event', |
|
133 | + 'obj_id' => $evt_id, |
|
134 | + 'noheader' => true, |
|
135 | + ), |
|
136 | + 'trash_event' => array( |
|
137 | + 'func' => '_trash_or_restore_event', |
|
138 | + 'args' => array('event_status' => 'trash'), |
|
139 | + 'capability' => 'ee_delete_event', |
|
140 | + 'obj_id' => $evt_id, |
|
141 | + 'noheader' => true, |
|
142 | + ), |
|
143 | + 'trash_events' => array( |
|
144 | + 'func' => '_trash_or_restore_events', |
|
145 | + 'args' => array('event_status' => 'trash'), |
|
146 | + 'capability' => 'ee_delete_events', |
|
147 | + 'noheader' => true, |
|
148 | + ), |
|
149 | + 'restore_event' => array( |
|
150 | + 'func' => '_trash_or_restore_event', |
|
151 | + 'args' => array('event_status' => 'draft'), |
|
152 | + 'capability' => 'ee_delete_event', |
|
153 | + 'obj_id' => $evt_id, |
|
154 | + 'noheader' => true, |
|
155 | + ), |
|
156 | + 'restore_events' => array( |
|
157 | + 'func' => '_trash_or_restore_events', |
|
158 | + 'args' => array('event_status' => 'draft'), |
|
159 | + 'capability' => 'ee_delete_events', |
|
160 | + 'noheader' => true, |
|
161 | + ), |
|
162 | + 'delete_event' => array( |
|
163 | + 'func' => '_delete_event', |
|
164 | + 'capability' => 'ee_delete_event', |
|
165 | + 'obj_id' => $evt_id, |
|
166 | + 'noheader' => true, |
|
167 | + ), |
|
168 | + 'delete_events' => array( |
|
169 | + 'func' => '_delete_events', |
|
170 | + 'capability' => 'ee_delete_events', |
|
171 | + 'noheader' => true, |
|
172 | + ), |
|
173 | + 'view_report' => array( |
|
174 | + 'func' => '_view_report', |
|
175 | + 'capablity' => 'ee_edit_events', |
|
176 | + ), |
|
177 | + 'default_event_settings' => array( |
|
178 | + 'func' => '_default_event_settings', |
|
179 | + 'capability' => 'manage_options', |
|
180 | + ), |
|
181 | + 'update_default_event_settings' => array( |
|
182 | + 'func' => '_update_default_event_settings', |
|
183 | + 'capability' => 'manage_options', |
|
184 | + 'noheader' => true, |
|
185 | + ), |
|
186 | + 'template_settings' => array( |
|
187 | + 'func' => '_template_settings', |
|
188 | + 'capability' => 'manage_options', |
|
189 | + ), |
|
190 | + //event category tab related |
|
191 | + 'add_category' => array( |
|
192 | + 'func' => '_category_details', |
|
193 | + 'capability' => 'ee_edit_event_category', |
|
194 | + 'args' => array('add'), |
|
195 | + ), |
|
196 | + 'edit_category' => array( |
|
197 | + 'func' => '_category_details', |
|
198 | + 'capability' => 'ee_edit_event_category', |
|
199 | + 'args' => array('edit'), |
|
200 | + ), |
|
201 | + 'delete_categories' => array( |
|
202 | + 'func' => '_delete_categories', |
|
203 | + 'capability' => 'ee_delete_event_category', |
|
204 | + 'noheader' => true, |
|
205 | + ), |
|
206 | + 'delete_category' => array( |
|
207 | + 'func' => '_delete_categories', |
|
208 | + 'capability' => 'ee_delete_event_category', |
|
209 | + 'noheader' => true, |
|
210 | + ), |
|
211 | + 'insert_category' => array( |
|
212 | + 'func' => '_insert_or_update_category', |
|
213 | + 'args' => array('new_category' => true), |
|
214 | + 'capability' => 'ee_edit_event_category', |
|
215 | + 'noheader' => true, |
|
216 | + ), |
|
217 | + 'update_category' => array( |
|
218 | + 'func' => '_insert_or_update_category', |
|
219 | + 'args' => array('new_category' => false), |
|
220 | + 'capability' => 'ee_edit_event_category', |
|
221 | + 'noheader' => true, |
|
222 | + ), |
|
223 | + 'category_list' => array( |
|
224 | + 'func' => '_category_list_table', |
|
225 | + 'capability' => 'ee_manage_event_categories', |
|
226 | + ), |
|
227 | + ); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + |
|
232 | + protected function _set_page_config() |
|
233 | + { |
|
234 | + $this->_page_config = array( |
|
235 | + 'default' => array( |
|
236 | + 'nav' => array( |
|
237 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
238 | + 'order' => 10, |
|
239 | + ), |
|
240 | + 'list_table' => 'Events_Admin_List_Table', |
|
241 | + 'help_tabs' => array( |
|
242 | + 'events_overview_help_tab' => array( |
|
243 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
244 | + 'filename' => 'events_overview', |
|
245 | + ), |
|
246 | + 'events_overview_table_column_headings_help_tab' => array( |
|
247 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
248 | + 'filename' => 'events_overview_table_column_headings', |
|
249 | + ), |
|
250 | + 'events_overview_filters_help_tab' => array( |
|
251 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
252 | + 'filename' => 'events_overview_filters', |
|
253 | + ), |
|
254 | + 'events_overview_view_help_tab' => array( |
|
255 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
256 | + 'filename' => 'events_overview_views', |
|
257 | + ), |
|
258 | + 'events_overview_other_help_tab' => array( |
|
259 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
260 | + 'filename' => 'events_overview_other', |
|
261 | + ), |
|
262 | + ), |
|
263 | + 'help_tour' => array( |
|
264 | + 'Event_Overview_Help_Tour', |
|
265 | + //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
266 | + ), |
|
267 | + 'qtips' => array( |
|
268 | + 'EE_Event_List_Table_Tips', |
|
269 | + ), |
|
270 | + 'require_nonce' => false, |
|
271 | + ), |
|
272 | + 'create_new' => array( |
|
273 | + 'nav' => array( |
|
274 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
275 | + 'order' => 5, |
|
276 | + 'persistent' => false, |
|
277 | + ), |
|
278 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
279 | + 'help_tabs' => array( |
|
280 | + 'event_editor_help_tab' => array( |
|
281 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
282 | + 'filename' => 'event_editor', |
|
283 | + ), |
|
284 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
285 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
286 | + 'filename' => 'event_editor_title_richtexteditor', |
|
287 | + ), |
|
288 | + 'event_editor_venue_details_help_tab' => array( |
|
289 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
290 | + 'filename' => 'event_editor_venue_details', |
|
291 | + ), |
|
292 | + 'event_editor_event_datetimes_help_tab' => array( |
|
293 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
294 | + 'filename' => 'event_editor_event_datetimes', |
|
295 | + ), |
|
296 | + 'event_editor_event_tickets_help_tab' => array( |
|
297 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
298 | + 'filename' => 'event_editor_event_tickets', |
|
299 | + ), |
|
300 | + 'event_editor_event_registration_options_help_tab' => array( |
|
301 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
302 | + 'filename' => 'event_editor_event_registration_options', |
|
303 | + ), |
|
304 | + 'event_editor_tags_categories_help_tab' => array( |
|
305 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
306 | + 'filename' => 'event_editor_tags_categories', |
|
307 | + ), |
|
308 | + 'event_editor_questions_registrants_help_tab' => array( |
|
309 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
310 | + 'filename' => 'event_editor_questions_registrants', |
|
311 | + ), |
|
312 | + 'event_editor_save_new_event_help_tab' => array( |
|
313 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
314 | + 'filename' => 'event_editor_save_new_event', |
|
315 | + ), |
|
316 | + 'event_editor_other_help_tab' => array( |
|
317 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
318 | + 'filename' => 'event_editor_other', |
|
319 | + ), |
|
320 | + ), |
|
321 | + 'help_tour' => array( |
|
322 | + 'Event_Editor_Help_Tour', |
|
323 | + ), |
|
324 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
325 | + 'require_nonce' => false, |
|
326 | + ), |
|
327 | + 'edit' => array( |
|
328 | + 'nav' => array( |
|
329 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
330 | + 'order' => 5, |
|
331 | + 'persistent' => false, |
|
332 | + 'url' => isset($this->_req_data['post']) |
|
333 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
334 | + array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
335 | + $this->_current_page_view_url |
|
336 | + ) |
|
337 | + : $this->_admin_base_url, |
|
338 | + ), |
|
339 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
340 | + 'help_tabs' => array( |
|
341 | + 'event_editor_help_tab' => array( |
|
342 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
343 | + 'filename' => 'event_editor', |
|
344 | + ), |
|
345 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
346 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
347 | + 'filename' => 'event_editor_title_richtexteditor', |
|
348 | + ), |
|
349 | + 'event_editor_venue_details_help_tab' => array( |
|
350 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
351 | + 'filename' => 'event_editor_venue_details', |
|
352 | + ), |
|
353 | + 'event_editor_event_datetimes_help_tab' => array( |
|
354 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
355 | + 'filename' => 'event_editor_event_datetimes', |
|
356 | + ), |
|
357 | + 'event_editor_event_tickets_help_tab' => array( |
|
358 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
359 | + 'filename' => 'event_editor_event_tickets', |
|
360 | + ), |
|
361 | + 'event_editor_event_registration_options_help_tab' => array( |
|
362 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
363 | + 'filename' => 'event_editor_event_registration_options', |
|
364 | + ), |
|
365 | + 'event_editor_tags_categories_help_tab' => array( |
|
366 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
367 | + 'filename' => 'event_editor_tags_categories', |
|
368 | + ), |
|
369 | + 'event_editor_questions_registrants_help_tab' => array( |
|
370 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
371 | + 'filename' => 'event_editor_questions_registrants', |
|
372 | + ), |
|
373 | + 'event_editor_save_new_event_help_tab' => array( |
|
374 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
375 | + 'filename' => 'event_editor_save_new_event', |
|
376 | + ), |
|
377 | + 'event_editor_other_help_tab' => array( |
|
378 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
379 | + 'filename' => 'event_editor_other', |
|
380 | + ), |
|
381 | + ), |
|
382 | + /*'help_tour' => array( |
|
383 | 383 | 'Event_Edit_Help_Tour' |
384 | 384 | ),*/ |
385 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
386 | - 'require_nonce' => false, |
|
387 | - ), |
|
388 | - 'default_event_settings' => array( |
|
389 | - 'nav' => array( |
|
390 | - 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
391 | - 'order' => 40, |
|
392 | - ), |
|
393 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
394 | - 'labels' => array( |
|
395 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
396 | - ), |
|
397 | - 'help_tabs' => array( |
|
398 | - 'default_settings_help_tab' => array( |
|
399 | - 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
400 | - 'filename' => 'events_default_settings', |
|
401 | - ), |
|
402 | - 'default_settings_status_help_tab' => array( |
|
403 | - 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
404 | - 'filename' => 'events_default_settings_status', |
|
405 | - ), |
|
406 | - ), |
|
407 | - 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
408 | - 'require_nonce' => false, |
|
409 | - ), |
|
410 | - //template settings |
|
411 | - 'template_settings' => array( |
|
412 | - 'nav' => array( |
|
413 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
414 | - 'order' => 30, |
|
415 | - ), |
|
416 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
417 | - 'help_tabs' => array( |
|
418 | - 'general_settings_templates_help_tab' => array( |
|
419 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
420 | - 'filename' => 'general_settings_templates', |
|
421 | - ), |
|
422 | - ), |
|
423 | - 'help_tour' => array('Templates_Help_Tour'), |
|
424 | - 'require_nonce' => false, |
|
425 | - ), |
|
426 | - //event category stuff |
|
427 | - 'add_category' => array( |
|
428 | - 'nav' => array( |
|
429 | - 'label' => esc_html__('Add Category', 'event_espresso'), |
|
430 | - 'order' => 15, |
|
431 | - 'persistent' => false, |
|
432 | - ), |
|
433 | - 'help_tabs' => array( |
|
434 | - 'add_category_help_tab' => array( |
|
435 | - 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
436 | - 'filename' => 'events_add_category', |
|
437 | - ), |
|
438 | - ), |
|
439 | - 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
440 | - 'metaboxes' => array('_publish_post_box'), |
|
441 | - 'require_nonce' => false, |
|
442 | - ), |
|
443 | - 'edit_category' => array( |
|
444 | - 'nav' => array( |
|
445 | - 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
446 | - 'order' => 15, |
|
447 | - 'persistent' => false, |
|
448 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
449 | - ? add_query_arg( |
|
450 | - array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
451 | - $this->_current_page_view_url |
|
452 | - ) |
|
453 | - : $this->_admin_base_url, |
|
454 | - ), |
|
455 | - 'help_tabs' => array( |
|
456 | - 'edit_category_help_tab' => array( |
|
457 | - 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
458 | - 'filename' => 'events_edit_category', |
|
459 | - ), |
|
460 | - ), |
|
461 | - /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
462 | - 'metaboxes' => array('_publish_post_box'), |
|
463 | - 'require_nonce' => false, |
|
464 | - ), |
|
465 | - 'category_list' => array( |
|
466 | - 'nav' => array( |
|
467 | - 'label' => esc_html__('Categories', 'event_espresso'), |
|
468 | - 'order' => 20, |
|
469 | - ), |
|
470 | - 'list_table' => 'Event_Categories_Admin_List_Table', |
|
471 | - 'help_tabs' => array( |
|
472 | - 'events_categories_help_tab' => array( |
|
473 | - 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
474 | - 'filename' => 'events_categories', |
|
475 | - ), |
|
476 | - 'events_categories_table_column_headings_help_tab' => array( |
|
477 | - 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
478 | - 'filename' => 'events_categories_table_column_headings', |
|
479 | - ), |
|
480 | - 'events_categories_view_help_tab' => array( |
|
481 | - 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
482 | - 'filename' => 'events_categories_views', |
|
483 | - ), |
|
484 | - 'events_categories_other_help_tab' => array( |
|
485 | - 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
486 | - 'filename' => 'events_categories_other', |
|
487 | - ), |
|
488 | - ), |
|
489 | - 'help_tour' => array( |
|
490 | - 'Event_Categories_Help_Tour', |
|
491 | - ), |
|
492 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
493 | - 'require_nonce' => false, |
|
494 | - ), |
|
495 | - ); |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - |
|
500 | - protected function _add_screen_options() |
|
501 | - { |
|
502 | - //todo |
|
503 | - } |
|
504 | - |
|
505 | - |
|
506 | - |
|
507 | - protected function _add_screen_options_default() |
|
508 | - { |
|
509 | - $this->_per_page_screen_option(); |
|
510 | - } |
|
511 | - |
|
512 | - |
|
513 | - |
|
514 | - protected function _add_screen_options_category_list() |
|
515 | - { |
|
516 | - $page_title = $this->_admin_page_title; |
|
517 | - $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
518 | - $this->_per_page_screen_option(); |
|
519 | - $this->_admin_page_title = $page_title; |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - |
|
524 | - protected function _add_feature_pointers() |
|
525 | - { |
|
526 | - //todo |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - |
|
531 | - public function load_scripts_styles() |
|
532 | - { |
|
533 | - wp_register_style( |
|
534 | - 'events-admin-css', |
|
535 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
536 | - array(), |
|
537 | - EVENT_ESPRESSO_VERSION |
|
538 | - ); |
|
539 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
540 | - wp_enqueue_style('events-admin-css'); |
|
541 | - wp_enqueue_style('ee-cat-admin'); |
|
542 | - //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
543 | - //registers for all views |
|
544 | - //scripts |
|
545 | - wp_register_script( |
|
546 | - 'event_editor_js', |
|
547 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
548 | - array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
549 | - EVENT_ESPRESSO_VERSION, |
|
550 | - true |
|
551 | - ); |
|
552 | - } |
|
553 | - |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * enqueuing scripts and styles specific to this view |
|
558 | - * |
|
559 | - * @return void |
|
560 | - */ |
|
561 | - public function load_scripts_styles_create_new() |
|
562 | - { |
|
563 | - $this->load_scripts_styles_edit(); |
|
564 | - } |
|
565 | - |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * enqueuing scripts and styles specific to this view |
|
570 | - * |
|
571 | - * @return void |
|
572 | - */ |
|
573 | - public function load_scripts_styles_edit() |
|
574 | - { |
|
575 | - //styles |
|
576 | - wp_enqueue_style('espresso-ui-theme'); |
|
577 | - wp_register_style( |
|
578 | - 'event-editor-css', |
|
579 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
580 | - array('ee-admin-css'), |
|
581 | - EVENT_ESPRESSO_VERSION |
|
582 | - ); |
|
583 | - wp_enqueue_style('event-editor-css'); |
|
584 | - //scripts |
|
585 | - wp_register_script( |
|
586 | - 'event-datetime-metabox', |
|
587 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
588 | - array('event_editor_js', 'ee-datepicker'), |
|
589 | - EVENT_ESPRESSO_VERSION |
|
590 | - ); |
|
591 | - wp_enqueue_script('event-datetime-metabox'); |
|
592 | - } |
|
593 | - |
|
594 | - |
|
595 | - |
|
596 | - public function load_scripts_styles_add_category() |
|
597 | - { |
|
598 | - $this->load_scripts_styles_edit_category(); |
|
599 | - } |
|
600 | - |
|
601 | - |
|
602 | - |
|
603 | - public function load_scripts_styles_edit_category() |
|
604 | - { |
|
605 | - } |
|
606 | - |
|
607 | - |
|
608 | - |
|
609 | - protected function _set_list_table_views_category_list() |
|
610 | - { |
|
611 | - $this->_views = array( |
|
612 | - 'all' => array( |
|
613 | - 'slug' => 'all', |
|
614 | - 'label' => esc_html__('All', 'event_espresso'), |
|
615 | - 'count' => 0, |
|
616 | - 'bulk_action' => array( |
|
617 | - 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
618 | - ), |
|
619 | - ), |
|
620 | - ); |
|
621 | - } |
|
622 | - |
|
623 | - |
|
624 | - |
|
625 | - public function admin_init() |
|
626 | - { |
|
627 | - EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
628 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
629 | - 'event_espresso' |
|
630 | - ); |
|
631 | - } |
|
632 | - |
|
633 | - |
|
634 | - |
|
635 | - //nothing needed for events with these methods. |
|
636 | - public function admin_notices() |
|
637 | - { |
|
638 | - } |
|
639 | - |
|
640 | - |
|
641 | - |
|
642 | - public function admin_footer_scripts() |
|
643 | - { |
|
644 | - } |
|
645 | - |
|
646 | - |
|
647 | - |
|
648 | - /** |
|
649 | - * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
650 | - * warning (via EE_Error::add_error()); |
|
651 | - * |
|
652 | - * @param EE_Event $event Event object |
|
653 | - * @access public |
|
654 | - * @return void |
|
655 | - */ |
|
656 | - public function verify_event_edit($event = null) |
|
657 | - { |
|
658 | - // no event? |
|
659 | - if (empty($event)) { |
|
660 | - // set event |
|
661 | - $event = $this->_cpt_model_obj; |
|
662 | - } |
|
663 | - // STILL no event? |
|
664 | - if (empty ($event)) { |
|
665 | - return; |
|
666 | - } |
|
667 | - $orig_status = $event->status(); |
|
668 | - // first check if event is active. |
|
669 | - if ( |
|
670 | - $orig_status === EEM_Event::cancelled |
|
671 | - || $orig_status === EEM_Event::postponed |
|
672 | - || $event->is_expired() |
|
673 | - || $event->is_inactive() |
|
674 | - ) { |
|
675 | - return; |
|
676 | - } |
|
677 | - //made it here so it IS active... next check that any of the tickets are sold. |
|
678 | - if ($event->is_sold_out(true)) { |
|
679 | - if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
680 | - EE_Error::add_attention( |
|
681 | - sprintf( |
|
682 | - esc_html__( |
|
683 | - 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
684 | - 'event_espresso' |
|
685 | - ), |
|
686 | - EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
687 | - ) |
|
688 | - ); |
|
689 | - } |
|
690 | - return; |
|
691 | - } else if ($orig_status === EEM_Event::sold_out) { |
|
692 | - EE_Error::add_attention( |
|
693 | - sprintf( |
|
694 | - esc_html__( |
|
695 | - 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
696 | - 'event_espresso' |
|
697 | - ), |
|
698 | - EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
699 | - ) |
|
700 | - ); |
|
701 | - } |
|
702 | - //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
703 | - if ( ! $event->tickets_on_sale()) { |
|
704 | - return; |
|
705 | - } |
|
706 | - //made it here so show warning |
|
707 | - $this->_edit_event_warning(); |
|
708 | - } |
|
709 | - |
|
710 | - |
|
711 | - |
|
712 | - /** |
|
713 | - * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
714 | - * When needed, hook this into a EE_Error::add_error() notice. |
|
715 | - * |
|
716 | - * @access protected |
|
717 | - * @return void |
|
718 | - */ |
|
719 | - protected function _edit_event_warning() |
|
720 | - { |
|
721 | - // we don't want to add warnings during these requests |
|
722 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
723 | - return; |
|
724 | - } |
|
725 | - EE_Error::add_attention( |
|
726 | - esc_html__( |
|
727 | - 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
728 | - 'event_espresso' |
|
729 | - ) |
|
730 | - ); |
|
731 | - } |
|
732 | - |
|
733 | - |
|
734 | - |
|
735 | - /** |
|
736 | - * When a user is creating a new event, notify them if they haven't set their timezone. |
|
737 | - * Otherwise, do the normal logic |
|
738 | - * |
|
739 | - * @return string |
|
740 | - * @throws \EE_Error |
|
741 | - */ |
|
742 | - protected function _create_new_cpt_item() |
|
743 | - { |
|
744 | - $gmt_offset = get_option('gmt_offset'); |
|
745 | - //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
746 | - if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
747 | - EE_Error::add_attention( |
|
748 | - sprintf( |
|
749 | - __( |
|
750 | - 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.', |
|
751 | - 'event_espresso' |
|
752 | - ), |
|
753 | - '<a href="' . admin_url('options-general.php') . '">', |
|
754 | - '</a>' |
|
755 | - ), |
|
756 | - __FILE__, |
|
757 | - __FUNCTION__, |
|
758 | - __LINE__ |
|
759 | - ); |
|
760 | - } |
|
761 | - return parent::_create_new_cpt_item(); |
|
762 | - } |
|
763 | - |
|
764 | - |
|
765 | - |
|
766 | - protected function _set_list_table_views_default() |
|
767 | - { |
|
768 | - $this->_views = array( |
|
769 | - 'all' => array( |
|
770 | - 'slug' => 'all', |
|
771 | - 'label' => esc_html__('View All Events', 'event_espresso'), |
|
772 | - 'count' => 0, |
|
773 | - 'bulk_action' => array( |
|
774 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
775 | - ), |
|
776 | - ), |
|
777 | - 'draft' => array( |
|
778 | - 'slug' => 'draft', |
|
779 | - 'label' => esc_html__('Draft', 'event_espresso'), |
|
780 | - 'count' => 0, |
|
781 | - 'bulk_action' => array( |
|
782 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
783 | - ), |
|
784 | - ), |
|
785 | - ); |
|
786 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
787 | - $this->_views['trash'] = array( |
|
788 | - 'slug' => 'trash', |
|
789 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
790 | - 'count' => 0, |
|
791 | - 'bulk_action' => array( |
|
792 | - 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
793 | - 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
794 | - ), |
|
795 | - ); |
|
796 | - } |
|
797 | - } |
|
798 | - |
|
799 | - |
|
800 | - |
|
801 | - /** |
|
802 | - * @return array |
|
803 | - */ |
|
804 | - protected function _event_legend_items() |
|
805 | - { |
|
806 | - $items = array( |
|
807 | - 'view_details' => array( |
|
808 | - 'class' => 'dashicons dashicons-search', |
|
809 | - 'desc' => esc_html__('View Event', 'event_espresso'), |
|
810 | - ), |
|
811 | - 'edit_event' => array( |
|
812 | - 'class' => 'ee-icon ee-icon-calendar-edit', |
|
813 | - 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
814 | - ), |
|
815 | - 'view_attendees' => array( |
|
816 | - 'class' => 'dashicons dashicons-groups', |
|
817 | - 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
818 | - ), |
|
819 | - ); |
|
820 | - $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
821 | - $statuses = array( |
|
822 | - 'sold_out_status' => array( |
|
823 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
824 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
825 | - ), |
|
826 | - 'active_status' => array( |
|
827 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
828 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
829 | - ), |
|
830 | - 'upcoming_status' => array( |
|
831 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
832 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
833 | - ), |
|
834 | - 'postponed_status' => array( |
|
835 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
836 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
837 | - ), |
|
838 | - 'cancelled_status' => array( |
|
839 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
840 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
841 | - ), |
|
842 | - 'expired_status' => array( |
|
843 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
844 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
845 | - ), |
|
846 | - 'inactive_status' => array( |
|
847 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
848 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
849 | - ), |
|
850 | - ); |
|
851 | - $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
852 | - return array_merge($items, $statuses); |
|
853 | - } |
|
854 | - |
|
855 | - |
|
856 | - |
|
857 | - /** |
|
858 | - * _event_model |
|
859 | - * |
|
860 | - * @return EEM_Event |
|
861 | - */ |
|
862 | - private function _event_model() |
|
863 | - { |
|
864 | - if ( ! $this->_event_model instanceof EEM_Event) { |
|
865 | - $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
866 | - } |
|
867 | - return $this->_event_model; |
|
868 | - } |
|
869 | - |
|
870 | - |
|
871 | - |
|
872 | - /** |
|
873 | - * Adds extra buttons to the WP CPT permalink field row. |
|
874 | - * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
875 | - * |
|
876 | - * @param string $return the current html |
|
877 | - * @param int $id the post id for the page |
|
878 | - * @param string $new_title What the title is |
|
879 | - * @param string $new_slug what the slug is |
|
880 | - * @return string The new html string for the permalink area |
|
881 | - */ |
|
882 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
883 | - { |
|
884 | - //make sure this is only when editing |
|
885 | - if ( ! empty($id)) { |
|
886 | - $post = get_post($id); |
|
887 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
888 | - . esc_html__('Shortcode', 'event_espresso') |
|
889 | - . '</a> '; |
|
890 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
891 | - . $post->ID |
|
892 | - . ']">'; |
|
893 | - } |
|
894 | - return $return; |
|
895 | - } |
|
896 | - |
|
897 | - |
|
898 | - |
|
899 | - /** |
|
900 | - * _events_overview_list_table |
|
901 | - * This contains the logic for showing the events_overview list |
|
902 | - * |
|
903 | - * @access protected |
|
904 | - * @return void |
|
905 | - * @throws \EE_Error |
|
906 | - */ |
|
907 | - protected function _events_overview_list_table() |
|
908 | - { |
|
909 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
910 | - $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
911 | - ? (array)$this->_template_args['after_list_table'] |
|
912 | - : array(); |
|
913 | - $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
914 | - . EEH_Template::get_button_or_link( |
|
915 | - get_post_type_archive_link('espresso_events'), |
|
916 | - esc_html__("View Event Archive Page", "event_espresso"), |
|
917 | - 'button' |
|
918 | - ); |
|
919 | - $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
920 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
921 | - 'create_new', |
|
922 | - 'add', |
|
923 | - array(), |
|
924 | - 'add-new-h2' |
|
925 | - ); |
|
926 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
927 | - } |
|
928 | - |
|
929 | - |
|
930 | - |
|
931 | - /** |
|
932 | - * this allows for extra misc actions in the default WP publish box |
|
933 | - * |
|
934 | - * @return void |
|
935 | - */ |
|
936 | - public function extra_misc_actions_publish_box() |
|
937 | - { |
|
938 | - $this->_generate_publish_box_extra_content(); |
|
939 | - } |
|
940 | - |
|
941 | - |
|
942 | - |
|
943 | - /** |
|
944 | - * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been saved. Child classes are required to declare this method. Typically you would use this to save any additional data. |
|
945 | - * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
946 | - * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that you |
|
947 | - * handle this accordingly. |
|
948 | - * |
|
949 | - * @access protected |
|
950 | - * @abstract |
|
951 | - * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
952 | - * @param object $post The post object of the cpt that was saved. |
|
953 | - * @return void |
|
954 | - */ |
|
955 | - protected function _insert_update_cpt_item($post_id, $post) |
|
956 | - { |
|
957 | - if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
958 | - //get out we're not processing an event save. |
|
959 | - return; |
|
960 | - } |
|
961 | - $event_values = array( |
|
962 | - 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
963 | - 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
964 | - 'EVT_additional_limit' => min( |
|
965 | - apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
966 | - ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
967 | - ), |
|
968 | - 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
969 | - ? $this->_req_data['EVT_default_registration_status'] |
|
970 | - : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
971 | - 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
972 | - 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
973 | - 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
974 | - ? $this->_req_data['timezone_string'] : null, |
|
975 | - 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
976 | - ? $this->_req_data['externalURL'] : null, |
|
977 | - 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
978 | - ? $this->_req_data['event_phone'] : null, |
|
979 | - ); |
|
980 | - //update event |
|
981 | - $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
982 | - //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
|
983 | - $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
984 | - $event = $this->_event_model()->get_one(array($get_one_where)); |
|
985 | - //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
986 | - $event_update_callbacks = apply_filters( |
|
987 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
988 | - array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
989 | - ); |
|
990 | - $att_success = true; |
|
991 | - foreach ($event_update_callbacks as $e_callback) { |
|
992 | - $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
993 | - $att_success = ! $att_success ? $att_success |
|
994 | - : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
995 | - } |
|
996 | - //any errors? |
|
997 | - if ($success && false === $att_success) { |
|
998 | - EE_Error::add_error( |
|
999 | - esc_html__( |
|
1000 | - 'Event Details saved successfully but something went wrong with saving attachments.', |
|
1001 | - 'event_espresso' |
|
1002 | - ), |
|
1003 | - __FILE__, |
|
1004 | - __FUNCTION__, |
|
1005 | - __LINE__ |
|
1006 | - ); |
|
1007 | - } else if ($success === false) { |
|
1008 | - EE_Error::add_error( |
|
1009 | - esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
1010 | - __FILE__, |
|
1011 | - __FUNCTION__, |
|
1012 | - __LINE__ |
|
1013 | - ); |
|
1014 | - } |
|
1015 | - } |
|
1016 | - |
|
1017 | - |
|
1018 | - |
|
1019 | - /** |
|
1020 | - * @see parent::restore_item() |
|
1021 | - * @param int $post_id |
|
1022 | - * @param int $revision_id |
|
1023 | - */ |
|
1024 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
1025 | - { |
|
1026 | - //copy existing event meta to new post |
|
1027 | - $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
1028 | - if ($post_evt instanceof EE_Event) { |
|
1029 | - //meta revision restore |
|
1030 | - $post_evt->restore_revision($revision_id); |
|
1031 | - //related objs restore |
|
1032 | - $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
1033 | - } |
|
1034 | - } |
|
1035 | - |
|
1036 | - |
|
1037 | - |
|
1038 | - /** |
|
1039 | - * Attach the venue to the Event |
|
1040 | - * |
|
1041 | - * @param \EE_Event $evtobj Event Object to add the venue to |
|
1042 | - * @param array $data The request data from the form |
|
1043 | - * @return bool Success or fail. |
|
1044 | - */ |
|
1045 | - protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
1046 | - { |
|
1047 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1048 | - $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1049 | - $rows_affected = null; |
|
1050 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1051 | - // very important. If we don't have a venue name... |
|
1052 | - // then we'll get out because not necessary to create empty venue |
|
1053 | - if (empty($data['venue_title'])) { |
|
1054 | - return false; |
|
1055 | - } |
|
1056 | - $venue_array = array( |
|
1057 | - 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1058 | - 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1059 | - 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1060 | - 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1061 | - 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1062 | - : null, |
|
1063 | - 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1064 | - 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1065 | - 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1066 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1067 | - 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1068 | - 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1069 | - 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1070 | - 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1071 | - 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1072 | - 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1073 | - 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1074 | - 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1075 | - 'status' => 'publish', |
|
1076 | - ); |
|
1077 | - //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
1078 | - if ( ! empty($venue_id)) { |
|
1079 | - $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1080 | - $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1081 | - //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
|
1082 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1083 | - return $rows_affected > 0 ? true : false; |
|
1084 | - } else { |
|
1085 | - //we insert the venue |
|
1086 | - $venue_id = $venue_model->insert($venue_array); |
|
1087 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1088 | - return ! empty($venue_id) ? true : false; |
|
1089 | - } |
|
1090 | - //when we have the ancestor come in it's already been handled by the revision save. |
|
1091 | - } |
|
1092 | - |
|
1093 | - |
|
1094 | - |
|
1095 | - /** |
|
1096 | - * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
1097 | - * |
|
1098 | - * @param EE_Event $evtobj The Event object we're attaching data to |
|
1099 | - * @param array $data The request data from the form |
|
1100 | - * @return array |
|
1101 | - */ |
|
1102 | - protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
1103 | - { |
|
1104 | - $success = true; |
|
1105 | - $saved_dtt = null; |
|
1106 | - $saved_tickets = array(); |
|
1107 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1108 | - foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1109 | - //trim all values to ensure any excess whitespace is removed. |
|
1110 | - $dtt = array_map('trim', $dtt); |
|
1111 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1112 | - : $dtt['DTT_EVT_start']; |
|
1113 | - $datetime_values = array( |
|
1114 | - 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1115 | - 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
1116 | - 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
1117 | - 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1118 | - 'DTT_order' => $row, |
|
1119 | - ); |
|
1120 | - //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
|
1121 | - if ( ! empty($dtt['DTT_ID'])) { |
|
1122 | - $DTM = EE_Registry::instance() |
|
1123 | - ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1124 | - ->get_one_by_ID($dtt['DTT_ID']); |
|
1125 | - $DTM->set_date_format($incoming_date_formats[0]); |
|
1126 | - $DTM->set_time_format($incoming_date_formats[1]); |
|
1127 | - foreach ($datetime_values as $field => $value) { |
|
1128 | - $DTM->set($field, $value); |
|
1129 | - } |
|
1130 | - //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
|
1131 | - $saved_dtts[$DTM->ID()] = $DTM; |
|
1132 | - } else { |
|
1133 | - $DTM = EE_Registry::instance()->load_class( |
|
1134 | - 'Datetime', |
|
1135 | - array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
1136 | - false, |
|
1137 | - false |
|
1138 | - ); |
|
1139 | - foreach ($datetime_values as $field => $value) { |
|
1140 | - $DTM->set($field, $value); |
|
1141 | - } |
|
1142 | - } |
|
1143 | - $DTM->save(); |
|
1144 | - $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1145 | - //load DTT helper |
|
1146 | - //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1147 | - if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1148 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1149 | - $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1150 | - $DTT->save(); |
|
1151 | - } |
|
1152 | - //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
|
1153 | - $saved_dtt = $DTT; |
|
1154 | - $success = ! $success ? $success : $DTT; |
|
1155 | - //if ANY of these updates fail then we want the appropriate global error message. |
|
1156 | - // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
1157 | - } |
|
1158 | - //no dtts get deleted so we don't do any of that logic here. |
|
1159 | - //update tickets next |
|
1160 | - $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1161 | - foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1162 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1163 | - $update_prices = false; |
|
1164 | - $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1165 | - ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1166 | - // trim inputs to ensure any excess whitespace is removed. |
|
1167 | - $tkt = array_map('trim', $tkt); |
|
1168 | - if (empty($tkt['TKT_start_date'])) { |
|
1169 | - //let's use now in the set timezone. |
|
1170 | - $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1171 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1172 | - } |
|
1173 | - if (empty($tkt['TKT_end_date'])) { |
|
1174 | - //use the start date of the first datetime |
|
1175 | - $dtt = $evtobj->first_datetime(); |
|
1176 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
1177 | - $incoming_date_formats[0], |
|
1178 | - $incoming_date_formats[1] |
|
1179 | - ); |
|
1180 | - } |
|
1181 | - $TKT_values = array( |
|
1182 | - 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1183 | - 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1184 | - 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1185 | - 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1186 | - 'TKT_start_date' => $tkt['TKT_start_date'], |
|
1187 | - 'TKT_end_date' => $tkt['TKT_end_date'], |
|
1188 | - 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1189 | - 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1190 | - 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1191 | - 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1192 | - 'TKT_row' => $row, |
|
1193 | - 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1194 | - 'TKT_price' => $ticket_price, |
|
1195 | - ); |
|
1196 | - //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
|
1197 | - if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1198 | - $TKT_values['TKT_ID'] = 0; |
|
1199 | - $TKT_values['TKT_is_default'] = 0; |
|
1200 | - $TKT_values['TKT_price'] = $ticket_price; |
|
1201 | - $update_prices = true; |
|
1202 | - } |
|
1203 | - //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
1204 | - //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
|
1205 | - //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
1206 | - if ( ! empty($tkt['TKT_ID'])) { |
|
1207 | - $TKT = EE_Registry::instance() |
|
1208 | - ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1209 | - ->get_one_by_ID($tkt['TKT_ID']); |
|
1210 | - if ($TKT instanceof EE_Ticket) { |
|
1211 | - $ticket_sold = $TKT->count_related( |
|
1212 | - 'Registration', |
|
1213 | - array( |
|
1214 | - array( |
|
1215 | - 'STS_ID' => array( |
|
1216 | - 'NOT IN', |
|
1217 | - array(EEM_Registration::status_id_incomplete), |
|
1218 | - ), |
|
1219 | - ), |
|
1220 | - ) |
|
1221 | - ) > 0 ? true : false; |
|
1222 | - //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
|
1223 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1224 | - && ! $TKT->get( |
|
1225 | - 'TKT_deleted' |
|
1226 | - ) ? true : false; |
|
1227 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
1228 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
1229 | - //set new values |
|
1230 | - foreach ($TKT_values as $field => $value) { |
|
1231 | - if ($field == 'TKT_qty') { |
|
1232 | - $TKT->set_qty($value); |
|
1233 | - } else { |
|
1234 | - $TKT->set($field, $value); |
|
1235 | - } |
|
1236 | - } |
|
1237 | - //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
1238 | - if ($create_new_TKT) { |
|
1239 | - //archive the old ticket first |
|
1240 | - $TKT->set('TKT_deleted', 1); |
|
1241 | - $TKT->save(); |
|
1242 | - //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
1243 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
1244 | - //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
|
1245 | - $TKT = clone $TKT; |
|
1246 | - $TKT->set('TKT_ID', 0); |
|
1247 | - $TKT->set('TKT_deleted', 0); |
|
1248 | - $TKT->set('TKT_price', $ticket_price); |
|
1249 | - $TKT->set('TKT_sold', 0); |
|
1250 | - //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
1251 | - $update_prices = true; |
|
1252 | - } |
|
1253 | - //make sure price is set if it hasn't been already |
|
1254 | - $TKT->set('TKT_price', $ticket_price); |
|
1255 | - } |
|
1256 | - } else { |
|
1257 | - //no TKT_id so a new TKT |
|
1258 | - $TKT_values['TKT_price'] = $ticket_price; |
|
1259 | - $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1260 | - if ($TKT instanceof EE_Ticket) { |
|
1261 | - //need to reset values to properly account for the date formats |
|
1262 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
1263 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
1264 | - $TKT->set_timezone($evtobj->get_timezone()); |
|
1265 | - //set new values |
|
1266 | - foreach ($TKT_values as $field => $value) { |
|
1267 | - if ($field == 'TKT_qty') { |
|
1268 | - $TKT->set_qty($value); |
|
1269 | - } else { |
|
1270 | - $TKT->set($field, $value); |
|
1271 | - } |
|
1272 | - } |
|
1273 | - $update_prices = true; |
|
1274 | - } |
|
1275 | - } |
|
1276 | - // cap ticket qty by datetime reg limits |
|
1277 | - $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1278 | - //update ticket. |
|
1279 | - $TKT->save(); |
|
1280 | - //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1281 | - if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1282 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1283 | - $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1284 | - $TKT->save(); |
|
1285 | - } |
|
1286 | - //initially let's add the ticket to the dtt |
|
1287 | - $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1288 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
1289 | - //add prices to ticket |
|
1290 | - $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1291 | - } |
|
1292 | - //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
1293 | - $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1294 | - $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1295 | - foreach ($tickets_removed as $id) { |
|
1296 | - $id = absint($id); |
|
1297 | - //get the ticket for this id |
|
1298 | - $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1299 | - //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
1300 | - $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1301 | - foreach ($dtts as $dtt) { |
|
1302 | - $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1303 | - } |
|
1304 | - //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
1305 | - $tkt_to_remove->delete_related_permanently('Price'); |
|
1306 | - //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1307 | - $tkt_to_remove->delete_permanently(); |
|
1308 | - } |
|
1309 | - return array($saved_dtt, $saved_tickets); |
|
1310 | - } |
|
1311 | - |
|
1312 | - |
|
1313 | - |
|
1314 | - /** |
|
1315 | - * This attaches a list of given prices to a ticket. |
|
1316 | - * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
1317 | - * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
1318 | - * price info and prices are automatically "archived" via the ticket. |
|
1319 | - * |
|
1320 | - * @access private |
|
1321 | - * @param array $prices Array of prices from the form. |
|
1322 | - * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
1323 | - * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
1324 | - * @return void |
|
1325 | - */ |
|
1326 | - private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
1327 | - { |
|
1328 | - foreach ($prices as $row => $prc) { |
|
1329 | - $PRC_values = array( |
|
1330 | - 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1331 | - 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1332 | - 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1333 | - 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1334 | - 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1335 | - 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
1336 | - 'PRC_order' => $row, |
|
1337 | - ); |
|
1338 | - if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1339 | - $PRC_values['PRC_ID'] = 0; |
|
1340 | - $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1341 | - } else { |
|
1342 | - $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1343 | - //update this price with new values |
|
1344 | - foreach ($PRC_values as $field => $newprc) { |
|
1345 | - $PRC->set($field, $newprc); |
|
1346 | - } |
|
1347 | - $PRC->save(); |
|
1348 | - } |
|
1349 | - $ticket->_add_relation_to($PRC, 'Price'); |
|
1350 | - } |
|
1351 | - } |
|
1352 | - |
|
1353 | - |
|
1354 | - |
|
1355 | - /** |
|
1356 | - * Add in our autosave ajax handlers |
|
1357 | - * |
|
1358 | - * @return void |
|
1359 | - */ |
|
1360 | - protected function _ee_autosave_create_new() |
|
1361 | - { |
|
1362 | - // $this->_ee_autosave_edit(); |
|
1363 | - } |
|
1364 | - |
|
1365 | - |
|
1366 | - |
|
1367 | - protected function _ee_autosave_edit() |
|
1368 | - { |
|
1369 | - return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
1370 | - } |
|
1371 | - |
|
1372 | - |
|
1373 | - |
|
1374 | - /** |
|
1375 | - * _generate_publish_box_extra_content |
|
1376 | - * |
|
1377 | - * @access private |
|
1378 | - * @return void |
|
1379 | - */ |
|
1380 | - private function _generate_publish_box_extra_content() |
|
1381 | - { |
|
1382 | - //load formatter helper |
|
1383 | - //args for getting related registrations |
|
1384 | - $approved_query_args = array( |
|
1385 | - array( |
|
1386 | - 'REG_deleted' => 0, |
|
1387 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
1388 | - ), |
|
1389 | - ); |
|
1390 | - $not_approved_query_args = array( |
|
1391 | - array( |
|
1392 | - 'REG_deleted' => 0, |
|
1393 | - 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
1394 | - ), |
|
1395 | - ); |
|
1396 | - $pending_payment_query_args = array( |
|
1397 | - array( |
|
1398 | - 'REG_deleted' => 0, |
|
1399 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
1400 | - ), |
|
1401 | - ); |
|
1402 | - // publish box |
|
1403 | - $publish_box_extra_args = array( |
|
1404 | - 'view_approved_reg_url' => add_query_arg( |
|
1405 | - array( |
|
1406 | - 'action' => 'default', |
|
1407 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1408 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1409 | - ), |
|
1410 | - REG_ADMIN_URL |
|
1411 | - ), |
|
1412 | - 'view_not_approved_reg_url' => add_query_arg( |
|
1413 | - array( |
|
1414 | - 'action' => 'default', |
|
1415 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1416 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1417 | - ), |
|
1418 | - REG_ADMIN_URL |
|
1419 | - ), |
|
1420 | - 'view_pending_payment_reg_url' => add_query_arg( |
|
1421 | - array( |
|
1422 | - 'action' => 'default', |
|
1423 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1424 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1425 | - ), |
|
1426 | - REG_ADMIN_URL |
|
1427 | - ), |
|
1428 | - 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
1429 | - 'Registration', |
|
1430 | - $approved_query_args |
|
1431 | - ), |
|
1432 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
1433 | - 'Registration', |
|
1434 | - $not_approved_query_args |
|
1435 | - ), |
|
1436 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
1437 | - 'Registration', |
|
1438 | - $pending_payment_query_args |
|
1439 | - ), |
|
1440 | - 'misc_pub_section_class' => apply_filters( |
|
1441 | - 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
1442 | - 'misc-pub-section' |
|
1443 | - ), |
|
1444 | - //'email_attendees_url' => add_query_arg( |
|
1445 | - // array( |
|
1446 | - // 'event_admin_reports' => 'event_newsletter', |
|
1447 | - // 'event_id' => $this->_cpt_model_obj->id |
|
1448 | - // ), |
|
1449 | - // 'admin.php?page=espresso_registrations' |
|
1450 | - //), |
|
1451 | - ); |
|
1452 | - ob_start(); |
|
1453 | - do_action( |
|
1454 | - 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
1455 | - $this->_cpt_model_obj |
|
1456 | - ); |
|
1457 | - $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1458 | - // load template |
|
1459 | - EEH_Template::display_template( |
|
1460 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1461 | - $publish_box_extra_args |
|
1462 | - ); |
|
1463 | - } |
|
1464 | - |
|
1465 | - |
|
1466 | - |
|
1467 | - /** |
|
1468 | - * This just returns whatever is set as the _event object property |
|
1469 | - * //todo this will become obsolete once the models are in place |
|
1470 | - * |
|
1471 | - * @return object |
|
1472 | - */ |
|
1473 | - public function get_event_object() |
|
1474 | - { |
|
1475 | - return $this->_cpt_model_obj; |
|
1476 | - } |
|
1477 | - |
|
1478 | - |
|
1479 | - |
|
1480 | - |
|
1481 | - /** METABOXES * */ |
|
1482 | - /** |
|
1483 | - * _register_event_editor_meta_boxes |
|
1484 | - * add all metaboxes related to the event_editor |
|
1485 | - * |
|
1486 | - * @return void |
|
1487 | - */ |
|
1488 | - protected function _register_event_editor_meta_boxes() |
|
1489 | - { |
|
1490 | - $this->verify_cpt_object(); |
|
1491 | - add_meta_box( |
|
1492 | - 'espresso_event_editor_tickets', |
|
1493 | - esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1494 | - array($this, 'ticket_metabox'), |
|
1495 | - $this->page_slug, |
|
1496 | - 'normal', |
|
1497 | - 'high' |
|
1498 | - ); |
|
1499 | - add_meta_box( |
|
1500 | - 'espresso_event_editor_event_options', |
|
1501 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
1502 | - array($this, 'registration_options_meta_box'), |
|
1503 | - $this->page_slug, |
|
1504 | - 'side', |
|
1505 | - 'default' |
|
1506 | - ); |
|
1507 | - // NOTE: if you're looking for other metaboxes in here, |
|
1508 | - // where a metabox has a related management page in the admin |
|
1509 | - // you will find it setup in the related management page's "_Hooks" file. |
|
1510 | - // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
1511 | - } |
|
1512 | - |
|
1513 | - |
|
1514 | - |
|
1515 | - public function ticket_metabox() |
|
1516 | - { |
|
1517 | - $existing_datetime_ids = $existing_ticket_ids = array(); |
|
1518 | - //defaults for template args |
|
1519 | - $template_args = array( |
|
1520 | - 'existing_datetime_ids' => '', |
|
1521 | - 'event_datetime_help_link' => '', |
|
1522 | - 'ticket_options_help_link' => '', |
|
1523 | - 'time' => null, |
|
1524 | - 'ticket_rows' => '', |
|
1525 | - 'existing_ticket_ids' => '', |
|
1526 | - 'total_ticket_rows' => 1, |
|
1527 | - 'ticket_js_structure' => '', |
|
1528 | - 'trash_icon' => 'ee-lock-icon', |
|
1529 | - 'disabled' => '', |
|
1530 | - ); |
|
1531 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1532 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1533 | - /** |
|
1534 | - * 1. Start with retrieving Datetimes |
|
1535 | - * 2. Fore each datetime get related tickets |
|
1536 | - * 3. For each ticket get related prices |
|
1537 | - */ |
|
1538 | - $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1539 | - /** @type EE_Datetime $first_datetime */ |
|
1540 | - $first_datetime = reset($times); |
|
1541 | - //do we get related tickets? |
|
1542 | - if ($first_datetime instanceof EE_Datetime |
|
1543 | - && $first_datetime->ID() !== 0 |
|
1544 | - ) { |
|
1545 | - $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1546 | - $template_args['time'] = $first_datetime; |
|
1547 | - $related_tickets = $first_datetime->tickets( |
|
1548 | - array( |
|
1549 | - array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1550 | - 'default_where_conditions' => 'none', |
|
1551 | - ) |
|
1552 | - ); |
|
1553 | - if ( ! empty($related_tickets)) { |
|
1554 | - $template_args['total_ticket_rows'] = count($related_tickets); |
|
1555 | - $row = 0; |
|
1556 | - foreach ($related_tickets as $ticket) { |
|
1557 | - $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1558 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1559 | - $row++; |
|
1560 | - } |
|
1561 | - } else { |
|
1562 | - $template_args['total_ticket_rows'] = 1; |
|
1563 | - /** @type EE_Ticket $ticket */ |
|
1564 | - $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1565 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1566 | - } |
|
1567 | - } else { |
|
1568 | - $template_args['time'] = $times[0]; |
|
1569 | - /** @type EE_Ticket $ticket */ |
|
1570 | - $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1571 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1572 | - // NOTE: we're just sending the first default row |
|
1573 | - // (decaf can't manage default tickets so this should be sufficient); |
|
1574 | - } |
|
1575 | - $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
1576 | - 'event_editor_event_datetimes_help_tab' |
|
1577 | - ); |
|
1578 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1579 | - $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1580 | - $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1581 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
1582 | - EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1583 | - true |
|
1584 | - ); |
|
1585 | - $template = apply_filters( |
|
1586 | - 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
1587 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1588 | - ); |
|
1589 | - EEH_Template::display_template($template, $template_args); |
|
1590 | - } |
|
1591 | - |
|
1592 | - |
|
1593 | - |
|
1594 | - /** |
|
1595 | - * Setup an individual ticket form for the decaf event editor page |
|
1596 | - * |
|
1597 | - * @access private |
|
1598 | - * @param EE_Ticket $ticket the ticket object |
|
1599 | - * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
1600 | - * @param int $row |
|
1601 | - * @return string generated html for the ticket row. |
|
1602 | - */ |
|
1603 | - private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
1604 | - { |
|
1605 | - $template_args = array( |
|
1606 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1607 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
1608 | - : '', |
|
1609 | - 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
1610 | - 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1611 | - 'TKT_name' => $ticket->get('TKT_name'), |
|
1612 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1613 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1614 | - 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1615 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1616 | - 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
1617 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1618 | - 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1619 | - && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1620 | - ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1621 | - 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1622 | - : ' disabled=disabled', |
|
1623 | - ); |
|
1624 | - $price = $ticket->ID() !== 0 |
|
1625 | - ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1626 | - : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1627 | - $price_args = array( |
|
1628 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
1629 | - 'PRC_amount' => $price->get('PRC_amount'), |
|
1630 | - 'PRT_ID' => $price->get('PRT_ID'), |
|
1631 | - 'PRC_ID' => $price->get('PRC_ID'), |
|
1632 | - 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1633 | - ); |
|
1634 | - //make sure we have default start and end dates if skeleton |
|
1635 | - //handle rows that should NOT be empty |
|
1636 | - if (empty($template_args['TKT_start_date'])) { |
|
1637 | - //if empty then the start date will be now. |
|
1638 | - $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1639 | - } |
|
1640 | - if (empty($template_args['TKT_end_date'])) { |
|
1641 | - //get the earliest datetime (if present); |
|
1642 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
1643 | - ? $this->_cpt_model_obj->get_first_related( |
|
1644 | - 'Datetime', |
|
1645 | - array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1646 | - ) |
|
1647 | - : null; |
|
1648 | - if ( ! empty($earliest_dtt)) { |
|
1649 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1650 | - } else { |
|
1651 | - $template_args['TKT_end_date'] = date( |
|
1652 | - 'Y-m-d h:i a', |
|
1653 | - mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1654 | - ); |
|
1655 | - } |
|
1656 | - } |
|
1657 | - $template_args = array_merge($template_args, $price_args); |
|
1658 | - $template = apply_filters( |
|
1659 | - 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
1660 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1661 | - $ticket |
|
1662 | - ); |
|
1663 | - return EEH_Template::display_template($template, $template_args, true); |
|
1664 | - } |
|
1665 | - |
|
1666 | - |
|
1667 | - |
|
1668 | - public function registration_options_meta_box() |
|
1669 | - { |
|
1670 | - $yes_no_values = array( |
|
1671 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1672 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1673 | - ); |
|
1674 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
1675 | - array( |
|
1676 | - EEM_Registration::status_id_cancelled, |
|
1677 | - EEM_Registration::status_id_declined, |
|
1678 | - EEM_Registration::status_id_incomplete, |
|
1679 | - ), |
|
1680 | - true |
|
1681 | - ); |
|
1682 | - //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
1683 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
1684 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1685 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
1686 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
1687 | - 'default_reg_status', |
|
1688 | - $default_reg_status_values, |
|
1689 | - $this->_cpt_model_obj->default_registration_status() |
|
1690 | - ); |
|
1691 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1692 | - 'display_desc', |
|
1693 | - $yes_no_values, |
|
1694 | - $this->_cpt_model_obj->display_description() |
|
1695 | - ); |
|
1696 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1697 | - 'display_ticket_selector', |
|
1698 | - $yes_no_values, |
|
1699 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
1700 | - '', |
|
1701 | - '', |
|
1702 | - false |
|
1703 | - ); |
|
1704 | - $template_args['additional_registration_options'] = apply_filters( |
|
1705 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1706 | - '', |
|
1707 | - $template_args, |
|
1708 | - $yes_no_values, |
|
1709 | - $default_reg_status_values |
|
1710 | - ); |
|
1711 | - EEH_Template::display_template( |
|
1712 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1713 | - $template_args |
|
1714 | - ); |
|
1715 | - } |
|
1716 | - |
|
1717 | - |
|
1718 | - |
|
1719 | - /** |
|
1720 | - * _get_events() |
|
1721 | - * This method simply returns all the events (for the given _view and paging) |
|
1722 | - * |
|
1723 | - * @access public |
|
1724 | - * @param int $per_page count of items per page (20 default); |
|
1725 | - * @param int $current_page what is the current page being viewed. |
|
1726 | - * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
1727 | - * If FALSE then we return an array of event objects |
|
1728 | - * that match the given _view and paging parameters. |
|
1729 | - * @return array an array of event objects. |
|
1730 | - */ |
|
1731 | - public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
1732 | - { |
|
1733 | - $EEME = $this->_event_model(); |
|
1734 | - $offset = ($current_page - 1) * $per_page; |
|
1735 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1736 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1737 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1738 | - if (isset($this->_req_data['month_range'])) { |
|
1739 | - $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1740 | - $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1741 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1742 | - } |
|
1743 | - $where = array(); |
|
1744 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1745 | - //determine what post_status our condition will have for the query. |
|
1746 | - switch ($status) { |
|
1747 | - case 'month' : |
|
1748 | - case 'today' : |
|
1749 | - case null : |
|
1750 | - case 'all' : |
|
1751 | - break; |
|
1752 | - case 'draft' : |
|
1753 | - $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1754 | - break; |
|
1755 | - default : |
|
1756 | - $where['status'] = $status; |
|
1757 | - } |
|
1758 | - //categories? |
|
1759 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1760 | - ? $this->_req_data['EVT_CAT'] : null; |
|
1761 | - if ( ! empty ($category)) { |
|
1762 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1763 | - $where['Term_Taxonomy.term_id'] = $category; |
|
1764 | - } |
|
1765 | - //date where conditions |
|
1766 | - $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1767 | - if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1768 | - $DateTime = new DateTime( |
|
1769 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1770 | - new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1771 | - ); |
|
1772 | - $start = $DateTime->format(implode(' ', $start_formats)); |
|
1773 | - $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
1774 | - ->format('t'))->setTime(23, 59, 59) |
|
1775 | - ->format(implode(' ', $start_formats)); |
|
1776 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1777 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1778 | - $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1779 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1780 | - $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1781 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1782 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1783 | - $now = date('Y-m-01'); |
|
1784 | - $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1785 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1786 | - $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1787 | - ->setTime(23, 59, 59) |
|
1788 | - ->format(implode(' ', $start_formats)); |
|
1789 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1790 | - } |
|
1791 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1792 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1793 | - } else { |
|
1794 | - if ( ! isset($where['status'])) { |
|
1795 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1796 | - $where['OR'] = array( |
|
1797 | - 'status*restrict_private' => array('!=', 'private'), |
|
1798 | - 'AND' => array( |
|
1799 | - 'status*inclusive' => array('=', 'private'), |
|
1800 | - 'EVT_wp_user' => get_current_user_id(), |
|
1801 | - ), |
|
1802 | - ); |
|
1803 | - } |
|
1804 | - } |
|
1805 | - } |
|
1806 | - if (isset($this->_req_data['EVT_wp_user'])) { |
|
1807 | - if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1808 | - && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1809 | - ) { |
|
1810 | - $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
1811 | - } |
|
1812 | - } |
|
1813 | - //search query handling |
|
1814 | - if (isset($this->_req_data['s'])) { |
|
1815 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1816 | - $where['OR'] = array( |
|
1817 | - 'EVT_name' => array('LIKE', $search_string), |
|
1818 | - 'EVT_desc' => array('LIKE', $search_string), |
|
1819 | - 'EVT_short_desc' => array('LIKE', $search_string), |
|
1820 | - ); |
|
1821 | - } |
|
1822 | - $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1823 | - $query_params = apply_filters( |
|
1824 | - 'FHEE__Events_Admin_Page__get_events__query_params', |
|
1825 | - array( |
|
1826 | - $where, |
|
1827 | - 'limit' => $limit, |
|
1828 | - 'order_by' => $orderby, |
|
1829 | - 'order' => $order, |
|
1830 | - 'group_by' => 'EVT_ID', |
|
1831 | - ), |
|
1832 | - $this->_req_data |
|
1833 | - ); |
|
1834 | - //let's first check if we have special requests coming in. |
|
1835 | - if (isset($this->_req_data['active_status'])) { |
|
1836 | - switch ($this->_req_data['active_status']) { |
|
1837 | - case 'upcoming' : |
|
1838 | - return $EEME->get_upcoming_events($query_params, $count); |
|
1839 | - break; |
|
1840 | - case 'expired' : |
|
1841 | - return $EEME->get_expired_events($query_params, $count); |
|
1842 | - break; |
|
1843 | - case 'active' : |
|
1844 | - return $EEME->get_active_events($query_params, $count); |
|
1845 | - break; |
|
1846 | - case 'inactive' : |
|
1847 | - return $EEME->get_inactive_events($query_params, $count); |
|
1848 | - break; |
|
1849 | - } |
|
1850 | - } |
|
1851 | - $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1852 | - return $events; |
|
1853 | - } |
|
1854 | - |
|
1855 | - |
|
1856 | - |
|
1857 | - /** |
|
1858 | - * handling for WordPress CPT actions (trash, restore, delete) |
|
1859 | - * |
|
1860 | - * @param string $post_id |
|
1861 | - */ |
|
1862 | - public function trash_cpt_item($post_id) |
|
1863 | - { |
|
1864 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1865 | - $this->_trash_or_restore_event('trash', false); |
|
1866 | - } |
|
1867 | - |
|
1868 | - |
|
1869 | - |
|
1870 | - /** |
|
1871 | - * @param string $post_id |
|
1872 | - */ |
|
1873 | - public function restore_cpt_item($post_id) |
|
1874 | - { |
|
1875 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1876 | - $this->_trash_or_restore_event('draft', false); |
|
1877 | - } |
|
1878 | - |
|
1879 | - |
|
1880 | - |
|
1881 | - /** |
|
1882 | - * @param string $post_id |
|
1883 | - */ |
|
1884 | - public function delete_cpt_item($post_id) |
|
1885 | - { |
|
1886 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1887 | - $this->_delete_event(false); |
|
1888 | - } |
|
1889 | - |
|
1890 | - |
|
1891 | - |
|
1892 | - /** |
|
1893 | - * _trash_or_restore_event |
|
1894 | - * |
|
1895 | - * @access protected |
|
1896 | - * @param string $event_status |
|
1897 | - * @param bool $redirect_after |
|
1898 | - */ |
|
1899 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
1900 | - { |
|
1901 | - //determine the event id and set to array. |
|
1902 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1903 | - // loop thru events |
|
1904 | - if ($EVT_ID) { |
|
1905 | - // clean status |
|
1906 | - $event_status = sanitize_key($event_status); |
|
1907 | - // grab status |
|
1908 | - if ( ! empty($event_status)) { |
|
1909 | - $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1910 | - } else { |
|
1911 | - $success = false; |
|
1912 | - $msg = esc_html__( |
|
1913 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1914 | - 'event_espresso' |
|
1915 | - ); |
|
1916 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1917 | - } |
|
1918 | - } else { |
|
1919 | - $success = false; |
|
1920 | - $msg = esc_html__( |
|
1921 | - 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
1922 | - 'event_espresso' |
|
1923 | - ); |
|
1924 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1925 | - } |
|
1926 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1927 | - if ($redirect_after) { |
|
1928 | - $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1929 | - } |
|
1930 | - } |
|
1931 | - |
|
1932 | - |
|
1933 | - |
|
1934 | - /** |
|
1935 | - * _trash_or_restore_events |
|
1936 | - * |
|
1937 | - * @access protected |
|
1938 | - * @param string $event_status |
|
1939 | - * @return void |
|
1940 | - */ |
|
1941 | - protected function _trash_or_restore_events($event_status = 'trash') |
|
1942 | - { |
|
1943 | - // clean status |
|
1944 | - $event_status = sanitize_key($event_status); |
|
1945 | - // grab status |
|
1946 | - if ( ! empty($event_status)) { |
|
1947 | - $success = true; |
|
1948 | - //determine the event id and set to array. |
|
1949 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1950 | - // loop thru events |
|
1951 | - foreach ($EVT_IDs as $EVT_ID) { |
|
1952 | - if ($EVT_ID = absint($EVT_ID)) { |
|
1953 | - $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1954 | - $success = $results !== false ? $success : false; |
|
1955 | - } else { |
|
1956 | - $msg = sprintf( |
|
1957 | - esc_html__( |
|
1958 | - 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
1959 | - 'event_espresso' |
|
1960 | - ), |
|
1961 | - $EVT_ID |
|
1962 | - ); |
|
1963 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1964 | - $success = false; |
|
1965 | - } |
|
1966 | - } |
|
1967 | - } else { |
|
1968 | - $success = false; |
|
1969 | - $msg = esc_html__( |
|
1970 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1971 | - 'event_espresso' |
|
1972 | - ); |
|
1973 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1974 | - } |
|
1975 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1976 | - $success = $success ? 2 : false; |
|
1977 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1978 | - $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1979 | - } |
|
1980 | - |
|
1981 | - |
|
1982 | - |
|
1983 | - /** |
|
1984 | - * _trash_or_restore_events |
|
1985 | - * |
|
1986 | - * @access private |
|
1987 | - * @param int $EVT_ID |
|
1988 | - * @param string $event_status |
|
1989 | - * @return bool |
|
1990 | - */ |
|
1991 | - private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
1992 | - { |
|
1993 | - // grab event id |
|
1994 | - if ( ! $EVT_ID) { |
|
1995 | - $msg = esc_html__( |
|
1996 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
1997 | - 'event_espresso' |
|
1998 | - ); |
|
1999 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2000 | - return false; |
|
2001 | - } |
|
2002 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2003 | - // clean status |
|
2004 | - $event_status = sanitize_key($event_status); |
|
2005 | - // grab status |
|
2006 | - if (empty($event_status)) { |
|
2007 | - $msg = esc_html__( |
|
2008 | - 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
2009 | - 'event_espresso' |
|
2010 | - ); |
|
2011 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2012 | - return false; |
|
2013 | - } |
|
2014 | - // was event trashed or restored ? |
|
2015 | - switch ($event_status) { |
|
2016 | - case 'draft' : |
|
2017 | - $action = 'restored from the trash'; |
|
2018 | - $hook = 'AHEE_event_restored_from_trash'; |
|
2019 | - break; |
|
2020 | - case 'trash' : |
|
2021 | - $action = 'moved to the trash'; |
|
2022 | - $hook = 'AHEE_event_moved_to_trash'; |
|
2023 | - break; |
|
2024 | - default : |
|
2025 | - $action = 'updated'; |
|
2026 | - $hook = false; |
|
2027 | - } |
|
2028 | - //use class to change status |
|
2029 | - $this->_cpt_model_obj->set_status($event_status); |
|
2030 | - $success = $this->_cpt_model_obj->save(); |
|
2031 | - if ($success === false) { |
|
2032 | - $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
2033 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2034 | - return false; |
|
2035 | - } |
|
2036 | - if ($hook) { |
|
2037 | - do_action($hook); |
|
2038 | - } |
|
2039 | - return true; |
|
2040 | - } |
|
2041 | - |
|
2042 | - |
|
2043 | - |
|
2044 | - /** |
|
2045 | - * _delete_event |
|
2046 | - * |
|
2047 | - * @access protected |
|
2048 | - * @param bool $redirect_after |
|
2049 | - */ |
|
2050 | - protected function _delete_event($redirect_after = true) |
|
2051 | - { |
|
2052 | - //determine the event id and set to array. |
|
2053 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
2054 | - $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
2055 | - // loop thru events |
|
2056 | - if ($EVT_ID) { |
|
2057 | - $success = $this->_permanently_delete_event($EVT_ID); |
|
2058 | - // get list of events with no prices |
|
2059 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2060 | - // remove this event from the list of events with no prices |
|
2061 | - if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
2062 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2063 | - } |
|
2064 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2065 | - } else { |
|
2066 | - $success = false; |
|
2067 | - $msg = esc_html__( |
|
2068 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2069 | - 'event_espresso' |
|
2070 | - ); |
|
2071 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2072 | - } |
|
2073 | - if ($redirect_after) { |
|
2074 | - $this->_redirect_after_action( |
|
2075 | - $success, |
|
2076 | - 'Event', |
|
2077 | - 'deleted', |
|
2078 | - array('action' => 'default', 'status' => 'trash') |
|
2079 | - ); |
|
2080 | - } |
|
2081 | - } |
|
2082 | - |
|
2083 | - |
|
2084 | - |
|
2085 | - /** |
|
2086 | - * _delete_events |
|
2087 | - * |
|
2088 | - * @access protected |
|
2089 | - * @return void |
|
2090 | - */ |
|
2091 | - protected function _delete_events() |
|
2092 | - { |
|
2093 | - $success = true; |
|
2094 | - // get list of events with no prices |
|
2095 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2096 | - //determine the event id and set to array. |
|
2097 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2098 | - // loop thru events |
|
2099 | - foreach ($EVT_IDs as $EVT_ID) { |
|
2100 | - $EVT_ID = absint($EVT_ID); |
|
2101 | - if ($EVT_ID) { |
|
2102 | - $results = $this->_permanently_delete_event($EVT_ID); |
|
2103 | - $success = $results !== false ? $success : false; |
|
2104 | - // remove this event from the list of events with no prices |
|
2105 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2106 | - } else { |
|
2107 | - $success = false; |
|
2108 | - $msg = esc_html__( |
|
2109 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2110 | - 'event_espresso' |
|
2111 | - ); |
|
2112 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2113 | - } |
|
2114 | - } |
|
2115 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2116 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
2117 | - $success = $success ? 2 : false; |
|
2118 | - $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2119 | - } |
|
2120 | - |
|
2121 | - |
|
2122 | - |
|
2123 | - /** |
|
2124 | - * _permanently_delete_event |
|
2125 | - * |
|
2126 | - * @access private |
|
2127 | - * @param int $EVT_ID |
|
2128 | - * @return bool |
|
2129 | - */ |
|
2130 | - private function _permanently_delete_event($EVT_ID = 0) |
|
2131 | - { |
|
2132 | - // grab event id |
|
2133 | - if ( ! $EVT_ID) { |
|
2134 | - $msg = esc_html__( |
|
2135 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2136 | - 'event_espresso' |
|
2137 | - ); |
|
2138 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2139 | - return false; |
|
2140 | - } |
|
2141 | - if ( |
|
2142 | - ! $this->_cpt_model_obj instanceof EE_Event |
|
2143 | - || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
2144 | - ) { |
|
2145 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2146 | - } |
|
2147 | - if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2148 | - return false; |
|
2149 | - } |
|
2150 | - //need to delete related tickets and prices first. |
|
2151 | - $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2152 | - foreach ($datetimes as $datetime) { |
|
2153 | - $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2154 | - $tickets = $datetime->get_many_related('Ticket'); |
|
2155 | - foreach ($tickets as $ticket) { |
|
2156 | - $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2157 | - $ticket->delete_related_permanently('Price'); |
|
2158 | - $ticket->delete_permanently(); |
|
2159 | - } |
|
2160 | - $datetime->delete(); |
|
2161 | - } |
|
2162 | - //what about related venues or terms? |
|
2163 | - $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2164 | - foreach ($venues as $venue) { |
|
2165 | - $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2166 | - } |
|
2167 | - //any attached question groups? |
|
2168 | - $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2169 | - if ( ! empty($question_groups)) { |
|
2170 | - foreach ($question_groups as $question_group) { |
|
2171 | - $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2172 | - } |
|
2173 | - } |
|
2174 | - //Message Template Groups |
|
2175 | - $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2176 | - /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
2177 | - $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
2178 | - foreach ($term_taxonomies as $term_taxonomy) { |
|
2179 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2180 | - } |
|
2181 | - $success = $this->_cpt_model_obj->delete_permanently(); |
|
2182 | - // did it all go as planned ? |
|
2183 | - if ($success) { |
|
2184 | - $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2185 | - EE_Error::add_success($msg); |
|
2186 | - } else { |
|
2187 | - $msg = sprintf( |
|
2188 | - esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2189 | - $EVT_ID |
|
2190 | - ); |
|
2191 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2192 | - return false; |
|
2193 | - } |
|
2194 | - do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2195 | - return true; |
|
2196 | - } |
|
2197 | - |
|
2198 | - |
|
2199 | - |
|
2200 | - /** |
|
2201 | - * get total number of events |
|
2202 | - * |
|
2203 | - * @access public |
|
2204 | - * @return int |
|
2205 | - */ |
|
2206 | - public function total_events() |
|
2207 | - { |
|
2208 | - $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2209 | - return $count; |
|
2210 | - } |
|
2211 | - |
|
2212 | - |
|
2213 | - |
|
2214 | - /** |
|
2215 | - * get total number of draft events |
|
2216 | - * |
|
2217 | - * @access public |
|
2218 | - * @return int |
|
2219 | - */ |
|
2220 | - public function total_events_draft() |
|
2221 | - { |
|
2222 | - $where = array( |
|
2223 | - 'status' => array('IN', array('draft', 'auto-draft')), |
|
2224 | - ); |
|
2225 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2226 | - return $count; |
|
2227 | - } |
|
2228 | - |
|
2229 | - |
|
2230 | - |
|
2231 | - /** |
|
2232 | - * get total number of trashed events |
|
2233 | - * |
|
2234 | - * @access public |
|
2235 | - * @return int |
|
2236 | - */ |
|
2237 | - public function total_trashed_events() |
|
2238 | - { |
|
2239 | - $where = array( |
|
2240 | - 'status' => 'trash', |
|
2241 | - ); |
|
2242 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2243 | - return $count; |
|
2244 | - } |
|
2245 | - |
|
2246 | - |
|
2247 | - |
|
2248 | - /** |
|
2249 | - * _default_event_settings |
|
2250 | - * This generates the Default Settings Tab |
|
2251 | - * |
|
2252 | - * @return void |
|
2253 | - */ |
|
2254 | - protected function _default_event_settings() |
|
2255 | - { |
|
2256 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
2257 | - $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array( |
|
2258 | - // exclude array |
|
2259 | - array( |
|
2260 | - EEM_Registration::status_id_cancelled, |
|
2261 | - EEM_Registration::status_id_declined, |
|
2262 | - EEM_Registration::status_id_incomplete, |
|
2263 | - EEM_Registration::status_id_wait_list, |
|
2264 | - ), |
|
2265 | - // translated |
|
2266 | - true |
|
2267 | - ); |
|
2268 | - $this->_template_args['default_reg_status'] = isset( |
|
2269 | - EE_Registry::instance()->CFG->registration->default_STS_ID |
|
2270 | - ) |
|
2271 | - && array_key_exists( |
|
2272 | - EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
2273 | - $this->_template_args['reg_status_array'] |
|
2274 | - ) |
|
2275 | - ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2276 | - : EEM_Registration::status_id_pending_payment; |
|
2277 | - $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2278 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2279 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2280 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2281 | - $this->_template_args, |
|
2282 | - true |
|
2283 | - ); |
|
2284 | - $this->display_admin_page_with_sidebar(); |
|
2285 | - } |
|
2286 | - |
|
2287 | - |
|
2288 | - |
|
2289 | - /** |
|
2290 | - * _update_default_event_settings |
|
2291 | - * |
|
2292 | - * @access protected |
|
2293 | - * @return void |
|
2294 | - */ |
|
2295 | - protected function _update_default_event_settings() |
|
2296 | - { |
|
2297 | - EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2298 | - ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2299 | - : EEM_Registration::status_id_pending_payment; |
|
2300 | - $what = 'Default Event Settings'; |
|
2301 | - $success = $this->_update_espresso_configuration( |
|
2302 | - $what, |
|
2303 | - EE_Config::instance(), |
|
2304 | - __FILE__, |
|
2305 | - __FUNCTION__, |
|
2306 | - __LINE__ |
|
2307 | - ); |
|
2308 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2309 | - } |
|
2310 | - |
|
2311 | - |
|
2312 | - |
|
2313 | - /************* Templates *************/ |
|
2314 | - protected function _template_settings() |
|
2315 | - { |
|
2316 | - $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2317 | - $this->_template_args['preview_img'] = '<img src="' |
|
2318 | - . EVENTS_ASSETS_URL |
|
2319 | - . DS |
|
2320 | - . 'images' |
|
2321 | - . DS |
|
2322 | - . 'caffeinated_template_features.jpg" alt="' |
|
2323 | - . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2324 | - . '" />'; |
|
2325 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2326 | - 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
2327 | - 'event_espresso' |
|
2328 | - ) . '</strong>'; |
|
2329 | - $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2330 | - } |
|
2331 | - |
|
2332 | - |
|
2333 | - /** Event Category Stuff **/ |
|
2334 | - /** |
|
2335 | - * set the _category property with the category object for the loaded page. |
|
2336 | - * |
|
2337 | - * @access private |
|
2338 | - * @return void |
|
2339 | - */ |
|
2340 | - private function _set_category_object() |
|
2341 | - { |
|
2342 | - if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2343 | - return; |
|
2344 | - } //already have the category object so get out. |
|
2345 | - //set default category object |
|
2346 | - $this->_set_empty_category_object(); |
|
2347 | - //only set if we've got an id |
|
2348 | - if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2349 | - return; |
|
2350 | - } |
|
2351 | - $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2352 | - $term = get_term($category_id, 'espresso_event_categories'); |
|
2353 | - if ( ! empty($term)) { |
|
2354 | - $this->_category->category_name = $term->name; |
|
2355 | - $this->_category->category_identifier = $term->slug; |
|
2356 | - $this->_category->category_desc = $term->description; |
|
2357 | - $this->_category->id = $term->term_id; |
|
2358 | - $this->_category->parent = $term->parent; |
|
2359 | - } |
|
2360 | - } |
|
2361 | - |
|
2362 | - |
|
2363 | - |
|
2364 | - private function _set_empty_category_object() |
|
2365 | - { |
|
2366 | - $this->_category = new stdClass(); |
|
2367 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2368 | - $this->_category->id = $this->_category->parent = 0; |
|
2369 | - } |
|
2370 | - |
|
2371 | - |
|
2372 | - |
|
2373 | - protected function _category_list_table() |
|
2374 | - { |
|
2375 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2376 | - $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2377 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2378 | - 'add_category', |
|
2379 | - 'add_category', |
|
2380 | - array(), |
|
2381 | - 'add-new-h2' |
|
2382 | - ); |
|
2383 | - $this->display_admin_list_table_page_with_sidebar(); |
|
2384 | - } |
|
2385 | - |
|
2386 | - |
|
2387 | - |
|
2388 | - /** |
|
2389 | - * @param $view |
|
2390 | - */ |
|
2391 | - protected function _category_details($view) |
|
2392 | - { |
|
2393 | - //load formatter helper |
|
2394 | - //load field generator helper |
|
2395 | - $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
2396 | - $this->_set_add_edit_form_tags($route); |
|
2397 | - $this->_set_category_object(); |
|
2398 | - $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2399 | - $delete_action = 'delete_category'; |
|
2400 | - //custom redirect |
|
2401 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
2402 | - array('action' => 'category_list'), |
|
2403 | - $this->_admin_base_url |
|
2404 | - ); |
|
2405 | - $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2406 | - //take care of contents |
|
2407 | - $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
2408 | - $this->display_admin_page_with_sidebar(); |
|
2409 | - } |
|
2410 | - |
|
2411 | - |
|
2412 | - |
|
2413 | - /** |
|
2414 | - * @return mixed |
|
2415 | - */ |
|
2416 | - protected function _category_details_content() |
|
2417 | - { |
|
2418 | - $editor_args['category_desc'] = array( |
|
2419 | - 'type' => 'wp_editor', |
|
2420 | - 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2421 | - 'class' => 'my_editor_custom', |
|
2422 | - 'wpeditor_args' => array('media_buttons' => false), |
|
2423 | - ); |
|
2424 | - $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2425 | - $all_terms = get_terms( |
|
2426 | - array('espresso_event_categories'), |
|
2427 | - array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2428 | - ); |
|
2429 | - //setup category select for term parents. |
|
2430 | - $category_select_values[] = array( |
|
2431 | - 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2432 | - 'id' => 0, |
|
2433 | - ); |
|
2434 | - foreach ($all_terms as $term) { |
|
2435 | - $category_select_values[] = array( |
|
2436 | - 'text' => $term->name, |
|
2437 | - 'id' => $term->term_id, |
|
2438 | - ); |
|
2439 | - } |
|
2440 | - $category_select = EEH_Form_Fields::select_input( |
|
2441 | - 'category_parent', |
|
2442 | - $category_select_values, |
|
2443 | - $this->_category->parent |
|
2444 | - ); |
|
2445 | - $template_args = array( |
|
2446 | - 'category' => $this->_category, |
|
2447 | - 'category_select' => $category_select, |
|
2448 | - 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2449 | - 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
2450 | - 'disable' => '', |
|
2451 | - 'disabled_message' => false, |
|
2452 | - ); |
|
2453 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2454 | - return EEH_Template::display_template($template, $template_args, true); |
|
2455 | - } |
|
2456 | - |
|
2457 | - |
|
2458 | - |
|
2459 | - protected function _delete_categories() |
|
2460 | - { |
|
2461 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2462 | - : (array)$this->_req_data['category_id']; |
|
2463 | - foreach ($cat_ids as $cat_id) { |
|
2464 | - $this->_delete_category($cat_id); |
|
2465 | - } |
|
2466 | - //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
2467 | - $query_args = array( |
|
2468 | - 'action' => 'category_list', |
|
2469 | - ); |
|
2470 | - $this->_redirect_after_action(0, '', '', $query_args); |
|
2471 | - } |
|
2472 | - |
|
2473 | - |
|
2474 | - |
|
2475 | - /** |
|
2476 | - * @param $cat_id |
|
2477 | - */ |
|
2478 | - protected function _delete_category($cat_id) |
|
2479 | - { |
|
2480 | - $cat_id = absint($cat_id); |
|
2481 | - wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2482 | - } |
|
2483 | - |
|
2484 | - |
|
2485 | - |
|
2486 | - /** |
|
2487 | - * @param $new_category |
|
2488 | - */ |
|
2489 | - protected function _insert_or_update_category($new_category) |
|
2490 | - { |
|
2491 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2492 | - $success = 0; //we already have a success message so lets not send another. |
|
2493 | - if ($cat_id) { |
|
2494 | - $query_args = array( |
|
2495 | - 'action' => 'edit_category', |
|
2496 | - 'EVT_CAT_ID' => $cat_id, |
|
2497 | - ); |
|
2498 | - } else { |
|
2499 | - $query_args = array('action' => 'add_category'); |
|
2500 | - } |
|
2501 | - $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2502 | - } |
|
2503 | - |
|
2504 | - |
|
2505 | - |
|
2506 | - /** |
|
2507 | - * @param bool $update |
|
2508 | - * @return bool|mixed|string |
|
2509 | - */ |
|
2510 | - private function _insert_category($update = false) |
|
2511 | - { |
|
2512 | - $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
2513 | - $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2514 | - $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2515 | - $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2516 | - if (empty($category_name)) { |
|
2517 | - $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2518 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2519 | - return false; |
|
2520 | - } |
|
2521 | - $term_args = array( |
|
2522 | - 'name' => $category_name, |
|
2523 | - 'description' => $category_desc, |
|
2524 | - 'parent' => $category_parent, |
|
2525 | - ); |
|
2526 | - //was the category_identifier input disabled? |
|
2527 | - if (isset($this->_req_data['category_identifier'])) { |
|
2528 | - $term_args['slug'] = $this->_req_data['category_identifier']; |
|
2529 | - } |
|
2530 | - $insert_ids = $update |
|
2531 | - ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2532 | - : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2533 | - if ( ! is_array($insert_ids)) { |
|
2534 | - $msg = esc_html__( |
|
2535 | - 'An error occurred and the category has not been saved to the database.', |
|
2536 | - 'event_espresso' |
|
2537 | - ); |
|
2538 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2539 | - } else { |
|
2540 | - $cat_id = $insert_ids['term_id']; |
|
2541 | - $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2542 | - EE_Error::add_success($msg); |
|
2543 | - } |
|
2544 | - return $cat_id; |
|
2545 | - } |
|
2546 | - |
|
2547 | - |
|
2548 | - |
|
2549 | - /** |
|
2550 | - * @param int $per_page |
|
2551 | - * @param int $current_page |
|
2552 | - * @param bool $count |
|
2553 | - * @return \EE_Base_Class[]|int |
|
2554 | - */ |
|
2555 | - public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
2556 | - { |
|
2557 | - //testing term stuff |
|
2558 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2559 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2560 | - $limit = ($current_page - 1) * $per_page; |
|
2561 | - $where = array('taxonomy' => 'espresso_event_categories'); |
|
2562 | - if (isset($this->_req_data['s'])) { |
|
2563 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2564 | - $where['OR'] = array( |
|
2565 | - 'Term.name' => array('LIKE', $sstr), |
|
2566 | - 'description' => array('LIKE', $sstr), |
|
2567 | - ); |
|
2568 | - } |
|
2569 | - $query_params = array( |
|
2570 | - $where, |
|
2571 | - 'order_by' => array($orderby => $order), |
|
2572 | - 'limit' => $limit . ',' . $per_page, |
|
2573 | - 'force_join' => array('Term'), |
|
2574 | - ); |
|
2575 | - $categories = $count |
|
2576 | - ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2577 | - : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2578 | - return $categories; |
|
2579 | - } |
|
2580 | - |
|
2581 | - |
|
2582 | - |
|
2583 | - /* end category stuff */ |
|
2584 | - /**************/ |
|
385 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
386 | + 'require_nonce' => false, |
|
387 | + ), |
|
388 | + 'default_event_settings' => array( |
|
389 | + 'nav' => array( |
|
390 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
391 | + 'order' => 40, |
|
392 | + ), |
|
393 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
394 | + 'labels' => array( |
|
395 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
396 | + ), |
|
397 | + 'help_tabs' => array( |
|
398 | + 'default_settings_help_tab' => array( |
|
399 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
400 | + 'filename' => 'events_default_settings', |
|
401 | + ), |
|
402 | + 'default_settings_status_help_tab' => array( |
|
403 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
404 | + 'filename' => 'events_default_settings_status', |
|
405 | + ), |
|
406 | + ), |
|
407 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
408 | + 'require_nonce' => false, |
|
409 | + ), |
|
410 | + //template settings |
|
411 | + 'template_settings' => array( |
|
412 | + 'nav' => array( |
|
413 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
414 | + 'order' => 30, |
|
415 | + ), |
|
416 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
417 | + 'help_tabs' => array( |
|
418 | + 'general_settings_templates_help_tab' => array( |
|
419 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
420 | + 'filename' => 'general_settings_templates', |
|
421 | + ), |
|
422 | + ), |
|
423 | + 'help_tour' => array('Templates_Help_Tour'), |
|
424 | + 'require_nonce' => false, |
|
425 | + ), |
|
426 | + //event category stuff |
|
427 | + 'add_category' => array( |
|
428 | + 'nav' => array( |
|
429 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
430 | + 'order' => 15, |
|
431 | + 'persistent' => false, |
|
432 | + ), |
|
433 | + 'help_tabs' => array( |
|
434 | + 'add_category_help_tab' => array( |
|
435 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
436 | + 'filename' => 'events_add_category', |
|
437 | + ), |
|
438 | + ), |
|
439 | + 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
440 | + 'metaboxes' => array('_publish_post_box'), |
|
441 | + 'require_nonce' => false, |
|
442 | + ), |
|
443 | + 'edit_category' => array( |
|
444 | + 'nav' => array( |
|
445 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
446 | + 'order' => 15, |
|
447 | + 'persistent' => false, |
|
448 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
449 | + ? add_query_arg( |
|
450 | + array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
451 | + $this->_current_page_view_url |
|
452 | + ) |
|
453 | + : $this->_admin_base_url, |
|
454 | + ), |
|
455 | + 'help_tabs' => array( |
|
456 | + 'edit_category_help_tab' => array( |
|
457 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
458 | + 'filename' => 'events_edit_category', |
|
459 | + ), |
|
460 | + ), |
|
461 | + /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
462 | + 'metaboxes' => array('_publish_post_box'), |
|
463 | + 'require_nonce' => false, |
|
464 | + ), |
|
465 | + 'category_list' => array( |
|
466 | + 'nav' => array( |
|
467 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
468 | + 'order' => 20, |
|
469 | + ), |
|
470 | + 'list_table' => 'Event_Categories_Admin_List_Table', |
|
471 | + 'help_tabs' => array( |
|
472 | + 'events_categories_help_tab' => array( |
|
473 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
474 | + 'filename' => 'events_categories', |
|
475 | + ), |
|
476 | + 'events_categories_table_column_headings_help_tab' => array( |
|
477 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
478 | + 'filename' => 'events_categories_table_column_headings', |
|
479 | + ), |
|
480 | + 'events_categories_view_help_tab' => array( |
|
481 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
482 | + 'filename' => 'events_categories_views', |
|
483 | + ), |
|
484 | + 'events_categories_other_help_tab' => array( |
|
485 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
486 | + 'filename' => 'events_categories_other', |
|
487 | + ), |
|
488 | + ), |
|
489 | + 'help_tour' => array( |
|
490 | + 'Event_Categories_Help_Tour', |
|
491 | + ), |
|
492 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
493 | + 'require_nonce' => false, |
|
494 | + ), |
|
495 | + ); |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + |
|
500 | + protected function _add_screen_options() |
|
501 | + { |
|
502 | + //todo |
|
503 | + } |
|
504 | + |
|
505 | + |
|
506 | + |
|
507 | + protected function _add_screen_options_default() |
|
508 | + { |
|
509 | + $this->_per_page_screen_option(); |
|
510 | + } |
|
511 | + |
|
512 | + |
|
513 | + |
|
514 | + protected function _add_screen_options_category_list() |
|
515 | + { |
|
516 | + $page_title = $this->_admin_page_title; |
|
517 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
518 | + $this->_per_page_screen_option(); |
|
519 | + $this->_admin_page_title = $page_title; |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + |
|
524 | + protected function _add_feature_pointers() |
|
525 | + { |
|
526 | + //todo |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + |
|
531 | + public function load_scripts_styles() |
|
532 | + { |
|
533 | + wp_register_style( |
|
534 | + 'events-admin-css', |
|
535 | + EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
536 | + array(), |
|
537 | + EVENT_ESPRESSO_VERSION |
|
538 | + ); |
|
539 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
540 | + wp_enqueue_style('events-admin-css'); |
|
541 | + wp_enqueue_style('ee-cat-admin'); |
|
542 | + //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
543 | + //registers for all views |
|
544 | + //scripts |
|
545 | + wp_register_script( |
|
546 | + 'event_editor_js', |
|
547 | + EVENTS_ASSETS_URL . 'event_editor.js', |
|
548 | + array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
549 | + EVENT_ESPRESSO_VERSION, |
|
550 | + true |
|
551 | + ); |
|
552 | + } |
|
553 | + |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * enqueuing scripts and styles specific to this view |
|
558 | + * |
|
559 | + * @return void |
|
560 | + */ |
|
561 | + public function load_scripts_styles_create_new() |
|
562 | + { |
|
563 | + $this->load_scripts_styles_edit(); |
|
564 | + } |
|
565 | + |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * enqueuing scripts and styles specific to this view |
|
570 | + * |
|
571 | + * @return void |
|
572 | + */ |
|
573 | + public function load_scripts_styles_edit() |
|
574 | + { |
|
575 | + //styles |
|
576 | + wp_enqueue_style('espresso-ui-theme'); |
|
577 | + wp_register_style( |
|
578 | + 'event-editor-css', |
|
579 | + EVENTS_ASSETS_URL . 'event-editor.css', |
|
580 | + array('ee-admin-css'), |
|
581 | + EVENT_ESPRESSO_VERSION |
|
582 | + ); |
|
583 | + wp_enqueue_style('event-editor-css'); |
|
584 | + //scripts |
|
585 | + wp_register_script( |
|
586 | + 'event-datetime-metabox', |
|
587 | + EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
588 | + array('event_editor_js', 'ee-datepicker'), |
|
589 | + EVENT_ESPRESSO_VERSION |
|
590 | + ); |
|
591 | + wp_enqueue_script('event-datetime-metabox'); |
|
592 | + } |
|
593 | + |
|
594 | + |
|
595 | + |
|
596 | + public function load_scripts_styles_add_category() |
|
597 | + { |
|
598 | + $this->load_scripts_styles_edit_category(); |
|
599 | + } |
|
600 | + |
|
601 | + |
|
602 | + |
|
603 | + public function load_scripts_styles_edit_category() |
|
604 | + { |
|
605 | + } |
|
606 | + |
|
607 | + |
|
608 | + |
|
609 | + protected function _set_list_table_views_category_list() |
|
610 | + { |
|
611 | + $this->_views = array( |
|
612 | + 'all' => array( |
|
613 | + 'slug' => 'all', |
|
614 | + 'label' => esc_html__('All', 'event_espresso'), |
|
615 | + 'count' => 0, |
|
616 | + 'bulk_action' => array( |
|
617 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
618 | + ), |
|
619 | + ), |
|
620 | + ); |
|
621 | + } |
|
622 | + |
|
623 | + |
|
624 | + |
|
625 | + public function admin_init() |
|
626 | + { |
|
627 | + EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
628 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
629 | + 'event_espresso' |
|
630 | + ); |
|
631 | + } |
|
632 | + |
|
633 | + |
|
634 | + |
|
635 | + //nothing needed for events with these methods. |
|
636 | + public function admin_notices() |
|
637 | + { |
|
638 | + } |
|
639 | + |
|
640 | + |
|
641 | + |
|
642 | + public function admin_footer_scripts() |
|
643 | + { |
|
644 | + } |
|
645 | + |
|
646 | + |
|
647 | + |
|
648 | + /** |
|
649 | + * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
650 | + * warning (via EE_Error::add_error()); |
|
651 | + * |
|
652 | + * @param EE_Event $event Event object |
|
653 | + * @access public |
|
654 | + * @return void |
|
655 | + */ |
|
656 | + public function verify_event_edit($event = null) |
|
657 | + { |
|
658 | + // no event? |
|
659 | + if (empty($event)) { |
|
660 | + // set event |
|
661 | + $event = $this->_cpt_model_obj; |
|
662 | + } |
|
663 | + // STILL no event? |
|
664 | + if (empty ($event)) { |
|
665 | + return; |
|
666 | + } |
|
667 | + $orig_status = $event->status(); |
|
668 | + // first check if event is active. |
|
669 | + if ( |
|
670 | + $orig_status === EEM_Event::cancelled |
|
671 | + || $orig_status === EEM_Event::postponed |
|
672 | + || $event->is_expired() |
|
673 | + || $event->is_inactive() |
|
674 | + ) { |
|
675 | + return; |
|
676 | + } |
|
677 | + //made it here so it IS active... next check that any of the tickets are sold. |
|
678 | + if ($event->is_sold_out(true)) { |
|
679 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
680 | + EE_Error::add_attention( |
|
681 | + sprintf( |
|
682 | + esc_html__( |
|
683 | + 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
684 | + 'event_espresso' |
|
685 | + ), |
|
686 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
687 | + ) |
|
688 | + ); |
|
689 | + } |
|
690 | + return; |
|
691 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
692 | + EE_Error::add_attention( |
|
693 | + sprintf( |
|
694 | + esc_html__( |
|
695 | + 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
696 | + 'event_espresso' |
|
697 | + ), |
|
698 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
699 | + ) |
|
700 | + ); |
|
701 | + } |
|
702 | + //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
703 | + if ( ! $event->tickets_on_sale()) { |
|
704 | + return; |
|
705 | + } |
|
706 | + //made it here so show warning |
|
707 | + $this->_edit_event_warning(); |
|
708 | + } |
|
709 | + |
|
710 | + |
|
711 | + |
|
712 | + /** |
|
713 | + * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
714 | + * When needed, hook this into a EE_Error::add_error() notice. |
|
715 | + * |
|
716 | + * @access protected |
|
717 | + * @return void |
|
718 | + */ |
|
719 | + protected function _edit_event_warning() |
|
720 | + { |
|
721 | + // we don't want to add warnings during these requests |
|
722 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
723 | + return; |
|
724 | + } |
|
725 | + EE_Error::add_attention( |
|
726 | + esc_html__( |
|
727 | + 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
728 | + 'event_espresso' |
|
729 | + ) |
|
730 | + ); |
|
731 | + } |
|
732 | + |
|
733 | + |
|
734 | + |
|
735 | + /** |
|
736 | + * When a user is creating a new event, notify them if they haven't set their timezone. |
|
737 | + * Otherwise, do the normal logic |
|
738 | + * |
|
739 | + * @return string |
|
740 | + * @throws \EE_Error |
|
741 | + */ |
|
742 | + protected function _create_new_cpt_item() |
|
743 | + { |
|
744 | + $gmt_offset = get_option('gmt_offset'); |
|
745 | + //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
746 | + if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
747 | + EE_Error::add_attention( |
|
748 | + sprintf( |
|
749 | + __( |
|
750 | + 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.', |
|
751 | + 'event_espresso' |
|
752 | + ), |
|
753 | + '<a href="' . admin_url('options-general.php') . '">', |
|
754 | + '</a>' |
|
755 | + ), |
|
756 | + __FILE__, |
|
757 | + __FUNCTION__, |
|
758 | + __LINE__ |
|
759 | + ); |
|
760 | + } |
|
761 | + return parent::_create_new_cpt_item(); |
|
762 | + } |
|
763 | + |
|
764 | + |
|
765 | + |
|
766 | + protected function _set_list_table_views_default() |
|
767 | + { |
|
768 | + $this->_views = array( |
|
769 | + 'all' => array( |
|
770 | + 'slug' => 'all', |
|
771 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
772 | + 'count' => 0, |
|
773 | + 'bulk_action' => array( |
|
774 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
775 | + ), |
|
776 | + ), |
|
777 | + 'draft' => array( |
|
778 | + 'slug' => 'draft', |
|
779 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
780 | + 'count' => 0, |
|
781 | + 'bulk_action' => array( |
|
782 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
783 | + ), |
|
784 | + ), |
|
785 | + ); |
|
786 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
787 | + $this->_views['trash'] = array( |
|
788 | + 'slug' => 'trash', |
|
789 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
790 | + 'count' => 0, |
|
791 | + 'bulk_action' => array( |
|
792 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
793 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
794 | + ), |
|
795 | + ); |
|
796 | + } |
|
797 | + } |
|
798 | + |
|
799 | + |
|
800 | + |
|
801 | + /** |
|
802 | + * @return array |
|
803 | + */ |
|
804 | + protected function _event_legend_items() |
|
805 | + { |
|
806 | + $items = array( |
|
807 | + 'view_details' => array( |
|
808 | + 'class' => 'dashicons dashicons-search', |
|
809 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
810 | + ), |
|
811 | + 'edit_event' => array( |
|
812 | + 'class' => 'ee-icon ee-icon-calendar-edit', |
|
813 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
814 | + ), |
|
815 | + 'view_attendees' => array( |
|
816 | + 'class' => 'dashicons dashicons-groups', |
|
817 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
818 | + ), |
|
819 | + ); |
|
820 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
821 | + $statuses = array( |
|
822 | + 'sold_out_status' => array( |
|
823 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
824 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
825 | + ), |
|
826 | + 'active_status' => array( |
|
827 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
828 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
829 | + ), |
|
830 | + 'upcoming_status' => array( |
|
831 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
832 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
833 | + ), |
|
834 | + 'postponed_status' => array( |
|
835 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
836 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
837 | + ), |
|
838 | + 'cancelled_status' => array( |
|
839 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
840 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
841 | + ), |
|
842 | + 'expired_status' => array( |
|
843 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
844 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
845 | + ), |
|
846 | + 'inactive_status' => array( |
|
847 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
848 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
849 | + ), |
|
850 | + ); |
|
851 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
852 | + return array_merge($items, $statuses); |
|
853 | + } |
|
854 | + |
|
855 | + |
|
856 | + |
|
857 | + /** |
|
858 | + * _event_model |
|
859 | + * |
|
860 | + * @return EEM_Event |
|
861 | + */ |
|
862 | + private function _event_model() |
|
863 | + { |
|
864 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
865 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
866 | + } |
|
867 | + return $this->_event_model; |
|
868 | + } |
|
869 | + |
|
870 | + |
|
871 | + |
|
872 | + /** |
|
873 | + * Adds extra buttons to the WP CPT permalink field row. |
|
874 | + * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
875 | + * |
|
876 | + * @param string $return the current html |
|
877 | + * @param int $id the post id for the page |
|
878 | + * @param string $new_title What the title is |
|
879 | + * @param string $new_slug what the slug is |
|
880 | + * @return string The new html string for the permalink area |
|
881 | + */ |
|
882 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
883 | + { |
|
884 | + //make sure this is only when editing |
|
885 | + if ( ! empty($id)) { |
|
886 | + $post = get_post($id); |
|
887 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
888 | + . esc_html__('Shortcode', 'event_espresso') |
|
889 | + . '</a> '; |
|
890 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
891 | + . $post->ID |
|
892 | + . ']">'; |
|
893 | + } |
|
894 | + return $return; |
|
895 | + } |
|
896 | + |
|
897 | + |
|
898 | + |
|
899 | + /** |
|
900 | + * _events_overview_list_table |
|
901 | + * This contains the logic for showing the events_overview list |
|
902 | + * |
|
903 | + * @access protected |
|
904 | + * @return void |
|
905 | + * @throws \EE_Error |
|
906 | + */ |
|
907 | + protected function _events_overview_list_table() |
|
908 | + { |
|
909 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
910 | + $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
911 | + ? (array)$this->_template_args['after_list_table'] |
|
912 | + : array(); |
|
913 | + $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
914 | + . EEH_Template::get_button_or_link( |
|
915 | + get_post_type_archive_link('espresso_events'), |
|
916 | + esc_html__("View Event Archive Page", "event_espresso"), |
|
917 | + 'button' |
|
918 | + ); |
|
919 | + $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
920 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
921 | + 'create_new', |
|
922 | + 'add', |
|
923 | + array(), |
|
924 | + 'add-new-h2' |
|
925 | + ); |
|
926 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
927 | + } |
|
928 | + |
|
929 | + |
|
930 | + |
|
931 | + /** |
|
932 | + * this allows for extra misc actions in the default WP publish box |
|
933 | + * |
|
934 | + * @return void |
|
935 | + */ |
|
936 | + public function extra_misc_actions_publish_box() |
|
937 | + { |
|
938 | + $this->_generate_publish_box_extra_content(); |
|
939 | + } |
|
940 | + |
|
941 | + |
|
942 | + |
|
943 | + /** |
|
944 | + * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been saved. Child classes are required to declare this method. Typically you would use this to save any additional data. |
|
945 | + * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
946 | + * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that you |
|
947 | + * handle this accordingly. |
|
948 | + * |
|
949 | + * @access protected |
|
950 | + * @abstract |
|
951 | + * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
952 | + * @param object $post The post object of the cpt that was saved. |
|
953 | + * @return void |
|
954 | + */ |
|
955 | + protected function _insert_update_cpt_item($post_id, $post) |
|
956 | + { |
|
957 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
958 | + //get out we're not processing an event save. |
|
959 | + return; |
|
960 | + } |
|
961 | + $event_values = array( |
|
962 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
963 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
964 | + 'EVT_additional_limit' => min( |
|
965 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
966 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
967 | + ), |
|
968 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
969 | + ? $this->_req_data['EVT_default_registration_status'] |
|
970 | + : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
971 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
972 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
973 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
974 | + ? $this->_req_data['timezone_string'] : null, |
|
975 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
976 | + ? $this->_req_data['externalURL'] : null, |
|
977 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
978 | + ? $this->_req_data['event_phone'] : null, |
|
979 | + ); |
|
980 | + //update event |
|
981 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
982 | + //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
|
983 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
984 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
985 | + //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
986 | + $event_update_callbacks = apply_filters( |
|
987 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
988 | + array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
989 | + ); |
|
990 | + $att_success = true; |
|
991 | + foreach ($event_update_callbacks as $e_callback) { |
|
992 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
993 | + $att_success = ! $att_success ? $att_success |
|
994 | + : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
995 | + } |
|
996 | + //any errors? |
|
997 | + if ($success && false === $att_success) { |
|
998 | + EE_Error::add_error( |
|
999 | + esc_html__( |
|
1000 | + 'Event Details saved successfully but something went wrong with saving attachments.', |
|
1001 | + 'event_espresso' |
|
1002 | + ), |
|
1003 | + __FILE__, |
|
1004 | + __FUNCTION__, |
|
1005 | + __LINE__ |
|
1006 | + ); |
|
1007 | + } else if ($success === false) { |
|
1008 | + EE_Error::add_error( |
|
1009 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
1010 | + __FILE__, |
|
1011 | + __FUNCTION__, |
|
1012 | + __LINE__ |
|
1013 | + ); |
|
1014 | + } |
|
1015 | + } |
|
1016 | + |
|
1017 | + |
|
1018 | + |
|
1019 | + /** |
|
1020 | + * @see parent::restore_item() |
|
1021 | + * @param int $post_id |
|
1022 | + * @param int $revision_id |
|
1023 | + */ |
|
1024 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
1025 | + { |
|
1026 | + //copy existing event meta to new post |
|
1027 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
1028 | + if ($post_evt instanceof EE_Event) { |
|
1029 | + //meta revision restore |
|
1030 | + $post_evt->restore_revision($revision_id); |
|
1031 | + //related objs restore |
|
1032 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
1033 | + } |
|
1034 | + } |
|
1035 | + |
|
1036 | + |
|
1037 | + |
|
1038 | + /** |
|
1039 | + * Attach the venue to the Event |
|
1040 | + * |
|
1041 | + * @param \EE_Event $evtobj Event Object to add the venue to |
|
1042 | + * @param array $data The request data from the form |
|
1043 | + * @return bool Success or fail. |
|
1044 | + */ |
|
1045 | + protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
1046 | + { |
|
1047 | + require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1048 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1049 | + $rows_affected = null; |
|
1050 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1051 | + // very important. If we don't have a venue name... |
|
1052 | + // then we'll get out because not necessary to create empty venue |
|
1053 | + if (empty($data['venue_title'])) { |
|
1054 | + return false; |
|
1055 | + } |
|
1056 | + $venue_array = array( |
|
1057 | + 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1058 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1059 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1060 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1061 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1062 | + : null, |
|
1063 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1064 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1065 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1066 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1067 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1068 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1069 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1070 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1071 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1072 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1073 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1074 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1075 | + 'status' => 'publish', |
|
1076 | + ); |
|
1077 | + //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
1078 | + if ( ! empty($venue_id)) { |
|
1079 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1080 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1081 | + //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
|
1082 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1083 | + return $rows_affected > 0 ? true : false; |
|
1084 | + } else { |
|
1085 | + //we insert the venue |
|
1086 | + $venue_id = $venue_model->insert($venue_array); |
|
1087 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1088 | + return ! empty($venue_id) ? true : false; |
|
1089 | + } |
|
1090 | + //when we have the ancestor come in it's already been handled by the revision save. |
|
1091 | + } |
|
1092 | + |
|
1093 | + |
|
1094 | + |
|
1095 | + /** |
|
1096 | + * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
1097 | + * |
|
1098 | + * @param EE_Event $evtobj The Event object we're attaching data to |
|
1099 | + * @param array $data The request data from the form |
|
1100 | + * @return array |
|
1101 | + */ |
|
1102 | + protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
1103 | + { |
|
1104 | + $success = true; |
|
1105 | + $saved_dtt = null; |
|
1106 | + $saved_tickets = array(); |
|
1107 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1108 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1109 | + //trim all values to ensure any excess whitespace is removed. |
|
1110 | + $dtt = array_map('trim', $dtt); |
|
1111 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1112 | + : $dtt['DTT_EVT_start']; |
|
1113 | + $datetime_values = array( |
|
1114 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1115 | + 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
1116 | + 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
1117 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1118 | + 'DTT_order' => $row, |
|
1119 | + ); |
|
1120 | + //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
|
1121 | + if ( ! empty($dtt['DTT_ID'])) { |
|
1122 | + $DTM = EE_Registry::instance() |
|
1123 | + ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1124 | + ->get_one_by_ID($dtt['DTT_ID']); |
|
1125 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1126 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1127 | + foreach ($datetime_values as $field => $value) { |
|
1128 | + $DTM->set($field, $value); |
|
1129 | + } |
|
1130 | + //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
|
1131 | + $saved_dtts[$DTM->ID()] = $DTM; |
|
1132 | + } else { |
|
1133 | + $DTM = EE_Registry::instance()->load_class( |
|
1134 | + 'Datetime', |
|
1135 | + array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
1136 | + false, |
|
1137 | + false |
|
1138 | + ); |
|
1139 | + foreach ($datetime_values as $field => $value) { |
|
1140 | + $DTM->set($field, $value); |
|
1141 | + } |
|
1142 | + } |
|
1143 | + $DTM->save(); |
|
1144 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1145 | + //load DTT helper |
|
1146 | + //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1147 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1148 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1149 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1150 | + $DTT->save(); |
|
1151 | + } |
|
1152 | + //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
|
1153 | + $saved_dtt = $DTT; |
|
1154 | + $success = ! $success ? $success : $DTT; |
|
1155 | + //if ANY of these updates fail then we want the appropriate global error message. |
|
1156 | + // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
1157 | + } |
|
1158 | + //no dtts get deleted so we don't do any of that logic here. |
|
1159 | + //update tickets next |
|
1160 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1161 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1162 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1163 | + $update_prices = false; |
|
1164 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1165 | + ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1166 | + // trim inputs to ensure any excess whitespace is removed. |
|
1167 | + $tkt = array_map('trim', $tkt); |
|
1168 | + if (empty($tkt['TKT_start_date'])) { |
|
1169 | + //let's use now in the set timezone. |
|
1170 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1171 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1172 | + } |
|
1173 | + if (empty($tkt['TKT_end_date'])) { |
|
1174 | + //use the start date of the first datetime |
|
1175 | + $dtt = $evtobj->first_datetime(); |
|
1176 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
1177 | + $incoming_date_formats[0], |
|
1178 | + $incoming_date_formats[1] |
|
1179 | + ); |
|
1180 | + } |
|
1181 | + $TKT_values = array( |
|
1182 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1183 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1184 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1185 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1186 | + 'TKT_start_date' => $tkt['TKT_start_date'], |
|
1187 | + 'TKT_end_date' => $tkt['TKT_end_date'], |
|
1188 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1189 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1190 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1191 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1192 | + 'TKT_row' => $row, |
|
1193 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1194 | + 'TKT_price' => $ticket_price, |
|
1195 | + ); |
|
1196 | + //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
|
1197 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1198 | + $TKT_values['TKT_ID'] = 0; |
|
1199 | + $TKT_values['TKT_is_default'] = 0; |
|
1200 | + $TKT_values['TKT_price'] = $ticket_price; |
|
1201 | + $update_prices = true; |
|
1202 | + } |
|
1203 | + //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
1204 | + //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
|
1205 | + //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
1206 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1207 | + $TKT = EE_Registry::instance() |
|
1208 | + ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1209 | + ->get_one_by_ID($tkt['TKT_ID']); |
|
1210 | + if ($TKT instanceof EE_Ticket) { |
|
1211 | + $ticket_sold = $TKT->count_related( |
|
1212 | + 'Registration', |
|
1213 | + array( |
|
1214 | + array( |
|
1215 | + 'STS_ID' => array( |
|
1216 | + 'NOT IN', |
|
1217 | + array(EEM_Registration::status_id_incomplete), |
|
1218 | + ), |
|
1219 | + ), |
|
1220 | + ) |
|
1221 | + ) > 0 ? true : false; |
|
1222 | + //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
|
1223 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1224 | + && ! $TKT->get( |
|
1225 | + 'TKT_deleted' |
|
1226 | + ) ? true : false; |
|
1227 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1228 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1229 | + //set new values |
|
1230 | + foreach ($TKT_values as $field => $value) { |
|
1231 | + if ($field == 'TKT_qty') { |
|
1232 | + $TKT->set_qty($value); |
|
1233 | + } else { |
|
1234 | + $TKT->set($field, $value); |
|
1235 | + } |
|
1236 | + } |
|
1237 | + //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
1238 | + if ($create_new_TKT) { |
|
1239 | + //archive the old ticket first |
|
1240 | + $TKT->set('TKT_deleted', 1); |
|
1241 | + $TKT->save(); |
|
1242 | + //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
1243 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1244 | + //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
|
1245 | + $TKT = clone $TKT; |
|
1246 | + $TKT->set('TKT_ID', 0); |
|
1247 | + $TKT->set('TKT_deleted', 0); |
|
1248 | + $TKT->set('TKT_price', $ticket_price); |
|
1249 | + $TKT->set('TKT_sold', 0); |
|
1250 | + //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
1251 | + $update_prices = true; |
|
1252 | + } |
|
1253 | + //make sure price is set if it hasn't been already |
|
1254 | + $TKT->set('TKT_price', $ticket_price); |
|
1255 | + } |
|
1256 | + } else { |
|
1257 | + //no TKT_id so a new TKT |
|
1258 | + $TKT_values['TKT_price'] = $ticket_price; |
|
1259 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1260 | + if ($TKT instanceof EE_Ticket) { |
|
1261 | + //need to reset values to properly account for the date formats |
|
1262 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1263 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1264 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1265 | + //set new values |
|
1266 | + foreach ($TKT_values as $field => $value) { |
|
1267 | + if ($field == 'TKT_qty') { |
|
1268 | + $TKT->set_qty($value); |
|
1269 | + } else { |
|
1270 | + $TKT->set($field, $value); |
|
1271 | + } |
|
1272 | + } |
|
1273 | + $update_prices = true; |
|
1274 | + } |
|
1275 | + } |
|
1276 | + // cap ticket qty by datetime reg limits |
|
1277 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1278 | + //update ticket. |
|
1279 | + $TKT->save(); |
|
1280 | + //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1281 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1282 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1283 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1284 | + $TKT->save(); |
|
1285 | + } |
|
1286 | + //initially let's add the ticket to the dtt |
|
1287 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1288 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1289 | + //add prices to ticket |
|
1290 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1291 | + } |
|
1292 | + //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
1293 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1294 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1295 | + foreach ($tickets_removed as $id) { |
|
1296 | + $id = absint($id); |
|
1297 | + //get the ticket for this id |
|
1298 | + $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1299 | + //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
1300 | + $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1301 | + foreach ($dtts as $dtt) { |
|
1302 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1303 | + } |
|
1304 | + //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
1305 | + $tkt_to_remove->delete_related_permanently('Price'); |
|
1306 | + //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1307 | + $tkt_to_remove->delete_permanently(); |
|
1308 | + } |
|
1309 | + return array($saved_dtt, $saved_tickets); |
|
1310 | + } |
|
1311 | + |
|
1312 | + |
|
1313 | + |
|
1314 | + /** |
|
1315 | + * This attaches a list of given prices to a ticket. |
|
1316 | + * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
1317 | + * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
1318 | + * price info and prices are automatically "archived" via the ticket. |
|
1319 | + * |
|
1320 | + * @access private |
|
1321 | + * @param array $prices Array of prices from the form. |
|
1322 | + * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
1323 | + * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
1324 | + * @return void |
|
1325 | + */ |
|
1326 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
1327 | + { |
|
1328 | + foreach ($prices as $row => $prc) { |
|
1329 | + $PRC_values = array( |
|
1330 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1331 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1332 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1333 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1334 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1335 | + 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
1336 | + 'PRC_order' => $row, |
|
1337 | + ); |
|
1338 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1339 | + $PRC_values['PRC_ID'] = 0; |
|
1340 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1341 | + } else { |
|
1342 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1343 | + //update this price with new values |
|
1344 | + foreach ($PRC_values as $field => $newprc) { |
|
1345 | + $PRC->set($field, $newprc); |
|
1346 | + } |
|
1347 | + $PRC->save(); |
|
1348 | + } |
|
1349 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1350 | + } |
|
1351 | + } |
|
1352 | + |
|
1353 | + |
|
1354 | + |
|
1355 | + /** |
|
1356 | + * Add in our autosave ajax handlers |
|
1357 | + * |
|
1358 | + * @return void |
|
1359 | + */ |
|
1360 | + protected function _ee_autosave_create_new() |
|
1361 | + { |
|
1362 | + // $this->_ee_autosave_edit(); |
|
1363 | + } |
|
1364 | + |
|
1365 | + |
|
1366 | + |
|
1367 | + protected function _ee_autosave_edit() |
|
1368 | + { |
|
1369 | + return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
1370 | + } |
|
1371 | + |
|
1372 | + |
|
1373 | + |
|
1374 | + /** |
|
1375 | + * _generate_publish_box_extra_content |
|
1376 | + * |
|
1377 | + * @access private |
|
1378 | + * @return void |
|
1379 | + */ |
|
1380 | + private function _generate_publish_box_extra_content() |
|
1381 | + { |
|
1382 | + //load formatter helper |
|
1383 | + //args for getting related registrations |
|
1384 | + $approved_query_args = array( |
|
1385 | + array( |
|
1386 | + 'REG_deleted' => 0, |
|
1387 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
1388 | + ), |
|
1389 | + ); |
|
1390 | + $not_approved_query_args = array( |
|
1391 | + array( |
|
1392 | + 'REG_deleted' => 0, |
|
1393 | + 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
1394 | + ), |
|
1395 | + ); |
|
1396 | + $pending_payment_query_args = array( |
|
1397 | + array( |
|
1398 | + 'REG_deleted' => 0, |
|
1399 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
1400 | + ), |
|
1401 | + ); |
|
1402 | + // publish box |
|
1403 | + $publish_box_extra_args = array( |
|
1404 | + 'view_approved_reg_url' => add_query_arg( |
|
1405 | + array( |
|
1406 | + 'action' => 'default', |
|
1407 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1408 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1409 | + ), |
|
1410 | + REG_ADMIN_URL |
|
1411 | + ), |
|
1412 | + 'view_not_approved_reg_url' => add_query_arg( |
|
1413 | + array( |
|
1414 | + 'action' => 'default', |
|
1415 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1416 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1417 | + ), |
|
1418 | + REG_ADMIN_URL |
|
1419 | + ), |
|
1420 | + 'view_pending_payment_reg_url' => add_query_arg( |
|
1421 | + array( |
|
1422 | + 'action' => 'default', |
|
1423 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1424 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1425 | + ), |
|
1426 | + REG_ADMIN_URL |
|
1427 | + ), |
|
1428 | + 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
1429 | + 'Registration', |
|
1430 | + $approved_query_args |
|
1431 | + ), |
|
1432 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
1433 | + 'Registration', |
|
1434 | + $not_approved_query_args |
|
1435 | + ), |
|
1436 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
1437 | + 'Registration', |
|
1438 | + $pending_payment_query_args |
|
1439 | + ), |
|
1440 | + 'misc_pub_section_class' => apply_filters( |
|
1441 | + 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
1442 | + 'misc-pub-section' |
|
1443 | + ), |
|
1444 | + //'email_attendees_url' => add_query_arg( |
|
1445 | + // array( |
|
1446 | + // 'event_admin_reports' => 'event_newsletter', |
|
1447 | + // 'event_id' => $this->_cpt_model_obj->id |
|
1448 | + // ), |
|
1449 | + // 'admin.php?page=espresso_registrations' |
|
1450 | + //), |
|
1451 | + ); |
|
1452 | + ob_start(); |
|
1453 | + do_action( |
|
1454 | + 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
1455 | + $this->_cpt_model_obj |
|
1456 | + ); |
|
1457 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1458 | + // load template |
|
1459 | + EEH_Template::display_template( |
|
1460 | + EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1461 | + $publish_box_extra_args |
|
1462 | + ); |
|
1463 | + } |
|
1464 | + |
|
1465 | + |
|
1466 | + |
|
1467 | + /** |
|
1468 | + * This just returns whatever is set as the _event object property |
|
1469 | + * //todo this will become obsolete once the models are in place |
|
1470 | + * |
|
1471 | + * @return object |
|
1472 | + */ |
|
1473 | + public function get_event_object() |
|
1474 | + { |
|
1475 | + return $this->_cpt_model_obj; |
|
1476 | + } |
|
1477 | + |
|
1478 | + |
|
1479 | + |
|
1480 | + |
|
1481 | + /** METABOXES * */ |
|
1482 | + /** |
|
1483 | + * _register_event_editor_meta_boxes |
|
1484 | + * add all metaboxes related to the event_editor |
|
1485 | + * |
|
1486 | + * @return void |
|
1487 | + */ |
|
1488 | + protected function _register_event_editor_meta_boxes() |
|
1489 | + { |
|
1490 | + $this->verify_cpt_object(); |
|
1491 | + add_meta_box( |
|
1492 | + 'espresso_event_editor_tickets', |
|
1493 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1494 | + array($this, 'ticket_metabox'), |
|
1495 | + $this->page_slug, |
|
1496 | + 'normal', |
|
1497 | + 'high' |
|
1498 | + ); |
|
1499 | + add_meta_box( |
|
1500 | + 'espresso_event_editor_event_options', |
|
1501 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
1502 | + array($this, 'registration_options_meta_box'), |
|
1503 | + $this->page_slug, |
|
1504 | + 'side', |
|
1505 | + 'default' |
|
1506 | + ); |
|
1507 | + // NOTE: if you're looking for other metaboxes in here, |
|
1508 | + // where a metabox has a related management page in the admin |
|
1509 | + // you will find it setup in the related management page's "_Hooks" file. |
|
1510 | + // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
1511 | + } |
|
1512 | + |
|
1513 | + |
|
1514 | + |
|
1515 | + public function ticket_metabox() |
|
1516 | + { |
|
1517 | + $existing_datetime_ids = $existing_ticket_ids = array(); |
|
1518 | + //defaults for template args |
|
1519 | + $template_args = array( |
|
1520 | + 'existing_datetime_ids' => '', |
|
1521 | + 'event_datetime_help_link' => '', |
|
1522 | + 'ticket_options_help_link' => '', |
|
1523 | + 'time' => null, |
|
1524 | + 'ticket_rows' => '', |
|
1525 | + 'existing_ticket_ids' => '', |
|
1526 | + 'total_ticket_rows' => 1, |
|
1527 | + 'ticket_js_structure' => '', |
|
1528 | + 'trash_icon' => 'ee-lock-icon', |
|
1529 | + 'disabled' => '', |
|
1530 | + ); |
|
1531 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1532 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1533 | + /** |
|
1534 | + * 1. Start with retrieving Datetimes |
|
1535 | + * 2. Fore each datetime get related tickets |
|
1536 | + * 3. For each ticket get related prices |
|
1537 | + */ |
|
1538 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1539 | + /** @type EE_Datetime $first_datetime */ |
|
1540 | + $first_datetime = reset($times); |
|
1541 | + //do we get related tickets? |
|
1542 | + if ($first_datetime instanceof EE_Datetime |
|
1543 | + && $first_datetime->ID() !== 0 |
|
1544 | + ) { |
|
1545 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1546 | + $template_args['time'] = $first_datetime; |
|
1547 | + $related_tickets = $first_datetime->tickets( |
|
1548 | + array( |
|
1549 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1550 | + 'default_where_conditions' => 'none', |
|
1551 | + ) |
|
1552 | + ); |
|
1553 | + if ( ! empty($related_tickets)) { |
|
1554 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
1555 | + $row = 0; |
|
1556 | + foreach ($related_tickets as $ticket) { |
|
1557 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1558 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1559 | + $row++; |
|
1560 | + } |
|
1561 | + } else { |
|
1562 | + $template_args['total_ticket_rows'] = 1; |
|
1563 | + /** @type EE_Ticket $ticket */ |
|
1564 | + $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1565 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1566 | + } |
|
1567 | + } else { |
|
1568 | + $template_args['time'] = $times[0]; |
|
1569 | + /** @type EE_Ticket $ticket */ |
|
1570 | + $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1571 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1572 | + // NOTE: we're just sending the first default row |
|
1573 | + // (decaf can't manage default tickets so this should be sufficient); |
|
1574 | + } |
|
1575 | + $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
1576 | + 'event_editor_event_datetimes_help_tab' |
|
1577 | + ); |
|
1578 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1579 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1580 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1581 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
1582 | + EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1583 | + true |
|
1584 | + ); |
|
1585 | + $template = apply_filters( |
|
1586 | + 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
1587 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1588 | + ); |
|
1589 | + EEH_Template::display_template($template, $template_args); |
|
1590 | + } |
|
1591 | + |
|
1592 | + |
|
1593 | + |
|
1594 | + /** |
|
1595 | + * Setup an individual ticket form for the decaf event editor page |
|
1596 | + * |
|
1597 | + * @access private |
|
1598 | + * @param EE_Ticket $ticket the ticket object |
|
1599 | + * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
1600 | + * @param int $row |
|
1601 | + * @return string generated html for the ticket row. |
|
1602 | + */ |
|
1603 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
1604 | + { |
|
1605 | + $template_args = array( |
|
1606 | + 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1607 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
1608 | + : '', |
|
1609 | + 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
1610 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1611 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
1612 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1613 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1614 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1615 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1616 | + 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
1617 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1618 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1619 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1620 | + ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1621 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1622 | + : ' disabled=disabled', |
|
1623 | + ); |
|
1624 | + $price = $ticket->ID() !== 0 |
|
1625 | + ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1626 | + : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1627 | + $price_args = array( |
|
1628 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
1629 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
1630 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
1631 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
1632 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1633 | + ); |
|
1634 | + //make sure we have default start and end dates if skeleton |
|
1635 | + //handle rows that should NOT be empty |
|
1636 | + if (empty($template_args['TKT_start_date'])) { |
|
1637 | + //if empty then the start date will be now. |
|
1638 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1639 | + } |
|
1640 | + if (empty($template_args['TKT_end_date'])) { |
|
1641 | + //get the earliest datetime (if present); |
|
1642 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
1643 | + ? $this->_cpt_model_obj->get_first_related( |
|
1644 | + 'Datetime', |
|
1645 | + array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1646 | + ) |
|
1647 | + : null; |
|
1648 | + if ( ! empty($earliest_dtt)) { |
|
1649 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1650 | + } else { |
|
1651 | + $template_args['TKT_end_date'] = date( |
|
1652 | + 'Y-m-d h:i a', |
|
1653 | + mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1654 | + ); |
|
1655 | + } |
|
1656 | + } |
|
1657 | + $template_args = array_merge($template_args, $price_args); |
|
1658 | + $template = apply_filters( |
|
1659 | + 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
1660 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1661 | + $ticket |
|
1662 | + ); |
|
1663 | + return EEH_Template::display_template($template, $template_args, true); |
|
1664 | + } |
|
1665 | + |
|
1666 | + |
|
1667 | + |
|
1668 | + public function registration_options_meta_box() |
|
1669 | + { |
|
1670 | + $yes_no_values = array( |
|
1671 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1672 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1673 | + ); |
|
1674 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
1675 | + array( |
|
1676 | + EEM_Registration::status_id_cancelled, |
|
1677 | + EEM_Registration::status_id_declined, |
|
1678 | + EEM_Registration::status_id_incomplete, |
|
1679 | + ), |
|
1680 | + true |
|
1681 | + ); |
|
1682 | + //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
1683 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
1684 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1685 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
1686 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
1687 | + 'default_reg_status', |
|
1688 | + $default_reg_status_values, |
|
1689 | + $this->_cpt_model_obj->default_registration_status() |
|
1690 | + ); |
|
1691 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1692 | + 'display_desc', |
|
1693 | + $yes_no_values, |
|
1694 | + $this->_cpt_model_obj->display_description() |
|
1695 | + ); |
|
1696 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1697 | + 'display_ticket_selector', |
|
1698 | + $yes_no_values, |
|
1699 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
1700 | + '', |
|
1701 | + '', |
|
1702 | + false |
|
1703 | + ); |
|
1704 | + $template_args['additional_registration_options'] = apply_filters( |
|
1705 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1706 | + '', |
|
1707 | + $template_args, |
|
1708 | + $yes_no_values, |
|
1709 | + $default_reg_status_values |
|
1710 | + ); |
|
1711 | + EEH_Template::display_template( |
|
1712 | + EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1713 | + $template_args |
|
1714 | + ); |
|
1715 | + } |
|
1716 | + |
|
1717 | + |
|
1718 | + |
|
1719 | + /** |
|
1720 | + * _get_events() |
|
1721 | + * This method simply returns all the events (for the given _view and paging) |
|
1722 | + * |
|
1723 | + * @access public |
|
1724 | + * @param int $per_page count of items per page (20 default); |
|
1725 | + * @param int $current_page what is the current page being viewed. |
|
1726 | + * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
1727 | + * If FALSE then we return an array of event objects |
|
1728 | + * that match the given _view and paging parameters. |
|
1729 | + * @return array an array of event objects. |
|
1730 | + */ |
|
1731 | + public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
1732 | + { |
|
1733 | + $EEME = $this->_event_model(); |
|
1734 | + $offset = ($current_page - 1) * $per_page; |
|
1735 | + $limit = $count ? null : $offset . ',' . $per_page; |
|
1736 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1737 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1738 | + if (isset($this->_req_data['month_range'])) { |
|
1739 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1740 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1741 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1742 | + } |
|
1743 | + $where = array(); |
|
1744 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1745 | + //determine what post_status our condition will have for the query. |
|
1746 | + switch ($status) { |
|
1747 | + case 'month' : |
|
1748 | + case 'today' : |
|
1749 | + case null : |
|
1750 | + case 'all' : |
|
1751 | + break; |
|
1752 | + case 'draft' : |
|
1753 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1754 | + break; |
|
1755 | + default : |
|
1756 | + $where['status'] = $status; |
|
1757 | + } |
|
1758 | + //categories? |
|
1759 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1760 | + ? $this->_req_data['EVT_CAT'] : null; |
|
1761 | + if ( ! empty ($category)) { |
|
1762 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1763 | + $where['Term_Taxonomy.term_id'] = $category; |
|
1764 | + } |
|
1765 | + //date where conditions |
|
1766 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1767 | + if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1768 | + $DateTime = new DateTime( |
|
1769 | + $year_r . '-' . $month_r . '-01 00:00:00', |
|
1770 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1771 | + ); |
|
1772 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1773 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
1774 | + ->format('t'))->setTime(23, 59, 59) |
|
1775 | + ->format(implode(' ', $start_formats)); |
|
1776 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1777 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1778 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1779 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1780 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1781 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1782 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1783 | + $now = date('Y-m-01'); |
|
1784 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1785 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1786 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1787 | + ->setTime(23, 59, 59) |
|
1788 | + ->format(implode(' ', $start_formats)); |
|
1789 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1790 | + } |
|
1791 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1792 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1793 | + } else { |
|
1794 | + if ( ! isset($where['status'])) { |
|
1795 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1796 | + $where['OR'] = array( |
|
1797 | + 'status*restrict_private' => array('!=', 'private'), |
|
1798 | + 'AND' => array( |
|
1799 | + 'status*inclusive' => array('=', 'private'), |
|
1800 | + 'EVT_wp_user' => get_current_user_id(), |
|
1801 | + ), |
|
1802 | + ); |
|
1803 | + } |
|
1804 | + } |
|
1805 | + } |
|
1806 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1807 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1808 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1809 | + ) { |
|
1810 | + $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
1811 | + } |
|
1812 | + } |
|
1813 | + //search query handling |
|
1814 | + if (isset($this->_req_data['s'])) { |
|
1815 | + $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1816 | + $where['OR'] = array( |
|
1817 | + 'EVT_name' => array('LIKE', $search_string), |
|
1818 | + 'EVT_desc' => array('LIKE', $search_string), |
|
1819 | + 'EVT_short_desc' => array('LIKE', $search_string), |
|
1820 | + ); |
|
1821 | + } |
|
1822 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1823 | + $query_params = apply_filters( |
|
1824 | + 'FHEE__Events_Admin_Page__get_events__query_params', |
|
1825 | + array( |
|
1826 | + $where, |
|
1827 | + 'limit' => $limit, |
|
1828 | + 'order_by' => $orderby, |
|
1829 | + 'order' => $order, |
|
1830 | + 'group_by' => 'EVT_ID', |
|
1831 | + ), |
|
1832 | + $this->_req_data |
|
1833 | + ); |
|
1834 | + //let's first check if we have special requests coming in. |
|
1835 | + if (isset($this->_req_data['active_status'])) { |
|
1836 | + switch ($this->_req_data['active_status']) { |
|
1837 | + case 'upcoming' : |
|
1838 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1839 | + break; |
|
1840 | + case 'expired' : |
|
1841 | + return $EEME->get_expired_events($query_params, $count); |
|
1842 | + break; |
|
1843 | + case 'active' : |
|
1844 | + return $EEME->get_active_events($query_params, $count); |
|
1845 | + break; |
|
1846 | + case 'inactive' : |
|
1847 | + return $EEME->get_inactive_events($query_params, $count); |
|
1848 | + break; |
|
1849 | + } |
|
1850 | + } |
|
1851 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1852 | + return $events; |
|
1853 | + } |
|
1854 | + |
|
1855 | + |
|
1856 | + |
|
1857 | + /** |
|
1858 | + * handling for WordPress CPT actions (trash, restore, delete) |
|
1859 | + * |
|
1860 | + * @param string $post_id |
|
1861 | + */ |
|
1862 | + public function trash_cpt_item($post_id) |
|
1863 | + { |
|
1864 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1865 | + $this->_trash_or_restore_event('trash', false); |
|
1866 | + } |
|
1867 | + |
|
1868 | + |
|
1869 | + |
|
1870 | + /** |
|
1871 | + * @param string $post_id |
|
1872 | + */ |
|
1873 | + public function restore_cpt_item($post_id) |
|
1874 | + { |
|
1875 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1876 | + $this->_trash_or_restore_event('draft', false); |
|
1877 | + } |
|
1878 | + |
|
1879 | + |
|
1880 | + |
|
1881 | + /** |
|
1882 | + * @param string $post_id |
|
1883 | + */ |
|
1884 | + public function delete_cpt_item($post_id) |
|
1885 | + { |
|
1886 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1887 | + $this->_delete_event(false); |
|
1888 | + } |
|
1889 | + |
|
1890 | + |
|
1891 | + |
|
1892 | + /** |
|
1893 | + * _trash_or_restore_event |
|
1894 | + * |
|
1895 | + * @access protected |
|
1896 | + * @param string $event_status |
|
1897 | + * @param bool $redirect_after |
|
1898 | + */ |
|
1899 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
1900 | + { |
|
1901 | + //determine the event id and set to array. |
|
1902 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1903 | + // loop thru events |
|
1904 | + if ($EVT_ID) { |
|
1905 | + // clean status |
|
1906 | + $event_status = sanitize_key($event_status); |
|
1907 | + // grab status |
|
1908 | + if ( ! empty($event_status)) { |
|
1909 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1910 | + } else { |
|
1911 | + $success = false; |
|
1912 | + $msg = esc_html__( |
|
1913 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1914 | + 'event_espresso' |
|
1915 | + ); |
|
1916 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1917 | + } |
|
1918 | + } else { |
|
1919 | + $success = false; |
|
1920 | + $msg = esc_html__( |
|
1921 | + 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
1922 | + 'event_espresso' |
|
1923 | + ); |
|
1924 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1925 | + } |
|
1926 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1927 | + if ($redirect_after) { |
|
1928 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1929 | + } |
|
1930 | + } |
|
1931 | + |
|
1932 | + |
|
1933 | + |
|
1934 | + /** |
|
1935 | + * _trash_or_restore_events |
|
1936 | + * |
|
1937 | + * @access protected |
|
1938 | + * @param string $event_status |
|
1939 | + * @return void |
|
1940 | + */ |
|
1941 | + protected function _trash_or_restore_events($event_status = 'trash') |
|
1942 | + { |
|
1943 | + // clean status |
|
1944 | + $event_status = sanitize_key($event_status); |
|
1945 | + // grab status |
|
1946 | + if ( ! empty($event_status)) { |
|
1947 | + $success = true; |
|
1948 | + //determine the event id and set to array. |
|
1949 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1950 | + // loop thru events |
|
1951 | + foreach ($EVT_IDs as $EVT_ID) { |
|
1952 | + if ($EVT_ID = absint($EVT_ID)) { |
|
1953 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1954 | + $success = $results !== false ? $success : false; |
|
1955 | + } else { |
|
1956 | + $msg = sprintf( |
|
1957 | + esc_html__( |
|
1958 | + 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
1959 | + 'event_espresso' |
|
1960 | + ), |
|
1961 | + $EVT_ID |
|
1962 | + ); |
|
1963 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1964 | + $success = false; |
|
1965 | + } |
|
1966 | + } |
|
1967 | + } else { |
|
1968 | + $success = false; |
|
1969 | + $msg = esc_html__( |
|
1970 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1971 | + 'event_espresso' |
|
1972 | + ); |
|
1973 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1974 | + } |
|
1975 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1976 | + $success = $success ? 2 : false; |
|
1977 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1978 | + $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1979 | + } |
|
1980 | + |
|
1981 | + |
|
1982 | + |
|
1983 | + /** |
|
1984 | + * _trash_or_restore_events |
|
1985 | + * |
|
1986 | + * @access private |
|
1987 | + * @param int $EVT_ID |
|
1988 | + * @param string $event_status |
|
1989 | + * @return bool |
|
1990 | + */ |
|
1991 | + private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
1992 | + { |
|
1993 | + // grab event id |
|
1994 | + if ( ! $EVT_ID) { |
|
1995 | + $msg = esc_html__( |
|
1996 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
1997 | + 'event_espresso' |
|
1998 | + ); |
|
1999 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2000 | + return false; |
|
2001 | + } |
|
2002 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2003 | + // clean status |
|
2004 | + $event_status = sanitize_key($event_status); |
|
2005 | + // grab status |
|
2006 | + if (empty($event_status)) { |
|
2007 | + $msg = esc_html__( |
|
2008 | + 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
2009 | + 'event_espresso' |
|
2010 | + ); |
|
2011 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2012 | + return false; |
|
2013 | + } |
|
2014 | + // was event trashed or restored ? |
|
2015 | + switch ($event_status) { |
|
2016 | + case 'draft' : |
|
2017 | + $action = 'restored from the trash'; |
|
2018 | + $hook = 'AHEE_event_restored_from_trash'; |
|
2019 | + break; |
|
2020 | + case 'trash' : |
|
2021 | + $action = 'moved to the trash'; |
|
2022 | + $hook = 'AHEE_event_moved_to_trash'; |
|
2023 | + break; |
|
2024 | + default : |
|
2025 | + $action = 'updated'; |
|
2026 | + $hook = false; |
|
2027 | + } |
|
2028 | + //use class to change status |
|
2029 | + $this->_cpt_model_obj->set_status($event_status); |
|
2030 | + $success = $this->_cpt_model_obj->save(); |
|
2031 | + if ($success === false) { |
|
2032 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
2033 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2034 | + return false; |
|
2035 | + } |
|
2036 | + if ($hook) { |
|
2037 | + do_action($hook); |
|
2038 | + } |
|
2039 | + return true; |
|
2040 | + } |
|
2041 | + |
|
2042 | + |
|
2043 | + |
|
2044 | + /** |
|
2045 | + * _delete_event |
|
2046 | + * |
|
2047 | + * @access protected |
|
2048 | + * @param bool $redirect_after |
|
2049 | + */ |
|
2050 | + protected function _delete_event($redirect_after = true) |
|
2051 | + { |
|
2052 | + //determine the event id and set to array. |
|
2053 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
2054 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
2055 | + // loop thru events |
|
2056 | + if ($EVT_ID) { |
|
2057 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
2058 | + // get list of events with no prices |
|
2059 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2060 | + // remove this event from the list of events with no prices |
|
2061 | + if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
2062 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2063 | + } |
|
2064 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2065 | + } else { |
|
2066 | + $success = false; |
|
2067 | + $msg = esc_html__( |
|
2068 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2069 | + 'event_espresso' |
|
2070 | + ); |
|
2071 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2072 | + } |
|
2073 | + if ($redirect_after) { |
|
2074 | + $this->_redirect_after_action( |
|
2075 | + $success, |
|
2076 | + 'Event', |
|
2077 | + 'deleted', |
|
2078 | + array('action' => 'default', 'status' => 'trash') |
|
2079 | + ); |
|
2080 | + } |
|
2081 | + } |
|
2082 | + |
|
2083 | + |
|
2084 | + |
|
2085 | + /** |
|
2086 | + * _delete_events |
|
2087 | + * |
|
2088 | + * @access protected |
|
2089 | + * @return void |
|
2090 | + */ |
|
2091 | + protected function _delete_events() |
|
2092 | + { |
|
2093 | + $success = true; |
|
2094 | + // get list of events with no prices |
|
2095 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2096 | + //determine the event id and set to array. |
|
2097 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2098 | + // loop thru events |
|
2099 | + foreach ($EVT_IDs as $EVT_ID) { |
|
2100 | + $EVT_ID = absint($EVT_ID); |
|
2101 | + if ($EVT_ID) { |
|
2102 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
2103 | + $success = $results !== false ? $success : false; |
|
2104 | + // remove this event from the list of events with no prices |
|
2105 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2106 | + } else { |
|
2107 | + $success = false; |
|
2108 | + $msg = esc_html__( |
|
2109 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2110 | + 'event_espresso' |
|
2111 | + ); |
|
2112 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2113 | + } |
|
2114 | + } |
|
2115 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2116 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
2117 | + $success = $success ? 2 : false; |
|
2118 | + $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2119 | + } |
|
2120 | + |
|
2121 | + |
|
2122 | + |
|
2123 | + /** |
|
2124 | + * _permanently_delete_event |
|
2125 | + * |
|
2126 | + * @access private |
|
2127 | + * @param int $EVT_ID |
|
2128 | + * @return bool |
|
2129 | + */ |
|
2130 | + private function _permanently_delete_event($EVT_ID = 0) |
|
2131 | + { |
|
2132 | + // grab event id |
|
2133 | + if ( ! $EVT_ID) { |
|
2134 | + $msg = esc_html__( |
|
2135 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2136 | + 'event_espresso' |
|
2137 | + ); |
|
2138 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2139 | + return false; |
|
2140 | + } |
|
2141 | + if ( |
|
2142 | + ! $this->_cpt_model_obj instanceof EE_Event |
|
2143 | + || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
2144 | + ) { |
|
2145 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2146 | + } |
|
2147 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2148 | + return false; |
|
2149 | + } |
|
2150 | + //need to delete related tickets and prices first. |
|
2151 | + $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2152 | + foreach ($datetimes as $datetime) { |
|
2153 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2154 | + $tickets = $datetime->get_many_related('Ticket'); |
|
2155 | + foreach ($tickets as $ticket) { |
|
2156 | + $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2157 | + $ticket->delete_related_permanently('Price'); |
|
2158 | + $ticket->delete_permanently(); |
|
2159 | + } |
|
2160 | + $datetime->delete(); |
|
2161 | + } |
|
2162 | + //what about related venues or terms? |
|
2163 | + $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2164 | + foreach ($venues as $venue) { |
|
2165 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2166 | + } |
|
2167 | + //any attached question groups? |
|
2168 | + $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2169 | + if ( ! empty($question_groups)) { |
|
2170 | + foreach ($question_groups as $question_group) { |
|
2171 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2172 | + } |
|
2173 | + } |
|
2174 | + //Message Template Groups |
|
2175 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2176 | + /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
2177 | + $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
2178 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
2179 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2180 | + } |
|
2181 | + $success = $this->_cpt_model_obj->delete_permanently(); |
|
2182 | + // did it all go as planned ? |
|
2183 | + if ($success) { |
|
2184 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2185 | + EE_Error::add_success($msg); |
|
2186 | + } else { |
|
2187 | + $msg = sprintf( |
|
2188 | + esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2189 | + $EVT_ID |
|
2190 | + ); |
|
2191 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2192 | + return false; |
|
2193 | + } |
|
2194 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2195 | + return true; |
|
2196 | + } |
|
2197 | + |
|
2198 | + |
|
2199 | + |
|
2200 | + /** |
|
2201 | + * get total number of events |
|
2202 | + * |
|
2203 | + * @access public |
|
2204 | + * @return int |
|
2205 | + */ |
|
2206 | + public function total_events() |
|
2207 | + { |
|
2208 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2209 | + return $count; |
|
2210 | + } |
|
2211 | + |
|
2212 | + |
|
2213 | + |
|
2214 | + /** |
|
2215 | + * get total number of draft events |
|
2216 | + * |
|
2217 | + * @access public |
|
2218 | + * @return int |
|
2219 | + */ |
|
2220 | + public function total_events_draft() |
|
2221 | + { |
|
2222 | + $where = array( |
|
2223 | + 'status' => array('IN', array('draft', 'auto-draft')), |
|
2224 | + ); |
|
2225 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2226 | + return $count; |
|
2227 | + } |
|
2228 | + |
|
2229 | + |
|
2230 | + |
|
2231 | + /** |
|
2232 | + * get total number of trashed events |
|
2233 | + * |
|
2234 | + * @access public |
|
2235 | + * @return int |
|
2236 | + */ |
|
2237 | + public function total_trashed_events() |
|
2238 | + { |
|
2239 | + $where = array( |
|
2240 | + 'status' => 'trash', |
|
2241 | + ); |
|
2242 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2243 | + return $count; |
|
2244 | + } |
|
2245 | + |
|
2246 | + |
|
2247 | + |
|
2248 | + /** |
|
2249 | + * _default_event_settings |
|
2250 | + * This generates the Default Settings Tab |
|
2251 | + * |
|
2252 | + * @return void |
|
2253 | + */ |
|
2254 | + protected function _default_event_settings() |
|
2255 | + { |
|
2256 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
2257 | + $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array( |
|
2258 | + // exclude array |
|
2259 | + array( |
|
2260 | + EEM_Registration::status_id_cancelled, |
|
2261 | + EEM_Registration::status_id_declined, |
|
2262 | + EEM_Registration::status_id_incomplete, |
|
2263 | + EEM_Registration::status_id_wait_list, |
|
2264 | + ), |
|
2265 | + // translated |
|
2266 | + true |
|
2267 | + ); |
|
2268 | + $this->_template_args['default_reg_status'] = isset( |
|
2269 | + EE_Registry::instance()->CFG->registration->default_STS_ID |
|
2270 | + ) |
|
2271 | + && array_key_exists( |
|
2272 | + EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
2273 | + $this->_template_args['reg_status_array'] |
|
2274 | + ) |
|
2275 | + ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2276 | + : EEM_Registration::status_id_pending_payment; |
|
2277 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2278 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2279 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2280 | + EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2281 | + $this->_template_args, |
|
2282 | + true |
|
2283 | + ); |
|
2284 | + $this->display_admin_page_with_sidebar(); |
|
2285 | + } |
|
2286 | + |
|
2287 | + |
|
2288 | + |
|
2289 | + /** |
|
2290 | + * _update_default_event_settings |
|
2291 | + * |
|
2292 | + * @access protected |
|
2293 | + * @return void |
|
2294 | + */ |
|
2295 | + protected function _update_default_event_settings() |
|
2296 | + { |
|
2297 | + EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2298 | + ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2299 | + : EEM_Registration::status_id_pending_payment; |
|
2300 | + $what = 'Default Event Settings'; |
|
2301 | + $success = $this->_update_espresso_configuration( |
|
2302 | + $what, |
|
2303 | + EE_Config::instance(), |
|
2304 | + __FILE__, |
|
2305 | + __FUNCTION__, |
|
2306 | + __LINE__ |
|
2307 | + ); |
|
2308 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2309 | + } |
|
2310 | + |
|
2311 | + |
|
2312 | + |
|
2313 | + /************* Templates *************/ |
|
2314 | + protected function _template_settings() |
|
2315 | + { |
|
2316 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2317 | + $this->_template_args['preview_img'] = '<img src="' |
|
2318 | + . EVENTS_ASSETS_URL |
|
2319 | + . DS |
|
2320 | + . 'images' |
|
2321 | + . DS |
|
2322 | + . 'caffeinated_template_features.jpg" alt="' |
|
2323 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2324 | + . '" />'; |
|
2325 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2326 | + 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
2327 | + 'event_espresso' |
|
2328 | + ) . '</strong>'; |
|
2329 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2330 | + } |
|
2331 | + |
|
2332 | + |
|
2333 | + /** Event Category Stuff **/ |
|
2334 | + /** |
|
2335 | + * set the _category property with the category object for the loaded page. |
|
2336 | + * |
|
2337 | + * @access private |
|
2338 | + * @return void |
|
2339 | + */ |
|
2340 | + private function _set_category_object() |
|
2341 | + { |
|
2342 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2343 | + return; |
|
2344 | + } //already have the category object so get out. |
|
2345 | + //set default category object |
|
2346 | + $this->_set_empty_category_object(); |
|
2347 | + //only set if we've got an id |
|
2348 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2349 | + return; |
|
2350 | + } |
|
2351 | + $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2352 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2353 | + if ( ! empty($term)) { |
|
2354 | + $this->_category->category_name = $term->name; |
|
2355 | + $this->_category->category_identifier = $term->slug; |
|
2356 | + $this->_category->category_desc = $term->description; |
|
2357 | + $this->_category->id = $term->term_id; |
|
2358 | + $this->_category->parent = $term->parent; |
|
2359 | + } |
|
2360 | + } |
|
2361 | + |
|
2362 | + |
|
2363 | + |
|
2364 | + private function _set_empty_category_object() |
|
2365 | + { |
|
2366 | + $this->_category = new stdClass(); |
|
2367 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2368 | + $this->_category->id = $this->_category->parent = 0; |
|
2369 | + } |
|
2370 | + |
|
2371 | + |
|
2372 | + |
|
2373 | + protected function _category_list_table() |
|
2374 | + { |
|
2375 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2376 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2377 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2378 | + 'add_category', |
|
2379 | + 'add_category', |
|
2380 | + array(), |
|
2381 | + 'add-new-h2' |
|
2382 | + ); |
|
2383 | + $this->display_admin_list_table_page_with_sidebar(); |
|
2384 | + } |
|
2385 | + |
|
2386 | + |
|
2387 | + |
|
2388 | + /** |
|
2389 | + * @param $view |
|
2390 | + */ |
|
2391 | + protected function _category_details($view) |
|
2392 | + { |
|
2393 | + //load formatter helper |
|
2394 | + //load field generator helper |
|
2395 | + $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
2396 | + $this->_set_add_edit_form_tags($route); |
|
2397 | + $this->_set_category_object(); |
|
2398 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2399 | + $delete_action = 'delete_category'; |
|
2400 | + //custom redirect |
|
2401 | + $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
2402 | + array('action' => 'category_list'), |
|
2403 | + $this->_admin_base_url |
|
2404 | + ); |
|
2405 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2406 | + //take care of contents |
|
2407 | + $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
2408 | + $this->display_admin_page_with_sidebar(); |
|
2409 | + } |
|
2410 | + |
|
2411 | + |
|
2412 | + |
|
2413 | + /** |
|
2414 | + * @return mixed |
|
2415 | + */ |
|
2416 | + protected function _category_details_content() |
|
2417 | + { |
|
2418 | + $editor_args['category_desc'] = array( |
|
2419 | + 'type' => 'wp_editor', |
|
2420 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2421 | + 'class' => 'my_editor_custom', |
|
2422 | + 'wpeditor_args' => array('media_buttons' => false), |
|
2423 | + ); |
|
2424 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2425 | + $all_terms = get_terms( |
|
2426 | + array('espresso_event_categories'), |
|
2427 | + array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2428 | + ); |
|
2429 | + //setup category select for term parents. |
|
2430 | + $category_select_values[] = array( |
|
2431 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2432 | + 'id' => 0, |
|
2433 | + ); |
|
2434 | + foreach ($all_terms as $term) { |
|
2435 | + $category_select_values[] = array( |
|
2436 | + 'text' => $term->name, |
|
2437 | + 'id' => $term->term_id, |
|
2438 | + ); |
|
2439 | + } |
|
2440 | + $category_select = EEH_Form_Fields::select_input( |
|
2441 | + 'category_parent', |
|
2442 | + $category_select_values, |
|
2443 | + $this->_category->parent |
|
2444 | + ); |
|
2445 | + $template_args = array( |
|
2446 | + 'category' => $this->_category, |
|
2447 | + 'category_select' => $category_select, |
|
2448 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2449 | + 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
2450 | + 'disable' => '', |
|
2451 | + 'disabled_message' => false, |
|
2452 | + ); |
|
2453 | + $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2454 | + return EEH_Template::display_template($template, $template_args, true); |
|
2455 | + } |
|
2456 | + |
|
2457 | + |
|
2458 | + |
|
2459 | + protected function _delete_categories() |
|
2460 | + { |
|
2461 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2462 | + : (array)$this->_req_data['category_id']; |
|
2463 | + foreach ($cat_ids as $cat_id) { |
|
2464 | + $this->_delete_category($cat_id); |
|
2465 | + } |
|
2466 | + //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
2467 | + $query_args = array( |
|
2468 | + 'action' => 'category_list', |
|
2469 | + ); |
|
2470 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2471 | + } |
|
2472 | + |
|
2473 | + |
|
2474 | + |
|
2475 | + /** |
|
2476 | + * @param $cat_id |
|
2477 | + */ |
|
2478 | + protected function _delete_category($cat_id) |
|
2479 | + { |
|
2480 | + $cat_id = absint($cat_id); |
|
2481 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2482 | + } |
|
2483 | + |
|
2484 | + |
|
2485 | + |
|
2486 | + /** |
|
2487 | + * @param $new_category |
|
2488 | + */ |
|
2489 | + protected function _insert_or_update_category($new_category) |
|
2490 | + { |
|
2491 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2492 | + $success = 0; //we already have a success message so lets not send another. |
|
2493 | + if ($cat_id) { |
|
2494 | + $query_args = array( |
|
2495 | + 'action' => 'edit_category', |
|
2496 | + 'EVT_CAT_ID' => $cat_id, |
|
2497 | + ); |
|
2498 | + } else { |
|
2499 | + $query_args = array('action' => 'add_category'); |
|
2500 | + } |
|
2501 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2502 | + } |
|
2503 | + |
|
2504 | + |
|
2505 | + |
|
2506 | + /** |
|
2507 | + * @param bool $update |
|
2508 | + * @return bool|mixed|string |
|
2509 | + */ |
|
2510 | + private function _insert_category($update = false) |
|
2511 | + { |
|
2512 | + $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
2513 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2514 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2515 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2516 | + if (empty($category_name)) { |
|
2517 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2518 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2519 | + return false; |
|
2520 | + } |
|
2521 | + $term_args = array( |
|
2522 | + 'name' => $category_name, |
|
2523 | + 'description' => $category_desc, |
|
2524 | + 'parent' => $category_parent, |
|
2525 | + ); |
|
2526 | + //was the category_identifier input disabled? |
|
2527 | + if (isset($this->_req_data['category_identifier'])) { |
|
2528 | + $term_args['slug'] = $this->_req_data['category_identifier']; |
|
2529 | + } |
|
2530 | + $insert_ids = $update |
|
2531 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2532 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2533 | + if ( ! is_array($insert_ids)) { |
|
2534 | + $msg = esc_html__( |
|
2535 | + 'An error occurred and the category has not been saved to the database.', |
|
2536 | + 'event_espresso' |
|
2537 | + ); |
|
2538 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2539 | + } else { |
|
2540 | + $cat_id = $insert_ids['term_id']; |
|
2541 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2542 | + EE_Error::add_success($msg); |
|
2543 | + } |
|
2544 | + return $cat_id; |
|
2545 | + } |
|
2546 | + |
|
2547 | + |
|
2548 | + |
|
2549 | + /** |
|
2550 | + * @param int $per_page |
|
2551 | + * @param int $current_page |
|
2552 | + * @param bool $count |
|
2553 | + * @return \EE_Base_Class[]|int |
|
2554 | + */ |
|
2555 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
2556 | + { |
|
2557 | + //testing term stuff |
|
2558 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2559 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2560 | + $limit = ($current_page - 1) * $per_page; |
|
2561 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2562 | + if (isset($this->_req_data['s'])) { |
|
2563 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2564 | + $where['OR'] = array( |
|
2565 | + 'Term.name' => array('LIKE', $sstr), |
|
2566 | + 'description' => array('LIKE', $sstr), |
|
2567 | + ); |
|
2568 | + } |
|
2569 | + $query_params = array( |
|
2570 | + $where, |
|
2571 | + 'order_by' => array($orderby => $order), |
|
2572 | + 'limit' => $limit . ',' . $per_page, |
|
2573 | + 'force_join' => array('Term'), |
|
2574 | + ); |
|
2575 | + $categories = $count |
|
2576 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2577 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2578 | + return $categories; |
|
2579 | + } |
|
2580 | + |
|
2581 | + |
|
2582 | + |
|
2583 | + /* end category stuff */ |
|
2584 | + /**************/ |
|
2585 | 2585 | } |
2586 | 2586 | //end class Events_Admin_Page |
@@ -13,93 +13,93 @@ |
||
13 | 13 | class EE_Has_Many_Relation extends EE_Model_Relation_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the |
|
18 | - * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but |
|
19 | - * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get |
|
20 | - * related models across the relation, and add-and-remove the relationships. |
|
21 | - * |
|
22 | - * @param boolean $block_deletes For this type of r elation, we block by default. If there are |
|
23 | - * related models across this relation, block (prevent and add an |
|
24 | - * error) the deletion of this model |
|
25 | - * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the |
|
26 | - * default |
|
27 | - */ |
|
28 | - public function __construct($block_deletes = true, $blocking_delete_error_message = null) |
|
29 | - { |
|
30 | - parent::__construct($block_deletes, $blocking_delete_error_message); |
|
31 | - } |
|
16 | + /** |
|
17 | + * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the |
|
18 | + * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but |
|
19 | + * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get |
|
20 | + * related models across the relation, and add-and-remove the relationships. |
|
21 | + * |
|
22 | + * @param boolean $block_deletes For this type of r elation, we block by default. If there are |
|
23 | + * related models across this relation, block (prevent and add an |
|
24 | + * error) the deletion of this model |
|
25 | + * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the |
|
26 | + * default |
|
27 | + */ |
|
28 | + public function __construct($block_deletes = true, $blocking_delete_error_message = null) |
|
29 | + { |
|
30 | + parent::__construct($block_deletes, $blocking_delete_error_message); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Gets the SQL string for performing the join between this model and the other model. |
|
36 | - * |
|
37 | - * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
38 | - * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
39 | - * other_model_primary_table.fk" etc |
|
40 | - * @throws \EE_Error |
|
41 | - */ |
|
42 | - public function get_join_statement($model_relation_chain) |
|
43 | - { |
|
44 | - //create the sql string like |
|
45 | - // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
46 | - $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
47 | - $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
48 | - $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, |
|
49 | - $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
50 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, |
|
51 | - $this->get_other_model()->get_this_model_name()) . $other_table_fk_field->get_table_alias(); |
|
52 | - $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
34 | + /** |
|
35 | + * Gets the SQL string for performing the join between this model and the other model. |
|
36 | + * |
|
37 | + * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
38 | + * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
39 | + * other_model_primary_table.fk" etc |
|
40 | + * @throws \EE_Error |
|
41 | + */ |
|
42 | + public function get_join_statement($model_relation_chain) |
|
43 | + { |
|
44 | + //create the sql string like |
|
45 | + // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
46 | + $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
47 | + $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
48 | + $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, |
|
49 | + $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
50 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, |
|
51 | + $this->get_other_model()->get_this_model_name()) . $other_table_fk_field->get_table_alias(); |
|
52 | + $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
53 | 53 | |
54 | - return $this->_left_join($fk_table, $fk_table_alias, $other_table_fk_field->get_table_column(), $pk_table_alias, |
|
55 | - $this_table_pk_field->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
56 | - } |
|
54 | + return $this->_left_join($fk_table, $fk_table_alias, $other_table_fk_field->get_table_column(), $pk_table_alias, |
|
55 | + $this_table_pk_field->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
61 | - * you like. |
|
62 | - * |
|
63 | - * @param EE_Base_Class|int $this_obj_or_id |
|
64 | - * @param EE_Base_Class|int $other_obj_or_id |
|
65 | - * @param array $extra_join_model_fields_n_values |
|
66 | - * @return \EE_Base_Class |
|
67 | - * @throws \EE_Error |
|
68 | - */ |
|
69 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
70 | - { |
|
71 | - $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
72 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
59 | + /** |
|
60 | + * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
61 | + * you like. |
|
62 | + * |
|
63 | + * @param EE_Base_Class|int $this_obj_or_id |
|
64 | + * @param EE_Base_Class|int $other_obj_or_id |
|
65 | + * @param array $extra_join_model_fields_n_values |
|
66 | + * @return \EE_Base_Class |
|
67 | + * @throws \EE_Error |
|
68 | + */ |
|
69 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) |
|
70 | + { |
|
71 | + $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
72 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
73 | 73 | |
74 | - //find the field on the other model which is a foreign key to this model |
|
75 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
76 | - if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) { |
|
77 | - //set that field on the other model to this model's ID |
|
78 | - $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
79 | - $other_model_obj->save(); |
|
80 | - } |
|
81 | - return $other_model_obj; |
|
82 | - } |
|
74 | + //find the field on the other model which is a foreign key to this model |
|
75 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
76 | + if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) { |
|
77 | + //set that field on the other model to this model's ID |
|
78 | + $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
79 | + $other_model_obj->save(); |
|
80 | + } |
|
81 | + return $other_model_obj; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
87 | - * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
88 | - * |
|
89 | - * @param EE_Base_Class|int $this_obj_or_id |
|
90 | - * @param EE_Base_Class|int $other_obj_or_id |
|
91 | - * @param array $where_query |
|
92 | - * @return \EE_Base_Class |
|
93 | - * @throws \EE_Error |
|
94 | - */ |
|
95 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
96 | - { |
|
97 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
98 | - //find the field on the other model which is a foreign key to this model |
|
99 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
100 | - //set that field on the other model to this model's ID |
|
101 | - $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
102 | - $other_model_obj->save(); |
|
103 | - return $other_model_obj; |
|
104 | - } |
|
85 | + /** |
|
86 | + * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
87 | + * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
88 | + * |
|
89 | + * @param EE_Base_Class|int $this_obj_or_id |
|
90 | + * @param EE_Base_Class|int $other_obj_or_id |
|
91 | + * @param array $where_query |
|
92 | + * @return \EE_Base_Class |
|
93 | + * @throws \EE_Error |
|
94 | + */ |
|
95 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) |
|
96 | + { |
|
97 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
98 | + //find the field on the other model which is a foreign key to this model |
|
99 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
100 | + //set that field on the other model to this model's ID |
|
101 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
102 | + $other_model_obj->save(); |
|
103 | + return $other_model_obj; |
|
104 | + } |
|
105 | 105 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -61,23 +61,23 @@ discard block |
||
61 | 61 | * @param string $min_core_version |
62 | 62 | * @return string always like '4.3.0.rc.000' |
63 | 63 | */ |
64 | - protected static function _effective_version( $min_core_version ) { |
|
64 | + protected static function _effective_version($min_core_version) { |
|
65 | 65 | // versions: 4 . 3 . 1 . p . 123 |
66 | 66 | // offsets: 0 . 1 . 2 . 3 . 4 |
67 | - $version_parts = explode( '.', $min_core_version ); |
|
67 | + $version_parts = explode('.', $min_core_version); |
|
68 | 68 | //check they specified the micro version (after 2nd period) |
69 | - if ( ! isset( $version_parts[2] ) ) { |
|
69 | + if ( ! isset($version_parts[2])) { |
|
70 | 70 | $version_parts[2] = '0'; |
71 | 71 | } |
72 | 72 | //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
73 | 73 | //soon we can assume that's 'rc', but this current version is 'alpha' |
74 | - if ( ! isset( $version_parts[3] ) ) { |
|
74 | + if ( ! isset($version_parts[3])) { |
|
75 | 75 | $version_parts[3] = 'dev'; |
76 | 76 | } |
77 | - if ( ! isset( $version_parts[4] ) ) { |
|
77 | + if ( ! isset($version_parts[4])) { |
|
78 | 78 | $version_parts[4] = '000'; |
79 | 79 | } |
80 | - return implode( '.', $version_parts ); |
|
80 | + return implode('.', $version_parts); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | $actual_core_version = EVENT_ESPRESSO_VERSION |
95 | 95 | ) { |
96 | 96 | return version_compare( |
97 | - self::_effective_version( $actual_core_version ), |
|
98 | - self::_effective_version( $min_core_version ), |
|
97 | + self::_effective_version($actual_core_version), |
|
98 | + self::_effective_version($min_core_version), |
|
99 | 99 | '>=' |
100 | 100 | ); |
101 | 101 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @throws EE_Error |
218 | 218 | * @return void |
219 | 219 | */ |
220 | - public static function register( $addon_name = '', $setup_args = array() ) { |
|
220 | + public static function register($addon_name = '', $setup_args = array()) { |
|
221 | 221 | // required fields MUST be present, so let's make sure they are. |
222 | 222 | \EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
223 | 223 | // get class name for addon |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | // setup PUE |
228 | 228 | \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
229 | 229 | // does this addon work with this version of core or WordPress ? |
230 | - if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings) ) { |
|
230 | + if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | // register namespaces |
234 | 234 | \EE_Register_Addon::_setup_namespaces($addon_settings); |
235 | 235 | // check if this is an activation request |
236 | - if ( \EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
236 | + if (\EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
237 | 237 | // dont bother setting up the rest of the addon atm |
238 | 238 | return; |
239 | 239 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | } else { |
327 | 327 | $class_name = $setup_args['class_name']; |
328 | 328 | } |
329 | - return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
329 | + return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_'.$class_name; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | |
@@ -344,105 +344,105 @@ discard block |
||
344 | 344 | 'class_name' => $class_name, |
345 | 345 | // the addon slug for use in URLs, etc |
346 | 346 | 'plugin_slug' => isset($setup_args['plugin_slug']) |
347 | - ? (string)$setup_args['plugin_slug'] |
|
347 | + ? (string) $setup_args['plugin_slug'] |
|
348 | 348 | : '', |
349 | 349 | // page slug to be used when generating the "Settings" link on the WP plugin page |
350 | 350 | 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
351 | - ? (string)$setup_args['plugin_action_slug'] |
|
351 | + ? (string) $setup_args['plugin_action_slug'] |
|
352 | 352 | : '', |
353 | 353 | // the "software" version for the addon |
354 | 354 | 'version' => isset($setup_args['version']) |
355 | - ? (string)$setup_args['version'] |
|
355 | + ? (string) $setup_args['version'] |
|
356 | 356 | : '', |
357 | 357 | // the minimum version of EE Core that the addon will work with |
358 | 358 | 'min_core_version' => isset($setup_args['min_core_version']) |
359 | - ? (string)$setup_args['min_core_version'] |
|
359 | + ? (string) $setup_args['min_core_version'] |
|
360 | 360 | : '', |
361 | 361 | // the minimum version of WordPress that the addon will work with |
362 | 362 | 'min_wp_version' => isset($setup_args['min_wp_version']) |
363 | - ? (string)$setup_args['min_wp_version'] |
|
363 | + ? (string) $setup_args['min_wp_version'] |
|
364 | 364 | : EE_MIN_WP_VER_REQUIRED, |
365 | 365 | // full server path to main file (file loaded directly by WP) |
366 | 366 | 'main_file_path' => isset($setup_args['main_file_path']) |
367 | - ? (string)$setup_args['main_file_path'] |
|
367 | + ? (string) $setup_args['main_file_path'] |
|
368 | 368 | : '', |
369 | 369 | // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
370 | 370 | 'admin_path' => isset($setup_args['admin_path']) |
371 | - ? (string)$setup_args['admin_path'] : '', |
|
371 | + ? (string) $setup_args['admin_path'] : '', |
|
372 | 372 | // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
373 | 373 | 'admin_callback' => isset($setup_args['admin_callback']) |
374 | - ? (string)$setup_args['admin_callback'] |
|
374 | + ? (string) $setup_args['admin_callback'] |
|
375 | 375 | : '', |
376 | 376 | // the section name for this addon's configuration settings section (defaults to "addons") |
377 | 377 | 'config_section' => isset($setup_args['config_section']) |
378 | - ? (string)$setup_args['config_section'] |
|
378 | + ? (string) $setup_args['config_section'] |
|
379 | 379 | : 'addons', |
380 | 380 | // the class name for this addon's configuration settings object |
381 | 381 | 'config_class' => isset($setup_args['config_class']) |
382 | - ? (string)$setup_args['config_class'] : '', |
|
382 | + ? (string) $setup_args['config_class'] : '', |
|
383 | 383 | //the name given to the config for this addons' configuration settings object (optional) |
384 | 384 | 'config_name' => isset($setup_args['config_name']) |
385 | - ? (string)$setup_args['config_name'] : '', |
|
385 | + ? (string) $setup_args['config_name'] : '', |
|
386 | 386 | // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
387 | 387 | 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
388 | - ? (array)$setup_args['autoloader_paths'] |
|
388 | + ? (array) $setup_args['autoloader_paths'] |
|
389 | 389 | : array(), |
390 | 390 | // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
391 | 391 | 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
392 | - ? (array)$setup_args['autoloader_folders'] |
|
392 | + ? (array) $setup_args['autoloader_folders'] |
|
393 | 393 | : array(), |
394 | 394 | // array of full server paths to any EE_DMS data migration scripts used by the addon |
395 | 395 | 'dms_paths' => isset($setup_args['dms_paths']) |
396 | - ? (array)$setup_args['dms_paths'] |
|
396 | + ? (array) $setup_args['dms_paths'] |
|
397 | 397 | : array(), |
398 | 398 | // array of full server paths to any EED_Modules used by the addon |
399 | 399 | 'module_paths' => isset($setup_args['module_paths']) |
400 | - ? (array)$setup_args['module_paths'] |
|
400 | + ? (array) $setup_args['module_paths'] |
|
401 | 401 | : array(), |
402 | 402 | // array of full server paths to any EES_Shortcodes used by the addon |
403 | 403 | 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
404 | - ? (array)$setup_args['shortcode_paths'] |
|
404 | + ? (array) $setup_args['shortcode_paths'] |
|
405 | 405 | : array(), |
406 | 406 | // array of full server paths to any WP_Widgets used by the addon |
407 | 407 | 'widget_paths' => isset($setup_args['widget_paths']) |
408 | - ? (array)$setup_args['widget_paths'] |
|
408 | + ? (array) $setup_args['widget_paths'] |
|
409 | 409 | : array(), |
410 | 410 | // array of PUE options used by the addon |
411 | 411 | 'pue_options' => isset($setup_args['pue_options']) |
412 | - ? (array)$setup_args['pue_options'] |
|
412 | + ? (array) $setup_args['pue_options'] |
|
413 | 413 | : array(), |
414 | 414 | 'message_types' => isset($setup_args['message_types']) |
415 | - ? (array)$setup_args['message_types'] |
|
415 | + ? (array) $setup_args['message_types'] |
|
416 | 416 | : array(), |
417 | 417 | 'capabilities' => isset($setup_args['capabilities']) |
418 | - ? (array)$setup_args['capabilities'] |
|
418 | + ? (array) $setup_args['capabilities'] |
|
419 | 419 | : array(), |
420 | 420 | 'capability_maps' => isset($setup_args['capability_maps']) |
421 | - ? (array)$setup_args['capability_maps'] |
|
421 | + ? (array) $setup_args['capability_maps'] |
|
422 | 422 | : array(), |
423 | 423 | 'model_paths' => isset($setup_args['model_paths']) |
424 | - ? (array)$setup_args['model_paths'] |
|
424 | + ? (array) $setup_args['model_paths'] |
|
425 | 425 | : array(), |
426 | 426 | 'class_paths' => isset($setup_args['class_paths']) |
427 | - ? (array)$setup_args['class_paths'] |
|
427 | + ? (array) $setup_args['class_paths'] |
|
428 | 428 | : array(), |
429 | 429 | 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
430 | - ? (array)$setup_args['model_extension_paths'] |
|
430 | + ? (array) $setup_args['model_extension_paths'] |
|
431 | 431 | : array(), |
432 | 432 | 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
433 | - ? (array)$setup_args['class_extension_paths'] |
|
433 | + ? (array) $setup_args['class_extension_paths'] |
|
434 | 434 | : array(), |
435 | 435 | 'custom_post_types' => isset($setup_args['custom_post_types']) |
436 | - ? (array)$setup_args['custom_post_types'] |
|
436 | + ? (array) $setup_args['custom_post_types'] |
|
437 | 437 | : array(), |
438 | 438 | 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
439 | - ? (array)$setup_args['custom_taxonomies'] |
|
439 | + ? (array) $setup_args['custom_taxonomies'] |
|
440 | 440 | : array(), |
441 | 441 | 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
442 | - ? (array)$setup_args['payment_method_paths'] |
|
442 | + ? (array) $setup_args['payment_method_paths'] |
|
443 | 443 | : array(), |
444 | 444 | 'default_terms' => isset($setup_args['default_terms']) |
445 | - ? (array)$setup_args['default_terms'] |
|
445 | + ? (array) $setup_args['default_terms'] |
|
446 | 446 | : array(), |
447 | 447 | // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
448 | 448 | // that can be used for adding upgrading/marketing info |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $setup_args['namespace']['FQNS'], |
455 | 455 | $setup_args['namespace']['DIR'] |
456 | 456 | ) |
457 | - ? (array)$setup_args['namespace'] |
|
457 | + ? (array) $setup_args['namespace'] |
|
458 | 458 | : array(), |
459 | 459 | ); |
460 | 460 | // if plugin_action_slug is NOT set, but an admin page path IS set, |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @param array $addon_settings |
476 | 476 | * @return boolean |
477 | 477 | */ |
478 | - private static function _addon_is_compatible( $addon_name, array $addon_settings ) { |
|
478 | + private static function _addon_is_compatible($addon_name, array $addon_settings) { |
|
479 | 479 | global $wp_version; |
480 | 480 | $incompatibility_message = ''; |
481 | 481 | //check whether this addon version is compatible with EE core |
@@ -551,20 +551,20 @@ discard block |
||
551 | 551 | * @param array $setup_args |
552 | 552 | * @return void |
553 | 553 | */ |
554 | - private static function _parse_pue_options( $addon_name, $class_name, array $setup_args ) { |
|
554 | + private static function _parse_pue_options($addon_name, $class_name, array $setup_args) { |
|
555 | 555 | if ( ! empty($setup_args['pue_options'])) { |
556 | 556 | self::$_settings[$addon_name]['pue_options'] = array( |
557 | 557 | 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
558 | - ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
559 | - : 'espresso_' . strtolower($class_name), |
|
558 | + ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
|
559 | + : 'espresso_'.strtolower($class_name), |
|
560 | 560 | 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
561 | - ? (string)$setup_args['pue_options']['plugin_basename'] |
|
561 | + ? (string) $setup_args['pue_options']['plugin_basename'] |
|
562 | 562 | : plugin_basename($setup_args['main_file_path']), |
563 | 563 | 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
564 | - ? (string)$setup_args['pue_options']['checkPeriod'] |
|
564 | + ? (string) $setup_args['pue_options']['checkPeriod'] |
|
565 | 565 | : '24', |
566 | 566 | 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
567 | - ? (string)$setup_args['pue_options']['use_wp_update'] |
|
567 | + ? (string) $setup_args['pue_options']['use_wp_update'] |
|
568 | 568 | : false, |
569 | 569 | ); |
570 | 570 | add_action( |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | * @param array $addon_settings |
607 | 607 | * @return bool |
608 | 608 | */ |
609 | - private static function _addon_activation( $addon_name, array $addon_settings ) { |
|
609 | + private static function _addon_activation($addon_name, array $addon_settings) { |
|
610 | 610 | // this is an activation request |
611 | 611 | if (did_action('activate_plugin')) { |
612 | 612 | //to find if THIS is the addon that was activated, |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | } |
664 | 664 | // setup autoloaders for folders |
665 | 665 | if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
666 | - foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
666 | + foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
667 | 667 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
668 | 668 | } |
669 | 669 | } |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | * @return void |
679 | 679 | * @throws \EE_Error |
680 | 680 | */ |
681 | - private static function _register_models_and_extensions( $addon_name ) { |
|
681 | + private static function _register_models_and_extensions($addon_name) { |
|
682 | 682 | // register new models |
683 | 683 | if ( |
684 | 684 | ! empty(self::$_settings[$addon_name]['model_paths']) |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | * @return void |
715 | 715 | * @throws \EE_Error |
716 | 716 | */ |
717 | - private static function _register_data_migration_scripts( $addon_name ) { |
|
717 | + private static function _register_data_migration_scripts($addon_name) { |
|
718 | 718 | // setup DMS |
719 | 719 | if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
720 | 720 | EE_Register_Data_Migration_Scripts::register( |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @return void |
731 | 731 | * @throws \EE_Error |
732 | 732 | */ |
733 | - private static function _register_config( $addon_name ) { |
|
733 | + private static function _register_config($addon_name) { |
|
734 | 734 | // if config_class is present let's register config. |
735 | 735 | if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
736 | 736 | EE_Register_Config::register( |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @return void |
750 | 750 | * @throws \EE_Error |
751 | 751 | */ |
752 | - private static function _register_admin_pages( $addon_name ) { |
|
752 | + private static function _register_admin_pages($addon_name) { |
|
753 | 753 | if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
754 | 754 | EE_Register_Admin_Page::register( |
755 | 755 | $addon_name, |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | * @return void |
765 | 765 | * @throws \EE_Error |
766 | 766 | */ |
767 | - private static function _register_modules( $addon_name ) { |
|
767 | + private static function _register_modules($addon_name) { |
|
768 | 768 | if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
769 | 769 | EE_Register_Module::register( |
770 | 770 | $addon_name, |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | * @return void |
780 | 780 | * @throws \EE_Error |
781 | 781 | */ |
782 | - private static function _register_shortcodes( $addon_name ) { |
|
782 | + private static function _register_shortcodes($addon_name) { |
|
783 | 783 | if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
784 | 784 | EE_Register_Shortcode::register( |
785 | 785 | $addon_name, |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | * @return void |
795 | 795 | * @throws \EE_Error |
796 | 796 | */ |
797 | - private static function _register_widgets( $addon_name ) { |
|
797 | + private static function _register_widgets($addon_name) { |
|
798 | 798 | if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
799 | 799 | EE_Register_Widget::register( |
800 | 800 | $addon_name, |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | * @return void |
810 | 810 | * @throws \EE_Error |
811 | 811 | */ |
812 | - private static function _register_capabilities( $addon_name ) { |
|
812 | + private static function _register_capabilities($addon_name) { |
|
813 | 813 | if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
814 | 814 | EE_Register_Capabilities::register( |
815 | 815 | $addon_name, |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | * @return void |
828 | 828 | * @throws \EE_Error |
829 | 829 | */ |
830 | - private static function _register_message_types( $addon_name ) { |
|
830 | + private static function _register_message_types($addon_name) { |
|
831 | 831 | if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
832 | 832 | add_action( |
833 | 833 | 'EE_Brewing_Regular___messages_caf', |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | * @return void |
843 | 843 | * @throws \EE_Error |
844 | 844 | */ |
845 | - private static function _register_custom_post_types( $addon_name ) { |
|
845 | + private static function _register_custom_post_types($addon_name) { |
|
846 | 846 | if ( |
847 | 847 | ! empty(self::$_settings[$addon_name]['custom_post_types']) |
848 | 848 | || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | * @return void |
865 | 865 | * @throws \EE_Error |
866 | 866 | */ |
867 | - private static function _register_payment_methods( $addon_name ) { |
|
867 | + private static function _register_payment_methods($addon_name) { |
|
868 | 868 | if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
869 | 869 | EE_Register_Payment_Method::register( |
870 | 870 | $addon_name, |
@@ -881,25 +881,25 @@ discard block |
||
881 | 881 | * @param string $addon_name |
882 | 882 | * @return EE_Addon |
883 | 883 | */ |
884 | - private static function _load_and_init_addon_class( $addon_name ) { |
|
884 | + private static function _load_and_init_addon_class($addon_name) { |
|
885 | 885 | $addon = EE_Registry::instance()->load_addon( |
886 | - dirname( self::$_settings[ $addon_name ]['main_file_path'] ), |
|
887 | - self::$_settings[ $addon_name ]['class_name'] |
|
886 | + dirname(self::$_settings[$addon_name]['main_file_path']), |
|
887 | + self::$_settings[$addon_name]['class_name'] |
|
888 | 888 | ); |
889 | - $addon->set_name( $addon_name ); |
|
890 | - $addon->set_plugin_slug( self::$_settings[ $addon_name ]['plugin_slug'] ); |
|
891 | - $addon->set_plugin_basename( self::$_settings[ $addon_name ]['plugin_basename'] ); |
|
892 | - $addon->set_main_plugin_file( self::$_settings[ $addon_name ]['main_file_path'] ); |
|
893 | - $addon->set_plugin_action_slug( self::$_settings[ $addon_name ]['plugin_action_slug'] ); |
|
894 | - $addon->set_plugins_page_row( self::$_settings[ $addon_name ]['plugins_page_row'] ); |
|
895 | - $addon->set_version( self::$_settings[ $addon_name ]['version'] ); |
|
896 | - $addon->set_min_core_version( self::_effective_version( self::$_settings[ $addon_name ]['min_core_version'] ) ); |
|
897 | - $addon->set_config_section( self::$_settings[ $addon_name ]['config_section'] ); |
|
898 | - $addon->set_config_class( self::$_settings[ $addon_name ]['config_class'] ); |
|
899 | - $addon->set_config_name( self::$_settings[ $addon_name ]['config_name'] ); |
|
889 | + $addon->set_name($addon_name); |
|
890 | + $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
891 | + $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
892 | + $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
893 | + $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
894 | + $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
895 | + $addon->set_version(self::$_settings[$addon_name]['version']); |
|
896 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
897 | + $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
898 | + $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
899 | + $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
900 | 900 | //unfortunately this can't be hooked in upon construction, because we don't have |
901 | 901 | //the plugin mainfile's path upon construction. |
902 | - register_deactivation_hook( $addon->get_main_plugin_file(), array( $addon, 'deactivation' ) ); |
|
902 | + register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
903 | 903 | // call any additional admin_callback functions during load_admin_controller hook |
904 | 904 | if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
905 | 905 | add_action( |
@@ -919,18 +919,18 @@ discard block |
||
919 | 919 | */ |
920 | 920 | public static function load_pue_update() { |
921 | 921 | // load PUE client |
922 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
922 | + require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php'; |
|
923 | 923 | // cycle thru settings |
924 | - foreach ( self::$_settings as $settings ) { |
|
925 | - if ( ! empty( $settings['pue_options'] ) ) { |
|
924 | + foreach (self::$_settings as $settings) { |
|
925 | + if ( ! empty($settings['pue_options'])) { |
|
926 | 926 | // initiate the class and start the plugin update engine! |
927 | 927 | new PluginUpdateEngineChecker( |
928 | 928 | // host file URL |
929 | 929 | 'https://eventespresso.com', |
930 | 930 | // plugin slug(s) |
931 | 931 | array( |
932 | - 'premium' => array( 'p' => $settings['pue_options']['pue_plugin_slug'] ), |
|
933 | - 'prerelease' => array( 'beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr' ), |
|
932 | + 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
933 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'), |
|
934 | 934 | ), |
935 | 935 | // options |
936 | 936 | array( |
@@ -958,9 +958,9 @@ discard block |
||
958 | 958 | * @throws \EE_Error |
959 | 959 | */ |
960 | 960 | public static function register_message_types() { |
961 | - foreach ( self::$_settings as $addon_name => $settings ) { |
|
961 | + foreach (self::$_settings as $addon_name => $settings) { |
|
962 | 962 | if ( ! empty($settings['message_types'])) { |
963 | - foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) { |
|
963 | + foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
|
964 | 964 | EE_Register_Message_Type::register($message_type, $message_type_settings); |
965 | 965 | } |
966 | 966 | } |
@@ -977,73 +977,73 @@ discard block |
||
977 | 977 | * @throws EE_Error |
978 | 978 | * @return void |
979 | 979 | */ |
980 | - public static function deregister( $addon_name = null ) { |
|
981 | - if ( isset( self::$_settings[ $addon_name ] ) ) { |
|
982 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
983 | - if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] ) ) { |
|
980 | + public static function deregister($addon_name = null) { |
|
981 | + if (isset(self::$_settings[$addon_name])) { |
|
982 | + $class_name = self::$_settings[$addon_name]['class_name']; |
|
983 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
984 | 984 | // setup DMS |
985 | - EE_Register_Data_Migration_Scripts::deregister( $addon_name ); |
|
985 | + EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
986 | 986 | } |
987 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] ) ) { |
|
987 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
988 | 988 | // register admin page |
989 | - EE_Register_Admin_Page::deregister( $addon_name ); |
|
989 | + EE_Register_Admin_Page::deregister($addon_name); |
|
990 | 990 | } |
991 | - if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] ) ) { |
|
991 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
992 | 992 | // add to list of modules to be registered |
993 | - EE_Register_Module::deregister( $addon_name ); |
|
993 | + EE_Register_Module::deregister($addon_name); |
|
994 | 994 | } |
995 | - if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] ) ) { |
|
995 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
996 | 996 | // add to list of shortcodes to be registered |
997 | - EE_Register_Shortcode::deregister( $addon_name ); |
|
997 | + EE_Register_Shortcode::deregister($addon_name); |
|
998 | 998 | } |
999 | - if ( ! empty( self::$_settings[ $addon_name ]['config_class'] ) ) { |
|
999 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
1000 | 1000 | // if config_class present let's register config. |
1001 | - EE_Register_Config::deregister( self::$_settings[ $addon_name ]['config_class'] ); |
|
1001 | + EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
1002 | 1002 | } |
1003 | - if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] ) ) { |
|
1003 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
1004 | 1004 | // add to list of widgets to be registered |
1005 | - EE_Register_Widget::deregister( $addon_name ); |
|
1005 | + EE_Register_Widget::deregister($addon_name); |
|
1006 | 1006 | } |
1007 | - if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) |
|
1007 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) |
|
1008 | 1008 | || |
1009 | - ! empty( self::$_settings[ $addon_name ]['class_paths'] ) |
|
1009 | + ! empty(self::$_settings[$addon_name]['class_paths']) |
|
1010 | 1010 | ) { |
1011 | 1011 | // add to list of shortcodes to be registered |
1012 | - EE_Register_Model::deregister( $addon_name ); |
|
1012 | + EE_Register_Model::deregister($addon_name); |
|
1013 | 1013 | } |
1014 | - if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) |
|
1014 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
1015 | 1015 | || |
1016 | - ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] ) |
|
1016 | + ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
1017 | 1017 | ) { |
1018 | 1018 | // add to list of shortcodes to be registered |
1019 | - EE_Register_Model_Extensions::deregister( $addon_name ); |
|
1019 | + EE_Register_Model_Extensions::deregister($addon_name); |
|
1020 | 1020 | } |
1021 | - if ( ! empty( self::$_settings[ $addon_name ]['message_types'] ) ) { |
|
1022 | - foreach ((array)self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings ) |
|
1021 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
1022 | + foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) |
|
1023 | 1023 | { |
1024 | - EE_Register_Message_Type::deregister( $message_type ); |
|
1024 | + EE_Register_Message_Type::deregister($message_type); |
|
1025 | 1025 | } |
1026 | 1026 | } |
1027 | 1027 | //deregister capabilities for addon |
1028 | 1028 | if ( |
1029 | - ! empty( self::$_settings[ $addon_name ]['capabilities'] ) |
|
1030 | - || ! empty( self::$_settings[ $addon_name ]['capability_maps'] ) |
|
1029 | + ! empty(self::$_settings[$addon_name]['capabilities']) |
|
1030 | + || ! empty(self::$_settings[$addon_name]['capability_maps']) |
|
1031 | 1031 | ) { |
1032 | - EE_Register_Capabilities::deregister( $addon_name ); |
|
1032 | + EE_Register_Capabilities::deregister($addon_name); |
|
1033 | 1033 | } |
1034 | 1034 | //deregister custom_post_types for addon |
1035 | - if ( ! empty( self::$_settings[ $addon_name ]['custom_post_types'] ) ) { |
|
1036 | - EE_Register_CPT::deregister( $addon_name ); |
|
1035 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
1036 | + EE_Register_CPT::deregister($addon_name); |
|
1037 | 1037 | } |
1038 | 1038 | remove_action( |
1039 | - 'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), |
|
1040 | - array( EE_Registry::instance()->addons->{$class_name}, 'deactivation' ) |
|
1039 | + 'deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), |
|
1040 | + array(EE_Registry::instance()->addons->{$class_name}, 'deactivation') |
|
1041 | 1041 | ); |
1042 | 1042 | remove_action( |
1043 | 1043 | 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
1044 | - array( EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required' ) |
|
1044 | + array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required') |
|
1045 | 1045 | ); |
1046 | - unset( EE_Registry::instance()->addons->{$class_name}, self::$_settings[ $addon_name ] ); |
|
1046 | + unset(EE_Registry::instance()->addons->{$class_name}, self::$_settings[$addon_name]); |
|
1047 | 1047 | } |
1048 | 1048 | } |
1049 | 1049 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | protected static $_incompatible_addons = array( |
49 | 49 | 'Multi_Event_Registration' => '2.0.11.rc.002', |
50 | 50 | 'Promotions' => '1.0.0.rc.084', |
51 | - ); |
|
51 | + ); |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
@@ -219,660 +219,660 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public static function register( $addon_name = '', $setup_args = array() ) { |
221 | 221 | // required fields MUST be present, so let's make sure they are. |
222 | - \EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
223 | - // get class name for addon |
|
222 | + \EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
223 | + // get class name for addon |
|
224 | 224 | $class_name = \EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
225 | 225 | //setup $_settings array from incoming values. |
226 | - $addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
227 | - // setup PUE |
|
228 | - \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
229 | - // does this addon work with this version of core or WordPress ? |
|
230 | - if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings) ) { |
|
231 | - return; |
|
226 | + $addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
227 | + // setup PUE |
|
228 | + \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
229 | + // does this addon work with this version of core or WordPress ? |
|
230 | + if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings) ) { |
|
231 | + return; |
|
232 | 232 | } |
233 | 233 | // register namespaces |
234 | - \EE_Register_Addon::_setup_namespaces($addon_settings); |
|
235 | - // check if this is an activation request |
|
236 | - if ( \EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
237 | - // dont bother setting up the rest of the addon atm |
|
238 | - return; |
|
239 | - } |
|
240 | - // we need cars |
|
241 | - \EE_Register_Addon::_setup_autoloaders($addon_name); |
|
242 | - // register new models and extensions |
|
243 | - \EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
244 | - // setup DMS |
|
245 | - \EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
246 | - // if config_class is present let's register config. |
|
247 | - \EE_Register_Addon::_register_config($addon_name); |
|
248 | - // register admin pages |
|
249 | - \EE_Register_Addon::_register_admin_pages($addon_name); |
|
250 | - // add to list of modules to be registered |
|
251 | - \EE_Register_Addon::_register_modules($addon_name); |
|
252 | - // add to list of shortcodes to be registered |
|
253 | - \EE_Register_Addon::_register_shortcodes($addon_name); |
|
254 | - // add to list of widgets to be registered |
|
255 | - \EE_Register_Addon::_register_widgets($addon_name); |
|
256 | - // register capability related stuff. |
|
257 | - \EE_Register_Addon::_register_capabilities($addon_name); |
|
258 | - // any message type to register? |
|
259 | - \EE_Register_Addon::_register_message_types($addon_name); |
|
234 | + \EE_Register_Addon::_setup_namespaces($addon_settings); |
|
235 | + // check if this is an activation request |
|
236 | + if ( \EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
237 | + // dont bother setting up the rest of the addon atm |
|
238 | + return; |
|
239 | + } |
|
240 | + // we need cars |
|
241 | + \EE_Register_Addon::_setup_autoloaders($addon_name); |
|
242 | + // register new models and extensions |
|
243 | + \EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
244 | + // setup DMS |
|
245 | + \EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
246 | + // if config_class is present let's register config. |
|
247 | + \EE_Register_Addon::_register_config($addon_name); |
|
248 | + // register admin pages |
|
249 | + \EE_Register_Addon::_register_admin_pages($addon_name); |
|
250 | + // add to list of modules to be registered |
|
251 | + \EE_Register_Addon::_register_modules($addon_name); |
|
252 | + // add to list of shortcodes to be registered |
|
253 | + \EE_Register_Addon::_register_shortcodes($addon_name); |
|
254 | + // add to list of widgets to be registered |
|
255 | + \EE_Register_Addon::_register_widgets($addon_name); |
|
256 | + // register capability related stuff. |
|
257 | + \EE_Register_Addon::_register_capabilities($addon_name); |
|
258 | + // any message type to register? |
|
259 | + \EE_Register_Addon::_register_message_types($addon_name); |
|
260 | 260 | // any custom post type/ custom capabilities or default terms to register |
261 | - \EE_Register_Addon::_register_custom_post_types($addon_name); |
|
262 | - // and any payment methods |
|
263 | - \EE_Register_Addon::_register_payment_methods($addon_name); |
|
261 | + \EE_Register_Addon::_register_custom_post_types($addon_name); |
|
262 | + // and any payment methods |
|
263 | + \EE_Register_Addon::_register_payment_methods($addon_name); |
|
264 | 264 | // load and instantiate main addon class |
265 | - $addon = \EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
266 | - $addon->after_registration(); |
|
267 | - } |
|
268 | - |
|
269 | - |
|
270 | - |
|
271 | - /** |
|
272 | - * @param string $addon_name |
|
273 | - * @param array $setup_args |
|
274 | - * @return void |
|
275 | - * @throws \EE_Error |
|
276 | - */ |
|
277 | - private static function _verify_parameters($addon_name, array $setup_args) |
|
278 | - { |
|
279 | - // required fields MUST be present, so let's make sure they are. |
|
280 | - if (empty($addon_name) || ! is_array($setup_args)) { |
|
281 | - throw new EE_Error( |
|
282 | - __( |
|
283 | - 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
284 | - 'event_espresso' |
|
285 | - ) |
|
286 | - ); |
|
287 | - } |
|
288 | - if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
289 | - throw new EE_Error( |
|
290 | - sprintf( |
|
291 | - __( |
|
292 | - 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
293 | - 'event_espresso' |
|
294 | - ), |
|
295 | - implode(',', array_keys($setup_args)) |
|
296 | - ) |
|
297 | - ); |
|
298 | - } |
|
299 | - // check that addon has not already been registered with that name |
|
300 | - if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
301 | - throw new EE_Error( |
|
302 | - sprintf( |
|
303 | - __( |
|
304 | - 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
305 | - 'event_espresso' |
|
306 | - ), |
|
307 | - $addon_name |
|
308 | - ) |
|
309 | - ); |
|
310 | - } |
|
265 | + $addon = \EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
266 | + $addon->after_registration(); |
|
267 | + } |
|
268 | + |
|
269 | + |
|
270 | + |
|
271 | + /** |
|
272 | + * @param string $addon_name |
|
273 | + * @param array $setup_args |
|
274 | + * @return void |
|
275 | + * @throws \EE_Error |
|
276 | + */ |
|
277 | + private static function _verify_parameters($addon_name, array $setup_args) |
|
278 | + { |
|
279 | + // required fields MUST be present, so let's make sure they are. |
|
280 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
281 | + throw new EE_Error( |
|
282 | + __( |
|
283 | + 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
284 | + 'event_espresso' |
|
285 | + ) |
|
286 | + ); |
|
287 | + } |
|
288 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
289 | + throw new EE_Error( |
|
290 | + sprintf( |
|
291 | + __( |
|
292 | + 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
293 | + 'event_espresso' |
|
294 | + ), |
|
295 | + implode(',', array_keys($setup_args)) |
|
296 | + ) |
|
297 | + ); |
|
298 | + } |
|
299 | + // check that addon has not already been registered with that name |
|
300 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
301 | + throw new EE_Error( |
|
302 | + sprintf( |
|
303 | + __( |
|
304 | + 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
305 | + 'event_espresso' |
|
306 | + ), |
|
307 | + $addon_name |
|
308 | + ) |
|
309 | + ); |
|
310 | + } |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | |
314 | 314 | |
315 | - /** |
|
316 | - * @param string $addon_name |
|
317 | - * @param array $setup_args |
|
318 | - * @return string |
|
319 | - */ |
|
320 | - private static function _parse_class_name($addon_name, array $setup_args) |
|
321 | - { |
|
322 | - if (empty($setup_args['class_name'])) { |
|
323 | - // generate one by first separating name with spaces |
|
324 | - $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
325 | - //capitalize, then replace spaces with underscores |
|
326 | - $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
327 | - } else { |
|
328 | - $class_name = $setup_args['class_name']; |
|
329 | - } |
|
330 | - return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
331 | - } |
|
332 | - |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * @param string $class_name |
|
337 | - * @param array $setup_args |
|
338 | - * @return array |
|
339 | - */ |
|
340 | - private static function _get_addon_settings($class_name, array $setup_args) |
|
341 | - { |
|
342 | - //setup $_settings array from incoming values. |
|
343 | - $addon_settings = array( |
|
344 | - // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
345 | - 'class_name' => $class_name, |
|
346 | - // the addon slug for use in URLs, etc |
|
347 | - 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
348 | - ? (string)$setup_args['plugin_slug'] |
|
349 | - : '', |
|
350 | - // page slug to be used when generating the "Settings" link on the WP plugin page |
|
351 | - 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
352 | - ? (string)$setup_args['plugin_action_slug'] |
|
353 | - : '', |
|
354 | - // the "software" version for the addon |
|
355 | - 'version' => isset($setup_args['version']) |
|
356 | - ? (string)$setup_args['version'] |
|
357 | - : '', |
|
358 | - // the minimum version of EE Core that the addon will work with |
|
359 | - 'min_core_version' => isset($setup_args['min_core_version']) |
|
360 | - ? (string)$setup_args['min_core_version'] |
|
361 | - : '', |
|
362 | - // the minimum version of WordPress that the addon will work with |
|
363 | - 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
364 | - ? (string)$setup_args['min_wp_version'] |
|
365 | - : EE_MIN_WP_VER_REQUIRED, |
|
366 | - // full server path to main file (file loaded directly by WP) |
|
367 | - 'main_file_path' => isset($setup_args['main_file_path']) |
|
368 | - ? (string)$setup_args['main_file_path'] |
|
369 | - : '', |
|
370 | - // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
371 | - 'admin_path' => isset($setup_args['admin_path']) |
|
372 | - ? (string)$setup_args['admin_path'] : '', |
|
373 | - // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
374 | - 'admin_callback' => isset($setup_args['admin_callback']) |
|
375 | - ? (string)$setup_args['admin_callback'] |
|
376 | - : '', |
|
377 | - // the section name for this addon's configuration settings section (defaults to "addons") |
|
378 | - 'config_section' => isset($setup_args['config_section']) |
|
379 | - ? (string)$setup_args['config_section'] |
|
380 | - : 'addons', |
|
381 | - // the class name for this addon's configuration settings object |
|
382 | - 'config_class' => isset($setup_args['config_class']) |
|
383 | - ? (string)$setup_args['config_class'] : '', |
|
384 | - //the name given to the config for this addons' configuration settings object (optional) |
|
385 | - 'config_name' => isset($setup_args['config_name']) |
|
386 | - ? (string)$setup_args['config_name'] : '', |
|
387 | - // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
388 | - 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
389 | - ? (array)$setup_args['autoloader_paths'] |
|
390 | - : array(), |
|
391 | - // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
392 | - 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
393 | - ? (array)$setup_args['autoloader_folders'] |
|
394 | - : array(), |
|
395 | - // array of full server paths to any EE_DMS data migration scripts used by the addon |
|
396 | - 'dms_paths' => isset($setup_args['dms_paths']) |
|
397 | - ? (array)$setup_args['dms_paths'] |
|
398 | - : array(), |
|
399 | - // array of full server paths to any EED_Modules used by the addon |
|
400 | - 'module_paths' => isset($setup_args['module_paths']) |
|
401 | - ? (array)$setup_args['module_paths'] |
|
402 | - : array(), |
|
403 | - // array of full server paths to any EES_Shortcodes used by the addon |
|
404 | - 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
405 | - ? (array)$setup_args['shortcode_paths'] |
|
406 | - : array(), |
|
407 | - // array of full server paths to any WP_Widgets used by the addon |
|
408 | - 'widget_paths' => isset($setup_args['widget_paths']) |
|
409 | - ? (array)$setup_args['widget_paths'] |
|
410 | - : array(), |
|
411 | - // array of PUE options used by the addon |
|
412 | - 'pue_options' => isset($setup_args['pue_options']) |
|
413 | - ? (array)$setup_args['pue_options'] |
|
414 | - : array(), |
|
415 | - 'message_types' => isset($setup_args['message_types']) |
|
416 | - ? (array)$setup_args['message_types'] |
|
417 | - : array(), |
|
418 | - 'capabilities' => isset($setup_args['capabilities']) |
|
419 | - ? (array)$setup_args['capabilities'] |
|
420 | - : array(), |
|
421 | - 'capability_maps' => isset($setup_args['capability_maps']) |
|
422 | - ? (array)$setup_args['capability_maps'] |
|
423 | - : array(), |
|
424 | - 'model_paths' => isset($setup_args['model_paths']) |
|
425 | - ? (array)$setup_args['model_paths'] |
|
426 | - : array(), |
|
427 | - 'class_paths' => isset($setup_args['class_paths']) |
|
428 | - ? (array)$setup_args['class_paths'] |
|
429 | - : array(), |
|
430 | - 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
431 | - ? (array)$setup_args['model_extension_paths'] |
|
432 | - : array(), |
|
433 | - 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
434 | - ? (array)$setup_args['class_extension_paths'] |
|
435 | - : array(), |
|
436 | - 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
437 | - ? (array)$setup_args['custom_post_types'] |
|
438 | - : array(), |
|
439 | - 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
440 | - ? (array)$setup_args['custom_taxonomies'] |
|
441 | - : array(), |
|
442 | - 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
443 | - ? (array)$setup_args['payment_method_paths'] |
|
444 | - : array(), |
|
445 | - 'default_terms' => isset($setup_args['default_terms']) |
|
446 | - ? (array)$setup_args['default_terms'] |
|
447 | - : array(), |
|
448 | - // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
449 | - // that can be used for adding upgrading/marketing info |
|
450 | - 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
451 | - ? $setup_args['plugins_page_row'] |
|
452 | - : '', |
|
453 | - 'namespace' => isset( |
|
454 | - $setup_args['namespace'], |
|
455 | - $setup_args['namespace']['FQNS'], |
|
456 | - $setup_args['namespace']['DIR'] |
|
457 | - ) |
|
458 | - ? (array)$setup_args['namespace'] |
|
459 | - : array(), |
|
460 | - ); |
|
461 | - // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
462 | - // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
463 | - $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
464 | - && ! empty($addon_settings['admin_path']) |
|
465 | - ? $addon_settings['plugin_slug'] |
|
466 | - : $addon_settings['plugin_action_slug']; |
|
467 | - // full server path to main file (file loaded directly by WP) |
|
468 | - $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
469 | - return $addon_settings; |
|
315 | + /** |
|
316 | + * @param string $addon_name |
|
317 | + * @param array $setup_args |
|
318 | + * @return string |
|
319 | + */ |
|
320 | + private static function _parse_class_name($addon_name, array $setup_args) |
|
321 | + { |
|
322 | + if (empty($setup_args['class_name'])) { |
|
323 | + // generate one by first separating name with spaces |
|
324 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
325 | + //capitalize, then replace spaces with underscores |
|
326 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
327 | + } else { |
|
328 | + $class_name = $setup_args['class_name']; |
|
329 | + } |
|
330 | + return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
470 | 331 | } |
471 | 332 | |
472 | 333 | |
473 | 334 | |
474 | - /** |
|
475 | - * @param string $addon_name |
|
476 | - * @param array $addon_settings |
|
477 | - * @return boolean |
|
478 | - */ |
|
335 | + /** |
|
336 | + * @param string $class_name |
|
337 | + * @param array $setup_args |
|
338 | + * @return array |
|
339 | + */ |
|
340 | + private static function _get_addon_settings($class_name, array $setup_args) |
|
341 | + { |
|
342 | + //setup $_settings array from incoming values. |
|
343 | + $addon_settings = array( |
|
344 | + // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
345 | + 'class_name' => $class_name, |
|
346 | + // the addon slug for use in URLs, etc |
|
347 | + 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
348 | + ? (string)$setup_args['plugin_slug'] |
|
349 | + : '', |
|
350 | + // page slug to be used when generating the "Settings" link on the WP plugin page |
|
351 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
352 | + ? (string)$setup_args['plugin_action_slug'] |
|
353 | + : '', |
|
354 | + // the "software" version for the addon |
|
355 | + 'version' => isset($setup_args['version']) |
|
356 | + ? (string)$setup_args['version'] |
|
357 | + : '', |
|
358 | + // the minimum version of EE Core that the addon will work with |
|
359 | + 'min_core_version' => isset($setup_args['min_core_version']) |
|
360 | + ? (string)$setup_args['min_core_version'] |
|
361 | + : '', |
|
362 | + // the minimum version of WordPress that the addon will work with |
|
363 | + 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
364 | + ? (string)$setup_args['min_wp_version'] |
|
365 | + : EE_MIN_WP_VER_REQUIRED, |
|
366 | + // full server path to main file (file loaded directly by WP) |
|
367 | + 'main_file_path' => isset($setup_args['main_file_path']) |
|
368 | + ? (string)$setup_args['main_file_path'] |
|
369 | + : '', |
|
370 | + // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
371 | + 'admin_path' => isset($setup_args['admin_path']) |
|
372 | + ? (string)$setup_args['admin_path'] : '', |
|
373 | + // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
374 | + 'admin_callback' => isset($setup_args['admin_callback']) |
|
375 | + ? (string)$setup_args['admin_callback'] |
|
376 | + : '', |
|
377 | + // the section name for this addon's configuration settings section (defaults to "addons") |
|
378 | + 'config_section' => isset($setup_args['config_section']) |
|
379 | + ? (string)$setup_args['config_section'] |
|
380 | + : 'addons', |
|
381 | + // the class name for this addon's configuration settings object |
|
382 | + 'config_class' => isset($setup_args['config_class']) |
|
383 | + ? (string)$setup_args['config_class'] : '', |
|
384 | + //the name given to the config for this addons' configuration settings object (optional) |
|
385 | + 'config_name' => isset($setup_args['config_name']) |
|
386 | + ? (string)$setup_args['config_name'] : '', |
|
387 | + // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
388 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
389 | + ? (array)$setup_args['autoloader_paths'] |
|
390 | + : array(), |
|
391 | + // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
392 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
393 | + ? (array)$setup_args['autoloader_folders'] |
|
394 | + : array(), |
|
395 | + // array of full server paths to any EE_DMS data migration scripts used by the addon |
|
396 | + 'dms_paths' => isset($setup_args['dms_paths']) |
|
397 | + ? (array)$setup_args['dms_paths'] |
|
398 | + : array(), |
|
399 | + // array of full server paths to any EED_Modules used by the addon |
|
400 | + 'module_paths' => isset($setup_args['module_paths']) |
|
401 | + ? (array)$setup_args['module_paths'] |
|
402 | + : array(), |
|
403 | + // array of full server paths to any EES_Shortcodes used by the addon |
|
404 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
405 | + ? (array)$setup_args['shortcode_paths'] |
|
406 | + : array(), |
|
407 | + // array of full server paths to any WP_Widgets used by the addon |
|
408 | + 'widget_paths' => isset($setup_args['widget_paths']) |
|
409 | + ? (array)$setup_args['widget_paths'] |
|
410 | + : array(), |
|
411 | + // array of PUE options used by the addon |
|
412 | + 'pue_options' => isset($setup_args['pue_options']) |
|
413 | + ? (array)$setup_args['pue_options'] |
|
414 | + : array(), |
|
415 | + 'message_types' => isset($setup_args['message_types']) |
|
416 | + ? (array)$setup_args['message_types'] |
|
417 | + : array(), |
|
418 | + 'capabilities' => isset($setup_args['capabilities']) |
|
419 | + ? (array)$setup_args['capabilities'] |
|
420 | + : array(), |
|
421 | + 'capability_maps' => isset($setup_args['capability_maps']) |
|
422 | + ? (array)$setup_args['capability_maps'] |
|
423 | + : array(), |
|
424 | + 'model_paths' => isset($setup_args['model_paths']) |
|
425 | + ? (array)$setup_args['model_paths'] |
|
426 | + : array(), |
|
427 | + 'class_paths' => isset($setup_args['class_paths']) |
|
428 | + ? (array)$setup_args['class_paths'] |
|
429 | + : array(), |
|
430 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
431 | + ? (array)$setup_args['model_extension_paths'] |
|
432 | + : array(), |
|
433 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
434 | + ? (array)$setup_args['class_extension_paths'] |
|
435 | + : array(), |
|
436 | + 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
437 | + ? (array)$setup_args['custom_post_types'] |
|
438 | + : array(), |
|
439 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
440 | + ? (array)$setup_args['custom_taxonomies'] |
|
441 | + : array(), |
|
442 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
443 | + ? (array)$setup_args['payment_method_paths'] |
|
444 | + : array(), |
|
445 | + 'default_terms' => isset($setup_args['default_terms']) |
|
446 | + ? (array)$setup_args['default_terms'] |
|
447 | + : array(), |
|
448 | + // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
449 | + // that can be used for adding upgrading/marketing info |
|
450 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
451 | + ? $setup_args['plugins_page_row'] |
|
452 | + : '', |
|
453 | + 'namespace' => isset( |
|
454 | + $setup_args['namespace'], |
|
455 | + $setup_args['namespace']['FQNS'], |
|
456 | + $setup_args['namespace']['DIR'] |
|
457 | + ) |
|
458 | + ? (array)$setup_args['namespace'] |
|
459 | + : array(), |
|
460 | + ); |
|
461 | + // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
462 | + // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
463 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
464 | + && ! empty($addon_settings['admin_path']) |
|
465 | + ? $addon_settings['plugin_slug'] |
|
466 | + : $addon_settings['plugin_action_slug']; |
|
467 | + // full server path to main file (file loaded directly by WP) |
|
468 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
469 | + return $addon_settings; |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + |
|
474 | + /** |
|
475 | + * @param string $addon_name |
|
476 | + * @param array $addon_settings |
|
477 | + * @return boolean |
|
478 | + */ |
|
479 | 479 | private static function _addon_is_compatible( $addon_name, array $addon_settings ) { |
480 | - global $wp_version; |
|
481 | - $incompatibility_message = ''; |
|
482 | - //check whether this addon version is compatible with EE core |
|
483 | - if ( |
|
484 | - isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
485 | - && ! self::_meets_min_core_version_requirement( |
|
486 | - EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
487 | - $addon_settings['version'] |
|
488 | - ) |
|
489 | - ) { |
|
490 | - $incompatibility_message = sprintf( |
|
491 | - __( |
|
492 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.' |
|
493 | - ), |
|
494 | - $addon_name, |
|
495 | - '<br />', |
|
496 | - EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
497 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
498 | - '</span><br />' |
|
499 | - ); |
|
500 | - } else if ( |
|
501 | - ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
502 | - ) { |
|
503 | - $incompatibility_message = sprintf( |
|
504 | - __( |
|
505 | - '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
506 | - 'event_espresso' |
|
507 | - ), |
|
508 | - $addon_name, |
|
509 | - self::_effective_version($addon_settings['min_core_version']), |
|
510 | - self::_effective_version(espresso_version()), |
|
511 | - '<br />', |
|
512 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
513 | - '</span><br />' |
|
514 | - ); |
|
515 | - } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
516 | - $incompatibility_message = sprintf( |
|
517 | - __( |
|
518 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
519 | - 'event_espresso' |
|
520 | - ), |
|
521 | - $addon_name, |
|
522 | - $addon_settings['min_wp_version'], |
|
523 | - '<br />', |
|
524 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
525 | - '</span><br />' |
|
526 | - ); |
|
527 | - } |
|
528 | - if ( ! empty($incompatibility_message)) { |
|
529 | - // remove 'activate' from the REQUEST |
|
530 | - // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
531 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
532 | - if (current_user_can('activate_plugins')) { |
|
533 | - // show an error message indicating the plugin didn't activate properly |
|
534 | - EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
535 | - } |
|
536 | - // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
537 | - return false; |
|
538 | - } |
|
539 | - // addon IS compatible |
|
540 | - return true; |
|
480 | + global $wp_version; |
|
481 | + $incompatibility_message = ''; |
|
482 | + //check whether this addon version is compatible with EE core |
|
483 | + if ( |
|
484 | + isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
485 | + && ! self::_meets_min_core_version_requirement( |
|
486 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
487 | + $addon_settings['version'] |
|
488 | + ) |
|
489 | + ) { |
|
490 | + $incompatibility_message = sprintf( |
|
491 | + __( |
|
492 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.' |
|
493 | + ), |
|
494 | + $addon_name, |
|
495 | + '<br />', |
|
496 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
497 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
498 | + '</span><br />' |
|
499 | + ); |
|
500 | + } else if ( |
|
501 | + ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
502 | + ) { |
|
503 | + $incompatibility_message = sprintf( |
|
504 | + __( |
|
505 | + '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
506 | + 'event_espresso' |
|
507 | + ), |
|
508 | + $addon_name, |
|
509 | + self::_effective_version($addon_settings['min_core_version']), |
|
510 | + self::_effective_version(espresso_version()), |
|
511 | + '<br />', |
|
512 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
513 | + '</span><br />' |
|
514 | + ); |
|
515 | + } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
516 | + $incompatibility_message = sprintf( |
|
517 | + __( |
|
518 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
519 | + 'event_espresso' |
|
520 | + ), |
|
521 | + $addon_name, |
|
522 | + $addon_settings['min_wp_version'], |
|
523 | + '<br />', |
|
524 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
525 | + '</span><br />' |
|
526 | + ); |
|
527 | + } |
|
528 | + if ( ! empty($incompatibility_message)) { |
|
529 | + // remove 'activate' from the REQUEST |
|
530 | + // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
531 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
532 | + if (current_user_can('activate_plugins')) { |
|
533 | + // show an error message indicating the plugin didn't activate properly |
|
534 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
535 | + } |
|
536 | + // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
537 | + return false; |
|
538 | + } |
|
539 | + // addon IS compatible |
|
540 | + return true; |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | |
544 | 544 | |
545 | - /** |
|
546 | - * if plugin update engine is being used for auto-updates, |
|
547 | - * then let's set that up now before going any further so that ALL addons can be updated |
|
548 | - * (not needed if PUE is not being used) |
|
549 | - * |
|
550 | - * @param string $addon_name |
|
551 | - * @param string $class_name |
|
552 | - * @param array $setup_args |
|
553 | - * @return void |
|
554 | - */ |
|
545 | + /** |
|
546 | + * if plugin update engine is being used for auto-updates, |
|
547 | + * then let's set that up now before going any further so that ALL addons can be updated |
|
548 | + * (not needed if PUE is not being used) |
|
549 | + * |
|
550 | + * @param string $addon_name |
|
551 | + * @param string $class_name |
|
552 | + * @param array $setup_args |
|
553 | + * @return void |
|
554 | + */ |
|
555 | 555 | private static function _parse_pue_options( $addon_name, $class_name, array $setup_args ) { |
556 | - if ( ! empty($setup_args['pue_options'])) { |
|
557 | - self::$_settings[$addon_name]['pue_options'] = array( |
|
558 | - 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
559 | - ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
560 | - : 'espresso_' . strtolower($class_name), |
|
561 | - 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
562 | - ? (string)$setup_args['pue_options']['plugin_basename'] |
|
563 | - : plugin_basename($setup_args['main_file_path']), |
|
564 | - 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
565 | - ? (string)$setup_args['pue_options']['checkPeriod'] |
|
566 | - : '24', |
|
567 | - 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
568 | - ? (string)$setup_args['pue_options']['use_wp_update'] |
|
569 | - : false, |
|
570 | - ); |
|
571 | - add_action( |
|
572 | - 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
573 | - array('EE_Register_Addon', 'load_pue_update') |
|
574 | - ); |
|
575 | - } |
|
556 | + if ( ! empty($setup_args['pue_options'])) { |
|
557 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
558 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
559 | + ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
560 | + : 'espresso_' . strtolower($class_name), |
|
561 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
562 | + ? (string)$setup_args['pue_options']['plugin_basename'] |
|
563 | + : plugin_basename($setup_args['main_file_path']), |
|
564 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
565 | + ? (string)$setup_args['pue_options']['checkPeriod'] |
|
566 | + : '24', |
|
567 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
568 | + ? (string)$setup_args['pue_options']['use_wp_update'] |
|
569 | + : false, |
|
570 | + ); |
|
571 | + add_action( |
|
572 | + 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
573 | + array('EE_Register_Addon', 'load_pue_update') |
|
574 | + ); |
|
575 | + } |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
579 | 579 | |
580 | - /** |
|
581 | - * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
582 | - * |
|
583 | - * @param array $addon_settings |
|
584 | - * @return void |
|
585 | - */ |
|
586 | - private static function _setup_namespaces(array $addon_settings) |
|
587 | - { |
|
588 | - // |
|
589 | - if ( |
|
590 | - isset( |
|
591 | - $addon_settings['namespace'], |
|
592 | - $addon_settings['namespace']['FQNS'], |
|
593 | - $addon_settings['namespace']['DIR'] |
|
594 | - ) |
|
595 | - ) { |
|
596 | - EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
597 | - $addon_settings['namespace']['FQNS'], |
|
598 | - $addon_settings['namespace']['DIR'] |
|
599 | - ); |
|
600 | - } |
|
601 | - } |
|
602 | - |
|
603 | - |
|
604 | - |
|
605 | - /** |
|
606 | - * @param string $addon_name |
|
607 | - * @param array $addon_settings |
|
608 | - * @return bool |
|
609 | - */ |
|
580 | + /** |
|
581 | + * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
582 | + * |
|
583 | + * @param array $addon_settings |
|
584 | + * @return void |
|
585 | + */ |
|
586 | + private static function _setup_namespaces(array $addon_settings) |
|
587 | + { |
|
588 | + // |
|
589 | + if ( |
|
590 | + isset( |
|
591 | + $addon_settings['namespace'], |
|
592 | + $addon_settings['namespace']['FQNS'], |
|
593 | + $addon_settings['namespace']['DIR'] |
|
594 | + ) |
|
595 | + ) { |
|
596 | + EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
597 | + $addon_settings['namespace']['FQNS'], |
|
598 | + $addon_settings['namespace']['DIR'] |
|
599 | + ); |
|
600 | + } |
|
601 | + } |
|
602 | + |
|
603 | + |
|
604 | + |
|
605 | + /** |
|
606 | + * @param string $addon_name |
|
607 | + * @param array $addon_settings |
|
608 | + * @return bool |
|
609 | + */ |
|
610 | 610 | private static function _addon_activation( $addon_name, array $addon_settings ) { |
611 | - // this is an activation request |
|
612 | - if (did_action('activate_plugin')) { |
|
613 | - //to find if THIS is the addon that was activated, |
|
614 | - //just check if we have already registered it or not |
|
615 | - //(as the newly-activated addon wasn't around the first time addons were registered) |
|
616 | - if ( ! isset(self::$_settings[$addon_name])) { |
|
617 | - self::$_settings[$addon_name] = $addon_settings; |
|
618 | - $addon = self::_load_and_init_addon_class($addon_name); |
|
619 | - $addon->set_activation_indicator_option(); |
|
620 | - // dont bother setting up the rest of the addon. |
|
621 | - // we know it was just activated and the request will end soon |
|
622 | - } |
|
623 | - return true; |
|
624 | - } else { |
|
625 | - // make sure this was called in the right place! |
|
626 | - if ( |
|
627 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
628 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
629 | - ) { |
|
630 | - EE_Error::doing_it_wrong( |
|
631 | - __METHOD__, |
|
632 | - sprintf( |
|
633 | - __( |
|
634 | - 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
635 | - 'event_espresso' |
|
636 | - ), |
|
637 | - $addon_name |
|
638 | - ), |
|
639 | - '4.3.0' |
|
640 | - ); |
|
641 | - } |
|
642 | - // make sure addon settings are set correctly without overwriting anything existing |
|
643 | - if (isset(self::$_settings[$addon_name])) { |
|
644 | - self::$_settings[$addon_name] += $addon_settings; |
|
645 | - } else { |
|
646 | - self::$_settings[$addon_name] = $addon_settings; |
|
647 | - } |
|
648 | - } |
|
649 | - return false; |
|
650 | - } |
|
651 | - |
|
652 | - |
|
653 | - |
|
654 | - /** |
|
655 | - * @param string $addon_name |
|
656 | - * @return void |
|
657 | - * @throws \EE_Error |
|
658 | - */ |
|
659 | - private static function _setup_autoloaders($addon_name) |
|
660 | - { |
|
661 | - if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
662 | - // setup autoloader for single file |
|
663 | - EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
664 | - } |
|
665 | - // setup autoloaders for folders |
|
666 | - if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
667 | - foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
668 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
669 | - } |
|
670 | - } |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - |
|
675 | - /** |
|
676 | - * register new models and extensions |
|
677 | - * |
|
678 | - * @param string $addon_name |
|
679 | - * @return void |
|
680 | - * @throws \EE_Error |
|
681 | - */ |
|
611 | + // this is an activation request |
|
612 | + if (did_action('activate_plugin')) { |
|
613 | + //to find if THIS is the addon that was activated, |
|
614 | + //just check if we have already registered it or not |
|
615 | + //(as the newly-activated addon wasn't around the first time addons were registered) |
|
616 | + if ( ! isset(self::$_settings[$addon_name])) { |
|
617 | + self::$_settings[$addon_name] = $addon_settings; |
|
618 | + $addon = self::_load_and_init_addon_class($addon_name); |
|
619 | + $addon->set_activation_indicator_option(); |
|
620 | + // dont bother setting up the rest of the addon. |
|
621 | + // we know it was just activated and the request will end soon |
|
622 | + } |
|
623 | + return true; |
|
624 | + } else { |
|
625 | + // make sure this was called in the right place! |
|
626 | + if ( |
|
627 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
628 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
629 | + ) { |
|
630 | + EE_Error::doing_it_wrong( |
|
631 | + __METHOD__, |
|
632 | + sprintf( |
|
633 | + __( |
|
634 | + 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
635 | + 'event_espresso' |
|
636 | + ), |
|
637 | + $addon_name |
|
638 | + ), |
|
639 | + '4.3.0' |
|
640 | + ); |
|
641 | + } |
|
642 | + // make sure addon settings are set correctly without overwriting anything existing |
|
643 | + if (isset(self::$_settings[$addon_name])) { |
|
644 | + self::$_settings[$addon_name] += $addon_settings; |
|
645 | + } else { |
|
646 | + self::$_settings[$addon_name] = $addon_settings; |
|
647 | + } |
|
648 | + } |
|
649 | + return false; |
|
650 | + } |
|
651 | + |
|
652 | + |
|
653 | + |
|
654 | + /** |
|
655 | + * @param string $addon_name |
|
656 | + * @return void |
|
657 | + * @throws \EE_Error |
|
658 | + */ |
|
659 | + private static function _setup_autoloaders($addon_name) |
|
660 | + { |
|
661 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
662 | + // setup autoloader for single file |
|
663 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
664 | + } |
|
665 | + // setup autoloaders for folders |
|
666 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
667 | + foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
668 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
669 | + } |
|
670 | + } |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + |
|
675 | + /** |
|
676 | + * register new models and extensions |
|
677 | + * |
|
678 | + * @param string $addon_name |
|
679 | + * @return void |
|
680 | + * @throws \EE_Error |
|
681 | + */ |
|
682 | 682 | private static function _register_models_and_extensions( $addon_name ) { |
683 | - // register new models |
|
684 | - if ( |
|
685 | - ! empty(self::$_settings[$addon_name]['model_paths']) |
|
686 | - || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
687 | - ) { |
|
688 | - EE_Register_Model::register( |
|
689 | - $addon_name, |
|
690 | - array( |
|
691 | - 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
692 | - 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
693 | - ) |
|
694 | - ); |
|
695 | - } |
|
696 | - // register model extensions |
|
697 | - if ( |
|
698 | - ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
699 | - || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
700 | - ) { |
|
701 | - EE_Register_Model_Extensions::register( |
|
702 | - $addon_name, |
|
703 | - array( |
|
704 | - 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
705 | - 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
706 | - ) |
|
707 | - ); |
|
708 | - } |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * @param string $addon_name |
|
715 | - * @return void |
|
716 | - * @throws \EE_Error |
|
717 | - */ |
|
683 | + // register new models |
|
684 | + if ( |
|
685 | + ! empty(self::$_settings[$addon_name]['model_paths']) |
|
686 | + || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
687 | + ) { |
|
688 | + EE_Register_Model::register( |
|
689 | + $addon_name, |
|
690 | + array( |
|
691 | + 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
692 | + 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
693 | + ) |
|
694 | + ); |
|
695 | + } |
|
696 | + // register model extensions |
|
697 | + if ( |
|
698 | + ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
699 | + || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
700 | + ) { |
|
701 | + EE_Register_Model_Extensions::register( |
|
702 | + $addon_name, |
|
703 | + array( |
|
704 | + 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
705 | + 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
706 | + ) |
|
707 | + ); |
|
708 | + } |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * @param string $addon_name |
|
715 | + * @return void |
|
716 | + * @throws \EE_Error |
|
717 | + */ |
|
718 | 718 | private static function _register_data_migration_scripts( $addon_name ) { |
719 | - // setup DMS |
|
720 | - if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
721 | - EE_Register_Data_Migration_Scripts::register( |
|
722 | - $addon_name, |
|
723 | - array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
724 | - ); |
|
725 | - } |
|
726 | - } |
|
727 | - |
|
728 | - |
|
729 | - /** |
|
730 | - * @param string $addon_name |
|
731 | - * @return void |
|
732 | - * @throws \EE_Error |
|
733 | - */ |
|
719 | + // setup DMS |
|
720 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
721 | + EE_Register_Data_Migration_Scripts::register( |
|
722 | + $addon_name, |
|
723 | + array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
724 | + ); |
|
725 | + } |
|
726 | + } |
|
727 | + |
|
728 | + |
|
729 | + /** |
|
730 | + * @param string $addon_name |
|
731 | + * @return void |
|
732 | + * @throws \EE_Error |
|
733 | + */ |
|
734 | 734 | private static function _register_config( $addon_name ) { |
735 | - // if config_class is present let's register config. |
|
736 | - if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
737 | - EE_Register_Config::register( |
|
738 | - self::$_settings[$addon_name]['config_class'], |
|
739 | - array( |
|
740 | - 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
741 | - 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
742 | - ) |
|
743 | - ); |
|
744 | - } |
|
745 | - } |
|
746 | - |
|
747 | - |
|
748 | - /** |
|
749 | - * @param string $addon_name |
|
750 | - * @return void |
|
751 | - * @throws \EE_Error |
|
752 | - */ |
|
735 | + // if config_class is present let's register config. |
|
736 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
737 | + EE_Register_Config::register( |
|
738 | + self::$_settings[$addon_name]['config_class'], |
|
739 | + array( |
|
740 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
741 | + 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
742 | + ) |
|
743 | + ); |
|
744 | + } |
|
745 | + } |
|
746 | + |
|
747 | + |
|
748 | + /** |
|
749 | + * @param string $addon_name |
|
750 | + * @return void |
|
751 | + * @throws \EE_Error |
|
752 | + */ |
|
753 | 753 | private static function _register_admin_pages( $addon_name ) { |
754 | - if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
755 | - EE_Register_Admin_Page::register( |
|
756 | - $addon_name, |
|
757 | - array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
758 | - ); |
|
759 | - } |
|
760 | - } |
|
761 | - |
|
762 | - |
|
763 | - /** |
|
764 | - * @param string $addon_name |
|
765 | - * @return void |
|
766 | - * @throws \EE_Error |
|
767 | - */ |
|
754 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
755 | + EE_Register_Admin_Page::register( |
|
756 | + $addon_name, |
|
757 | + array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
758 | + ); |
|
759 | + } |
|
760 | + } |
|
761 | + |
|
762 | + |
|
763 | + /** |
|
764 | + * @param string $addon_name |
|
765 | + * @return void |
|
766 | + * @throws \EE_Error |
|
767 | + */ |
|
768 | 768 | private static function _register_modules( $addon_name ) { |
769 | - if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
770 | - EE_Register_Module::register( |
|
771 | - $addon_name, |
|
772 | - array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
773 | - ); |
|
774 | - } |
|
775 | - } |
|
776 | - |
|
777 | - |
|
778 | - /** |
|
779 | - * @param string $addon_name |
|
780 | - * @return void |
|
781 | - * @throws \EE_Error |
|
782 | - */ |
|
769 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
770 | + EE_Register_Module::register( |
|
771 | + $addon_name, |
|
772 | + array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
773 | + ); |
|
774 | + } |
|
775 | + } |
|
776 | + |
|
777 | + |
|
778 | + /** |
|
779 | + * @param string $addon_name |
|
780 | + * @return void |
|
781 | + * @throws \EE_Error |
|
782 | + */ |
|
783 | 783 | private static function _register_shortcodes( $addon_name ) { |
784 | - if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
785 | - EE_Register_Shortcode::register( |
|
786 | - $addon_name, |
|
787 | - array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']) |
|
788 | - ); |
|
789 | - } |
|
790 | - } |
|
791 | - |
|
792 | - |
|
793 | - /** |
|
794 | - * @param string $addon_name |
|
795 | - * @return void |
|
796 | - * @throws \EE_Error |
|
797 | - */ |
|
784 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
785 | + EE_Register_Shortcode::register( |
|
786 | + $addon_name, |
|
787 | + array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']) |
|
788 | + ); |
|
789 | + } |
|
790 | + } |
|
791 | + |
|
792 | + |
|
793 | + /** |
|
794 | + * @param string $addon_name |
|
795 | + * @return void |
|
796 | + * @throws \EE_Error |
|
797 | + */ |
|
798 | 798 | private static function _register_widgets( $addon_name ) { |
799 | - if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
800 | - EE_Register_Widget::register( |
|
801 | - $addon_name, |
|
802 | - array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
803 | - ); |
|
804 | - } |
|
805 | - } |
|
806 | - |
|
807 | - |
|
808 | - /** |
|
809 | - * @param string $addon_name |
|
810 | - * @return void |
|
811 | - * @throws \EE_Error |
|
812 | - */ |
|
799 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
800 | + EE_Register_Widget::register( |
|
801 | + $addon_name, |
|
802 | + array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
803 | + ); |
|
804 | + } |
|
805 | + } |
|
806 | + |
|
807 | + |
|
808 | + /** |
|
809 | + * @param string $addon_name |
|
810 | + * @return void |
|
811 | + * @throws \EE_Error |
|
812 | + */ |
|
813 | 813 | private static function _register_capabilities( $addon_name ) { |
814 | - if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
815 | - EE_Register_Capabilities::register( |
|
816 | - $addon_name, |
|
817 | - array( |
|
818 | - 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
819 | - 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
820 | - ) |
|
821 | - ); |
|
822 | - } |
|
823 | - } |
|
824 | - |
|
825 | - |
|
826 | - /** |
|
827 | - * @param string $addon_name |
|
828 | - * @return void |
|
829 | - * @throws \EE_Error |
|
830 | - */ |
|
814 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
815 | + EE_Register_Capabilities::register( |
|
816 | + $addon_name, |
|
817 | + array( |
|
818 | + 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
819 | + 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
820 | + ) |
|
821 | + ); |
|
822 | + } |
|
823 | + } |
|
824 | + |
|
825 | + |
|
826 | + /** |
|
827 | + * @param string $addon_name |
|
828 | + * @return void |
|
829 | + * @throws \EE_Error |
|
830 | + */ |
|
831 | 831 | private static function _register_message_types( $addon_name ) { |
832 | - if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
833 | - add_action( |
|
834 | - 'EE_Brewing_Regular___messages_caf', |
|
835 | - array('EE_Register_Addon', 'register_message_types') |
|
836 | - ); |
|
837 | - } |
|
838 | - } |
|
839 | - |
|
840 | - |
|
841 | - /** |
|
842 | - * @param string $addon_name |
|
843 | - * @return void |
|
844 | - * @throws \EE_Error |
|
845 | - */ |
|
832 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
833 | + add_action( |
|
834 | + 'EE_Brewing_Regular___messages_caf', |
|
835 | + array('EE_Register_Addon', 'register_message_types') |
|
836 | + ); |
|
837 | + } |
|
838 | + } |
|
839 | + |
|
840 | + |
|
841 | + /** |
|
842 | + * @param string $addon_name |
|
843 | + * @return void |
|
844 | + * @throws \EE_Error |
|
845 | + */ |
|
846 | 846 | private static function _register_custom_post_types( $addon_name ) { |
847 | - if ( |
|
848 | - ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
849 | - || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
850 | - ) { |
|
851 | - EE_Register_CPT::register( |
|
852 | - $addon_name, |
|
853 | - array( |
|
854 | - 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
855 | - 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
856 | - 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
857 | - ) |
|
858 | - ); |
|
859 | - } |
|
860 | - } |
|
861 | - |
|
862 | - |
|
863 | - /** |
|
864 | - * @param string $addon_name |
|
865 | - * @return void |
|
866 | - * @throws \EE_Error |
|
867 | - */ |
|
847 | + if ( |
|
848 | + ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
849 | + || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
850 | + ) { |
|
851 | + EE_Register_CPT::register( |
|
852 | + $addon_name, |
|
853 | + array( |
|
854 | + 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
855 | + 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
856 | + 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
857 | + ) |
|
858 | + ); |
|
859 | + } |
|
860 | + } |
|
861 | + |
|
862 | + |
|
863 | + /** |
|
864 | + * @param string $addon_name |
|
865 | + * @return void |
|
866 | + * @throws \EE_Error |
|
867 | + */ |
|
868 | 868 | private static function _register_payment_methods( $addon_name ) { |
869 | - if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
870 | - EE_Register_Payment_Method::register( |
|
871 | - $addon_name, |
|
872 | - array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
873 | - ); |
|
874 | - } |
|
875 | - } |
|
869 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
870 | + EE_Register_Payment_Method::register( |
|
871 | + $addon_name, |
|
872 | + array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
873 | + ); |
|
874 | + } |
|
875 | + } |
|
876 | 876 | |
877 | 877 | |
878 | 878 | |
@@ -901,14 +901,14 @@ discard block |
||
901 | 901 | //unfortunately this can't be hooked in upon construction, because we don't have |
902 | 902 | //the plugin mainfile's path upon construction. |
903 | 903 | register_deactivation_hook( $addon->get_main_plugin_file(), array( $addon, 'deactivation' ) ); |
904 | - // call any additional admin_callback functions during load_admin_controller hook |
|
905 | - if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
906 | - add_action( |
|
907 | - 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
908 | - array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
909 | - ); |
|
910 | - } |
|
911 | - return $addon; |
|
904 | + // call any additional admin_callback functions during load_admin_controller hook |
|
905 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
906 | + add_action( |
|
907 | + 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
908 | + array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
909 | + ); |
|
910 | + } |
|
911 | + return $addon; |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | // cycle thru settings |
925 | 925 | foreach ( self::$_settings as $settings ) { |
926 | 926 | if ( ! empty( $settings['pue_options'] ) ) { |
927 | - // initiate the class and start the plugin update engine! |
|
927 | + // initiate the class and start the plugin update engine! |
|
928 | 928 | new PluginUpdateEngineChecker( |
929 | 929 | // host file URL |
930 | 930 | 'https://eventespresso.com', |
@@ -960,11 +960,11 @@ discard block |
||
960 | 960 | */ |
961 | 961 | public static function register_message_types() { |
962 | 962 | foreach ( self::$_settings as $addon_name => $settings ) { |
963 | - if ( ! empty($settings['message_types'])) { |
|
964 | - foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) { |
|
965 | - EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
966 | - } |
|
967 | - } |
|
963 | + if ( ! empty($settings['message_types'])) { |
|
964 | + foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) { |
|
965 | + EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
966 | + } |
|
967 | + } |
|
968 | 968 | } |
969 | 969 | } |
970 | 970 | |
@@ -1006,15 +1006,15 @@ discard block |
||
1006 | 1006 | EE_Register_Widget::deregister( $addon_name ); |
1007 | 1007 | } |
1008 | 1008 | if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) |
1009 | - || |
|
1010 | - ! empty( self::$_settings[ $addon_name ]['class_paths'] ) |
|
1009 | + || |
|
1010 | + ! empty( self::$_settings[ $addon_name ]['class_paths'] ) |
|
1011 | 1011 | ) { |
1012 | 1012 | // add to list of shortcodes to be registered |
1013 | 1013 | EE_Register_Model::deregister( $addon_name ); |
1014 | 1014 | } |
1015 | 1015 | if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) |
1016 | - || |
|
1017 | - ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] ) |
|
1016 | + || |
|
1017 | + ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] ) |
|
1018 | 1018 | ) { |
1019 | 1019 | // add to list of shortcodes to be registered |
1020 | 1020 | EE_Register_Model_Extensions::deregister( $addon_name ); |
@@ -187,6 +187,7 @@ |
||
187 | 187 | * when retrieving cached registrations from a transaction |
188 | 188 | * @param bool $trigger_notifications whether or not to call |
189 | 189 | * \EE_Registration_Processor::trigger_registration_update_notifications() |
190 | + * @param EE_Payment $payment |
|
190 | 191 | * @return array |
191 | 192 | * @throws \EE_Error |
192 | 193 | */ |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | * the interaction of EE_Transaction and EE_Registration model objects |
8 | 8 | * Provides methods for manipulating and processing changes to an EE_Transaction |
9 | 9 | * and it's related EE_Registrations with regards to the checkout/registration process |
10 | - |
|
11 | -* |
|
10 | + * |
|
12 | 11 | *@package Event Espresso |
13 | 12 | * @subpackage core |
14 | 13 | * @author Brent Christensen |
@@ -177,24 +176,24 @@ discard block |
||
177 | 176 | |
178 | 177 | |
179 | 178 | |
180 | - /** |
|
181 | - * update_transaction_and_registrations_after_checkout_or_payment |
|
182 | - * cycles thru related registrations and calls update_registration_after_checkout_or_payment() on each |
|
183 | - * |
|
184 | - * @param EE_Transaction $transaction |
|
185 | - * @param \EE_Payment | NULL $payment |
|
186 | - * @param array $registration_query_params array of query WHERE params to use |
|
187 | - * when retrieving cached registrations from a transaction |
|
188 | - * @param bool $trigger_notifications whether or not to call |
|
189 | - * \EE_Registration_Processor::trigger_registration_update_notifications() |
|
190 | - * @return array |
|
191 | - * @throws \EE_Error |
|
192 | - */ |
|
179 | + /** |
|
180 | + * update_transaction_and_registrations_after_checkout_or_payment |
|
181 | + * cycles thru related registrations and calls update_registration_after_checkout_or_payment() on each |
|
182 | + * |
|
183 | + * @param EE_Transaction $transaction |
|
184 | + * @param \EE_Payment | NULL $payment |
|
185 | + * @param array $registration_query_params array of query WHERE params to use |
|
186 | + * when retrieving cached registrations from a transaction |
|
187 | + * @param bool $trigger_notifications whether or not to call |
|
188 | + * \EE_Registration_Processor::trigger_registration_update_notifications() |
|
189 | + * @return array |
|
190 | + * @throws \EE_Error |
|
191 | + */ |
|
193 | 192 | public function update_transaction_and_registrations_after_checkout_or_payment( |
194 | 193 | EE_Transaction $transaction, |
195 | 194 | $payment = null, |
196 | 195 | $registration_query_params = array(), |
197 | - $trigger_notifications = true |
|
196 | + $trigger_notifications = true |
|
198 | 197 | ) { |
199 | 198 | // make sure some query params are set for retrieving registrations |
200 | 199 | $this->_set_registration_query_params( $registration_query_params ); |
@@ -224,15 +223,15 @@ discard block |
||
224 | 223 | $update_params |
225 | 224 | ); |
226 | 225 | if ($trigger_notifications) { |
227 | - // send messages |
|
228 | - /** @type EE_Registration_Processor $registration_processor */ |
|
229 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
230 | - $registration_processor->trigger_registration_update_notifications( |
|
231 | - $transaction->primary_registration(), |
|
232 | - $update_params |
|
233 | - ); |
|
234 | - } |
|
235 | - do_action( |
|
226 | + // send messages |
|
227 | + /** @type EE_Registration_Processor $registration_processor */ |
|
228 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
229 | + $registration_processor->trigger_registration_update_notifications( |
|
230 | + $transaction->primary_registration(), |
|
231 | + $update_params |
|
232 | + ); |
|
233 | + } |
|
234 | + do_action( |
|
236 | 235 | 'AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', |
237 | 236 | $transaction, |
238 | 237 | $update_params |
@@ -522,7 +521,7 @@ discard block |
||
522 | 521 | foreach ( $available_payment_methods as $available_payment_method ) { |
523 | 522 | if ( |
524 | 523 | $available_payment_method instanceof EE_Payment_Method |
525 | - && $available_payment_method->open_by_default() |
|
524 | + && $available_payment_method->open_by_default() |
|
526 | 525 | ) { |
527 | 526 | $PMD_ID = $available_payment_method->ID(); |
528 | 527 | break; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Class EE_Transaction_Processor |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | * @param array $registration_query_params |
51 | 51 | *@return EE_Transaction_Processor instance |
52 | 52 | */ |
53 | - public static function instance( $registration_query_params = array() ) { |
|
53 | + public static function instance($registration_query_params = array()) { |
|
54 | 54 | // check if class object is instantiated |
55 | - if ( ! self::$_instance instanceof EE_Transaction_Processor ) { |
|
56 | - self::$_instance = new self( $registration_query_params ); |
|
55 | + if ( ! self::$_instance instanceof EE_Transaction_Processor) { |
|
56 | + self::$_instance = new self($registration_query_params); |
|
57 | 57 | } |
58 | 58 | return self::$_instance; |
59 | 59 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @param array $registration_query_params |
65 | 65 | */ |
66 | - private function __construct( $registration_query_params = array() ) { |
|
66 | + private function __construct($registration_query_params = array()) { |
|
67 | 67 | // make sure some query params are set for retrieving registrations |
68 | - $this->_set_registration_query_params( $registration_query_params ); |
|
68 | + $this->_set_registration_query_params($registration_query_params); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * @access private |
75 | 75 | * @param array $registration_query_params |
76 | 76 | */ |
77 | - private function _set_registration_query_params( $registration_query_params ) { |
|
78 | - $this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
77 | + private function _set_registration_query_params($registration_query_params) { |
|
78 | + $this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC')); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | ); |
105 | 105 | // send messages |
106 | 106 | /** @type EE_Registration_Processor $registration_processor */ |
107 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
107 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
108 | 108 | $registration_processor->trigger_registration_update_notifications( |
109 | 109 | $transaction->primary_registration(), |
110 | - array( 'manually_updated' => true ) |
|
110 | + array('manually_updated' => true) |
|
111 | 111 | ); |
112 | 112 | do_action( |
113 | 113 | 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', |
@@ -197,13 +197,13 @@ discard block |
||
197 | 197 | $trigger_notifications = true |
198 | 198 | ) { |
199 | 199 | // make sure some query params are set for retrieving registrations |
200 | - $this->_set_registration_query_params( $registration_query_params ); |
|
200 | + $this->_set_registration_query_params($registration_query_params); |
|
201 | 201 | // get final reg step status |
202 | 202 | $finalized = $transaction->final_reg_step_completed(); |
203 | 203 | // if the 'finalize_registration' step has been initiated (has a timestamp) |
204 | 204 | // but has not yet been fully completed (TRUE) |
205 | - if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) { |
|
206 | - $transaction->set_reg_step_completed( 'finalize_registration' ); |
|
205 | + if (is_int($finalized) && $finalized !== false && $finalized !== true) { |
|
206 | + $transaction->set_reg_step_completed('finalize_registration'); |
|
207 | 207 | $finalized = true; |
208 | 208 | } |
209 | 209 | $transaction->save(); |
@@ -258,22 +258,22 @@ discard block |
||
258 | 258 | $update_txn = true |
259 | 259 | ) { |
260 | 260 | // these reg statuses should not be considered in any calculations involving monies owing |
261 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
262 | - if ( in_array( $registration->status_ID(), $closed_reg_statuses ) ) { |
|
261 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
262 | + if (in_array($registration->status_ID(), $closed_reg_statuses)) { |
|
263 | 263 | return false; |
264 | 264 | } |
265 | 265 | try { |
266 | - $transaction = $this->get_transaction_for_registration( $registration ); |
|
266 | + $transaction = $this->get_transaction_for_registration($registration); |
|
267 | 267 | $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration( |
268 | 268 | $transaction, |
269 | 269 | $registration |
270 | 270 | ); |
271 | 271 | // un-cancel the ticket |
272 | - $success = EEH_Line_Item::reinstate_canceled_ticket_line_item( $ticket_line_item ); |
|
273 | - } catch ( EE_Error $e ) { |
|
272 | + $success = EEH_Line_Item::reinstate_canceled_ticket_line_item($ticket_line_item); |
|
273 | + } catch (EE_Error $e) { |
|
274 | 274 | EE_Error::add_error( |
275 | 275 | sprintf( |
276 | - __( 'The Ticket Line Item for Registration %1$d could not be reinstated because :%2$s%3$s', 'event_espresso' ), |
|
276 | + __('The Ticket Line Item for Registration %1$d could not be reinstated because :%2$s%3$s', 'event_espresso'), |
|
277 | 277 | $registration->ID(), |
278 | 278 | '<br />', |
279 | 279 | $e->getMessage() |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | ); |
283 | 283 | return false; |
284 | 284 | } |
285 | - if ( $update_txn ) { |
|
285 | + if ($update_txn) { |
|
286 | 286 | return $transaction->save() ? $success : false; |
287 | 287 | } |
288 | 288 | return $success; |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | $update_txn = true |
307 | 307 | ) { |
308 | 308 | // these reg statuses should not be considered in any calculations involving monies owing |
309 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
310 | - if ( ! in_array( $registration->status_ID(), $closed_reg_statuses ) ) { |
|
309 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
310 | + if ( ! in_array($registration->status_ID(), $closed_reg_statuses)) { |
|
311 | 311 | return false; |
312 | 312 | } |
313 | 313 | try { |
314 | - $transaction = $this->get_transaction_for_registration( $registration ); |
|
315 | - $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration( $transaction, $registration ); |
|
316 | - EEH_Line_Item::cancel_ticket_line_item( $ticket_line_item ); |
|
317 | - } catch ( EE_Error $e ) { |
|
314 | + $transaction = $this->get_transaction_for_registration($registration); |
|
315 | + $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration($transaction, $registration); |
|
316 | + EEH_Line_Item::cancel_ticket_line_item($ticket_line_item); |
|
317 | + } catch (EE_Error $e) { |
|
318 | 318 | EE_Error::add_error( |
319 | 319 | sprintf( |
320 | - __( 'The Ticket Line Item for Registration %1$d could not be cancelled because :%2$s%3$s', 'event_espresso' ), |
|
320 | + __('The Ticket Line Item for Registration %1$d could not be cancelled because :%2$s%3$s', 'event_espresso'), |
|
321 | 321 | $registration->ID(), |
322 | 322 | '<br />', |
323 | 323 | $e->getMessage() |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | ); |
327 | 327 | return false; |
328 | 328 | } |
329 | - if ( $update_txn ) { |
|
329 | + if ($update_txn) { |
|
330 | 330 | return $transaction->save() ? true : false; |
331 | 331 | } |
332 | 332 | return true; |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | * @return EE_Transaction |
343 | 343 | * @throws EE_Error |
344 | 344 | */ |
345 | - public function get_transaction_for_registration( EE_Registration $registration ) { |
|
345 | + public function get_transaction_for_registration(EE_Registration $registration) { |
|
346 | 346 | $transaction = $registration->transaction(); |
347 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
347 | + if ( ! $transaction instanceof EE_Transaction) { |
|
348 | 348 | throw new EE_Error( |
349 | 349 | sprintf( |
350 | - __( 'The Transaction for Registration %1$d was not found or is invalid.', 'event_espresso' ), |
|
350 | + __('The Transaction for Registration %1$d was not found or is invalid.', 'event_espresso'), |
|
351 | 351 | $registration->ID() |
352 | 352 | ) |
353 | 353 | ); |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | EE_Transaction $transaction, |
371 | 371 | EE_Registration $registration |
372 | 372 | ) { |
373 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
373 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
374 | 374 | $ticket_line_item = EEM_Line_Item::instance()->get_ticket_line_item_for_transaction( |
375 | 375 | $transaction->ID(), |
376 | 376 | $registration->ticket_ID() |
377 | 377 | ); |
378 | - if ( ! $ticket_line_item instanceof EE_Line_Item ) { |
|
378 | + if ( ! $ticket_line_item instanceof EE_Line_Item) { |
|
379 | 379 | throw new EE_Error( |
380 | 380 | sprintf( |
381 | - __( 'The Line Item for Transaction %1$d and Ticket %2$d was not found or is invalid.', |
|
382 | - 'event_espresso' ), |
|
381 | + __('The Line Item for Transaction %1$d and Ticket %2$d was not found or is invalid.', |
|
382 | + 'event_espresso'), |
|
383 | 383 | $transaction->ID(), |
384 | 384 | $registration->ticket_ID() |
385 | 385 | ) |
@@ -412,22 +412,22 @@ discard block |
||
412 | 412 | $update_txn = true |
413 | 413 | ) { |
414 | 414 | // make sure some query params are set for retrieving registrations |
415 | - $this->_set_registration_query_params( $registration_query_params ); |
|
415 | + $this->_set_registration_query_params($registration_query_params); |
|
416 | 416 | // these reg statuses should not be considered in any calculations involving monies owing |
417 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
417 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
418 | 418 | // loop through cached registrations |
419 | - foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) { |
|
419 | + foreach ($transaction->registrations($this->_registration_query_params) as $registration) { |
|
420 | 420 | if ( |
421 | 421 | $registration instanceof EE_Registration |
422 | - && ! in_array( $registration->status_ID(), $closed_reg_statuses ) |
|
422 | + && ! in_array($registration->status_ID(), $closed_reg_statuses) |
|
423 | 423 | ) { |
424 | 424 | return false; |
425 | 425 | } |
426 | 426 | } |
427 | - if ( in_array( $new_TXN_status, EEM_Transaction::txn_status_array() ) ) { |
|
428 | - $transaction->set_status( $new_TXN_status ); |
|
427 | + if (in_array($new_TXN_status, EEM_Transaction::txn_status_array())) { |
|
428 | + $transaction->set_status($new_TXN_status); |
|
429 | 429 | } |
430 | - if ( $update_txn ) { |
|
430 | + if ($update_txn) { |
|
431 | 431 | return $transaction->save() ? true : false; |
432 | 432 | } |
433 | 433 | return true; |
@@ -456,22 +456,22 @@ discard block |
||
456 | 456 | ) { |
457 | 457 | $response = false; |
458 | 458 | /** @type EE_Registration_Processor $registration_processor */ |
459 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
459 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
460 | 460 | // check that method exists |
461 | - if ( ! method_exists( $registration_processor, $method_name )) { |
|
462 | - throw new EE_Error( __( 'Method does not exist.', 'event_espresso' )); |
|
461 | + if ( ! method_exists($registration_processor, $method_name)) { |
|
462 | + throw new EE_Error(__('Method does not exist.', 'event_espresso')); |
|
463 | 463 | } |
464 | 464 | // make sure some query params are set for retrieving registrations |
465 | - $this->_set_registration_query_params( $registration_query_params ); |
|
465 | + $this->_set_registration_query_params($registration_query_params); |
|
466 | 466 | // loop through cached registrations |
467 | - foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) { |
|
468 | - if ( $registration instanceof EE_Registration ) { |
|
469 | - if ( $additional_param ) { |
|
470 | - $response = $registration_processor->{$method_name}( $registration, $additional_param ) |
|
467 | + foreach ($transaction->registrations($this->_registration_query_params) as $registration) { |
|
468 | + if ($registration instanceof EE_Registration) { |
|
469 | + if ($additional_param) { |
|
470 | + $response = $registration_processor->{$method_name}($registration, $additional_param) |
|
471 | 471 | ? true |
472 | 472 | : $response; |
473 | 473 | } else { |
474 | - $response = $registration_processor->{$method_name}( $registration ) |
|
474 | + $response = $registration_processor->{$method_name}($registration) |
|
475 | 475 | ? true |
476 | 476 | : $response; |
477 | 477 | } |
@@ -498,28 +498,28 @@ discard block |
||
498 | 498 | public function set_transaction_payment_method_based_on_registration_statuses( |
499 | 499 | EE_Registration $edited_registration |
500 | 500 | ) { |
501 | - if ( $edited_registration instanceof EE_Registration ) { |
|
501 | + if ($edited_registration instanceof EE_Registration) { |
|
502 | 502 | $transaction = $edited_registration->transaction(); |
503 | - if ( $transaction instanceof EE_Transaction ) { |
|
503 | + if ($transaction instanceof EE_Transaction) { |
|
504 | 504 | $all_not_approved = true; |
505 | - foreach ( $transaction->registrations() as $registration ) { |
|
506 | - if ( $registration instanceof EE_Registration ) { |
|
505 | + foreach ($transaction->registrations() as $registration) { |
|
506 | + if ($registration instanceof EE_Registration) { |
|
507 | 507 | // if any REG != "Not Approved" then toggle to false |
508 | 508 | $all_not_approved = $registration->is_not_approved() ? $all_not_approved : false; |
509 | 509 | } |
510 | 510 | } |
511 | 511 | // if ALL Registrations are "Not Approved" |
512 | - if ( $all_not_approved ) { |
|
513 | - $transaction->set_payment_method_ID( null ); |
|
512 | + if ($all_not_approved) { |
|
513 | + $transaction->set_payment_method_ID(null); |
|
514 | 514 | $transaction->save(); |
515 | 515 | } else { |
516 | 516 | $available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
517 | 517 | $transaction, |
518 | 518 | EEM_Payment_Method::scope_cart |
519 | 519 | ); |
520 | - if ( ! empty( $available_payment_methods ) ) { |
|
520 | + if ( ! empty($available_payment_methods)) { |
|
521 | 521 | $PMD_ID = 0; |
522 | - foreach ( $available_payment_methods as $available_payment_method ) { |
|
522 | + foreach ($available_payment_methods as $available_payment_method) { |
|
523 | 523 | if ( |
524 | 524 | $available_payment_method instanceof EE_Payment_Method |
525 | 525 | && $available_payment_method->open_by_default() |
@@ -528,22 +528,22 @@ discard block |
||
528 | 528 | break; |
529 | 529 | } |
530 | 530 | } |
531 | - if ( ! $PMD_ID ) { |
|
532 | - $first_payment_method = reset( $available_payment_methods ); |
|
533 | - if ( $first_payment_method instanceof EE_Payment_Method ) { |
|
531 | + if ( ! $PMD_ID) { |
|
532 | + $first_payment_method = reset($available_payment_methods); |
|
533 | + if ($first_payment_method instanceof EE_Payment_Method) { |
|
534 | 534 | $PMD_ID = $first_payment_method->ID(); |
535 | 535 | } else { |
536 | 536 | EE_Error::add_error( |
537 | - __( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ), |
|
537 | + __('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'), |
|
538 | 538 | __FILE__, __LINE__, __FUNCTION__ |
539 | 539 | ); |
540 | 540 | } |
541 | 541 | } |
542 | - $transaction->set_payment_method_ID( $PMD_ID ); |
|
542 | + $transaction->set_payment_method_ID($PMD_ID); |
|
543 | 543 | $transaction->save(); |
544 | 544 | } else { |
545 | 545 | EE_Error::add_error( |
546 | - __( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ), |
|
546 | + __('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'), |
|
547 | 547 | __FILE__, __LINE__, __FUNCTION__ |
548 | 548 | ); |
549 | 549 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * @deprecated 4.9.12 |
581 | 581 | * @param string $old_txn_status |
582 | 582 | */ |
583 | - public function set_old_txn_status( $old_txn_status ) { |
|
583 | + public function set_old_txn_status($old_txn_status) { |
|
584 | 584 | EE_Error::doing_it_wrong( |
585 | 585 | __METHOD__, |
586 | 586 | esc_html__( |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | '4.9.12' |
591 | 591 | ); |
592 | 592 | // only set the first time |
593 | - if ( $this->_old_txn_status === null ) { |
|
593 | + if ($this->_old_txn_status === null) { |
|
594 | 594 | $this->_old_txn_status = $old_txn_status; |
595 | 595 | } |
596 | 596 | } |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @deprecated 4.9.12 |
620 | 620 | * @param string $new_txn_status |
621 | 621 | */ |
622 | - public function set_new_txn_status( $new_txn_status ) { |
|
622 | + public function set_new_txn_status($new_txn_status) { |
|
623 | 623 | EE_Error::doing_it_wrong( |
624 | 624 | __METHOD__, |
625 | 625 | esc_html__( |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | * @param EE_Transaction $transaction |
664 | 664 | * @return boolean |
665 | 665 | */ |
666 | - public function all_reg_steps_completed( EE_Transaction $transaction ) { |
|
666 | + public function all_reg_steps_completed(EE_Transaction $transaction) { |
|
667 | 667 | EE_Error::doing_it_wrong( |
668 | 668 | __METHOD__, |
669 | 669 | esc_html__( |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | * @param string $exception |
691 | 691 | * @return boolean |
692 | 692 | */ |
693 | - public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) { |
|
693 | + public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') { |
|
694 | 694 | EE_Error::doing_it_wrong( |
695 | 695 | __METHOD__, |
696 | 696 | esc_html__( |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | '4.9.12', |
701 | 701 | '5.0.0' |
702 | 702 | ); |
703 | - return $transaction->all_reg_steps_completed_except( $exception ); |
|
703 | + return $transaction->all_reg_steps_completed_except($exception); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | * @param EE_Transaction $transaction |
717 | 717 | * @return boolean |
718 | 718 | */ |
719 | - public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) { |
|
719 | + public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) { |
|
720 | 720 | EE_Error::doing_it_wrong( |
721 | 721 | __METHOD__, |
722 | 722 | esc_html__( |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | * @param string $reg_step_slug |
744 | 744 | * @return boolean | int |
745 | 745 | */ |
746 | - public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
746 | + public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
747 | 747 | EE_Error::doing_it_wrong( |
748 | 748 | __METHOD__, |
749 | 749 | esc_html__( |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | '4.9.12', |
754 | 754 | '5.0.0' |
755 | 755 | ); |
756 | - return $transaction->reg_step_completed( $reg_step_slug ); |
|
756 | + return $transaction->reg_step_completed($reg_step_slug); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | * @param EE_Transaction $transaction |
770 | 770 | * @return boolean | int |
771 | 771 | */ |
772 | - public function final_reg_step_completed( EE_Transaction $transaction ) { |
|
772 | + public function final_reg_step_completed(EE_Transaction $transaction) { |
|
773 | 773 | EE_Error::doing_it_wrong( |
774 | 774 | __METHOD__, |
775 | 775 | esc_html__( |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * @return boolean |
796 | 796 | * @throws \EE_Error |
797 | 797 | */ |
798 | - public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) { |
|
798 | + public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) { |
|
799 | 799 | EE_Error::doing_it_wrong( |
800 | 800 | __METHOD__, |
801 | 801 | esc_html__( |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | '4.9.12', |
806 | 806 | '5.0.0' |
807 | 807 | ); |
808 | - return $transaction->set_reg_step_initiated( $reg_step_slug ); |
|
808 | + return $transaction->set_reg_step_initiated($reg_step_slug); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | * @return boolean |
822 | 822 | * @throws \EE_Error |
823 | 823 | */ |
824 | - public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
824 | + public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
825 | 825 | EE_Error::doing_it_wrong( |
826 | 826 | __METHOD__, |
827 | 827 | esc_html__( |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | '4.9.12', |
832 | 832 | '5.0.0' |
833 | 833 | ); |
834 | - return $transaction->set_reg_step_completed( $reg_step_slug ); |
|
834 | + return $transaction->set_reg_step_completed($reg_step_slug); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | * @return boolean |
848 | 848 | * @throws \EE_Error |
849 | 849 | */ |
850 | - public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
850 | + public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
851 | 851 | EE_Error::doing_it_wrong( |
852 | 852 | __METHOD__, |
853 | 853 | esc_html__( |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | '4.9.12', |
858 | 858 | '5.0.0' |
859 | 859 | ); |
860 | - return $transaction->set_reg_step_not_completed( $reg_step_slug ); |
|
860 | + return $transaction->set_reg_step_not_completed($reg_step_slug); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | * @param string $reg_step_slug |
875 | 875 | * @return void |
876 | 876 | */ |
877 | - public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) { |
|
877 | + public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) { |
|
878 | 878 | EE_Error::doing_it_wrong( |
879 | 879 | __METHOD__, |
880 | 880 | esc_html__( |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | '4.9.12', |
885 | 885 | '5.0.0' |
886 | 886 | ); |
887 | - $transaction->remove_reg_step( $reg_step_slug ); |
|
887 | + $transaction->remove_reg_step($reg_step_slug); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | * @return boolean |
901 | 901 | * @throws \EE_Error |
902 | 902 | */ |
903 | - public function toggle_failed_transaction_status( EE_Transaction $transaction ) { |
|
903 | + public function toggle_failed_transaction_status(EE_Transaction $transaction) { |
|
904 | 904 | EE_Error::doing_it_wrong( |
905 | 905 | __METHOD__, |
906 | 906 | esc_html__( |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | * @param EE_Transaction $transaction |
925 | 925 | * @return boolean |
926 | 926 | */ |
927 | - public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) { |
|
927 | + public function toggle_abandoned_transaction_status(EE_Transaction $transaction) { |
|
928 | 928 | EE_Error::doing_it_wrong( |
929 | 929 | __METHOD__, |
930 | 930 | esc_html__( |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
217 | 217 | if ( ! EE_Processor_Base::$IPN ) { |
218 | - // otherwise, send out notifications |
|
218 | + // otherwise, send out notifications |
|
219 | 219 | add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
220 | 220 | } |
221 | 221 | // DEBUG LOG |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | } |
263 | 263 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
264 | 264 | if ( ! EE_Processor_Base::$IPN ) { |
265 | - // otherwise, send out notifications |
|
265 | + // otherwise, send out notifications |
|
266 | 266 | add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
267 | 267 | } |
268 | 268 | // DEBUG LOG |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | } |
350 | 350 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
351 | 351 | if ( ! EE_Processor_Base::$IPN ) { |
352 | - // otherwise, send out notifications |
|
352 | + // otherwise, send out notifications |
|
353 | 353 | add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
354 | 354 | } |
355 | 355 | // DEBUG LOG |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | // false, |
391 | 391 | // 'EE_Transaction: ' . $registration->transaction()->ID() |
392 | 392 | // ); |
393 | - if ( ! $registration->is_primary_registrant()) { |
|
394 | - return; |
|
395 | - } |
|
396 | - do_action( |
|
393 | + if ( ! $registration->is_primary_registrant()) { |
|
394 | + return; |
|
395 | + } |
|
396 | + do_action( |
|
397 | 397 | 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
398 | 398 | $registration, |
399 | 399 | $additional_details |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | // set new REG_Status |
429 | 429 | $this->set_new_reg_status( $registration->ID(), $registration->status_ID() ); |
430 | 430 | return $this->reg_status_updated( $registration->ID() ) |
431 | - && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved |
|
431 | + && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved |
|
432 | 432 | ? true |
433 | 433 | : false; |
434 | 434 | } |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | use EventEspresso\core\domain\entities\RegUrlLink; |
4 | 4 | use EventEspresso\core\domain\services\registration\CreateRegistrationService; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
7 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
7 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Class EE_Registration_Processor |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public static function instance() { |
68 | 68 | // check if class object is instantiated |
69 | - if ( ! self::$_instance instanceof EE_Registration_Processor ) { |
|
69 | + if ( ! self::$_instance instanceof EE_Registration_Processor) { |
|
70 | 70 | self::$_instance = new self(); |
71 | 71 | } |
72 | 72 | return self::$_instance; |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @param int $REG_ID |
87 | 87 | * @return string |
88 | 88 | */ |
89 | - public function old_reg_status( $REG_ID ) { |
|
90 | - return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null; |
|
89 | + public function old_reg_status($REG_ID) { |
|
90 | + return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * @param int $REG_ID |
97 | 97 | * @param string $old_reg_status |
98 | 98 | */ |
99 | - public function set_old_reg_status( $REG_ID, $old_reg_status ) { |
|
99 | + public function set_old_reg_status($REG_ID, $old_reg_status) { |
|
100 | 100 | // only set the first time |
101 | - if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) { |
|
102 | - $this->_old_reg_status[ $REG_ID ] = $old_reg_status; |
|
101 | + if ( ! isset($this->_old_reg_status[$REG_ID])) { |
|
102 | + $this->_old_reg_status[$REG_ID] = $old_reg_status; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @param int $REG_ID |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public function new_reg_status( $REG_ID ) { |
|
113 | - return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null; |
|
112 | + public function new_reg_status($REG_ID) { |
|
113 | + return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @param int $REG_ID |
120 | 120 | * @param string $new_reg_status |
121 | 121 | */ |
122 | - public function set_new_reg_status( $REG_ID, $new_reg_status ) { |
|
123 | - $this->_new_reg_status[ $REG_ID ] = $new_reg_status; |
|
122 | + public function set_new_reg_status($REG_ID, $new_reg_status) { |
|
123 | + $this->_new_reg_status[$REG_ID] = $new_reg_status; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param int $REG_ID |
132 | 132 | * @return bool |
133 | 133 | */ |
134 | - public function reg_status_updated( $REG_ID ) { |
|
135 | - return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false; |
|
134 | + public function reg_status_updated($REG_ID) { |
|
135 | + return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | * @param \EE_Registration $registration |
142 | 142 | * @throws \EE_Error |
143 | 143 | */ |
144 | - public function update_registration_status_and_trigger_notifications( \EE_Registration $registration ) { |
|
145 | - $this->toggle_incomplete_registration_status_to_default( $registration, false ); |
|
146 | - $this->toggle_registration_status_for_default_approved_events( $registration, false ); |
|
147 | - $this->toggle_registration_status_if_no_monies_owing( $registration, false ); |
|
144 | + public function update_registration_status_and_trigger_notifications(\EE_Registration $registration) { |
|
145 | + $this->toggle_incomplete_registration_status_to_default($registration, false); |
|
146 | + $this->toggle_registration_status_for_default_approved_events($registration, false); |
|
147 | + $this->toggle_registration_status_if_no_monies_owing($registration, false); |
|
148 | 148 | $registration->save(); |
149 | 149 | // trigger notifications |
150 | - $this->trigger_registration_update_notifications( $registration ); |
|
150 | + $this->trigger_registration_update_notifications($registration); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -162,18 +162,18 @@ discard block |
||
162 | 162 | * @return boolean |
163 | 163 | * @throws \EE_Error |
164 | 164 | */ |
165 | - public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) { |
|
165 | + public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) { |
|
166 | 166 | // set initial REG_Status |
167 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
167 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
168 | 168 | // set incoming REG_Status |
169 | - $this->set_new_reg_status( $registration->ID(), $new_reg_status ); |
|
169 | + $this->set_new_reg_status($registration->ID(), $new_reg_status); |
|
170 | 170 | // toggle reg status but only if it has changed and the user can do so |
171 | 171 | if ( |
172 | - $this->reg_status_updated( $registration->ID() ) && |
|
173 | - EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() ) |
|
172 | + $this->reg_status_updated($registration->ID()) && |
|
173 | + EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID()) |
|
174 | 174 | ) { |
175 | 175 | // change status to new value |
176 | - if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) ) && $save ) { |
|
176 | + if ($registration->set_status($this->new_reg_status($registration->ID())) && $save) { |
|
177 | 177 | $registration->save(); |
178 | 178 | } |
179 | 179 | return TRUE; |
@@ -193,30 +193,30 @@ discard block |
||
193 | 193 | * @return void |
194 | 194 | * @throws \EE_Error |
195 | 195 | */ |
196 | - public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) { |
|
196 | + public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) { |
|
197 | 197 | $existing_reg_status = $registration->status_ID(); |
198 | 198 | // set initial REG_Status |
199 | - $this->set_old_reg_status( $registration->ID(), $existing_reg_status ); |
|
199 | + $this->set_old_reg_status($registration->ID(), $existing_reg_status); |
|
200 | 200 | // is the registration currently incomplete ? |
201 | - if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) { |
|
201 | + if ($registration->status_ID() === EEM_Registration::status_id_incomplete) { |
|
202 | 202 | // grab default reg status for the event, if set |
203 | 203 | $event_default_registration_status = $registration->event()->default_registration_status(); |
204 | 204 | // if no default reg status is set for the event, then use the global value |
205 | - $STS_ID = ! empty( $event_default_registration_status ) |
|
205 | + $STS_ID = ! empty($event_default_registration_status) |
|
206 | 206 | ? $event_default_registration_status |
207 | 207 | : EE_Registry::instance()->CFG->registration->default_STS_ID; |
208 | 208 | // if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered |
209 | 209 | $STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID; |
210 | 210 | // set incoming REG_Status |
211 | - $this->set_new_reg_status( $registration->ID(), $STS_ID ); |
|
212 | - $registration->set_status( $STS_ID ); |
|
213 | - if ( $save ) { |
|
211 | + $this->set_new_reg_status($registration->ID(), $STS_ID); |
|
212 | + $registration->set_status($STS_ID); |
|
213 | + if ($save) { |
|
214 | 214 | $registration->save(); |
215 | 215 | } |
216 | 216 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
217 | - if ( ! EE_Processor_Base::$IPN ) { |
|
217 | + if ( ! EE_Processor_Base::$IPN) { |
|
218 | 218 | // otherwise, send out notifications |
219 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
219 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
220 | 220 | } |
221 | 221 | // DEBUG LOG |
222 | 222 | //$this->log( |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | * @return boolean |
242 | 242 | * @throws \EE_Error |
243 | 243 | */ |
244 | - public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) { |
|
244 | + public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) { |
|
245 | 245 | $reg_status = $registration->status_ID(); |
246 | 246 | // set initial REG_Status |
247 | - $this->set_old_reg_status( $registration->ID(), $reg_status ); |
|
247 | + $this->set_old_reg_status($registration->ID(), $reg_status); |
|
248 | 248 | // if not already, toggle reg status to approved IF the event default reg status is approved |
249 | 249 | // ( as long as the registration wasn't cancelled or declined at some point ) |
250 | 250 | if ( |
@@ -254,16 +254,16 @@ discard block |
||
254 | 254 | $registration->event()->default_registration_status() === EEM_Registration::status_id_approved |
255 | 255 | ) { |
256 | 256 | // set incoming REG_Status |
257 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
257 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
258 | 258 | // toggle status to approved |
259 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
260 | - if ( $save ) { |
|
259 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
260 | + if ($save) { |
|
261 | 261 | $registration->save(); |
262 | 262 | } |
263 | 263 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
264 | - if ( ! EE_Processor_Base::$IPN ) { |
|
264 | + if ( ! EE_Processor_Base::$IPN) { |
|
265 | 265 | // otherwise, send out notifications |
266 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
266 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
267 | 267 | } |
268 | 268 | // DEBUG LOG |
269 | 269 | //$this->log( |
@@ -291,19 +291,19 @@ discard block |
||
291 | 291 | * @return bool |
292 | 292 | * @throws \EE_Error |
293 | 293 | */ |
294 | - public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) { |
|
294 | + public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) { |
|
295 | 295 | // set initial REG_Status |
296 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
296 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
297 | 297 | //EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ ); |
298 | 298 | // was a payment just made ? |
299 | 299 | if ( |
300 | - isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) && |
|
301 | - $additional_details[ 'payment_updates' ] && |
|
302 | - $additional_details[ 'last_payment' ] instanceof EE_Payment |
|
300 | + isset($additional_details['payment_updates'], $additional_details['last_payment']) && |
|
301 | + $additional_details['payment_updates'] && |
|
302 | + $additional_details['last_payment'] instanceof EE_Payment |
|
303 | 303 | ) { |
304 | - $payment = $additional_details[ 'last_payment' ]; |
|
304 | + $payment = $additional_details['last_payment']; |
|
305 | 305 | $total_paid = 0; |
306 | - foreach ( self::$_amount_paid as $reg => $amount_paid ) { |
|
306 | + foreach (self::$_amount_paid as $reg => $amount_paid) { |
|
307 | 307 | $total_paid += $amount_paid; |
308 | 308 | } |
309 | 309 | } else { |
@@ -327,30 +327,30 @@ discard block |
||
327 | 327 | $registration->transaction()->is_completed() || |
328 | 328 | $registration->transaction()->is_overpaid() || |
329 | 329 | $registration->transaction()->is_free() || |
330 | - apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration ) |
|
330 | + apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration) |
|
331 | 331 | ) || ( |
332 | 332 | $payment instanceof EE_Payment && |
333 | 333 | $payment->is_approved() && |
334 | 334 | // this specific registration has not yet been paid for |
335 | - ! isset( self::$_amount_paid[ $registration->ID() ] ) && |
|
335 | + ! isset(self::$_amount_paid[$registration->ID()]) && |
|
336 | 336 | // payment amount, less what we have already attributed to other registrations, is greater than this reg's final price |
337 | 337 | $payment->amount() - $total_paid >= $registration->final_price() |
338 | 338 | ) |
339 | 339 | ) |
340 | 340 | ) { |
341 | 341 | // mark as paid |
342 | - self::$_amount_paid[ $registration->ID() ] = $registration->final_price(); |
|
342 | + self::$_amount_paid[$registration->ID()] = $registration->final_price(); |
|
343 | 343 | // track new REG_Status |
344 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
344 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
345 | 345 | // toggle status to approved |
346 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
347 | - if ( $save ) { |
|
346 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
347 | + if ($save) { |
|
348 | 348 | $registration->save(); |
349 | 349 | } |
350 | 350 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
351 | - if ( ! EE_Processor_Base::$IPN ) { |
|
351 | + if ( ! EE_Processor_Base::$IPN) { |
|
352 | 352 | // otherwise, send out notifications |
353 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
353 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
354 | 354 | } |
355 | 355 | // DEBUG LOG |
356 | 356 | //$this->log( |
@@ -376,10 +376,10 @@ discard block |
||
376 | 376 | * @param array $additional_details |
377 | 377 | * @return void |
378 | 378 | */ |
379 | - public function trigger_registration_update_notifications( $registration, $additional_details = array() ) { |
|
379 | + public function trigger_registration_update_notifications($registration, $additional_details = array()) { |
|
380 | 380 | try { |
381 | - if ( ! $registration instanceof EE_Registration ) { |
|
382 | - throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) ); |
|
381 | + if ( ! $registration instanceof EE_Registration) { |
|
382 | + throw new EE_Error(__('An invalid registration was received.', 'event_espresso')); |
|
383 | 383 | } |
384 | 384 | // EE_Registry::instance()->load_helper( 'Debug_Tools' ); |
385 | 385 | // EEH_Debug_Tools::log( |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | $registration, |
399 | 399 | $additional_details |
400 | 400 | ); |
401 | - } catch( Exception $e ) { |
|
402 | - EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() ); |
|
401 | + } catch (Exception $e) { |
|
402 | + EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine()); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -413,22 +413,22 @@ discard block |
||
413 | 413 | * @return bool |
414 | 414 | * @throws \EE_Error |
415 | 415 | */ |
416 | - public function update_registration_after_checkout_or_payment( EE_Registration $registration, $additional_details = array() ) { |
|
416 | + public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) { |
|
417 | 417 | // set initial REG_Status |
418 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
418 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
419 | 419 | |
420 | 420 | // if the registration status gets updated, then save the registration |
421 | 421 | if ( |
422 | - $this->toggle_registration_status_for_default_approved_events( $registration, false ) |
|
423 | - || $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details ) |
|
422 | + $this->toggle_registration_status_for_default_approved_events($registration, false) |
|
423 | + || $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details) |
|
424 | 424 | ) { |
425 | 425 | $registration->save(); |
426 | 426 | } |
427 | 427 | |
428 | 428 | // set new REG_Status |
429 | - $this->set_new_reg_status( $registration->ID(), $registration->status_ID() ); |
|
430 | - return $this->reg_status_updated( $registration->ID() ) |
|
431 | - && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved |
|
429 | + $this->set_new_reg_status($registration->ID(), $registration->status_ID()); |
|
430 | + return $this->reg_status_updated($registration->ID()) |
|
431 | + && $this->new_reg_status($registration->ID()) === EEM_Registration::status_id_approved |
|
432 | 432 | ? true |
433 | 433 | : false; |
434 | 434 | } |
@@ -444,20 +444,20 @@ discard block |
||
444 | 444 | * @return void |
445 | 445 | * @throws \EE_Error |
446 | 446 | */ |
447 | - public function update_registration_final_prices( $transaction, $save_regs = true ) { |
|
448 | - $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() ); |
|
449 | - foreach( $transaction->registrations() as $registration ) { |
|
447 | + public function update_registration_final_prices($transaction, $save_regs = true) { |
|
448 | + $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item()); |
|
449 | + foreach ($transaction->registrations() as $registration) { |
|
450 | 450 | /** @var EE_Line_Item $line_item */ |
451 | - $line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration ); |
|
452 | - if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) { |
|
453 | - $registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ); |
|
454 | - if( $save_regs ) { |
|
451 | + $line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration); |
|
452 | + if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) { |
|
453 | + $registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]); |
|
454 | + if ($save_regs) { |
|
455 | 455 | $registration->save(); |
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
459 | 459 | //and make sure there's no rounding problem |
460 | - $this->fix_reg_final_price_rounding_issue( $transaction ); |
|
460 | + $this->fix_reg_final_price_rounding_issue($transaction); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return boolean success verifying that there is NO difference after this method is done |
478 | 478 | * @throws \EE_Error |
479 | 479 | */ |
480 | - public function fix_reg_final_price_rounding_issue( $transaction ) { |
|
480 | + public function fix_reg_final_price_rounding_issue($transaction) { |
|
481 | 481 | $reg_final_price_sum = EEM_Registration::instance()->sum( |
482 | 482 | array( |
483 | 483 | array( |
@@ -486,9 +486,9 @@ discard block |
||
486 | 486 | ), |
487 | 487 | 'REG_final_price' |
488 | 488 | ); |
489 | - $diff = $transaction->total() - (float) $reg_final_price_sum; |
|
489 | + $diff = $transaction->total() - (float) $reg_final_price_sum; |
|
490 | 490 | //ok then, just grab one of the registrations |
491 | - if( $diff !== 0 ) { |
|
491 | + if ($diff !== 0) { |
|
492 | 492 | $a_reg = EEM_Registration::instance()->get_one( |
493 | 493 | array( |
494 | 494 | array( |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | )); |
498 | 498 | $success = $a_reg instanceof EE_Registration |
499 | 499 | ? $a_reg->save( |
500 | - array( 'REG_final_price' => $a_reg->final_price() + $diff ) |
|
500 | + array('REG_final_price' => $a_reg->final_price() + $diff) |
|
501 | 501 | ) |
502 | 502 | : false; |
503 | 503 | return $success ? true : false; |
@@ -522,13 +522,13 @@ discard block |
||
522 | 522 | $update_reg = true |
523 | 523 | ) { |
524 | 524 | // these reg statuses should not be considered in any calculations involving monies owing |
525 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses |
|
525 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses |
|
526 | 526 | : EEM_Registration::closed_reg_statuses(); |
527 | - if ( ! in_array( $registration->status_ID(), $closed_reg_statuses ) ) { |
|
527 | + if ( ! in_array($registration->status_ID(), $closed_reg_statuses)) { |
|
528 | 528 | return false; |
529 | 529 | } |
530 | 530 | $registration->set_final_price(0); |
531 | - if ( $update_reg ) { |
|
531 | + if ($update_reg) { |
|
532 | 532 | $registration->save(); |
533 | 533 | } |
534 | 534 | return true; |
@@ -551,23 +551,23 @@ discard block |
||
551 | 551 | $update_reg = true |
552 | 552 | ) { |
553 | 553 | // these reg statuses should not be considered in any calculations involving monies owing |
554 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses |
|
554 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses |
|
555 | 555 | : EEM_Registration::closed_reg_statuses(); |
556 | - if ( in_array( $registration->status_ID(), $closed_reg_statuses ) ) { |
|
556 | + if (in_array($registration->status_ID(), $closed_reg_statuses)) { |
|
557 | 557 | return false; |
558 | 558 | } |
559 | 559 | $ticket = $registration->ticket(); |
560 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
560 | + if ( ! $ticket instanceof EE_Ticket) { |
|
561 | 561 | throw new EE_Error( |
562 | 562 | sprintf( |
563 | - __( 'The Ticket for Registration %1$d was not found or is invalid.', |
|
564 | - 'event_espresso' ), |
|
563 | + __('The Ticket for Registration %1$d was not found or is invalid.', |
|
564 | + 'event_espresso'), |
|
565 | 565 | $registration->ticket_ID() |
566 | 566 | ) |
567 | 567 | ); |
568 | 568 | } |
569 | - $registration->set_final_price( $ticket->price() ); |
|
570 | - if ( $update_reg ) { |
|
569 | + $registration->set_final_price($ticket->price()); |
|
570 | + if ($update_reg) { |
|
571 | 571 | $registration->save(); |
572 | 572 | } |
573 | 573 | return true; |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | $total_ticket_count = 1 |
606 | 606 | ) { |
607 | 607 | EE_Error::doing_it_wrong( |
608 | - __CLASS__ . '::' . __FUNCTION__, |
|
608 | + __CLASS__.'::'.__FUNCTION__, |
|
609 | 609 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
610 | 610 | '\EventEspresso\core\domain\services\registration\CreateRegistrationService::create()'), |
611 | 611 | '4.9.1', |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | public function generate_reg_url_link($att_nmbr, $item) |
649 | 649 | { |
650 | 650 | EE_Error::doing_it_wrong( |
651 | - __CLASS__ . '::' . __FUNCTION__, |
|
651 | + __CLASS__.'::'.__FUNCTION__, |
|
652 | 652 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
653 | 653 | 'EventEspresso\core\domain\entities\RegUrlLink'), |
654 | 654 | '4.9.1', |
@@ -668,11 +668,11 @@ discard block |
||
668 | 668 | * @return string |
669 | 669 | * @throws \EE_Error |
670 | 670 | */ |
671 | - public function generate_reg_code( EE_Registration $registration ) { |
|
671 | + public function generate_reg_code(EE_Registration $registration) { |
|
672 | 672 | EE_Error::doing_it_wrong( |
673 | - __CLASS__ . '::' . __FUNCTION__, |
|
673 | + __CLASS__.'::'.__FUNCTION__, |
|
674 | 674 | sprintf( |
675 | - __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), |
|
675 | + __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
676 | 676 | 'EventEspresso\core\domain\entities\RegCode' |
677 | 677 | ), |
678 | 678 | '4.9.1', |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | return apply_filters( |
682 | 682 | 'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', |
683 | 683 | new RegCode( |
684 | - RegUrlLink::fromRegistration( $registration ), |
|
684 | + RegUrlLink::fromRegistration($registration), |
|
685 | 685 | $registration->transaction(), |
686 | 686 | $registration->ticket() |
687 | 687 | ), |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | |
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @return string |
|
61 | - * @throws \EE_Error |
|
62 | - */ |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + * @throws \EE_Error |
|
62 | + */ |
|
63 | 63 | public function generate_reg_form() { |
64 | 64 | // create empty form so that things don't break |
65 | 65 | $this->reg_form = new EE_Form_Section_Proper(); |
@@ -68,26 +68,26 @@ discard block |
||
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @return boolean |
|
73 | - * @throws \RuntimeException |
|
74 | - * @throws \EE_Error |
|
75 | - */ |
|
71 | + /** |
|
72 | + * @return boolean |
|
73 | + * @throws \RuntimeException |
|
74 | + * @throws \EE_Error |
|
75 | + */ |
|
76 | 76 | public function process_reg_step() { |
77 | - // ensure all data gets refreshed from the db |
|
77 | + // ensure all data gets refreshed from the db |
|
78 | 78 | $this->checkout->refresh_all_entities( true ); |
79 | 79 | // ensures that all details and statuses for transaction, registration, and payments are updated |
80 | 80 | $txn_update_params = $this->_finalize_transaction(); |
81 | - // maybe send messages |
|
82 | - $this->_set_notification_triggers(); |
|
83 | - // send messages |
|
84 | - /** @type EE_Registration_Processor $registration_processor */ |
|
85 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
86 | - $registration_processor->trigger_registration_update_notifications( |
|
87 | - $this->checkout->transaction->primary_registration(), |
|
88 | - $txn_update_params |
|
89 | - ); |
|
90 | - // set a hook point |
|
81 | + // maybe send messages |
|
82 | + $this->_set_notification_triggers(); |
|
83 | + // send messages |
|
84 | + /** @type EE_Registration_Processor $registration_processor */ |
|
85 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
86 | + $registration_processor->trigger_registration_update_notifications( |
|
87 | + $this->checkout->transaction->primary_registration(), |
|
88 | + $txn_update_params |
|
89 | + ); |
|
90 | + // set a hook point |
|
91 | 91 | do_action( |
92 | 92 | 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', |
93 | 93 | $this->checkout, |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | if ( |
105 | 105 | ! ( |
106 | 106 | $this->checkout->payment_method instanceof EE_Payment_Method |
107 | - && $this->checkout->payment_method->is_off_site() |
|
107 | + && $this->checkout->payment_method->is_off_site() |
|
108 | 108 | ) |
109 | 109 | ) { |
110 | 110 | // mark this reg step as completed |
@@ -116,14 +116,14 @@ discard block |
||
116 | 116 | |
117 | 117 | |
118 | 118 | |
119 | - /** |
|
120 | - * _finalize_transaction |
|
121 | - * ensures that all details and statuses for transaction, registration, and payments are updated |
|
122 | - * |
|
123 | - * @return array |
|
124 | - * @throws \RuntimeException |
|
125 | - * @throws \EE_Error |
|
126 | - */ |
|
119 | + /** |
|
120 | + * _finalize_transaction |
|
121 | + * ensures that all details and statuses for transaction, registration, and payments are updated |
|
122 | + * |
|
123 | + * @return array |
|
124 | + * @throws \RuntimeException |
|
125 | + * @throws \EE_Error |
|
126 | + */ |
|
127 | 127 | protected function _finalize_transaction() { |
128 | 128 | /** @type EE_Transaction_Processor $transaction_processor */ |
129 | 129 | $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
@@ -139,17 +139,17 @@ discard block |
||
139 | 139 | } |
140 | 140 | // maybe update status, but don't save transaction just yet |
141 | 141 | $this->checkout->transaction->update_status_based_on_total_paid( false ); |
142 | - // this will result in the base session properties getting saved to the TXN_Session_data field |
|
142 | + // this will result in the base session properties getting saved to the TXN_Session_data field |
|
143 | 143 | $this->checkout->transaction->set_txn_session_data( |
144 | 144 | EE_Registry::instance()->SSN->get_session_data( null, true ) |
145 | 145 | ); |
146 | - // update the TXN if payment conditions have changed, but do NOT trigger notifications, |
|
147 | - // because we will do that in process_reg_step() after setting some more triggers |
|
146 | + // update the TXN if payment conditions have changed, but do NOT trigger notifications, |
|
147 | + // because we will do that in process_reg_step() after setting some more triggers |
|
148 | 148 | return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
149 | 149 | $this->checkout->transaction, |
150 | 150 | $this->checkout->payment, |
151 | 151 | $this->checkout->reg_cache_where_params, |
152 | - false |
|
152 | + false |
|
153 | 153 | ); |
154 | 154 | } |
155 | 155 | |
@@ -167,43 +167,43 @@ discard block |
||
167 | 167 | protected function _set_notification_triggers() { |
168 | 168 | |
169 | 169 | if ( $this->checkout->payment_method instanceof EE_Payment_Method ) { |
170 | - // let's start with the assumption that we need to trigger notifications |
|
171 | - // then toggle this to false for conditions where we know we don't need to |
|
172 | - $deliver_notifications = true; |
|
173 | - if ( |
|
174 | - // if SPCO revisit |
|
175 | - filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN) |
|
176 | - // and TXN or REG statuses have NOT changed due to a payment |
|
177 | - && ! ( |
|
178 | - $this->checkout->transaction->txn_status_updated() |
|
179 | - || $this->checkout->any_reg_status_updated() |
|
180 | - ) |
|
181 | - ) { |
|
182 | - $deliver_notifications = false; |
|
183 | - } |
|
184 | - if ($this->checkout->payment_method->is_off_site()) { |
|
185 | - /** @var EE_Gateway $gateway */ |
|
186 | - $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
|
187 | - // and the gateway uses a separate request to process the IPN |
|
188 | - if ( |
|
189 | - $gateway instanceof EE_Offsite_Gateway |
|
190 | - && $gateway->handle_IPN_in_this_request(\EE_Registry::instance()->REQ->params(), true) |
|
191 | - ) { |
|
192 | - // IPN request will handle triggering notifications |
|
193 | - $deliver_notifications = false; |
|
194 | - // no really... don't send any notices in this request |
|
195 | - remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications'); |
|
196 | - add_filter( |
|
197 | - 'FHEE__EED_Messages___maybe_registration__deliver_notifications', |
|
198 | - '__return_false', |
|
199 | - 15 |
|
200 | - ); |
|
201 | - } |
|
202 | - } |
|
203 | - if ($deliver_notifications) { |
|
204 | - // send out notifications |
|
205 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
206 | - } |
|
170 | + // let's start with the assumption that we need to trigger notifications |
|
171 | + // then toggle this to false for conditions where we know we don't need to |
|
172 | + $deliver_notifications = true; |
|
173 | + if ( |
|
174 | + // if SPCO revisit |
|
175 | + filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN) |
|
176 | + // and TXN or REG statuses have NOT changed due to a payment |
|
177 | + && ! ( |
|
178 | + $this->checkout->transaction->txn_status_updated() |
|
179 | + || $this->checkout->any_reg_status_updated() |
|
180 | + ) |
|
181 | + ) { |
|
182 | + $deliver_notifications = false; |
|
183 | + } |
|
184 | + if ($this->checkout->payment_method->is_off_site()) { |
|
185 | + /** @var EE_Gateway $gateway */ |
|
186 | + $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
|
187 | + // and the gateway uses a separate request to process the IPN |
|
188 | + if ( |
|
189 | + $gateway instanceof EE_Offsite_Gateway |
|
190 | + && $gateway->handle_IPN_in_this_request(\EE_Registry::instance()->REQ->params(), true) |
|
191 | + ) { |
|
192 | + // IPN request will handle triggering notifications |
|
193 | + $deliver_notifications = false; |
|
194 | + // no really... don't send any notices in this request |
|
195 | + remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications'); |
|
196 | + add_filter( |
|
197 | + 'FHEE__EED_Messages___maybe_registration__deliver_notifications', |
|
198 | + '__return_false', |
|
199 | + 15 |
|
200 | + ); |
|
201 | + } |
|
202 | + } |
|
203 | + if ($deliver_notifications) { |
|
204 | + // send out notifications |
|
205 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
206 | + } |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | * @access public |
22 | 22 | * @param EE_Checkout $checkout |
23 | 23 | */ |
24 | - public function __construct( EE_Checkout $checkout ) { |
|
24 | + public function __construct(EE_Checkout $checkout) { |
|
25 | 25 | $this->_slug = 'finalize_registration'; |
26 | - $this->_name = __( 'Finalize Registration', 'event_espresso' ); |
|
26 | + $this->_name = __('Finalize Registration', 'event_espresso'); |
|
27 | 27 | $this->_submit_button_text = $this->_name; |
28 | 28 | $this->_template = ''; |
29 | 29 | $this->checkout = $checkout; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function initialize_reg_step() { |
48 | 48 | // there's actually no reg form to process if this is the final step |
49 | - if ( $this->is_current_step() ) { |
|
49 | + if ($this->is_current_step()) { |
|
50 | 50 | $this->checkout->step = $_REQUEST['step'] = $this->slug(); |
51 | 51 | $this->checkout->action = $_REQUEST['action'] = 'process_reg_step'; |
52 | 52 | $this->checkout->generate_reg_form = false; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function process_reg_step() { |
77 | 77 | // ensure all data gets refreshed from the db |
78 | - $this->checkout->refresh_all_entities( true ); |
|
78 | + $this->checkout->refresh_all_entities(true); |
|
79 | 79 | // ensures that all details and statuses for transaction, registration, and payments are updated |
80 | 80 | $txn_update_params = $this->_finalize_transaction(); |
81 | 81 | // maybe send messages |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | $txn_update_params |
95 | 95 | ); |
96 | 96 | // check if transaction has a primary registrant and that it has a related Attendee object |
97 | - if ( ! $this->_validate_primary_registrant() ) { |
|
97 | + if ( ! $this->_validate_primary_registrant()) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | // you don't have to go home but you can't stay here ! |
101 | 101 | $this->checkout->redirect = true; |
102 | 102 | $this->checkout->continue_reg = true; |
103 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
103 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
104 | 104 | if ( |
105 | 105 | ! ( |
106 | 106 | $this->checkout->payment_method instanceof EE_Payment_Method |
@@ -126,22 +126,22 @@ discard block |
||
126 | 126 | */ |
127 | 127 | protected function _finalize_transaction() { |
128 | 128 | /** @type EE_Transaction_Processor $transaction_processor */ |
129 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
129 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
130 | 130 | //set revisit flag in txn processor |
131 | - $transaction_processor->set_revisit( $this->checkout->revisit ); |
|
131 | + $transaction_processor->set_revisit($this->checkout->revisit); |
|
132 | 132 | // at this point we'll consider a TXN to not have been abandoned |
133 | 133 | $this->checkout->transaction->toggle_abandoned_transaction_status(); |
134 | - if ( $this->checkout->cart instanceof EE_Cart ) { |
|
134 | + if ($this->checkout->cart instanceof EE_Cart) { |
|
135 | 135 | // save TXN data to the cart |
136 | 136 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
137 | 137 | $this->checkout->transaction->ID() |
138 | 138 | ); |
139 | 139 | } |
140 | 140 | // maybe update status, but don't save transaction just yet |
141 | - $this->checkout->transaction->update_status_based_on_total_paid( false ); |
|
141 | + $this->checkout->transaction->update_status_based_on_total_paid(false); |
|
142 | 142 | // this will result in the base session properties getting saved to the TXN_Session_data field |
143 | 143 | $this->checkout->transaction->set_txn_session_data( |
144 | - EE_Registry::instance()->SSN->get_session_data( null, true ) |
|
144 | + EE_Registry::instance()->SSN->get_session_data(null, true) |
|
145 | 145 | ); |
146 | 146 | // update the TXN if payment conditions have changed, but do NOT trigger notifications, |
147 | 147 | // because we will do that in process_reg_step() after setting some more triggers |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function _set_notification_triggers() { |
168 | 168 | |
169 | - if ( $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
169 | + if ($this->checkout->payment_method instanceof EE_Payment_Method) { |
|
170 | 170 | // let's start with the assumption that we need to trigger notifications |
171 | 171 | // then toggle this to false for conditions where we know we don't need to |
172 | 172 | $deliver_notifications = true; |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * @throws \EE_Error |
217 | 217 | */ |
218 | 218 | protected function _validate_primary_registrant() { |
219 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
219 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
220 | 220 | EE_Error::add_error( |
221 | - __( 'A valid Primary Registration for this Transaction could not be found.', 'event_espresso' ), |
|
221 | + __('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'), |
|
222 | 222 | __FILE__, |
223 | 223 | __FUNCTION__, |
224 | 224 | __LINE__ |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | } |
230 | 230 | // setup URL for redirect |
231 | 231 | $this->checkout->redirect_url = add_query_arg( |
232 | - array( 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link() ), |
|
232 | + array('e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link()), |
|
233 | 233 | $this->checkout->thank_you_page_url |
234 | 234 | ); |
235 | 235 | return true; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function update_reg_step() { |
244 | 244 | EE_Error::doing_it_wrong( |
245 | - __CLASS__ . '::' . __FILE__, |
|
245 | + __CLASS__.'::'.__FILE__, |
|
246 | 246 | __( |
247 | 247 | 'Can not call update_reg_step() on the Finalize Registration reg step.', |
248 | 248 | 'event_espresso' |