Version Description
- New: Preview icons and shortcuts in the WordPress Menu Editor.
- New: vimeo.com and stackexchange.com icons when FontAwesome 4.0 is turned on.
- Notice: FontAwesome 4.0 removes support for IE7, so it is off by default. Use the filter
storm_social_icons_use_latest
shown in the readme to turn on FontAwesome 4.0.
Download this release
Release Info
Developer | pdclark |
Plugin | Menu Social Icons |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 1.3
- classes/msi-admin.php +73 -0
- classes/msi-frontend.php +277 -0
- css/menu-social-icons-admin.css +40 -0
- js/menu-social-icons-admin.js +188 -0
- menu-social-icons.php +0 -213
- plugin.php +64 -0
- readme.txt +59 -30
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- screenshot-6.png +0 -0
- screenshot-7.png +0 -0
classes/msi-admin.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MSI_Admin {
|
4 |
+
/**
|
5 |
+
* @var Storm_Menu_Social_Icons Instance of the class.
|
6 |
+
*/
|
7 |
+
private static $instance = false;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Don't use this. Use ::get_instance() instead.
|
11 |
+
*/
|
12 |
+
public function __construct() {
|
13 |
+
if ( !self::$instance ) {
|
14 |
+
$message = '<code>' . __CLASS__ . '</code> is a singleton.<br/> Please get an instantiate it with <code>' . __CLASS__ . '::get_instance();</code>';
|
15 |
+
wp_die( $message );
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
public static function get_instance() {
|
20 |
+
if ( !is_a( self::$instance, __CLASS__ ) ) {
|
21 |
+
self::$instance = true;
|
22 |
+
self::$instance = new self();
|
23 |
+
self::$instance->init();
|
24 |
+
}
|
25 |
+
return self::$instance;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Initial setup. Called by get_instance.
|
30 |
+
*/
|
31 |
+
protected function init() {
|
32 |
+
|
33 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
public function admin_enqueue_scripts( $page ) {
|
38 |
+
|
39 |
+
if ( 'nav-menus.php' == $page ) {
|
40 |
+
$msi_frontend = MSI_Frontend::get_instance();
|
41 |
+
|
42 |
+
$msi_frontend->wp_enqueue_scripts();
|
43 |
+
|
44 |
+
wp_enqueue_script( 'menu-social-icons-admin', plugins_url( 'js/menu-social-icons-admin.js', MSI_PLUGIN_FILE ), array( 'jquery' ), MSI_VERSION, true );
|
45 |
+
wp_enqueue_style( 'menu-social-icons-admin', plugins_url( 'css/menu-social-icons-admin.css', MSI_PLUGIN_FILE ), array(), MSI_VERSION );
|
46 |
+
|
47 |
+
wp_localize_script( 'menu-social-icons-admin', 'MenuSocialIconsNetworks', $this->get_networks() );
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Get networks array to pass to javascript
|
54 |
+
* Set icon-sign values as icon values if icon-sign in use.
|
55 |
+
* Strip remaining icon-sign values
|
56 |
+
*/
|
57 |
+
public function get_networks() {
|
58 |
+
$msi_frontend = MSI_Frontend::get_instance();
|
59 |
+
|
60 |
+
$networks = $msi_frontend->networks;
|
61 |
+
|
62 |
+
foreach ( $networks as &$network ) {
|
63 |
+
if ( 'icon-sign' == $msi_frontend->type ) {
|
64 |
+
$network['icon'] = $network['icon-sign'];
|
65 |
+
}
|
66 |
+
unset( $network['icon-sign'] );
|
67 |
+
}
|
68 |
+
|
69 |
+
return $networks;
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
}
|
classes/msi-frontend.php
ADDED
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MSI_Frontend {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Should we hide the original menu text, or put the icon before it?
|
7 |
+
* Override with storm_social_icons_hide_text filter
|
8 |
+
*
|
9 |
+
* @var bool
|
10 |
+
*/
|
11 |
+
var $hide_text = true;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Contains 3.2.1 FontAwesome icons only. See $networks_latest for additional 4.0 icons.
|
15 |
+
* @var array links social site URLs with CSS classes for icons
|
16 |
+
*/
|
17 |
+
var $networks = array(
|
18 |
+
'bitbucket.org' => array( 'name' => 'Bitbucket', 'class' => 'bitbucket', 'icon' => 'icon-bitbucket', 'icon-sign' => 'icon-bitbucket-sign' ),
|
19 |
+
'dribbble.com' => array( 'name' => 'Dribbble', 'class' => 'dribbble', 'icon' => 'icon-dribbble', 'icon-sign' => 'icon-dribbble' ),
|
20 |
+
'dropbox.com' => array( 'name' => 'Dropbox', 'class' => 'dropbox', 'icon' => 'icon-dropbox', 'icon-sign' => 'icon-dropbox' ),
|
21 |
+
'facebook.com' => array( 'name' => 'Facebook', 'class' => 'facebook', 'icon' => 'icon-facebook', 'icon-sign' => 'icon-facebook-sign' ),
|
22 |
+
'flickr.com' => array( 'name' => 'Flickr', 'class' => 'flickr', 'icon' => 'icon-flickr', 'icon-sign' => 'icon-flickr' ),
|
23 |
+
'foursquare.com' => array( 'name' => 'Foursquare', 'class' => 'foursquare', 'icon' => 'icon-foursquare', 'icon-sign' => 'icon-foursquare' ),
|
24 |
+
'github.com' => array( 'name' => 'Github', 'class' => 'github', 'icon' => 'icon-github', 'icon-sign' => 'icon-github-sign' ),
|
25 |
+
'gittip.com' => array( 'name' => 'GitTip', 'class' => 'gittip', 'icon' => 'icon-gittip', 'icon-sign' => 'icon-gittip' ),
|
26 |
+
'instagr.am' => array( 'name' => 'Instagram', 'class' => 'instagram', 'icon' => 'icon-instagram', 'icon-sign' => 'icon-instagram' ),
|
27 |
+
'instagram.com' => array( 'name' => 'Instagram', 'class' => 'instagram', 'icon' => 'icon-instagram', 'icon-sign' => 'icon-instagram' ),
|
28 |
+
'linkedin.com' => array( 'name' => 'LinkedIn', 'class' => 'linkedin', 'icon' => 'icon-linkedin', 'icon-sign' => 'icon-linkedin-sign' ),
|
29 |
+
'mailto:' => array( 'name' => 'Email', 'class' => 'envelope', 'icon' => 'icon-envelope', 'icon-sign' => 'icon-envelope-alt' ),
|
30 |
+
'pinterest.com' => array( 'name' => 'Pinterest', 'class' => 'pinterest', 'icon' => 'icon-pinterest', 'icon-sign' => 'icon-pinterest-sign' ),
|
31 |
+
'plus.google.com' => array( 'name' => 'Google+', 'class' => 'google-plus', 'icon' => 'icon-google-plus', 'icon-sign' => 'icon-google-plus-sign' ),
|
32 |
+
'renren.com' => array( 'name' => 'RenRen', 'class' => 'renren', 'icon' => 'icon-renren', 'icon-sign' => 'icon-renren' ),
|
33 |
+
'stackoverflow.com' => array( 'name' => 'Stack Exchange', 'class' => 'stackexchange', 'icon' => 'icon-stackexchange', 'icon-sign' => 'icon-stackexchange' ),
|
34 |
+
'trello.com' => array( 'name' => 'Trello', 'class' => 'trello', 'icon' => 'icon-trello', 'icon-sign' => 'icon-trello' ),
|
35 |
+
'tumblr.com' => array( 'name' => 'Tumblr', 'class' => 'tumblr', 'icon' => 'icon-tumblr', 'icon-sign' => 'icon-tumblr' ),
|
36 |
+
'twitter.com' => array( 'name' => 'Twitter', 'class' => 'twitter', 'icon' => 'icon-twitter', 'icon-sign' => 'icon-twitter-sign' ),
|
37 |
+
'vk.com' => array( 'name' => 'VK', 'class' => 'vk', 'icon' => 'icon-vk', 'icon-sign' => 'icon-vk' ),
|
38 |
+
'weibo.com' => array( 'name' => 'Weibo', 'class' => 'weibo', 'icon' => 'icon-weibo', 'icon-sign' => 'icon-weibo' ),
|
39 |
+
'xing.com' => array( 'name' => 'Xing', 'class' => 'xing', 'icon' => 'icon-xing', 'icon-sign' => 'icon-xing' ),
|
40 |
+
'youtu.be' => array( 'name' => 'YouTube', 'class' => 'youtube', 'icon' => 'icon-youtube', 'icon-sign' => 'icon-youtube-sign' ),
|
41 |
+
'youtube.com' => array( 'name' => 'YouTube', 'class' => 'youtube', 'icon' => 'icon-youtube', 'icon-sign' => 'icon-youtube-sign' ),
|
42 |
+
);
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Contains 4.0+ FontAwesome icons only.
|
46 |
+
* @var array links social site URLs with CSS classes for icons
|
47 |
+
*/
|
48 |
+
var $networks_latest = array(
|
49 |
+
'stackoverflow.com' => array( 'name' => 'Stack Overflow', 'class' => 'stack-overflow', 'icon' => 'fa fa-stack-overflow', 'icon-sign' => 'fa fa-stack-overflow' ),
|
50 |
+
'stackexchange.com' => array( 'name' => 'Stack Exchange', 'class' => 'stack-exchange', 'icon' => 'fa fa-stack-exchange', 'icon-sign' => 'fa fa-stack-exchange' ),
|
51 |
+
'vimeo.com' => array( 'name' => 'Vimeo', 'class' => 'vimeo', 'icon' => 'fa fa-vimeo-square', 'icon-sign' => 'fa fa-vimeo-square' ),
|
52 |
+
'mailto:' => array( 'name' => 'Email', 'class' => 'envelope', 'icon' => 'fa fa-envelope', 'icon-sign' => 'fa fa-envelope-o' ),
|
53 |
+
);
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Class to apply to the <li> of all social menu items
|
57 |
+
*/
|
58 |
+
var $li_class = 'social-icon';
|
59 |
+
|
60 |
+
/**
|
61 |
+
* FontAwesome 4.0+ -- Size options available for icon output
|
62 |
+
* These are sizes that render as "pixel perfect" according to FontAwesome.
|
63 |
+
*/
|
64 |
+
var $icon_sizes = array(
|
65 |
+
'normal' => '',
|
66 |
+
'large' => 'fa-lg',
|
67 |
+
'2x' => 'fa-2x',
|
68 |
+
'3x' => 'fa-3x',
|
69 |
+
'4x' => 'fa-4x',
|
70 |
+
'5x' => 'fa-5x',
|
71 |
+
);
|
72 |
+
|
73 |
+
/**
|
74 |
+
* FontAwesome 3.2.1 -- Size options available for icon output
|
75 |
+
* These are sizes that render as "pixel perfect" according to FontAwesome.
|
76 |
+
*/
|
77 |
+
var $legacy_icon_sizes = array(
|
78 |
+
'normal' => '',
|
79 |
+
'large' => 'icon-large',
|
80 |
+
'2x' => 'icon-2x',
|
81 |
+
'3x' => 'icon-3x',
|
82 |
+
'4x' => 'icon-4x',
|
83 |
+
);
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Size of the icons to display.
|
87 |
+
* Override with storm_social_icons_size filter
|
88 |
+
*
|
89 |
+
* @var string normal|large|2x|3x|4x
|
90 |
+
*/
|
91 |
+
var $size = '2x';
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Display normal icons, or icons cut out of a box (sign) shape?
|
95 |
+
* Override with storm_social_icons_type filter
|
96 |
+
*
|
97 |
+
* @var string icon|icon-sign
|
98 |
+
*/
|
99 |
+
var $type = 'icon';
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @var bool If true, use FontAwesome 4.0+, which drops IE7, but adds Vimeo
|
103 |
+
*/
|
104 |
+
var $use_latest = true;
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @var Storm_Menu_Social_Icons Instance of the class.
|
108 |
+
*/
|
109 |
+
private static $instance = false;
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Don't use this. Use ::get_instance() instead.
|
113 |
+
*/
|
114 |
+
public function __construct() {
|
115 |
+
if ( !self::$instance ) {
|
116 |
+
$message = '<code>' . __CLASS__ . '</code> is a singleton.<br/> Please get an instantiate it with <code>' . __CLASS__ . '::get_instance();</code>';
|
117 |
+
wp_die( $message );
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
public static function get_instance() {
|
122 |
+
if ( !is_a( self::$instance, __CLASS__ ) ) {
|
123 |
+
self::$instance = true;
|
124 |
+
self::$instance = new self();
|
125 |
+
self::$instance->init();
|
126 |
+
}
|
127 |
+
return self::$instance;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Initial setup. Called by get_instance.
|
132 |
+
*/
|
133 |
+
protected function init() {
|
134 |
+
|
135 |
+
// Option to update to FontAwesome 4.0+ format (drops IE7 support)
|
136 |
+
$this->use_latest = apply_filters( 'storm_social_icons_use_latest', $this->use_latest );
|
137 |
+
|
138 |
+
if ( $this->use_latest ) {
|
139 |
+
add_filter( 'storm_social_icons_networks', array( $this, 'update_network_classes' ), 1000 );
|
140 |
+
}
|
141 |
+
|
142 |
+
$this->size = apply_filters( 'storm_social_icons_size', $this->size );
|
143 |
+
$this->type = apply_filters( 'storm_social_icons_type', $this->type );
|
144 |
+
$this->hide_text = apply_filters( 'storm_social_icons_hide_text', $this->hide_text );
|
145 |
+
$this->networks = apply_filters( 'storm_social_icons_networks', $this->networks );
|
146 |
+
|
147 |
+
add_action( 'wp_print_scripts', array( $this, 'wp_enqueue_scripts' ) );
|
148 |
+
add_action( 'wp_print_scripts', array( $this, 'wp_print_scripts' ) );
|
149 |
+
|
150 |
+
add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ), 5, 2 );
|
151 |
+
|
152 |
+
// Shortcode for testing all fontawesome icons: [fontawesometest]
|
153 |
+
add_shortcode( 'fontawesometest', array( $this, 'shortcode_fontawesometest' ) );
|
154 |
+
add_action( 'fontawesometest', array( $this, 'fontawesometest' ) );
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Load FontAwesome from NetDNA's Content Deliver Network (faster, likely to be cached)
|
160 |
+
* @see http://www.bootstrapcdn.com/#tab_fontawesome
|
161 |
+
*/
|
162 |
+
public function wp_enqueue_scripts() {
|
163 |
+
|
164 |
+
if ( $this->use_latest ) {
|
165 |
+
|
166 |
+
// FontAwesome latest. Drops IE7 support.
|
167 |
+
wp_enqueue_style( 'fontawesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.css', array(), MSI_VERSION, 'all' );
|
168 |
+
|
169 |
+
}else {
|
170 |
+
|
171 |
+
// FontAwesome 3.2.1 -- support IE7, but lacks Vimeo
|
172 |
+
global $wp_styles;
|
173 |
+
wp_enqueue_style( 'fontawesome', '//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css', array(), MSI_VERSION, 'all' );
|
174 |
+
wp_enqueue_style( 'fontawesome-ie', '//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome-ie7.min.css', array( 'fontawesome' ), MSI_VERSION );
|
175 |
+
|
176 |
+
// Internet Explorer conditional comment
|
177 |
+
$wp_styles->add_data( 'fontawesome-ie', 'conditional', 'IE 7' );
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Hide text visually, but keep available for screen readers.
|
185 |
+
* Just 2 lines of stylesheet, so loading inline rather than adding another HTTP request.
|
186 |
+
*/
|
187 |
+
public function wp_print_scripts() {
|
188 |
+
?>
|
189 |
+
<style>
|
190 |
+
/* Accessible for screen readers but hidden from view */
|
191 |
+
.fa-hidden { position:absolute; left:-10000px; top:auto; width:1px; height:1px; overflow:hidden; }
|
192 |
+
.fa-showtext { margin-right: 5px; }
|
193 |
+
</style>
|
194 |
+
<?php
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Get icon HTML with appropriate classes depending on size and icon type
|
199 |
+
*/
|
200 |
+
public function get_icon( $network ) {
|
201 |
+
|
202 |
+
// Switch between legacy or current icon size classes
|
203 |
+
$icon_sizes = ( $this->use_latest ) ? $this->icon_sizes : $this->legacy_icon_sizes;
|
204 |
+
|
205 |
+
$size = $icon_sizes[ $this->size ];
|
206 |
+
$icon = $network[ $this->type ];
|
207 |
+
$show_text = $this->hide_text ? '' : 'fa-showtext';
|
208 |
+
|
209 |
+
return "<i class='$size $icon $show_text'></i>";
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Find social links in top-level menu items, add icon HTML
|
215 |
+
*/
|
216 |
+
public function wp_nav_menu_objects( $sorted_menu_items, $args ){
|
217 |
+
|
218 |
+
foreach( $sorted_menu_items as &$item ) {
|
219 |
+
if ( 0 != $item->menu_item_parent ) {
|
220 |
+
// Skip submenu items
|
221 |
+
continue;
|
222 |
+
}
|
223 |
+
|
224 |
+
foreach( $this->networks as $url => $network ) {
|
225 |
+
if ( false !== strpos( $item->url, $url ) ) {
|
226 |
+
|
227 |
+
$item->classes[] = $this->li_class;
|
228 |
+
$item->classes[] = $network['class'];
|
229 |
+
|
230 |
+
if ( $this->hide_text ) {
|
231 |
+
$item->title = '<span class="fa-hidden">' . $item->title . '</span>';
|
232 |
+
}
|
233 |
+
|
234 |
+
$item->title = $this->get_icon( $network ) . $item->title ;
|
235 |
+
}
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
return $sorted_menu_items;
|
240 |
+
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Change size classes from 3.2.1 format to 4.0+ format.
|
245 |
+
*
|
246 |
+
* @param array $networks See $this->$networks
|
247 |
+
* @return array $networks Filtered to change "icon-" to "fa fa-"
|
248 |
+
*/
|
249 |
+
public function update_network_classes( $networks ) {
|
250 |
+
|
251 |
+
foreach ( $networks as $url => &$values ) {
|
252 |
+
$values['icon'] = str_replace( 'icon-', 'fa fa-', $values['icon'] );
|
253 |
+
$values['icon-sign'] = str_replace( 'icon-', 'fa fa-', $values['icon-sign'] );
|
254 |
+
$values['icon-sign'] = str_replace( '-sign', '-square', $values['icon-sign'] );
|
255 |
+
}
|
256 |
+
|
257 |
+
$networks = array_merge( $networks, $this->networks_latest );
|
258 |
+
|
259 |
+
return $networks;
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Test output of all FontAwesome icons
|
264 |
+
*/
|
265 |
+
public function fontawesometest( $args ) {
|
266 |
+
include dirname( __FILE__ ) . '/font-awesome-test.html';
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Shortcode to test output of all FontAwesome icons
|
271 |
+
*/
|
272 |
+
public function shortcode_fontawesometest( $args ) {
|
273 |
+
ob_start();
|
274 |
+
$this->fontawesometest();
|
275 |
+
return ob_get_clean();
|
276 |
+
}
|
277 |
+
}
|
css/menu-social-icons-admin.css
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Icon sizes */
|
2 |
+
.menu-item-handle i.fa, #msi-shortcuts i.fa {
|
3 |
+
font-size: 28px;
|
4 |
+
}
|
5 |
+
|
6 |
+
/* Fixed width for FontAwesome 3.2.1 */
|
7 |
+
i.fa-fw {
|
8 |
+
width: 1.2857142857142858em;
|
9 |
+
text-align: center;
|
10 |
+
display:block;
|
11 |
+
float:left;
|
12 |
+
}
|
13 |
+
|
14 |
+
#msi-shortcuts i {
|
15 |
+
cursor: pointer;
|
16 |
+
margin: 0 5px 5px 0;
|
17 |
+
color: #333;
|
18 |
+
}
|
19 |
+
#msi-shortcuts i:hover {
|
20 |
+
color: #1A749D;
|
21 |
+
}
|
22 |
+
#msi-shortcuts h4 {
|
23 |
+
font-weight: normal;
|
24 |
+
font-style: italic;
|
25 |
+
}
|
26 |
+
|
27 |
+
/* Add Link active icon */
|
28 |
+
#msi-shortcuts i.active {
|
29 |
+
color: #1A749D;
|
30 |
+
}
|
31 |
+
|
32 |
+
/* Menu item handle */
|
33 |
+
.menu-item-handle i.fa {
|
34 |
+
position: absolute;
|
35 |
+
top: 4px;
|
36 |
+
left: 4px;
|
37 |
+
}
|
38 |
+
.menu-item-handle span.has-social-icon {
|
39 |
+
padding-left: 33px;
|
40 |
+
}
|
js/menu-social-icons-admin.js
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function( $, icons ){
|
2 |
+
/**
|
3 |
+
* Variable "icons" from MenuSocialIconsNetworks, PHP: MSI_Frontend::$networks)
|
4 |
+
*/
|
5 |
+
|
6 |
+
/**
|
7 |
+
* List of URLs to search for
|
8 |
+
*/
|
9 |
+
var icon_urls = Object.keys( icons );
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Iterate over all menu items, add icon if URL matches
|
13 |
+
*/
|
14 |
+
var check_menu_item = function(){
|
15 |
+
var $input = $(this);
|
16 |
+
var url_value = $input.val();
|
17 |
+
|
18 |
+
var icon_url = get_icon_if_exists_for_url( url_value );
|
19 |
+
|
20 |
+
if ( icon_url ){
|
21 |
+
add_icon( $input, icon_url );
|
22 |
+
}else {
|
23 |
+
remove_icon( $input );
|
24 |
+
}
|
25 |
+
};
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Check a URL to see if we have an icon for it
|
29 |
+
* @return string|bool valid URL|false
|
30 |
+
*/
|
31 |
+
var get_icon_if_exists_for_url = function( url_value ) {
|
32 |
+
for (var i = 0; i < icon_urls.length; i++) {
|
33 |
+
if ( -1 != url_value.indexOf( icon_urls[i] ) ){
|
34 |
+
return icon_urls[i];
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
return false;
|
39 |
+
};
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Add icon, either from New Link area or menu item title
|
43 |
+
*/
|
44 |
+
var add_icon = function( $input, icon_url ){
|
45 |
+
if ( "custom-menu-item-url" == $input.attr('id') ) {
|
46 |
+
add_icon_to_new_link( $input, icon_url );
|
47 |
+
}else {
|
48 |
+
add_icon_to_title( $input, icon_url );
|
49 |
+
}
|
50 |
+
};
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Remove icon, either from New Link area or menu item title
|
54 |
+
*/
|
55 |
+
var remove_icon = function( $input ){
|
56 |
+
if ( "custom-menu-item-url" == $input.attr('id') ) {
|
57 |
+
remove_icon_from_new_link();
|
58 |
+
}else {
|
59 |
+
remove_icon_from_title( $input );
|
60 |
+
}
|
61 |
+
};
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Add icon to New Link area
|
65 |
+
*/
|
66 |
+
var add_icon_to_new_link = function( $input, icon_url ){
|
67 |
+
remove_icon_from_new_link();
|
68 |
+
|
69 |
+
$('#msi-shortcuts i').each( function(){
|
70 |
+
if ( icon_url == $(this).data('url') ) {
|
71 |
+
$(this).addClass('active');
|
72 |
+
}
|
73 |
+
});
|
74 |
+
|
75 |
+
};
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Add an icon to menu title bar
|
79 |
+
*/
|
80 |
+
var add_icon_to_title = function( $input, icon_url ){
|
81 |
+
// Identify title element and build appropriate icon
|
82 |
+
var $title = $input.parents('li.menu-item').find('dt.menu-item-handle');
|
83 |
+
|
84 |
+
var $icon = get_icon_from_url( icon_url );
|
85 |
+
|
86 |
+
// Add icon and move title text over
|
87 |
+
remove_icon_from_title( $input );
|
88 |
+
$title.prepend( $icon );
|
89 |
+
$title.find("span.item-title").addClass("has-social-icon");
|
90 |
+
};
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Remove icon from title area of menu item
|
94 |
+
*/
|
95 |
+
var remove_icon_from_title = function( $input ) {
|
96 |
+
var $title = $input.parents('li.menu-item').find('dt.menu-item-handle');
|
97 |
+
|
98 |
+
$title.children('i').remove();
|
99 |
+
$title.find("span.item-title").removeClass("has-social-icon");
|
100 |
+
};
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Remove icon from New Link area
|
104 |
+
*/
|
105 |
+
var remove_icon_from_new_link = function(){
|
106 |
+
$('#msi-shortcuts i').removeClass('active');
|
107 |
+
};
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Take a matched URL and create an icon from info looked up in icons object
|
111 |
+
*/
|
112 |
+
var get_icon_from_url = function( url ){
|
113 |
+
var $icon = $("<i>").addClass( icons[ url ].icon ).addClass('fa').addClass('fa-fw');
|
114 |
+
|
115 |
+
return $icon;
|
116 |
+
};
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Take a matched URL and return the network name
|
120 |
+
*/
|
121 |
+
var get_name_from_url = function( url ){
|
122 |
+
return icons[ url ].name;
|
123 |
+
};
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Add shortcuts to all icons in Links menu
|
127 |
+
*/
|
128 |
+
var display_icon_shortcuts = function(){
|
129 |
+
var $icon, name;
|
130 |
+
var $wrapper = $('<div>').attr('id', 'msi-shortcuts');
|
131 |
+
|
132 |
+
$wrapper.append( '<h4>Social Icons</h4>');
|
133 |
+
|
134 |
+
for (var i = 0; i < icon_urls.length; i++) {
|
135 |
+
// Skip short-links (duplicates)
|
136 |
+
if ( 'youtu.be' == icon_urls[i] || 'instagr.am' == icon_urls[i] ) {
|
137 |
+
continue;
|
138 |
+
}
|
139 |
+
|
140 |
+
$icon = get_icon_from_url( icon_urls[i] );
|
141 |
+
name = get_name_from_url( icon_urls[i] );
|
142 |
+
|
143 |
+
$icon.data( 'url', icon_urls[i] );
|
144 |
+
$icon.data( 'name', name );
|
145 |
+
|
146 |
+
$icon.click( update_link_fields );
|
147 |
+
|
148 |
+
$wrapper.append( $icon );
|
149 |
+
}
|
150 |
+
|
151 |
+
$('#customlinkdiv').append( $wrapper );
|
152 |
+
};
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Insert icon URL into input field when icon is clicked
|
156 |
+
*/
|
157 |
+
var update_link_fields = function(){
|
158 |
+
var url = $(this).data('url');
|
159 |
+
var name = $(this).data('name');
|
160 |
+
|
161 |
+
remove_icon_from_new_link();
|
162 |
+
$(this).addClass('active');
|
163 |
+
|
164 |
+
$('#custom-menu-item-url').val( 'http://' + url + '/' );
|
165 |
+
$('#custom-menu-item-name').val( name ).removeClass('input-with-default-title');
|
166 |
+
};
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Initial search and change event hook
|
170 |
+
*/
|
171 |
+
var init = function(){
|
172 |
+
$( '#menu-to-edit input.edit-menu-item-url' ).each( check_menu_item );
|
173 |
+
$( '#menu-to-edit input.edit-menu-item-url' ).on( 'keyup', check_menu_item );
|
174 |
+
$( '#custom-menu-item-url' ).on( 'keyup', check_menu_item );
|
175 |
+
|
176 |
+
// Closest thing I can find to an event on new link add
|
177 |
+
$( '#custom-menu-item-name' ).on( 'blur', function(){
|
178 |
+
$( '#menu-to-edit input.edit-menu-item-url' ).each( check_menu_item );
|
179 |
+
remove_icon_from_new_link();
|
180 |
+
});
|
181 |
+
|
182 |
+
display_icon_shortcuts();
|
183 |
+
};
|
184 |
+
|
185 |
+
// Fire this plugin
|
186 |
+
init();
|
187 |
+
|
188 |
+
})( jQuery, MenuSocialIconsNetworks );
|
menu-social-icons.php
DELETED
@@ -1,213 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Menu Social Icons
|
4 |
-
Description: Change menu links to social sites to icons automatically. Uses <a href="http://fortawesome.github.io/Font-Awesome/" target="_blank">FontAwesome</a> and supports: Bitbucket, Dribbble, Dropbox, Flickr, Foursquare, Gittip, Instagram, RenRen, Stack Overflow, Trello, Tumblr, VK, Weibo, Xing, and YouTube.
|
5 |
-
Version: 1.2
|
6 |
-
Author: Brainstorm Media
|
7 |
-
Author URI: http://brainstormmedia.com
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Copyright (c) 2013 Brainstorm Media. All rights reserved.
|
12 |
-
*
|
13 |
-
* Released under the GPL license
|
14 |
-
* http://www.opensource.org/licenses/gpl-license.php
|
15 |
-
*
|
16 |
-
* This is an add-on for WordPress
|
17 |
-
* http://wordpress.org/
|
18 |
-
*
|
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 as published by
|
22 |
-
* the Free Software Foundation; either version 2 of the License, or
|
23 |
-
* (at your option) any later version.
|
24 |
-
*
|
25 |
-
* This program is distributed in the hope that it will be useful,
|
26 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
27 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
28 |
-
* GNU General Public License for more details.
|
29 |
-
* **********************************************************************
|
30 |
-
*/
|
31 |
-
|
32 |
-
add_action( 'template_redirect', create_function( '', 'global $storm_menu_social_icons; $storm_menu_social_icons = new Storm_Menu_Social_Icons();' ) );
|
33 |
-
|
34 |
-
class Storm_Menu_Social_Icons {
|
35 |
-
|
36 |
-
var $version = '1.2';
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Should we hide the original menu text, or put the icon before it?
|
40 |
-
* Override with storm_social_icons_hide_text filter
|
41 |
-
*
|
42 |
-
* @var bool
|
43 |
-
*/
|
44 |
-
var $hide_text = true;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Array linking social site URLs with CSS classes for icons
|
48 |
-
*/
|
49 |
-
var $networks = array(
|
50 |
-
'bitbucket.org' => array( 'class' => 'bitbucket', 'icon' => 'icon-bitbucket', 'icon-sign' => 'icon-bitbucket-sign' ),
|
51 |
-
'dribbble.com' => array( 'class' => 'dribbble', 'icon' => 'icon-dribbble', 'icon-sign' => 'icon-dribbble' ),
|
52 |
-
'dropbox.com' => array( 'class' => 'dropbox', 'icon' => 'icon-dropbox', 'icon-sign' => 'icon-dropbox' ),
|
53 |
-
'facebook.com' => array( 'class' => 'facebook', 'icon' => 'icon-facebook', 'icon-sign' => 'icon-facebook-sign' ),
|
54 |
-
'flickr.com' => array( 'class' => 'flickr', 'icon' => 'icon-flickr', 'icon-sign' => 'icon-flickr' ),
|
55 |
-
'foursquare.com' => array( 'class' => 'foursquare', 'icon' => 'icon-foursquare', 'icon-sign' => 'icon-foursquare' ),
|
56 |
-
'github.com' => array( 'class' => 'github', 'icon' => 'icon-github', 'icon-sign' => 'icon-github-sign' ),
|
57 |
-
'gittip.com' => array( 'class' => 'gittip', 'icon' => 'icon-gittip', 'icon-sign' => 'icon-gittip-sign' ),
|
58 |
-
'instagr.am' => array( 'class' => 'instagram', 'icon' => 'icon-instagram', 'icon-sign' => 'icon-instagram' ),
|
59 |
-
'instagram.com' => array( 'class' => 'instagram', 'icon' => 'icon-instagram', 'icon-sign' => 'icon-instagram' ),
|
60 |
-
'linkedin.com' => array( 'class' => 'linkedin', 'icon' => 'icon-linkedin', 'icon-sign' => 'icon-linkedin-sign' ),
|
61 |
-
'mailto:' => array( 'class' => 'envelope', 'icon' => 'icon-envelope', 'icon-sign' => 'icon-envelope-alt' ),
|
62 |
-
'pinterest.com' => array( 'class' => 'pinterest', 'icon' => 'icon-pinterest', 'icon-sign' => 'icon-pinterest-sign' ),
|
63 |
-
'plus.google.com' => array( 'class' => 'google-plus', 'icon' => 'icon-google-plus', 'icon-sign' => 'icon-google-plus-sign' ),
|
64 |
-
'renren.com' => array( 'class' => 'renren', 'icon' => 'icon-renren', 'icon-sign' => 'icon-renren' ),
|
65 |
-
'stackoverflow.com' => array( 'class' => 'stackexchange', 'icon' => 'icon-stackexchange', 'icon-sign' => 'icon-stackexchange' ),
|
66 |
-
'trello.com' => array( 'class' => 'trello', 'icon' => 'icon-trello', 'icon-sign' => 'icon-trello' ),
|
67 |
-
'tumblr.com' => array( 'class' => 'tumblr', 'icon' => 'icon-tumblr', 'icon-sign' => 'icon-tumblr' ),
|
68 |
-
'twitter.com' => array( 'class' => 'twitter', 'icon' => 'icon-twitter', 'icon-sign' => 'icon-twitter-sign' ),
|
69 |
-
'vk.com' => array( 'class' => 'vk', 'icon' => 'icon-vk', 'icon-sign' => 'icon-vk' ),
|
70 |
-
'weibo.com' => array( 'class' => 'weibo', 'icon' => 'icon-weibo', 'icon-sign' => 'icon-weibo' ),
|
71 |
-
'xing.com' => array( 'class' => 'xing', 'icon' => 'icon-xing', 'icon-sign' => 'icon-xing' ),
|
72 |
-
'youtu.be' => array( 'class' => 'youtube', 'icon' => 'icon-youtube', 'icon-sign' => 'icon-youtube-sign' ),
|
73 |
-
'youtube.com' => array( 'class' => 'youtube', 'icon' => 'icon-youtube', 'icon-sign' => 'icon-youtube-sign' ),
|
74 |
-
);
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Class to apply to the <li> of all social menu items
|
78 |
-
*/
|
79 |
-
var $li_class = 'social-icon';
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Size options available for icon output
|
83 |
-
* These are sizes that render as "pixel perfect" according to FontAwesome.
|
84 |
-
*/
|
85 |
-
var $icon_sizes = array(
|
86 |
-
'normal' => '',
|
87 |
-
'large' => 'icon-large',
|
88 |
-
'2x' => 'icon-2x',
|
89 |
-
'3x' => 'icon-3x',
|
90 |
-
'4x' => 'icon-4x',
|
91 |
-
);
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Size of the icons to display.
|
95 |
-
* Override with storm_social_icons_size filter
|
96 |
-
*
|
97 |
-
* @var string normal|large|2x|3x|4x
|
98 |
-
*/
|
99 |
-
var $size = '2x';
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Display normal icons, or icons cut out of a box (sign) shape?
|
103 |
-
* Override with storm_social_icons_type filter
|
104 |
-
*
|
105 |
-
* @var string icon|icon-sign
|
106 |
-
*/
|
107 |
-
var $type = 'icon';
|
108 |
-
|
109 |
-
public function __construct() {
|
110 |
-
|
111 |
-
$this->size = apply_filters( 'storm_social_icons_size', $this->size );
|
112 |
-
$this->type = apply_filters( 'storm_social_icons_type', $this->type );
|
113 |
-
$this->hide_text = apply_filters( 'storm_social_icons_hide_text', $this->hide_text );
|
114 |
-
$this->networks = apply_filters( 'storm_social_icons_networks', $this->networks );
|
115 |
-
|
116 |
-
add_action( 'wp_print_scripts', array( $this, 'wp_enqueue_scripts' ) );
|
117 |
-
add_action( 'wp_print_scripts', array( $this, 'wp_print_scripts' ) );
|
118 |
-
|
119 |
-
add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ), 5, 2 );
|
120 |
-
|
121 |
-
// Shortcode for testing all fontawesome icons: [fontawesometest]
|
122 |
-
add_shortcode( 'fontawesometest', array( $this, 'shortcode_fontawesometest' ) );
|
123 |
-
add_action( 'fontawesometest', array( $this, 'fontawesometest' ) );
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Load FontAwesome from NetDNA's Content Deliver Network (faster, likely to be cached)
|
129 |
-
* @see http://www.bootstrapcdn.com/#tab_fontawesome
|
130 |
-
*/
|
131 |
-
public function wp_enqueue_scripts() {
|
132 |
-
global $wp_styles;
|
133 |
-
|
134 |
-
wp_enqueue_style( 'fontawesome', '//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css', array(), $this->version, 'all' );
|
135 |
-
wp_enqueue_style( 'fontawesome-ie', '//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome-ie7.min.css', array( 'fontawesome' ), $this->version );
|
136 |
-
|
137 |
-
// Add Internet Explorer conditional comment
|
138 |
-
$wp_styles->add_data( 'fontawesome-ie', 'conditional', 'IE 7' );
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Hide text visually, but keep available for screen readers.
|
143 |
-
* Just 2 lines of stylesheet, so loading inline rather than adding another HTTP request.
|
144 |
-
*/
|
145 |
-
public function wp_print_scripts() {
|
146 |
-
?>
|
147 |
-
<style>
|
148 |
-
/* Accessible for screen readers but hidden from view */
|
149 |
-
.fa-hidden { position:absolute; left:-10000px; top:auto; width:1px; height:1px; overflow:hidden; }
|
150 |
-
.fa-showtext { margin-right: 5px; }
|
151 |
-
</style>
|
152 |
-
<?php
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Get icon HTML with appropriate classes depending on size and icon type
|
157 |
-
*/
|
158 |
-
public function get_icon( $network ) {
|
159 |
-
|
160 |
-
$size = $this->icon_sizes[ $this->size ];
|
161 |
-
$icon = $network[ $this->type ];
|
162 |
-
$show_text = $this->hide_text ? '' : 'fa-showtext';
|
163 |
-
|
164 |
-
return "<i class='$size $icon $show_text'></i>";
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Find social links in top-level menu items, add icon HTML
|
170 |
-
*/
|
171 |
-
public function wp_nav_menu_objects( $sorted_menu_items, $args ){
|
172 |
-
|
173 |
-
foreach( $sorted_menu_items as &$item ) {
|
174 |
-
if ( 0 != $item->menu_item_parent ) {
|
175 |
-
// Skip submenu items
|
176 |
-
continue;
|
177 |
-
}
|
178 |
-
|
179 |
-
foreach( $this->networks as $url => $network ) {
|
180 |
-
if ( false !== strpos( $item->url, $url ) ) {
|
181 |
-
|
182 |
-
$item->classes[] = $this->li_class;
|
183 |
-
$item->classes[] = $network['class'];
|
184 |
-
|
185 |
-
if ( $this->hide_text ) {
|
186 |
-
$item->title = '<span class="fa-hidden">' . $item->title . '</span>';
|
187 |
-
}
|
188 |
-
|
189 |
-
$item->title = $this->get_icon( $network ) . $item->title ;
|
190 |
-
}
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
return $sorted_menu_items;
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Test output of all FontAwesome icons
|
200 |
-
*/
|
201 |
-
public function fontawesometest( $args ) {
|
202 |
-
include dirname( __FILE__ ) . '/font-awesome-test.html';
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Shortcode to test output of all FontAwesome icons
|
207 |
-
*/
|
208 |
-
public function shortcode_fontawesometest( $args ) {
|
209 |
-
ob_start();
|
210 |
-
$this->fontawesometest();
|
211 |
-
return ob_get_clean();
|
212 |
-
}
|
213 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugin.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Menu Social Icons
|
4 |
+
Description: Change menu links to social sites to icons automatically. Uses <a href="http://fortawesome.github.io/Font-Awesome/" target="_blank">FontAwesome</a> and supports: Bitbucket, Dribbble, Dropbox, Flickr, Foursquare, Gittip, Instagram, RenRen, Stack Overflow, Trello, Tumblr, VK, Weibo, Xing, and YouTube.
|
5 |
+
Version: 1.3
|
6 |
+
Author: Brainstorm Media
|
7 |
+
Author URI: http://brainstormmedia.com
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Copyright (c) 2013 Brainstorm Media. All rights reserved.
|
12 |
+
*
|
13 |
+
* Released under the GPL license
|
14 |
+
* http://www.opensource.org/licenses/gpl-license.php
|
15 |
+
*
|
16 |
+
* This is an add-on for WordPress
|
17 |
+
* http://wordpress.org/
|
18 |
+
*
|
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 as published by
|
22 |
+
* the Free Software Foundation; either version 2 of the License, or
|
23 |
+
* (at your option) any later version.
|
24 |
+
*
|
25 |
+
* This program is distributed in the hope that it will be useful,
|
26 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
27 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
28 |
+
* GNU General Public License for more details.
|
29 |
+
* **********************************************************************
|
30 |
+
*/
|
31 |
+
|
32 |
+
define( 'MSI_PLUGIN_FILE', __FILE__ );
|
33 |
+
define( 'MSI_VERSION', '1.3' );
|
34 |
+
|
35 |
+
add_action( 'init', 'storm_menu_social_icons_init' );
|
36 |
+
|
37 |
+
function storm_menu_social_icons_init() {
|
38 |
+
|
39 |
+
// PHP Version Check
|
40 |
+
$php_is_outdated = version_compare( PHP_VERSION, '5.2', '<' );
|
41 |
+
|
42 |
+
// Only exit and warn if on admin page
|
43 |
+
$okay_to_exit = is_admin() && ( !defined('DOING_AJAX') || !DOING_AJAX );
|
44 |
+
|
45 |
+
if ( $php_is_outdated ) {
|
46 |
+
if ( $okay_to_exit ) {
|
47 |
+
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
48 |
+
deactivate_plugins( __FILE__ );
|
49 |
+
wp_die( sprintf( __( 'Menu Social Icons requires PHP 5.2 or higher, as does WordPress 3.2 and higher. The plugin has now disabled itself. For information on upgrading, %ssee this article%s.', 'menu-social-icons'), '<a href="http://codex.wordpress.org/Switching_to_PHP5" target="_blank">', '</a>') );
|
50 |
+
} else {
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
require_once dirname ( __FILE__ ) . '/classes/msi-frontend.php';
|
56 |
+
require_once dirname ( __FILE__ ) . '/classes/msi-admin.php';
|
57 |
+
|
58 |
+
// Frontend actions
|
59 |
+
add_action( 'template_redirect', 'MSI_Frontend::get_instance' );
|
60 |
+
|
61 |
+
// Admin actions
|
62 |
+
add_action( 'admin_init', 'MSI_Admin::get_instance' );
|
63 |
+
|
64 |
+
}
|
readme.txt
CHANGED
@@ -5,7 +5,8 @@ Author URI: http://brainstormmedia.com
|
|
5 |
Tags: social, icons, menus, FontAwesome, social media, easy
|
6 |
Requires at least: 3.4
|
7 |
Tested up to: 3.6
|
8 |
-
Stable tag: 1.
|
|
|
9 |
|
10 |
Add social icons to your WordPress menu items automatically.
|
11 |
|
@@ -34,35 +35,40 @@ http://www.youtube.com/watch?v=AS3hLeyV4S0
|
|
34 |
* plus.google.com
|
35 |
* renren.com
|
36 |
* stackoverflow.com
|
|
|
37 |
* trello.com
|
38 |
* tumblr.com
|
39 |
* twitter.com
|
|
|
40 |
* vk.com
|
41 |
* weibo.com
|
42 |
* xing.com
|
43 |
* youtube.com
|
44 |
|
45 |
-
**
|
46 |
|
47 |
-
If you want to edit the appearance of the icons in ways that the options below don't provide, you can do more with custom CSS to match your theme.
|
48 |
|
49 |
-
|
50 |
|
51 |
-
|
52 |
|
53 |
-
|
|
|
54 |
|
55 |
-
**
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
Show menu item text in addition to the icons:
|
60 |
`add_filter( 'storm_social_icons_hide_text', '__return_false' );`
|
61 |
|
62 |
-
|
|
|
|
|
63 |
`add_filter( 'storm_social_icons_type', create_function( '', 'return "icon-sign";' ) );`
|
64 |
|
65 |
-
|
|
|
|
|
66 |
|
67 |
add_filter( 'storm_social_icons_size', create_function( '', 'return "normal";' ) );
|
68 |
add_filter( 'storm_social_icons_size', create_function( '', 'return "large";' ) );
|
@@ -70,15 +76,25 @@ Various sizes for icons. Pick one. (Default is 2x).
|
|
70 |
add_filter( 'storm_social_icons_size', create_function( '', 'return "3x";' ) );
|
71 |
add_filter( 'storm_social_icons_size', create_function( '', 'return "4x";' ) );
|
72 |
|
73 |
-
Add
|
|
|
|
|
74 |
|
75 |
add_filter( 'storm_social_icons_networks', 'storm_social_icons_networks');
|
76 |
function storm_social_icons_networks( $networks ) {
|
|
|
77 |
$extra_icons = array (
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
79 |
);
|
|
|
80 |
$extra_icons = array_merge( $networks, $extra_icons );
|
81 |
return $extra_icons;
|
|
|
82 |
}
|
83 |
|
84 |
|
@@ -89,15 +105,26 @@ Add icons from [FontAwesome](http://fortawesome.github.io/Font-Awesome/) for oth
|
|
89 |
|
90 |
== Screenshots ==
|
91 |
|
|
|
92 |
1. Menu without the plugin activated.
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
|
99 |
== Frequently Asked Questions ==
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
= Does this plugin install all of FontAwesome? =
|
102 |
|
103 |
Yes. The plugin installs the complete FontAwesome package. You can use any of the icons in your HTML.
|
@@ -108,24 +135,26 @@ We load FontAwesome onto your site using NetDNA's [Bootstrap CDN](http://www.boo
|
|
108 |
|
109 |
== Changelog ==
|
110 |
|
|
|
|
|
|
|
|
|
|
|
111 |
= 1.2 =
|
112 |
-
*
|
113 |
-
*
|
114 |
* [Thanks to mmcginnis](http://wordpress.org/support/topic/just-works-40) for both of these changes.
|
115 |
|
116 |
= 1.1 =
|
117 |
-
* Upgrade to FontAwesome 3.2.1
|
118 |
-
*
|
119 |
|
120 |
= 1.0 =
|
121 |
* Initial public release.
|
122 |
|
123 |
== Upgrade Notice ==
|
124 |
|
125 |
-
**1.
|
126 |
-
*
|
127 |
-
*
|
128 |
-
*
|
129 |
-
|
130 |
-
**1.1**
|
131 |
-
Add lots of new networks: bitbucket.org, dribbble.com, dropbox.com, flickr.com, foursquare.com, gittip.com, instagram.com, renren.com, stackoverflow.com, trello.com, tumblr.com, vk.com, weibo.com, xing.com, youtube.com
|
5 |
Tags: social, icons, menus, FontAwesome, social media, easy
|
6 |
Requires at least: 3.4
|
7 |
Tested up to: 3.6
|
8 |
+
Stable tag: 1.3
|
9 |
+
License: GPLv2
|
10 |
|
11 |
Add social icons to your WordPress menu items automatically.
|
12 |
|
35 |
* plus.google.com
|
36 |
* renren.com
|
37 |
* stackoverflow.com
|
38 |
+
* stackexchange.com (Requires `storm_social_icons_use_latest`)
|
39 |
* trello.com
|
40 |
* tumblr.com
|
41 |
* twitter.com
|
42 |
+
* vimeo.com (Requires `storm_social_icons_use_latest`)
|
43 |
* vk.com
|
44 |
* weibo.com
|
45 |
* xing.com
|
46 |
* youtube.com
|
47 |
|
48 |
+
**Changing Icon Appearance**
|
49 |
|
50 |
+
If you want to edit the appearance of the icons in ways that the options below don't provide, you can do more with custom CSS to match your theme. This video walks through the process:
|
51 |
|
52 |
+
http://youtube.com/watch?v=hA2rjDwmvms
|
53 |
|
54 |
+
**Option: Add Vimeo and Stack Exchange**
|
55 |
|
56 |
+
To use FontAwesome 4.0, which drops support for **IE7**, but adds **vimeo.com** and **stackexchange.com**, add this to your theme's **functions.php** file:
|
57 |
+
`add_filter( 'storm_social_icons_use_latest', '__return_true' );`
|
58 |
|
59 |
+
**Option: Show Text**
|
60 |
|
61 |
+
To show menu item text in addition to the icons, add this to your theme's **functions.php** file:
|
|
|
|
|
62 |
`add_filter( 'storm_social_icons_hide_text', '__return_false' );`
|
63 |
|
64 |
+
**Option: Alternate Icons**
|
65 |
+
|
66 |
+
To show an alternative icon style, where logos are cut out of signs, , add this to your theme's **functions.php** file:
|
67 |
`add_filter( 'storm_social_icons_type', create_function( '', 'return "icon-sign";' ) );`
|
68 |
|
69 |
+
**Option: Icon Sizes**
|
70 |
+
|
71 |
+
To vary icon sizes, add this to your theme's **functions.php** file: (Default is 2x)
|
72 |
|
73 |
add_filter( 'storm_social_icons_size', create_function( '', 'return "normal";' ) );
|
74 |
add_filter( 'storm_social_icons_size', create_function( '', 'return "large";' ) );
|
76 |
add_filter( 'storm_social_icons_size', create_function( '', 'return "3x";' ) );
|
77 |
add_filter( 'storm_social_icons_size', create_function( '', 'return "4x";' ) );
|
78 |
|
79 |
+
**Option: Add More Icons**
|
80 |
+
|
81 |
+
Add icons from [FontAwesome](http://fontawesome.github.io/Font-Awesome/) for other URLs. For example, an RSS feed:
|
82 |
|
83 |
add_filter( 'storm_social_icons_networks', 'storm_social_icons_networks');
|
84 |
function storm_social_icons_networks( $networks ) {
|
85 |
+
|
86 |
$extra_icons = array (
|
87 |
+
'/feed' => array( // Enable this icon for any URL containing this text
|
88 |
+
'name' => 'RSS', // Default menu item label
|
89 |
+
'class' => 'rss', // Custom class
|
90 |
+
'icon' => 'icon-rss', // FontAwesome class
|
91 |
+
'icon-sign' => 'icon-rss-sign' // May not be available. Check FontAwesome.
|
92 |
+
),
|
93 |
);
|
94 |
+
|
95 |
$extra_icons = array_merge( $networks, $extra_icons );
|
96 |
return $extra_icons;
|
97 |
+
|
98 |
}
|
99 |
|
100 |
|
105 |
|
106 |
== Screenshots ==
|
107 |
|
108 |
+
1. Icons and shortcuts in WordPress Menu Editor.
|
109 |
1. Menu without the plugin activated.
|
110 |
+
1. Menu with default settings.
|
111 |
+
1. Alternative "icon-sign" display.
|
112 |
+
1. Hidden text disabled.
|
113 |
+
1. "normal" icon size
|
114 |
+
1. "4x" icon size
|
115 |
|
116 |
== Frequently Asked Questions ==
|
117 |
|
118 |
+
= Can you add X icon? =
|
119 |
+
|
120 |
+
Menu Social Icons is dependent on the [FontAwesome icon library](http://fontawesome.github.io/Font-Awesome). If an icon exists in FontAwesome, you can add a filter for it using the `storm_social_icons_networks` example shown in the plugin description.
|
121 |
+
|
122 |
+
If an icon does not exist in FontAwesome, you can request see FontAwesome's instructions for [requesting new icons](http://fontawesome.github.io/Font-Awesome/community/#requesting-new-icons).
|
123 |
+
|
124 |
+
= How can I change how the icons are aligned, positioned, colored, sized, etc. =
|
125 |
+
|
126 |
+
See the tutorial video on editing appearance and the code samples for various options in the [plugin description](http://wordpress.org/plugins/menu-social-icons/).
|
127 |
+
|
128 |
= Does this plugin install all of FontAwesome? =
|
129 |
|
130 |
Yes. The plugin installs the complete FontAwesome package. You can use any of the icons in your HTML.
|
135 |
|
136 |
== Changelog ==
|
137 |
|
138 |
+
= 1.3 =
|
139 |
+
* New: Preview icons and shortcuts in the WordPress Menu Editor.
|
140 |
+
* New: vimeo.com and stackexchange.com icons when FontAwesome 4.0 is turned on.
|
141 |
+
* Notice: FontAwesome 4.0 removes support for IE7, so it is off by default. Use the filter `storm_social_icons_use_latest` shown in the readme to turn on FontAwesome 4.0.
|
142 |
+
|
143 |
= 1.2 =
|
144 |
+
* New: Filter for custom icons and URLs.
|
145 |
+
* New: Icon for `mailto:` links.
|
146 |
* [Thanks to mmcginnis](http://wordpress.org/support/topic/just-works-40) for both of these changes.
|
147 |
|
148 |
= 1.1 =
|
149 |
+
* New: Upgrade to FontAwesome 3.2.1
|
150 |
+
* New: ots of new site icons: bitbucket.org, dribbble.com, dropbox.com, flickr.com, foursquare.com, gittip.com, instagram.com, renren.com, stackoverflow.com, trello.com, tumblr.com, vk.com, weibo.com, xing.com, youtube.com
|
151 |
|
152 |
= 1.0 =
|
153 |
* Initial public release.
|
154 |
|
155 |
== Upgrade Notice ==
|
156 |
|
157 |
+
**1.3**
|
158 |
+
* New: Preview icons and shortcuts in the WordPress Menu Editor.
|
159 |
+
* New: vimeo.com and stackexchange.com icons when FontAwesome 4.0 is turned on.
|
160 |
+
* Notice: FontAwesome 4.0 removes support for IE7, so it is off by default. Use the filter `storm_social_icons_use_latest` shown in the readme to turn on FontAwesome 4.0.
|
|
|
|
|
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
CHANGED
Binary file
|
screenshot-4.png
CHANGED
Binary file
|
screenshot-5.png
CHANGED
Binary file
|
screenshot-6.png
CHANGED
Binary file
|
screenshot-7.png
ADDED
Binary file
|