PHP Class Twitter\Widgets\Buttons\Tweet

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

Protected Properties

Property Type Description
$intent Tweet Web Intent
$size Large is currently the only supported size.

Public Methods

Method Description
__construct ( boolean $validate = true ) Create a new button. Initialize the web intent.
addHashtag ( string $hashtag ) : __CLASS__ Add a hashtag
addRelated ( string $username, string $label = '' ) : __CLASS__ Add a related Twitter account
fromArray ( array $options ) : __CLASS__ Create a Tweet button from an associative array
setInReplyTo ( string $tweet_id ) : __CLASS__ Define a parent Tweet by ID
setIntent ( Tweet $intent ) : __CLASS__ Set a new intent
setSize ( string $size ) : __CLASS__ Set the size of the Tweet button
setText ( string $text ) : __CLASS__ Pre-populate Tweet text
setURL ( string $url ) : __CLASS__ Share a URL
setVia ( string $username ) : __CLASS__ Associate Tweet with a source account
toArray ( ) : array Return Tweet button parameters suitable
toHTML ( string $anchor_text = 'Tweet', string $html_builder_class = '\Twitter\Helpers\HTMLBuilder' ) : string Tweet button HTML

Method Details

__construct() public method

Create a new button. Initialize the web intent.
Since: 1.0.0
public __construct ( boolean $validate = true )
$validate boolean Validate inputs such as screen

addHashtag() public method

Add a hashtag
Since: 1.0.0
public addHashtag ( string $hashtag ) : __CLASS__
$hashtag string hashtag
return __CLASS__ support chaining

addRelated() public method

Add a related Twitter account
Since: 1.0.0
public addRelated ( string $username, string $label = '' ) : __CLASS__
$username string Twitter username
$label string brief description of how the account relates to the Tweet content
return __CLASS__ support chaining

fromArray() public static method

Create a Tweet button from an associative array
public static fromArray ( array $options ) : __CLASS__
$options array { @type string parameter name @type string|int|bool parameter value }
return __CLASS__ new button with configured parameters

setInReplyTo() public method

Define a parent Tweet by ID
Since: 1.0.0
public setInReplyTo ( string $tweet_id ) : __CLASS__
$tweet_id string Parent Tweet ID
return __CLASS__ support chaining

setIntent() public method

Set a new intent
Since: 1.0.0
public setIntent ( Tweet $intent ) : __CLASS__
$intent Twitter\Intents\Tweet Tweet Intent
return __CLASS__ support chaining

setSize() public method

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

setText() public method

Pre-populate Tweet text
Since: 1.0.0
public setText ( string $text ) : __CLASS__
$text string Tweet text
return __CLASS__ support chaining

setURL() public method

Share a URL
Since: 1.0.0
public setURL ( string $url ) : __CLASS__
$url string absolute URL
return __CLASS__ support chaining

setVia() public method

Associate Tweet with a source account
Since: 1.0.0
public setVia ( string $username ) : __CLASS__
$username string Twitter username
return __CLASS__ support chaining

toArray() public method

Return Tweet button parameters suitable
Since: 1.0.0
public toArray ( ) : array
return array Tweet button parameter array { @type string dashed parameter name @type string parameter value }

toHTML() public method

Tweet button HTML
Since: 1.0.0
public toHTML ( string $anchor_text = 'Tweet', string $html_builder_class = '\Twitter\Helpers\HTMLBuilder' ) : string
$anchor_text string inner text of the generated anchor element. Default: Tweet
$html_builder_class string callable HTML builder with a static anchorElement class
return string HTML markup

Property Details

$intent protected_oe property

Tweet Web Intent
Since: 1.0.0
protected $intent

$size protected_oe property

Large is currently the only supported size.
Since: 1.0.0
protected $size