Created
November 10, 2010 23:52
-
-
Save franz-josef-kaiser/671743 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
?> |
@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
My PHP throws parsing error on line 24, needed to add
function
keyword before__construct
. Might think of changing it to:public function __construct()