Twitter\WordPress\Shortcodes\EmbeddedTweetVideo::shortcodeHandler PHP Метод

shortcodeHandler() публичный статический Метод

Handle shortcode macro
С версии: 1.0.0
public static shortcodeHandler ( array $attributes, string $content = '' ) : string
$attributes array shortcode attributes
$content string shortcode content. no effect
Результат string HTML markup
    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-video">' . $html . '</div>';
        $inline_js = \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
        if ($inline_js) {
            return $html . $inline_js;
        }
        return $html;
    }