PluginProbe ʕ •ᴥ•ʔ
Smush – Image Optimization, Compression, Lazy Load, WebP & CDN / 3.15.3
Smush – Image Optimization, Compression, Lazy Load, WebP & CDN v3.15.3
4.1.0 4.0.3 4.0.2 2.8.1 2.9.1 3.0.0 3.0.1 3.0.2 3.1.1 3.10.1 3.10.2 3.10.3 3.11.1 3.12.3 3.12.4 3.12.5 3.12.6 3.13.0 3.13.1 3.13.2 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.15.2 3.15.3 3.15.4 3.15.5 3.16.2 3.16.4 3.16.5 3.16.6 3.17.0 3.17.1 3.18.0 3.18.1 3.2.0.1 3.2.1 3.2.2.1 3.2.4 3.20.0 3.21.1 3.22.1 3.22.3 3.23.0 3.23.1 3.23.2 3.23.3 3.23.4 3.24.0 3.24.0-beta.2 3.3.0 3.3.1 3.3.2 3.4.1 3.4.2 3.6.1 3.6.3 3.7.0 3.7.1 3.7.2 3.7.3 3.8.2 3.8.3 3.8.4 3.8.5 3.8.7 3.8.8 3.9.0 3.9.1 3.9.11 3.9.2 3.9.4 3.9.5 3.9.8 3.9.9 trunk 1.0.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.2 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.5.3 1.6.5.4 1.7 1.7.1 1.7.1.1 2.0 2.0.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.6.2 2.0.6.3 2.0.6.5 2.0.7 2.0.7.1 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.2 2.3 2.3.1 2.4 2.4.2 2.4.3 2.4.4 2.4.5 2.5.2 2.5.3 2.6.1 2.6.2 2.6.3 2.7 2.7.1 2.7.4 2.7.4.1 2.7.5 2.7.6 2.7.8 2.7.8.1 2.7.9.1 2.8.0 2.8.0.1
wp-smushit / app / pages / class-webp.php
wp-smushit / app / pages Last commit date
class-bulk.php 2 years ago class-cdn.php 2 years ago class-dashboard.php 2 years ago class-directory.php 2 years ago class-integrations.php 2 years ago class-lazy.php 2 years ago class-nextgen.php 2 years ago class-settings.php 2 years ago class-tutorials.php 2 years ago class-upgrade.php 2 years ago class-webp.php 2 years ago
class-webp.php
164 lines
1 <?php
2 /**
3 * Local WebP page.
4 *
5 * @package Smush\App\Pages
6 */
7
8 namespace Smush\App\Pages;
9
10 use Smush\App\Abstract_Summary_Page;
11 use Smush\App\Interface_Page;
12 use WP_Smush;
13
14 if ( ! defined( 'WPINC' ) ) {
15 die;
16 }
17
18 /**
19 * Class WebP
20 */
21 class WebP extends Abstract_Summary_Page implements Interface_Page {
22
23 /**
24 * Enqueue scripts.
25 *
26 * @since 3.9.0
27 *
28 * @param string $hook Hook from where the call is made.
29 */
30 public function enqueue_scripts( $hook ) {
31 // We only need this script for the wizard.
32 if ( ! $this->is_wizard() ) {
33 return;
34 }
35
36 wp_enqueue_script(
37 'smush-react-webp',
38 WP_SMUSH_URL . 'app/assets/js/smush-react-webp.min.js',
39 array( 'wp-i18n', 'smush-sui', 'clipboard' ),
40 WP_SMUSH_VERSION,
41 true
42 );
43
44 wp_add_inline_script(
45 'smush-react-webp',
46 'wp.i18n.setLocaleData( ' . wp_json_encode( $this->get_locale_data() ) . ', "wp-smushit" );',
47 'before'
48 );
49
50 $webp = WP_Smush::get_instance()->core()->mod->webp;
51
52 // Defining this here to esc_html before using dangerouslySetInnerHTML on frontend.
53 $third_step_message = ! is_multisite()
54 ? sprintf(
55 /* translators: 1. opening 'b' tag, 2. closing 'b' tag */
56 esc_html__(
57 'WebP versions of existing images in the Media Library can only be created by ‘smushing’ the originals via the Bulk Smush page. Click %1$sConvert Now%2$s to be redirected to the Bulk Smush page to start smushing your images.',
58 'wp-smushit'
59 ),
60 '<b>',
61 '</b>'
62 )
63 : sprintf(
64 /* translators: 1. opening 'b' tag, 2. closing 'b' tag */
65 esc_html__(
66 'WebP versions of existing images in the Media Library can only be created by ‘smushing’ the originals using the %1$sBulk Smush%2$s tool on each subsite.',
67 'wp-smushit'
68 ),
69 '<b>',
70 '</b>'
71 );
72
73 wp_localize_script(
74 'smush-react-webp',
75 'smushReact',
76 array(
77 'nonce' => wp_create_nonce( 'wp-smush-webp-nonce' ),
78 'isPro' => WP_Smush::is_pro(),
79 'detectedServer' => $webp->get_server_type(),
80 'apacheRules' => $webp->get_apache_code_to_print(),
81 'nginxRules' => $webp->get_nginx_code(),
82 'startStep' => true !== $webp->is_configured() || ! WP_Smush::is_pro() ? 1 : 3,
83 'isMultisite' => is_multisite(),
84 'isWpmudevHost' => isset( $_SERVER['WPMUDEV_HOSTED'] ),
85 'isWhitelabel' => apply_filters( 'wpmudev_branding_hide_doc_link', false ),
86 'isS3Enabled' => $this->settings->get( 's3' ) && ! WP_Smush::get_instance()->core()->s3->setting_status(),
87 'thirdStepMsg' => $third_step_message,
88 'urls' => array(
89 'bulkPage' => esc_url( admin_url( 'admin.php?page=smush-bulk' ) ),
90 'support' => 'https://wpmudev.com/hub2/support/#get-support',
91 'freeImg' => esc_url( WP_SMUSH_URL . 'app/assets/images/graphic-smush-webp-free-tier.png' ),
92 'freeImg2x' => esc_url( WP_SMUSH_URL . 'app/assets/images/graphic-smush-webp-free-tier@2x.png' ),
93 'webpDoc' => $this->get_utm_link( array( 'utm_campaign' => 'smush_webp_learnmore' ), 'https://wpmudev.com/blog/local-webp-support-smush/' ),
94 'upsell' => add_query_arg(
95 array(
96 'utm_source' => 'smush',
97 'utm_medium' => 'plugin',
98 'utm_campaign' => 'smush_webp_upgrade_button',
99 ),
100 $this->upgrade_url
101 ),
102 ),
103 )
104 );
105 }
106
107 /**
108 * Register meta boxes.
109 */
110 public function register_meta_boxes() {
111 parent::register_meta_boxes();
112
113 if ( $this->is_wizard() ) {
114 return;
115 }
116
117 if ( ! $this->settings->get( 'webp_mod' ) ) {
118 $this->add_meta_box(
119 'webp/disabled',
120 __( 'Local WebP', 'wp-smushit' ),
121 null,
122 array( $this, 'webp_meta_box_header' )
123 );
124
125 return;
126 }
127
128 $this->add_meta_box(
129 'webp/webp',
130 __( 'Local WebP', 'wp-smushit' ),
131 null,
132 array( $this, 'webp_meta_box_header' )
133 );
134
135 $this->modals['webp-delete-all'] = array();
136 }
137
138 /**
139 * WebP meta box header.
140 *
141 * @since 3.8.0
142 */
143 public function webp_meta_box_header() {
144 $this->view(
145 'webp/meta-box-header',
146 array(
147 'is_disabled' => ! $this->settings->get( 'webp_mod' ),
148 'is_configured' => true === WP_Smush::get_instance()->core()->mod->webp->is_configured(),
149 )
150 );
151 }
152
153 /**
154 * Whether the wizard should be displayed.
155 *
156 * @since 3.9.0
157 *
158 * @return bool
159 */
160 protected function is_wizard() {
161 return ( ! WP_Smush::is_pro() || ( $this->settings->get( 'webp_mod' ) && ! get_site_option( 'wp-smush-webp_hide_wizard' ) ) );
162 }
163 }
164