is_main_query() ) { $wp_query->set( 'cache_results', false ); return []; } return $posts; } /** * Filter: home_template */ public static function load_custom_home_template() { return get_template_directory() . '/inc/drafts-index/templates/tpl-drafts-index.php'; } public static function custom_body_class( $classes ) { // Add special drafts index class. $classes[] = 'is-drafts-index'; // Remove 'home' class. return array_diff( $classes, [ 'home' ] ); } public static function remove_infinite_scroll() { remove_theme_support( 'infinite-scroll' ); } public static function customize_o2_options( array $o2_options ) { $o2_options['options']['infiniteScroll'] = false; $o2_options['options']['hideAppControls'] = true; $o2_options['options']['showFrontSidePostBox'] = false; $o2_options['options']['viewType'] = 'archive'; return $o2_options; } public static function get_drafts() { $drafts_query = new \WP_Query( [ 'post_status' => 'draft', // Limit for better performance. 'posts_per_page' => 100, 'author' => get_current_user_id(), 'orderby' => 'modified', 'order' => 'DESC', ] ); return $drafts_query->posts; } public static function is_drafts_index_active(): bool { return isset( $_GET['drafts'] ); } }