Esempio n. 1
0
/**
 * Checks if the Idea being iterated on is sticky
 *
 * @package WP Idea Stream
 * @subpackage ideas/tags
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream() to get plugin's main instance
 * @uses   wp_idea_stream_is_idea_archive() to check if on an idea archive page
 * @uses   wp_idea_stream_get_idea_var() to check if order is not default
 * @uses   wp_idea_stream_is_search() to check if a search is being performed
 * @uses   wp_idea_stream_is_sticky_enabled() to check if sticky feature is enabled
 * @uses   wp_idea_stream_ideas_is_sticky() to check if the idea is sticky
 * @return bool True if the Idea being iterating on is sticky, false otherwise
 */
function wp_idea_stream_ideas_is_sticky_idea()
{
    $query_loop = wp_idea_stream()->query_loop;
    $idea = $query_loop->idea;
    if (!wp_idea_stream_is_idea_archive() || wp_idea_stream_get_idea_var('orderby') || wp_idea_stream_is_search()) {
        return;
    }
    if (empty($query_loop->page) || !empty($query_loop->page) && 1 < $query_loop->page) {
        return;
    }
    // Bail if sticky is disabled
    if (!wp_idea_stream_is_sticky_enabled()) {
        return;
    }
    if (!empty($idea->is_sticky)) {
        return true;
    } else {
        return wp_idea_stream_ideas_is_sticky($idea->ID);
    }
}
Esempio n. 2
0
 /**
  * Adds a sticky state after the idea title in WP_List_Table
  *
  * @package WP Idea Stream
  * @subpackage admin/sticky
  *
  * @since 2.0.0
  *
  * @param  array   $idea_states  the available idea states
  * @param  WP_Post $idea         the idea object
  * @uses   wp_idea_stream_ideas_is_sticky() to check if the idea is sticked to front of archive page
  * @return array                 the new idea states
  */
 public function idea_states($idea_states = array(), $idea = null)
 {
     if ($idea->post_type != $this->post_type) {
         return $idea_states;
     }
     if (wp_idea_stream_ideas_is_sticky($idea->ID)) {
         $idea_states['sticky'] = esc_html_x('Sticky', 'idea list table row state', 'wp-idea-stream');
     }
     return $idea_states;
 }