PluginProbe
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress / 4.1.1
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress v4.1.1
4.1.1 4.1.0 4.0.1 4.0.0 3.3.1 3.3.0 trunk 1.0.0 2.0.0 2.1.0 3.0.0 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8
← All changes | admin/class-settings.php +91 -0 4.0.14.1.1 View file →
@@ -62,8 +62,93 @@
62 62 'default_image_url' => QUICKWEBP_PLUGIN_URL . 'public/assets/img/preview.jpg',
63 63 ));
64 64 }
65 65 }
66 +
67 + /**
68 + * Persist dismissal of the contextual AVIF notice for the current user.
69 + */
70 + public function dismiss_avif_notice() {
71 + if ( ! isset( $_GET['quickwebp_dismiss_avif_notice'] ) || ! current_user_can( 'manage_options' ) ) {
72 + return;
73 + }
74 +
75 + check_admin_referer( 'quickwebp_dismiss_avif_notice' );
76 + update_user_meta( get_current_user_id(), 'quickwebp_avif_notice_dismissed', 1 );
77 +
78 + wp_safe_redirect( remove_query_arg( array( 'quickwebp_dismiss_avif_notice', '_wpnonce' ) ) );
79 + exit;
80 + }
81 +
82 + /**
83 + * Render the contextual AVIF upgrade notice outside QuickWebP screens.
84 + */
85 + public function render_avif_notice() {
86 + global $quickwebp_surecart_client;
87 +
88 + if ( ! current_user_can( 'manage_options' ) || get_user_meta( get_current_user_id(), 'quickwebp_avif_notice_dismissed', true ) ) {
89 + return;
90 + }
91 +
92 + $screen = get_current_screen();
93 + if ( $screen && false !== strpos( $screen->id, 'quickwebp' ) ) {
94 + return;
95 + }
96 +
97 + if ( $quickwebp_surecart_client && $quickwebp_surecart_client->license()->is_valid() ) {
98 + return;
99 + }
100 +
101 + $stats = get_option( 'quickwebp_optimization_stats', array() );
102 + $image_count = absint( $stats['images_optimized'] ?? 0 );
103 + $bytes_saved = absint( $stats['bytes_saved'] ?? 0 );
104 + $installed_at = absint( get_option( 'quickwebp_installed_at', 0 ) );
105 + $seven_days = 7 * DAY_IN_SECONDS;
106 +
107 + if ( $image_count < 20 && ( ! $installed_at || time() - $installed_at < $seven_days ) ) {
108 + return;
109 + }
110 +
111 + $avif_supported = function_exists( 'wp_image_editor_supports' ) && wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) );
112 + if ( ! $avif_supported ) {
113 + return;
114 + }
115 +
116 + $dismiss_url = wp_nonce_url(
117 + add_query_arg( 'quickwebp_dismiss_avif_notice', '1' ),
118 + 'quickwebp_dismiss_avif_notice'
119 + );
120 + ?>
121 + <div class="notice notice-success quickwebp-avif-notice">
122 + <p>
123 + <strong>
124 + <?php
125 + printf(
126 + /* translators: %s is the number of images optimized by QuickWebP. */
127 + esc_html( _n( 'QuickWebP has already optimized %s image on your site.', 'QuickWebP has already optimized %s images on your site.', $image_count, 'quickwebp' ) ),
128 + esc_html( number_format_i18n( $image_count ) )
129 + );
130 + ?>
131 + </strong>
132 + </p>
133 + <p>
134 + <?php
135 + printf(
136 + /* translators: %s is the disk space saved by QuickWebP. */
137 + esc_html__( 'You have saved %s thanks to WebP.', 'quickwebp' ),
138 + '<strong>' . esc_html( size_format( $bytes_saved, 1 ) ) . '</strong>'
139 + );
140 + ?>
141 + </p>
142 + <p><strong><?php esc_html_e( 'Your server also supports AVIF.', 'quickwebp' ); ?></strong></p>
143 + <p><strong><?php esc_html_e( 'With AVIF, your WebP images could be around 30% smaller on average.', 'quickwebp' ); ?></strong></p>
144 + <p>
145 + <a class="button button-primary" href="<?php echo esc_url( quickwebp_get_pro_url( 'avif-admin-notice' ) ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Discover AVIF', 'quickwebp' ); ?></a>
146 + <a class="button-link" href="<?php echo esc_url( $dismiss_url ); ?>"><?php esc_html_e( 'Dismiss', 'quickwebp' ); ?></a>
147 + </p>
148 + </div>
149 + <?php
150 + }
66 151
67 152 /**
68 153 * add_settings_menu
69 154 *
@@ -169,8 +254,14 @@
169 254 $new_actions['settings'] = sprintf(
170 255 // translators: %s is a placeholder for the link to the settings page.
171 256 __( '<a href="%s">Settings</a>', 'quickwebp' ),
172 257 esc_url( admin_url( 'upload.php?page=quickwebp-settings' ) )
258 + );
259 +
260 + $new_actions['upgrade_pro'] = sprintf(
261 + '<a href="%1$s" target="_blank" rel="noopener noreferrer" style="color: #008a20; font-weight: 600;">%2$s</a>',
262 + esc_url( quickwebp_get_pro_url( 'plugins-list-upgrade' ) ),
263 + esc_html__( 'Upgrade to Pro', 'quickwebp' )
173 264 );
174 265 }
175 266
176 267 return array_merge( $new_actions, $plugin_actions );