| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
if( ! class_exists( 'MywpControllerAbstractModule' ) ) { |
| 8 |
return false; |
| 9 |
} |
| 10 |
|
| 11 |
if ( ! class_exists( 'MywpControllerModuleSiteGeneral' ) ) : |
| 12 |
|
| 13 |
final class MywpControllerModuleSiteGeneral extends MywpControllerAbstractModule { |
| 14 |
|
| 15 |
static protected $network = true; |
| 16 |
|
| 17 |
static protected $id = 'site_general'; |
| 18 |
|
| 19 |
public static function mywp_controller_initial_data( $initial_data ) { |
| 20 |
|
| 21 |
$initial_data['disable_file_edit'] = ''; |
| 22 |
$initial_data['disable_user_admin'] = ''; |
| 23 |
|
| 24 |
return $initial_data; |
| 25 |
|
| 26 |
} |
| 27 |
|
| 28 |
public static function mywp_controller_default_data( $default_data ) { |
| 29 |
|
| 30 |
$default_data['disable_file_edit'] = false; |
| 31 |
$default_data['disable_user_admin'] = false; |
| 32 |
|
| 33 |
return $default_data; |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
protected static function after_init() { |
| 38 |
|
| 39 |
if( ! self::is_do_controller() ) { |
| 40 |
|
| 41 |
return false; |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
self::disable_file_edit(); |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
private static function disable_file_edit() { |
| 50 |
|
| 51 |
if( ! self::is_do_function( __FUNCTION__ ) ) { |
| 52 |
|
| 53 |
return false; |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
$setting_data = self::get_setting_data(); |
| 58 |
|
| 59 |
if( empty( $setting_data['disable_file_edit'] ) ) { |
| 60 |
|
| 61 |
return false; |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
if( ! defined( 'DISALLOW_FILE_EDIT' ) ) { |
| 66 |
|
| 67 |
define( 'DISALLOW_FILE_EDIT' , true ); |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
self::after_do_function( __FUNCTION__ ); |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
public static function mywp_wp_loaded() { |
| 76 |
|
| 77 |
if( ! self::is_do_controller() ) { |
| 78 |
|
| 79 |
return false; |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
self::disable_user_admin(); |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
public static function disable_user_admin() { |
| 88 |
|
| 89 |
if( is_network_admin() ) { |
| 90 |
|
| 91 |
return false; |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
if( ! is_admin() ) { |
| 96 |
|
| 97 |
return false; |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
if( ! self::is_do_function( __FUNCTION__ ) ) { |
| 102 |
|
| 103 |
return false; |
| 104 |
|
| 105 |
} |
| 106 |
|
| 107 |
$setting_data = self::get_setting_data(); |
| 108 |
|
| 109 |
if( empty( $setting_data['disable_user_admin'] ) ) { |
| 110 |
|
| 111 |
return false; |
| 112 |
|
| 113 |
} |
| 114 |
|
| 115 |
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
| 116 |
|
| 117 |
if( $current_url === user_admin_url() ) { |
| 118 |
|
| 119 |
wp_redirect( home_url() ); |
| 120 |
exit; |
| 121 |
|
| 122 |
} |
| 123 |
|
| 124 |
self::after_do_function( __FUNCTION__ ); |
| 125 |
|
| 126 |
} |
| 127 |
|
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
MywpControllerModuleSiteGeneral::init(); |
| 132 |
|
| 133 |
endif; |
| 134 |
|