/** * Require username * * @since 1.3.0 */ public function __construct($username, $validate = true) { $username = \Twitter\Helpers\Validators\PeriscopeUsername::trim($username); if (false === $validate || \Twitter\Helpers\Validators\PeriscopeUsername::isValid($username)) { $this->username = $username; } }
/** * Clean up provided shortcode values * * @since 1.3.0 * * @param array $attributes provided shortcode attributes { * @type string shortcode attribute name * @type mixed shortcode attribute value * } * * @return array simplified shortcode values with defaults removed { * @type string shortcode attribute name * @type bool|string shortcode attribute value * } */ public static function sanitizeShortcodeParameters($attributes = array()) { if (!is_array($attributes)) { return array(); } $options = array(); if (isset($attributes['username'])) { $username = \Twitter\Helpers\Validators\PeriscopeUsername::trim($attributes['username']); if ($username) { $options['username'] = $username; } unset($username); } // 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; }