Changeset 2005148
- Timestamp:
- 01/02/2019 12:57:19 PM (7 years ago)
- Location:
- minimum-featured-image-size/trunk
- Files:
-
- 6 added
- 2 deleted
- 3 edited
-
admin/mfis-admin-ajax-styles.css (deleted)
-
admin/mfis-admin-block-editor-scripts.js (added)
-
admin/mfis-admin-block-editor-scripts.min.js (added)
-
admin/mfis-admin-scripts.js (modified) (1 diff)
-
admin/mfis-admin-scripts.min.js (added)
-
admin/mfis-admin-styles.css (deleted)
-
admin/mfis-admin-styles.min.css (added)
-
admin/mfis-admin-styles.min.css.map (added)
-
admin/mfis-admin-styles.scss (added)
-
mfis.php (modified) (28 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
minimum-featured-image-size/trunk/admin/mfis-admin-scripts.js
r1871030 r2005148 1 jQuery( function($) { 2 3 // Initialise some variables, used later for the image ID input value4 mfis_value = ''; 1 /** 2 * Initialise some variables 3 */ 4 var mfis_value = -1, 5 5 previous_value = ''; 6 6 7 // Function to reset all things mfis 8 function mfis_reset(){ 9 10 $( '#publishing-action input[type="submit"]' ).removeAttr('disabled').show(); 11 12 $( '.mfis_publishing_disabled' ).fadeOut(500, function(){ 13 $( '.mfis_publishing_disabled' ).remove(); 14 $( '#postimagediv .inside' ).removeClass( 'mfis_is_disabled' ); 7 8 /** 9 * Check the image via ajax 10 * @param {number} image_id 11 */ 12 function mfis_do_ajax(image_id) { 13 14 if (image_id != -1) { 15 16 var data = { 17 action: 'mfis_get_size_from_id', 18 image_id: image_id, 19 post_type: mfis.post_type, 20 editor: 'classic', 21 }; 22 23 $.post(ajaxurl, data, function (response) { 24 25 var json = JSON.parse(response); 26 27 if (json.image_check == 'fail') { 28 29 // Add error message 30 var mfis_publishing_disabled_message = '<div class="mfis_publishing_disabled"><span class="mfis_icon">!</span><span class="mfis_error_message">' + json.error_message + '</span></div>'; 31 32 if (!$('#postimagediv .inside img').hasClass('mfis_is_disabled')) { 33 $('#postimagediv .inside img, #major-publishing-actions').after(mfis_publishing_disabled_message).addClass('mfis_is_disabled'); 34 $('.mfis_publishing_disabled').hide().fadeIn(); 35 } 36 37 } else { 38 39 // Image passed, so let's reset things 40 mfis_reset(); 41 42 } 43 15 44 }); 16 17 mfis_value = '';18 45 19 46 } 20 47 21 // Do the mfis check 22 function mfis_check_image(){ 48 } 23 49 24 // Check if there is an input with the image ID25 if ( $('#_thumbnail_id').length > 0 && $('#_thumbnail_id').val() >= 0 ) {26 50 27 // Compare it to the previous value 28 mfis_value = $('#_thumbnail_id').val(); 51 /** 52 * Reset all things mfis 53 */ 54 function mfis_reset() { 29 55 30 if ( mfis_value != previous_value ) { 31 32 // Value has changed, so let's disable the Publish button and do the ajax 33 $( '#publishing-action input[type="submit"]' ).attr('disabled', 'disabled').show(); 56 if (mfis.disable_publishing == 'publishing_disabled') $('#publishing-action input[type="submit"]').removeAttr('disabled').show(); 34 57 35 data = { 36 action : 'mfis_get_size_from_id', 37 image_id : mfis_value, 38 post_type : mfis.post_type, 39 }; 58 $('.mfis_publishing_disabled').fadeOut(500, function () { 59 $('.mfis_publishing_disabled').remove(); 60 $('#postimagediv .inside img').removeClass('mfis_is_disabled'); 61 }); 40 62 41 $.post( ajaxurl , data , function( response ) { 42 43 // Split the response into an array 44 response = response.split('[mfis_delimter]'); 63 mfis_value = ''; 45 64 46 if( response[0] == 'image_failed') { 65 } 47 66 48 // Add error message49 var mfis_publishing_disabled_message = '<div class="mfis_publishing_disabled"><span class="mfis_icon">!</span><span class="mfis_error_message">' + response[1] + '</span></div>';50 if( ! $( '#postimagediv .inside' ).hasClass('mfis_is_disabled') ) {51 $( '#postimagediv .inside' ).after( mfis_publishing_disabled_message ).addClass('mfis_is_disabled');52 $( '.mfis_publishing_disabled' ).hide().fadeIn();53 }54 55 } else {56 67 57 // Image passed, so let's reset things 58 mfis_reset(); 68 /** 69 * Do the mfis check 70 */ 71 function mfis_check_image() { 59 72 60 } 73 // Check if there is an input with the image ID 74 if ($('#_thumbnail_id').length > 0 && $('#_thumbnail_id').val() >= 0) { 61 75 62 });63 }76 // Compare it to the previous value 77 mfis_value = $('#_thumbnail_id').val(); 64 78 65 previous_value = mfis_value; 79 if (mfis_value != previous_value) { 80 81 // Value has changed, so let's disable the Publish button and do the ajax 82 if (mfis.disable_publishing == 'publishing_disabled') $('#publishing-action input[type="submit"]').attr('disabled', 'disabled').show(); 83 84 mfis_do_ajax(mfis_value); 85 86 } 87 88 previous_value = mfis_value; 89 90 } else { 66 91 67 92 // There's no image ID input present, so reset things 68 } else { 93 mfis_reset(); 94 95 } 96 97 } 98 99 100 jQuery(function ($) { 101 102 if (mfis.disable_ajax != 'ajax_disabled') { 103 104 // Reset mfis if 'Remove featured image' link is clicked 105 $('#remove-post-thumbnail').on('click', function () { 106 107 $('#_thumbnail_id').val(-1); 69 108 70 109 mfis_reset(); 71 110 72 } 111 }); 112 113 // Do initial check on page load, and then keep checking 114 mfis_check_image(); 115 setInterval(mfis_check_image, 200); 73 116 74 117 } 75 118 76 // Reset mfis if 'Remove featured image' link is clicked77 $( '#remove-post-thumbnail' ).on( 'click', function(){78 79 $('#_thumbnail_id').val( -1 );80 81 mfis_reset();82 83 });84 85 // Do initial check on page load, and then keep checking86 mfis_check_image();87 setInterval(mfis_check_image, 200);88 89 119 }); 90 -
minimum-featured-image-size/trunk/mfis.php
r1926403 r2005148 3 3 Plugin Name: Minimum Featured Image Size 4 4 Description: Set the minimum size required for featured images used in standard and custom posts. 5 Version: 1.1.25 Version: 2.0 6 6 Author: Martin Stewart 7 7 Author URI: https://www.corgdesign.com … … 14 14 15 15 /** 16 * Enqueue css for setting page16 * Enqueue css for settings page 17 17 * @since 1.0 18 18 */ … … 20 20 21 21 # admin css 22 wp_enqueue_style( 'mfis-admin-css', plugins_url('admin/mfis-admin-styles. css', __FILE__ ));22 wp_enqueue_style( 'mfis-admin-css', plugins_url('admin/mfis-admin-styles.min.css', __FILE__ )); 23 23 24 24 } … … 27 27 28 28 /** 29 * Enqueue css andjs for ajax functionality29 * Enqueue js for ajax functionality 30 30 * @since 1.0 31 31 */ … … 33 33 34 34 # admin javascript 35 wp_register_script( 'mfis-admin-js', plugins_url('admin/mfis-admin-scripts. js', __FILE__ ), array( 'jquery' ), false, true );35 wp_register_script( 'mfis-admin-js', plugins_url('admin/mfis-admin-scripts.min.js', __FILE__ ), array( 'jquery' ), false, true ); 36 36 37 37 # Localize the script and pass in the post type … … 39 39 $post_type = $current_screen->post_type; 40 40 $translation_array = array( 41 'post_type' => $post_type 41 'post_type' => $post_type, 42 'disable_publishing' => get_option('mfis_disable_publishing'), 43 'disable_ajax' => get_option( 'mfis_ajax_disable' ) 42 44 ); 43 45 … … 45 47 wp_enqueue_script( 'mfis-admin-js' ); 46 48 47 # admin css48 wp_enqueue_style( 'mfis-admin-ajax-css', plugins_url('admin/mfis-admin-ajax-styles.css', __FILE__ ));49 50 49 } 51 50 … … 58 57 59 58 /** 59 * Enqueue the js for the block editor, and remove the classic editor scripts 60 * @since 2.0 61 */ 62 function mfis_enqueue_admin_block_editor_ajax(){ 63 64 # admin javascript 65 wp_register_script( 'mfis-adminblock-editor-js', plugins_url('admin/mfis-admin-block-editor-scripts.min.js', __FILE__ ), array( 'jquery' ), false, true ); 66 67 # Localize the script and pass in the post type 68 $current_screen = get_current_screen(); 69 $post_type = $current_screen->post_type; 70 $translation_array = array( 71 'post_type' => $post_type, 72 'disable_publishing' => get_option('mfis_disable_publishing'), 73 'disable_ajax' => get_option( 'mfis_ajax_disable' ) 74 ); 75 76 wp_localize_script( 'mfis-adminblock-editor-js', 'mfis', $translation_array ); 77 wp_enqueue_script( 'mfis-adminblock-editor-js' ); 78 79 # Remove the previously enqueued classic editor scripts 80 remove_action( 'admin_enqueue_scripts' , 'mfis_enqueue_admin_ajax' ); 81 82 } 83 84 add_action('enqueue_block_editor_assets', 'mfis_enqueue_admin_block_editor_ajax'); 85 86 87 /** 60 88 * Add an admin options page for MFIS settings 61 89 * @since 1.0 … … 81 109 82 110 # Default error message 83 $mfis_default_error_message = 'Publishing disabled! The Featured Image you\'ve chosen is not large enough, it must be at least [width] x [height]'; 84 85 ?> 111 $mfis_default_error_message = 'Publishing disabled! The Featured Image you\'ve chosen is not large enough, it must be at least [width] x [height]'; 112 113 # Custom post types 114 $post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'objects' ); ?> 86 115 87 116 <div class="wrap mfis_wrap"> … … 114 143 </tr> 115 144 145 <tr valign="top"> 146 <th scope="row">Exact dimensions</th> 147 <td> 148 <label for="mfis_exact_dimensions"> 149 <input type="checkbox" id="mfis_exact_dimensions" name="mfis_exact_dimensions" class="mfis_exact_dimensions" value="use_exact_dimensions" <?php checked( 'use_exact_dimensions', get_option( 'mfis_exact_dimensions' ) ); ?> /> 150 Use exact dimensions? 151 </label> 152 </td> 153 </tr> 154 155 <tr valign="top"> 156 <th scope="row">Post publishing</th> 157 <td> 158 <label for="mfis_disable_publishing"> 159 <input type="checkbox" id="mfis_disable_publishing" name="mfis_disable_publishing" class="mfis_disable_publishing" value="publishing_disabled" <?php checked( 'publishing_disabled', get_option( 'mfis_disable_publishing' ) ); ?> /> 160 Disable publishing? <em><small>When the featured image isn't the required size</small></em> 161 </label><br> 162 163 </td> 164 </tr> 165 116 166 <tr valign="top"> 117 167 <th scope="row">Error message</th> … … 126 176 <label for="mfis_ajax_disable"> 127 177 <input type="checkbox" id="mfis_ajax_disable" name="mfis_ajax_disable" class="mfis_ajax_disable" value="ajax_disabled" <?php checked( 'ajax_disabled', get_option( 'mfis_ajax_disable' ) ); ?> /> 128 Disable Ajax? 178 Disable Ajax? <small><em>Classic editor only</em></small> 129 179 </label> 130 180 </td> 131 181 </tr> 132 182 183 <?php if ( ! empty($post_types) ) : ?> 184 133 185 <tr valign="top"> 134 186 <th valign="top" scope="row">Custom Post Types</th> … … 140 192 </td> 141 193 </tr> 194 195 <?php endif; ?> 142 196 143 197 </table> 198 199 <?php if ( ! empty($post_types) ) : ?> 144 200 145 201 <table class="form-table" id="mfis_custom_posts_options_table"> … … 152 208 <th valign="top" scope="row">Minimum width (px)</th> 153 209 <th valign="top" scope="row">Minimum height (px)</th> 210 <th valign="top" scope="row"> 211 Use exact dimensions?<br> 212 <small><a href="#" class="dimensions_select_all">Select all</a></small> 213 </th> 214 <th valign="top" scope="row"> 215 Error message<small> (Optional)<br> 216 <em> 217 <small> 218 Use [width] and [height] to display your settings 219 </small> 220 </em> 221 </th> 154 222 </tr> 155 223 </table> … … 163 231 164 232 $mfis_min_width = get_option( 'mfis_min_width_' . $post_type->name ); 165 $mfis_min_height = get_option( 'mfis_min_height_' . $post_type->name ); ?> 233 $mfis_min_height = get_option( 'mfis_min_height_' . $post_type->name ); 234 $mfis_exact_dimensions = get_option( 'mfis_exact_dimensions_' . $post_type->name ); 235 $mfis_error_message = get_option( 'mfis_error_message_' . $post_type->name ); ?> 166 236 167 <tr valign=" middle">168 <th valign=" middle" scope="row"><?php echo $post_type->labels->singular_name; ?></th>169 <td valign=" middle">237 <tr valign="top"> 238 <th valign="top" scope="row"><?php echo $post_type->labels->singular_name; ?></th> 239 <td valign="top"> 170 240 <table> 171 241 <tr> 172 <td valign=" middle">242 <td valign="top"> 173 243 <input type="number" name="mfis_min_width_<?php echo $post_type->name; ?>" class="mfis_min_width" value="<?php echo empty( $mfis_min_width ) ? '' : esc_attr( $mfis_min_width ); ?>" /> px 174 244 </td> 175 <td valign=" middle">245 <td valign="top"> 176 246 <input type="number" name="mfis_min_height_<?php echo $post_type->name; ?>" class="mfis_min_width" value="<?php echo empty( $mfis_min_height ) ? '' : esc_attr( $mfis_min_height ); ?>" /> px 177 247 </td> 248 </td> 249 <td valign="top"> 250 <input type="checkbox" name="mfis_exact_dimensions_<?php echo $post_type->name; ?>" class="mfis_exact_dimensions_cpt" value="mfis_exact_dimensions_<?php echo $post_type->name; ?>" <?php checked( 'mfis_exact_dimensions_' . $post_type->name, get_option( 'mfis_exact_dimensions_' . $post_type->name ) ); ?> /> 251 </td> 252 <td valign="top"> 253 <textarea name="mfis_error_message_<?php echo $post_type->name; ?>" class="mfis_error_message"><?php echo empty( $mfis_error_message ) ? '' : esc_attr( $mfis_error_message ); ?></textarea> 254 </td> 178 255 </tr> 179 256 </table> … … 185 262 </table> <?php 186 263 264 endif; 265 187 266 submit_button(); ?> 188 267 … … 212 291 $( '#mfis_custom_posts_options_table' ).show(); 213 292 214 } 293 } 294 295 $('.dimensions_select_all').on('click', function(e){ 296 297 e.preventDefault(); 298 299 if ($(this).hasClass('all-checkboxes-selected')) { 300 301 $('.mfis_exact_dimensions_cpt').prop('checked', false); 302 $(this).text('Select all').removeClass('all-checkboxes-selected'); 303 304 } else { 305 306 $('.mfis_exact_dimensions_cpt').prop('checked', true); 307 $(this).text('Deselect all').addClass('all-checkboxes-selected'); 308 309 } 310 311 }); 215 312 216 313 }); … … 230 327 register_setting( 'mfis_option_group' , 'mfis_min_width' ); 231 328 register_setting( 'mfis_option_group' , 'mfis_min_height' ); 329 register_setting( 'mfis_option_group' , 'mfis_exact_dimensions' ); 330 register_setting( 'mfis_option_group' , 'mfis_disable_publishing' ); 232 331 register_setting( 'mfis_option_group' , 'mfis_error_message' ); 233 332 register_setting( 'mfis_option_group' , 'mfis_ajax_disable' ); … … 239 338 register_setting( 'mfis_option_group' , 'mfis_min_width_' . $post_type ); 240 339 register_setting( 'mfis_option_group' , 'mfis_min_height_' . $post_type ); 340 register_setting( 'mfis_option_group' , 'mfis_exact_dimensions_' . $post_type ); 341 register_setting( 'mfis_option_group' , 'mfis_error_message_' . $post_type ); 241 342 242 343 } … … 251 352 } 252 353 253 254 /** 255 * Check featured image size meets minimum requirements 256 * @since 1.0 257 */ 258 function mfis_image_size_ok( $image_id, $post_type = 'post' ){ 354 # Set a default value for the mfis_allow_publishing setting 355 add_option('mfis_disable_publishing', 'publishing_disabled'); 356 357 358 /** 359 * Check featured image size meets minimum or exact requirements 360 * @since 1.0 361 * @param {number} $image_id 362 * @param {string} $post_type 363 */ 364 function mfis_image_size_ok( $image_id, $post_type = 'post' ) { 259 365 260 366 $image_data = wp_get_attachment_image_src( $image_id, "Full" ); … … 269 375 270 376 $min_width = get_option( 'mfis_min_width' ); 271 $min_height = get_option( 'mfis_min_height' ); 377 $min_height = get_option( 'mfis_min_height' ); 378 $exact_dimensions = get_option( 'mfis_exact_dimensions' ); 272 379 273 380 else : 274 381 275 382 $min_width = get_option('mfis_custom_post_types') === 'mfis_custom_post_types' ? get_option( 'mfis_min_width_' . $post_type ) : get_option( 'mfis_min_width' ); 276 $min_height = get_option('mfis_custom_post_types') === 'mfis_custom_post_types' ? get_option( 'mfis_min_height_' . $post_type ) : $min_height = get_option( 'mfis_min_height' );; 277 278 endif; 279 280 if( $image_width < $min_width || $image_height < $min_height ) : 383 $min_height = get_option('mfis_custom_post_types') === 'mfis_custom_post_types' ? get_option( 'mfis_min_height_' . $post_type ) : $min_height = get_option( 'mfis_min_height' ); 384 $exact_dimensions = get_option('mfis_custom_post_types') === 'mfis_custom_post_types' ? get_option( 'mfis_exact_dimensions_' . $post_type ) : get_option( 'mfis_exact_dimensions' ); 385 386 endif; 387 388 # Use exact dimensions? 389 if ( $exact_dimensions != '' ) { 390 391 if( $image_width == $min_width && $image_height == $min_height ) : 281 392 282 return false; # image is too small 283 284 else : 285 286 return true; # image is big enough 287 288 endif; 393 return true; # image is exact size 394 395 else : 396 397 return false; # image is not exact size 398 399 endif; 400 401 } else { 402 403 if( $image_width < $min_width || $image_height < $min_height ) : 404 405 return false; # image is too small 406 407 else : 408 409 return true; # image is big enough 410 411 endif; 412 413 } 414 415 } 416 417 418 /** 419 * Get the error message based on post type 420 * @since 2.0 421 * @param {string} $post_type 422 */ 423 function mfis_get_error_message($post_type) { 424 425 # Default error message 426 $mfis_default_error_message = 'Publishing disabled! The Featured Image you\'ve chosen is not large enough, it must be at least [width] x [height]'; 427 428 if ( $post_type === 'post' ) : 429 430 $min_width = get_option( 'mfis_min_width' ); 431 $min_height = get_option( 'mfis_min_height' ); 432 $mfis_error_message = get_option( 'mfis_error_message' ); 433 434 else : 435 436 $min_width = get_option('mfis_custom_post_types') === 'mfis_custom_post_types' ? get_option( 'mfis_min_width_' . $post_type ) : get_option( 'mfis_min_width' ); 437 $min_height = get_option('mfis_custom_post_types') === 'mfis_custom_post_types' ? get_option( 'mfis_min_height_' . $post_type ) : $min_height = get_option( 'mfis_min_height' ); 438 $mfis_error_message = get_option( 'mfis_error_message_' . $post_type ); 439 440 endif; 441 442 $mfis_error_message = empty( $mfis_error_message ) ? str_replace( array( '[width]' , '[height]' ), array( $min_width , $min_height ), $mfis_default_error_message ) : str_replace( array( '[width]' , '[height]' ), array( $min_width , $min_height ), $mfis_error_message ); 443 444 return $mfis_error_message; 289 445 290 446 } … … 305 461 if( ! mfis_image_size_ok( $image_id, $post_type ) ) : 306 462 307 if ( $post_type === 'post' ) : 308 309 $min_width = get_option( 'mfis_min_width' ); 310 $min_height = get_option( 'mfis_min_height' ); 311 312 else : 313 314 $min_width = get_option('mfis_custom_post_types') === 'mfis_custom_post_types' ? get_option( 'mfis_min_width_' . $post_type ) : get_option( 'mfis_min_width' ); 315 $min_height = get_option('mfis_custom_post_types') === 'mfis_custom_post_types' ? get_option( 'mfis_min_height_' . $post_type ) : $min_height = get_option( 'mfis_min_height' );; 316 317 endif; 318 319 $mfis_ajax_error_message = get_option( 'mfis_error_message' ); 320 321 $mfis_ajax_error_message = empty( $mfis_ajax_error_message ) ? str_replace( array( '[width]' , '[height]' ), array( $min_width , $min_height ), $mfis_default_error_message ) : str_replace( array( '[width]' , '[height]' ), array( $min_width , $min_height ), $mfis_ajax_error_message ); 322 323 $returned_data = 'image_failed[mfis_delimter]' . esc_attr( $mfis_ajax_error_message ); 463 $mfis_ajax_error_message = mfis_get_error_message($post_type); 464 465 $returned_data = '{"image_check":"fail", "error_message":"' . $mfis_ajax_error_message . '"}'; 324 466 325 467 die( $returned_data ); … … 327 469 else : 328 470 329 die( );471 die('{"image_check":"pass"}'); 330 472 331 473 endif; … … 335 477 336 478 /** 337 * If Ajax is disabled or the user gets past the javascript, check the image on post saving 479 * If publishing and the ajax is disabled or the user gets 480 * past the javascript, check the image on post saving 338 481 * @since 1.0 339 482 */ … … 359 502 if( ! mfis_image_size_ok( $image_id, $post_type ) ){ 360 503 361 $reverted_status = in_array( $old_status, $run_on_statuses ) ? 'draft' : $old_status; 362 363 if ( $post_type === 'post' ) : 364 365 $min_width = get_option( 'mfis_min_width' ); 366 $min_height = get_option( 'mfis_min_height' ); 367 368 else : 369 370 $min_width = get_option( 'mfis_min_width_' . $post_type ); 371 $min_height = get_option( 'mfis_min_height_' . $post_type ); 372 373 $min_width = ! empty($min_width) && get_option('mfis_custom_post_types') === 'mfis_custom_post_types' ? $min_width : get_option( 'mfis_min_width' ); 374 $min_height = ! empty($min_height) && get_option('mfis_custom_post_types') === 'mfis_custom_post_types' ? $min_height : get_option( 'mfis_min_height' ); 375 376 endif; 377 378 $mfis_error_message = str_replace( array( '[width]' , '[height]' ), array( $min_width , $min_height ), get_option( 'mfis_error_message' ) ); 504 $reverted_status = in_array( $old_status, $run_on_statuses ) ? 'draft' : $new_status; 505 506 $mfis_error_message = mfis_get_error_message($post_type); 379 507 380 508 wp_update_post(array( … … 382 510 'post_status' => $reverted_status, 383 511 )); 512 513 } 514 } 515 if (is_admin() && get_option('mfis_disable_publishing') === 'publishing_disabled') add_action('transition_post_status', 'mfis_after_save', 10, 3); 516 517 518 /** 519 * Update error message on post save if publishing and the 520 * ajax is disabled or the user gets past the javascript 521 * @since 2.0 522 */ 523 function mfis_output_error_message($new_status, $old_status, $post){ 524 525 $post_id = $post->ID; 526 527 if ( wp_is_post_revision( $post_id ) ) 528 return; 529 530 if( !function_exists('get_current_screen') ) 531 return; 532 533 $image_id = get_post_thumbnail_id( $post_id ); 534 $current_screen = get_current_screen(); 535 $post_type = $current_screen->post_type; 536 537 if( ! mfis_image_size_ok( $image_id, $post_type ) ){ 538 539 $mfis_error_message = mfis_get_error_message($post_type); 384 540 385 update_option('mfis_ size', '<span class="mfis_error"><span class="mfis_icon">!</span> <span class="mfis_error_message">' . esc_html($mfis_error_message) . '</span></span>');541 update_option('mfis_editor_error_message', '<span class="mfis_error"><span class="mfis_icon">!</span> <span class="mfis_error_message">' . esc_html($mfis_error_message) . '</span></span>'); 386 542 387 543 } 388 } 389 if (is_admin()) add_action('transition_post_status', 'mfis_after_save', 10, 3); 544 545 } 546 if (is_admin()) add_action('transition_post_status', 'mfis_output_error_message', 10, 3); 390 547 391 548 … … 396 553 function mfis_notice(){ 397 554 398 if( get_option( 'mfis_ size' ) ) : ?>555 if( get_option( 'mfis_editor_error_message' ) ) : ?> 399 556 400 557 <div class="notice notice-error mfis-notice-error"> 401 <p><?php echo get_option( 'mfis_ size' ); ?></p>558 <p><?php echo get_option( 'mfis_editor_error_message' ); ?></p> 402 559 </div> 403 560 404 561 <?php endif; 405 562 406 delete_option( 'mfis_ size' );563 delete_option( 'mfis_editor_error_message' ); 407 564 } 408 565 add_action( 'admin_notices','mfis_notice' ); … … 415 572 function mfis_remove_notice( $messages ){ 416 573 417 if(get_option('mfis_ size')) :574 if(get_option('mfis_editor_error_message')) : 418 575 419 576 return array(); … … 429 586 /** 430 587 * Function to check if we are in the MFIS settings page 431 *432 588 * @since 1.0.0 433 589 */ -
minimum-featured-image-size/trunk/readme.txt
r1926403 r2005148 4 4 Donate link: https://www.paypal.me/corgdesign/5 5 5 Requires at least: 4.7.5 6 Tested up to: 4.9.66 Tested up to: 5.0.2 7 7 Stable tag: trunk 8 8 License: GPL2 … … 12 12 13 13 == Description == 14 With this plugin you can set the minimum width and height required for featured images used in standard and custom posts. You can also customise the error message shown to the user when an image isn't large enough. 14 With this plugin you can set the minimum width and height required for featured images used in standard and custom posts. You can also customise the error message shown to the user when an image isn't large enough. Supports the Gutenberg Block Editor. 15 15 16 16 == Installation == 17 17 * Upload minimum-featured-image-size folder to your /wp-content/plugins/ directory. 18 18 * Activate the plugin through the ‘Plugins’ menu in WordPress. 19 * Set the minimum width and height for your featured images, customise the error message, and disable/enable Ajax by goingto Settings > Minimum Featured Image Size.19 * Go to Settings > Minimum Featured Image Size. 20 20 21 21 == Frequently Asked Questions == … … 24 24 == Screenshots == 25 25 1. Plugin settings 26 2. Ajax error message displayed to user if image isn't large enough 27 3. Non-ajax error message displayed to user if image isn't large enough 26 2. Error message displayed to user if image isn't large enough 28 27 29 28 == Changelog == … … 45 44 = 1.1.2 = 46 45 * Bug fix 46 47 = 2.0 = 48 * Feature requests added - exact dimensions, choice of post disabling 49 * Add Gutenberg Block Editor support
Note: See TracChangeset
for help on using the changeset viewer.