PHP Class Twitter\Widgets\Buttons\Follow

Since: 1.0.0
Inheritance: extends Twitter\Widgets\BaseWidget
Show file Open project: twitter/wordpress Class Usage Examples

Public Properties

Property Type Description
$ALLOWED_SIZES Allowed values for the size property

Protected Properties

Property Type Description
$intent Follow Web Intent
$show_count Show the current number of followers alongside the button
$show_screen_name Show or hide the screen name of the account
$size Size of the button

Public Methods

Method Description
__construct ( string $screen_name, boolean $validate = true ) Require screen name. Initialize Follow Web Intent
fromArray ( array $options ) : __CLASS__ Build a Follow button object from an associative array
getScreenName ( ) : string Return the screen name of the Twitter user
hideCount ( ) : __CLASS__ Show only the Follow button, without a follower count
hideScreenName ( ) : __CLASS__ Hide the screen name from display inside the Follow button
setSize ( string $size ) : __CLASS__ Set the desired size of the Follow button
showCount ( ) : __CLASS__ Show the number of followers alongside the Follow button
showScreenName ( ) : __CLASS__ Show the screen name to follow inside the Follow button
toArray ( ) : array Convert the class object into an array, removing default field values
toHTML ( string $anchor_text = 'Follow %s', string $html_builder_class = '\Twitter\Helpers\HTMLBuilder' ) : string Generate HTML to encourage follow behavior and expose data to the Twitter for Websites JavaScript

Method Details

__construct() public method

Require screen name. Initialize Follow Web Intent
Since: 1.0.0
public __construct ( string $screen_name, boolean $validate = true )
$screen_name string Twitter account name
$validate boolean validate screen name matches Twitter username allowed characters and length before saving

fromArray() public static method

Build a Follow button object from an associative array
Since: 1.0.0
public static fromArray ( array $options ) : __CLASS__
$options array associative array of options { @type string option name @type string|int|bool option value }
return __CLASS__ support chaining

getScreenName() public method

Return the screen name of the Twitter user
Since: 1.0.0
public getScreenName ( ) : string
return string Twitter screen name, or blank string if no screen name stored

hideCount() public method

Show only the Follow button, without a follower count
Since: 1.0.0
public hideCount ( ) : __CLASS__
return __CLASS__ support chaining

hideScreenName() public method

Hide the screen name from display inside the Follow button
Since: 1.0.0
public hideScreenName ( ) : __CLASS__
return __CLASS__ support chaining

setSize() public method

Set the desired size of the Follow button
Since: 1.0.0
public setSize ( string $size ) : __CLASS__
$size string button size
return __CLASS__ support chaining

showCount() public method

Show the number of followers alongside the Follow button
Since: 1.0.0
public showCount ( ) : __CLASS__
return __CLASS__ support chaining

showScreenName() public method

Show the screen name to follow inside the Follow button
Since: 1.0.0
public showScreenName ( ) : __CLASS__
return __CLASS__ support chaining

toArray() public method

Convert the class object into an array, removing default field values
Since: 1.0.0
public toArray ( ) : array
return array properties as associative array

toHTML() public method

Generate HTML to encourage follow behavior and expose data to the Twitter for Websites JavaScript
Since: 1.0.0
public toHTML ( string $anchor_text = 'Follow %s', string $html_builder_class = '\Twitter\Helpers\HTMLBuilder' ) : string
$anchor_text string inner text of the generated anchor element. Supports a single '%s' screen name passed through sprintf. Default: Follow %s
$html_builder_class string callable HTML builder with a static anchorElement class
return string HTML markup or empty string if minimum requirements not met

Property Details

$ALLOWED_SIZES public static property

Allowed values for the size property
Since: 1.0.0
public static $ALLOWED_SIZES

$intent protected property

Follow Web Intent
Since: 1.0.0
protected $intent

$show_count protected property

Show the current number of followers alongside the button
Since: 1.0.0
protected $show_count

$show_screen_name protected property

Show or hide the screen name of the account
Since: 1.0.0
protected $show_screen_name

$size protected property

Size of the button
Since: 1.0.0
protected $size