PluginProbe
Document Embedder – let visitors read files without downloading / 2.1.2
Document Embedder – let visitors read files without downloading v2.1.2
2.3.1 2.3.0 2.2.1 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.3 1.7.4 1.7.6 1.7.9 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 2.0.0 2.0.1 2.0.2 All 30 releases
document-emberdder / includes / admin / class-bplde-menu.php

class-bplde-menu.php in Document Embedder – let visitors read files without downloading 2.1.2, at includes/admin/class-bplde-menu.php

112 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * BPLDE Menu Class.
4 *
5 * @package DocumentEmbedder
6 */
7
8 namespace BPLDE\Admin;
9
10 if (!defined('ABSPATH')) {
11 exit;
12 }
13
14 if (!class_exists('BPLDE_Menu')) {
15 class BPLDE_Menu {
16
17 private static $_instance = null;
18
19 public static function instance() {
20 if (is_null(self::$_instance)) {
21 self::$_instance = new self();
22 }
23 return self::$_instance;
24 }
25
26 private function __construct() {
27 add_action('admin_menu', [$this, 'add_menus']);
28 add_action('admin_menu', [$this, 'remove_menus'], 999);
29 add_action('admin_menu', [$this, 'reorder_menus'], 9999);
30 }
31
32 /**
33 * Add submenus under PPT Viewer post type
34 */
35 public function add_menus() {
36 // Add Help & Demos submenu
37 add_submenu_page(
38 'edit.php?post_type=ppt_viewer',
39 __('Help & Demos', 'document-emberdder'),
40 __('<span style="color: #f18500;">Help & Demos</span>', 'document-emberdder'),
41 'manage_options',
42 'bplde-dashboard',
43 [$this, 'render_dashboard_page']
44 );
45
46 // Add Leads submenu (registered but hidden from menu tree via remove_menus)
47 if (class_exists('\BPLDE\Admin\LeadsPage')) {
48 add_submenu_page(
49 'edit.php?post_type=ppt_viewer',
50 'Download Leads',
51 'Download Leads',
52 'manage_options',
53 'bplde-download-leads',
54 [\BPLDE\Admin\LeadsPage::instance(), 'render_page']
55 );
56 }
57 }
58
59 /**
60 * Hide the registered leads page from the admin sidebar menu tree
61 */
62 public function remove_menus() {
63 remove_submenu_page('edit.php?post_type=ppt_viewer', 'bplde-download-leads');
64 }
65
66 /**
67 * Reorder submenus under PPT Viewer to push Help & Demos to the end
68 */
69 public function reorder_menus() {
70 global $submenu;
71
72 $parent = 'edit.php?post_type=ppt_viewer';
73 $slug = 'bplde-dashboard';
74
75 if (!isset($submenu[$parent])) {
76 return;
77 }
78
79 foreach ($submenu[$parent] as $index => $item) {
80 if ($item[2] === $slug) {
81 $menu_item = $item;
82 unset($submenu[$parent][$index]);
83 $submenu[$parent][] = $menu_item; // push to end
84 break;
85 }
86 }
87 }
88
89 /**
90 * Render callback for Help & Demos page
91 */
92 public function render_dashboard_page() {
93 ?>
94 <style>
95 #wpcontent {
96 padding-left: 0 !important;
97 }
98 </style>
99 <div id='bpldeDashboard' data-info='<?php echo esc_attr(wp_json_encode([
100 'version' => BPLDE_VER,
101 'isPremium' => false,
102 'hasPro' => BPLDE_HAS_PRO,
103 'licenseActiveNonce' => wp_create_nonce('bPlLicenseActivation'),
104 'exportLeadsNonce' => wp_create_nonce('de_export_leads_csv')
105 ])); ?>'></div>
106 <?php
107 }
108 }
109
110 BPLDE_Menu::instance();
111 }
112