Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

A WordPress plugin to build an environment to develop a single stylesheet for the login/reg/pass screen in WP 3.1

View future_core_login.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
<?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;
?>

My PHP throws parsing error on line 24, needed to add function keyword before __construct. Might think of changing it to:

public function __construct()

@attitude Thanks, fixed. But there're other things I should change also (like the locate_file() contents). Btw: forking of my Gists is highly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.