slug = sanitize_key( $slug ); $this->name = $name; $this->types_source = $post_types; $this->post_types = is_callable( $post_types ) ? array() : (array) $post_types; $this->enabled = $enabled; if ( is_array( $statuses ) && $statuses ) { $this->post_statuses = array_values( array_map( 'sanitize_key', $statuses ) ); } $this->item_filter = is_callable( $item_filter ) ? $item_filter : null; } protected function is_indexable( $post_id ) { if ( ! parent::is_indexable( $post_id ) ) { return false; } return $this->item_filter ? (bool) call_user_func( $this->item_filter, (int) $post_id ) : true; } public function is_enabled() { $source = is_callable( $this->types_source ) ? (array) call_user_func( $this->types_source ) : (array) $this->types_source; $types = array_values( array_filter( $source, 'post_type_exists' ) ); if ( empty( $types ) || ! call_user_func( $this->enabled ) ) { return false; } $this->post_types = $types; return true; } }