get(); if ( ! isset( $excluded ) ) { return $args; } /** * Exclude posts by post type */ if ( isset( $excluded->entries ) ) { $post__not_in = array(); foreach ( $excluded->entries as $post_type => $excluded_post_type ) { $post_type_ids = ! empty( $excluded_post_type['all'] ) ? $this->get_all_post_type_ids( $post_type ) : $excluded_post_type['ids']; $post__not_in = array_merge( $post__not_in, $post_type_ids ); } $args['post_not_in'] = is_array($args['post_not_in']) ? $args['post_not_in'] : array(); $args['post_not_in'] = array_unique( array_merge( $args['post_not_in'], $post__not_in ) ); } } return $args; } private function get_all_post_type_ids( $post_type ) { return get_posts( array( 'post_type' => $post_type, 'posts_per_page' => -1, 'fields' => 'ids', ) ); } // ------------------------------------------------------------ // ---------------- SINGLETON SPECIFIC -------------------- // ------------------------------------------------------------ /** * Static instance storage * * @var self */ protected static $_instance; public static function getInstance() { if ( ! ( self::$_instance instanceof self ) ) { self::$_instance = new self(); } return self::$_instance; } } }