public static function sanitizeShortcodeParameters($attributes = array())
{
if (!is_array($attributes)) {
return array();
}
$options = array();
if (isset($attributes['in_reply_to'])) {
$tweet_id = \Twitter\WordPress\Shortcodes\EmbeddedTweet::sanitizeTweetID((string) $attributes['in_reply_to']);
if ($tweet_id) {
$options['in_reply_to'] = $tweet_id;
}
unset($tweet_id);
}
if (isset($attributes['text']) && is_string($attributes['text'])) {
$options['text'] = $attributes['text'];
}
if (isset($attributes['url']) && $attributes['url']) {
$url = esc_url_raw(trim($attributes['url']), array('http', 'https'));
if ($url) {
$options['url'] = $url;
}
unset($url);
}
if (isset($attributes['related'])) {
$intent = \Twitter\Intents\Tweet::fromArray(array('related' => $attributes['related']));
if ($intent) {
$related = $intent->getRelated();
if (!empty($related)) {
$options['related'] = $related;
}
unset($related);
}
unset($intent);
}
if (isset($attributes['via'])) {
$via = (new \Twitter\Intents\Tweet())->setVia($attributes['via'])->getVia();
if ($via) {
$options['via'] = $via;
}
unset($via);
}
if (isset($attributes['hashtags'])) {
$intent = \Twitter\Intents\Tweet::fromArray(array('hashtags' => $attributes['hashtags']));
if ($intent) {
$hashtags = $intent->getHashtags();
if (!empty($hashtags)) {
$options['hashtags'] = $hashtags;
}
unset($hashtags);
}
unset($intent);
}
// large is the only option
if (isset($attributes['size'])) {
if (is_string($attributes['size']) && in_array(strtolower($attributes['size']), array('large', 'l'))) {
$options['size'] = 'large';
}
}
return $options;
}