Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/02/2024 01:16:13 AM (6 months ago)
Author:
espellcaste
Message:

WPCS: Part VI: miscellaneous fixes for some of the files of the core component.

Follow-up to [13883], [13886], [13887], [13888], and [13891]

See #9164 and #7228

File:
1 edited

Legend:

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

    r13372 r13892  
    11<?php
    22/**
    3  * Core component classes.
     3 * Represents an email that will be sent to member(s).
    44 *
    55 * @package BuddyPress
     
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
    1212/**
    13  * Represents an email that will be sent to member(s).
     13 * BP_Email class.
    1414 *
    1515 * @since 2.5.0
    1616 */
    1717class BP_Email {
     18
    1819    /**
    1920     * Addressee details (BCC).
     
    6667     * @since 2.5.0
    6768     *
    68      * @var BP_Email_Sender Sender details.
     69     * @var BP_Email_Sender
    6970     */
    7071    protected $from = null;
     
    8283     * Email headers.
    8384     *
    84      * @since 2.5.0
    85      *
    86      * @var string[] Associative pairing of email header name/value.
     85     * Associative pairing of email header name/value.
     86     *
     87     * @since 2.5.0
     88     *
     89     * @var string[]
    8790     */
    8891    protected $headers = array();
     
    9396     * @since 2.5.0
    9497     *
    95      * @var WP_Post
     98     * @var WP_Post|null
    9699     */
    97100    protected $post_object = null;
     
    102105     * @since 2.5.0
    103106     *
    104      * @var BP_Email_Sender "Reply to" details.
     107     * @var BP_Email_Sender|null
    105108     */
    106109    protected $reply_to = null;
     
    146149     * Token names and replacement values for this email.
    147150     *
    148      * @since 2.5.0
    149      *
    150      * @var string[] Associative pairing of token name (key) and replacement value (value).
     151     * Associative pairing of token name (key) and replacement value (value).
     152     *
     153     * @since 2.5.0
     154     *
     155     * @var string[]
    151156     */
    152157    protected $tokens = array();
     
    170175                $domain = substr( $domain, 4 );
    171176            }
    172 
    173177        } elseif ( function_exists( 'gethostname' ) && gethostname() !== false ) {
    174178            $domain = gethostname();
     
    205209    }
    206210
    207 
    208211    /*
    209212     * Setters/getters.
     
    228231            $property_name = 'content_' . $this->get_content_type();
    229232
    230             if ( ! in_array( $property_name, array( 'content_html', 'content_plaintext', ), true ) ) {
     233            if ( ! in_array( $property_name, array( 'content_html', 'content_plaintext' ), true ) ) {
    231234                $property_name = 'content_html';
    232235            }
     
    236239            return null;
    237240        }
    238 
    239241
    240242        /**
     
    273275         * @since 2.5.0
    274276         *
    275          * @param string   $retval        Property value.
     277         * @param mixed    $retval        Property value.
    276278         * @param string   $property_name Property name.
    277279         * @param string   $transform     How to transform the return value.
     
    286288     *
    287289     * @since 4.0.0
     290     *
     291     * @return string
    288292     */
    289293    public function get_preheader() {
     
    444448     * @since 2.5.0
    445449     *
    446      * @return WP_Post The post.
     450     * @param string $transform Optional. How to transform the return value. Defaults to 'raw'.
     451     * @return WP_Post|null WP_Post object, or null if not set.
    447452     */
    448453    public function get_post_object( $transform = 'raw' ) {
     
    459464     * @param string $transform Optional. How to transform the return value.
    460465     *                          Accepts 'raw' (default) or 'replace-tokens'.
    461      * @return BP_Email_Recipient "Reply to" recipient.
     466     * @return BP_Email_Recipient|null "Reply to" recipient, or null if not set.
    462467     */
    463468    public function get_reply_to( $transform = 'raw' ) {
     
    474479     * @param string $transform Optional. How to transform the return value.
    475480     *                          Accepts 'raw' (default) or 'replace-tokens'.
    476      * @return string Email subject.
     481     * @return string|null Email subject, or null if not set.
    477482     */
    478483    public function get_subject( $transform = 'raw' ) {
     
    489494     * @param string $transform Optional. How to transform the return value.
    490495     *                          Accepts 'raw' (default) or 'replace-tokens'.
    491      * @return string Email template. Assumed to be HTML.
     496     * @return string|null Email template. Assumed to be HTML. Or null if not set.
    492497     */
    493498    public function get_template( $transform = 'raw' ) {
     
    504509     * @param string $transform Optional. How to transform the return value.
    505510     *                          Accepts 'raw' (default) or 'replace-tokens'.
    506      * @return BP_Email_Recipient[] "To" recipients.
     511     * @return BP_Email_Recipient[]|null "To" recipients. Or null if not set.
    507512     */
    508513    public function get_to( $transform = 'raw' ) {
     
    519524     * @param string $transform Optional. How to transform the return value.
    520525     *                          Accepts 'raw' (default) or 'replace-tokens'.
    521      * @return string[] Associative pairing of token name (key) and replacement value (value).
     526     * @return string[]|null Associative pairing of token name (key) and replacement value (value).
     527     *                       Or null if not set.
    522528     */
    523529    public function get_tokens( $transform = 'raw' ) {
     
    571577     * @param string|array|int|WP_User $bcc_address Either a email address, user ID, WP_User object,
    572578     *                                              or an array containing any combination of the above.
    573      * @param string $name Optional. If $bcc_address is a string, this is the recipient's name.
    574      * @param string $operation Optional. If "replace", $to_address replaces current setting (default).
    575      *                          If "add", $to_address is added to the current setting.
     579     * @param string                   $name Optional. If $bcc_address is a string, this is the recipient's name.
     580     * @param string                   $operation Optional. If "replace", $to_address replaces current setting (default).
     581     *                                            If "add", $to_address is added to the current setting.
    576582     * @return BP_Email
    577583     */
     
    583589                $bcc[] = new BP_Email_Recipient( $address );
    584590            }
    585 
    586591        } else {
    587592            $bcc[] = new BP_Email_Recipient( $bcc_address, $name );
     
    620625     * @param string|array|int|WP_User $cc_address Either a email address, user ID, WP_User object,
    621626     *                                             or an array containing any combination of the above.
    622      * @param string $name Optional. If $cc_address is a string, this is the recipient's name.
    623      * @param string $operation Optional. If "replace", $to_address replaces current setting (default).
    624      *                          If "add", $to_address is added to the current setting.
     627     * @param string                   $name Optional. If $cc_address is a string, this is the recipient's name.
     628     * @param string                   $operation Optional. If "replace", $to_address replaces current setting (default).
     629     *                                            If "add", $to_address is added to the current setting.
    625630     * @return BP_Email
    626631     */
     
    632637                $cc[] = new BP_Email_Recipient( $address );
    633638            }
    634 
    635639        } else {
    636640            $cc[] = new BP_Email_Recipient( $cc_address, $name );
     
    710714     */
    711715    public function set_content_type( $content_type ) {
    712         if ( ! in_array( $content_type, array( 'html', 'plaintext', ), true ) ) {
     716        if ( ! in_array( $content_type, array( 'html', 'plaintext' ), true ) ) {
    713717            $class        = get_class_vars( get_class() );
    714718            $content_type = $class['content_type'];
     
    736740     *
    737741     * @param string|array|int|WP_User $email_address Either a email address, user ID, or WP_User object.
    738      * @param string $name Optional. If $email_address is a string, this is the recipient's name.
     742     * @param string                   $name Optional. If $email_address is a string, this is the recipient's name.
    739743     * @return BP_Email
    740744     */
     
    768772     * @since 2.5.0
    769773     *
    770      * @param WP_Post $post
     774     * @param WP_Post $post Post object.
    771775     * @return BP_Email
    772776     */
     
    820824     * @param string|array|int|WP_User $email_address Either a email address, user ID, WP_User object,
    821825     *                                                or an array containing any combination of the above.
    822      * @param string $name Optional. If $email_address is a string, this is the recipient's name.
     826     * @param string                   $name Optional. If $email_address is a string, this is the recipient's name.
    823827     * @return BP_Email
    824828     */
     
    913917     * @param string|array|int|WP_User $to_address Either a email address, user ID, WP_User object,
    914918     *                                             or an array containing any combination of the above.
    915      * @param string $name Optional. If $to_address is a string, this is the recipient's name.
    916      * @param string $operation Optional. If "replace", $to_address replaces current setting (default).
    917      *                          If "add", $to_address is added to the current setting.
     919     * @param string                   $name Optional. If $to_address is a string, this is the recipient's name.
     920     * @param string                   $operation Optional. If "replace", $to_address replaces current setting (default).
     921     *                                            If "add", $to_address is added to the current setting.
    918922     * @return BP_Email
    919923     */
     
    925929                $to[] = new BP_Email_Recipient( $address );
    926930            }
    927 
    928931        } else {
    929932            $to[] = new BP_Email_Recipient( $to_address, $name );
     
    982985        return $this;
    983986    }
    984 
    985987
    986988    /*
Note: See TracChangeset for help on using the changeset viewer.