PluginProbe
Customize Admin / 1.9.7
Customize Admin v1.9.7
trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.6 1.6.6 1.7 1.7.4 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.4 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 All 29 releases
customize-admin / customize-admin.php

customize-admin.php in Customize Admin 1.9.7, at customize-admin.php

193 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Customize Admin
4 Plugin URI: https://vanderwijk.com/wordpress/wordpress-customize-admin-plugin/
5 Description: This plugin allows you to customize the appearance and branding of the WordPress admin interface.
6 Version: 1.9.7
7 Author: Johan van der Wijk
8 Author URI: https://vanderwijk.com
9 Text Domain: customize-admin
10 Domain Path: /languages
11 License: GPL2 or later
12
13 Release notes: WP 6.9 compatibility tested.
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 2 of the License, or
18 (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30 if ( ! defined( 'ABSPATH' ) ) die ( 'Error!' );
31
32 // Load the required files needed for the plugin to run in the proper order and add needed functions to the required hooks.
33 function ca_plugin_init () {
34 load_plugin_textdomain ( 'customize-admin', false, 'customize-admin/languages' );
35 }
36 add_action ( 'plugins_loaded', 'ca_plugin_init' );
37
38 function ca_enqueue_scripts () {
39 if ( 'settings_page_customize-admin/customize-admin-options' !== get_current_screen ()->id ) {
40 return;
41 }
42
43 wp_register_script ( 'ca-color-picker', WP_PLUGIN_URL . '/customize-admin/js/color-picker.js', array ( 'jquery' ), '1.9.4', true );
44 wp_enqueue_script ( 'ca-color-picker' );
45 wp_enqueue_script ( 'wp-color-picker' );
46
47 wp_enqueue_media ();
48 wp_register_script ( 'ca-media-upload', WP_PLUGIN_URL . '/customize-admin/js/media-upload.js', array ( 'jquery' ), '1.9.4', true );
49 wp_enqueue_script ( 'ca-media-upload' );
50
51 // Enqueue code editor and settings for manipulating CSS
52 $settings = wp_enqueue_code_editor ( array ( 'type' => 'text/css' ) );
53
54 // Return if the editor was not enqueued.
55 if ( false === $settings ) {
56 return;
57 }
58
59 wp_add_inline_script (
60 'code-editor',
61 sprintf(
62 'jQuery( function () { wp.codeEditor.initialize ( "ca_custom_css", %s ); } );',
63 wp_json_encode ( $settings )
64 )
65 );
66 }
67 add_action ( 'admin_enqueue_scripts', 'ca_enqueue_scripts' );
68
69 function ca_enqueue_styles () {
70 if ( 'settings_page_customize-admin/customize-admin-options' !== get_current_screen ()->id ) {
71 return;
72 }
73
74 wp_enqueue_style ( 'wp-color-picker' );
75 }
76 add_action ( 'admin_print_styles', 'ca_enqueue_styles' );
77
78 // URL for the logo on the login screen
79 function ca_logo_url($url) {
80 if ( get_option ( 'ca_logo_url' ) != '' ) {
81 return esc_url( get_option ( 'ca_logo_url' ) );
82 } else {
83 return esc_url( get_bloginfo( 'url' ) );
84 }
85 }
86
87 // CSS for custom logo on the login screen
88 function ca_logo_file () {
89 if ( get_option ( 'ca_logo_file' ) != '' ) {
90 echo '<style>.login h1 a { background-image: url("' . esc_url ( get_option ( 'ca_logo_file' ) ) . '")!important; background-size: contain; width: 320px; }</style>';
91 } else {
92 echo '<style>.login h1 a { background-image: url("' . esc_url ( plugins_url ( 'vanderwijk.png' , __FILE__ ) ) . '")!important; background-size: contain; width: 320px; }</style>';
93 }
94 }
95
96 // CSS for custom background color
97 function ca_login_background_color () {
98 if ( get_option ( 'ca_login_background_color' ) != '' ) {
99 echo '<style>body { background-color: ' . esc_html ( get_option ( 'ca_login_background_color' ) ) . '!important; } </style>';
100 }
101 }
102
103 // CSS for custom CSS
104 function ca_custom_css () {
105 if ( get_option ( 'ca_custom_css' ) != '' ) {
106 echo '<style>' . esc_html ( wp_strip_all_tags ( get_option ( 'ca_custom_css' ) ) ) . '</style>';
107 }
108 }
109
110 // Remove the generator meta tag
111 function ca_remove_meta_generator () {
112 if ( get_option ( 'ca_remove_meta_generator' ) != '' ) {
113 remove_action ( 'wp_head', 'wp_generator' );
114 }
115 }
116
117 // Remove the RSD meta tag
118 function ca_remove_meta_rsd () {
119 if ( get_option ( 'ca_remove_meta_rsd' ) != '' ) {
120 remove_action ( 'wp_head', 'rsd_link' );
121 }
122 }
123
124 // Remove the WLW meta tag
125 function ca_remove_meta_wlw () {
126 if ( get_option ( 'ca_remove_meta_wlw' ) != '' ) {
127 remove_action ( 'wp_head', 'wlwmanifest_link' );
128 }
129 }
130
131 // Remove the RSS feed links
132 function ca_remove_rss_links () {
133 if ( get_option ( 'ca_remove_rss_links' ) != '' ) {
134 remove_action ( 'wp_head', 'feed_links', 2 ); //removes feeds
135 remove_action ( 'wp_head', 'feed_links_extra', 3 ); //removes comment feed links
136 }
137 }
138
139 add_action (
140 'wp_dashboard_setup',
141 function () {
142 global $wp_meta_boxes;
143
144 // Remove WordPress Site Health Status widget from dashboard
145 if ( get_option ( 'ca_remove_dashboard_site_health_status' ) != '' ) {
146 unset ( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_site_health'] );
147 }
148
149 // Remove At a Glance widget from dashboard
150 if ( get_option ( 'ca_remove_dashboard_at_a_glance' ) != '' ) {
151 unset ( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now'] );
152 }
153
154 // Remove Activity widget from dashboard
155 if ( get_option ( 'ca_remove_dashboard_activity' ) != '' ) {
156 unset ( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity'] );
157 }
158
159 // Remove Plugins widget from dashboard
160 if ( get_option ( 'ca_remove_dashboard_plugins' ) != '' ) {
161 unset ( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'] );
162 }
163
164 // Remove Quick Draft widget from dashboard
165 if ( get_option ( 'ca_remove_dashboard_quick_press' ) != '' ) {
166 unset ( $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'] );
167 }
168
169 // Remove WordPress Site News widget from dashboard
170 if ( get_option ( 'ca_remove_dashboard_wordpress_news' ) != '' ) {
171 unset ( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] );
172 }
173
174 // Remove WordPress Other News widget from dashboard
175 if ( get_option ( 'ca_remove_dashboard_wordpress_other' ) != '' ) {
176 unset ( $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'] );
177 }
178
179 }
180 );
181
182 add_filter ( 'login_headerurl', 'ca_logo_url' );
183 add_action ( 'login_head', 'ca_logo_file' );
184 add_action ( 'login_head', 'ca_login_background_color' );
185 add_action ( 'login_head', 'ca_custom_css' );
186
187 add_action ( 'init', 'ca_remove_meta_generator' );
188 add_action ( 'init', 'ca_remove_meta_rsd' );
189 add_action ( 'init', 'ca_remove_meta_wlw' );
190 add_action ( 'init', 'ca_remove_rss_links' );
191
192 require_once ( 'customize-admin-options.php' );
193