Custom Favicon - Version 1.0.0

Version Description

Download this release

Release Info

Developer hchouhan
Plugin Icon 128x128 Custom Favicon
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

custom-favicon.php ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Plugin Name: Custom Favicon
4
+ * Plugin URI: http://www.dreamsonline.net/wordpress-plugins/custom-favicon/
5
+ * Description: Helps customize WordPress for your clients by hiding non essential wp-admin components and by adding support for custom login logo and favicon for website and admin pages.
6
+ * Version: 1.0
7
+ * Author: Dreams Online Themes
8
+ * Author URI: http://www.dreamsonline.net/wordpress-themes/
9
+ * Author Email: hello@dreamsmedia.in
10
+ *
11
+ * @package WordPress
12
+ * @subpackage DOT_CFI
13
+ * @author Harish
14
+ * @since 1.0
15
+ *
16
+ * License:
17
+
18
+ Copyright 2013 "Custom Favicon WordPress Plugin" (hello@dreamsmedia.in)
19
+
20
+ This program is free software; you can redistribute it and/or modify
21
+ it under the terms of the GNU General Public License, version 2, as
22
+ published by the Free Software Foundation.
23
+
24
+ This program is distributed in the hope that it will be useful,
25
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ GNU General Public License for more details.
28
+
29
+ You should have received a copy of the GNU General Public License
30
+ along with this program; if not, write to the Free Software
31
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32
+
33
+ */
34
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
35
+ if ( ! class_exists( 'DOT_CFI' ) ) {
36
+
37
+
38
+ class DOT_CFI {
39
+
40
+ /*--------------------------------------------*
41
+ * Constructor
42
+ *--------------------------------------------*/
43
+
44
+ /**
45
+ * Initializes the plugin by setting localization, filters, and administration functions.
46
+ */
47
+ function __construct() {
48
+
49
+ // Load text domain
50
+ add_action( 'init', array( $this, 'load_localisation' ), 0 );
51
+
52
+ // Adding Plugin Menu
53
+ add_action( 'admin_menu', array( &$this, 'dot_cfi_menu' ) );
54
+
55
+ // Load our custom assets.
56
+ add_action( 'admin_enqueue_scripts', array( &$this, 'dot_cfi_assets' ) );
57
+
58
+ // Register Settings
59
+ add_action( 'admin_init', array( &$this, 'dot_cfi_settings' ) );
60
+
61
+ // Add Favicon to website frontend
62
+ add_action( 'wp_head', array( &$this, 'dot_cfi_favicon_frontend' ) );
63
+
64
+ // Add Favicon to website backend
65
+ add_action( 'admin_head', array( &$this, 'dot_cfi_favicon_backend' ) );
66
+ add_action( 'login_head', array( &$this, 'dot_cfi_favicon_backend' ) );
67
+
68
+
69
+ } // end constructor
70
+
71
+
72
+ /*--------------------------------------------*
73
+ * Localisation | Public | 1.0 | Return : void
74
+ *--------------------------------------------*/
75
+
76
+ public function load_localisation ()
77
+ {
78
+ load_plugin_textdomain( 'dot_cfi', false, basename( dirname( __FILE__ ) ) . '/languages' );
79
+
80
+ } // End load_localisation()
81
+
82
+ /**
83
+ * Defines constants for the plugin.
84
+ */
85
+ function constants() {
86
+ define( 'DOT_CFI_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
87
+ }
88
+
89
+ /*--------------------------------------------*
90
+ * Admin Menu
91
+ *--------------------------------------------*/
92
+
93
+ function dot_cfi_menu()
94
+ {
95
+ $page_title = __('Custom Favicon', 'dot_cfi');
96
+ $menu_title = __('Custom Favicon', 'dot_cfi');
97
+ $capability = 'manage_options';
98
+ $menu_slug = 'dot_cfi';
99
+ $function = array( &$this, 'dot_cfi_menu_contents');
100
+ add_options_page($page_title, $menu_title, $capability, $menu_slug, $function);
101
+
102
+ } //dot_cfi_menu
103
+
104
+ /*--------------------------------------------*
105
+ * Load Necessary JavaScript Files
106
+ *--------------------------------------------*/
107
+
108
+ function dot_cfi_assets() {
109
+ if (isset($_GET['page']) && $_GET['page'] == 'dot_cfi') {
110
+
111
+ wp_enqueue_style( 'thickbox' ); // Stylesheet used by Thickbox
112
+ wp_enqueue_script( 'thickbox' );
113
+ wp_enqueue_script( 'media-upload' );
114
+
115
+ wp_register_script('dot_cfi_admin', WP_PLUGIN_URL.'/custom-favicon/js/dot_cfi_admin.js', array( 'thickbox', 'media-upload' ));
116
+ wp_enqueue_script('dot_cfi_admin');
117
+ }
118
+ } //dot_cfi_assets
119
+
120
+ /*--------------------------------------------*
121
+ * Settings & Settings Page
122
+ *--------------------------------------------*/
123
+
124
+ public function dot_cfi_settings() {
125
+
126
+ // Settings
127
+ register_setting( 'dot_cfi_settings', 'dot_cfi_settings', array(&$this, 'settings_validate') );
128
+
129
+ // Custom Favicon
130
+ add_settings_section( 'favicon', __( 'Custom Favicon & Apple touch icon', 'dot_cfi' ), array( &$this, 'section_favicon' ), 'dot_cfi_settings' );
131
+
132
+ add_settings_field( 'favicon_frontend_url', __( 'Favicon for Website', 'dot_cfi' ), array( &$this, 'section_favicon_frontend_url' ), 'dot_cfi_settings', 'favicon' );
133
+
134
+ add_settings_field( 'favicon_backend_url', __( 'Favicon for Admin', 'dot_cfi' ), array( &$this, 'section_favicon_backend_url' ), 'dot_cfi_settings', 'favicon' );
135
+
136
+ add_settings_field( 'apple_icon_frontend_url', __( 'Apple Touch Icon for Website', 'dot_cfi' ), array( &$this, 'section_apple_icon_frontend_url' ), 'dot_cfi_settings', 'favicon' );
137
+
138
+ add_settings_field( 'apple_icon_backend_url', __( 'Apple Touch Icon for Admin', 'dot_cfi' ), array( &$this, 'section_apple_icon_backend_url' ), 'dot_cfi_settings', 'favicon' );
139
+
140
+ add_settings_field( 'apple_icon_style', __( 'Basic Apple Touch Icon', 'dot_cfi' ), array( &$this, 'section_apple_icon_style' ), 'dot_cfi_settings', 'favicon' );
141
+
142
+
143
+
144
+
145
+ } //dot_cfi_settings
146
+
147
+
148
+ /*--------------------------------------------*
149
+ * Settings & Settings Page
150
+ * dot_cfi_menu_contents
151
+ *--------------------------------------------*/
152
+
153
+ public function dot_cfi_menu_contents() {
154
+ ?>
155
+ <div class="wrap">
156
+ <!--<div id="icon-freshdesk-32" class="icon32"><br></div>-->
157
+ <div id="icon-options-general" class="icon32"><br></div>
158
+ <h2><?php _e('Custom Favicon Settings', 'dot_cfi'); ?></h2>
159
+
160
+ <form method="post" action="options.php">
161
+ <?php //wp_nonce_field('update-options'); ?>
162
+ <?php settings_fields('dot_cfi_settings'); ?>
163
+ <?php do_settings_sections('dot_cfi_settings'); ?>
164
+ <p class="submit">
165
+ <input name="Submit" type="submit" class="button-primary" value="<?php _e('Save Changes', 'dot_cfi'); ?>" />
166
+ </p>
167
+ </form>
168
+ </div>
169
+
170
+ <?php
171
+ } //dot_cfi_menu_contents
172
+
173
+ function section_favicon() {
174
+
175
+
176
+ }
177
+
178
+ function section_favicon_frontend_url() {
179
+ $options = get_option( 'dot_cfi_settings' );
180
+ ?>
181
+ <span class='upload'>
182
+ <input type='text' id='dot_cfi_settings[favicon_frontend_url]' class='regular-text text-upload' name='dot_cfi_settings[favicon_frontend_url]' value='<?php echo esc_url( $options["favicon_frontend_url"] ); ?>'/>
183
+ <input type='button' class='button button-upload' value='Upload an image'/></br>
184
+ <img style='max-width: 300px; display: block;' src='<?php echo esc_url( $options["favicon_frontend_url"] ); ?>' class='preview-upload' />
185
+ </span>
186
+ <?php
187
+ }
188
+
189
+ function section_favicon_backend_url() {
190
+ $options = get_option( 'dot_cfi_settings' );
191
+ ?>
192
+ <span class='upload'>
193
+ <input type='text' id='dot_cfi_settings[favicon_backend_url]' class='regular-text text-upload' name='dot_cfi_settings[favicon_backend_url]' value='<?php echo esc_url( $options["favicon_backend_url"] ); ?>'/>
194
+ <input type='button' class='button button-upload' value='Upload an image'/></br>
195
+ <img style='max-width: 300px; display: block;' src='<?php echo esc_url( $options["favicon_backend_url"] ); ?>' class='preview-upload' />
196
+ </span>
197
+ <?php
198
+ }
199
+
200
+ function section_apple_icon_frontend_url() {
201
+ $options = get_option( 'dot_cfi_settings' );
202
+ ?>
203
+ <span class='upload'>
204
+ <input type='text' id='dot_cfi_settings[apple_icon_frontend_url]' class='regular-text text-upload' name='dot_cfi_settings[apple_icon_frontend_url]' value='<?php echo esc_url( $options["apple_icon_frontend_url"] ); ?>'/>
205
+ <input type='button' class='button button-upload' value='Upload an image'/></br>
206
+ <img style='max-width: 300px; display: block;' src='<?php echo esc_url( $options["apple_icon_frontend_url"] ); ?>' class='preview-upload' />
207
+ </span>
208
+ <?php
209
+ }
210
+
211
+ function section_apple_icon_backend_url() {
212
+ $options = get_option( 'dot_cfi_settings' );
213
+ ?>
214
+ <span class='upload'>
215
+ <input type='text' id='dot_cfi_settings[apple_icon_backend_url]' class='regular-text text-upload' name='dot_cfi_settings[apple_icon_backend_url]' value='<?php echo esc_url( $options["apple_icon_backend_url"] ); ?>'/>
216
+ <input type='button' class='button button-upload' value='Upload an image'/></br>
217
+ <img style='max-width: 300px; display: block;' src='<?php echo esc_url( $options["apple_icon_backend_url"] ); ?>' class='preview-upload' />
218
+ </span>
219
+ <?php
220
+ }
221
+
222
+ function section_apple_icon_style() {
223
+
224
+ $options = get_option( 'dot_cfi_settings' );
225
+ if( !isset($options['apple_icon_style']) ) $options['apple_icon_style'] = '0';
226
+
227
+ echo '<input type="hidden" name="dot_cfi_settings[apple_icon_style]" value="0" />
228
+ <label><input type="checkbox" name="dot_cfi_settings[apple_icon_style]" value="1"'. (($options['apple_icon_style']) ? ' checked="checked"' : '') .' />
229
+ Disable Curved Border & reflective shine for Apple touch icon</label><br />';
230
+ }
231
+
232
+
233
+ /*--------------------------------------------*
234
+ * Settings Validation
235
+ *--------------------------------------------*/
236
+
237
+ function settings_validate($input) {
238
+
239
+ return $input;
240
+ }
241
+
242
+
243
+ // Add Favicon to website frontend
244
+ function dot_cfi_favicon_frontend() {
245
+ $options = get_option('dot_cfi_settings');
246
+
247
+ if( $options['favicon_frontend_url'] != "" ) {
248
+ echo '<link rel="shortcut icon" href="'. esc_url( $options["favicon_frontend_url"] ) .'"/>'."\n";
249
+ }
250
+
251
+ if( $options['apple_icon_frontend_url'] != "" ) {
252
+
253
+ if ( $options['apple_icon_style'] == '0') {
254
+
255
+ echo '<link rel="apple-touch-icon" href="'. esc_url( $options["apple_icon_frontend_url"] ) .'"/>'."\n";
256
+
257
+ }
258
+ else {
259
+
260
+ echo '<link rel="apple-touch-icon-precomposed" href="'. esc_url( $options["apple_icon_frontend_url"] ) .'"/>'."\n";
261
+
262
+ }
263
+ }
264
+ }
265
+
266
+ // Add Favicon to website backend
267
+ function dot_cfi_favicon_backend() {
268
+ $options = get_option('dot_cfi_settings');
269
+
270
+ if( $options['favicon_backend_url'] != "" ) {
271
+ echo '<link rel="shortcut icon" href="'. esc_url( $options["favicon_backend_url"] ) .'"/>'."\n";
272
+ }
273
+
274
+ if( $options['apple_icon_backend_url'] != "" ) {
275
+
276
+ if ( $options['apple_icon_style'] == '0') {
277
+
278
+ echo '<link rel="apple-touch-icon" href="'. esc_url( $options["apple_icon_backend_url"] ) .'"/>'."\n";
279
+
280
+ }
281
+ else {
282
+
283
+ echo '<link rel="apple-touch-icon-precomposed" href="'. esc_url( $options["apple_icon_backend_url"] ) .'"/>'."\n";
284
+
285
+ }
286
+ }
287
+ }
288
+
289
+
290
+ } // End Class
291
+
292
+
293
+ // Initiation call of plugin
294
+ $dot_cfi = new DOT_CFI(__FILE__);
295
+
296
+ }
297
+
298
+
299
+
300
+ ?>
index.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+
4
+ ?>
js/dot_cfi_admin.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function( $ ) {
2
+ $( function() {
3
+ $.fn.dot_cfi = function( options ) {
4
+ var selector = $( this ).selector; // Get the selector
5
+ // Set default options
6
+ var defaults = {
7
+ 'preview' : '.preview-upload',
8
+ 'text' : '.text-upload',
9
+ 'button' : '.button-upload'
10
+ };
11
+ var options = $.extend( defaults, options );
12
+
13
+ // When the Button is clicked...
14
+ $( options.button ).click( function() {
15
+ // Get the Text element.
16
+ var text = $( this ).siblings( options.text );
17
+
18
+ // Show WP Media Uploader popup
19
+ tb_show( 'Upload a logo', 'media-upload.php?referer=dot_cfi&type=image&TB_iframe=true&post_id=0', false );
20
+
21
+ // Re-define the global function 'send_to_editor'
22
+ // Define where the new value will be sent to
23
+ window.send_to_editor = function( html ) {
24
+ // Get the URL of new image
25
+ var src = $( 'img', html ).attr( 'src' );
26
+ // Send this value to the Text field.
27
+ text.attr( 'value', src ).trigger( 'change' );
28
+ tb_remove(); // Then close the popup window
29
+ }
30
+ return false;
31
+ } );
32
+
33
+ $( options.text ).bind( 'change', function() {
34
+ // Get the value of current object
35
+ var url = this.value;
36
+ // Determine the Preview field
37
+ var preview = $( this ).siblings( options.preview );
38
+ // Bind the value to Preview field
39
+ $( preview ).attr( 'src', url );
40
+ } );
41
+ }
42
+
43
+ // Usage
44
+ $( '.upload' ).dot_cfi(); // Use as default option.
45
+ } );
46
+ } ( jQuery ) );
languages/dot-cfi-en.mo ADDED
Binary file
languages/dot-cfi-en.po ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Custom Favicon 1.0\n"
4
+ "POT-Creation-Date: 2013-05-26 21:54+0530\n"
5
+ "PO-Revision-Date: 2013-05-26 21:54+0530\n"
6
+ "Last-Translator: DOT <hello@dreamsmedia.in>\n"
7
+ "Language-Team: DOT <hello@dreamsmedia.in>\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.5\n"
12
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;_;_e;__\n"
13
+ "X-Poedit-Basepath: D:\\wamp\\www\\dreamsonline\\wp-content\\plugins\\custom-"
14
+ "favicon\n"
15
+ "X-Poedit-SearchPath-0: D:\\wamp\\www\\dreamsonline\\wp-content\\plugins"
16
+ "\\custom-favicon\n"
17
+
18
+ #: D:\wamp\www\dreamsonline\wp-content\plugins\custom-favicon/custom-favicon.php:95
19
+ #: D:\wamp\www\dreamsonline\wp-content\plugins\custom-favicon/custom-favicon.php:96
20
+ msgid "Custom Favicon"
21
+ msgstr ""
22
+
23
+ #: D:\wamp\www\dreamsonline\wp-content\plugins\custom-favicon/custom-favicon.php:130
24
+ msgid "Custom Favicon & Apple touch icon"
25
+ msgstr ""
26
+
27
+ #: D:\wamp\www\dreamsonline\wp-content\plugins\custom-favicon/custom-favicon.php:132
28
+ msgid "Favicon for Website"
29
+ msgstr ""
30
+
31
+ #: D:\wamp\www\dreamsonline\wp-content\plugins\custom-favicon/custom-favicon.php:134
32
+ msgid "Favicon for Admin"
33
+ msgstr ""
34
+
35
+ #: D:\wamp\www\dreamsonline\wp-content\plugins\custom-favicon/custom-favicon.php:136
36
+ msgid "Apple Touch Icon for Website"
37
+ msgstr ""
38
+
39
+ #: D:\wamp\www\dreamsonline\wp-content\plugins\custom-favicon/custom-favicon.php:138
40
+ msgid "Apple Touch Icon for Admin"
41
+ msgstr ""
42
+
43
+ #: D:\wamp\www\dreamsonline\wp-content\plugins\custom-favicon/custom-favicon.php:140
44
+ msgid "Basic Apple Touch Icon"
45
+ msgstr ""
46
+
47
+ #: D:\wamp\www\dreamsonline\wp-content\plugins\custom-favicon/custom-favicon.php:158
48
+ msgid "Custom Favicon Settings"
49
+ msgstr ""
50
+
51
+ #: D:\wamp\www\dreamsonline\wp-content\plugins\custom-favicon/custom-favicon.php:165
52
+ msgid "Save Changes"
53
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Custom Favicon ===
2
+ Contributors: hchouhan, dreamsonline, dreamsmedia
3
+ Donate link: http://www.dreamsonline.net
4
+ Tags: theme, favicon, admin, blog, wordpress, icon, iphone, apple touch, apple touch icon, upload
5
+ Requires at least: 3.5
6
+ Tested up to: 3.5.2
7
+ Stable tag: 1.0
8
+ Last Updated: 2013-May-21
9
+ Plugin Name: Custom Favicon
10
+ Plugin URI: http://www.dreamsonline.net/wordpress-plugins/custom-favicon/
11
+ Author: Harish Chouhan
12
+ Author URI: http://www.dreamsonline.net/wordpress-themes/
13
+ License: GPLv2 or later
14
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
15
+
16
+
17
+ This plugin allows you to add upload custom favicon & Apple touch icon for your website and WordPress Dashboard using built-in media uploader.
18
+
19
+
20
+ == Description ==
21
+
22
+ Now easily upload a favicon and apple touch icon for your WordPress website and dashboard.
23
+
24
+
25
+ Please report any bugs you find via http://www.dreamsonline.net/wordpress-plugins/custom-favicon/
26
+
27
+
28
+
29
+
30
+ = My Links =
31
+
32
+ * Twitter @[harishchouhan](https://twitter.com/dreams_media)
33
+ * Google+ [Harish Chouhan](https://plus.google.com/u/0/103138475844539274387/)
34
+
35
+
36
+ If you love the plugin, please consider rating it and clicking on "it works" button.
37
+
38
+
39
+ == Installation ==
40
+
41
+ 1. Upload the directory `/custom-favicon/` to the `/wp-content/plugins/` directory
42
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
43
+ 3. Click on "Custom Favicon" sub menu under the Settings menu and upload your favicon
44
+
45
+
46
+
47
+ == Frequently Asked Questions ==
48
+
49
+ Take a look at the [official "Custom Favicon" FAQ](http://www.dreamsonline.net/wordpress-plugins/custom-favicon/).
50
+
51
+ You can also visit the [support center](http://www.dreamsonline.net/wordpress-plugins/custom-favicon/) and start a discussion if needed.
52
+
53
+
54
+
55
+ == Changelog ==
56
+
57
+ = 1.0.0
58
+ * This is the first version