-
-
Save robincornett/1c928950b44526c9b0d668bec59defaa to your computer and use it in GitHub Desktop.
Sort the networks/buttons in Scriptless Social Sharing in your own custom order.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'scriptlesssocialsharing_networks', 'prefix_sort_networks_alpha' ); | |
/** | |
* A function to reorder the social networks alphabetically for Scriptless Social Sharing. | |
* | |
* @author Robin Cornett | |
* @param $networks | |
* | |
* @return mixed | |
*/ | |
function prefix_sort_networks_alpha( $networks ) { | |
asort( $networks ); | |
return $networks; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'scriptlesssocialsharing_networks', 'prefix_sort_networks_custom' ); | |
/** | |
* A function to reorder the social networks for Scriptless Social Sharing. | |
* Set a value for each network order. 0 is first. | |
* @author Robin Cornett | |
* @param $networks | |
* | |
* @return mixed | |
*/ | |
function prefix_sort_networks_custom( $networks ) { | |
$networks['email']['order'] = 7; | |
$networks['facebook']['order'] = 1; | |
$networks['google']['order'] = 2; | |
$networks['linkedin']['order'] = 4; | |
$networks['reddit']['order'] = 0; | |
$networks['twitter']['order'] = 6; | |
$networks['pinterest']['order'] = 5; | |
uasort( $networks, 'prefix_set_scriptless_sort_order' ); | |
return $networks; | |
} | |
/** | |
* Custom comparison function to sort the networks. | |
* @param $a | |
* @param $b | |
* | |
* @return bool | |
*/ | |
function prefix_set_scriptless_sort_order( $a, $b ) { | |
return $a['order'] > $b['order']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment