public static function publicInit()
{
// enhance web browser view only
if (is_feed()) {
return;
}
$features = \Twitter\WordPress\Features::getEnabledFeatures();
// load widgets JS if a Twitter widget is active
if (isset($features[\Twitter\WordPress\Features::FOLLOW_BUTTON]) && is_active_widget(false, false, \Twitter\WordPress\Widgets\Buttons\Follow::BASE_ID, true) || isset($features[\Twitter\WordPress\Features::PERISCOPE_ON_AIR]) && is_active_widget(false, false, \Twitter\WordPress\Widgets\Buttons\PeriscopeOnAir::BASE_ID, true)) {
// enqueue after the script is registered in wp_enqueue_scripts action priority 1
add_action('wp_enqueue_scripts', array('\\Twitter\\WordPress\\JavaScriptLoaders\\Widgets', 'enqueue'));
// register DNS prefetch before WordPress resource hints run at wp_head priority 2
add_action('wp_head', array('\\Twitter\\WordPress\\JavaScriptLoaders\\Widgets', 'dnsPrefetch'), 1);
}
// do not add content filters to HTTP 404 response
if (is_404()) {
return;
}
if (!isset($features[\Twitter\WordPress\Features::TWEET_BUTTON])) {
return;
}
/**
* Set the priority to apply to Twitter elements automatically added to the_content
*
* Allow publishers to adjust the order of Twitter buttons relative to other the_content actors
*
* @since 1.0.0
*
* @param int $priority filter priority
*/
$twitter_content_priority = apply_filters('twitter_content_filter_priority', 15);
// possibly add Tweet button(s)
add_filter('the_content', array('\\Twitter\\WordPress\\Content\\Buttons\\Tweet', 'contentFilter'), $twitter_content_priority);
}