PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
jetpack / jetpack_vendor / automattic / jetpack-menu-badges / src / class-menu-badges.php

class-menu-badges.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-beta, at jetpack_vendor/automattic/jetpack-menu-badges/src/class-menu-badges.php

53 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Bootstrap for the Jetpack menu-badges package.
4 *
5 * @package automattic/jetpack-menu-badges
6 */
7
8 namespace Automattic\Jetpack\Menu_Badges;
9
10 /**
11 * Wires the notification-count registry into the admin menu and enqueues the client.
12 */
13 class Menu_Badges {
14
15 const PACKAGE_VERSION = '0.2.1';
16
17 /**
18 * Initialize the package. Idempotent.
19 *
20 * @return void
21 */
22 public static function init() {
23 static $done = false;
24 if ( $done ) {
25 return;
26 }
27 $done = true;
28
29 // Render badges late, after products have registered their menus and counts.
30 add_action( 'admin_menu', array( Menu_Renderer::class, 'render' ), 100000 );
31
32 // Client live-update API.
33 add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_client' ) );
34 }
35
36 /**
37 * Enqueue the vanilla client that owns live badge updates.
38 *
39 * @return void
40 */
41 public static function enqueue_client() {
42 \Automattic\Jetpack\Assets::register_script(
43 'jetpack-menu-badges',
44 '../src/js/menu-badges.js',
45 __FILE__,
46 array(
47 'enqueue' => true,
48 'in_footer' => true,
49 )
50 );
51 }
52 }
53