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);
$screen_name = '';
if (isset($options['screen_name'])) {
$screen_name = $options['screen_name'];
unset($options['screen_name']);
}
if (!$screen_name) {
$screen_name = static::getScreenName();
// follow target required
if (!$screen_name) {
return '';
}
}
// update the options array with the Follow screen name
$options['screen_name'] = $screen_name;
$follow = \Twitter\Widgets\Buttons\Follow::fromArray($options);
if (!$follow) {
return '';
}
$html = $follow->toHTML(_x('Follow %s', 'Follow a Twitter user', 'twitter'), '\\Twitter\\WordPress\\Helpers\\HTMLBuilder');
if (!$html) {
return '';
}
$html = '<div class="twitter-follow">' . $html . '</div>';
$inline_js = \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
if ($inline_js) {
return $html . $inline_js;
}
return $html;
}