Uber Login Logo - Version 0.5

Version Description

Download this release

Release Info

Developer uberweb
Plugin Icon wp plugin Uber Login Logo
Version 0.5
Comparing to
See all releases

Code changes from version 0.4 to 0.5

Files changed (3) hide show
  1. readme.txt +18 -9
  2. uber-login-logo-min.js +5 -3
  3. uber-login-logo.php +36 -35
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Uber Login Logo ===
2
  Contributors: uberweb
3
  Tags: login, logo, login logo, admin, customisation, customization, custom login, media uploader, AJAX, wp-login
4
- Requires at least: 3.0
5
- Tested up to: 3.4
6
- Stable tag: 0.4
7
 
8
  A simple, lightweight WordPress plugin to change your login logo.
9
 
@@ -25,6 +25,10 @@ Download and activate from the Plugins page of your WordPress site.
25
 
26
  I'd like to keep this plugin simple, but if you think you have a good idea leave a comment on the [plugin page](http://www.uberweb.com.au/uber-login-logo-wordpress-plugin/) and I'll at least consider it.
27
 
 
 
 
 
28
  == Screenshots ==
29
 
30
  1. How awesome your login screen could look after using this plugin.
@@ -33,18 +37,23 @@ I'd like to keep this plugin simple, but if you think you have a good idea leave
33
 
34
  == Changelog ==
35
 
36
- = Version 0.1 =
37
 
38
- * The first release.
39
 
40
- = Version 0.2 =
41
 
42
- * Compatible up to 3.3.1 (and probably beyond).
43
 
44
  = Version 0.3 =
45
 
46
  * Updated the link to the home URL for Jamie.
47
 
48
- = Version 0.4 =
 
 
 
 
 
 
49
 
50
- * Updated CSS for better compatibility with WordPress 3.4.
1
  === Uber Login Logo ===
2
  Contributors: uberweb
3
  Tags: login, logo, login logo, admin, customisation, customization, custom login, media uploader, AJAX, wp-login
4
+ Requires at least: 3.5
5
+ Tested up to: 3.5
6
+ Stable tag: 0.5
7
 
8
  A simple, lightweight WordPress plugin to change your login logo.
9
 
25
 
26
  I'd like to keep this plugin simple, but if you think you have a good idea leave a comment on the [plugin page](http://www.uberweb.com.au/uber-login-logo-wordpress-plugin/) and I'll at least consider it.
27
 
28
+ = This plugin does not work on my WordPress installation =
29
+
30
+ As of 0.5 This plugin makes use of the new media editor introduced in WordPress 3.5. If you are having issues try installing version 0.4, or better yet, updating your WordPress.
31
+
32
  == Screenshots ==
33
 
34
  1. How awesome your login screen could look after using this plugin.
37
 
38
  == Changelog ==
39
 
40
+ = Version 0.5 =
41
 
42
+ * javascript entirely rewritten to make use of the new media editor in WP 3.5.
43
 
44
+ = Version 0.4 =
45
 
46
+ * Updated CSS for better compatibility with WordPress 3.4.
47
 
48
  = Version 0.3 =
49
 
50
  * Updated the link to the home URL for Jamie.
51
 
52
+ = Version 0.2 =
53
+
54
+ * Compatible up to 3.3.1 (and probably beyond).
55
+
56
+ = Version 0.1 =
57
+
58
+ * The first release.
59
 
 
uber-login-logo-min.js CHANGED
@@ -1,3 +1,5 @@
1
- jQuery(document).ready(function(){function b(a,b){nonce=jQuery("#uber_login_logo_nonce").val();jQuery.post(ajaxurl,{action:"getImageData",id:a,src:b,uber_login_logo_nonce:nonce},function(a){jQuery(".uber-login-logo .img-holder .img-preview").html('<img src="'+a+'" />');jQuery(".uber-login-logo .img-holder").show();jQuery(".uber-login-logo .update-status").show()})}(function(){nonce=jQuery("#uber_login_logo_nonce").val();jQuery.post(ajaxurl,{action:"displayPreviewImg",uber_login_logo_nonce:nonce},
2
- function(a){a&&(jQuery("#upload_image").val(a),jQuery(".uber-login-logo .img-holder .img-preview").html('<img src="'+a+'" />'),jQuery(".uber-login-logo .img-holder").show())})})();jQuery("#upload_image_button, #upload_image").click(function(){tb_show("","media-upload.php?type=image&amp;TB_iframe=true");return!1});window.send_to_editor=function(a){word_old=!1;(imgurl=jQuery("img",a).attr("src"))||(word_old=!0);word_old?(imgurl=jQuery(a).attr("src"),imgclass=jQuery(a).attr("class")):imgclass=jQuery("img",
3
- a).attr("class");imgid=parseInt(imgclass.replace(/\D/g,""),10);imgid=parseInt(imgclass.replace(/\D/g,""),10);jQuery("#upload_image").val(imgurl);tb_remove();b(imgid,imgurl)}});
 
 
1
+ var Uber=Uber||{};
2
+ (function(d){Uber.LoginLogo={config:{version:"0.5",nonce:null,editor:null,selectedId:0},elems:{$container:".uber-login-logo",$uploadTrigger:".upload-image",$uploadInput:"#upload-input",$nonceInput:"#uber_login_logo_nonce",$updateStatus:".update-status",$imgHolder:".img-holder",$imgPreview:".img-preview"},init:function(){Uber.Tools.setElems(this.elems,this);if(Uber.Tools.doesElemExist(this.elems.$container)){_.bindAll(this);this.setNonce();this.setEditor();this.getOptions();this.catchInsert();var a=
3
+ this;this.elems.$uploadTrigger.on("click",function(){a.config.editor.open();return!1});this.config.editor.on("open",this.preSelectImage)}},setEditor:function(){this.config.editor=wp.media.editor.add("content")},setNonce:function(){this.config.nonce=this.elems.$nonceInput.val()},getOptions:function(){var a=this;d.ajax({url:ajaxurl,type:"post",dataType:"json",data:{action:"displayPreviewImg",uber_login_logo_nonce:this.config.nonce}}).done(function(b){a.showImagePreview(b)})},updateOptions:function(a,
4
+ b){var c=this;d.ajax({url:ajaxurl,type:"post",dataType:"json",data:{action:"getImageData",id:a,src:b,uber_login_logo_nonce:this.config.nonce}}).done(function(a){c.showImagePreview(a);c.elems.$updateStatus.show()})},showImagePreview:function(a){this.elems.$uploadInput.val(a.src);this.elems.$imgPreview.html('<img src="'+a.src+'" />');this.elems.$imgHolder.show();this.config.selectedId=a.id},preSelectImage:function(){var a=this.config.editor.state().get("selection"),b=wp.media.attachment(this.config.selectedId);
5
+ b.fetch();a.add(b?[b]:[])},catchInsert:function(){var a=this;wp.media.editor.send.attachment=function(b,c){a.updateOptions(c.id,c.url)}}};Uber.Tools={setElems:function(a,b,c){b.elems=b.elems||{};for(var e in a)b.elems[e]=c?c.find(a[e]):d(a[e])},doesElemExist:function(a){return"undefined"!==typeof a&&a.length}};d(function(){Uber.LoginLogo.init()})})(jQuery,window,document);
uber-login-logo.php CHANGED
@@ -6,7 +6,7 @@
6
  * @link http://www.uberweb.com.au/uber-login-logo-wordpress-plugin/
7
  *
8
  * @author Alex Rogers
9
- * @version 0.4
10
  * @package Uber_Login_Logo
11
  */
12
 
@@ -14,7 +14,7 @@
14
  Plugin Name: Uber Login Logo
15
  Plugin URI: http://www.uberweb.com.au/uber-login-logo-wordpress-plugin/
16
  Description: Change login logo.
17
- Version: 0.4
18
  Author: UberWeb
19
  Author URI: http://www.uberweb.com.au/
20
  License: GPLv2 or later
@@ -43,7 +43,7 @@ if(defined('ABSPATH') && defined('WPINC')) {
43
 
44
  /**
45
  * Main class for Uber Login Logo, does it all.
46
- *
47
  * @package Uber_Login_Logo
48
  * @todo Uninstall plugin hook
49
  * @todo I18n Support
@@ -54,16 +54,16 @@ class UberLoginLogo
54
  /**
55
  * @const VERSION The current plugin version
56
  */
57
- const VERSION = '0.4';
58
-
59
  /**
60
  * @const UBERURL Link to uberweb site
61
  */
62
  const UBERURL = 'http://www.uberweb.com.au';
63
-
64
  /**
65
  * Fire up the plugin and register them hooks
66
- */
67
  public static function init()
68
  {
69
  add_action('admin_menu', array('UberLoginLogo', 'registerAdminMenu'));
@@ -73,7 +73,7 @@ class UberLoginLogo
73
  add_action('login_head', array('UberLoginLogo', 'replaceLoginLogo'));
74
  add_filter('login_headerurl', array('UberLoginLogo', 'replaceLoginUrl'));
75
  add_filter("login_headertitle", array('UberLoginLogo', 'replaceLoginTitle'));
76
-
77
  //Load only on plugin admin page
78
  if (isset($_GET['page']) && $_GET['page'] == self::getBaseName()) {
79
  add_action('admin_print_scripts', array('UberLoginLogo', 'myAdminScripts'));
@@ -85,12 +85,11 @@ class UberLoginLogo
85
  */
86
  public static function myAdminScripts()
87
  {
88
- wp_enqueue_script('media-upload');
89
- wp_enqueue_script('thickbox');
90
  wp_register_script('uber-login-logo', self::getPluginDir() . '/uber-login-logo-min.js', array('jquery','media-upload','thickbox'), self::VERSION);
91
  wp_enqueue_script('uber-login-logo');
92
  }
93
-
94
  /**
95
  * Load styles for plugin admin mpage
96
  */
@@ -100,7 +99,7 @@ class UberLoginLogo
100
  wp_register_style('uber-login-logo', self::getPluginDir() . '/uber-login-logo-min.css', array(), self::VERSION);
101
  wp_enqueue_style('uber-login-logo');
102
  }
103
-
104
  /**
105
  * Setup admin menu and add options page
106
  */
@@ -112,14 +111,14 @@ class UberLoginLogo
112
  $capability = 'manage_options';
113
  $menu_slug = self::getBaseName();
114
  $function = array('UberLoginLogo','showOptionsPage');
115
-
116
  add_options_page($page_title, $menu_title, $capability, $menu_slug, $function);
117
  }
118
  }
119
-
120
  /**
121
  * Add settings link to plugin page
122
- *
123
  * @param array $links Array of plugin option links
124
  * @param string $file Handle to plugin filename
125
  * @return array Modified list of plugin option links
@@ -127,7 +126,7 @@ class UberLoginLogo
127
  public static function registerPluginSettingsLink($links, $file)
128
  {
129
  $this_plugin = self::getBaseName();
130
-
131
  if ($file == $this_plugin) {
132
  $settings_link = '<a href="' . admin_url() . 'options-general.php?page=' . $this_plugin . '">Settings</a>';
133
  array_unshift($links, $settings_link);
@@ -135,7 +134,7 @@ class UberLoginLogo
135
 
136
  return $links;
137
  }
138
-
139
  /**
140
  * Generate the HTML to display the plugin settings page
141
  */
@@ -146,13 +145,13 @@ class UberLoginLogo
146
  <div class="wrap uber-login-logo">
147
  <?php screen_icon('edit-pages'); ?>
148
  <h2>Uber Login Logo</h2>
149
-
150
  <div class="updated fade update-status">
151
  <p><strong>Settings Saved</strong></p>
152
  </div>
153
-
154
  <p>by <strong>Alex Rogers</strong> from <strong><a href="http://www.uberweb.com.au" title="uberweb web design and development">uberweb.com.au</a></strong></p>
155
-
156
  <h3>How it Works</h3>
157
  <ol>
158
  <li>Use the WordPress media uploader to upload an image, or select one from the media library.</li>
@@ -161,8 +160,8 @@ class UberLoginLogo
161
  <li>Finished!</li>
162
  </ol>
163
  <form class="inputfields">
164
- <input id="upload_image" type="text" size="36" name="upload_image" value="" />
165
- <input id="upload_image_button" type="button" value="Upload Image" />
166
  <?php wp_nonce_field('uber_login_logo_action','uber_login_logo_nonce'); ?>
167
  </form>
168
  <div class="img-holder">
@@ -173,7 +172,7 @@ class UberLoginLogo
173
 
174
  <?php
175
  }
176
-
177
  /**
178
  * Replace the login logo on wp-admin
179
  */
@@ -188,7 +187,7 @@ class UberLoginLogo
188
  echo $style;
189
  }
190
  }
191
-
192
  /**
193
  * Retrieve the img data via AJAX and save as wordpress option
194
  */
@@ -207,12 +206,13 @@ class UberLoginLogo
207
 
208
  update_option(uber_login_logo, $img_data);
209
 
210
- $returnval = $img_data['src'];
 
211
  die($returnval);
212
  }
213
  }
214
  }
215
-
216
  /**
217
  * Display the currently set login logo img
218
  */
@@ -222,7 +222,8 @@ class UberLoginLogo
222
  if (current_user_can('manage_options')) {
223
  $img_data = get_option('uber_login_logo');
224
  if ($img_data) {
225
- $returnval = $img_data['src'];
 
226
  }
227
  else {
228
  $returnval = false;
@@ -231,40 +232,40 @@ class UberLoginLogo
231
  }
232
  }
233
  }
234
-
235
  /**
236
  * Retrieve the Home URL
237
- *
238
  * @return string Home URL
239
  */
240
  public static function replaceLoginUrl()
241
  {
242
  return home_url();
243
  }
244
-
245
  /**
246
  * Retrieve the Site Description
247
- *
248
  * @return string Site Description
249
  */
250
  public static function replaceLoginTitle()
251
  {
252
  return get_bloginfo('description');
253
  }
254
-
255
  /**
256
  * Retrieve the unique plugin basename
257
- *
258
  * @return string Plugin basename
259
  */
260
  public static function getBaseName()
261
  {
262
  return plugin_basename(__FILE__);
263
  }
264
-
265
  /**
266
  * Retrieve the URL to the plugin basename
267
- *
268
  * @return string Plugin basename URL
269
  */
270
  public static function getPluginDir()
6
  * @link http://www.uberweb.com.au/uber-login-logo-wordpress-plugin/
7
  *
8
  * @author Alex Rogers
9
+ * @version 0.5
10
  * @package Uber_Login_Logo
11
  */
12
 
14
  Plugin Name: Uber Login Logo
15
  Plugin URI: http://www.uberweb.com.au/uber-login-logo-wordpress-plugin/
16
  Description: Change login logo.
17
+ Version: 0.5
18
  Author: UberWeb
19
  Author URI: http://www.uberweb.com.au/
20
  License: GPLv2 or later
43
 
44
  /**
45
  * Main class for Uber Login Logo, does it all.
46
+ *
47
  * @package Uber_Login_Logo
48
  * @todo Uninstall plugin hook
49
  * @todo I18n Support
54
  /**
55
  * @const VERSION The current plugin version
56
  */
57
+ const VERSION = '0.5';
58
+
59
  /**
60
  * @const UBERURL Link to uberweb site
61
  */
62
  const UBERURL = 'http://www.uberweb.com.au';
63
+
64
  /**
65
  * Fire up the plugin and register them hooks
66
+ */
67
  public static function init()
68
  {
69
  add_action('admin_menu', array('UberLoginLogo', 'registerAdminMenu'));
73
  add_action('login_head', array('UberLoginLogo', 'replaceLoginLogo'));
74
  add_filter('login_headerurl', array('UberLoginLogo', 'replaceLoginUrl'));
75
  add_filter("login_headertitle", array('UberLoginLogo', 'replaceLoginTitle'));
76
+
77
  //Load only on plugin admin page
78
  if (isset($_GET['page']) && $_GET['page'] == self::getBaseName()) {
79
  add_action('admin_print_scripts', array('UberLoginLogo', 'myAdminScripts'));
85
  */
86
  public static function myAdminScripts()
87
  {
88
+ wp_enqueue_media();
 
89
  wp_register_script('uber-login-logo', self::getPluginDir() . '/uber-login-logo-min.js', array('jquery','media-upload','thickbox'), self::VERSION);
90
  wp_enqueue_script('uber-login-logo');
91
  }
92
+
93
  /**
94
  * Load styles for plugin admin mpage
95
  */
99
  wp_register_style('uber-login-logo', self::getPluginDir() . '/uber-login-logo-min.css', array(), self::VERSION);
100
  wp_enqueue_style('uber-login-logo');
101
  }
102
+
103
  /**
104
  * Setup admin menu and add options page
105
  */
111
  $capability = 'manage_options';
112
  $menu_slug = self::getBaseName();
113
  $function = array('UberLoginLogo','showOptionsPage');
114
+
115
  add_options_page($page_title, $menu_title, $capability, $menu_slug, $function);
116
  }
117
  }
118
+
119
  /**
120
  * Add settings link to plugin page
121
+ *
122
  * @param array $links Array of plugin option links
123
  * @param string $file Handle to plugin filename
124
  * @return array Modified list of plugin option links
126
  public static function registerPluginSettingsLink($links, $file)
127
  {
128
  $this_plugin = self::getBaseName();
129
+
130
  if ($file == $this_plugin) {
131
  $settings_link = '<a href="' . admin_url() . 'options-general.php?page=' . $this_plugin . '">Settings</a>';
132
  array_unshift($links, $settings_link);
134
 
135
  return $links;
136
  }
137
+
138
  /**
139
  * Generate the HTML to display the plugin settings page
140
  */
145
  <div class="wrap uber-login-logo">
146
  <?php screen_icon('edit-pages'); ?>
147
  <h2>Uber Login Logo</h2>
148
+
149
  <div class="updated fade update-status">
150
  <p><strong>Settings Saved</strong></p>
151
  </div>
152
+
153
  <p>by <strong>Alex Rogers</strong> from <strong><a href="http://www.uberweb.com.au" title="uberweb web design and development">uberweb.com.au</a></strong></p>
154
+
155
  <h3>How it Works</h3>
156
  <ol>
157
  <li>Use the WordPress media uploader to upload an image, or select one from the media library.</li>
160
  <li>Finished!</li>
161
  </ol>
162
  <form class="inputfields">
163
+ <input id="upload-input" type="text" size="36" name="upload image" class="upload-image" value="" />
164
+ <input id="upload-button" type="button" value="Upload Image" class="upload-image" />
165
  <?php wp_nonce_field('uber_login_logo_action','uber_login_logo_nonce'); ?>
166
  </form>
167
  <div class="img-holder">
172
 
173
  <?php
174
  }
175
+
176
  /**
177
  * Replace the login logo on wp-admin
178
  */
187
  echo $style;
188
  }
189
  }
190
+
191
  /**
192
  * Retrieve the img data via AJAX and save as wordpress option
193
  */
206
 
207
  update_option(uber_login_logo, $img_data);
208
 
209
+ //$returnval = $img_data['src'];
210
+ $returnval = json_encode(array('src' => $img_data['src'], 'id' => $img_data['id']));
211
  die($returnval);
212
  }
213
  }
214
  }
215
+
216
  /**
217
  * Display the currently set login logo img
218
  */
222
  if (current_user_can('manage_options')) {
223
  $img_data = get_option('uber_login_logo');
224
  if ($img_data) {
225
+ //$returnval = $img_data['src'];
226
+ $returnval = json_encode(array('src' => $img_data['src'], 'id' => $img_data['id']));
227
  }
228
  else {
229
  $returnval = false;
232
  }
233
  }
234
  }
235
+
236
  /**
237
  * Retrieve the Home URL
238
+ *
239
  * @return string Home URL
240
  */
241
  public static function replaceLoginUrl()
242
  {
243
  return home_url();
244
  }
245
+
246
  /**
247
  * Retrieve the Site Description
248
+ *
249
  * @return string Site Description
250
  */
251
  public static function replaceLoginTitle()
252
  {
253
  return get_bloginfo('description');
254
  }
255
+
256
  /**
257
  * Retrieve the unique plugin basename
258
+ *
259
  * @return string Plugin basename
260
  */
261
  public static function getBaseName()
262
  {
263
  return plugin_basename(__FILE__);
264
  }
265
+
266
  /**
267
  * Retrieve the URL to the plugin basename
268
+ *
269
  * @return string Plugin basename URL
270
  */
271
  public static function getPluginDir()