PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.10
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.10
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / views / part-settings-webp.php

part-settings-webp.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.10, at views/part-settings-webp.php

169 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
3
4 $settings = Imagify_Settings::get_instance();
5 ?>
6 <div>
7 <h3 class="imagify-options-subtitle"><?php _e( 'WebP format', 'imagify' ); ?></h3>
8
9 <div class="imagify-setting-line">
10 <?php
11 $settings->field_checkbox( [
12 'option_name' => 'convert_to_webp',
13 'label' => __( 'Create WebP versions of images', 'imagify' ),
14 'attributes' => [
15 'aria-describedby' => 'describe-convert_to_webp',
16 ],
17 ] );
18 ?>
19
20 <div class="imagify-options-line">
21 <?php
22 $settings->field_checkbox( [
23 'option_name' => 'display_webp',
24 'label' => __( 'Display images in WebP format on the site', 'imagify' ),
25 ] );
26 ?>
27
28 <div class="imagify-options-line">
29 <?php
30 $settings->field_radio_list( [
31 'option_name' => 'display_webp_method',
32 'values' => [
33 'rewrite' => __( 'Use rewrite rules', 'imagify' ),
34 /* translators: 1 and 2 are <em> tag opening and closing. */
35 'picture' => sprintf( __( 'Use &lt;picture&gt; tags %1$s(preferred)%2$s', 'imagify' ), '<em>', '</em>' ),
36 ],
37 'attributes' => [
38 'aria-describedby' => 'describe-convert_to_webp',
39 ],
40 ] );
41 ?>
42
43 <div class="imagify-options-line">
44 <?php
45 $cdn_source = \Imagify\Webp\Picture\Display::get_instance()->get_cdn_source();
46
47 if ( 'option' !== $cdn_source['source'] ) {
48 if ( 'constant' === $cdn_source['source'] ) {
49 printf(
50 /* translators: 1 is an URL, 2 is a php constant name. */
51 esc_html__( 'Your CDN URL is set to %1$s by the constant %2$s.', 'imagify' ),
52 '<code>' . esc_url( $cdn_source['url'] ) . '</code>',
53 '<code>' . esc_html( $cdn_source['name'] ) . '</code>'
54 );
55 } elseif ( ! empty( $cdn_source['name'] ) ) {
56 printf(
57 /* translators: 1 is an URL, 2 is a plugin name. */
58 esc_html__( 'Your CDN URL is set to %1$s by %2$s.', 'imagify' ),
59 '<code>' . esc_url( $cdn_source['url'] ) . '</code>',
60 '<code>' . esc_html( $cdn_source['name'] ) . '</code>'
61 );
62 } else {
63 printf(
64 /* translators: %s is an URL. */
65 esc_html__( 'Your CDN URL is set to %1$s by filter.', 'imagify' ),
66 '<code>' . esc_url( $cdn_source['url'] ) . '</code>'
67 );
68 }
69
70 $settings->field_hidden( [
71 'option_name' => 'cdn_url',
72 'current_value' => $cdn_source['url'],
73 ] );
74 } else {
75 $settings->field_text_box( [
76 'option_name' => 'cdn_url',
77 'label' => __( 'If you use a CDN, specify the URL:', 'imagify' ),
78 'attributes' => [
79 'size' => 30,
80 'placeholder' => __( 'https://cdn.example.com', 'imagify' ),
81 ],
82 ] );
83 }
84 ?>
85 </div>
86 </div>
87
88 <div id="describe-display_webp_method" class="imagify-info">
89 <span class="dashicons dashicons-info"></span>
90 <?php
91 $conf_file_path = \Imagify\Webp\Display::get_instance()->get_file_path( true );
92
93 if ( $conf_file_path ) {
94 printf(
95 /* translators: 1 is a file name, 2 is a <strong> tag opening, 3 is the <strong> tag closing. */
96 esc_html__( 'The first option adds rewrite rules to your site’s configuration file (%1$s) and does not alter your pages code. %2$sThis does not work with CDN though.%3$s', 'imagify' ),
97 '<code>' . esc_html( $conf_file_path ) . '</code>',
98 '<strong>',
99 '</strong>'
100 );
101
102 echo '<br/>';
103 }
104
105 printf(
106 /* translators: 1 and 2 are HTML tag names, 3 is a <strong> tag opening, 4 is the <strong> tag closing. */
107 esc_html__( 'The second option replaces the %1$s tags with %2$s tags. %3$sThis is the preferred solution but some themes may break%4$s, so make sure to verify that everything seems fine.', 'imagify' ),
108 '<code>&lt;img&gt;</code>',
109 '<code>&lt;picture&gt;</code>',
110 '<strong>',
111 '</strong>'
112 );
113
114 echo '<br/>';
115
116 /**
117 * Add more information about WebP.
118 *
119 * @since 1.9
120 * @author Grégory Viguier
121 */
122 do_action( 'imagify_settings_webp_info' );
123 ?>
124 </div>
125 </div>
126
127 <?php
128 $count = \Imagify\Stats\OptimizedMediaWithoutWebp::get_instance()->get_cached_stat();
129
130 if ( $count ) {
131 ?>
132 <div class="imagify-options-line hide-if-no-js">
133 <p>
134 <?php
135 echo esc_html(
136 sprintf(
137 /* translators: %s is a formatted number (don’t use %d). */
138 _n( 'It seems that you have %s optimized image without WebP versions. You can generate them here if a backup copy is available.', 'It seems that you have %s optimized images without WebP versions. You can generate them here if backup copies are available.', $count, 'imagify' ),
139 number_format_i18n( $count )
140 )
141 );
142 ?>
143 </p>
144
145 <button id="imagify-generate-webp-versions" class="button imagify-button-primary imagify-button-mini" type="button">
146 <span class="dashicons dashicons-admin-generic"></span>
147 <span class="button-text"><?php esc_html_e( 'Generate missing WebP versions', 'imagify' ); ?></span>
148 </button>
149
150 <div aria-hidden="true" class="imagify-progress hidden">
151 <div class="progress">
152 <div class="bar"><div class="percent">0</div></div>
153 </div>
154 </div>
155 </div>
156 <?php
157 if ( Imagify_Requirements::is_api_key_valid() ) {
158 ?>
159 <script type="text/html" id="tmpl-imagify-overquota-alert">
160 <?php $this->print_template( 'part-bulk-optimization-overquota-alert' ); ?>
161 </script>
162 <?php
163 }
164 }
165 ?>
166 </div>
167 </div>
168 <?php
169