/** * Add "Page for * posts" dropdowns to the reading settings page. * * @since 1.0.0 */ public static function register_settings() { $registered = 0; foreach (Registry::get_post_types() as $post_type) { // Skip if post type does not exist or does not support archives if (!post_type_exists($post_type) || !get_post_type_object($post_type)->has_archive) { continue; } $option_name = "page_for_{$post_type}_posts"; register_setting('reading', $option_name, 'intval'); add_settings_field($option_name, self::get_index_page_label($post_type), array(__CLASS__, 'do_settings_field'), 'reading', 'index_pages', array('label_for' => $option_name, 'post_type' => $post_type)); $registered++; } // If any settings were registered, add the settings output if ($registered > 0) { add_settings_section('index_pages', __('Index Pages', 'index-pages'), array(__CLASS__, 'do_settings_section'), 'reading'); } }