Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Initializer | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| init | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Sets up the Sharing & Likes package. |
| 4 | * |
| 5 | * @package automattic/jetpack-sharing-likes |
| 6 | */ |
| 7 | |
| 8 | declare( strict_types = 1 ); |
| 9 | |
| 10 | namespace Automattic\Jetpack\Sharing_Likes; |
| 11 | |
| 12 | use Automattic\Jetpack\Sharing_Likes\Hooked_Blocks\Hooked_Blocks; |
| 13 | use Automattic\Jetpack\Sharing_Likes\REST\Endpoints; |
| 14 | use Automattic\Jetpack\Sharing_Likes\Settings\Post_Handler; |
| 15 | use Automattic\Jetpack\Sharing_Likes\Settings\Settings_Page; |
| 16 | |
| 17 | /** |
| 18 | * Wires up Settings > Sharing, the REST routes behind it, and the Sharing Buttons and Like blocks' |
| 19 | * template placements, even with the Sharing, Likes and Comment Likes modules off. |
| 20 | */ |
| 21 | final class Initializer { |
| 22 | |
| 23 | /** |
| 24 | * Package version. |
| 25 | */ |
| 26 | const PACKAGE_VERSION = '0.3.0'; |
| 27 | |
| 28 | /** |
| 29 | * Whether `init()` already ran in this request. |
| 30 | * |
| 31 | * @var bool |
| 32 | */ |
| 33 | private static $initialized = false; |
| 34 | |
| 35 | /** |
| 36 | * Hook everything up. Safe to call more than once. |
| 37 | */ |
| 38 | public static function init(): void { |
| 39 | if ( self::$initialized ) { |
| 40 | return; |
| 41 | } |
| 42 | self::$initialized = true; |
| 43 | |
| 44 | // Not behind `is_admin()`: Calypso's sidebar comes from `wpcom/v2/admin-menu`, a REST request that fires `admin_menu`. |
| 45 | Endpoints::init(); |
| 46 | Settings_Page::init(); |
| 47 | Post_Handler::init(); |
| 48 | Hooked_Blocks::init(); |
| 49 | } |
| 50 | } |