-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-switch.php
More file actions
56 lines (49 loc) · 1.39 KB
/
custom-switch.php
File metadata and controls
56 lines (49 loc) · 1.39 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
<?php
/*
Plugin Name: Custom Switch for WP
Description: Un plugin pour créer des boutons switch paramétrables via un shortcode.
Version: 1.0.1
Author: johan63360
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
define('CUSTOM_SWITCH_PLUGIN_URL', plugin_dir_url(__FILE__));
define('CUSTOM_SWITCH_PLUGIN_DIR', plugin_dir_path(__FILE__));
// Inclure les fichiers nécessaires
require_once CUSTOM_SWITCH_PLUGIN_DIR . 'includes/class-custom-switch.php';
require_once CUSTOM_SWITCH_PLUGIN_DIR . 'includes/admin/class-custom-switch-admin.php';
/**
* Initialiser les classes
*
* @return void
*/
function custom_switch_init() {
new Custom_Switch();
}
add_action('plugins_loaded', 'custom_switch_init');
// Initialiser la partie admin
function custom_switch_admin_init() {
if (is_admin() && current_user_can('manage_options')) {
new Custom_Switch_Admin();
}
}
add_action('admin_init', 'custom_switch_admin_init');
/**
* Activer le plugin
*
* @return void
*/
function custom_switch_activate() {
// Code à exécuter lors de l'activation
}
register_activation_hook(__FILE__, 'custom_switch_activate');
/**
* Désactiver le plugin
*
* @return void
*/
function custom_switch_deactivate() {
// Code à exécuter lors de la désactivation
}
register_deactivation_hook(__FILE__, 'custom_switch_deactivate');