Plugin Directory

Changeset 1714373


Ignore:
Timestamp:
08/16/2017 09:51:54 PM (9 years ago)
Author:
pressupinc
Message:

deploy from git

Location:
require-featured-image/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • require-featured-image/trunk/readme.txt

    r1539458 r1714373  
    44Tags: featured image, images, edit, post, admin, require featured image, image, media, thumbnail, thumbnails, post thumbnail, photo, pictures
    55Requires at least: 3.5
    6 Tested up to: 4.6.1
    7 Stable tag: 1.2.3
     6Tested up to: 4.8.1
     7Stable tag: 1.3.0
    88License: MIT
    99License URI: http://opensource.org/licenses/MIT
     
    7070
    7171== CHANGELOG ==
     72
     73= 1.3.0 (2017.08.16) =
     74* Fixing an issue where the PHP didn't stop the post from publishing, if it were invoked
     75* Fixing an issue where the size warning banner would flash on in Chrome erroneously
    7276
    7377= 1.2.3 (2016.11.23) =
  • require-featured-image/trunk/require-featured-image-on-edit.js

    r1355892 r1714373  
    11jQuery(document).ready(function($) {
    22
    3     function checkImageReturnWarningMessageOrEmpty() {
    4         var $img = $('#postimagediv').find('img');
    5         if ($img.length === 0) {
    6             return passedFromServer.jsWarningHtml;
    7         }
    8         if (passedImageIsTooSmall($img)) {
    9             return passedFromServer.jsSmallHtml;
    10         }
    11         return '';
    12     }
     3    function checkImageReturnWarningMessageOrEmpty() {
     4        var $img = $('#postimagediv').find('img');
     5        if ($img.length === 0) {
     6            return passedFromServer.jsWarningHtml;
     7        }
     8        if (featuredImageIsTooSmall()) {
     9            return passedFromServer.jsSmallHtml;
     10        }
     11        return '';
     12    }
    1313
    14     function passedImageIsTooSmall($img) {
    15         var input = $img[0].src;
    16         var pathToImage = input.replace(/-\d+[Xx]\d+\./g, ".");
    17         var featuredImage = new Image();
    18         featuredImage.src = pathToImage;
    19         return featuredImage.width < passedFromServer.width || featuredImage.height < passedFromServer.height;
    20     }
     14    // Contains three test "failures" at page load
     15    var isTooSmallTrials = [ true, true, true ];
    2116
    22     function disablePublishAndWarn(message) {
    23         createMessageAreaIfNeeded();
    24         $('#nofeature-message').addClass("error")
    25             .html('<p>'+message+'</p>');
    26         $('#publish').attr('disabled','disabled');
    27     }
     17    function featuredImageIsTooSmall() {
     18        // A weird polling issue in Chrome made this necessary
     19        var $img = $('#postimagediv').find('img');
    2820
    29     function clearWarningAndEnablePublish() {
    30         $('#nofeature-message').remove();
    31         $('#publish').removeAttr('disabled');
    32     }
     21        // pop one off, if needed
     22        if( isTooSmallTrials.length > 2 ) {
     23            isTooSmallTrials.shift();
     24        }
     25        isTooSmallTrials.push( passedImageIsTooSmall($img) );
    3326
    34     function createMessageAreaIfNeeded() {
    35         if ($('body').find("#nofeature-message").length === 0) {
    36             $('#post').before('<div id="nofeature-message"></div>');
    37         }
    38     }
     27        var imageIsTooSmallCount = isTooSmallTrials.reduce(function (a, b) {
     28            return a + b;
     29        }, 0);
     30
     31        return (imageIsTooSmallCount > 2);
     32    }
     33
     34    function passedImageIsTooSmall($img) {
     35        var input = $img[0].src;
     36        var pathToImage = input.replace(/-\d+[Xx]\d+\./g, ".");
     37        var featuredImage = new Image();
     38        featuredImage.src = pathToImage;
     39
     40        return featuredImage.width < passedFromServer.width || featuredImage.height < passedFromServer.height;
     41    }
     42
     43    function disablePublishAndWarn(message) {
     44        createMessageAreaIfNeeded();
     45        $('#nofeature-message').addClass("error")
     46            .html('<p>'+message+'</p>');
     47        $('#publish').attr('disabled','disabled');
     48    }
     49
     50    function clearWarningAndEnablePublish() {
     51        $('#nofeature-message').remove();
     52        $('#publish').removeAttr('disabled');
     53    }
     54
     55    function createMessageAreaIfNeeded() {
     56        if ($('body').find("#nofeature-message").length === 0) {
     57            $('#post').before('<div id="nofeature-message"></div>');
     58        }
     59    }
    3960
    4061    function detectWarnFeaturedImage() {
    41         if (checkImageReturnWarningMessageOrEmpty()) {
    42             disablePublishAndWarn(checkImageReturnWarningMessageOrEmpty());
    43         } else {
    44             clearWarningAndEnablePublish();
    45         }
    46     }
     62        if (checkImageReturnWarningMessageOrEmpty()) {
     63            disablePublishAndWarn(checkImageReturnWarningMessageOrEmpty());
     64        } else {
     65            clearWarningAndEnablePublish();
     66        }
     67    }
    4768
    48     detectWarnFeaturedImage();
    49     setInterval(detectWarnFeaturedImage, 800);
     69    detectWarnFeaturedImage();
     70    setInterval(detectWarnFeaturedImage, 800);
    5071
    5172});
  • require-featured-image/trunk/require-featured-image.php

    r1539458 r1714373  
    55Description: Like it says on the tin: requires posts to have a featured image set before they'll be published.
    66Author: Press Up
    7 Version: 1.2.3
     7Version: 1.3.0
    88Author URI: http://pressupinc.com
    99Text Domain: require-featured-image
     
    1515function rfi_guard( $new_status, $old_status, $post ) {
    1616    if ( $new_status === 'publish' && rfi_should_stop_post_publishing( $post ) ) {
     17        // transition_post_status comes after the post has changed statuses, so we must roll back here
     18        // because publish->publish->... is an infinite loop, move a published post without an image to draft
     19        if ( $old_status == 'publish' ) {
     20            $old_status = 'draft';
     21        }
     22        $post->post_status = $old_status;
     23        wp_update_post( $post );
    1724        wp_die( rfi_get_warning_message() );
    1825    }
Note: See TracChangeset for help on using the changeset viewer.