Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roose/2667269 to your computer and use it in GitHub Desktop.
Save roose/2667269 to your computer and use it in GitHub Desktop.
A WordPress plugin to build an environment to develop a single stylesheet for the login/reg/pass screen in WP 3.1
<?php
/**
* Plugin Name: Future Core Login
* Plugin URI: http://unserkaiser.com
* Description: Replacing the current stylesheets loaded on wp-login.php until this ticket goes into core: <a href="http://core.trac.wordpress.org/ticket/12506">#12506</a>
* Version: 0.1
* Author: Franz Josef Kaiser
* Author URI: http://unserkaiser.com
* License: GPL2
*
* This plugin is meant as testing environment for the development of a new stylesheet for the
* WordPress login/password/register screen. Goal is to remove the admin-colors stylesheet
* so in the future there would only be one stylesheet.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
if ( !class_exists('FutureCoreLogin') ) {
class FutureCoreLogin {
public function __construct() {
if ( $this->is_login() ) {
add_action( 'init', array(&$this, 'deregister') );
add_action( 'login_head', array( &$this, 'echo_css') );
# @todo: manipulate (filter?) wp_admin_css to not load login.css and colors-xy.css from /core_root/wp-admin/css/ dir
}
}
/**
* Custom "Conditional Tag" to check if we are on the login screen
* props adapted as a plugin function - altered from Ingo Henze & currently in use in my framework
* @return boolean $is_login
* @link http://schnurpsel.de/suche/is_login/
*/
public function is_login() {
$url_parts = parse_url( $_SERVER['REQUEST_URI'] );
$path_parts = pathinfo( $url_parts['path'] );
$dir_parts = explode( '/', $path_parts['dirname'] );
$dirname = end( $dir_parts );
$filename = $path_parts['basename'];
if ( 'wp-login.php' == $filename ) {
$is_login = true;
}
else {
$is_login = false;
}
return $is_login;
}
// Deregister the current stylesheets for a clean environment
public function deregister() {
wp_deregister_style( 'login' );
wp_deregister_style( 'colors-fresh' );
}
// return the file path
public function locate_file( $filename = 'login.css' ) {
$plugin_dir = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
if ( !file_exists( $plugin_dir.'/'.$filename) ) {
return get_bloginfo('stylesheet_directory').'/'.$filename;
}
else {
return $plugin_dir.'/'.$filename;
}
}
// Calling the new stylesheet
public function echo_css() {
$file = $this->locate_file();
echo '<link rel="stylesheet" href="'.$file.'" type="text/css" />';
}
// Won't work on login_head action hook
public function enqueue_css() {
$file = $this->locate_file();
wp_enqueue_style( 'future-core-login', $file, false, '0.0', 'screen' );
}
} // END Class FutureCoreLogin
// INIT
new FutureCoreLogin();
} // endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment