[ 'default' => 'lossy' ], 'optimize_on_upload' => [ 'type' => 'boolean', 'default' => true, ], 'resize_larger_images' => [ 'type' => 'boolean', 'default' => true, ], 'resize_larger_images_size' => [ 'type' => 'integer', 'default' => 1920, ], 'exif_metadata' => [ 'type' => 'boolean', 'default' => true, ], 'original_images' => [ 'type' => 'boolean', 'default' => true, ], 'convert_to_format' => [ 'type' => 'string', 'default' => Image_Conversion_Option::WEBP, ], 'custom_sizes' => [ 'type' => 'string', 'default' => 'all', ], ]; } public function register_options() { $options = $this->get_options(); foreach ( $options as $key => &$args ) { $args['type'] = $args['type'] ?? 'string'; $args['show_in_rest'] = $args['show_in_rest'] ?? true; $args['default'] = $args['default'] ?? ''; register_setting( self::SETTING_GROUP, self::SETTING_PREFIX . $key, $args ); // Set defaults add_option( self::SETTING_PREFIX . $key, $args['default'] ); } } public function render_app() { ?>

register_components(); add_action( 'admin_init', [ $this, 'register_options' ] ); add_action( 'rest_api_init', [ $this, 'register_options' ] ); add_action( 'admin_init', [ $this, 'maybe_migrate_legacy_conversion_option' ] ); add_action( 'admin_menu', [ $this, 'register_page' ] ); } }