public static function shortcodeHandler($attributes, $content = '')
{
// clean up attribute to shortcode option mappings before passing to filter
// apply the same filter as shortcode_atts
/** This filter is documented in wp-includes/shortcodes.php */
$options = apply_filters('shortcode_atts_' . self::SHORTCODE_TAG, array_merge(static::$SHORTCODE_DEFAULTS, static::sanitizeShortcodeParameters((array) $attributes)), static::$SHORTCODE_DEFAULTS, $attributes);
if (!$options['id']) {
return '';
}
$tweet_id = $options['id'];
unset($options['id']);
$oembed_params = static::shortcodeParamsToOEmbedParams($tweet_id, $options);
if (empty($oembed_params)) {
return '';
}
// fetch HTML markup from Twitter oEmbed endpoint for the given parameters
$html = trim(static::getOEmbedMarkup($oembed_params));
if (!$html) {
return '';
}
$html = '<div class="twitter-tweet">' . $html . '</div>';
$inline_js = \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
if ($inline_js) {
return $html . $inline_js;
}
return $html;
}