| @@ 418-432 (lines=15) @@ | ||
| 415 | * Default true. |
|
| 416 | * @return string|false Script on success, false otherwise. |
|
| 417 | */ |
|
| 418 | public function print_inline_script( $handle, $position = 'after', $echo = true ) { |
|
| 419 | $output = $this->get_data( $handle, $position ); |
|
| 420 | ||
| 421 | if ( empty( $output ) ) { |
|
| 422 | return false; |
|
| 423 | } |
|
| 424 | ||
| 425 | $output = trim( implode( "\n", $output ), "\n" ); |
|
| 426 | ||
| 427 | if ( $echo ) { |
|
| 428 | printf( "<script type='text/javascript'>\n%s\n</script>\n", $output ); |
|
| 429 | } |
|
| 430 | ||
| 431 | return $output; |
|
| 432 | } |
|
| 433 | ||
| 434 | /** |
|
| 435 | * Localizes a script, only if the script has already been added. |
|
| @@ 281-297 (lines=17) @@ | ||
| 278 | * Default true. |
|
| 279 | * @return string|bool False if no data exists, inline styles if `$echo` is true, true otherwise. |
|
| 280 | */ |
|
| 281 | public function print_inline_style( $handle, $echo = true ) { |
|
| 282 | $output = $this->get_data( $handle, 'after' ); |
|
| 283 | ||
| 284 | if ( empty( $output ) ) { |
|
| 285 | return false; |
|
| 286 | } |
|
| 287 | ||
| 288 | $output = implode( "\n", $output ); |
|
| 289 | ||
| 290 | if ( ! $echo ) { |
|
| 291 | return $output; |
|
| 292 | } |
|
| 293 | ||
| 294 | printf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $output ); |
|
| 295 | ||
| 296 | return true; |
|
| 297 | } |
|
| 298 | ||
| 299 | /** |
|
| 300 | * Determines style dependencies. |
|