Changeset 2449872
- Timestamp:
- 01/04/2021 11:20:15 AM (4 years ago)
- Location:
- wp-image-sizes
- Files:
-
- 14 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified wp-image-sizes/trunk/assets/css/wpis-style.css ¶
r2408153 r2449872 1 1 .text-red{ 2 2 color: #e80000 !important; 3 } 4 .fw-5{ 5 font-weight: 500; 6 } 7 .fw-6{ 8 font-weight: 600; 9 } 10 .fw-7{ 11 font-weight: 700; 12 } 13 .fw-8{ 14 font-weight: 800; 15 } 16 .fw-9{ 17 font-weight: 900; 3 18 } 4 19 .wpis-grid-columns-75-25{ -
TabularUnified wp-image-sizes/trunk/includes/tab-templates/image-sizes.php ¶
r2448837 r2449872 3 3 4 4 global $wpis_settings, 5 $wpis_image_sizes; 5 $wpis_image_sizes, 6 $wpis_disabled_sizes; 6 7 7 8 $core_cpts = get_post_types(["public" => true, "_builtin" => true],"objects"); … … 28 29 <fieldset class="wpis-fieldset"> 29 30 <legend><?php _e(ucwords($cpt->labels->singular_name), "wpis");?></legend> 30 <p>31 31 32 <?php 32 33 if( !empty( $intermediate_image_sizes ) ){ 33 foreach( $intermediate_image_sizes as $image_size ){ 34 echo( wp_sprintf('<label class="disable-size-checkbox fw-6"><input class="wpis-checkbox" name="wpis[disabled_sizes][]" type="checkbox" value="%s" %s>%s</label><br />', 35 $cpt->name, 36 in_array($cpt->name, (array)$wpis_disabled_sizes) ? 'checked="checked"' : '', 37 __("Disable All Sizes", "wpis")) 38 ); 39 40 foreach( $intermediate_image_sizes as $image_size ){ 34 41 if( isset( $wp_additional_image_sizes[$image_size]["width"] ) ){ 35 42 $width = $wp_additional_image_sizes[$image_size]["width"]; … … 44 51 } 45 52 46 echo( wp_sprintf('<label ><input name="wpis[image_sizes][%s][]" type="checkbox" value="%s"%s>%s (%s x %s)</label><br />',53 echo( wp_sprintf('<label class="image-size-checkbox"><input class="wpis-checkbox" name="wpis[image_sizes][%s][]" type="checkbox" value="%s" %s %s>%s (%s x %s)</label><br />', 47 54 $cpt->name, 48 55 $image_size, 49 56 in_array($image_size, (array)$wpis_image_sizes[$cpt->name]) ? 'checked="checked"' : '', 57 in_array($cpt->name, (array)$wpis_disabled_sizes) ? 'disabled="disabled"' : '', 50 58 ucwords($image_size), 51 59 $width, … … 54 62 } 55 63 }?> 56 </p>64 57 65 </fieldset> 58 66 <?php … … 86 94 </div> 87 95 </div> 96 <script type="text/javascript"> 97 jQuery(document).ready(function($){ 98 $(".disable-size-checkbox > .wpis-checkbox").change(function(){ 99 100 if($(this).is(":checked")){ 101 $(this).closest(".wpis-fieldset").find(".image-size-checkbox > .wpis-checkbox").attr("disabled", "disabled"); 102 }else{ 103 $(this).closest(".wpis-fieldset").find(".image-size-checkbox > .wpis-checkbox").removeAttr("disabled"); 104 } 105 }); 106 }); 107 </script> -
TabularUnified wp-image-sizes/trunk/readme.txt ¶
r2448837 r2449872 4 4 Requires at least: 4.7 5 5 Requires PHP: 5.2.4 6 Stable tag: 1.0. 76 Stable tag: 1.0.8 7 7 Tested up to: 5.6 8 8 License: GPLv2 or later … … 66 66 67 67 == Changelog == 68 = 1.0.8 = 69 * Option to disable all image sizes added to wpis settings 70 68 71 = 1.0.7 = 69 72 * Bug fixes -
TabularUnified wp-image-sizes/trunk/wp-image-sizes.php ¶
r2448837 r2449872 16 16 global $wpis, 17 17 $wpis_image_sizes, 18 $wpis_disabled_sizes, 18 19 $wpis_settings, 19 20 $wpis_plugin_data; … … 22 23 $wpis_image_sizes = isset($wpis["image_sizes"]) 23 24 ? $wpis["image_sizes"] 25 : []; 26 27 $wpis_disabled_sizes = isset($wpis["disabled_sizes"]) 28 ? $wpis["disabled_sizes"] 24 29 : []; 25 30 … … 64 69 } 65 70 66 if( ! wp_doing_ajax() ){71 if( ! wp_doing_ajax() ){ 67 72 update_option( "wpis_session", [] ); 68 73 } 69 70 74 } 71 75 -
TabularUnified wp-image-sizes/trunk/wpis-init.php ¶
r2448837 r2449872 136 136 add_filter("intermediate_image_sizes_advanced", "wpis_image_sizes_advanced", 10, 3); 137 137 function wpis_image_sizes_advanced( $sizes, $metadata, $attachment_id ){ 138 global $wpis_image_sizes; 138 global $wpis_image_sizes, 139 $wpis_disabled_sizes; 139 140 140 141 $wpis_session = get_option( "wpis_session" ); … … 148 149 } 149 150 151 if( !isset($wpis_session["wpis_disable_sizes"][$post_type]) ){ 152 $wpis_disable_sizes = in_array($post_type, $wpis_disabled_sizes); 153 } 154 else{ 155 $wpis_disable_sizes = $wpis_session["wpis_disable_sizes"][$post_type] == "true" 156 || $wpis_session["wpis_disable_sizes"][$post_type] === true; 157 } 158 150 159 //=== Return early if image sizes were disabled 151 if( $wpis_session["wpis_disable_sizes"][$post_type] == "true" 152 || $wpis_session["wpis_disable_sizes"][$post_type] === true ){ 153 160 if( $wpis_disable_sizes ){ 154 161 return []; 155 162 } … … 175 182 function save_wpis_image_sizes(){ 176 183 184 $post_type = sanitize_text_field( $_POST["post_type"] ); 177 185 $wpis_session = get_option( "wpis_session" ); 178 186 … … 184 192 if( $_POST["wpis_image_sizes"] ){ 185 193 $wpis_image_sizes = array_map( "sanitize_text_field", $_POST["wpis_image_sizes"] ); 186 $post_type = sanitize_text_field( $_POST["post_type"] );187 188 194 $res["success"] = 1; 189 195 $res["sizes"] = $wpis_image_sizes; … … 195 201 $wpis_session["wpis_disable_sizes"] = []; 196 202 } 197 203 198 204 if( isset($_POST["wpis_disable_sizes"]) ){ 199 205 $wpis_disable_sizes = sanitize_text_field($_POST["wpis_disable_sizes"]); 200 $wpis_session["wpis_disable_sizes"][$post_type] = $wpis_disable_sizes ;206 $wpis_session["wpis_disable_sizes"][$post_type] = $wpis_disable_sizes == "true" || $wpis_disable_sizes === true; 201 207 } 202 208 … … 224 230 add_action( "post-upload-ui", "wpis_media_uploader_ui" ); 225 231 function wpis_media_uploader_ui(){ 226 global $wpis_image_sizes; 232 global $wpis_image_sizes, 233 $wpis_disabled_sizes; 227 234 228 235 $wpis_session = get_option( "wpis_session" ); … … 239 246 } 240 247 241 $wpis_disable_sizes = isset($wpis_session["wpis_disable_sizes"][$post_type]) 242 && ($wpis_session["wpis_disable_sizes"][$post_type] == "true" || $wpis_session["wpis_disable_sizes"][$post_type] === true); 248 if( !isset($wpis_session["wpis_disable_sizes"][$post_type]) ){ 249 $wpis_disable_sizes = in_array($post_type, $wpis_disabled_sizes); 250 } 251 else{ 252 $wpis_disable_sizes = $wpis_session["wpis_disable_sizes"][$post_type] == "true" || $wpis_session["wpis_disable_sizes"][$post_type] === true; 253 } 243 254 ?> 244 255 … … 248 259 <p class="description textleft"> 249 260 <?php 250 echo( wp_sprintf('<label class="disable-size-checkbox "><input name="wpis_disable_sizes" class="wpis-checkbox" type="checkbox" %s>%s</label>',261 echo( wp_sprintf('<label class="disable-size-checkbox fw-6"><input name="wpis_disable_sizes" class="wpis-checkbox" type="checkbox" %s>%s</label>', 251 262 $wpis_disable_sizes ? 'checked="checked"' : '', 252 263 __("Disable All Sizes <small>(Select this option to skip all image size generation)</small>", "wpis") … … 260 271 ? array_map("sanitize_text_field",$wpis_session["wpis_image_sizes"][$post_type]) 261 272 : array_map("sanitize_text_field", (array)$wpis_image_sizes[$post_type]); 262 273 263 274 foreach( $intermediate_image_sizes as $image_size ){ 264 275 … … 364 375 365 376 //=== Hooked update wpis settings 377 if( !function_exists("wpis_update_option") ): 366 378 add_filter( "pre_update_option", "wpis_update_option", 10, 3 ); 367 379 function wpis_update_option( $value, $option, $old_value ){ … … 373 385 return $value; 374 386 } 387 endif;
Note: See TracChangeset
for help on using the changeset viewer.