Skip to Content


A convenient way to implement social media “like”, “share”, and “tweet” buttons for Facebook, Twitter, LinkedIn, and Pinterest.

PHP February 14, 2019


nebula()->social($networks, $counts)


(Optional) (String or Array) An array of which networks' buttons to use.
Default: Facebook, Twitter

(Optional) (Boolean) Whether to show the number of "likes", "shares", etc.
Default: false

Request or provide clarification »


Using a single network

<?php nebula()->social('facebook'); ?>

Only show "like" counts to developers and clients.

<?php nebula()->social(array('facebook', 'twitter'), nebula()->is_staff()); ?>


Source File

Located in /libs/Functions.php on line 1056.

1 Hook

Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.

Need a new filter hook? Request one here.

This function has no action hooks available. Request one?

        public function social($networks=array('shareapi', 'facebook', 'twitter'), $counts=0){
            $override = apply_filters('pre_nebula_social', null, $networks, $counts);
            if ( isset($override) ){return;}

            if ( is_string($networks) ){ //if $networks is a string, create an array for the string.
                $networks = array($networks);
            } elseif ( is_int($networks) && ($networks === 1 || $networks === 0) ){ //If it is an integer of 1 or 0, then set it to $counts
                $counts = $networks;
                $networks = array('shareapi', 'facebook', 'twitter');
            } elseif ( !is_array($networks) ){
                $networks = array('shareapi', 'facebook', 'twitter');

            //Convert $networks to lower case without dashes/spaces for more flexible string matching later.
            $networks = array_map(function($value){
                return str_replace(array(' ', '_', '-'), '', strtolower($value));
            }, $networks);

            echo '<div class="sharing-links">';

            //If the 'shareapi' cookie and 'shareapi' is requested, return *only* the Share API
            if ( isset($this->super->cookie['shareapi']) || in_array($networks, array('shareapi')) ){
                $networks = array('shareapi');

            foreach ( $networks as $network ){
                //Share API
                if ( in_array($network, array('shareapi')) ){

                if ( in_array($network, array('facebook', 'fb')) ){

                if ( in_array($network, array('twitter')) ){

                if ( in_array($network, array('linkedin', 'li')) ){

                if ( in_array($network, array('pinterest', 'pin')) ){

            echo '</div><!--/sharing-links-->';


To override this PHP function, use this hook in your child theme or plugin ("my_custom" can be changed):

add_filter('pre_nebula_social', 'my_custom_social', 10, 3); //The last integer must be 1 more than the actual parameters
function my_custom_social($null, $networks, $counts){ //$null is required, but can be ignored
    //Write your own code here

    return true; //Return true to prevent the original function from running afterwords

You can completely disable this PHP function with a single line actions:

 add_filter('pre_nebula_social', '__return_false');