PHP Class Twitter\WordPress\Shortcodes\EmbeddedTweet

Since: 1.0.0
Inheritance: implements Twitter\WordPress\Shortcodes\ShortcodeInterface, implements Twitter\WordPress\Shortcodes\PublishOEmbedEndpoint, use trait Twitter\WordPress\Shortcodes\OEmbedTrait
ファイルを表示 Open project: twitter/wordpress Class Usage Examples

Public Properties

Property Type Description
$ALIGN_OPTIONS Accepted values for the align parameter
$SHORTCODE_DEFAULTS Accepted shortcode attributes and their default values

Public Methods

Method Description
getOEmbedCacheKeyCustomParameters ( array $query_parameters ) : string Generate a unique string representing oEmbed result customizations set by shortcode parameters
init ( ) : void Attach handlers for embedded Tweets
linkHandler ( array $matches, array $attr, string $url, array $rawattr ) : string Handle a URL matched by an embed handler
oEmbedCacheKey ( array $query_parameters ) : string Construct a cache key for the oEmbed response. Account for query parameters needing to bust cache
sanitizeShortcodeParameters ( array $attributes = [] ) : array Convert shortcode parameters, attributes, and defaults into a clean set of Tweet parameters
sanitizeTweetID ( string $tweet_id ) : string Convert a Tweet ID in ID or URL form into a trimmed ID
shortcodeHandler ( array $attributes, string $content = '' ) : string Handle shortcode macro
shortcodeParamsToOEmbedParams ( string $tweet_id, array $shortcode_options = [] ) : array Convert shortcode parameters into query parameters supported by the Twitter oEmbed endpoint
shortcodeUI ( ) : void Describe shortcode for Shortcake UI

Method Details

getOEmbedCacheKeyCustomParameters() public static method

Generate a unique string representing oEmbed result customizations set by shortcode parameters
Since: 1.0.0
public static getOEmbedCacheKeyCustomParameters ( array $query_parameters ) : string
$query_parameters array associative array of query parameters sent to the oEmbed endpoint { @type string query parameter name @type string|bool query parameter value }
return string cache key component

init() public static method

Attach handlers for embedded Tweets
Since: 1.0.0
public static init ( ) : void
return void

linkHandler() public static method

Handle a URL matched by an embed handler
Since: 1.0.0
public static linkHandler ( array $matches, array $attr, string $url, array $rawattr ) : string
$matches array The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
$attr array Embed attributes. Not used.
$url string The original URL that was matched by the regex. Not used.
$rawattr array The original unmodified attributes. Not used.
return string HTML markup for the Tweet or an empty string if requirements not met

oEmbedCacheKey() public static method

Construct a cache key for the oEmbed response. Account for query parameters needing to bust cache
Since: 1.0.0
public static oEmbedCacheKey ( array $query_parameters ) : string
$query_parameters array oEmbed API query parameters
return string cache key

sanitizeShortcodeParameters() public static method

Convert shortcode parameters, attributes, and defaults into a clean set of Tweet parameters
Since: 1.0.0
public static sanitizeShortcodeParameters ( array $attributes = [] ) : array
$attributes array set of shortcode attribute-value pairs or positional content matching the WordPress shortcode regex { @type string|int attribute name or positional int @type mixed shortcode value }
return array cleaned up options ready for comparison { @type string option name @type string|bool option value }

sanitizeTweetID() public static method

Convert a Tweet ID in ID or URL form into a trimmed ID
Since: 1.0.0
public static sanitizeTweetID ( string $tweet_id ) : string
$tweet_id string Tweet identifier
return string $tweet_id Tweet identifier or empty string if minimum requirements not met

shortcodeHandler() public static method

Handle shortcode macro
Since: 1.0.0
public static shortcodeHandler ( array $attributes, string $content = '' ) : string
$attributes array set of shortcode attribute-value pairs or positional content matching the WordPress shortcode regex { @type string|int attribute name or positional int @type mixed shortcode value }
$content string content inside a shortcode macro. no effect on this shortcode
return string HTML markup. empty string if parameter requirement not met or no Tweet info found

shortcodeParamsToOEmbedParams() public static method

Convert shortcode parameters into query parameters supported by the Twitter oEmbed endpoint
Since: 1.0.0
public static shortcodeParamsToOEmbedParams ( string $tweet_id, array $shortcode_options = [] ) : array
$tweet_id string Tweet identifier
$shortcode_options array customizations specified in the shortcode
return array associative array of query parameters ready for http_build_query { @type string query parameter name @type string|bool query parameter value }

shortcodeUI() public static method

Describe shortcode for Shortcake UI
Since: 1.1.0
public static shortcodeUI ( ) : void
return void

Property Details

$ALIGN_OPTIONS public_oe static_oe property

Accepted values for the align parameter
Since: 1.0.0
public static $ALIGN_OPTIONS

$SHORTCODE_DEFAULTS public_oe static_oe property

Accepted shortcode attributes and their default values
Since: 1.0.0
public static $SHORTCODE_DEFAULTS