- plugin
- code
plugin
Download hier de gratis plugin om een WordPress pagina in de onderhoudsmodus te plaatsen.
code
01 | <?php |
02 | /* |
03 | Plugin Name: Onderhoud |
04 | Description: Schakelt de onderhoudsmodus in en uit. |
05 | Author: Pascal ter Heege |
06 | Version: 1.0 |
07 | */ |
08 |
09 | // Menu optie |
10 | function add_maintenance_menu() { |
11 | add_menu_page( 'Onderhoud' , 'Onderhoud' , 'manage_options' , 'maintenance_settings' , 'maintenance_settings_page' ); |
12 | } |
13 | add_action( 'admin_menu' , 'add_maintenance_menu' ); |
14 |
15 | // Pagina van menu |
16 | function maintenance_settings_page() { |
17 | if (!current_user_can( 'manage_options' )) { |
18 | wp_die( 'Je hebt geen toegang tot deze pagina.' ); |
19 | } |
20 |
21 | if (isset( $_POST [ 'maintenance_mode_toggle' ])) { |
22 | update_option( 'maintenance_mode_active' , $_POST [ 'maintenance_mode_active' ]); |
23 | } |
24 |
25 | $maintenance_mode_active = get_option( 'maintenance_mode_active' , 'off' ); |
26 | ?> |
27 | <div class = "wrap" > |
28 | <h2>Onderhoudsmodus instellingen</h2> |
29 | <form method= "post" action= "" > |
30 | <label for = "maintenance_mode_active" > |
31 | <input type= "checkbox" name= "maintenance_mode_active" id= "maintenance_mode_active" value= "on" <?php checked( 'on' , $maintenance_mode_active ); ?>> |
32 | Schakel onderhoudsmodus in |
33 | </label> |
34 | <p><em>Note: Onderhoudsmodus is momenteel <?php echo $maintenance_mode_active === 'on' ? 'ingeschakeld' : 'uitgeschakeld' ; ?></em></p> |
35 | <p class = "submit" > |
36 | <input type= "submit" name= "maintenance_mode_toggle" class = "button-primary" value= "Opslaan" > |
37 | </p> |
38 | </form> |
39 | </div> |
40 | <?php |
41 | } |
42 |
43 | // In en uitschakelen |
44 | function wp_maintenance_mode() { |
45 | if (get_option( 'maintenance_mode_active' ) === 'on' && !current_user_can( 'edit_themes' ) && !is_user_logged_in()) { |
46 | wp_die( 'Kom later terug' ); |
47 | } |
48 | } |
49 | add_action( 'wp' , 'wp_maintenance_mode' ); |
50 |
51 | ?> |