Example #1
0
 /**
  * Register JavaScript during the enqueue scripts action
  *
  * @since 1.0.0
  *
  * @return void
  */
 public static function registerScripts()
 {
     // Twitter widgets
     \Twitter\WordPress\JavaScriptLoaders\Widgets::register();
     // Vine embed
     \Twitter\WordPress\JavaScriptLoaders\VineEmbed::register();
     // Twitter audience tracker and conversion
     \Twitter\WordPress\JavaScriptLoaders\Tracking::register();
 }
Example #2
0
 /**
  * Handle shortcode macro
  *
  * @since 1.3.0
  *
  * @param array  $attributes set of shortcode attribute-value pairs or positional content matching the WordPress shortcode regex {
  *   @type string|int attribute name or positional int
  *   @type mixed      shortcode value
  * }
  * @param string $content    content inside a shortcode macro. no effect on this shortcode
  *
  * @return string HTML markup. empty string if parameter requirement not met or no collection info found
  */
 public static function shortcodeHandler($attributes, $content = '')
 {
     global $content_width;
     $options = shortcode_atts(static::$SHORTCODE_DEFAULTS, $attributes, static::SHORTCODE_TAG);
     $vine_id = trim($options['id']);
     if (!$vine_id) {
         return '';
     }
     $query_parameters = static::getBaseOEmbedParams($vine_id);
     unset($query_parameters['lang']);
     $width = absint($options['width']);
     if ($width < 100 && isset($content_width)) {
         $width = absint($content_width);
     }
     if ($width > 100) {
         // reset max_width to max value supported by Vine
         // collapses cache hits
         if ($width > 600) {
             $width = 600;
         }
         $query_parameters['maxwidth'] = $width;
     }
     // fetch HTML markup from Vine oEmbed endpoint for the given parameters
     $html = trim(static::getOEmbedMarkup($query_parameters));
     if (!$html) {
         return '';
     }
     $html = '<div class="' . sanitize_html_class(static::HTML_CLASS) . '">' . $html . '</div>';
     $inline_js = \Twitter\WordPress\JavaScriptLoaders\VineEmbed::enqueue();
     if ($inline_js) {
         return $html . $inline_js;
     }
     return $html;
 }