Login Logo - Version 0.3

Version Description

  • The login logo now links to your site, instead of WordPress.org
  • If you don't have a custom login logo, the plugin does nothing.
  • You can provide login-logo-network-{NETWORK ID}.png to have a different logo per multisite network.
Download this release

Release Info

Developer markjaquith
Plugin Icon wp plugin Login Logo
Version 0.3
Comparing to
See all releases

Code changes from version 0.2 to 0.3

Files changed (2) hide show
  1. login-logo.php +48 -14
  2. readme.txt +12 -3
login-logo.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Login Logo
4
  Description: Drop a PNG file named <code>login-logo.png</code> into your <code>wp-content</code> directory. This simple plugin takes care of the rest, with zero configuration. Transparent backgrounds work best. Keep the width below 326 pixels.
5
- Version: 0.2
6
  License: GPL
7
  Author: Mark Jaquith
8
  Author URI: http://coveredwebservices.com/
@@ -11,8 +11,8 @@ Author URI: http://coveredwebservices.com/
11
  class CWS_Login_Logo_Plugin {
12
  static $instance;
13
  const cutoff = 326;
14
- var $logo_path;
15
- var $logo_url;
16
  var $width = 0;
17
  var $height = 0;
18
  var $original_height;
@@ -21,25 +21,51 @@ class CWS_Login_Logo_Plugin {
21
 
22
  public function __construct() {
23
  self::$instance = $this;
24
- $this->add_hooks();
25
- }
26
-
27
- private function add_hooks() {
28
- add_action( 'init', array( $this, 'init' ) );
29
  add_action( 'login_head', array( $this, 'login_head' ) );
30
  }
31
 
32
  public function init() {
33
- $this->logo_path = WP_CONTENT_DIR . '/login-logo.png';
34
- $this->logo_url = WP_CONTENT_URL . '/login-logo.png';
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
 
37
  private function logo_file_exists() {
38
- if ( ! isset( $this->logo_file_exists ) )
39
- $this->logo_file_exists = !! file_exists( $this->logo_path );
 
 
 
 
 
 
 
 
 
40
  return !! $this->logo_file_exists;
41
  }
42
 
 
 
 
 
 
 
 
 
 
 
43
  private function get_width() {
44
  $this->get_logo_size();
45
  return absint( $this->width );
@@ -59,7 +85,7 @@ class CWS_Login_Logo_Plugin {
59
  if ( !$this->logo_file_exists() )
60
  return false;
61
  if ( !$this->logo_size ) {
62
- if ( $sizes = getimagesize( $this->logo_path ) ) {
63
  $this->logo_size = $sizes;
64
  $this->width = $sizes[0];
65
  $this->height = $sizes[1];
@@ -83,12 +109,20 @@ class CWS_Login_Logo_Plugin {
83
  }
84
  }
85
 
 
 
 
 
86
  public function login_head() {
 
 
 
 
87
  ?>
88
  <!-- Login Logo plugin for WordPress: http://txfx.net/wordpress-plugins/login-logo/ -->
89
  <style type="text/css">
90
  h1 a {
91
- background: url(<?php echo esc_url_raw( $this->logo_url ); ?>) no-repeat top center;
92
  width: <?php echo self::cutoff; ?>px;
93
  height: <?php echo $this->get_height() + 3; ?>px;
94
  <?php if ( self::cutoff < $this->get_width() ) $this->css3( 'background-size', 'contain' ); ?>
2
  /*
3
  Plugin Name: Login Logo
4
  Description: Drop a PNG file named <code>login-logo.png</code> into your <code>wp-content</code> directory. This simple plugin takes care of the rest, with zero configuration. Transparent backgrounds work best. Keep the width below 326 pixels.
5
+ Version: 0.3
6
  License: GPL
7
  Author: Mark Jaquith
8
  Author URI: http://coveredwebservices.com/
11
  class CWS_Login_Logo_Plugin {
12
  static $instance;
13
  const cutoff = 326;
14
+ var $logo_locations;
15
+ var $logo_location;
16
  var $width = 0;
17
  var $height = 0;
18
  var $original_height;
21
 
22
  public function __construct() {
23
  self::$instance = $this;
 
 
 
 
 
24
  add_action( 'login_head', array( $this, 'login_head' ) );
25
  }
26
 
27
  public function init() {
28
+ $this->logo_locations = array();
29
+ if ( is_multisite() && function_exists( 'get_current_site' ) ) {
30
+ $site = get_current_site(); // Site = Network? Ugh.
31
+ if ( $site && isset( $site->id ) ) {
32
+ $this->logo_locations['network'] = array(
33
+ 'path' => WP_CONTENT_DIR . '/login-logo-network-' . $site->id . '.png',
34
+ 'url' => WP_CONTENT_URL . '/login-logo-network-' . $site->id . '.png'
35
+ );
36
+ }
37
+ }
38
+ $this->logo_locations['global'] = array(
39
+ 'path' => WP_CONTENT_DIR . '/login-logo.png',
40
+ 'url' => WP_CONTENT_URL . '/login-logo.png'
41
+ );
42
  }
43
 
44
  private function logo_file_exists() {
45
+ if ( ! isset( $this->logo_file_exists ) ) {
46
+ foreach ( $this->logo_locations as $location ) {
47
+ if ( file_exists( $location['path'] ) ) {
48
+ $this->logo_file_exists = true;
49
+ $this->logo_location = $location;
50
+ break;
51
+ } else {
52
+ $this->logo_file_exists = false;
53
+ }
54
+ }
55
+ }
56
  return !! $this->logo_file_exists;
57
  }
58
 
59
+ private function get_location( $what = '' ) {
60
+ if ( $this->logo_file_exists() ) {
61
+ if ( 'path' == $what || 'url' == $what )
62
+ return $this->logo_location[$what];
63
+ else
64
+ return $this->logo_location;
65
+ }
66
+ return false;
67
+ }
68
+
69
  private function get_width() {
70
  $this->get_logo_size();
71
  return absint( $this->width );
85
  if ( !$this->logo_file_exists() )
86
  return false;
87
  if ( !$this->logo_size ) {
88
+ if ( $sizes = getimagesize( $this->get_location( 'path' ) ) ) {
89
  $this->logo_size = $sizes;
90
  $this->width = $sizes[0];
91
  $this->height = $sizes[1];
109
  }
110
  }
111
 
112
+ public function login_headerurl() {
113
+ return trailingslashit( get_bloginfo( 'url' ) );
114
+ }
115
+
116
  public function login_head() {
117
+ $this->init();
118
+ if ( !$this->logo_file_exists() )
119
+ return;
120
+ add_filter( 'login_headerurl', array( $this, 'login_headerurl' ) );
121
  ?>
122
  <!-- Login Logo plugin for WordPress: http://txfx.net/wordpress-plugins/login-logo/ -->
123
  <style type="text/css">
124
  h1 a {
125
+ background: url(<?php echo esc_url_raw( $this->get_location( 'url' ) ); ?>) no-repeat top center;
126
  width: <?php echo self::cutoff; ?>px;
127
  height: <?php echo $this->get_height() + 3; ?>px;
128
  <?php if ( self::cutoff < $this->get_width() ) $this->css3( 'background-size', 'contain' ); ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://txfx.net/wordpress-plugins/donate
4
  Tags: customize, login, login screen, logo, custom logo
5
  Requires at least: 3.0
6
  Tested up to: 3.1
7
- Stable tag: trunk
8
 
9
  Customize the logo on the WP login screen by simply dropping a file named login-logo.png into your WP content directory. CSS is automatic!
10
 
@@ -24,7 +24,9 @@ This plugin also works in the `mu-plugins` directory.
24
 
25
  3. Upload the PNG image to your WordPress content directory (`/wp-content/`, by default), and name the file `login-logo.png`.
26
 
27
- 4. Done! The login screen will now use your logo.
 
 
28
 
29
  == Screenshots ==
30
 
@@ -40,6 +42,10 @@ Your image is probably too wide. Wide images are scaled down in IE 9 or other mo
40
 
41
 
42
  == Changelog ==
 
 
 
 
43
 
44
  = 0.2 =
45
  * Do not use `background-size` unless the image is more than 326 pixels
@@ -48,5 +54,8 @@ Your image is probably too wide. Wide images are scaled down in IE 9 or other mo
48
  * Original version
49
 
50
  == Upgrade Notice ==
 
 
51
 
52
- Upgrade now to avoid stretching small images
 
4
  Tags: customize, login, login screen, logo, custom logo
5
  Requires at least: 3.0
6
  Tested up to: 3.1
7
+ Stable tag: 0.3
8
 
9
  Customize the logo on the WP login screen by simply dropping a file named login-logo.png into your WP content directory. CSS is automatic!
10
 
24
 
25
  3. Upload the PNG image to your WordPress content directory (`/wp-content/`, by default), and name the file `login-logo.png`.
26
 
27
+ 4. If you have a multisite install with more than one network, you can also use `login-logo-network-{NETWORK ID}.png` to assign a different login logo to each network.
28
+
29
+ 5. Done! The login screen will now use your logo.
30
 
31
  == Screenshots ==
32
 
42
 
43
 
44
  == Changelog ==
45
+ = 0.3 =
46
+ * The login logo now links to your site, instead of WordPress.org
47
+ * If you don't have a custom login logo, the plugin does nothing.
48
+ * You can provide `login-logo-network-{NETWORK ID}.png` to have a different logo per multisite network.
49
 
50
  = 0.2 =
51
  * Do not use `background-size` unless the image is more than 326 pixels
54
  * Original version
55
 
56
  == Upgrade Notice ==
57
+ = 0.3 =
58
+ Makes the logo link to your site instead of WordPress.org! Support for per-network logos.
59
 
60
+ = 0.2 =
61
+ Upgrade now to avoid stretching small images.