Extension:FacebookLikeButton
| This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net. |
| WARNING: The code or configuration described here poses a major security risk.
Site administrators: You are advised against using it until this security issue is resolved. Problem: Vulnerable to Cross-site scripting attacks, because it passes user input directly to the browser. This may lead to user accounts being hijacked, among other things. Solution: strictly validate user input and/or apply escaping to all characters that have a special meaning in HTML |
|
FacebookLikeButton Release status: stable |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | Creates a Facebook Like and/or Send button(s). | ||
| Author(s) | Piotr Zuk, Jmkim dot com | ||
| Last version | 1.1.0 (2012-08-16) | ||
| MediaWiki | 1.16 | ||
| License | GNU public License | ||
| Download | FacebookLikeButton.tgz | ||
| Example | http://jmnote.com/wiki/FacebookLikeButton | ||
|
|||
| Check usage and version matrix | |||
Contents |
What can this extension do? [edit]
Allows you to very simply include Facebook Like and/or Send button(s).
Usage [edit]
With the tag <fblike></fblike>
- button_count : <fblike/> (with horizontal counting box. default)
- box_count: <fblike layout="box_count"/> (with vertical counting box)
- standard: <fblike layout="standard"/> (without counting box)
Default layout = button_count (with horizontal counting box) and without send button ( send = false ).
Set send="true" to see the makes the Send button visible.
Download instructions [edit]
You can download the php file from FacebookLikeButton.tgz or copy and paste the code below to the file: $IP/extensions/FacebookLikeButton/FacebookLikeButton.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
Installation [edit]
To install this extension, add the following to LocalSettings.php:
require_once("$IP/extensions/FacebookLikeButton/FacebookLikeButton.php");
Code [edit]
<?php /* Wiki FacebookLikeButton MediaWiki extension * Installation Instructions: http://www.mediawiki.org/wiki/Extension:FacebookLikeButton * 2012-08-16 Article URL support. The tag changed. HTML5 code. * For another language support, "en_US" can be replaced by "de_DE", "ja_JP" or "ko_KR". */ $wgExtensionFunctions[] = "facebooklikebuttonExtension"; function FacebookLikeButtonUrl() { $protocol = 'http'; $port = '80'; if ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) { $protocol = 'https'; $port = '443'; } $port = $_SERVER['SERVER_PORT'] == $port ? '' : ':' . $_SERVER['SERVER_PORT']; return $protocol . '://' . $_SERVER['HTTP_HOST'] . $port . $_SERVER['SCRIPT_NAME']; } function facebooklikebuttonExtension() { global $wgParser; global $FacebookLikeButtonOnce; $wgParser->setHook( "fblike", "renderFacebookLikeButton" ); $FacebookLikeButtonOnce='<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>'; } function renderFacebookLikeButton( $input, $argv ) { global $wgRequest; global $FacebookLikeButtonOnce; $layout = @$argv['layout']; $send = @$argv['send']; if( $layout != 'standard' && $layout != 'box_count' ) $layout = 'button_count'; if( $send != 'true' ) $send = 'false'; $once = $FacebookLikeButtonOnce; $FacebookLikeButtonOnce = ''; $full_url = FacebookLikeButtonUrl().'/'.$wgRequest->getText('title'); return $once.'<div class="fb-like" data-href="'.$full_url.'" data-send="'. htmlspecialchars( $send ) .'" data-layout="'. htmlspecialchars( $layout ) .'" data-width="400"></div>'; } $wgExtensionCredits['parserhook'][] = array( 'name' => 'Wiki FacebookLikeButton', 'version' => '1.1.0', 'author' => 'Piotr Zuk, Jmkim dot com', 'url' => 'http://www.mediawiki.org/wiki/Extension:FacebookLikeButton', 'description' => 'Mediawiki FacebookLikeButton Extension' );

