Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/12/2022 06:41:40 PM (3 years ago)
Author:
imath
Message:

Raise WordPress required version to 5.7

BuddyPress 11.0.0 will require at least WordPress 5.7. The BP Development team took this decision according to our guideline about WordPress version compatibility.

Props espellcaste, dcavins, oztaser.

Fixes #8709

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-phpmailer.php

    r12708 r13297  
    2727    public function bp_email( BP_Email $email ) {
    2828        static $phpmailer = null;
    29         $phpmailer_is_6_0 = false;
    3029
    3130        /**
     
    4039        $phpmailer = apply_filters( 'bp_phpmailer_object', $phpmailer );
    4140
    42         /**
    43          * WordPress 5.5 deprecated version 5.2 of PHPMailer
    44          * and is now using version 6.0 of PHPMailer.
    45          */
    46         if ( bp_get_major_wp_version() >= 5.5 ) {
    47             $phpmailer_is_6_0 = true;
     41        if ( ! ( $phpmailer instanceof PHPMailer\PHPMailer\PHPMailer ) ) {
     42            if ( ! class_exists( 'PHPMailer\\PHPMailer\\PHPMailer' ) ) {
     43                require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
     44                require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
     45                require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
     46            }
    4847
    49             if ( ! ( $phpmailer instanceof PHPMailer\PHPMailer\PHPMailer ) ) {
    50                 if ( ! class_exists( 'PHPMailer\\PHPMailer\\PHPMailer' ) ) {
    51                     require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
    52                     require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
    53                     require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
    54                 }
    55 
    56                 $phpmailer = new PHPMailer\PHPMailer\PHPMailer( true );
    57             }
    58         } else {
    59             if ( ! ( $phpmailer instanceof PHPMailer ) ) {
    60                 if ( ! class_exists( 'PHPMailer' ) ) {
    61                     require_once ABSPATH . WPINC . '/class-phpmailer.php';
    62                     require_once ABSPATH . WPINC . '/class-smtp.php';
    63                 }
    64 
    65                 $phpmailer = new PHPMailer( true );
    66             }
     48            $phpmailer = new PHPMailer\PHPMailer\PHPMailer( true );
    6749        }
    6850
     
    8769         */
    8870        $phpmailer->Subject = $email->get_subject( 'replace-tokens' );
    89         if ( $phpmailer_is_6_0 ) {
    90             $content_plaintext = PHPMailer\PHPMailer\PHPMailer::normalizeBreaks( $email->get_content_plaintext( 'replace-tokens' ) );
    91         } else {
    92             $content_plaintext = PHPMailer::normalizeBreaks( $email->get_content_plaintext( 'replace-tokens' ) );
    93         }
     71        $content_plaintext = PHPMailer\PHPMailer\PHPMailer::normalizeBreaks( $email->get_content_plaintext( 'replace-tokens' ) );
    9472
    9573        if ( $email->get( 'content_type' ) === 'html' ) {
     
    10381
    10482        $recipient = $email->get_from();
    105         if ( $phpmailer_is_6_0 ) {
    106             try {
    107                 $phpmailer->setFrom( $recipient->get_address(), $recipient->get_name(), false );
    108             } catch ( PHPMailer\PHPMailer\Exception $e ) {
    109             }
    110         } else {
    111             try {
    112                 $phpmailer->SetFrom( $recipient->get_address(), $recipient->get_name(), false );
    113             } catch ( phpmailerException $e ) {
    114             }
     83        try {
     84            $phpmailer->setFrom( $recipient->get_address(), $recipient->get_name(), false );
     85        } catch ( PHPMailer\PHPMailer\Exception $e ) {
    11586        }
    11687
    11788        $recipient = $email->get_reply_to();
    118         if ( $phpmailer_is_6_0 ) {
    119             try {
    120                 $phpmailer->addReplyTo( $recipient->get_address(), $recipient->get_name() );
    121             } catch ( PHPMailer\PHPMailer\Exception $e ) {
    122             }
    123         } else {
    124             try {
    125                 $phpmailer->addReplyTo( $recipient->get_address(), $recipient->get_name() );
    126             } catch ( phpmailerException $e ) {
    127             }
     89        try {
     90            $phpmailer->addReplyTo( $recipient->get_address(), $recipient->get_name() );
     91        } catch ( PHPMailer\PHPMailer\Exception $e ) {
    12892        }
    12993
    13094        $recipients = $email->get_to();
    131         if ( $phpmailer_is_6_0 ) {
    132             foreach ( $recipients as $recipient ) {
    133                 try {
    134                     $phpmailer->AddAddress( $recipient->get_address(), $recipient->get_name() );
    135                 } catch ( PHPMailer\PHPMailer\Exception $e ) {
    136                 }
    137             }
    138         } else {
    139             foreach ( $recipients as $recipient ) {
    140                 try {
    141                     $phpmailer->AddAddress( $recipient->get_address(), $recipient->get_name() );
    142                 } catch ( phpmailerException $e ) {
    143                 }
     95        foreach ( $recipients as $recipient ) {
     96            try {
     97                $phpmailer->AddAddress( $recipient->get_address(), $recipient->get_name() );
     98            } catch ( PHPMailer\PHPMailer\Exception $e ) {
    14499            }
    145100        }
    146101
    147102        $recipients = $email->get_cc();
    148         if ( $phpmailer_is_6_0 ) {
    149             foreach ( $recipients as $recipient ) {
    150                 try {
    151                     $phpmailer->AddCc( $recipient->get_address(), $recipient->get_name() );
    152                 } catch ( PHPMailer\PHPMailer\Exception $e ) {
    153                 }
    154             }
    155         } else {
    156             foreach ( $recipients as $recipient ) {
    157                 try {
    158                     $phpmailer->AddCc( $recipient->get_address(), $recipient->get_name() );
    159                 } catch ( phpmailerException $e ) {
    160                 }
     103        foreach ( $recipients as $recipient ) {
     104            try {
     105                $phpmailer->AddCc( $recipient->get_address(), $recipient->get_name() );
     106            } catch ( PHPMailer\PHPMailer\Exception $e ) {
    161107            }
    162108        }
    163109
    164110        $recipients = $email->get_bcc();
    165         if ( $phpmailer_is_6_0 ) {
    166             foreach ( $recipients as $recipient ) {
    167                 try {
    168                     $phpmailer->AddBcc( $recipient->get_address(), $recipient->get_name() );
    169                 } catch ( PHPMailer\PHPMailer\Exception $e ) {
    170                 }
    171             }
    172         } else {
    173             foreach ( $recipients as $recipient ) {
    174                 try {
    175                     $phpmailer->AddBcc( $recipient->get_address(), $recipient->get_name() );
    176                 } catch ( phpmailerException $e ) {
    177                 }
     111        foreach ( $recipients as $recipient ) {
     112            try {
     113                $phpmailer->AddBcc( $recipient->get_address(), $recipient->get_name() );
     114            } catch ( PHPMailer\PHPMailer\Exception $e ) {
    178115            }
    179116        }
     
    196133        do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
    197134
    198         if ( $phpmailer_is_6_0 ) {
    199             try {
    200                 return $phpmailer->Send();
    201             } catch ( PHPMailer\PHPMailer\Exception $e ) {
    202                 return new WP_Error( $e->getCode(), $e->getMessage(), $email );
    203             }
    204         } else {
    205             try {
    206                 return $phpmailer->Send();
    207             } catch ( phpmailerException $e ) {
    208                 return new WP_Error( $e->getCode(), $e->getMessage(), $email );
    209             }
     135        try {
     136            return $phpmailer->Send();
     137        } catch ( PHPMailer\PHPMailer\Exception $e ) {
     138            return new WP_Error( $e->getCode(), $e->getMessage(), $email );
    210139        }
    211140    }
Note: See TracChangeset for help on using the changeset viewer.