public static function init()
{
$theme_support = get_theme_support('featured-content');
// Return early if theme does not support featured content.
if (!$theme_support) {
return;
}
/*
* An array of named arguments must be passed as the second parameter
* of add_theme_support().
*/
if (!isset($theme_support[0])) {
return;
}
if (isset($theme_support[0]['featured_content_filter'])) {
$theme_support[0]['filter'] = $theme_support[0]['featured_content_filter'];
unset($theme_support[0]['featured_content_filter']);
}
// Return early if "filter" has not been defined.
if (!isset($theme_support[0]['filter'])) {
return;
}
// Theme can override the number of max posts.
if (isset($theme_support[0]['max_posts'])) {
self::$max_posts = absint($theme_support[0]['max_posts']);
}
add_filter($theme_support[0]['filter'], array(__CLASS__, 'get_featured_posts'));
add_action('customize_register', array(__CLASS__, 'customize_register'), 9);
add_action('admin_init', array(__CLASS__, 'register_setting'));
add_action('save_post', array(__CLASS__, 'delete_transient'));
add_action('delete_post_tag', array(__CLASS__, 'delete_post_tag'));
add_action('customize_controls_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'));
add_action('pre_get_posts', array(__CLASS__, 'pre_get_posts'));
add_action('switch_theme', array(__CLASS__, 'switch_theme'));
add_action('switch_theme', array(__CLASS__, 'delete_transient'));
add_action('wp_loaded', array(__CLASS__, 'wp_loaded'));
add_action('split_shared_term', array(__CLASS__, 'jetpack_update_featured_content_for_split_terms', 10, 4));
if (isset($theme_support[0]['additional_post_types'])) {
$theme_support[0]['post_types'] = array_merge(array('post'), (array) $theme_support[0]['additional_post_types']);
unset($theme_support[0]['additional_post_types']);
}
// Themes can allow Featured Content pages
if (isset($theme_support[0]['post_types'])) {
self::$post_types = array_merge(self::$post_types, (array) $theme_support[0]['post_types']);
// register post_tag support for each post type
foreach (self::$post_types as $post_type) {
register_taxonomy_for_object_type('post_tag', $post_type);
}
}
}