Changeset 3137081
- Timestamp:
- 08/17/2024 04:52:18 PM (20 months ago)
- Location:
- wp-multitasking/trunk
- Files:
-
- 1 added
- 4 edited
-
includes/pagespeed-insights.php (modified) (6 diffs)
-
includes/psi/settings.php (modified) (5 diffs)
-
js/lazysizes.min.js (added)
-
readme.txt (modified) (2 diffs)
-
wp-multitasking.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-multitasking/trunk/includes/pagespeed-insights.php
r3137020 r3137081 15 15 $webp_enabled = intval(get_option('wpmt_psi_image_webp')); 16 16 if ($webp_enabled == 1) { 17 add_filter('wp_get_attachment_image', array(&$this, 'psi_wp_get_attachment_image'), 20, 4); 17 add_filter('wp_get_attachment_image', array(&$this, 'psi_wp_get_attachment_image'), 10, 4); 18 add_filter('woocommerce_product_get_image', array(&$this, 'psi_woocommerce_product_get_image'), 10, 5); 18 19 } 19 20 … … 26 27 $psi_score = intval(get_option('wpmt_psi_score')); 27 28 if ($psi_score == 1) { 28 add_action( 'wp_enqueue_scripts', array(&$this, 'psi_enqueued_scripts'), 100 ); 29 } 29 add_action( 'wp_enqueue_scripts', array(&$this, 'psi_dequeued_scripts'), 100 ); 30 } 31 32 add_action( 'wp_enqueue_scripts', array(&$this, 'psi_enqueue_scripts') ); 30 33 } 31 34 } … … 77 80 } 78 81 /** 82 * Render html support woocommerce 83 */ 84 function psi_woocommerce_product_get_image( $image, $that, $size, $attr, $placeholder ){ 85 // Load the HTML 86 $doc = new DOMDocument(); 87 libxml_use_internal_errors(true); // Suppress errors due to invalid HTML 88 $doc->loadHTML($image); 89 libxml_clear_errors(); 90 91 // Use DOMXPath to query the img tag 92 $xpath = new DOMXPath($doc); 93 $img_element = $xpath->query("//img")->item(0); 94 95 // Extract the attributes 96 $width = $img_element->getAttribute('width'); 97 $height = $img_element->getAttribute('height'); 98 $src = $img_element->getAttribute('src'); 99 $alt = $img_element->getAttribute('alt'); 100 $class = $img_element->getAttribute('class'); 101 102 // Replace with new values 103 // $image_size = !empty($size) ? $size : 'woocommerce_thumbnail'; 104 // $custom_class = 'attachment-'.$image_size.' size-'.$image_size; 105 $custom_class = $class; 106 if (empty($alt)) { 107 $alt = $that->name; 108 } 109 $image_webp_url = $src . '.webp'; 110 $custom_html = '<img width="'.esc_attr($width).'" height="'.esc_attr($height).'" src="' . esc_url($src) . '" srcset="' . esc_url($image_webp_url) . '" alt="' . esc_attr($alt) . '" class="' . esc_attr( $custom_class ) . '" />'; 111 112 // Lazyload 113 $image_lazyload = intval(get_option('wpmt_psi_image_lazyload')); 114 if ($image_lazyload == 1) { 115 $custom_class .= ' lazyload'; 116 $custom_html = '<img width="'.esc_attr($width).'" height="'.esc_attr($height).'" data-src="' . esc_url($src) . '" data-srcset="' . esc_url($image_webp_url) . '" alt="' . esc_attr($alt) . '" class="' . esc_attr( $custom_class ) . '" />'; 117 } 118 119 return $custom_html; 120 } 121 /** 79 122 * Custom render html for display 80 123 */ … … 108 151 $height = $image_size['height']; 109 152 153 // Lazyload 154 $custom_class = 'attachment-'.$size.' size-'.$size; 155 $image_lazyload = intval(get_option('wpmt_psi_image_lazyload')); 156 if ($image_lazyload == 1) { 157 $custom_class .= ' lazyload'; 158 // Generate the custom HTML 159 $custom_html = sprintf( 160 '<img data-src="%1$s" data-srcset="%2$s" alt="%3$s" width="%4$s" height="%5$s" class="%6$s" />', 161 esc_url($image_url), 162 esc_url($image_webp_url), 163 esc_attr($image_title), 164 esc_attr($width), 165 esc_attr($height), 166 esc_attr($custom_class) 167 ); 168 169 return $custom_html; 170 } 171 110 172 // Generate the custom HTML 111 173 $custom_html = sprintf( 112 '<img src="%1$s" srcset="%2$s" alt="%3$s" width="%4$s" height="%5$s" class=" " />',174 '<img src="%1$s" srcset="%2$s" alt="%3$s" width="%4$s" height="%5$s" class="%6$s" />', 113 175 esc_url($image_url), 114 176 esc_url($image_webp_url), 115 177 esc_attr($image_title), 116 178 esc_attr($width), 117 esc_attr($height) 179 esc_attr($height), 180 esc_attr($custom_class) 118 181 ); 119 182 … … 266 329 * Remove js for PSI 267 330 */ 268 function psi_ enqueued_scripts() {331 function psi_dequeued_scripts() { 269 332 global $wp_scripts; 270 333 … … 278 341 } 279 342 } 343 /** 344 * Add scripts 345 */ 346 function psi_enqueue_scripts() { 347 $image_lazyload = intval(get_option('wpmt_psi_image_lazyload')); 348 if ($image_lazyload == 1) { 349 wp_enqueue_script( 'wpmt-psi-lazysizes', WPMT_PLUGIN_URL . 'js/lazysizes.min.js', array( 'jquery' ), WPMT_VER, true ); 350 } 351 } 280 352 } 281 353 -
wp-multitasking/trunk/includes/psi/settings.php
r3137020 r3137081 2 2 if (isset($_POST['action']) and 'save' == $_POST['action']) { 3 3 if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'security_nonce')) { 4 $fields = ['wpmt_psi_image_ webp', 'wpmt_psi_score', 'wpmt_psi_wprocket_css_inline'];4 $fields = ['wpmt_psi_image_lazyload', 'wpmt_psi_image_webp', 'wpmt_psi_score', 'wpmt_psi_wprocket_css_inline']; 5 5 foreach ($fields as $field) { 6 6 if (isset($_REQUEST[$field]) and !empty($_REQUEST[$field])) { … … 21 21 22 22 $image_webp = intval(get_option('wpmt_psi_image_webp')); 23 $image_lazyload = intval(get_option('wpmt_psi_image_lazyload')); 23 24 $psi_score = intval(get_option('wpmt_psi_score')); 24 25 $wprocket_css_inline = intval(get_option('wpmt_psi_wprocket_css_inline')); … … 31 32 </td> 32 33 <td> 33 <a class="button button-large button-primary" href="<?php echo esc_url('admin.php?page=wpmt_psi&convert=webp') ?>" target="_blank">START</a> 34 <p><a class="button button-large button-primary" href="<?php echo esc_url('admin.php?page=wpmt_psi&convert=webp') ?>" target="_blank">START</a></p> 35 <div>Don't worry! WebP generation is no error occur and does not affect existing images.</div> 34 36 </td> 35 37 </tr> … … 43 45 <option value="1" <?php echo ($image_webp == 1) ? "selected" : ""; ?>>Enabled</option> 44 46 </select> 47 </td> 48 </tr> 49 <tr> 50 <td> 51 <label for="wpmt_psi_image_lazyload">Lazyload for images:</label> 52 </td> 53 <td> 54 <select name="wpmt_psi_image_lazyload" id="wpmt_psi_image_lazyload" class="regular-text"> 55 <option value="0" <?php echo ($image_lazyload != 1) ? "selected" : ""; ?>>Disabled</option> 56 <option value="1" <?php echo ($image_lazyload == 1) ? "selected" : ""; ?>>Enabled</option> 57 </select><br/> 58 <div>Please disable lazyload images from WP Rocket and other plugins.</div> 45 59 </td> 46 60 </tr> … … 66 80 </select><br/> 67 81 <p> 68 This option required plugin <a href="https://docs.wp-rocket.me/article/61-disable-page-caching" target="_blank">WP Rocket | Disable Page Caching</a> 82 This option required:<br/> 83 - CSS minify and combine with WP Rocket<br/> 84 - Activate plugin <a href="https://docs.wp-rocket.me/article/61-disable-page-caching" target="_blank">WP Rocket | Disable Page Caching</a> 69 85 </p> 86 </td> 87 </tr> 88 <tr> 89 <td>Recommends:</td> 90 <td> 91 <p>HTML Minify with plugin <a href="https://wordpress.org/plugins/autoptimize/" target="_blank">Autoptimize</a></p> 92 <p>JS minify you can use any plugin</p> 70 93 </td> 71 94 </tr> -
wp-multitasking/trunk/readme.txt
r3137020 r3137081 5 5 Requires at least: 2.1.0 6 6 Tested up to: 6.4.2 7 Stable tag: 0.1.1 47 Stable tag: 0.1.15 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 86 86 == Changelog == 87 87 88 = 0.1.15 = 89 * Update PSI 90 * Add lazyload images 91 * Support WebP for woocommerce 92 88 93 = 0.1.14 = 89 94 * Fix missing files -
wp-multitasking/trunk/wp-multitasking.php
r3137020 r3137081 4 4 Plugin URI: http://wordpress.org/plugins/wp-multitasking/ 5 5 Description: This plugin is synthetic utility for your WordPress site: Shortcode, BBCode, AddQuickTag, Exit pop-up, Welcome pop-up, Remove base slug, SMTP, Classic Editor, Classic widgets... 6 Version: 0.1.1 46 Version: 0.1.15 7 7 Author: thangnv27 8 8 Author URI: https://ngothang.me/ … … 22 22 23 23 if ( ! defined( 'WPMT_VER' ) ) 24 define( 'WPMT_VER', '0.1. 8' );24 define( 'WPMT_VER', '0.1.15' ); 25 25 26 26 add_action('admin_menu', 'wpmt_add_settings_page');
Note: See TracChangeset
for help on using the changeset viewer.