| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- Legacy TaxoPress file: keep behavior unchanged while documenting existing PHPCS exceptions. |
| 4 |
|
| 5 |
class SimpleTags_Dashboard |
| 6 |
{ |
| 7 |
public const MENU_SLUG = 'st_options'; |
| 8 |
|
| 9 |
// class instance |
| 10 |
public static $instance; |
| 11 |
|
| 12 |
/** |
| 13 |
* Constructor |
| 14 |
* |
| 15 |
* @return void |
| 16 |
* @author Olatechpro |
| 17 |
*/ |
| 18 |
public function __construct() |
| 19 |
{ |
| 20 |
// Admin menu |
| 21 |
add_action('admin_menu', [$this, 'admin_menu']); |
| 22 |
} |
| 23 |
|
| 24 |
/** Singleton instance */ |
| 25 |
public static function get_instance() |
| 26 |
{ |
| 27 |
if (!isset(self::$instance)) { |
| 28 |
self::$instance = new self(); |
| 29 |
} |
| 30 |
|
| 31 |
return self::$instance; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Add WP admin menu for Tags |
| 36 |
* |
| 37 |
* @return void |
| 38 |
* @author Olatechpro |
| 39 |
*/ |
| 40 |
public function admin_menu() |
| 41 |
{ |
| 42 |
$hook = add_submenu_page( |
| 43 |
self::MENU_SLUG, |
| 44 |
esc_html__('Dashboard', 'simple-tags'), |
| 45 |
esc_html__('Dashboard', 'simple-tags'), |
| 46 |
'simple_tags', |
| 47 |
'st_dashboard', |
| 48 |
[ |
| 49 |
$this, |
| 50 |
'page_manage_dashboard', |
| 51 |
] |
| 52 |
); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Method for build the page HTML manage tags |
| 57 |
* |
| 58 |
* @return void |
| 59 |
* @author Ojopaul |
| 60 |
*/ |
| 61 |
public function page_manage_dashboard() |
| 62 |
{ |
| 63 |
// Default order |
| 64 |
if (!isset($_GET['order'])) { |
| 65 |
$_GET['order'] = 'name-asc'; |
| 66 |
} |
| 67 |
|
| 68 |
// Display message |
| 69 |
settings_errors(__CLASS__); |
| 70 |
|
| 71 |
$show_welcome = isset($_GET['welcome']) ? true : false; |
| 72 |
?> |
| 73 |
<?php if ($show_welcome) : ?> |
| 74 |
<div class="taxopress-welcome-banner"> |
| 75 |
<div class="banner-wrap"> |
| 76 |
<div class="banner-inner"> |
| 77 |
<a> |
| 78 |
<img src="<?php echo esc_url(STAGS_URL . '/assets/images/tp-email-logo.png'); ?>" alt="TaxoPress Logo"/> |
| 79 |
</a> |
| 80 |
</div> |
| 81 |
</div> |
| 82 |
</div> |
| 83 |
|
| 84 |
<div class="taxopress-welcome-content"> |
| 85 |
<div class="content-wrap"> |
| 86 |
<div class="taxopress-welcome"> |
| 87 |
<div class="welcome-panel-content"> |
| 88 |
<h2><?php esc_html_e('Welcome to TaxoPress, the WordPress taxonomy plugin', 'simple-tags'); ?></h2> |
| 89 |
</div> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
</div> |
| 93 |
<?php endif; ?> |
| 94 |
<div class="taxopress-block-wrap"> |
| 95 |
<div class="wrap st_wrap tagcloudui st_dashboard-page admin-settings"> |
| 96 |
<h1 class="wp-heading-inline"><?php esc_html_e('Dashboard', 'simple-tags'); ?></h1> |
| 97 |
<div class="taxopress-description"> |
| 98 |
<?php esc_html_e('This screen allows you to enable or disable TaxoPress features.', 'simple-tags'); ?> |
| 99 |
</div> |
| 100 |
|
| 101 |
<form id="taxopress-capabilities-dashboard-form"> |
| 102 |
<div class="taxopress-dashboard-settings-boxes"> |
| 103 |
<?php foreach (taxopress_dashboard_options() as $feature => $option) : |
| 104 |
$feature_option_key = $option['option_key']; |
| 105 |
?> |
| 106 |
<div class="taxopress-dashboard-settings-box"> |
| 107 |
<h3><?php echo esc_html($option['label']); ?></h3> |
| 108 |
<div class="taxopress-dashboard-settings-description"><?php echo esc_html($option['description']); ?></div> |
| 109 |
<div class="taxopress-dashboard-settings-control"> |
| 110 |
<div class="taxopress-switch-button"> |
| 111 |
<label class="switch"> |
| 112 |
<input type="checkbox" value="1" data-option_key="<?php echo esc_attr($feature_option_key); ?>" data-feature="<?php echo esc_attr($feature); ?>" <?php checked((int) SimpleTags_Plugin::get_option_value($feature_option_key), 1); ?> /> |
| 113 |
<span class="slider"></span> |
| 114 |
</label> |
| 115 |
</div> |
| 116 |
</div> |
| 117 |
</div> |
| 118 |
<?php endforeach; ?> |
| 119 |
</div> |
| 120 |
</form> |
| 121 |
</div> |
| 122 |
|
| 123 |
<div class="taxopress-right-sidebar admin-settings-sidebar"> |
| 124 |
<?php do_action('taxopress_admin_after_sidebar'); ?> |
| 125 |
</div> |
| 126 |
|
| 127 |
</div> |
| 128 |
|
| 129 |
<?php |
| 130 |
} |
| 131 |
} |
| 132 |
|