/** * Filter on `the_posts` for the theme archive. Moves sticky posts to the top of * the theme archive list. * * @since 1.0.0 * @access public * @param array $posts * @param object $query * @return array */ function thds_posts_sticky_filter($posts, $query) { // Allow devs to filter when to show sticky themes. $show_stickies = apply_filters('thds_show_stickies', $query->is_main_query() && !is_admin() && thds_is_theme_archive() && !is_paged()); // If we should show stickies, let's get them. if ($show_stickies) { remove_filter('the_posts', 'thds_posts_sticky_filter'); $posts = thds_add_stickies($posts, thds_get_sticky_themes()); } return $posts; }
/** * Conditional check to see if a theme is sticky. * * @since 1.0.0 * @access public * @param int $theme_id * @return bool */ function thds_is_theme_sticky($theme_id = 0) { $theme_id = thds_get_theme_id($theme_id); return apply_filters('thds_is_theme_sticky', in_array($theme_id, thds_get_sticky_themes()), $theme_id); }
/** * Add custom views (status list). * * @since 1.0.0 * @access public * @param array $views * @return array */ public function views($views) { $count = count(thds_get_sticky_themes()); if (0 < $count) { $post_type = thds_get_theme_post_type(); $noop = _n('Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $count, 'theme-designer'); $text = sprintf($noop, number_format_i18n($count)); $views['sticky'] = sprintf('<a href="%s">%s</a>', add_query_arg(array('post_type' => $post_type, 'sticky' => 1), admin_url('edit.php')), $text); } return $views; }