Changeset 3407383
- Timestamp:
- 12/01/2025 11:55:47 PM (4 months ago)
- Location:
- png-to-jpg/trunk
- Files:
-
- 2 edited
-
png-to-jpg.php (modified) (17 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
png-to-jpg/trunk/png-to-jpg.php
r3059378 r3407383 4 4 Plugin URI: https://wp-speedup.eu 5 5 Description: Convert PNG images to JPG, free up web space and speed up your webpage 6 Version: 4. 46 Version: 4.5 7 7 Author: KubiQ 8 8 Author URI: https://www.paypal.me/jakubnovaksl … … 11 11 */ 12 12 13 /*14 ** TODO15 ** - restore PNG version?16 */17 18 13 class png_to_jpg{ 19 14 var $plugin_admin_page; 20 15 var $settings; 21 var $db_tables;22 16 var $tab; 23 17 var $image; … … 40 34 add_filter( 'attachment_fields_to_edit', array( $this, 'attachment_fields_to_edit' ), 10, 2 ); 41 35 add_filter( 'wp_loaded', array( $this, 'convert_png_from_media_library' ), 10, 2 ); 36 37 add_filter( 'posts_clauses', function( $clauses, $query ){ 38 global $wpdb; 39 if( is_admin() ){ 40 $direction = $query->get('sort_filesize'); 41 if( in_array( $direction, [ 'asc', 'desc' ] ) ){ 42 $clauses['join'] .= " LEFT JOIN {$wpdb->postmeta} AS mt_filesize ON {$wpdb->posts}.ID = mt_filesize.post_id AND mt_filesize.meta_key = '_wp_attachment_metadata' "; 43 $clauses['orderby'] = "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(mt_filesize.meta_value, 's:8:\"filesize\";i:', -1), ';', 1) AS UNSIGNED) " . strtoupper( $direction ); 44 } 45 } 46 return $clauses; 47 }, 10, 2 ); 42 48 } 43 49 … … 190 196 global $wpdb; 191 197 $this->settings = get_option('png_to_jpg_settings'); 192 $this->db_tables = $wpdb->get_col('SHOW TABLES');193 198 } 194 199 … … 348 353 wp_enqueue_media(); 349 354 $paged = isset( $_GET['paged'] ) && intval( $_GET['paged'] ) ? intval( $_GET['paged'] ) : 1; 350 $ query_images = new WP_Query(array(355 $args = [ 351 356 'post_type' => 'attachment', 352 357 'post_mime_type' => 'image/png', … … 354 359 'posts_per_page' => $this->settings['general']['images_per_page'], 355 360 'paged' => $paged, 356 )); ?> 361 ]; 362 if( ! empty( $_GET['order'] ) ){ 363 $args['sort_filesize'] = $_GET['order'] == 'asc' ? 'asc' : 'desc'; 364 } 365 $query_images = new WP_Query( $args ); ?> 357 366 <div class="below-h2 error"><p><strong><?php _e( 'Do you have BACKUP? This operation will alter your original images and cannot be undone!', 'png_to_jpg' ) ?></strong></p></div> 358 367 <div class="below-h2 error"> … … 395 404 <tr> 396 405 <th class="check-column"><input type="checkbox"></th> 406 397 407 <th><?php _e('Media') ?></th> 398 <th><?php _e( 'Filesize', 'png_to_jpg' ) ?></th> 408 409 410 <th scope="col" id="filesize" class="manage-column column-filesize column-primary <?php echo empty( $_GET['order'] ) ? 'sortable' : ( $_GET['order'] == 'asc' ? 'sorted asc' : 'sorted desc' ) ?>" abbr="Filesize"> 411 <a href="?page=<?php echo basename( __FILE__ ) ?>&tab=convert&order=<?php echo empty( $_GET['order'] ) || $_GET['order'] == 'asc' ? 'desc' : 'asc' ?>"> 412 <span><?php _e( 'Filesize', 'png_to_jpg' ) ?></span> 413 <span class="sorting-indicators"> 414 <span class="sorting-indicator asc" aria-hidden="true"></span> 415 <span class="sorting-indicator desc" aria-hidden="true"></span> 416 </span> 417 </a> 418 </th> 419 399 420 <?php if( isset( $this->settings['general']['autodetect'] ) ): ?> 400 421 <th><?php _e( 'Has transparency', 'png_to_jpg' ) ?></th> … … 829 850 global $wpdb; 830 851 852 $db_tables = $wpdb->get_col('SHOW TABLES'); 853 831 854 $old_name = basename( $this->image['link'] ); 832 855 $old_name_clean = substr( $old_name, 0, -4 ); … … 896 919 // Yoast SEO: wp_yoast_seo_links 897 920 $table_name = $wpdb->prefix.'yoast_seo_links'; 898 if( in_array( $table_name, $ this->db_tables ) ){921 if( in_array( $table_name, $db_tables ) ){ 899 922 $wpdb->query(" 900 923 UPDATE $table_name … … 905 928 // Revolution Slider: wp_revslider_slides 906 929 $table_name = $wpdb->prefix.'revslider_slides'; 907 if( in_array( $table_name, $ this->db_tables ) ){930 if( in_array( $table_name, $db_tables ) ){ 908 931 $wpdb->query(" 909 932 UPDATE $table_name … … 919 942 // Revolution Slider: wp_revslider_static_slides 920 943 $table_name = $wpdb->prefix.'revslider_static_slides'; 921 if( in_array( $table_name, $ this->db_tables ) ){944 if( in_array( $table_name, $db_tables ) ){ 922 945 $wpdb->query(" 923 946 UPDATE $table_name … … 928 951 // Toolset Types: wp_toolset_post_guid_id 929 952 $table_name = $wpdb->prefix.'toolset_post_guid_id'; 930 if( in_array( $table_name, $ this->db_tables ) ){953 if( in_array( $table_name, $db_tables ) ){ 931 954 $wpdb->query(" 932 955 UPDATE $table_name … … 937 960 // Fancy Product Designer: wp_fpd_products 938 961 $table_name = $wpdb->prefix.'fpd_products'; 939 if( in_array( $table_name, $ this->db_tables ) ){962 if( in_array( $table_name, $db_tables ) ){ 940 963 $wpdb->query(" 941 964 UPDATE $table_name … … 946 969 // Fancy Product Designer: wp_fpd_views 947 970 $table_name = $wpdb->prefix.'fpd_views'; 948 if( in_array( $table_name, $ this->db_tables ) ){971 if( in_array( $table_name, $db_tables ) ){ 949 972 $wpdb->query(" 950 973 UPDATE $table_name … … 960 983 // Broken Link Checker: wp_blc_instances 961 984 $table_name = $wpdb->prefix.'blc_instances'; 962 if( in_array( $table_name, $ this->db_tables ) ){985 if( in_array( $table_name, $db_tables ) ){ 963 986 $wpdb->query(" 964 987 UPDATE $table_name … … 974 997 // Broken Link Checker: wp_blc_links 975 998 $table_name = $wpdb->prefix.'blc_links'; 976 if( in_array( $table_name, $ this->db_tables ) ){999 if( in_array( $table_name, $db_tables ) ){ 977 1000 $wpdb->query(" 978 1001 UPDATE $table_name … … 998 1021 // FV Player 999 1022 $table_name = $wpdb->prefix.'fv_player_videos'; 1000 if( in_array( $table_name, $ this->db_tables ) ){1023 if( in_array( $table_name, $db_tables ) ){ 1001 1024 $wpdb->query(" 1002 1025 UPDATE $table_name -
png-to-jpg/trunk/readme.txt
r3059378 r3407383 2 2 Contributors: kubiq 3 3 Donate link: https://www.paypal.me/jakubnovaksl 4 Tags: png, jpg,optimize, save space, convert, image, media4 Tags: optimize, save space, convert, image, media 5 5 Requires at least: 3.0.1 6 Tested up to: 6. 57 Stable tag: 4. 46 Tested up to: 6.9 7 Stable tag: 4.5 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 32 32 33 33 == Changelog == 34 35 = 4.5 = 36 * tested on WP 6.9 37 * performance optimization - load DB tables only when needed 38 * sorting by filesize in convert screen 34 39 35 40 = 4.4 =
Note: See TracChangeset
for help on using the changeset viewer.