PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 3.6.0
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v3.6.0
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / app / Admin / Admin.php

Admin.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 3.6.0, at app/Admin/Admin.php

125 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * SOFTWARE LICENSE INFORMATION
4 *
5 * Copyright (c) 2017 Buttonizer, all rights reserved.
6 *
7 * This file is part of Buttonizer
8 *
9 * For detailed information regarding to the licensing of
10 * this software, please review the license.txt or visit:
11 * https://buttonizer.pro/license/
12 */
13
14 namespace Buttonizer\Admin;
15
16 use Buttonizer\Api\Settings\MigrateToStandalone;
17 use Buttonizer\Core\Admin\BaseAdmin;
18 use Buttonizer\Core\Utils\PermissionCheck;
19 use Buttonizer\Migration\LegacyFallback;
20
21 # No script kiddies
22 defined('ABSPATH') or die('No script kiddies please!');
23
24 class Admin extends BaseAdmin
25 {
26 /**
27 * Admin constructor.
28 */
29 public function __construct()
30 {
31 // Register shared admin hooks (assets, modules, notices)
32 parent::__construct();
33
34 // Add to admin menu
35 add_action('admin_menu', [$this, 'pluginAdminMenu']);
36
37 // Plugin information, add links
38 add_filter("plugin_action_links_" . BUTTONIZER_BASE_NAME, function ($actions) {
39 $links = [
40 '<a href="' . admin_url('admin.php?page=Buttonizer#/support') . '">' . __('Support', 'buttonizer-multifunctional-button') . '</a>',
41 '<a href="' . admin_url('admin.php?page=Buttonizer#/editor') . '">' . __('Edit buttons', 'buttonizer-multifunctional-button') . '</a>',
42 '<a href="' . admin_url('admin.php?page=Buttonizer#/settings') . '">' . __('Settings', 'buttonizer-multifunctional-button') . '</a>',
43 ];
44
45 return array_merge($actions, $links);
46 });
47 }
48
49 /**
50 * Create Admin menu
51 */
52 public function pluginAdminMenu()
53 {
54
55 if (!PermissionCheck::hasPermission()) return;
56
57 // Admin menu
58 add_menu_page('Buttonizer Buttons', 'Buttonizer', 'read', 'Buttonizer', [$this, 'page'], plugins_url('/assets/images/wp-icon.png', BUTTONIZER_PLUGIN_DIR), 81);
59
60 // Add submenu
61 add_submenu_page('Buttonizer', 'Edit buttons', __('Edit buttons', 'buttonizer-multifunctional-button'), 'read', 'admin.php?page=Buttonizer#/editor');
62
63 // Add support link
64 add_submenu_page('Buttonizer', __('I need support', 'buttonizer-multifunctional-button'), __('I need support', 'buttonizer-multifunctional-button'), 'read', 'admin.php?page=Buttonizer#/support');
65
66 // Add community link
67 add_submenu_page('Buttonizer', __('Community', 'buttonizer-multifunctional-button'), __('Community', 'buttonizer-multifunctional-button'), 'read', 'https://r.buttonizer.io/support/community?referral=buttonizer-plugin-menu');
68
69 // Add knowledge base link
70 add_submenu_page('Buttonizer', __('Knowledge base', 'buttonizer-multifunctional-button'), __('Knowledge base', 'buttonizer-multifunctional-button'), 'read', 'https://r.buttonizer.io/support/knowledgebase?referral=buttonizer-plugin-menu');
71 }
72
73 /**
74 * Lock the screen to a specific action.
75 *
76 * Adds legacy migration check on top of the base implementation.
77 *
78 * @return string lock
79 */
80 public function getActionLock(): string
81 {
82 // Needs migration (legacy-specific)
83 if (defined("BUTTONIZER_LEGACY_REQUESTED_MIGRATION") && !BUTTONIZER_LEGACY_REQUESTED_MIGRATION) {
84 return "migration";
85 }
86
87 return parent::getActionLock();
88 }
89
90 /**
91 * Dashboard configuration.
92 *
93 * Adds whether this site can go back to an absorbed plugin's old system,
94 * so the signup screen can offer it the way that plugin used to.
95 *
96 * @return array
97 */
98 protected function getLocalizeData(): array
99 {
100 $data = parent::getLocalizeData();
101
102 $source = LegacyFallback::available();
103
104 // Only ever offered to a site whose old system Buttonizer took over,
105 // so the name that means something here is the old one.
106 $data['legacyModule'] = $source ? ['label' => $source->legacyLabel()] : null;
107
108 return $data;
109 }
110
111 /**
112 * Migration status (legacy-specific).
113 *
114 * @return mixed
115 */
116 public function getBeforeMigrate()
117 {
118 if (!defined("BUTTONIZER_LEGACY_REQUESTED_MIGRATION")) {
119 return null;
120 }
121
122 return MigrateToStandalone::getReadyForMigration();
123 }
124 }
125