wp_connect_like_button

Description

The wp_connect_like_button function renders a Facebook Like Button based on the specified setting values. It can be used by theme designers who would like to add specific like buttons(s) to their theme.
The output can be restricted globally by the plugin settings and for individual posts and pages by the position settings.

Usage

<?php wp_connect_like_button(
$url, $send_button, $layout, $width, $show_faces,
$verb, $colorscheme, $font, $ref, $echo
); ?>

Parameters

$url
(string) (required) The URL to like. Defaults to the current page.
Default: None. Pass an empty string for the current page.
$send_button
(required) Whether to include the Send Button or not.
Valid Values: 

  • WPC_OPTION_DISABLED
  • WPC_OPTION_ENABLED

Default: None

$layout
(required) The layout style determines the size and amount of social context next to the button.
Valid Values: 

  • WPC_LAYOUT_STANDARD
  • WPC_LAYOUT_BUTTON_COUNT
  • WPC_LAYOUT_BOX_COUNT

Default: None

$width
(integer) (required) The width of the plugin in pixels.
Default: None
$show_faces
(required) Whether to show profile pictures below the button.
Valid Values: 

  • WPC_OPTION_DISABLED
  • WPC_OPTION_ENABLED

Default: None

$verb
(required) The verb to display in the button.
Valid Values: 

  • WPC_ACTION_LIKE
  • WPC_ACTION_RECOMMEND

Default: None

$colorscheme
(required) The color scheme of the plugin.
Valid Values: 

  • WPC_THEME_LIGHT
  • WPC_THEME_DARK

Default: None

$font
(required) The font of the plugin.
Valid Values: 

  • WPC_FONT_ARIAL
  • WPC_FONT_LUCIDA_GRANDE
  • WPC_FONT_SEGOE_UI
  • WPC_FONT_TAHOMA
  • WPC_FONT_TREBUCHET_MS
  • WPC_FONT_VERDANA

Default: None

$ref
(string) (required) a label for tracking referrals; must be less than 50 characters and can contain alphanumeric characters and some punctuation (currently +/=-.:_). Specifying a value for the ref attribute adds the ‘fb_ref’ parameter to the any links back to your site which are clicked from within the plugin. Using different values for the ref parameter for different positions and configurations of this plugin within your pages allows you to track which instances are performing the best.
Default: None; an empty string is allowed.
$echo
(boolean) (optional) Whether to print the plugin code (TRUE) or return it as a PHP variable (FALSE).
Default: TRUE

Examples

Default Usage

Prints the Like Button.

// this file is required to enable the use of WordPress Connect constants
$wpc_constants_file = WP_PLUGIN_DIR . '/wordpress-connect/src/WordpressConnectConstants.php';

if ( file_exists( $wpc_constants_file ) && function_exists( 'wp_connect_like_button' ) ){

	require_once( $wpc_constants_file );

	$like_url = 'http://www.mysite.com/my-post';
	$send_button = WPC_OPTION_DISABLED; // or WPC_OPTION_ENABLED
	$layout = WPC_LAYOUT_STANDARD;
	$like_button_width = 480;
	$show_faces = WPC_OPTION_ENABLED; // or WPC_OPTION_DISABLED
	$verb = WPC_ACTION_RECOMMEND;
	$colorscheme = WPC_THEME_DARK; // or WPC_THEME_LIGHT
	$font = WPC_FONT_DEFAULT;
	$ref = 'top';

	// render the like button in place
	wp_connect_like_button(
		$like_url,
		$send_button,
		$layout,
		$like_button_width,
		$show_faces,
		$verb,
		$colorscheme,
		$font,
		$ref
	);
}

Change Log

  • Since: 2.0
  • Since: 2.0.1 – Fixes the problem with api functions not defaulting to the current post/page url when an empty string is passed in as the url parameter

Source File

wp_connect_like_button() is located in wordpress-connect/wordpress-connect-functions.php.

Related

wp_connect_activity_feed, wp_connect_comments, wp_connect_comments_default, wp_connect_facepile, wp_connect_like_button, wp_connect_like_button_default, wp_connect_live_stream, wp_connect_login_button, wp_connect_recommendations, wp_connect_send_button