PluginProbe
PDF Embed Block – share documents right inside your posts / trunk
PDF Embed Block – share documents right inside your posts vtrunk
1.3.3 1.3.2 1.3.1 1.3.0 trunk 1.0.0 1.0.1 1.0.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5
pdf-embed-block / includes / AdminMenu.php

AdminMenu.php in PDF Embed Block – share documents right inside your posts trunk, at includes/AdminMenu.php

66 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PEB;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 class AdminMenu {
10 function __construct() {
11 add_action('admin_menu', [$this, 'adminMenu']);
12 add_action('admin_init', [$this, 'handleLegacyRedirect']);
13 }
14
15 function handleLegacyRedirect() {
16 if ( isset( $_GET['page'] ) && $_GET['page'] === 'peb_settings_page' ) {
17 wp_safe_redirect( admin_url( 'edit.php?post_type=pdf_embed&page=peb_demo_page#/settings' ) );
18 exit;
19 }
20 }
21
22 function adminMenu(){
23 add_submenu_page(
24 'edit.php?post_type=pdf_embed',
25 'Settings',
26 'Settings <span style="background: linear-gradient(135deg, #ff6b00, #ff2e00); color: #fff; font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 10px; margin-left: 4px; display: inline-block; line-height: 1.2; text-transform: uppercase; letter-spacing: 0.5px; vertical-align: middle;">NEW</span>',
27 'manage_options',
28 'edit.php?post_type=pdf_embed&page=peb_demo_page#/settings',
29 [$this, 'renderSettingsPage']
30 );
31
32
33 add_submenu_page(
34 'edit.php?post_type=pdf_embed',
35 'Help & Demos',
36 '<span style="color: #f18500; font-weight: 600;">Help & Demos</span>',
37 'manage_options',
38 'peb_demo_page',
39 [$this, 'renderDemoPage']
40 );
41 }
42
43 function renderSettingsPage(){
44 wp_safe_redirect( admin_url( 'edit.php?post_type=pdf_embed&page=peb_demo_page#/settings' ) );
45 exit;
46 }
47
48 function renderDemoPage(){
49 ?>
50 <div
51 id='pebCurrentBplDashboard'
52 data-info='<?php echo esc_attr( wp_json_encode( [
53 'version' => PEB_PLUGIN_VERSION,
54 'isPremium' => false,
55 'hasPro' => false,
56 'adminUrl' => admin_url(),
57 'deleteDataOnUninstall' => (bool) get_option( 'peb_delete_data_on_uninstall', false ),
58 'uninstallNonce' => wp_create_nonce( 'peb_uninstall_nonce' ),
59 'globalViewerOptions' => function_exists( 'pebGetGlobalViewerOptions' ) ? pebGetGlobalViewerOptions() : [],
60 'globalOptionsNonce' => wp_create_nonce( 'peb_global_options_nonce' ),
61 ] ) ); ?>'
62 ></div>
63 <?php
64 }
65 }
66