settings = Settings::get_instance(); $this->register_filter( 'wp_smush_settings', array( $this, 'register_cdn_settings' ) ); $this->register_action( 'smush_setting_column_right_inside', array( $this, 'settings_desc' ), 10, 2 ); } /** * Add settings to settings array. * * @param array $settings Current settings array. * * @return array * @since 3.0 */ public function register_cdn_settings( $settings ) { $next_gen_cdn_key = Settings::NEXT_GEN_CDN_KEY; return array_merge( $settings, array( 'background_images' => array( 'label' => __( 'Serve background images from the CDN', 'wp-smushit' ), 'short_label' => __( 'Background Images', 'wp-smushit' ), 'desc' => __( 'Where possible we will serve background images declared with CSS directly from the CDN.', 'wp-smushit' ), ), 'auto_resize' => array( 'label' => __( 'Enable automatic resizing of my images', 'wp-smushit' ), 'short_label' => __( 'Automatic Resizing', 'wp-smushit' ), 'desc' => __( 'If your images don’t match their containers, we’ll automatically serve a correctly sized image.', 'wp-smushit' ), ), $next_gen_cdn_key => array( 'label' => __( 'Choose Format Settings', 'wp-smushit' ), 'short_label' => __( 'Next-Gen Conversion', 'wp-smushit' ), 'desc' => __( 'Smush can automatically convert and serve your images as WebP or AVIF to compatible browsers.', 'wp-smushit' ), ), 'rest_api_support' => array( 'label' => __( 'Enable REST API support', 'wp-smushit' ), 'short_label' => __( 'REST API', 'wp-smushit' ), 'desc' => __( 'Smush can automatically replace image URLs when fetched via REST API endpoints.', 'wp-smushit' ), ), ) ); } /** * Show additional descriptions for settings. * * @param string $setting_key Setting key. * * @since 3.0 */ public function settings_desc( $setting_key = '' ) { if ( empty( $setting_key ) || ! in_array( $setting_key, $this->settings->get_cdn_fields(), true ) || Settings::NEXT_GEN_CDN_KEY === $setting_key ) { return; } ?> '; printf( /* translators: %1$s - opening tag, %2$s - closing tag */ esc_html__( 'Note: Smush will pre-fill the srcset attribute with missing image sizes so for this feature to work, those must be declared properly by your theme and page builder using the %1$scontent width%2$s variable.', 'wp-smushit' ), '', '' ); break; case 'background_images': printf( /* translators: %1$s - Open the link , %2$s - Closing link tag */ esc_html__( 'Note: For this feature to work your theme’s background images must be declared correctly using the default %1$swp_attachment%2$s functions.', 'wp-smushit' ), '', '' ); echo '
'; printf( /* translators: %1$s - Open the link , %2$s - closing link tag */ esc_html__( 'For any non-media library uploads, you can still use the %1$sDirectory Smush%2$s feature to compress them, they just won’t be served from the CDN.', 'wp-smushit' ), '', '' ); break; case 'rest_api_support': printf( /* translators: %1$s - Open a link , %2$s - closing link tag */ esc_html__( 'Note: Smush will use the %1$srest_pre_echo_response%2$s hook to filter images in REST API responses.', 'wp-smushit' ), '', '' ); break; default: break; } ?>