Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
83.33% |
5 / 6 |
|
100.00% |
1 / 1 |
CRAP | n/a |
0 / 0 |
|
| jetpack_shortcodes_should_hook_pre_kses | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Shared utility functions for Jetpack shortcodes. |
| 4 | * |
| 5 | * @package automattic/jetpack |
| 6 | */ |
| 7 | |
| 8 | use Automattic\Jetpack\Status\Request; |
| 9 | |
| 10 | if ( ! function_exists( 'jetpack_shortcodes_should_hook_pre_kses' ) ) { |
| 11 | /** |
| 12 | * Determine if shortcodes should hook on pre_kses. |
| 13 | * |
| 14 | * @param bool $force_recheck Whether to force a re-check of the request. Defaults to false. |
| 15 | * |
| 16 | * @return bool True if shortcodes should hook on pre_kses, false otherwise. |
| 17 | */ |
| 18 | function jetpack_shortcodes_should_hook_pre_kses( $force_recheck = false ) { |
| 19 | static $is_frontend; |
| 20 | |
| 21 | if ( $force_recheck || null === $is_frontend ) { |
| 22 | $is_frontend = Request::is_frontend( false ); |
| 23 | } |
| 24 | |
| 25 | $should_hook = ! $is_frontend; |
| 26 | |
| 27 | /** |
| 28 | * Filters whether shortcodes should hook on pre_kses. |
| 29 | * |
| 30 | * @since 15.0 |
| 31 | * |
| 32 | * @param bool $should_hook Whether shortcodes should hook on pre_kses. |
| 33 | */ |
| 34 | return apply_filters( 'jetpack_shortcodes_should_hook_pre_kses', $should_hook ); |
| 35 | } |
| 36 | } |