*/ public static function options(): array { $out = [['value' => '', 'label' => __('— Select —', 'zadex')]]; if (function_exists('post_type_exists') && post_type_exists(self::POST_TYPE) && function_exists('get_posts')) { $posts = get_posts([ 'post_type' => self::POST_TYPE, 'post_status' => ['publish', 'draft', 'private'], 'numberposts' => 200, 'orderby' => 'title', 'order' => 'ASC', // phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_key, WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- popup templates are identified by their type meta; bounded query. 'meta_key' => self::TYPE_META, 'meta_value' => 'popup', // phpcs:enable WordPress.DB.SlowDBQuery.slow_db_query_meta_key, WordPress.DB.SlowDBQuery.slow_db_query_meta_value 'suppress_filters' => false, ]); foreach (is_array($posts) ? $posts : [] as $post) { $title = (string) ($post->post_title ?? ''); $out[] = ['value' => (string) $post->ID, 'label' => $title !== '' ? $title : '#' . $post->ID]; } } return (array) apply_filters('zadex/forms/popup_options', $out); } }