-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin-folder-structure.php
67 lines (57 loc) · 2.06 KB
/
plugin-folder-structure.php
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
<?php
/**
* Plugin Name: Plugin Folder Structure Generator
* Description: Generate and export folder structures of available plugins to debug or visualize the plugin structure.
* Version: 1.0.0
* Author: Prabakaran Shankar
* Author URI: https://prabakaranshankar.com
* plugin uri: https://nviewsweb.com/plugin-folder-structure-generator/
* Text Domain: plugin-folder-structure
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
defined('ABSPATH') || exit;
// Include required files
require_once plugin_dir_path(__FILE__) . 'includes/class-plugin-folder-generator.php';
require_once plugin_dir_path(__FILE__) . 'admin/settings-page.php';
// Initialize the plugin
add_action('admin_menu', function () {
Plugin_Folder_Generator_Settings::add_settings_page();
});
add_action('admin_post_download_file', function () {
if (isset($_POST['file_path'])) {
$file_path = sanitize_text_field($_POST['file_path']);
Plugin_Folder_Generator::serve_file_for_download($file_path);
}
});
/**
* Initialize the default exclude list on plugin activation
*/
function plugin_folder_generator_activate() {
$default_list = [
'node_modules' => true,
'vendor' => true,
'.git' => true,
'build' => true,
'__MACOSX' => true,
];
// Retrieve the existing list
$current_list = get_option('plugin_folder_generator_exclude_list', []);
// Merge new defaults without overwriting existing items
foreach ($default_list as $key => $value) {
if (!array_key_exists($key, $current_list)) {
$current_list[$key] = $value;
}
}
// Save the updated list
update_option('plugin_folder_generator_exclude_list', $current_list);
}
// Register activation hook
register_activation_hook(__FILE__, 'plugin_folder_generator_activate');
/**
* Clean up options on plugin deactivation
*/
function plugin_folder_generator_deactivate() {
delete_option('plugin_folder_generator_exclude_list');
}
register_deactivation_hook(__FILE__, 'plugin_folder_generator_deactivate');