API

Description

A big addition since WordPress Connect 2.0 is a simple yet powerful API for plugin and theme developers. Developers can now specify default settings for WordPress Connect to reflect the needs of their plugin/theme. Furthermore, the API provides an easy way to include any widget/plugin (such as the Like Button of Comments) anywhere in the theme/plugin pages, e.g. to add the Like Button to the page header, or create pages which include a particular plugin by default (e.g ‘Comments Page’, ‘Like Box Page’ etc) .

WordPress Connect Settings

It may be very useful for theme developers to be able to set the default look-and-feel of Facebook Social Plugins so that they fit within the theme’s design. The WordPress Connect plugin provides the ‘wp_connect_options’ hook to give WordPress developers an easy access to the plugin settings.

<?php add_filter'wp_connect_options''my_theme_name_set_wp_connect_options' ); ?>

add_filter( 'wp_connect_options', 'my_theme_name_set_wp_connect_options' );

function my_theme_name_set_wp_connect_options( $options ){

	// the following shouldn't be necessary as the 'wp_connect_options' filter 
	// should be applied only from WordPress Connect ( but just in case
	// someone else adds a filter with the same name, do the following check:
	
	$wpc_constants_file = WP_PLUGIN_DIR . '/wordpress-connect/src/WordpressConnectConstants.php';
	if ( !file_exists( $wpc_constants_file ){ return $options; }
	require_once( $wpc_constants_file );
	
	// set the default wordpress connect settings
	
	$options = array(
		WPC_OPTIONS => array(
			WPC_OPTIONS_LANGUAGE => 'en_US',
			WPC_OPTIONS_THEME => WPC_THEME_LIGHT
		),
		WPC_OPTIONS_COMMENTS => array(
			WPC_OPTIONS_COMMENTS_NUMBER => 6,
			WPC_OPTIONS_COMMENTS_WIDTH => 480,
			WPC_OPTIONS_COMMENTS_POSTION_DEFAULT => 
					WPC_CUSTOM_FIELD_VALUE_POSITION_BOTTOM,
			WPC_OPTIONS_COMMENTS_ENABLED_DEFAULT => WPC_OPTIONS_ENABLED,
			WPC_OPTIONS_DISPLAY_EVERYWHERE => 'on',
			WPC_OPTIONS_DISPLAY_NOWHERE => ''
		),
		WPC_OPTIONS_LIKE_BUTTON => array(
			WPC_OPTIONS_LIKE_BUTTON_SEND => WPC_OPTIONS_ENABLED,
			WPC_OPTIONS_LIKE_BUTTON_LAYOUT => WPC_LAYOUT_STANDARD,
			WPC_OPTIONS_LIKE_BUTTON_WIDTH => 480,
			WPC_OPTIONS_LIKE_BUTTON_FACES => WPC_OPTIONS_ENABLED,
			WPC_OPTIONS_LIKE_BUTTON_VERB => WPC_ACTION_LIKE,
			WPC_OPTIONS_LIKE_BUTTON_FONT => WPC_FONT_DEFAULT,
			WPC_OPTIONS_LIKE_BUTTON_POSITION_DEFAULT => 
					WPC_CUSTOM_FIELD_VALUE_POSITION_TOP,
			WPC_OPTIONS_LIKE_BUTTON_ENABLED_DEFAULT => WPC_OPTIONS_ENABLED,
			WPC_OPTIONS_DISPLAY_EVERYWHERE => 'on',
			WPC_OPTIONS_DISPLAY_NOWHERE => ''
		)
	);

	return $options;
}

Back to Contents

WordPress Connect Integration

The new API provide a simple way to add Facebook Social plugins anywhere within a WordPress theme. The list of functions available through the API is below. Click on the function’s name to see a detailed documentation.

WordPress Connect API Functions

WordPress Connect Constants

To simplify development and updates WordPress Connect comes with a set of constant values used throughout the plugin’s code.

Back to Contents

Option Values

Option values provide a standardized set of values that can be used anywhere in your code without having to worry about the change in the actual value. For example, even if Facebook changed the xfbml value for the ‘dark’ theme to ‘black’, using WPC_THEME_DARK will still work (as the plugin will take care of the change with an update)

WPC_ACTION_LIKE
Specifies the ‘like’ value for the verb option of the Like Button – details available here
WPC_ACTION_RECOMMEND
Specifies the ‘recommend’ value for the verb option of the Like Button – details available here
WPC_FONT_ARIAL
Specifies the ‘arial’ value for the font option of the WordPress Connect plugins
WPC_FONT_LUCIDA_GRANDE
Specifies the ‘lucida grande’ value for the font option of the WordPress Connect plugins
WPC_FONT_SEGOE_UI
Specifies the ‘segoe ui’ value for the font option of the WordPress Connect plugins
WPC_FONT_TAHOMA
Specifies the ‘tahoma’ value for the font option of the WordPress Connect plugins
WPC_FONT_TREBUCHET_MS
Specifies the ‘trebuchet ms’ value for the font option of the WordPress Connect plugins
WPC_FONT_VERDANA
Specifies the ‘verdana’ value for the font option of the WordPress Connect plugins
WPC_FONT_DEFAULT
see WPC_FONT_ARIAL
WPC_LAYOUT_BOX_COUNT
The value for ‘box_count’ Like Button layout – details available here
WPC_LAYOUT_BUTTON_COUNT
The value for ‘button_count’ Like Button layout – details available here
WPC_LAYOUT_STANDARD
The value for ‘standard’ Like Button layout – details available here
WPC_OPTION_DISABLED
This value should be use for disabling any option that can be set either disabled or enabled
WPC_OPTION_ENABLED
This value should be use for enabling any option that can be set either disabled or enabled
WPC_THEME_LIGHT
Use this value to set the ‘light’ theme for WordPress Connect plugins
WPC_THEME_DARK
Use this value to set the ‘dark’ theme for WordPress Connect plugins

Back to Contents

Option Names

WPC_OPTIONS
The option_name for the general settings
WPC_OPTIONS_COMMENTS
The option_name for the comments settings
WPC_OPTIONS_COMMENTS_ENABLED
The option_name for the comments enabled setting
WPC_OPTIONS_COMMENTS_NUMBER
The option_name for the number of comments setting
WPC_OPTIONS_COMMENTS_POSITION
The option_name for the comments position settings
WPC_OPTIONS_COMMENTS_WIDTH
The option_name for the comments width setting
WPC_OPTIONS_DISPLAY
The option_name for the display settings (these are subcategories to the comments and like button settings)
WPC_OPTIONS_DISPLAY_ARCHIVE
The option_name for the displaying plugin on archive pages
WPC_OPTIONS_DISPLAY_CATEGORIES
The option_name for the displaying plugin on category pages
WPC_OPTIONS_DISPLAY_EVERYWHERE
The option_name for the displaying plugin everywhere
WPC_OPTIONS_DISPLAY_HOMEPAGE
The option_name for the displaying plugin on the homepage
WPC_OPTIONS_DISPLAY_NOWHERE
The option_name for the displaying plugin nowhere
WPC_OPTIONS_DISPLAY_SEARCH
The option_name for the displaying plugin on search results
WPC_OPTIONS_DISPLAY_TAGS
The option_name for the displaying plugin on tag pages
WPC_OPTIONS_LANGUAGE
The option_name for the currently selected language
WPC_OPTIONS_LIKE_BOX
The option_name for the like box settings
WPC_OPTIONS_LIKE_BOX_URL
The option_name for the like box url setting
WPC_OPTIONS_LIKE_BUTTON
The option_name for the like button settings
WPC_OPTIONS_LIKE_BUTTON_ENABLED
The option_name for the like button enabled setting
WPC_OPTIONS_LIKE_BUTTON_LAYOUT
The option_name for the like button layout setting
WPC_OPTIONS_LIKE_BUTTON_FACES
The option_name for the setting specifying whether to show like button faces or not
WPC_OPTIONS_LIKE_BUTTON_FONT
The option_name for the like button font setting
WPC_OPTIONS_LIKE_BUTTON_POSITION
The option_name for the like button position setting
WPC_OPTIONS_LIKE_BUTTON_REF
The option_name for the default like button ref value setting
WPC_OPTIONS_LIKE_BUTTON_SEND
The option_name for the setting specifying whether to show the send button or not
WPC_OPTIONS_LIKE_BUTTON_VERB
The option_name for the like button verb setting
WPC_OPTIONS_LIKE_BUTTON_WIDTH
The option_name for the like button width setting
WPC_OPTIONS_THEME
The option_name for the currently selected color theme

Back to Contents

Miscellaneous

WPC_TEXT_DOMAIN
The text domain for i18n
WPC_VERSION
The current version of WordPress Connect

Back to Contents