Easily define additional CSS (inline and/or by URL) to be added to all administration pages.
Ever want to tweak the appearance of the WordPress admin pages by hiding stuff, moving stuff around, changing fonts, colors, sizes, etc? Any modification you may want to do with CSS can easily be done via this plugin.
Using this plugin you’ll easily be able to define additional CSS (inline and/or files by URL) to be added to all administration pages. You can define CSS to appear inline in the admin head (within style tags), or reference CSS files to be linked (via “link rel=’stylesheet'” tags). The referenced CSS files will appear in the admin head first, listed in the order defined in the plugin’s settings. Then any inline CSS are added to the admin head. Both values can be filtered for advanced customization (see Advanced section).
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
The plugin exposes two filters for hooking. Typically, code making use of filters should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain). Bear in mind that the features controlled by these filters are also configurable via the plugin’s settings page. These filters are likely only of interest to advanced users able to code.
c2c_add_admin_css (filter)
The ‘c2c_add_admin_css’ filter allows customization of CSS that should be added directly to the admin page head.
Arguments:
Example:
/** * Add CSS to admin pages. * * @param string $css String to be added to admin pages. * @return string */ function my_admin_css( $css ) { $css .= " #site-heading a span { color:blue !important; } #favorite-actions { display:none; } "; return $css; } add_filter( 'c2c_add_admin_css', 'my_admin_css' );
c2c_add_admin_css_files (filter)
The ‘c2c_add_admin_css_files’ filter allows programmatic modification of the list of CSS files to enqueue in the admin.
Arguments:
Example:
/** * Add CSS file(s) to admin pages. * * @param array $files CSS files to be added to admin pages. * @return array */ function my_admin_css_files( $files ) { $files[] = 'http://yui.yahooapis.com/2.9.0/build/reset/reset-min.css'; return $files; } add_filter( 'c2c_add_admin_css_files', 'my_admin_css_files' );
add-admin-css.zip
inside the plugins directory for your site (typically wp-content/plugins/
)Yes, via the “Admin CSS Files” input field on the plugin’s settings page.
No, not presently. At least not directly. By default, the CSS is added for every admin page on the site.
However, you can preface your selectors with admin page specific class(es) on the ‘body’ tag to ensure CSS only applies on certain admin pages. (e.g. body.index-php h2, #icon-index { display: none; }
).
Or, you can hook the ‘c2c_add_admin_css’ and ‘c2c_add_admin_css_files’ filters and determine the current admin page context to decide whether the respective hook argument should be returned (and thus output) or not.
No, not presently. At least not directly. By default, the CSS is added for any user that can enter the admin section of the site.
You can hook the ‘c2c_add_admin_css’ and ‘c2c_add_admin_css_files’ filters and determine the current user to decide whether the respective hook argument should be returned (and thus output) for the user or not.
It is certainly possible that you can put yourself in an unfortunate position by supplying CSS that could hide critical parts of admin pages, making it seeminly impossible to fix or revert your changes. Fortunately, there are a number of approaches you can take to correct the problem.
The recommended approach is to visit the URL for the plugin’s settings page, but appended with a special query parameter to disable the output of its CSS. The plugin’s settings page would typically be at a URL like https://example.com/wp-admin/themes.php?page=add-admin-css%2Fadd-admin-css.php
. Append &c2c-no-css=1
to that, so that the URL is https://example.com/wp-admin/themes.php?page=add-admin-css%2Fadd-admin-css.php&c2c-no-css=1
(obviously change example.com with the domain name for your site).
There are other approaches you can use, though they require direct database or server filesystem access:
wp-config.php
file, define a constant to disable output of the plugin-defined CSS: define( 'C2C_ADD_ADMIN_CSS_DISABLED', true );
. You can then visit the site’s admin. Just remember to remove that line after you’ve fixed the CSS (or at least change “true” to “false”). This is an alternative to the query parameter approach described above, though it persists while the constant remains defined. There will be an admin notice on the plugin’s setting page to alert you to the fact that the constant is defined and effectively disabling the plugin from adding any CSS.c2c_add_admin_css
and delete that row. The settings you saved for the plugin will be deleted and it will be like you’ve installed the plugin for the first time.wp option delete c2c_add_admin_css
The initial reaction by some might be to remove the plugin from the server’s filesystem. This will certainly disable the plugin and prevent the CSS you configured through it from taking effect, restoring the access and functionality to the backend. However, reinstalling the plugin will put you back into the original predicament because the plugin will use the previously-configured settings, which wouldn’t have changed.
The plugin’s syntax highlighting of CSS (available as of WP 4.9) honors the built-in setting for whether syntax highlighting should be enabled or not.
To disable syntax highlighting, go to your profile page. Next to “Syntax Highlighting”, click the checkbox labeled “Disable syntax highlighting when editing code”. Note that this checkbox disables syntax highlighting throughout the admin interface and not just specifically for the plugin’s settings page.
Yes.
Highlights:
This recommended bugfix release addresses a potential conflict with other plugins that prevented the plugin settings page main content from being displayed.
Details:
'admin_enqueue_scripts'
action instead of during 'init'
is_plugin_admin_page()
in help_tabs()
instead of reproducing its functionalityis_plugin_admin_page()
is used before 'admin_init'
action is firedHighlights:
This recommended minor release updates the plugin framework, restructures unit test files, notes compatibility through 5.7+, and incorporates numerous minor behind-the-scenes tweaks.
Details:
is_plugin_admin_page()
to use get_current_screen()
when availablestyle
tagc2c_{PluginName}_Plugin_051
to c2c_Plugin_060
get_c2c_string()
as a getter for translated stringsget_c2c_string()
whitelist_options()
to allowed_options()
add_allowed_options()
instead of deprecated add_option_whitelist()
for WP 5.5+allowed_options
filter instead of deprecated whitelist_options
for WP 5.5+is_wp_version_cmp()
and get_c2c_string()
)is_wp_version_cmp()
as a utility to compare current WP version against a given WP versioncontextual_help()
to be easier to read, and correct function docblocksnumber_format_i18n()
to format integer value within input fieldreadme_url()
to refer to plugin’s readme.txt on plugins.svn.wordpress.orgis_plugin_admin_page()
instead of reinventing itadd_codemirror()
get_css_files()
tests/
top-level directorynumber_format_i18n()
to format integer value within input fieldreadme_url()
to refer to plugin’s readme.txt on plugins.svn.wordpress.orgphpunit/
to house all files related to unit testingbin/
to phpunit/bin/
tests/bootstrap.php
to phpunit/
tests/
to phpunit/tests/
phpunit.xml
to phpunit.xml.dist
per best practicesFull changelog is available in CHANGELOG.md.