Tycoon_Hosting

JobRoller Social Widget Counter

Nov 22nd, 2012
134
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Hello everyone, today I'm going to show you how you can add an impressive looking Twitter and Facebook widget counter to your JobRoller sidebar. It will look something like this..
  2.  
  3. http://forums.appthemes.com/attachment.php?attachmentid=4194&d=1352046137&thumb=1
  4.  
  5. If you have access to the AppThemes forum, this tutorial can also be found here: http://forums.appthemes.com/jobroller-social-widget-counter-39383/
  6.  
  7. It's important to know that this was done to my websites child-theme, and that I highly don't recommend doing this to your native JobRoller files. Should you choose to go against my advise, it's important to understand that any changes you make to the JobRoller folder and any of it's files, will be overwritten by the AppThemes updater, should a new copy of JobRoller be released.
  8.  
  9. Okay, lets begin..
  10.  
  11. STEP 1: OUR FRAMEWORK
  12. First, you will need to create a new php file.. I named mine "sidebar-social-count.php", add the following code into your file, and change the user id "jobortunity" to whatever your user name is on Twitter or Facebook. Once you've done this, save the file in the /includes/ folder.
  13.  
  14. <li class="widget widget-social-count">
  15.  
  16. <div class="counter-widget-wrapper">
  17.  
  18. <a rel="nofollow" href="https://www.facebook.com/jobortunity" class="counter ">
  19. <span class="icon"><img alt="Facebook" src="<?php bloginfo('stylesheet_directory'); ?>/images/facebook-count-icon.png" /></span>
  20. <span class="count facebook"></span>
  21. <span class="title">Fans</span>
  22. </a>
  23.  
  24. <a rel="nofollow" href="http://twitter.com/jobortunity" class="counter">
  25. <span class="icon"><img alt="Twitter" src="<?php bloginfo('stylesheet_directory'); ?>/images/twitter-count-icon.png" /></span>
  26. <span class="count twitter"></span>
  27. <span class="title">Followers</span>
  28. </a>
  29.  
  30. </div>
  31.  
  32. <script type="text/javascript">
  33. /* <![CDATA[ */
  34.  
  35. jQuery(document).ready(function() {
  36. jQuery.getJSON('https://graph.facebook.com/jobortunity', function(data) {
  37. jQuery('span.facebook').text(data.likes + 1 + ' ');
  38. });
  39.  
  40. jQuery.getJSON("https://api.twitter.com/1/users/show.json?callback=?&screen_name=jobortunity", function(data) {
  41. jQuery('span.twitter').text(data.followers_count + 1 + ' ');
  42. });
  43.  
  44. });
  45.  
  46. /* ]]> */
  47.  
  48. </script>
  49. </li>
  50.  
  51. STEP 2: FETCH OUR WIDGET FILE FOR DISPLAY
  52. Go to the root of your child-theme and find "sidebar.php", open the file and add the following code on line 4.
  53.  
  54. <?php get_template_part( 'includes/sidebar-social-count' ); ?>
  55.  
  56. Hit Save, and close this file, you're done here.
  57.  
  58. STEP 3: CSS LOVE
  59. While still in the root of the child-theme visit the "style.css" file and add the following code in the widgets parameter.. Just search for /* =Widgets and you should be in the right place
  60.  
  61. /*-- Begin: Social Count Widget --*/
  62. ul.widgets li.widget-social-count { padding: 0 !important; width: 260px; border-top: 0; border-bottom: 1px solid #E4E4E4; }
  63. ul.widgets li.widget-social-count div.counter-widget-wrapper { margin: 0; padding: 10px 0 0; }
  64.  
  65. ul.widgets li.widget-social-count a { text-decoration: none !important; }
  66. ul.widgets li.widget-social-count a.counter { float:left; text-align:center; width:33.33%; padding: 0 0 10px; }
  67.  
  68. ul.widgets li.widget-social-count a.counter span { display:block; font-style:italic; font-weight:bold; line-height: 20px; margin:0 10px; }
  69. ul.widgets li.widget-social-count a.counter span.icon { margin: 0; padding: 0; }
  70. ul.widgets li.widget-social-count a.counter span.count { color: #C23A3A; font-size: 15px; height: 20px; margin: 0 auto; width: 100%; }
  71. ul.widgets li.widget-social-count a.counter span.title { color:#5C5C5C; height: 20px; }
  72. /*-- End: Social Count Widget --*/
  73.  
  74. STEP 4: OUR ICONS!
  75. Follow the links, and Save the following icons to your "/images/" folder inside the child-theme.. Should you want to use your own icons, you're more then welcome to do so, but for the purpose of this tutorial I'm sharing my icons.
  76.  
  77. Facebook: http://postimage.org/image/52gn7s15t/
  78. Twitter: http://postimage.org/image/78ay2a4m9/
  79.  
  80. And that's it, you're done. Refresh your websites browser, and take a look at your new social widget counter.. Enjoy.
  81.  
  82. ##### UPDATE #################################################################################
  83.  
  84. Here's an extra, I just added.. it's for "Delicious Bookmarks" should any of you use it..
  85. STEP 1: HTML/PHP
  86.  
  87. Add the following html code under the twitter hyperlink, before "</div>"
  88.  
  89. <a rel="nofollow" href="http://delicious.com/jobortunity" class="counter">
  90. <span class="icon"><img alt="Delicious" src="< ?php bloginfo('stylesheet_directory'); ?>/images/delicious-count-icon.png" /></span>
  91. <span class="count delicious"></span>
  92. <span class="title">Bookmarks</span>
  93. </a>
  94.  
  95. STEP 2: JQUERY LOVE
  96. Add the following code to the jQuery script before the ending "}); /* ]]> */", make sure to edit out the jobortunity url to your websites url..
  97.  
  98. jQuery.getJSON('http://feeds.delicious.com/v2/json/urlinfo/data?url=http://jobortunity.ca/&amp;callback=?', function(data) {
  99. var count = 0; if (data.length > 0) { count = data[0].total_posts; }
  100. jQuery('span.delicious').text(count);
  101. });
  102.  
  103. P.S.
  104. I'm also trying to make the FeedBurner code work, for some reason I can't seem to get it to work for my feed.. but here's the code, should anyone wish to try and make it work for their feeds.. just so you know the Awareness API has been depreciated, but it's still active, just no support from Google. But if you get it working before I do, I would appreciate a follow up post of your updated code.
  105.  
  106. jQuery.getJSON("http://feeds.feedburner.com/jobortunity?format=xml", function(count) {
  107. jQuery('span.feedburner').text(count['xml']['feed']['entry']['attributes'].circulation);
  108. });
RAW Paste Data