@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | <?php echo $eei18n; ?> |
36 | 36 | </script> |
37 | 37 | <?php foreach ($header_js as $key => $url) :?> |
38 | - <?php $header_attributes = isset($header_js_attributes[ $key ]) ? $header_js_attributes[ $key ] : ''; ?> |
|
38 | + <?php $header_attributes = isset($header_js_attributes[$key]) ? $header_js_attributes[$key] : ''; ?> |
|
39 | 39 | <script type="text/javascript" src="<?php echo esc_url_raw($url); ?>"<?php echo $header_attributes; ?>></script> |
40 | 40 | <?php endforeach; ?> |
41 | 41 | <?php endif; ?> |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | <?php echo wp_kses($content, AllowedTags::getWithFormTags()); ?> |
47 | 47 | </div> |
48 | 48 | <?php foreach ($footer_js as $key => $url) : ?> |
49 | - <?php $footer_attributes = isset($footer_js_attributes[ $key ]) ? $footer_js_attributes[ $key ] : ''; ?> |
|
49 | + <?php $footer_attributes = isset($footer_js_attributes[$key]) ? $footer_js_attributes[$key] : ''; ?> |
|
50 | 50 | <script type="text/javascript" src="<?php echo esc_url_raw($url); ?>"<?php echo $footer_attributes; ?>></script> |
51 | 51 | <?php endforeach; ?> |
52 | 52 | <?php if ($enqueue_wp_assets) : ?> |
@@ -15,274 +15,274 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * @var string $iframe_name |
|
20 | - */ |
|
21 | - private $iframe_name; |
|
18 | + /** |
|
19 | + * @var string $iframe_name |
|
20 | + */ |
|
21 | + private $iframe_name; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var string $route_name |
|
25 | - */ |
|
26 | - private $route_name; |
|
23 | + /** |
|
24 | + * @var string $route_name |
|
25 | + */ |
|
26 | + private $route_name; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var string $slug |
|
30 | - */ |
|
31 | - private $slug; |
|
28 | + /** |
|
29 | + * @var string $slug |
|
30 | + */ |
|
31 | + private $slug; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var boolean $append_filterable_content |
|
35 | - */ |
|
36 | - private $append_filterable_content; |
|
33 | + /** |
|
34 | + * @var boolean $append_filterable_content |
|
35 | + */ |
|
36 | + private $append_filterable_content; |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * IframeEmbedButton constructor. |
|
41 | - * |
|
42 | - * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
43 | - * @param string $route_name the name of the registered route |
|
44 | - * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
45 | - * will most likely be "event" since that's the only usage atm |
|
46 | - */ |
|
47 | - public function __construct($iframe_name, $route_name, $slug = 'event') |
|
48 | - { |
|
49 | - $this->iframe_name = $iframe_name; |
|
50 | - $this->route_name = $route_name; |
|
51 | - $this->slug = $slug; |
|
52 | - } |
|
39 | + /** |
|
40 | + * IframeEmbedButton constructor. |
|
41 | + * |
|
42 | + * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
43 | + * @param string $route_name the name of the registered route |
|
44 | + * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
45 | + * will most likely be "event" since that's the only usage atm |
|
46 | + */ |
|
47 | + public function __construct($iframe_name, $route_name, $slug = 'event') |
|
48 | + { |
|
49 | + $this->iframe_name = $iframe_name; |
|
50 | + $this->route_name = $route_name; |
|
51 | + $this->slug = $slug; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Adds an iframe embed code button to the Event editor. |
|
57 | - */ |
|
58 | - public function addEventEditorIframeEmbedButtonFilter() |
|
59 | - { |
|
60 | - // add button for iframe code to event editor. |
|
61 | - add_filter( |
|
62 | - 'get_sample_permalink_html', |
|
63 | - array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'), |
|
64 | - 10, |
|
65 | - 2 |
|
66 | - ); |
|
67 | - add_action( |
|
68 | - 'admin_enqueue_scripts', |
|
69 | - array($this, 'embedButtonAssets'), |
|
70 | - 10 |
|
71 | - ); |
|
72 | - } |
|
55 | + /** |
|
56 | + * Adds an iframe embed code button to the Event editor. |
|
57 | + */ |
|
58 | + public function addEventEditorIframeEmbedButtonFilter() |
|
59 | + { |
|
60 | + // add button for iframe code to event editor. |
|
61 | + add_filter( |
|
62 | + 'get_sample_permalink_html', |
|
63 | + array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'), |
|
64 | + 10, |
|
65 | + 2 |
|
66 | + ); |
|
67 | + add_action( |
|
68 | + 'admin_enqueue_scripts', |
|
69 | + array($this, 'embedButtonAssets'), |
|
70 | + 10 |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * @param $permalink_string |
|
77 | - * @param $id |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id) |
|
81 | - { |
|
82 | - return $this->eventEditorIframeEmbedButton( |
|
83 | - $permalink_string, |
|
84 | - $id |
|
85 | - ); |
|
86 | - } |
|
75 | + /** |
|
76 | + * @param $permalink_string |
|
77 | + * @param $id |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id) |
|
81 | + { |
|
82 | + return $this->eventEditorIframeEmbedButton( |
|
83 | + $permalink_string, |
|
84 | + $id |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * iframe embed code button to the Event editor. |
|
91 | - * |
|
92 | - * @param string $permalink_string |
|
93 | - * @param int $id |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function eventEditorIframeEmbedButton( |
|
97 | - $permalink_string, |
|
98 | - $id |
|
99 | - ) { |
|
100 | - // make sure this is ONLY when editing and the event id has been set. |
|
101 | - if (! empty($id)) { |
|
102 | - $post = get_post($id); |
|
103 | - // if NOT event then let's get out. |
|
104 | - if ($post->post_type !== 'espresso_events') { |
|
105 | - return $permalink_string; |
|
106 | - } |
|
107 | - $permalink_string .= $this->embedButtonHtml( |
|
108 | - array($this->slug => $id), |
|
109 | - 'button-small' |
|
110 | - ); |
|
111 | - } |
|
112 | - return $permalink_string; |
|
113 | - } |
|
89 | + /** |
|
90 | + * iframe embed code button to the Event editor. |
|
91 | + * |
|
92 | + * @param string $permalink_string |
|
93 | + * @param int $id |
|
94 | + * @return string |
|
95 | + */ |
|
96 | + public function eventEditorIframeEmbedButton( |
|
97 | + $permalink_string, |
|
98 | + $id |
|
99 | + ) { |
|
100 | + // make sure this is ONLY when editing and the event id has been set. |
|
101 | + if (! empty($id)) { |
|
102 | + $post = get_post($id); |
|
103 | + // if NOT event then let's get out. |
|
104 | + if ($post->post_type !== 'espresso_events') { |
|
105 | + return $permalink_string; |
|
106 | + } |
|
107 | + $permalink_string .= $this->embedButtonHtml( |
|
108 | + array($this->slug => $id), |
|
109 | + 'button-small' |
|
110 | + ); |
|
111 | + } |
|
112 | + return $permalink_string; |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
118 | - * |
|
119 | - * @param string $action name of the WP do_action() to hook into |
|
120 | - */ |
|
121 | - public function addActionIframeEmbedButton($action) |
|
122 | - { |
|
123 | - // add button for iframe code to event editor. |
|
124 | - add_action( |
|
125 | - $action, |
|
126 | - array($this, 'addActionIframeEmbedButtonCallback'), |
|
127 | - 10, |
|
128 | - 2 |
|
129 | - ); |
|
130 | - } |
|
116 | + /** |
|
117 | + * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
118 | + * |
|
119 | + * @param string $action name of the WP do_action() to hook into |
|
120 | + */ |
|
121 | + public function addActionIframeEmbedButton($action) |
|
122 | + { |
|
123 | + // add button for iframe code to event editor. |
|
124 | + add_action( |
|
125 | + $action, |
|
126 | + array($this, 'addActionIframeEmbedButtonCallback'), |
|
127 | + 10, |
|
128 | + 2 |
|
129 | + ); |
|
130 | + } |
|
131 | 131 | |
132 | 132 | |
133 | - /** |
|
134 | - * @return void |
|
135 | - */ |
|
136 | - public function addActionIframeEmbedButtonCallback() |
|
137 | - { |
|
138 | - echo wp_kses($this->embedButtonHtml(), AllowedTags::getWithFormTags()); |
|
139 | - } |
|
133 | + /** |
|
134 | + * @return void |
|
135 | + */ |
|
136 | + public function addActionIframeEmbedButtonCallback() |
|
137 | + { |
|
138 | + echo wp_kses($this->embedButtonHtml(), AllowedTags::getWithFormTags()); |
|
139 | + } |
|
140 | 140 | |
141 | 141 | |
142 | - /** |
|
143 | - * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
144 | - * |
|
145 | - * @param string $filter name of the WP apply_filters() to hook into |
|
146 | - * @param bool $append if true, will add iframe embed button to end of content, |
|
147 | - * else if false, will add to the beginning of the content |
|
148 | - */ |
|
149 | - public function addFilterIframeEmbedButton($filter, $append = true) |
|
150 | - { |
|
151 | - $this->append_filterable_content = $append; |
|
152 | - // add button for iframe code to event editor. |
|
153 | - add_filter( |
|
154 | - $filter, |
|
155 | - array($this, 'addFilterIframeEmbedButtonCallback'), |
|
156 | - 10 |
|
157 | - ); |
|
158 | - } |
|
142 | + /** |
|
143 | + * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
144 | + * |
|
145 | + * @param string $filter name of the WP apply_filters() to hook into |
|
146 | + * @param bool $append if true, will add iframe embed button to end of content, |
|
147 | + * else if false, will add to the beginning of the content |
|
148 | + */ |
|
149 | + public function addFilterIframeEmbedButton($filter, $append = true) |
|
150 | + { |
|
151 | + $this->append_filterable_content = $append; |
|
152 | + // add button for iframe code to event editor. |
|
153 | + add_filter( |
|
154 | + $filter, |
|
155 | + array($this, 'addFilterIframeEmbedButtonCallback'), |
|
156 | + 10 |
|
157 | + ); |
|
158 | + } |
|
159 | 159 | |
160 | 160 | |
161 | - /** |
|
162 | - * @param array|string $filterable_content |
|
163 | - * @return array|string |
|
164 | - */ |
|
165 | - public function addFilterIframeEmbedButtonCallback($filterable_content) |
|
166 | - { |
|
167 | - $embedButtonHtml = $this->embedButtonHtml(); |
|
168 | - if (is_array($filterable_content)) { |
|
169 | - $filterable_content = $this->append_filterable_content |
|
170 | - ? $filterable_content + array($this->route_name => $embedButtonHtml) |
|
171 | - : array($this->route_name => $embedButtonHtml) + $filterable_content; |
|
172 | - } else { |
|
173 | - $filterable_content = $this->append_filterable_content |
|
174 | - ? $filterable_content . $embedButtonHtml |
|
175 | - : $embedButtonHtml . $filterable_content; |
|
176 | - } |
|
177 | - return $filterable_content; |
|
178 | - } |
|
161 | + /** |
|
162 | + * @param array|string $filterable_content |
|
163 | + * @return array|string |
|
164 | + */ |
|
165 | + public function addFilterIframeEmbedButtonCallback($filterable_content) |
|
166 | + { |
|
167 | + $embedButtonHtml = $this->embedButtonHtml(); |
|
168 | + if (is_array($filterable_content)) { |
|
169 | + $filterable_content = $this->append_filterable_content |
|
170 | + ? $filterable_content + array($this->route_name => $embedButtonHtml) |
|
171 | + : array($this->route_name => $embedButtonHtml) + $filterable_content; |
|
172 | + } else { |
|
173 | + $filterable_content = $this->append_filterable_content |
|
174 | + ? $filterable_content . $embedButtonHtml |
|
175 | + : $embedButtonHtml . $filterable_content; |
|
176 | + } |
|
177 | + return $filterable_content; |
|
178 | + } |
|
179 | 179 | |
180 | 180 | |
181 | - /** |
|
182 | - * iframe_embed_html |
|
183 | - * |
|
184 | - * @param array $query_args |
|
185 | - * @param string $button_class |
|
186 | - * @return string |
|
187 | - */ |
|
188 | - public function embedButtonHtml($query_args = array(), $button_class = '') |
|
189 | - { |
|
190 | - // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
191 | - $query_args = (array) $query_args + array($this->route_name => 'iframe'); |
|
192 | - $query_args = (array) apply_filters( |
|
193 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
194 | - $query_args |
|
195 | - ); |
|
196 | - // add this route to our localized vars |
|
197 | - $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes']) |
|
198 | - ? \EE_Registry::$i18n_js_strings['iframe_module_routes'] |
|
199 | - : array(); |
|
200 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
201 | - \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes; |
|
202 | - $iframe_embed_html = \EEH_HTML::link( |
|
203 | - '#', |
|
204 | - sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name), |
|
205 | - sprintf( |
|
206 | - esc_html__( |
|
207 | - 'click here to generate code for embedding %1$s iframe into another site.', |
|
208 | - 'event_espresso' |
|
209 | - ), |
|
210 | - \EEH_Inflector::add_indefinite_article($this->iframe_name) |
|
211 | - ), |
|
212 | - esc_attr($this->route_name) . "-iframe-embed-trigger-js", |
|
213 | - 'iframe-embed-trigger-js button ' . esc_attr($button_class), |
|
214 | - '', |
|
215 | - ' data-iframe_embed_button="#' . esc_attr($this->route_name) . '-iframe-js" tabindex="-1"' |
|
216 | - ); |
|
217 | - $iframe_embed_html .= \EEH_HTML::div( |
|
218 | - '', |
|
219 | - esc_attr($this->route_name) . "-iframe-js", |
|
220 | - 'iframe-embed-wrapper-js', |
|
221 | - 'display:none;' |
|
222 | - ); |
|
223 | - $iframe_embed_html .= esc_html( |
|
224 | - \EEH_HTML::div( |
|
225 | - '<iframe src="' . esc_url_raw(add_query_arg($query_args, site_url())) . '" width="100%" height="100%"></iframe>', |
|
226 | - '', |
|
227 | - '', |
|
228 | - 'width:100%; height: 500px;' |
|
229 | - ) |
|
230 | - ); |
|
231 | - $iframe_embed_html .= \EEH_HTML::divx(); |
|
232 | - return $iframe_embed_html; |
|
233 | - } |
|
181 | + /** |
|
182 | + * iframe_embed_html |
|
183 | + * |
|
184 | + * @param array $query_args |
|
185 | + * @param string $button_class |
|
186 | + * @return string |
|
187 | + */ |
|
188 | + public function embedButtonHtml($query_args = array(), $button_class = '') |
|
189 | + { |
|
190 | + // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
191 | + $query_args = (array) $query_args + array($this->route_name => 'iframe'); |
|
192 | + $query_args = (array) apply_filters( |
|
193 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
194 | + $query_args |
|
195 | + ); |
|
196 | + // add this route to our localized vars |
|
197 | + $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes']) |
|
198 | + ? \EE_Registry::$i18n_js_strings['iframe_module_routes'] |
|
199 | + : array(); |
|
200 | + $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
201 | + \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes; |
|
202 | + $iframe_embed_html = \EEH_HTML::link( |
|
203 | + '#', |
|
204 | + sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name), |
|
205 | + sprintf( |
|
206 | + esc_html__( |
|
207 | + 'click here to generate code for embedding %1$s iframe into another site.', |
|
208 | + 'event_espresso' |
|
209 | + ), |
|
210 | + \EEH_Inflector::add_indefinite_article($this->iframe_name) |
|
211 | + ), |
|
212 | + esc_attr($this->route_name) . "-iframe-embed-trigger-js", |
|
213 | + 'iframe-embed-trigger-js button ' . esc_attr($button_class), |
|
214 | + '', |
|
215 | + ' data-iframe_embed_button="#' . esc_attr($this->route_name) . '-iframe-js" tabindex="-1"' |
|
216 | + ); |
|
217 | + $iframe_embed_html .= \EEH_HTML::div( |
|
218 | + '', |
|
219 | + esc_attr($this->route_name) . "-iframe-js", |
|
220 | + 'iframe-embed-wrapper-js', |
|
221 | + 'display:none;' |
|
222 | + ); |
|
223 | + $iframe_embed_html .= esc_html( |
|
224 | + \EEH_HTML::div( |
|
225 | + '<iframe src="' . esc_url_raw(add_query_arg($query_args, site_url())) . '" width="100%" height="100%"></iframe>', |
|
226 | + '', |
|
227 | + '', |
|
228 | + 'width:100%; height: 500px;' |
|
229 | + ) |
|
230 | + ); |
|
231 | + $iframe_embed_html .= \EEH_HTML::divx(); |
|
232 | + return $iframe_embed_html; |
|
233 | + } |
|
234 | 234 | |
235 | 235 | |
236 | - /** |
|
237 | - * enqueue iframe button js |
|
238 | - */ |
|
239 | - public function embedButtonAssets() |
|
240 | - { |
|
241 | - \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__( |
|
242 | - 'copy and paste the following into any other site\'s content to display this event:', |
|
243 | - 'event_espresso' |
|
244 | - ); |
|
245 | - \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__( |
|
246 | - 'click anywhere outside of this window to close it.', |
|
247 | - 'event_espresso' |
|
248 | - ); |
|
249 | - wp_register_script( |
|
250 | - 'iframe_embed_button', |
|
251 | - plugin_dir_url(__FILE__) . 'iframe-embed-button.js', |
|
252 | - array('ee-dialog'), |
|
253 | - EVENT_ESPRESSO_VERSION, |
|
254 | - true |
|
255 | - ); |
|
256 | - wp_enqueue_script('iframe_embed_button'); |
|
257 | - } |
|
236 | + /** |
|
237 | + * enqueue iframe button js |
|
238 | + */ |
|
239 | + public function embedButtonAssets() |
|
240 | + { |
|
241 | + \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__( |
|
242 | + 'copy and paste the following into any other site\'s content to display this event:', |
|
243 | + 'event_espresso' |
|
244 | + ); |
|
245 | + \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__( |
|
246 | + 'click anywhere outside of this window to close it.', |
|
247 | + 'event_espresso' |
|
248 | + ); |
|
249 | + wp_register_script( |
|
250 | + 'iframe_embed_button', |
|
251 | + plugin_dir_url(__FILE__) . 'iframe-embed-button.js', |
|
252 | + array('ee-dialog'), |
|
253 | + EVENT_ESPRESSO_VERSION, |
|
254 | + true |
|
255 | + ); |
|
256 | + wp_enqueue_script('iframe_embed_button'); |
|
257 | + } |
|
258 | 258 | |
259 | 259 | |
260 | - /** |
|
261 | - * generates embed button sections for admin pages |
|
262 | - * |
|
263 | - * @param array $embed_buttons |
|
264 | - * @return string |
|
265 | - */ |
|
266 | - public function addIframeEmbedButtonsSection(array $embed_buttons) |
|
267 | - { |
|
268 | - $embed_buttons = (array) apply_filters( |
|
269 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
270 | - $embed_buttons |
|
271 | - ); |
|
272 | - if (empty($embed_buttons)) { |
|
273 | - return ''; |
|
274 | - } |
|
275 | - // add button for iframe code to event editor. |
|
276 | - $html = \EEH_HTML::br(2); |
|
277 | - $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso')); |
|
278 | - $html .= \EEH_HTML::p( |
|
279 | - esc_html__( |
|
280 | - 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
281 | - 'event_espresso' |
|
282 | - ) |
|
283 | - ); |
|
284 | - $html .= ' ' . implode(' ', $embed_buttons) . ' '; |
|
285 | - $html .= \EEH_HTML::br(2); |
|
286 | - return $html; |
|
287 | - } |
|
260 | + /** |
|
261 | + * generates embed button sections for admin pages |
|
262 | + * |
|
263 | + * @param array $embed_buttons |
|
264 | + * @return string |
|
265 | + */ |
|
266 | + public function addIframeEmbedButtonsSection(array $embed_buttons) |
|
267 | + { |
|
268 | + $embed_buttons = (array) apply_filters( |
|
269 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
270 | + $embed_buttons |
|
271 | + ); |
|
272 | + if (empty($embed_buttons)) { |
|
273 | + return ''; |
|
274 | + } |
|
275 | + // add button for iframe code to event editor. |
|
276 | + $html = \EEH_HTML::br(2); |
|
277 | + $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso')); |
|
278 | + $html .= \EEH_HTML::p( |
|
279 | + esc_html__( |
|
280 | + 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
281 | + 'event_espresso' |
|
282 | + ) |
|
283 | + ); |
|
284 | + $html .= ' ' . implode(' ', $embed_buttons) . ' '; |
|
285 | + $html .= \EEH_HTML::br(2); |
|
286 | + return $html; |
|
287 | + } |
|
288 | 288 | } |