PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / php / Admin / Menus / Insights / Insights_Menu.php

Insights_Menu.php in Code Snippets 4.0.0-beta.2, at php/Admin/Menus/Insights/Insights_Menu.php

79 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Code_Snippets\Admin\Menus\Insights;
4
5 use Code_Snippets\Admin\Contextual_Help;
6 use Code_Snippets\Admin\Menus\Admin_Menu;
7 use function Code_Snippets\code_snippets;
8 use const Code_Snippets\PLUGIN_FILE;
9 use const Code_Snippets\PLUGIN_VERSION;
10
11 /**
12 * Provides the Insights admin menu.
13 */
14 class Insights_Menu extends Admin_Menu {
15
16 /**
17 * Handle for the Insights script and stylesheet.
18 */
19 private const ASSET_HANDLE = 'code-snippets-insights';
20
21 /**
22 * Class constructor.
23 */
24 public function __construct() {
25 parent::__construct(
26 'insights',
27 _x( 'Insights', 'menu label', 'code-snippets' ),
28 __( 'Snippet Insights', 'code-snippets' )
29 );
30 }
31
32 /**
33 * Render the Insights interface.
34 *
35 * @return void
36 */
37 public function render() {
38 echo '<div id="code-snippets-insights-container" class="wrap"></div>';
39 }
40
41 /**
42 * Load the contextual help tabs.
43 *
44 * @return void
45 */
46 public function load() {
47 parent::load();
48
49 $contextual_help = new Contextual_Help( 'insights' );
50 $contextual_help->load();
51 }
52
53 /**
54 * Enqueue Insights assets and localized runtime data.
55 *
56 * @return void
57 */
58 public function enqueue_assets() {
59 wp_enqueue_style(
60 self::ASSET_HANDLE,
61 plugins_url( 'dist/insights.css', PLUGIN_FILE ),
62 self::$style_deps,
63 PLUGIN_VERSION
64 );
65
66 wp_enqueue_script(
67 self::ASSET_HANDLE,
68 plugins_url( 'dist/insights.js', PLUGIN_FILE ),
69 self::$script_deps,
70 PLUGIN_VERSION,
71 true
72 );
73
74 wp_set_script_translations( self::ASSET_HANDLE, 'code-snippets' );
75 code_snippets()->localize_script( self::ASSET_HANDLE );
76 wp_localize_script( self::ASSET_HANDLE, 'CODE_SNIPPETS_INSIGHTS', ( new Insights_Summary() )->get() );
77 }
78 }
79