HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/OneDrive/Desktop/wordpress/wp-content/pluginsBK/diyfacebooklike/diyfacebooklike.php
<?php
/*
Plugin Name: DIYFacebookLike
Plugin URI: http://diyonlinesolutions.com
Description: This Plug-in adds the new Facebook Open Graph, better known as the "Like" button to the end of all your WordPress blog posts. This allows your Facebook friends to show what they like.
Version: 1.4.0
Author: DIYOnlineSolutions.com
Author URI: http://DIYOnlineSolutions.com
*/

/*
	DIYFacebookLike class:

	DIYFacebookLike()					constructor
	getInstance()						retrieve singleton reference
	adminMenu()							callback to init admin menu
	setOptions()						sets options saved from configuration page
	editSettings()						shows the form for editing settings
	postContent()						hook function for post contents
	hookHeader()						hook function to display meta tags in header
*/

class DIYFacebookLike
{
	static $_singleton = null;								// singleton reference
	static $_id = 0;

	private $m_fDisplayLike = FALSE;						// when TRUE, display the Facebook Like div

	const PLUGIN_NAME = 'DIY Facebook Like';				// Facebook Like links
	const VERSION = '1.4.0';								// version number

	// define constants

	const HOOK_POST = 'postContent';						// hook function for post content
	const HOOK_HEADER = 'hookHeader';						// hook function for the <head> section
	const HOOK_ADMINMENU = 'adminMenu';						// hook function for admin menu page
	const HOOK_EDITSETTINGS = 'editSettings';				// hook function for edit settings
	const HOOK_SETOPTIONS = 'setOptions';					// hook function for setting options

	// options
	const OPT_FB_USERIDS = 'diy_fblike_userids';			// facebook user id
	const OPT_FB_APPID = 'diy_dblike_appid';				// facebook application id
	const OPT_IFRAME_WID = 'diy_fblike_width';				// facebook like iframe width
	const OPT_IFRAME_HGT = 'diy_fblike_height';				// facebook like iframe height


	// constructor
	function DIYFacebookLike()
	{
		if (self::$_singleton != null)
		{
			return;
		}

		//add_filter
		$sRet = add_action('the_content', array($this, self::HOOK_POST), 10);
		$sRet = add_filter('wp_head', array($this, self::HOOK_HEADER), 10);

		$sRet = add_action('admin_menu', array($this, self::HOOK_ADMINMENU));
		$sRet = add_action('init', array($this, self::HOOK_SETOPTIONS));

		self::$_singleton = $this;
	}


	// getInstance - return previously created instance
	public static function getInstance()
	{
		if (self::$_singleton == null)
			$ref = new DIYFacebookLike();

		return (self::$_singleton);
	}


	// adminMenu - adds the admin menu option to the menu
	public function adminMenu()
	{
		add_options_page('DIY Facebook Like Options', 'DIY Facebook Like', 8, __FILE__, array($this, self::HOOK_EDITSETTINGS));
	}


	// setOptions - called when saving options set by the configuration page
	public function setOptions()
	{

		// saving an edited configuration
		if (!empty($_POST['diy_fblike']))
		{
			if (isset($_POST['fb_user_ids']))
			{
				$sData = $_POST['fb_user_ids'];
				update_option(self::OPT_FB_USERIDS, $sData);
			}

			if (isset($_POST['fb_app_id']))
			{
				$sData = $_POST['fb_app_id'];
				update_option(self::OPT_FB_APPID, $sData);
			}

			if (isset($_POST['fb_iframe_wid']))
			{
				$nData = intval($_POST['fb_iframe_wid']);
				update_option(self::OPT_IFRAME_WID, $nData);
			}

			if (isset($_POST['fb_iframe_hgt']))
			{
				$nData = intval($_POST['fb_iframe_hgt']);
				update_option(self::OPT_IFRAME_HGT, $nData);
			}
		}
	}


	// editSettings - shows the form for editing settings
	public function editSettings()
	{
		$nWidth = intval(get_option(self::OPT_IFRAME_WID));
		$nHeight = intval(get_option(self::OPT_IFRAME_HGT));

		if ($nWidth == 0)
			$nWidth = 260;
		if ($nHeight == 0)
			$nHeight = 81;
?>
      <div id="poststuff" class="metabox-holder">
        <div class="stuffbox" style="width: 95%">
          <h3>DIY Facebook Like Plugin Settings:</h3>
          <div style="padding: 8px">
            <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
            <table width="80%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="210"></td>
                <td></td>
              </tr>
              <tr>
                <td><b>Facebook User Id:</b></td>
                <td><input type="text" id="fb_user_ids" name="fb_user_ids" size="30" value="<?php echo get_option(self::OPT_FB_USERIDS); ?>" /></td>
              </tr>
              <tr>
                <td></td>
                <td>
                  <p>Don't know your Facebook User Id? You can use the <a href="http://apps.facebook.com/whatismyid/"
                  target="facebook">What is My Id</a> Facebook Application. Activate the <a href="http://apps.facebook.com/whatismyid/"
                  target="facebook">What is My Id</a> application and then it will
                  display your user id. Copy that user id and paste it into the space above.</p>
                  <p><b>Note: </b>The Facebook Like button area will not be displayed with your blog
                  posts until the <b>User Id</b> is entered.</p>
<?php /*
                  <p>You can include multiple User Ids if you like, just use a comma (,) to separate them.</p>
                  <p>Each User Id listed will be allowed to manage the pages that people "Like" through the Facebook
                  Like button added to your pages.</p>
*/ ?>
                  <p>To manage pages that people have liked, go to your <a href="http://www.facebook.com/pages/manage/"
                  target="facebook">Facebook Pages You Admin</a> page
                </td>
              </tr>
<?php /*
              <tr>
                <td><b>Facebook App Id:</b></td>
                <td><input type="text" name="fb_app_id" size="30" value="<?php echo get_option(self::OPT_FB_APPID); ?>" /></td>
              </tr>
              <tr>
                <td></td>
                <td>
                  <p>If you are using a Facebook Application and would like to administer the pages that people "Like"
                  via that Application, you can enter the Application Id here.</p>
                  <p>If you are planning on using the Application Id to manage the pages, be sure to clear out the
                  <b>Facebook User Ids</b> field.</p>
                  <p><b>Note: </b>The Facebook Like button area will not be displayed until either <b>User Ids</b>
                  or an <b>App Id</b> is entered.</p>
                </td>
              </tr>
*/ ?>
              <tr>
                <td><b>Width of Like button Area</b></td>
                <td><input type="text" name="fb_iframe_wid" size="4" value="<?php echo $nWidth; ?>" /></td>
              </tr>
              <tr>
                <td><b>Height of Like Button Area</b></td>
                <td><input type="text" name="fb_iframe_hgt" size="4" value="<?php echo $nHeight; ?>" /></td>
              </tr>
              <tr>
                <td></td>
                <td>
                  <p>The <b>Width</b> and <b>Height</b> settings here define how large an area on the page will
                  be used by the Facebook Like button. The larger the area, the more names of people who have
                  "Liked" your content will appear.</p>
                  <p>We suggest a size of 260 wide by 81 high to start.</p>
                </td>
              </tr>
              <tr>
                <td></td>
                <td>
                  <p class="submit">
                    <input class="button-primary" type="submit" name="diy_fblike" value=" Save Settings "/>
                  </p>
                </td>
              </tr>
            </table>
            </form>
            <script type="text/javascript">
              document.getElementById("fb_user_ids").focus();
            </script>
          </div>
        </div>
      </div>
<?php
	}


	// postContent - hook function for a post's content
	public function postContent($sContent)
	{
		if (!$this->m_fDisplayLike)							// if there is no proper configuration
			return ($sContent);								// exit without displaying the IFRAME

		$nWidth = intval(get_option(self::OPT_IFRAME_WID));
		$nHeight = intval(get_option(self::OPT_IFRAME_HGT));
		if ($nWidth == 0)
			$nWidth = 260;
		if ($nHeight == 0)
			$nHeight = 81;

		$sUrl = urlencode(get_permalink());

		$sCredit = '<span class="diyfacebooklikemsg">Plugin developed by <a href="http://www.diyonlinesolutions.com/products/facebook-like-wordpress-plugin/" target="diy">DIY Online Solutions</a>.</span>';
		$sCredit = '<span class="diyfacebooklikemsg"><a href="http://www.diyonlinesolutions.com/products/facebook-like-wordpress-plugin/" target="diy">Facebook Like Plugin developed by DIY Online Solutions</a>.</span>';

		$sFacebook = '<div class="diyfacebooklikewrapper" align="center"><div class="diyfacebooklike" style="width: ' . $nWidth . 'px">';
		$sFacebook .= '<iframe id="iframe_like' . ++self::$_id . '" name="iframe_like' . self::$_id . '"';
		$sFacebook .= ' class="facebook_iframe" scrolling="no" frameborder="0"';
		$sFacebook .= ' width="' . $nWidth . '" height="' . $nHeight . '" allowtransparency="true"';
		$sFacebook .= ' src="http://www.facebook.com/widgets/like.php?width=' . $nWidth;
		$sFacebook .= '&amp;action=like&amp;show_faces=1&amp;layout=standard&amp;colorscheme=light&amp;';
		$sFacebook .= 'href=' . $sUrl . '"></iframe>'                                                                                . $sCredit;
		$sFacebook .= '</div></div>';

		return ($sContent . $sFacebook);
	}


	// hookHeader - hook function for the <head> section
	public function hookHeader()
	{

		$sTitle = trim(wp_title('', false));
		if ($sTitle == '')
			$sTitle = get_bloginfo('name');

		$sType = 'blog';
		$sImage = WP_PLUGIN_URL . '/diyfacebooklike/images/facebook_logo.jpg';

		$arParse = parse_url(get_bloginfo('url'));
		$sUrl = 'http://' . $arParse['host'] . $_SERVER['REQUEST_URI'];

		$sSiteName = get_bloginfo('name');

		$sUsers = get_option(self::OPT_FB_USERIDS);
		if (!empty($sUsers))
		{
			$sIdent = 'fb:admins';
			$sContent = $sUsers;
		}
		else
		{
			$sIdent = 'fb:app_id';
			$sContent = get_option(self::OPT_FB_APPID);
		}

		if (empty($sContent))
			return;											// no configuration - don't display the IFRAME
		$this->m_fDisplayLike = TRUE;						// good configuration - display the IFRAME

		$sDescrip = trim(wp_title('', false)); // get_bloginfo('description');

?>
<!-- meta tags for the DIY Facebook Like plugin from www.diyonlinesolutions.com -->
<link rel="stylesheet" type="text/css" href="<?php bloginfo('url'); ?>/wp-content/plugins/diyfacebooklike/diyfacebooklike.css" />
<meta property="<?php echo $sIdent; ?>" content="<?php echo $sContent; ?>" />
<meta property="og:title" content="<?php echo $sTitle; ?>"/>
<meta property="og:type" content="<?php echo $sType; ?>" />
<meta property="og:image" content="<?php echo $sImage; ?>" />
<meta property="og:url" content="<?php echo $sUrl; ?>" />
<meta property="og:site_name" content="<?php echo $sSiteName; ?>" />
<meta property="og:description" content="<?php echo $sDescrip; ?>" />
<!-- end of meta tags for DIY Facebook Like plugin -->

<?php
	}
}

$diyfacebooklike = DIYFacebookLike::getInstance();

?>