Topic on Extension talk:Social Sidebar

I tweaked the extension to support linkedin and +1

1
Robpol86 (talkcontribs)

This extension was exactly what I was looking for, however I tweaked it a little to fit my needs. Perhaps you can merge my changes into your code for others to use? Everything is hard coded since it's only for me so it needs to be cleaned up a little bit.

<?php
/**
 * MediaWiki extension to add a social sidebar in a portlet in the sidebar.
 * Installation instructions can be found on
 * https://www.mediawiki.org/wiki/Extension:Social_Sidebar
 *
 * This extension will not add the Social Sidebar portlet to *any* skin
 * that is used with MediaWiki. Because of inconsistencies in the skin
 * implementation, it will not be add to the following skins:
 * cologneblue, standard, nostalgia
 *
 * @addtogroup Extensions
 * @author Joachim De Schrijver
 * @license LGPL
 *
 * Social Sidebar
 */

/**
 * Exit if called outside of MediaWiki
 */
if( !defined( 'MEDIAWIKI' ) ) {
        echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
        die( 1 );
}

/**
 * SETTINGS
 * --------
 * The description of the portlet can be changed in [[MediaWiki:Socialsidebar]].
 */

$wgExtensionCredits['other'][] = array(
        'name'           => 'Social Sidebar',
        'version'        => '0.2',
        'author'         => '[https://www.mediawiki.org/wiki/User:Joa_ds Joachim De Schrijver]',
        'description'    => 'Adds [http://www.twitter.com Twitter] and [http://www.facebook.com Facebook] links to the sidebar',
        'url'            => 'https://www.mediawiki.org/wiki/Extension:Social_Sidebar',
);

// Hook to modify the sidebar
$wgHooks['SkinBuildSidebar'][] = 'SocialSidebar::SocialLinks';

// Class & functions
class SocialSidebar {
        function SocialLinks( $skin, &$bar ) {
                $bar['Social']  = "\n";
    
                // Facebook
                $bar['Social']  .= '<div id="fb-root"></div><script>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];\
if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";\
fjs.parentNode.insertBefore(js, fjs);}(document, "script", "facebook-jssdk"));</script><div class="fb-like" data-send="false" \
data-layout="button_count" data-width="140" data-show-faces="false"></div>'."\n\n";

                // Twitter
                $bar['Social'] .= '<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a><script>!function(d,s,id)\
{var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";\
fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>'."\n\n";

                // Linked In
                $bar['Social'] .= '<script src="//platform.linkedin.com/in.js" type="text/javascript"></script>\
<script type="IN/Share" data-counter="right"></script>'."\n\n";

                // +1
                $bar['Social'] .= '<g:plusone size="medium" annotation="inline" width="140"></g:plusone>\
<script type="text/javascript">(function() {var po = document.createElement("script"); po.type = "text/javascript"; \
po.async = true;po.src = "https://apis.google.com/js/plusone.js";var s = document.getElementsByTagName("script")[0]; \
s.parentNode.insertBefore(po, s);})();</script>'."\n\n";

                return true;
        }
}
Reply to "I tweaked the extension to support linkedin and +1"