| @@ 207-224 (lines=18) @@ | ||
| 204 | * @param bool $add_to_header |
|
| 205 | * @throws DomainException |
|
| 206 | */ |
|
| 207 | public function addScripts( array $scripts, $add_to_header = false ) |
|
| 208 | { |
|
| 209 | if ( empty( $scripts ) ) { |
|
| 210 | throw new DomainException( |
|
| 211 | esc_html__( |
|
| 212 | 'A non-empty array of URLs, is required to add Javascript to an iframe.', |
|
| 213 | 'event_espresso' |
|
| 214 | ) |
|
| 215 | ); |
|
| 216 | } |
|
| 217 | foreach ( $scripts as $handle => $script ) { |
|
| 218 | if ( $add_to_header ) { |
|
| 219 | $this->header_js[ $handle ] = $script; |
|
| 220 | } else { |
|
| 221 | $this->footer_js[ $handle ] = $script; |
|
| 222 | } |
|
| 223 | } |
|
| 224 | } |
|
| 225 | ||
| 226 | ||
| 227 | ||
| @@ 233-250 (lines=18) @@ | ||
| 230 | * @param bool $add_to_header |
|
| 231 | * @throws DomainException |
|
| 232 | */ |
|
| 233 | public function addScriptAttributes( array $script_attributes, $add_to_header = false ) |
|
| 234 | { |
|
| 235 | if ( empty($script_attributes ) ) { |
|
| 236 | throw new DomainException( |
|
| 237 | esc_html__( |
|
| 238 | 'A non-empty array of strings, is required to add attributes to iframe Javascript.', |
|
| 239 | 'event_espresso' |
|
| 240 | ) |
|
| 241 | ); |
|
| 242 | } |
|
| 243 | foreach ($script_attributes as $handle => $script_attribute ) { |
|
| 244 | if ( $add_to_header ) { |
|
| 245 | $this->header_js_attributes[ $handle ] = $script_attribute; |
|
| 246 | } else { |
|
| 247 | $this->footer_js_attributes[ $handle ] = $script_attribute; |
|
| 248 | } |
|
| 249 | } |
|
| 250 | } |
|
| 251 | ||
| 252 | ||
| 253 | ||