Add Logo to Admin - Version 1.3

Version Description

Download this release

Release Info

Developer tinkerpriest
Plugin Icon wp plugin Add Logo to Admin
Version 1.3
Comparing to
See all releases

Code changes from version 1.2 to 1.3

Files changed (9) hide show
  1. add-logo.php +92 -43
  2. css/login.css +12 -2
  3. css/wp-admin.css +1 -1
  4. images/logo.png +0 -0
  5. js/admin.js +1 -2
  6. js/login.js +1 -1
  7. readme.txt +18 -15
  8. screenshot-1.jpg +0 -0
  9. screenshot-2.jpg +0 -0
add-logo.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Add Logo to Admin
4
Plugin URI: http://bavotasan.com/tidbits/add-your-logo-to-the-wordpress-admin-and-login-page/
5
Description: Adds a custom logo to your site's Admin header and your login page.
6
Author: c.bavota
7
- Version: 1.2
8
Author URI: http://bavotasan.com
9
*/
10
@@ -14,14 +14,69 @@ add_action('admin_menu', 'add_logo_init');
14
15
//add page to admin
16
function add_logo_init() {
17
- add_options_page('Add Logo to Admin', 'Add Logo to Admin', 10, __FILE__, 'my_plugin_options');
18
}
19
20
//set default options
21
function set_add_logo_options() {
22
add_option('add_logo_on_login','yes','Do you want the logo to appear on the login page?');
23
add_option('add_logo_on_admin','yes','Do you want the logo to appear on the admin pages?');
24
- add_option('add_logo_logo','/wp-content/plugins/add-logo-to-admin/images/logo.png','Logo location');
25
}
26
27
//delete options upon plugin deactivation
@@ -29,6 +84,7 @@ function unset_add_logo_options() {
29
delete_option('add_logo_on_login');
30
delete_option('add_logo_on_admin');
31
delete_option('add_logo_logo');
32
}
33
34
register_activation_hook(__FILE__,'set_add_logo_options');
@@ -44,7 +100,6 @@ if(get_option('add_logo_on_admin') == "yes") {
44
wp_enqueue_script('add_logo_admin_script', get_option('siteurl') . '/wp-content/plugins/add-logo-to-admin/js/admin.js');
45
wp_localize_script( 'add_logo_admin_script', 'newLogo', array(
46
'logo' => get_option('add_logo_logo'),
47
- 'site' => get_option('siteurl')
48
));
49
}
50
}
@@ -54,7 +109,7 @@ if(get_option('add_logo_on_login') == "yes") {
54
add_action('login_head', 'wp_admin_login_css');
55
function wp_admin_login_css() {
56
echo '<link rel="stylesheet" type="text/css" href="' . get_option('siteurl') . '/wp-content/plugins/add-logo-to-admin/css/login.css" />'."\n";
57
- echo '<script type="text/javascript">' . "\n" . '/* <![CDATA[ */' . "\n" . ' newLogo = {' . "\n" . ' logo: "' . get_option('add_logo_logo') . '",' . "\n" . ' site: "' . get_option('siteurl') . '"' . "\n" .' }' . "\n" . '/* ]]> */' . "\n" . '</script>' . "\n";
58
echo '<script type="text/javascript" src="' . get_option('siteurl') . '/wp-content/plugins/add-logo-to-admin/js/login.js"></script>'."\n";
59
}
60
}
@@ -64,10 +119,10 @@ function my_plugin_options() {
64
?>
65
<div class="wrap">
66
<h2>Add Logo to Admin</h2>
67
<?php
68
- if($_REQUEST['submit']) {
69
- update_add_logo_options();
70
- }
71
print_add_logo_form();
72
?>
73
</div>
@@ -76,32 +131,7 @@ function my_plugin_options() {
76
77
//updating the options
78
function update_add_logo_options() {
79
- $ok = false;
80
-
81
- if($_REQUEST['add_logo_on_login']) {
82
- update_option('add_logo_on_login',$_REQUEST['add_logo_on_login']);
83
- $ok = true;
84
- }
85
-
86
- if($_REQUEST['add_logo_on_admin']) {
87
- update_option('add_logo_on_admin',$_REQUEST['add_logo_on_admin']);
88
- $ok = true;
89
- }
90
-
91
- if($_REQUEST['add_logo_logo']) {
92
- update_option('add_logo_logo',$_REQUEST['add_logo_logo']);
93
- $ok = true;
94
- }
95
-
96
- if($ok) {
97
- echo'<div id="message" class="updated fade">';
98
- echo '<p>Options saved.</p>';
99
- echo '</div>';
100
- } else {
101
- echo'<div id="message" class="error fade">';
102
- echo '<p>Failed to save options.</p>';
103
- echo '</div>';
104
- }
105
}
106
107
//the actual admin page
@@ -113,15 +143,15 @@ function print_add_logo_form() {
113
if ($default_admin == "yes") { $admin_yes = "checked"; } else { $admin_no = "checked"; }
114
?>
115
<!-- Add Logo to Admin box begin-->
116
- <form method="post">
117
<table class="form-table">
118
<tr valign="top">
119
<th scope="row" style="width: 370px;">
120
<label for="add_logo_on_login">Would you like your logo to appear on the login page?</label>
121
</th>
122
<td>
123
- <input type="radio" name="add_logo_on_login" value="yes" <?=$login_yes?> />Yes
124
- <input type="radio" name="add_logo_on_login" value="no" <?=$login_no?> />No
125
</td>
126
</tr>
127
<tr valign="top">
@@ -129,24 +159,43 @@ function print_add_logo_form() {
129
<label for="add_logo_on_admin">Would you like your logo to appear on the admin pages?</label>
130
</th>
131
<td>
132
- <input type="radio" name="add_logo_on_admin" value="yes" <?=$admin_yes?> />Yes
133
- <input type="radio" name="add_logo_on_admin" value="no" <?=$admin_no?> />No
134
</td>
135
</tr>
136
<tr valign="top">
137
<th scope="row" style="width: 370px;">
138
- <label for="add_logo_logo">Where is your logo located? </label>
139
</th>
140
<td>
141
- <?php bloginfo('url'); ?><input type="text" name="add_logo_logo" size="60" value="<?=$the_logo?>" /><br />
142
- </td>
143
</tr>
144
</table>
145
<p class="submit">
146
<input type="submit" name="submit" class="button-primary" value="Save Changes" />
147
</p>
148
</form>
149
- <p><em>NOTE: You need to refresh this page or just navigate to another page if you switch the Admin option from "No" to "Yes" and want to see the option take affect.</em></p>
150
<!-- Add Logo to Admin admin box end-->
151
<?php
152
}
4
Plugin URI: http://bavotasan.com/tidbits/add-your-logo-to-the-wordpress-admin-and-login-page/
5
Description: Adds a custom logo to your site's Admin header and your login page.
6
Author: c.bavota
7
+ Version: 1.3
8
Author URI: http://bavotasan.com
9
*/
10
14
15
//add page to admin
16
function add_logo_init() {
17
+ if(stristr($_SERVER['REQUEST_URI'],'&delete-logo')) {
18
+ $directory = dirname(__FILE__) . "/images/";
19
+ unlink($directory . $_REQUEST['delete-logo']);
20
+ if($_REQUEST['delete-logo'] == get_option('add_logo_filename')) {
21
+ update_option('add_logo_filename', "");
22
+ update_option('add_logo_logo', "");
23
+ }
24
+
25
+ $location = str_replace("&delete-logo=". $_REQUEST['delete-logo'], "", $_SERVER['REQUEST_URI']."&deleted=true");
26
+ header("Location: $location");
27
+ die;
28
+ }
29
+ if($_REQUEST['submit']) {
30
+
31
+ if ($_FILES["file"]["type"]){
32
+ $directory = dirname(__FILE__) . "/images/";
33
+ move_uploaded_file($_FILES["file"]["tmp_name"],
34
+ $directory . $_FILES["file"]["name"]);
35
+ update_option('add_logo_logo', get_option('siteurl'). "/wp-content/plugins/add-logo-to-admin/images/". $_FILES["file"]["name"]);
36
+ update_option('add_logo_filename', $_FILES["file"]["name"]);
37
+ }
38
+
39
+ if($_REQUEST['add_logo_on_login']) {
40
+ update_option('add_logo_on_login',$_REQUEST['add_logo_on_login']);
41
+ }
42
+
43
+ if($_REQUEST['add_logo_on_admin']) {
44
+ update_option('add_logo_on_admin',$_REQUEST['add_logo_on_admin']);
45
+ }
46
+
47
+ if($_REQUEST['add_logo_filename']) {
48
+ update_option('add_logo_filename',$_REQUEST['add_logo_filename']);
49
+ update_option('add_logo_logo', get_option('siteurl'). "/wp-content/plugins/add-logo-to-admin/images/". $_REQUEST['add_logo_filename']);
50
+ }
51
+
52
+ if(stristr($_SERVER['REQUEST_URI'],'&saved=true')) {
53
+ $location = $_SERVER['REQUEST_URI'];
54
+ } else {
55
+ $location = str_replace("&deleted=true", "", $_SERVER['REQUEST_URI']."&saved=true");
56
+ }
57
+ header("Location: $location");
58
+ die;
59
+ }
60
+
61
+
62
+ add_options_page('Add Logo to Admin', 'Add Logo to Admin', 10, __FILE__, 'my_plugin_options');
63
+ }
64
+
65
+ function addConfigureLink( $links ) {
66
+ $settings_link = '<a href="options-general.php?page=add-logo-to-admin/add-logo.php">Settings</a>';
67
+ array_unshift( $links, $settings_link );
68
+ return $links;
69
}
70
+
71
+ $plugin = plugin_basename(__FILE__);
72
+ add_filter("plugin_action_links_$plugin", 'addConfigureLink' );
73
74
//set default options
75
function set_add_logo_options() {
76
add_option('add_logo_on_login','yes','Do you want the logo to appear on the login page?');
77
add_option('add_logo_on_admin','yes','Do you want the logo to appear on the admin pages?');
78
+ add_option('add_logo_logo',get_option("siteurl").'/wp-content/plugins/add-logo-to-admin/images/logo.png','Logo location');
79
+ add_option('add_logo_filename', 'logo.png','Logo filename');
80
}
81
82
//delete options upon plugin deactivation
84
delete_option('add_logo_on_login');
85
delete_option('add_logo_on_admin');
86
delete_option('add_logo_logo');
87
+ delete_option('add_logo_filename');
88
}
89
90
register_activation_hook(__FILE__,'set_add_logo_options');
100
wp_enqueue_script('add_logo_admin_script', get_option('siteurl') . '/wp-content/plugins/add-logo-to-admin/js/admin.js');
101
wp_localize_script( 'add_logo_admin_script', 'newLogo', array(
102
'logo' => get_option('add_logo_logo'),
103
));
104
}
105
}
109
add_action('login_head', 'wp_admin_login_css');
110
function wp_admin_login_css() {
111
echo '<link rel="stylesheet" type="text/css" href="' . get_option('siteurl') . '/wp-content/plugins/add-logo-to-admin/css/login.css" />'."\n";
112
+ echo '<script type="text/javascript">' . "\n" . '/* <![CDATA[ */' . "\n" . ' newLogo = {' . "\n" . ' logo: "' . get_option('add_logo_logo') . '",' . "\n" . ' }' . "\n" . '/* ]]> */' . "\n" . '</script>' . "\n";
113
echo '<script type="text/javascript" src="' . get_option('siteurl') . '/wp-content/plugins/add-logo-to-admin/js/login.js"></script>'."\n";
114
}
115
}
119
?>
120
<div class="wrap">
121
<h2>Add Logo to Admin</h2>
122
+
123
<?php
124
+ if ( $_REQUEST['saved'] ) { echo '<div id="message" class="updated fade"><p><strong>Add Logo to Admin settings saved.</strong></p></div>'; }
125
+ if ( $_REQUEST['deleted'] ) { echo '<div id="message" class="updated fade"><p><strong>Logo deleted.</strong></p></div>'; }
126
print_add_logo_form();
127
?>
128
</div>
131
132
//updating the options
133
function update_add_logo_options() {
134
+
135
}
136
137
//the actual admin page
143
if ($default_admin == "yes") { $admin_yes = "checked"; } else { $admin_no = "checked"; }
144
?>
145
<!-- Add Logo to Admin box begin-->
146
+ <form method="post" id="myForm" enctype="multipart/form-data">
147
<table class="form-table">
148
<tr valign="top">
149
<th scope="row" style="width: 370px;">
150
<label for="add_logo_on_login">Would you like your logo to appear on the login page?</label>
151
</th>
152
<td>
153
+ <input type="radio" name="add_logo_on_login" value="yes" <?=$login_yes?> />&nbsp;Yes&nbsp;&nbsp;
154
+ <input type="radio" name="add_logo_on_login" value="no" <?=$login_no?> />&nbsp;No
155
</td>
156
</tr>
157
<tr valign="top">
159
<label for="add_logo_on_admin">Would you like your logo to appear on the admin pages?</label>
160
</th>
161
<td>
162
+ <input type="radio" name="add_logo_on_admin" value="yes" <?=$admin_yes?> />&nbsp;Yes&nbsp;&nbsp;
163
+ <input type="radio" name="add_logo_on_admin" value="no" <?=$admin_no?> />&nbsp;No
164
</td>
165
</tr>
166
<tr valign="top">
167
<th scope="row" style="width: 370px;">
168
+ <label for="add_logo_logo">Choose a file to upload: </label>
169
</th>
170
<td>
171
+ <input type="file" name="file" id="file" />&nbsp;<em><small>Click Save Changes below to upload your logo.</small></em>
172
+ <?php
173
+ update_option('add_logo_logo', get_option('siteurl'). "/wp-content/plugins/add-logo-to-admin/images/". get_option('add_logo_filename'));
174
+ $path = dirname(__FILE__) . "/images/";
175
+ $directory = get_option('siteurl'). "/wp-content/plugins/add-logo-to-admin/images/";
176
+ // Open the folder
177
+ $dir_handle = @opendir($path) or die("Unable to open $path");
178
+ // Loop through the files
179
+ $count = 1;
180
+ while ($file = readdir($dir_handle)) {
181
+
182
+ if($file == "." || $file == ".." || $file == "index.php" ) {
183
+ continue;
184
+ }
185
+ if($count==1) { echo "<br /><br />Select which logo you would like to use.<br />"; $count++; }
186
+ if($file == get_option('add_logo_filename')) { $checked = "checked"; } else { $checked = ""; }
187
+ echo "<br /><table><tr><td style=\"padding-right: 5px;\"><img src=\"$directory$file\" style=\"max-height:100px;border:1px solid #aaa;padding:10px;\" /></td><td><input id=\"add_logo_filename\" name=\"add_logo_filename\" type=\"radio\" value=\"$file\" $checked />&nbsp;Select<br /><br /><a href=\"options-general.php?page=add-logo-to-admin/add-logo.php&delete-logo=$file\">&laquo; Delete</a></td></tr></table>";
188
+ }
189
+
190
+ // Close
191
+ closedir($dir_handle);
192
+ ?> </td>
193
</tr>
194
</table>
195
<p class="submit">
196
<input type="submit" name="submit" class="button-primary" value="Save Changes" />
197
</p>
198
</form>
199
<!-- Add Logo to Admin admin box end-->
200
<?php
201
}
css/login.css CHANGED
@@ -1,7 +1,17 @@
1
#newLogo {
2
- padding: 0 0 20px;
3
}
4
5
#login h1 {
6
display: none;
7
- }
1
#newLogo {
2
+ padding: 0 0 10px 7px;
3
+ max-width: 314px;
4
+ margin: 0;
5
}
6
7
#login h1 {
8
display: none;
9
+ }
10
+
11
+ #login {
12
+ text-align: center;
13
+ }
14
+
15
+ #login p {
16
+ text-align: left;
17
+ }
css/wp-admin.css CHANGED
@@ -3,7 +3,7 @@
3
}
4
5
#newLogo {
6
- padding: 0 0 10px;
7
}
8
9
#wphead {
3
}
4
5
#newLogo {
6
+ padding: 0 0 5px;
7
}
8
9
#wphead {
images/logo.png CHANGED
Binary file
js/admin.js CHANGED
@@ -16,13 +16,12 @@ function addLogo() {
16
myBody.innerHTML = "";
17
18
var img = document.createElement("img");
19
- var imgSrc = newLogo.site+newLogo.logo;
20
img.setAttribute("src",imgSrc);
21
img.setAttribute("id", "newLogo");
22
23
myBody.appendChild(img);
24
25
myBody.style.display = "block";
26
-
27
return false;
28
}
16
myBody.innerHTML = "";
17
18
var img = document.createElement("img");
19
+ var imgSrc = newLogo.logo;
20
img.setAttribute("src",imgSrc);
21
img.setAttribute("id", "newLogo");
22
23
myBody.appendChild(img);
24
25
myBody.style.display = "block";
26
return false;
27
}
js/login.js CHANGED
@@ -16,7 +16,7 @@ function addLogo() {
16
myBody.innerHTML = "";
17
18
var img = document.createElement("img");
19
- var imgSrc = newLogo.site+newLogo.logo;
20
img.setAttribute("src",imgSrc);
21
img.setAttribute("id", "newLogo");
22
16
myBody.innerHTML = "";
17
18
var img = document.createElement("img");
19
+ var imgSrc = newLogo.logo;
20
img.setAttribute("src",imgSrc);
21
img.setAttribute("id", "newLogo");
22
readme.txt CHANGED
@@ -4,30 +4,30 @@ Donate Link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
Tags: custom logo, admin, login
5
Requires at least: 2.7
6
Tested up to: 2.7.1
7
- Stable tag: 1.2
8
9
- Add a custom logo to your admin header and to your login page.
10
11
== Description ==
12
13
- This plugin allows a user to customize their admin panel by adding their own logo to the header. It also replaces the WordPress logo on the login screen with the same custom logo.
14
15
== Installation ==
16
17
1. Unzip the add-logo-to-admin.zip file.
18
2. Upload the `add-logo-to-admin` folder to the `/wp-content/plugins/` directory.
19
3. Activate the plugin through the 'Plugins' menu in WordPress.
20
- 4. Go to Settings => Add Logo to Admin and set your options and add the location of your logo.
21
22
== Frequently Asked Questions ==
23
24
1) How do I add my own logo?
25
26
- You have two options. You can create your own logo and name it logo.png, then add it to the add-logo-to-admin/images folder. Or you can go to Settings => Add Logo to Admin and add the location of you logo in the appropriate box.
27
28
2) How big does my logo need to be?
29
30
- You can make it any width or height.
31
32
== Screenshots ==
33
@@ -36,6 +36,15 @@ You can make it any width or height.
36
37
== Change Log ==
38
39
1.2 (2009-02-23)
40
<ul>
41
<li>Fixed issue with WP installs in subdirectories</li>
@@ -52,16 +61,10 @@ You can make it any width or height.
52
</ul>
53
54
1.0.2 (2008-12-16)
55
- <ul>
56
- <li>Fixed weirdness with extra folder</li>
57
- </ul>
58
59
1.0.1 (2008-12-16)
60
- <ul>
61
- <li>Fixed the code to direct to the proper plugin folder</li>
62
- </ul>
63
64
1.0 (2008-12-15)
65
- <ul>
66
- <li>Initial Public Release</li>
67
- </ul>
4
Tags: custom logo, admin, login
5
Requires at least: 2.7
6
Tested up to: 2.7.1
7
+ Stable tag: 1.3
8
9
+ Add a custom logo to your Admin header and to your login page.
10
11
== Description ==
12
13
+ This plugin allows a user to customize their Admin panel by adding their own logo to the header. It also replaces the WordPress logo on the login screen with the same custom logo.
14
15
== Installation ==
16
17
1. Unzip the add-logo-to-admin.zip file.
18
2. Upload the `add-logo-to-admin` folder to the `/wp-content/plugins/` directory.
19
3. Activate the plugin through the 'Plugins' menu in WordPress.
20
+ 4. Go to Settings => Add Logo to Admin and set your options and add your logo.
21
22
== Frequently Asked Questions ==
23
24
1) How do I add my own logo?
25
26
+ Just go to Settings => Add Logo to Admin and upload the logo you would like to use.
27
28
2) How big does my logo need to be?
29
30
+ You can make it any width or height, as well as any file format.
31
32
== Screenshots ==
33
36
37
== Change Log ==
38
39
+ 1.3 (2009-02-25)
40
+ <ul>
41
+ <li>Created uploader for logos</li>
42
+ <li>Added "Settings" link on plugins page</li>
43
+ <li>Added option to delete logo</li>
44
+ <li>Added logo select option</li>
45
+ <li>Updated CSS</li>
46
+ </ul>
47
+
48
1.2 (2009-02-23)
49
<ul>
50
<li>Fixed issue with WP installs in subdirectories</li>
61
</ul>
62
63
1.0.2 (2008-12-16)
64
+ Fixed weirdness with extra folder
65
66
1.0.1 (2008-12-16)
67
+ Fixed the code to direct to the proper plugin folder
68
69
1.0 (2008-12-15)
70
+ Initial Public Release
screenshot-1.jpg CHANGED
Binary file
screenshot-2.jpg CHANGED
Binary file