Uber Login Logo - Version 0.1

Version Description

Download this release

Release Info

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

Version 0.1

readme.txt ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2
6
+ Stable tag: 0.1
7
+
8
+ A simple, lightweight WordPress plugin to change your login logo.
9
+
10
+ == Description ==
11
+
12
+ View the plugin page for more information and discussion: [http://www.uberweb.com.au/uber-login-logo-wordpress-plugin/](http://www.uberweb.com.au/uber-login-logo-wordpress-plugin/)
13
+
14
+ Uber Login Logo is a simple plugin I made so that I could customise the login screen on my own website by utilising in-built WordPress functions and the WordPress media uploader.
15
+ Considering all the bloated plugins and resource intensive implementations floating around, I thought this lightweight codebase and clean UI could be of similar benefit to other WordPress users/developers.
16
+ Don't expect too many fancy bells and whistles, this plugin does one thing, and does it well.
17
+
18
+ == Installation ==
19
+
20
+ Download and activate from the Plugins page of your WordPress site.
21
+
22
+ == Frequently Asked Questions ==
23
+
24
+ = Will you add X feature? =
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.
31
+
32
+ 2. The oh so simple settings page.
33
+
34
+ == Changelog ==
35
+
36
+ = Version 0.1 =
37
+
38
+ * The first release.
39
+
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
uber-login-logo-min.css ADDED
@@ -0,0 +1 @@
 
1
+ .uber-login-logo .inputfields{margin-top:10px}.uber-login-logo .img-holder,.uber-login-logo .update-status{display:none}
uber-login-logo-min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(){b();jQuery("#upload_image_button, #upload_image").click(function(){tb_show("","media-upload.php?type=image&amp;TB_iframe=true");return false});window.send_to_editor=function(c){word_old=false;imgurl=jQuery("img",c).attr("src");if(!imgurl){word_old=true}if(word_old){imgurl=jQuery(c).attr("src");imgclass=jQuery(c).attr("class")}else{imgclass=jQuery("img",c).attr("class")}imgid=parseInt(imgclass.replace(/\D/g,""),10);imgid=parseInt(imgclass.replace(/\D/g,""),10);jQuery("#upload_image").val(imgurl);tb_remove();a(imgid,imgurl)};function a(d,c){nonce=jQuery("#uber_login_logo_nonce").val();jQuery.post(ajaxurl,{action:"getImageData",id:d,src:c,uber_login_logo_nonce:nonce},function(e){jQuery(".uber-login-logo .img-holder .img-preview").html('<img src="'+e+'" />');jQuery(".uber-login-logo .img-holder").show();jQuery(".uber-login-logo .update-status").show()})}function b(){nonce=jQuery("#uber_login_logo_nonce").val();jQuery.post(ajaxurl,{action:"displayPreviewImg",uber_login_logo_nonce:nonce},function(c){if(c){jQuery("#upload_image").val(c);jQuery(".uber-login-logo .img-holder .img-preview").html('<img src="'+c+'" />');jQuery(".uber-login-logo .img-holder").show()}})}});
uber-login-logo.php ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Uber Login Logo
5
+ *
6
+ * @link http://www.uberweb.com.au/uber-login-logo-wordpress-plugin/
7
+ *
8
+ * @author Alex Rogers
9
+ * @version 0.1
10
+ * @package Uber_Login_Logo
11
+ */
12
+
13
+ /*
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.1
18
+ Author: UberWeb
19
+ Author URI: http://www.uberweb.com.au/
20
+ License: GPLv2 or later
21
+ */
22
+
23
+ /*
24
+ This program is free software; you can redistribute it and/or
25
+ modify it under the terms of the GNU General Public License
26
+ as published by the Free Software Foundation; either version 2
27
+ of the License, or (at your option) any later version.
28
+
29
+ This program is distributed in the hope that it will be useful,
30
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
31
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
+ GNU General Public License for more details.
33
+
34
+ You should have received a copy of the GNU General Public License
35
+ along with this program; if not, write to the Free Software
36
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37
+ */
38
+
39
+ //Enable the plugin for the init hook, but only if WP is loaded. Calling this php file directly will do nothing.
40
+ if(defined('ABSPATH') && defined('WPINC')) {
41
+ add_action("init",array("UberLoginLogo","init"),1000,0);
42
+ }
43
+
44
+ /**
45
+ * Main class for Uber Login Logo, does it all.
46
+ *
47
+ * @package Uber_Login_Logo
48
+ * @todo Unistall plugin hook
49
+ * @todo I18n Support
50
+ * @todo Remove login logo support
51
+ */
52
+
53
+ class UberLoginLogo
54
+ {
55
+ /**
56
+ * @const VERSION The current plugin version
57
+ */
58
+ const VERSION = '0.1';
59
+
60
+ /**
61
+ * @const UBERURL Link to uberweb site
62
+ */
63
+ const UBERURL = 'http://www.uberweb.com.au';
64
+
65
+ /**
66
+ * Fire up the plugin and register them hooks
67
+ */
68
+ public static function init()
69
+ {
70
+ add_action('admin_menu', array('UberLoginLogo', 'registerAdminMenu'));
71
+ add_filter('plugin_action_links', array('UberLoginLogo', 'registerPluginSettingsLink'),10,2);
72
+ add_action('wp_ajax_getImageData', array('UberLoginLogo', 'getImageData'));
73
+ add_action('wp_ajax_displayPreviewImg', array('UberLoginLogo', 'displayPreviewImg'));
74
+ add_action('login_head', array('UberLoginLogo', 'replaceLoginLogo'));
75
+ add_filter('login_headerurl', array('UberLoginLogo', 'replaceLoginUrl'));
76
+ add_filter("login_headertitle", array('UberLoginLogo', 'replaceLoginTitle'));
77
+
78
+ //Load only on plugin admin page
79
+ if (isset($_GET['page']) && $_GET['page'] == self::getBaseName()) {
80
+ add_action('admin_print_scripts', array('UberLoginLogo', 'myAdminScripts'));
81
+ add_action('admin_print_styles', array('UberLoginLogo', 'myAdminStyles'));
82
+ }
83
+ }
84
+ /**
85
+ * Load scripts for plugin admin page
86
+ */
87
+ public static function myAdminScripts()
88
+ {
89
+ wp_enqueue_script('media-upload');
90
+ wp_enqueue_script('thickbox');
91
+ wp_register_script('uber-login-logo', self::getPluginDir() . '/uber-login-logo-min.js', array('jquery','media-upload','thickbox'), '0.1');
92
+ wp_enqueue_script('uber-login-logo');
93
+ }
94
+
95
+ /**
96
+ * Load styles for plugin admin mpage
97
+ */
98
+ public static function myAdminStyles()
99
+ {
100
+ wp_enqueue_style('thickbox');
101
+ wp_register_style('uber-login-logo', self::getPluginDir() . '/uber-login-logo-min.css', array(), '0.1');
102
+ wp_enqueue_style('uber-login-logo');
103
+ }
104
+
105
+ /**
106
+ * Setup admin menu and add options page
107
+ */
108
+ public static function registerAdminMenu()
109
+ {
110
+ if (function_exists('add_options_page')) {
111
+ $page_title = 'Uber Login Logo Settings';
112
+ $menu_title = 'Uber Login Logo';
113
+ $capability = 'manage_options';
114
+ $menu_slug = self::getBaseName();
115
+ $function = array('UberLoginLogo','showOptionsPage');
116
+
117
+ add_options_page($page_title, $menu_title, $capability, $menu_slug, $function);
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Add settings link to plugin page
123
+ *
124
+ * @param array $links Array of plugin option links
125
+ * @param string $file Handle to plugin filename
126
+ * @return array Modified list of plugin option links
127
+ */
128
+ public static function registerPluginSettingsLink($links, $file)
129
+ {
130
+ $this_plugin = self::getBaseName();
131
+
132
+ if ($file == $this_plugin) {
133
+ $settings_link = '<a href="' . admin_url() . 'options-general.php?page=' . $this_plugin . '">Settings</a>';
134
+ array_unshift($links, $settings_link);
135
+ }
136
+
137
+ return $links;
138
+ }
139
+
140
+ /**
141
+ * Generate the HTML to display the plugin settings page
142
+ */
143
+ public static function showOptionsPage()
144
+ {
145
+ ?>
146
+
147
+ <div class="wrap uber-login-logo">
148
+ <?php screen_icon('edit-pages'); ?>
149
+ <h2>Uber Login Logo</h2>
150
+
151
+ <div class="updated fade update-status">
152
+ <p><strong>Settings Saved</strong></p>
153
+ </div>
154
+
155
+ <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>
156
+
157
+ <h3>How it Works</h3>
158
+ <ol>
159
+ <li>Use the WordPress media uploader to upload an image, or select one from the media library.</li>
160
+ <li>It is highly recommended that you select an image with a width less than 320px.</li>
161
+ <li>Select "Full Size" and click "insert into post".</li>
162
+ <li>Finished!</li>
163
+ </ol>
164
+ <form class="inputfields">
165
+ <input id="upload_image" type="text" size="36" name="upload_image" value="" />
166
+ <input id="upload_image_button" type="button" value="Upload Image" />
167
+ <?php wp_nonce_field('uber_login_logo_action','uber_login_logo_nonce'); ?>
168
+ </form>
169
+ <div class="img-holder">
170
+ <p>Here is a preview of your selected image at actual size</p>
171
+ <div class="img-preview"></div>
172
+ </div>
173
+ </div>
174
+
175
+ <?php
176
+ }
177
+
178
+ /**
179
+ * Replace the login logo on wp-admin
180
+ */
181
+ public static function replaceLoginLogo()
182
+ {
183
+ $img_data = get_option('uber_login_logo');
184
+ if ($img_data) {
185
+ $style = '<style type="text/css">';
186
+ $style .= '#login h1 a { background: url(' . $img_data['src'] . ') no-repeat center top; height: ' . $img_data['height'] . 'px;}';
187
+ $style .= '</style>';
188
+ $style .= "\r\n" . '<!-- Uber Login Logo ' . self::VERSION . ' ' . self::UBERURL . ' -->' . "\r\n";
189
+ echo $style;
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Retrieve the img data via AJAX and save as wordpress option
195
+ */
196
+ public static function getImageData()
197
+ {
198
+ if (!empty($_POST) && check_admin_referer('uber_login_logo_action','uber_login_logo_nonce')) {
199
+ if (current_user_can('manage_options')) {
200
+ $img_id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
201
+ $img_src = filter_input(INPUT_POST, 'src', FILTER_SANITIZE_URL);
202
+ $img_meta = wp_get_attachment_metadata($img_id, false);
203
+
204
+ $img_data['id'] = $img_id;
205
+ $img_data['src'] = $img_src;
206
+ $img_data['height'] = $img_meta['height'];
207
+ $img_data['width'] = $img_meta['width'];
208
+
209
+ update_option(uber_login_logo, $img_data);
210
+
211
+ $returnval = $img_data['src'];
212
+ die($returnval);
213
+ }
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Display the currently set login logo img
219
+ */
220
+ public static function displayPreviewImg()
221
+ {
222
+ if (!empty($_POST) && check_admin_referer('uber_login_logo_action','uber_login_logo_nonce')) {
223
+ if (current_user_can('manage_options')) {
224
+ $img_data = get_option('uber_login_logo');
225
+ if ($img_data) {
226
+ $returnval = $img_data['src'];
227
+ }
228
+ else {
229
+ $returnval = false;
230
+ }
231
+ die($returnval);
232
+ }
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Retrieve the Site URL
238
+ *
239
+ * @return string Site URL
240
+ */
241
+ public static function replaceLoginUrl()
242
+ {
243
+ return site_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()
272
+ {
273
+ return WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__));
274
+ }
275
+ }
276
+
277
+ ?>