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

192 lines 6.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' ) || die( 'Cheatin’ uh?' );
7
8 $settings = Imagify_Settings::get_instance();
9 ?>
10 <div>
11 <h3 class="imagify-options-subtitle"><?php _e( 'Next-Gen image format', 'imagify' ); ?></h3>
12
13 <div class="imagify-setting-line">
14 <?php
15 $settings->field_checkbox( [
16 'option_name' => 'convert_to_avif',
17 'label' => __( 'Create AVIF versions of images', 'imagify' ),
18 'attributes' => [
19 'aria-describedby' => 'describe-convert_to_avif',
20 ],
21 ] );
22 ?>
23 <div class="imagify-info">
24 <span class="dashicons dashicons-info"></span>
25 <?php esc_html_e( 'Enabling this option will start the process of creating AVIF version of your images automatically.', 'imagify' ); ?>
26 </div>
27 </div>
28
29 <div class="imagify-setting-line">
30
31 <div class="imagify-options-line">
32 <?php
33 $settings->field_checkbox( [
34 'option_name' => 'display_nextgen',
35 'label' => __( 'Display images in Next-Gen format on the site', 'imagify' ),
36 ] );
37 ?>
38
39 <div class="imagify-options-line">
40 <?php
41 $settings->field_radio_list( [
42 'option_name' => 'display_nextgen_method',
43 'values' => [
44 'rewrite' => __( 'Use rewrite rules', 'imagify' ),
45 /* translators: 1 and 2 are <em> tag opening and closing. */
46 'picture' => sprintf( __( 'Use &lt;picture&gt; tags %1$s(preferred)%2$s', 'imagify' ), '<em>', '</em>' ),
47 ],
48 'attributes' => [
49 'aria-describedby' => 'describe-convert_to_webp',
50 ],
51 ] );
52 ?>
53
54 <div class="imagify-options-line">
55 <?php
56 $cdn_source = apply_filters( 'imagify_cdn_source_url', '' );
57
58 if ( 'option' !== $cdn_source['source'] ) {
59 if ( 'constant' === $cdn_source['source'] ) {
60 printf(
61 /* translators: 1 is an URL, 2 is a php constant name. */
62 esc_html__( 'Your CDN URL is set to %1$s by the constant %2$s.', 'imagify' ),
63 '<code>' . esc_url( $cdn_source['url'] ) . '</code>',
64 '<code>' . esc_html( $cdn_source['name'] ) . '</code>'
65 );
66 } elseif ( ! empty( $cdn_source['name'] ) ) {
67 printf(
68 /* translators: 1 is an URL, 2 is a plugin name. */
69 esc_html__( 'Your CDN URL is set to %1$s by %2$s.', 'imagify' ),
70 '<code>' . esc_url( $cdn_source['url'] ) . '</code>',
71 '<code>' . esc_html( $cdn_source['name'] ) . '</code>'
72 );
73 } else {
74 printf(
75 /* translators: %s is an URL. */
76 esc_html__( 'Your CDN URL is set to %1$s by filter.', 'imagify' ),
77 '<code>' . esc_url( $cdn_source['url'] ) . '</code>'
78 );
79 }
80
81 $settings->field_hidden( [
82 'option_name' => 'cdn_url',
83 'current_value' => $cdn_source['url'],
84 ] );
85 } else {
86 $settings->field_text_box( [
87 'option_name' => 'cdn_url',
88 'label' => __( 'If you use a CDN, specify the URL:', 'imagify' ),
89 'attributes' => [
90 'size' => 30,
91 'placeholder' => __( 'https://cdn.example.com', 'imagify' ),
92 ],
93 ] );
94 }
95 ?>
96 </div>
97 </div>
98
99 <div id="describe-display_nextgen_method" class="imagify-info">
100 <span class="dashicons dashicons-info"></span>
101 <?php
102 $conf_file_path = Display::get_instance()->get_file_path( true );
103
104 if ( $conf_file_path ) {
105 printf(
106 /* translators: 1 is a file name, 2 is a <strong> tag opening, 3 is the <strong> tag closing. */
107 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' ),
108 '<code>' . esc_html( $conf_file_path ) . '</code>',
109 '<strong>',
110 '</strong>'
111 );
112
113 echo '<br/>';
114 }
115
116 printf(
117 /* translators: 1 and 2 are HTML tag names, 3 is a <strong> tag opening, 4 is the <strong> tag closing. */
118 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' ),
119 '<code>&lt;img&gt;</code>',
120 '<code>&lt;picture&gt;</code>',
121 '<strong>',
122 '</strong>'
123 );
124
125 echo '<br/>';
126
127 /**
128 * Add more information about WebP.
129 *
130 * @since 1.9
131 * @author Grégory Viguier
132 */
133 do_action( 'imagify_settings_webp_info' );
134 ?>
135 </div>
136 </div>
137
138 <?php
139 $count = OptimizedMediaWithoutNextGen::get_instance()->get_cached_stat();
140
141 if ( $count ) {
142 ?>
143 <div class="imagify-options-line hide-if-no-js generate-missing-webp">
144 <?php $this->print_template( 'part-settings-webp-missing-message', [ 'count' => $count ] ); ?>
145
146 <button id="imagify-generate-webp-versions" class="button imagify-button-primary imagify-button-mini" type="button">
147 <span class="dashicons dashicons-admin-generic"></span>
148 <span class="button-text"><?php esc_html_e( 'Generate missing Next-Gen images versions', 'imagify' ); ?></span>
149 </button>
150
151 <?php
152 $remaining = OptimizedMediaWithoutNextGen::get_instance()->get_stat();
153 $total = get_transient( 'imagify_missing_next_gen_total' );
154 $progress = 0;
155 $aria = ' aria-hidden="true"';
156 $class = 'hidden';
157 $style = '';
158
159 if (
160 false !== $total
161 &&
162 $total > 0
163 ) {
164 $aria = '';
165 $class = '';
166 $processed = $total - $remaining;
167 $progress = $processed . '/' . $total;
168 $percent = $processed / $total * 100;
169 $style = 'style="width:' . $percent . '%;"';
170 }
171 ?>
172
173 <div <?php echo $aria; ?> class="imagify-progress <?php echo $class; ?>">
174 <div class="progress">
175 <div class="bar" <?php echo $style; ?>><div class="percent"><?php echo $progress; ?></div></div>
176 </div>
177 </div>
178 </div>
179 <?php
180 if ( Imagify_Requirements::is_api_key_valid() ) {
181 ?>
182 <script type="text/html" id="tmpl-imagify-overquota-alert">
183 <?php $this->print_template( 'part-bulk-optimization-overquota-alert' ); ?>
184 </script>
185 <?php
186 }
187 }
188 ?>
189 </div>
190 </div>
191 <?php
192