-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwp-bulk-plugin-checker.php
More file actions
136 lines (119 loc) · 4.35 KB
/
mainwp-bulk-plugin-checker.php
File metadata and controls
136 lines (119 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* Plugin Name: [API] MainWP Bulk Plugin Checker
* Plugin URI: https://github.com/chiedev
* Description: Check multiple MainWP sites for specific plugin installations using the MainWP REST API. Features include bulk checking, custom site lists, sortable results, and CSV export.
* Version: 1.0.0
* Author: chiedev (Raycille Dimla)
* Author URI: https://github.com/chiedev
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: mainwp-bulk-plugin-checker
* Domain Path: /languages
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
// Define plugin constants
define('MWPPC_VERSION', '1.0.0');
define('MWPPC_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('MWPPC_PLUGIN_URL', plugin_dir_url(__FILE__));
define('MWPPC_PLUGIN_BASENAME', plugin_basename(__FILE__));
/**
* MainWP Bulk Plugin Checker Class
*/
class MainWP_Bulk_Plugin_Checker {
/**
* Constructor
*/
public function __construct() {
// Add admin menu
add_action('admin_menu', array($this, 'add_admin_menu'));
// Enqueue scripts and styles
add_action('admin_enqueue_scripts', array($this, 'enqueue_assets'));
// Add settings link on plugins page
add_filter('plugin_action_links_' . MWPPC_PLUGIN_BASENAME, array($this, 'add_settings_link'));
}
/**
* Add admin menu
*/
public function add_admin_menu() {
add_menu_page(
__('MainWP Plugin Checker', 'mainwp-bulk-plugin-checker'),
__('Plugin Checker', 'mainwp-bulk-plugin-checker'),
'manage_options',
'mainwp-plugin-checker',
array($this, 'render_admin_page'),
'dashicons-search',
30
);
// Add settings submenu
add_submenu_page(
'mainwp-plugin-checker',
__('Settings', 'mainwp-bulk-plugin-checker'),
__('Settings', 'mainwp-bulk-plugin-checker'),
'manage_options',
'mainwp-plugin-checker-settings',
array($this, 'render_settings_page')
);
}
/**
* Enqueue scripts and styles
*/
public function enqueue_assets($hook) {
// Only load on our plugin pages
if ($hook !== 'toplevel_page_mainwp-plugin-checker' && $hook !== 'plugin-checker_page_mainwp-plugin-checker-settings') {
return;
}
// Enqueue styles
wp_enqueue_style(
'mwppc-admin-style',
MWPPC_PLUGIN_URL . 'assets/css/admin-style.css',
array(),
MWPPC_VERSION
);
// Enqueue scripts
wp_enqueue_script(
'mwppc-admin-script',
MWPPC_PLUGIN_URL . 'assets/js/admin-script.js',
array(),
MWPPC_VERSION,
true
);
// Localize script with config
wp_localize_script('mwppc-admin-script', 'MWPPCConfig', array(
'baseUrl' => get_option('mwppc_api_base_url', ''),
'apiKey' => get_option('mwppc_api_key', ''),
'nonce' => wp_create_nonce('mwppc_nonce')
));
}
/**
* Render admin page
*/
public function render_admin_page() {
include MWPPC_PLUGIN_DIR . 'templates/admin-page.php';
}
/**
* Render settings page
*/
public function render_settings_page() {
// Save settings if form submitted
if (isset($_POST['mwppc_save_settings']) && check_admin_referer('mwppc_settings_nonce')) {
update_option('mwppc_api_base_url', sanitize_text_field($_POST['mwppc_api_base_url']));
update_option('mwppc_api_key', sanitize_text_field($_POST['mwppc_api_key']));
echo '<div class="notice notice-success is-dismissible"><p>' . __('Settings saved successfully!', 'mainwp-bulk-plugin-checker') . '</p></div>';
}
include MWPPC_PLUGIN_DIR . 'templates/settings-page.php';
}
/**
* Add settings link on plugins page
*/
public function add_settings_link($links) {
$settings_link = '<a href="' . admin_url('admin.php?page=mainwp-plugin-checker-settings') . '">' . __('Settings', 'mainwp-bulk-plugin-checker') . '</a>';
array_unshift($links, $settings_link);
return $links;
}
}
// Initialize the plugin
new MainWP_Bulk_Plugin_Checker();