Version Description
- New: Remove templates folder. Replace with filters
storm_social_icons_title_html
andstorm_social_icons_icon_html
. Add example of corewp_nav_menu_objects
filter to readme.
Download this release
Release Info
Developer | pdclark |
Plugin | Menu Social Icons |
Version | 1.3.7 |
Comparing to | |
See all releases |
Code changes from version 1.3.6 to 1.3.7
- classes/msi-frontend.php +14 -29
- plugin.php +2 -2
- readme.txt +61 -6
classes/msi-frontend.php
CHANGED
@@ -182,10 +182,17 @@ class MSI_Frontend {
|
|
182 |
|
183 |
/**
|
184 |
* Hide text visually, but keep available for screen readers.
|
185 |
-
* Just
|
186 |
*/
|
187 |
public function wp_print_scripts() {
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
|
191 |
/**
|
@@ -200,7 +207,9 @@ class MSI_Frontend {
|
|
200 |
$icon = $network[ $this->type ];
|
201 |
$show_text = $this->hide_text ? '' : 'fa-showtext';
|
202 |
|
203 |
-
|
|
|
|
|
204 |
|
205 |
}
|
206 |
|
@@ -222,7 +231,8 @@ class MSI_Frontend {
|
|
222 |
$item->classes[] = $network['class'];
|
223 |
|
224 |
if ( $this->hide_text ) {
|
225 |
-
$
|
|
|
226 |
}
|
227 |
|
228 |
$item->title = $this->get_icon( $network ) . $item->title ;
|
@@ -253,31 +263,6 @@ class MSI_Frontend {
|
|
253 |
return $networks;
|
254 |
}
|
255 |
|
256 |
-
/**
|
257 |
-
* Load HTML template from templates directory.
|
258 |
-
* Contents of $args are turned into variables for use in the template.
|
259 |
-
*
|
260 |
-
* For example, $args = array( 'foo' => 'bar' );
|
261 |
-
* becomes variable $foo with value 'bar'
|
262 |
-
*/
|
263 |
-
static public function get_template( $file, $args = array() ) {
|
264 |
-
extract( $args );
|
265 |
-
|
266 |
-
$locations = array(
|
267 |
-
'theme_file' => get_stylesheet_directory() . "/msi-templates/$file.php",
|
268 |
-
'plugin_file' => dirname( dirname( __FILE__ ) ) . "/msi-templates/$file.php",
|
269 |
-
);
|
270 |
-
|
271 |
-
foreach ( $locations as $file ) {
|
272 |
-
if ( file_exists( $file ) ) {
|
273 |
-
ob_start();
|
274 |
-
include $file;
|
275 |
-
$output = ob_get_clean();
|
276 |
-
return $output;
|
277 |
-
}
|
278 |
-
}
|
279 |
-
}
|
280 |
-
|
281 |
/**
|
282 |
* Test output of all FontAwesome icons
|
283 |
*/
|
182 |
|
183 |
/**
|
184 |
* Hide text visually, but keep available for screen readers.
|
185 |
+
* Just a few 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 |
+
.rtl .fa-hidden { left:10000px; }
|
193 |
+
.fa-showtext { margin-right: 5px; }
|
194 |
+
</style>
|
195 |
+
<?php
|
196 |
}
|
197 |
|
198 |
/**
|
207 |
$icon = $network[ $this->type ];
|
208 |
$show_text = $this->hide_text ? '' : 'fa-showtext';
|
209 |
|
210 |
+
$html = "<i class='$size $icon $show_text'></i>";
|
211 |
+
|
212 |
+
return apply_filters( 'storm_social_icons_icon_html', $html, $size, $icon, $show_text );
|
213 |
|
214 |
}
|
215 |
|
231 |
$item->classes[] = $network['class'];
|
232 |
|
233 |
if ( $this->hide_text ) {
|
234 |
+
$html = "<span class='fa-hidden'>$title</span>";
|
235 |
+
$item->title = apply_filters( 'storm_social_icons_title_html', $html, $item->title );
|
236 |
}
|
237 |
|
238 |
$item->title = $this->get_icon( $network ) . $item->title ;
|
263 |
return $networks;
|
264 |
}
|
265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
/**
|
267 |
* Test output of all FontAwesome icons
|
268 |
*/
|
plugin.php
CHANGED
@@ -2,7 +2,7 @@
|
|
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 |
License: GPLv2 or later
|
@@ -10,7 +10,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
10 |
*/
|
11 |
|
12 |
define( 'MSI_PLUGIN_FILE', __FILE__ );
|
13 |
-
define( 'MSI_VERSION', '1.3.
|
14 |
|
15 |
add_action( 'init', 'storm_menu_social_icons_init' );
|
16 |
|
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.7
|
6 |
Author: Brainstorm Media
|
7 |
Author URI: http://brainstormmedia.com
|
8 |
License: GPLv2 or later
|
10 |
*/
|
11 |
|
12 |
define( 'MSI_PLUGIN_FILE', __FILE__ );
|
13 |
+
define( 'MSI_VERSION', '1.3.7' );
|
14 |
|
15 |
add_action( 'init', 'storm_menu_social_icons_init' );
|
16 |
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ 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.7.1
|
8 |
-
Stable tag: 1.3.
|
9 |
License: GPLv2
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -73,7 +73,7 @@ Add icons from [FontAwesome](http://fortawesome.github.io/Font-Awesome/) for oth
|
|
73 |
function storm_social_icons_networks( $networks ) {
|
74 |
|
75 |
$extra_icons = array (
|
76 |
-
|
77 |
'name' => 'RSS', // Default menu item label
|
78 |
'class' => 'rss', // Custom class
|
79 |
'icon' => 'icon-rss', // FontAwesome class
|
@@ -88,9 +88,60 @@ Add icons from [FontAwesome](http://fortawesome.github.io/Font-Awesome/) for oth
|
|
88 |
|
89 |
**Option: Change HTML Output**
|
90 |
|
91 |
-
|
92 |
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
== Installation ==
|
96 |
|
@@ -129,6 +180,10 @@ We load FontAwesome onto your site using NetDNA's [Bootstrap CDN](http://www.boo
|
|
129 |
|
130 |
== Changelog ==
|
131 |
|
|
|
|
|
|
|
|
|
132 |
= 1.3.6 =
|
133 |
|
134 |
* New: Allow themes to override HTML output with msi-templates directory.
|
@@ -173,6 +228,6 @@ We load FontAwesome onto your site using NetDNA's [Bootstrap CDN](http://www.boo
|
|
173 |
|
174 |
== Upgrade Notice ==
|
175 |
|
176 |
-
= 1.3.
|
177 |
|
178 |
-
* New:
|
5 |
Tags: social, icons, menus, FontAwesome, social media, easy
|
6 |
Requires at least: 3.4
|
7 |
Tested up to: 3.7.1
|
8 |
+
Stable tag: 1.3.7
|
9 |
License: GPLv2
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
73 |
function storm_social_icons_networks( $networks ) {
|
74 |
|
75 |
$extra_icons = array (
|
76 |
+
'/feed' => array( // Enable this icon for any URL containing this text
|
77 |
'name' => 'RSS', // Default menu item label
|
78 |
'class' => 'rss', // Custom class
|
79 |
'icon' => 'icon-rss', // FontAwesome class
|
88 |
|
89 |
**Option: Change HTML Output**
|
90 |
|
91 |
+
This is useful for developers using the plugin with custom icon sets.
|
92 |
|
93 |
+
Edit icon HTML output:
|
94 |
+
`
|
95 |
+
add_filter( 'storm_social_icons_icon_html', 'storm_social_icons_icon_html', 10, 4 );
|
96 |
+
|
97 |
+
function storm_social_icons_icon_html( $html, $size, $icon, $show_text ) {
|
98 |
+
$html = "<i class='$size $icon $show_text'></i>";
|
99 |
+
return $html;
|
100 |
+
}
|
101 |
+
`
|
102 |
+
|
103 |
+
Edit title HTML output:
|
104 |
+
`
|
105 |
+
add_filter( 'storm_social_icons_title_html', 'storm_social_icons_title_html', 10, 2 );
|
106 |
+
|
107 |
+
function storm_social_icons_title_html( $html, $title ){
|
108 |
+
$html = "<span class='fa-hidden'>$title</span>";
|
109 |
+
return $html;
|
110 |
+
}
|
111 |
+
`
|
112 |
+
|
113 |
+
Edit all link attributes (WordPress core filter):
|
114 |
+
|
115 |
+
`
|
116 |
+
add_filter( 'wp_nav_menu_objects', 'storm_wp_nav_menu_objects', 7, 2 );
|
117 |
+
|
118 |
+
function storm_wp_nav_menu_objects( $sorted_menu_items, $args ){
|
119 |
+
|
120 |
+
foreach( $sorted_menu_items as &$item ) {
|
121 |
+
|
122 |
+
if ( 0 != $item->menu_item_parent ) {
|
123 |
+
// Skip submenu items
|
124 |
+
continue;
|
125 |
+
}
|
126 |
+
|
127 |
+
// Only apply changes to links containing this text.
|
128 |
+
$search_url = 'facebook.com';
|
129 |
+
|
130 |
+
if ( false !== strpos( $item->url, $search_url ) ) {
|
131 |
+
|
132 |
+
// Add a custom class
|
133 |
+
$item->classes[] = 'some-custom-class';
|
134 |
+
|
135 |
+
// Add custom HTML inside the link
|
136 |
+
$item->title = '<strong>custom html</strong>' . $item->title;
|
137 |
+
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
return $sorted_menu_items;
|
142 |
+
|
143 |
+
}
|
144 |
+
`
|
145 |
|
146 |
== Installation ==
|
147 |
|
180 |
|
181 |
== Changelog ==
|
182 |
|
183 |
+
= 1.3.7 =
|
184 |
+
|
185 |
+
* New: Remove templates folder. Replace with filters `storm_social_icons_title_html` and `storm_social_icons_icon_html`. Add example of core `wp_nav_menu_objects` filter to readme.
|
186 |
+
|
187 |
= 1.3.6 =
|
188 |
|
189 |
* New: Allow themes to override HTML output with msi-templates directory.
|
228 |
|
229 |
== Upgrade Notice ==
|
230 |
|
231 |
+
= 1.3.7 =
|
232 |
|
233 |
+
* New: Remove templates folder. Replace with filters `storm_social_icons_title_html` and `storm_social_icons_icon_html`. Add example of core `wp_nav_menu_objects` filter to readme.
|