Skip to content

Commit

Permalink
Multi-Layer Admin Menu, Removed legacy ASM table, Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
otrok7 committed Nov 14, 2024
1 parent b5e29be commit f2ec3f5
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 327 deletions.
50 changes: 50 additions & 0 deletions admin/class-bmltenabled-admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* Creates the main item in the admin menu, where both bread and crouton admins can live.
*
* @package Bread
* @subpackage Bread/admin
* @author bmlt-enabled <[email protected]>
*/
class BmltEnabled_Admin
{
private bool $menu_created = false;
/**
* Initialize the class and set its properties.
*
* @since 2.8.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct()
{
}
public function createdMenu()
{
$this->menu_created = true;
}
function admin_menu_link()
{
if ($this->menu_created) {
return;
}
$cap = 'manage_options';
if (!current_user_can($cap)) {
$cap = 'manage_bread';
}
$slugs = apply_filters('BmltEnabled_Slugs', []);
$slug = $slugs[0];
add_menu_page(
'Meeting List',
'Meeting List',
$cap,
$slug,
'',
//'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyINCiB3aWR0aD0iNTAuMDAwMDAwcHQiIGhlaWdodD0iNTAuMDAwMDAwcHQiIHZpZXdCb3g9IjAgMCA1MC4wMDAwMDAgNTAuMDAwMDAwIg0KIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIG1lZXQiPg0KDQo8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLjAwMDAwMCw1MC4wMDAwMDApIHNjYWxlKDAuMTAwMDAwLC0wLjEwMDAwMCkiDQpmaWxsPSIjMDAwMDAwIiBzdHJva2U9Im5vbmUiPg0KPHBhdGggZD0iTTI4MCAzNjEgYzAgLTc0IC0zIC05MSAtMTUgLTkxIC0xMiAwIC0xNSAxNSAtMTUgNzEgMCA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yIC02IDE3IDIgNCA2IDMgMTYgLTMgMjIgLTYgNg0KLTEyIDYgLTE3IC0yeiIvPg0KPC9nPg0KPC9zdmc+',
'dashicons-location-alt',
null
);
do_action('BmltEnabled_Submenu', $slug);
}
}
33 changes: 20 additions & 13 deletions admin/class-bread-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ class Bread_Admin
var $outside_meeting_result = array();
var $maxSetting = 1;
var $loaded_setting = 1;
public function __construct($plugin_name, $version)
var $bmltEnabled_admin;
public function __construct($plugin_name, $version, $bmltEnabled_admin)
{
$this->plugin_name = $plugin_name;
$this->version = $version;
$this->bmltEnabled_admin = $bmltEnabled_admin;
}

/**
Expand All @@ -64,7 +66,7 @@ public function __construct($plugin_name, $version)
*/
public function enqueue_styles($hook)
{
if ($hook != 'toplevel_page_class-bread-admin') {
if (!str_ends_with($hook, 'page_class-bread-admin')) {
return;
}
wp_enqueue_style("jquery-ui", plugin_dir_url(__FILE__) . "css/jquery-ui.min.css", false, "1.2", 'all');
Expand All @@ -80,7 +82,7 @@ public function enqueue_styles($hook)
*/
public function enqueue_scripts($hook)
{
if ($hook != 'toplevel_page_class-bread-admin') {
if (!str_ends_with($hook, 'page_class-bread-admin')) {
return;
}
wp_enqueue_script('common');
Expand Down Expand Up @@ -358,10 +360,6 @@ function filter_plugin_actions($links, $file)
$settings_link = '<a href="options-general.php?page=' . basename(__FILE__) . '">' . __('Settings') . '</a>';
array_unshift($links, $settings_link); // before other links
return $links;
}
function arraySafeGet($arr, $i = 0)
{
return is_array($arr) ? $arr[$i] ?? '': '';
}
/**
* Saves the admin options to the database.
Expand Down Expand Up @@ -399,22 +397,31 @@ function get($url, $cookies = array())
$args['sslverify'] = false;
}
return wp_remote_get($url, $args);
}
function submenu_slug($slugs)
{
$this->bmltEnabled_admin->createdMenu();
if (!is_array($slugs)) {
$slugs = array();
}
$slugs[] = basename(__FILE__);
return $slugs;
}
/**
* @desc Adds the options sub-panel
*/
function admin_menu_link()
function admin_submenu_link($parent_slug)
{
activate_bread();
global $my_admin_page;
Bread_Activator::activate();
$my_admin_page = add_menu_page(
'Meeting List',
'Meeting List',
$my_admin_page = add_submenu_page(
$parent_slug,
'Printable Meeting List',
'Printable Meeting List',
'manage_bread',
basename(__FILE__),
array(&$this, 'admin_options_page'),
'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyINCiB3aWR0aD0iNTAuMDAwMDAwcHQiIGhlaWdodD0iNTAuMDAwMDAwcHQiIHZpZXdCb3g9IjAgMCA1MC4wMDAwMDAgNTAuMDAwMDAwIg0KIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIG1lZXQiPg0KDQo8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLjAwMDAwMCw1MC4wMDAwMDApIHNjYWxlKDAuMTAwMDAwLC0wLjEwMDAwMCkiDQpmaWxsPSIjMDAwMDAwIiBzdHJva2U9Im5vbmUiPg0KPHBhdGggZD0iTTI4MCAzNjEgYzAgLTc0IC0zIC05MSAtMTUgLTkxIC0xMiAwIC0xNSAxNSAtMTUgNzEgMCA2NyAtMSA3MCAtMjINCjY3IC0yMSAtMyAtMjMgLTEwIC0yOCAtNzIgbC01IC02OSAtMzQgNzEgYy0zNCA3MCAtMzUgNzEgLTU0IDU0IC01NSAtNDggLTcyDQotMTU1IC0zNiAtMjI5IDE4IC0zNiAyNSAtNDMgNTEgLTQzIGwyOSAwIC0yMSAzMCBjLTMzIDQ3IC00MyA5MyAtMjkgMTQyIGwxMQ0KNDMgNjkgLTEzNSA2OCAtMTM1IDAgODMgYzEgNjIgNCA4MyAxNCA4MCA3IC0zIDEzIC0yNiAxNSAtNTYgMyAtNDQgNiAtNTIgMjMNCi01MiAxNiAwIDE5IDcgMTkgNTUgbDAgNTUgNDAgMCBjNDkgMCA1MiAtMTcgMTUgLTczIGwtMjYgLTM3IDMxIDAgYzI3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