actions.php
29 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Action Hooks for Jetpack connection assets. |
| 4 | * |
| 5 | * @package automattic/jetpack-connection |
| 6 | */ |
| 7 | |
| 8 | if ( function_exists( 'is_admin' ) && ! is_admin() && ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) ) { |
| 9 | // Don't initialize the assets in the frontend on self-hosted and WoA. |
| 10 | return; |
| 11 | } |
| 12 | |
| 13 | // If WordPress's plugin API is available already, use it. If not, |
| 14 | // drop data into `$wp_filter` for `WP_Hook::build_preinitialized_hooks()`. |
| 15 | if ( function_exists( 'add_action' ) ) { |
| 16 | add_action( |
| 17 | 'plugins_loaded', |
| 18 | array( Automattic\Jetpack\Connection\Connection_Assets::class, 'configure' ), |
| 19 | 1 |
| 20 | ); |
| 21 | } else { |
| 22 | global $wp_filter; |
| 23 | // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 24 | $wp_filter['plugins_loaded'][1][] = array( |
| 25 | 'accepted_args' => 0, |
| 26 | 'function' => array( Automattic\Jetpack\Connection\Connection_Assets::class, 'configure' ), |
| 27 | ); |
| 28 | } |
| 29 |