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