PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / trunk
Gutenify – Visual Site Builder Blocks & Starter Templates vtrunk
1.7.0 1.6.6 1.6.5 1.6.4 trunk 0.0.1 0.0.2 0.0.3 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 All 72 releases
gutenify / core / inc / admin / class-menu.php

class-menu.php in Gutenify – Visual Site Builder Blocks & Starter Templates trunk, at core/inc/admin/class-menu.php

156 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin Menu for Gutenify
4 *
5 * Handles registration and rendering of the Gutenify admin menu and submenus.
6 *
7 * @package Gutenify
8 */
9
10 namespace gutenify;
11
12 if ( ! defined( 'ABSPATH' ) ) exit;
13
14 /**
15 * Class Menu
16 *
17 * Handles the admin menu and related callbacks for Gutenify.
18 */
19 class Menu {
20
21 /**
22 * Menu constructor.
23 *
24 * Adds required WordPress hooks for menu and redirection.
25 */
26 public function __construct() {
27 add_action( 'admin_menu', array( $this, 'register_sub_menu' ) );
28 add_action( 'init', array( $this, 'redirect_template_kit_page' ) );
29 }
30
31 /**
32 * Redirects old 'gutenify-template-kits' submenu to 'gutenify-demo-importer'.
33 *
34 * Prevents users from landing on deprecated submenu.
35 *
36 * @return void
37 */
38 public function redirect_template_kit_page() {
39 if ( ! is_admin() ) {
40 return;
41 }
42 $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
43 if ( ! empty( $page ) && 'gutenify-template-kits' === $page ) {
44 wp_safe_redirect( admin_url( 'admin.php?page=gutenify-demo-importer' ) );
45 exit;
46 }
47 }
48
49 /**
50 * Registers the main Gutenify menu and all submenus.
51 *
52 * @return void
53 */
54 public function register_sub_menu() {
55 // Main menu page.
56 add_menu_page(
57 __( 'Gutenify: Getting Started', 'gutenify' ),
58 __( 'Gutenify', 'gutenify' ),
59 'manage_options',
60 'gutenify',
61 array( $this, 'getting_started_page_callback' ),
62 GUTENIFY_BRAND_LOGO,
63 90
64 );
65
66 // First submenu: label for first submenu.
67 add_submenu_page(
68 'gutenify',
69 esc_html__( 'Gutenify: Getting Started', 'gutenify' ),
70 esc_html__( 'Getting Started', 'gutenify' ),
71 'manage_options',
72 'gutenify',
73 array( $this, 'getting_started_page_callback' )
74 );
75
76 // Demo Importer submenu.
77 add_submenu_page(
78 'gutenify',
79 __( 'Gutenify Demo Importer', 'gutenify' ),
80 __( 'Demo Importer', 'gutenify' ),
81 'manage_options',
82 'gutenify-demo-importer',
83 array( $this, 'demo_importer_page_callback' )
84 );
85
86 // Settings submenu.
87 add_submenu_page(
88 'gutenify',
89 __( 'Gutenify Settings', 'gutenify' ),
90 __( 'Settings', 'gutenify' ),
91 'manage_options',
92 'gutenify-settings',
93 array( $this, 'settings_page_callback' )
94 );
95 }
96
97 /**
98 * Callback for the Demo Importer submenu page.
99 *
100 * @return void
101 */
102 public function demo_importer_page_callback() {
103 $handle = Demo_Importer_V2::$handle;
104 wp_enqueue_script( $handle );
105 wp_enqueue_style( $handle );
106 echo '<div class="wrap">';
107 echo '<div id="gutenify-demo-importer-app">Loading...</div>';
108 echo '</div>';
109 }
110
111 /**
112 * Callback for the (optional) Start Up submenu page.
113 *
114 * @return void
115 */
116 public function startup_page_callback() {
117 echo '<div class="wrap">';
118 echo '<div id="gutenify-start-up-app">Loading...</div>';
119 echo '</div>';
120 }
121
122 /**
123 * Callback for the Settings submenu page.
124 *
125 * @return void
126 */
127 public function settings_page_callback() {
128 $handle = Settings_Admin_Page::$handle;
129 wp_enqueue_script( $handle );
130 wp_enqueue_style( $handle );
131 echo '<div class="wrap">';
132 echo '<div id="gutenify-settings-app">Loading...</div>';
133 echo '</div>';
134 }
135
136 /**
137 * Callback for the Getting Started main menu page.
138 *
139 * @return void
140 */
141 public function getting_started_page_callback() {
142 $handle = Getting_Started::$handle;
143 wp_enqueue_script( $handle );
144 wp_enqueue_style( $handle );
145
146 $output = '<div class="wrap">';
147 $output .= '<div id="gutenify-getting-started-app">Loading...</div>';
148 $output .= '</div>';
149
150 echo wp_kses_post( $output );
151 }
152 }
153
154 // Initialize the admin menu.
155 new Menu();
156