-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings-api-enhanced.php
executable file
·130 lines (98 loc) · 3.42 KB
/
settings-api-enhanced.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
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
<?php
/*
Plugin Name: Settings API Enhanced
Plugin URI: https://github.com/wpaccessibility/settings-api-enhanced
Description: An improved WordPress Settings API with default render callbacks and a new accessible layout.
Version: 1.0.0-alpha
Author: WordPress Core Contributors
Author URI: https://make.wordpress.org/core/
License: GNU General Public License v3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
defined( 'ABSPATH' ) || exit;
/**
* Enqueues the stylesheet with the new forms.css styles.
*/
function sae_enqueue_forms_css() {
wp_enqueue_style( 'sae-forms', plugin_dir_url( __FILE__ ) . 'wp-admin/css/forms.css', array( 'forms' ) );
}
/**
* Replaces the Settings > General screen with the plugin variant.
*/
function sae_replace_options_general() {
global $title, $parent_file, $submenu_file, $timezone_format;
// Ensure submenu item is highlighted correctly.
$submenu_file = 'options-general.php';
require_once SAE_ABSPATH . 'wp-admin/options-general.php';
exit;
}
/**
* Replaces the Settings > Writing screen with the plugin variant.
*/
function sae_replace_options_writing() {
global $title, $parent_file, $submenu_file;
// Ensure submenu item is highlighted correctly.
$submenu_file = 'options-writing.php';
require_once SAE_ABSPATH . 'wp-admin/options-writing.php';
exit;
}
/**
* Replaces the Settings > Reading screen with the plugin variant.
*/
function sae_replace_options_reading() {
global $title, $parent_file, $submenu_file;
// Ensure submenu item is highlighted correctly.
$submenu_file = 'options-reading.php';
require_once SAE_ABSPATH . 'wp-admin/options-reading.php';
exit;
}
/**
* Replaces the Settings > Media screen with the plugin variant.
*/
function sae_replace_options_media() {
global $title, $parent_file, $submenu_file;
// Ensure submenu item is highlighted correctly.
$submenu_file = 'options-media.php';
require_once SAE_ABSPATH . 'wp-admin/options-media.php';
exit;
}
/**
* Replaces the Settings > Permalink screen with the plugin variant.
*/
function sae_replace_options_permalink() {
global $title, $parent_file, $submenu_file, $is_nginx, $wp_rewrite;
// Ensure submenu item is highlighted correctly.
$submenu_file = 'options-permalink.php';
require_once SAE_ABSPATH . 'wp-admin/options-permalink.php';
exit;
}
/**
* Replaces the Settings > Discussion screen with the plugin variant.
*/
function sae_replace_options_discussion() {
global $title, $parent_file, $submenu_file;
// Ensure submenu item is highlighted correctly.
$submenu_file = 'options-discussion.php';
require_once SAE_ABSPATH . 'wp-admin/options-discussion.php';
exit;
}
/**
* Loads the plugin files.
*/
function sae_load() {
define( 'SAE_ABSPATH', plugin_dir_path( __FILE__ ) );
if ( ! is_admin() ) {
return;
}
$admin_path = SAE_ABSPATH . 'wp-admin/';
require_once $admin_path . 'includes/template.php';
require_once $admin_path . 'includes/options.php';
add_action( 'admin_enqueue_scripts', 'sae_enqueue_forms_css' );
add_action( 'load-options-general.php', 'sae_replace_options_general' );
add_action( 'load-options-writing.php', 'sae_replace_options_writing' );
add_action( 'load-options-reading.php', 'sae_replace_options_reading' );
add_action( 'load-options-media.php', 'sae_replace_options_media' );
add_action( 'load-options-permalink.php', 'sae_replace_options_permalink' );
add_action( 'load-options-discussion.php', 'sae_replace_options_discussion' );
}
sae_load();