PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.3.1
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.3.1
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 2.3.1, at views/part-settings-webp.php

229 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Imagify\Stats\OptimizedMediaWithoutNextGen;
4 use Imagify\Webp\Display;
5
6 defined( 'ABSPATH' ) || exit;
7
8 $settings = Imagify_Settings::get_instance();
9 ?>
10 <div>
11 <h3 class="imagify-options-subtitle"><?php esc_html_e( 'Next-Gen image format', 'imagify' ); ?></h3>
12
13 <div class="imagify-setting-line">
14 <?php
15 $message = __( 'Select WebP for high compatibility, AVIF for superior compression. Please note that the generation process will start automatically after saving the settings.', 'imagify' );
16 $message_class = 'info';
17 $disabled = false;
18
19 if ( has_filter( 'imagify_nextgen_images_formats' ) ) {
20 $message = sprintf(
21 // translators: %1$s and %2$s are <code> tag opening and closing, %3$s and %4$s are <a> tag opening and closing.
22 __( 'Next-Gen Images format is currently defined by the %1$simagify_nextgen_images_format%2$s filter. %3$sRead more%4$s', 'imagify' ),
23 '<code>',
24 '</code>',
25 '<a href="https://imagify.io/documentation/how-to-use-the-next-gen-image-format-filter/" target="_blank">',
26 '</a>'
27 );
28
29 $message_class = 'error';
30 $disabled = true;
31 }
32
33 $attributes = [
34 'aria-describedby' => 'describe-optimization_format',
35 ];
36
37 if ( $disabled ) {
38 $attributes['disabled'] = true;
39 }
40
41 $settings->field_inline_radio_list(
42 [
43 'option_name' => 'optimization_format',
44 'legend' => __( 'Next-gen image format', 'imagify' ),
45 'info' => $message,
46 'info_class' => $message_class,
47 'values' => [
48 'off' => __( 'Off', 'imagify' ),
49 'avif' => __( 'AVIF', 'imagify' ),
50 'webp' => __( 'WebP', 'imagify' ),
51 ],
52 'attributes' => $attributes,
53 ]
54 );
55 ?>
56 </div>
57
58 <div class="imagify-setting-line">
59
60 <div class="imagify-options-line">
61 <?php
62 $settings->field_checkbox(
63 [
64 'option_name' => 'display_nextgen',
65 'label' => __( 'Display images in Next-Gen format on the site', 'imagify' ),
66 ]
67 );
68 ?>
69
70 <div class="imagify-options-line">
71 <?php
72 $settings->field_radio_list(
73 [
74 'option_name' => 'display_nextgen_method',
75 'values' => [
76 'rewrite' => __( 'Use rewrite rules', 'imagify' ),
77 /* translators: 1 and 2 are <em> tag opening and closing. */
78 'picture' => sprintf( __( 'Use &lt;picture&gt; tags %1$s(preferred)%2$s', 'imagify' ), '<em>', '</em>' ),
79 ],
80 'attributes' => [
81 'aria-describedby' => 'describe-convert_to_webp',
82 ],
83 ]
84 );
85 ?>
86
87 <div class="imagify-options-line">
88 <?php
89 $cdn_source = apply_filters( 'imagify_cdn_source_url', '' );
90
91 if ( 'option' !== $cdn_source['source'] ) {
92 if ( 'constant' === $cdn_source['source'] ) {
93 printf(
94 /* translators: 1 is an URL, 2 is a php constant name. */
95 esc_html__( 'Your CDN URL is set to %1$s by the constant %2$s.', 'imagify' ),
96 '<code>' . esc_url( $cdn_source['url'] ) . '</code>',
97 '<code>' . esc_html( $cdn_source['name'] ) . '</code>'
98 );
99 } elseif ( ! empty( $cdn_source['name'] ) ) {
100 printf(
101 /* translators: 1 is an URL, 2 is a plugin name. */
102 esc_html__( 'Your CDN URL is set to %1$s by %2$s.', 'imagify' ),
103 '<code>' . esc_url( $cdn_source['url'] ) . '</code>',
104 '<code>' . esc_html( $cdn_source['name'] ) . '</code>'
105 );
106 } else {
107 printf(
108 /* translators: %s is an URL. */
109 esc_html__( 'Your CDN URL is set to %1$s by filter.', 'imagify' ),
110 '<code>' . esc_url( $cdn_source['url'] ) . '</code>'
111 );
112 }
113
114 $settings->field_hidden(
115 [
116 'option_name' => 'cdn_url',
117 'current_value' => $cdn_source['url'],
118 ]
119 );
120 } else {
121 $settings->field_text_box(
122 [
123 'option_name' => 'cdn_url',
124 'label' => __( 'If you use a CDN, specify the URL:', 'imagify' ),
125 'attributes' => [
126 'size' => 30,
127 'placeholder' => __( 'https://cdn.example.com', 'imagify' ),
128 ],
129 ]
130 );
131 }
132 ?>
133 </div>
134 </div>
135
136 <div id="describe-display_nextgen_method" class="imagify-info">
137 <span class="dashicons dashicons-info"></span>
138 <?php
139 $conf_file_path = Display::get_instance()->get_file_path( true );
140
141 if ( $conf_file_path ) {
142 printf(
143 /* translators: 1 is a file name, 2 is a <strong> tag opening, 3 is the <strong> tag closing. */
144 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' ),
145 '<code>' . esc_html( $conf_file_path ) . '</code>',
146 '<strong>',
147 '</strong>'
148 );
149
150 echo '<br/>';
151 }
152
153 printf(
154 /* translators: 1 and 2 are HTML tag names, 3 is a <strong> tag opening, 4 is the <strong> tag closing. */
155 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' ),
156 '<code>&lt;img&gt;</code>',
157 '<code>&lt;picture&gt;</code>',
158 '<strong>',
159 '</strong>'
160 );
161
162 echo '<br/>';
163
164 /**
165 * Add more information about WebP.
166 *
167 * @since 1.9
168 * @author Grégory Viguier
169 */
170 do_action( 'imagify_settings_webp_info' );
171 ?>
172 </div>
173 </div>
174
175 <?php
176 $count = OptimizedMediaWithoutNextGen::get_instance()->get_cached_stat();
177
178 if ( $count ) {
179 ?>
180 <div class="imagify-options-line hide-if-no-js generate-missing-webp">
181 <?php $this->print_template( 'part-settings-webp-missing-message', [ 'count' => $count ] ); ?>
182
183 <button id="imagify-generate-webp-versions" class="button imagify-button-primary imagify-button-mini" type="button">
184 <span class="dashicons dashicons-admin-generic"></span>
185 <span class="button-text"><?php esc_html_e( 'Generate missing Next-Gen images versions', 'imagify' ); ?></span>
186 </button>
187
188 <?php
189 $remaining = OptimizedMediaWithoutNextGen::get_instance()->get_stat();
190 $total = get_transient( 'imagify_missing_next_gen_total' );
191 $progress = 0;
192 $aria = ' aria-hidden="true"';
193 $class = 'hidden';
194 $style = '';
195
196 if (
197 false !== $total
198 &&
199 $total > 0
200 ) {
201 $aria = '';
202 $class = '';
203 $processed = $total - $remaining;
204 $progress = $processed . '/' . $total;
205 $percent = $processed / $total * 100;
206 $style = 'style="width:' . $percent . '%;"';
207 }
208 ?>
209
210 <div <?php echo $aria; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> class="imagify-progress <?php echo esc_attr( $class ); ?>">
211 <div class="progress">
212 <div class="bar" <?php echo $style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>><div class="percent"><?php echo esc_html( $progress ); ?></div></div>
213 </div>
214 </div>
215 </div>
216 <?php
217 if ( Imagify_Requirements::is_api_key_valid() ) {
218 ?>
219 <script type="text/html" id="tmpl-imagify-overquota-alert">
220 <?php $this->print_template( 'part-bulk-optimization-overquota-alert' ); ?>
221 </script>
222 <?php
223 }
224 }
225 ?>
226 </div>
227 </div>
228 <?php
229