settings(); $settings->add_tab( 'media', __( 'Media', 'all-in-one-utilities' ), __( 'Settings related to images and attachments.', 'all-in-one-utilities' ), 30 ); $settings->add_section( 'media', 'default_featured_image', __( 'Default Featured Image', 'all-in-one-utilities' ), __( 'Show a fallback featured image for content that does not have one set.', 'all-in-one-utilities' ), 10 ); $settings->add_field( 'media', 'default_featured_image', new Field( id: 'enabled', label: __( 'Enable Default Featured Image', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Use a fallback image when a post has none', 'all-in-one-utilities' ) ), doc: new Doc( title: __( 'Default Featured Image', 'all-in-one-utilities' ), short: __( 'Applies a sitewide fallback thumbnail wherever a supported post has no featured image set.', 'all-in-one-utilities' ), detailed: __( 'The fallback never overwrites a real featured image; it only fills in visually when a post would otherwise have none.', 'all-in-one-utilities' ) ), priority: 10 ) ); $settings->add_field( 'media', 'default_featured_image', new Field( id: 'image_id', label: __( 'Fallback image', 'all-in-one-utilities' ), type: 'media', default: 0, args: array( 'depends_on' => 'enabled' ), doc: new Doc( title: __( 'Fallback image', 'all-in-one-utilities' ), short: __( 'The image used whenever a supported post type has no featured image.', 'all-in-one-utilities' ) ), priority: 20 ) ); $settings->add_field( 'media', 'default_featured_image', new Field( id: 'post_types', label: __( 'Apply to', 'all-in-one-utilities' ), type: 'post_types', default: array( 'post', 'page' ), // Worked out when the field is shown, not now: modules boot at // `init` priority 0, before most custom post types (and // WooCommerce Products) are registered. args: array( 'choices' => static fn(): array => PostTypes::eligible(), 'depends_on' => 'enabled', ), doc: new Doc( title: __( 'Supported content types', 'all-in-one-utilities' ), short: __( 'Only public post types that support featured images are shown here.', 'all-in-one-utilities' ), detailed: __( 'Additional post types (e.g. WooCommerce Products) can be unlocked by the Pro add-on.', 'all-in-one-utilities' ) ), priority: 30 ) ); if ( $settings->get_value( 'media', 'default_featured_image', 'enabled', 0 ) ) { ( new Feature() )->register(); } } }