Featured_Content::get_featured_post_ids PHP Method

get_featured_post_ids() public static method

This function will return the an array containing the post IDs of all featured posts. Sets the "featured_content_ids" transient.
public static get_featured_post_ids ( ) : array
return array Array of post IDs.
        public static function get_featured_post_ids()
        {
            // Return array of cached results if they exist.
            $featured_ids = get_transient('featured_content_ids');
            if (!empty($featured_ids)) {
                return array_map('absint', apply_filters('featured_content_post_ids', (array) $featured_ids));
            }
            $settings = self::get_setting();
            // Return empty array if no tag name is set.
            $term = get_term_by('name', $settings['tag-name'], 'post_tag');
            if (!$term) {
                $term = get_term_by('id', $settings['tag-id'], 'post_tag');
            }
            if ($term) {
                $tag = $term->term_id;
            } else {
                /** This action is documented in modules/theme-tools/featured-content.php */
                return apply_filters('featured_content_post_ids', array());
            }
            // Back compat for installs that have the quantity option still set.
            $quantity = isset($settings['quantity']) ? $settings['quantity'] : self::$max_posts;
            // Query for featured posts.
            $featured = get_posts(array('numberposts' => $quantity, 'post_type' => self::$post_types, 'tax_query' => array(array('field' => 'term_id', 'taxonomy' => 'post_tag', 'terms' => $tag))));
            // Return empty array if no featured content exists.
            if (!$featured) {
                /** This action is documented in modules/theme-tools/featured-content.php */
                return apply_filters('featured_content_post_ids', array());
            }
            // Ensure correct format before save/return.
            $featured_ids = wp_list_pluck((array) $featured, 'ID');
            $featured_ids = array_map('absint', $featured_ids);
            set_transient('featured_content_ids', $featured_ids);
            /** This action is documented in modules/theme-tools/featured-content.php */
            return apply_filters('featured_content_post_ids', $featured_ids);
        }