Skip to content

Instantly share code, notes, and snippets.

@bearcodi
Last active August 29, 2015 13:57
Show Gist options
  • Save bearcodi/9478758 to your computer and use it in GitHub Desktop.
Save bearcodi/9478758 to your computer and use it in GitHub Desktop.
Custom CSS for WP Network Admin confirmation pages, drop it into mu-plugins or a plugins folder or adapt it to a themes functions.php. The css file is meant as an example to override the WordPress logo with a custom one.
.wp-core-ui h1#logo > a
{
border:1px solid blue;
/**
* change all the overrides here
width:;
height:;
background-image: none, url(/path/to/url.image);
background-size:;
*/
}
<?php
/*
* Plugin Name: WP Admin Network Confirmation Screen CSS
* Plugin URI: https://gist.github.com/bearcodi/9478758
* Version: 0.1.1
* Author: Mark Babic <mark@bearcodi.com>
* Description: Custom CSS for WordPress Multisite Network Admin confirmation pages
* License: GPL2+
*/
namespace Bearcodi;
/**
* Add an action to add CSS to change the WordPress logo on the confirmation screens in WP Admin
* @return [bool] Returns true if we cant get_current_screen()
*/
function confirmation_screen_css_action() {
// Make sure we can use the get_current_screen object
if( !function_exists( 'get_current_screen' ) ) {
return true;
}
// Get the current screen object
$screen = get_current_screen();
// Retreive the confirmation action, it is actually action we are targeting
$action = isset( $_REQUEST['action'] ) ? esc_attr( $_REQUEST['action'] ) : false;
// Accepted screens to insert the logo override
$accepted_screens = array( 'sites-network' );
// Accepted actions
$accepted_actions = array( 'confirm' );
if( in_array( $screen->base, $accepted_screens ) && in_array( $action, $accepted_actions ) )
{
// Uber hack in place here, esc_html is called to display the message in the page
// essentialy this is hijacking it to
add_filter( 'esc_html','\\Bearcodi\confirmation_screen_css' );
}
}
add_action( 'wpmuadminedit', '\\Bearcodi\confirmation_screen_css_action' );
/**
* Funtion to tack onto esc_html via filter hook to add our override CSS to the screen
* @param [type] $html HTML source in the filter chain
* @return [type] HTML with our hacked on CSS file
*/
function confirmation_screen_css( $html )
{
// Change the path to this override css file to whatever you want
$css_overide = '/wp-content/mu-plugins/bc-confirm-css.css';
$custom = sprintf( '<style type="text/css">@import url(%s);</style>', $css_overide );
return $html . $custom;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment