Plugin Directory

Changeset 3139317


Ignore:
Timestamp:
08/21/2024 10:38:08 PM (19 months ago)
Author:
mdawaffe
Message:

PHP8 Compatibility fixes

Props sixhours

File:
1 edited

Legend:

Unmodified
Added
Removed
  • email-post-changes/trunk/class.email-post-changes.php

    r3139316 r3139317  
    9494        // If this is a new post, set an empty title for $this->left_post so that it appears in the diff.
    9595        $child_posts = wp_get_post_revisions( $post_id, array( 'numberposts' => 1 ) );
    96         if ( count( $child_posts ) == 0 ) {
     96        if ( ( is_countable( $child_posts ) ? count( $child_posts ) : 0 ) == 0 ) {
    9797            $this->left_post->post_title = '';
    9898        }
     
    160160
    161161        $emails = array_unique( array_merge( $options['emails'], $user_emails ) );
    162         if ( ! count( $emails ) && apply_filters( 'email_post_changes_admin_email_fallback', true ) )
     162        if ( $emails === [] && apply_filters( 'email_post_changes_admin_email_fallback', true ) ) {
    163163            $emails[] = get_option( 'admin_email' );
    164 
     164        }
    165165        $emails = apply_filters( 'email_post_changes_emails', $emails, $this->left_post->ID, $this->right_post->ID );
    166166
     
    311311
    312312        if ( empty( $options['emails'] ) ) {
    313             if ( count( $return['users'] ) )
     313            if ( is_countable( $return['users'] ) ? count( $return['users'] ) : 0 ) {
    314314                $return['emails'] = array();
    315             else
     315            } else {
    316316                $return['emails'] = $this->defaults['emails'];
     317            }
    317318        } else {
    318319            $_emails = is_string( $options['emails'] ) ? preg_split( '(\n|\r)', $options['emails'], -1, PREG_SPLIT_NO_EMPTY ) : array();
     
    325326                $return['invalid_emails'] = $invalid_emails;
    326327
    327             if ( $emails )
     328            if ( $emails ) {
    328329                $return['emails'] = $emails;
    329             elseif ( count( $return['users'] ) )
     330            } elseif ( is_countable( $return['users'] ) ? count( $return['users'] ) : 0 ) {
    330331                $return['emails'] = array();
    331             else
     332            } else {
    332333                $return['emails'] = $this->defaults['emails'];
     334            }
    333335
    334336            // Don't store a huge list of invalid emails addresses in the option
     
    339341
    340342            // Cap to at max 200 email addresses
    341             if ( count( $return['emails'] ) > 200 ) {
     343            if ( ( is_countable( $return['emails'] ) ? count( $return['emails'] ) : 0 ) > 200 ) {
    342344                $return['emails'] = array_slice( $return['emails'], 0, 200 );
    343345            }
     
    389391<?php   if ( !empty( $options['invalid_emails'] ) && $_GET['settings-updated'] ) : ?>
    390392    <div class="error">
    391         <p><?php printf( _n( 'Invalid Email: %s', 'Invalid Emails: %s', count( $options['invalid_emails'] ) ), '<kbd>' . join( '</kbd>, <kbd>', array_map( 'esc_html', $options['invalid_emails'] ) ) ); ?></p>
     393        <p><?php printf( _n( 'Invalid Email: %s', 'Invalid Emails: %s', is_countable( $options['invalid_emails'] ) ? count( $options['invalid_emails'] ) : 0 ), '<kbd>' . implode( '</kbd>, <kbd>', array_map( 'esc_html', $options['invalid_emails'] ) ) ); ?></p>
    392394    </div>
    393395<?php   endif; ?>
     
    448450        $options = $this->get_options();
    449451?>
    450         <textarea class="epc-additional-emails" rows="4" cols="40" name="email_post_changes[emails]"><?php echo esc_html( join( "\n", $options['emails'] ) ); ?></textarea>
     452        <textarea class="epc-additional-emails" rows="4" cols="40" name="email_post_changes[emails]"><?php echo esc_html( implode( "\n", $options['emails'] ) ); ?></textarea>
    451453        <p class="description"><?php _e( 'One email address per line.' ); ?></p>
    452454<?php
Note: See TracChangeset for help on using the changeset viewer.