MyBB Community Forums

Full Version: Facebook Like Button 1.0 - show only on index.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,


Could someone modify this plugin, that Like button will be shown only on index.php (Homepage of forum)? Cause loading plugin on all pages slows down browsing speed.

Any help would be appreciated.

<?php
/********************************************************************************
 *
 *  Facebook Like plugin (/inc/plugins/FB_like.php)
 *  Author: Pratik Unadkat (crazy4cs)
 *  Copyright: © 2011 Pratik Unadkat (crazy4cs)
 *  
 *  Website: http://www.mybbworld.net , http://www.ubers.org/
 *  License: license.txt
 *  Any codes in this plugin are copyrighted and not allowed to be reproduced.
 * 
 *  Allows you to add a Facebook like button on your website.
 *
 ********************************************************************************/


if(!defined("IN_MYBB"))
	die("This file cannot be accessed directly.");

// add hooks

function FB_like_info()
{
	return array(
		"name"			=> "Facebook Like Button",
		"description"	=> "Allows you to add a Facebook like button in header on your website.",
		"website"		=> "http://www.ubers.org",
		"author"		=> "Pratik Unadkat (crazy4cs)",
		"authorsite"	=> "http://www.ubers.org",
		"version"		=> "1.0",
		"guid" 		=> "",
		"compatibility"	=> "*"
	);
}


function FB_like_activate()
{
	global $db, $lang;
      require MYBB_ROOT."/inc/adminfunctions_templates.php";
	$insertarray = array(
		'name' => 'Facebook_Like', 
		'title' => 'FB Like', 
		'description' => "Settings for FB Like", 
		'disporder' => 1, 
		'isdefault' => 0
	);
	$gid = $db->insert_query("settinggroups", $insertarray);
	// add settings

	$furl = array(
		"sid"			=> NULL,
		"name"			=> "FB_like_url",
		"title"			=> "URL",
		"description"	=> "Enter the Facebook Like Page URL here.",
		"optionscode"	=> "textarea",
		"value"			=> "",
		"disporder"		=> 1,
		"gid"			=> intval($gid)
	);

	$db->insert_query("settings", $furl);
	rebuild_settings();

    require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
    find_replace_templatesets("header", "#".preg_quote("{\$pending_joinrequests}")."#i", "{\$pending_joinrequests}{\$flike}");

}

function FB_like_deactivate()
{
    global $db, $mybb;
    $db->delete_query("settinggroups", "name='Facebook_Like'");
    $db->delete_query('settings', 'name IN ( \'FB_like_url\')');

	
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("header", "#".preg_quote('{$flike}')."#i", '', 0);


	rebuild_settings();

}

$plugins->add_hook("global_start", "flike");
function flike()
{
    global $mybb, $templates,  $flike;
    $flike = '<br /><div align="center"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="'.$mybb->settings['FB_like_url'].'" show_faces="false" width="500" font="arial"></fb:like></script></div><br />';
}

?>
(2013-05-06, 03:21 PM)brad-t Wrote: [ -> ]You could just manually add a like button to your index. It's pretty easy.

Done. It was really easy. Thanks.