Changeset 2446637
- Timestamp:
- 12/28/2020 08:02:18 AM (5 years ago)
- Location:
- wp-image-sizes
- Files:
-
- 14 added
- 3 edited
-
tags/1.0.3 (added)
-
tags/1.0.3/assets (added)
-
tags/1.0.3/assets/css (added)
-
tags/1.0.3/assets/css/wpis-style.css (added)
-
tags/1.0.3/assets/js (added)
-
tags/1.0.3/assets/js/api-request.min.js (added)
-
tags/1.0.3/assets/js/wpis.js (added)
-
tags/1.0.3/includes (added)
-
tags/1.0.3/includes/tab-templates (added)
-
tags/1.0.3/includes/tab-templates/image-sizes.php (added)
-
tags/1.0.3/includes/wpis-settings.php (added)
-
tags/1.0.3/readme.txt (added)
-
tags/1.0.3/wp-image-sizes.php (added)
-
tags/1.0.3/wpis-init.php (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wp-image-sizes.php (modified) (3 diffs)
-
trunk/wpis-init.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-image-sizes/trunk/readme.txt
r2445033 r2446637 1 1 === WP Image Sizes === 2 2 Contributors: aiwatech 3 Tags: image sizes, selected image sizes, media uploader, bulk image sizes, disable image sizes, prevent unnecessary images, thumbnails3 Tags: images, sizes, thumbnails, gallery, image sizes, media uploader, media library, featured image, multiple image creation, selected image sizes, bulk image sizes, disable image sizes, prevent unnecessary images 4 4 Requires at least: 4.7 5 5 Requires PHP: 5.2.4 6 Stable tag: 1.0. 26 Stable tag: 1.0.3 7 7 Tested up to: 5.6 8 8 License: GPLv2 or later … … 52 52 53 53 == Changelog == 54 = 1.0.3 = 55 * Session storage changed to fix register_globals conflict 56 54 57 = 1.0.2 = 55 58 * Plugin core changes -
wp-image-sizes/trunk/wp-image-sizes.php
r2431304 r2446637 4 4 * Plugin URI: https://aiwatech.com/wp-image-sizes 5 5 * Description: Save server space by creating selected image sizes for every post type. It allows to select registered image sizes in media uploader and helps to avoid creation of unneccessary images. 6 * Version: 1.0. 26 * Version: 1.0.3 7 7 * Requires at least: 4.7 8 * Tested up to: 5. 5.38 * Tested up to: 5.6 9 9 * Author: Aiwatech 10 10 * Author URI: https://aiwatech.com … … 20 20 21 21 $wpis = get_option( "wpis" ); 22 $wpis_image_sizes = $wpis["image_sizes"]; 23 $wpis_settings = $wpis["settings"]; 22 $wpis_image_sizes = isset($wpis["image_sizes"]) 23 ? $wpis["image_sizes"] 24 : []; 25 26 $wpis_settings = isset($wpis["settings"]) 27 ? $wpis["settings"] 28 : []; 24 29 25 30 if( !is_array($wpis_image_sizes) ){ … … 76 81 } 77 82 78 79 //=== Hooked update wpis settings80 add_filter( "pre_update_option", "wpis_pre_update_option", 10, 3 );81 function wpis_pre_update_option( $posted_option, $option, $old_option ){82 if( !session_id() ){83 session_start();84 }85 86 //--- Unset image sizes in session87 if( isset( $_SESSION["wpis_image_sizes"] ) ){88 unset( $_SESSION["wpis_image_sizes"] );89 }90 91 return $posted_option;92 }93 94 83 include_once( "wpis-init.php" ); -
wp-image-sizes/trunk/wpis-init.php
r2431304 r2446637 136 136 global $wpis_image_sizes; 137 137 138 if( !session_id() ){ 139 session_start(); 140 } 138 $wpis_session = get_option( "wpis_session" ); 141 139 142 140 $post_type = get_post_type( intval($_REQUEST["post_id"]) ); … … 146 144 } 147 145 148 $selected_image_sizes = array_map("sanitize_text_field", $ _SESSION["wpis_image_sizes"][$post_type]);146 $selected_image_sizes = array_map("sanitize_text_field", $wpis_session["wpis_image_sizes"][$post_type]); 149 147 150 148 if( $selected_image_sizes ){ … … 157 155 158 156 //=== Remove sizes from session 159 unset($_SESSION["wpis_image_sizes"][$post_type]); 157 unset($wpis_session["wpis_image_sizes"][$post_type]); 158 update_option( "wpis_session", $wpis_session ); 160 159 161 160 return $sizes; … … 167 166 function save_wpis_image_sizes(){ 168 167 169 if( !session_id() ){ 170 session_start(); 171 } 168 $wpis_session = get_option( "wpis_session" ); 172 169 173 170 $res["success"] = 0; … … 184 181 } 185 182 186 $_SESSION["wpis_image_sizes"][$post_type] = $wpis_image_sizes; 183 $wpis_session["wpis_image_sizes"][$post_type] = $wpis_image_sizes; 184 update_option( "wpis_session", $wpis_session ); 187 185 188 186 die(json_encode($res)); … … 195 193 function wpis_media_uploader_ui(){ 196 194 197 if( !session_id() ){ 198 session_start(); 199 } 195 $wpis_session = get_option( "wpis_session" ); 200 196 201 197 $intermediate_image_sizes = get_intermediate_image_sizes(); … … 215 211 } 216 212 217 $wpis_image_sizes[$post_type] = isset($ _SESSION["wpis_image_sizes"][$post_type]) ? array_map("sanitize_text_field",$_SESSION["wpis_image_sizes"][$post_type]) : array_map("sanitize_text_field", (array)$wpis_image_sizes[$post_type]);213 $wpis_image_sizes[$post_type] = isset($wpis_session["wpis_image_sizes"][$post_type]) ? array_map("sanitize_text_field",$wpis_session["wpis_image_sizes"][$post_type]) : array_map("sanitize_text_field", (array)$wpis_image_sizes[$post_type]); 218 214 219 215 foreach( $intermediate_image_sizes as $image_size ){ … … 284 280 } 285 281 endif; 282 283 //=== Hooked update wpis settings 284 add_action( "update_option_wpis", "wpis_update_option", 10, 3 ); 285 function wpis_update_option( $old_option, $new_option, $option ){ 286 update_option( "wpis_session", [] ); 287 }
Note: See TracChangeset
for help on using the changeset viewer.