| 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 <picture> 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><img></code>', |
| 109 |
'<code><picture></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 |
|