BP_Email::get( string $property_name, string $transform = 'raw' )

Getter function to expose object properties.

Description

Unlike most other methods in this class, this one is not chainable.

Parameters

$property_name

(Required) Property to access.

$transform

(Optional) How to transform the return value. Accepts 'raw' (default) or 'replace-tokens'.

Default value: 'raw'

Return

(mixed) Returns null if property does not exist, otherwise the value.

Source

File: bp-core/classes/class-bp-email.php

213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
public function get( $property_name, $transform = 'raw' ) {
 
    // "content" is replaced by HTML or plain text depending on $content_type.
    if ( $property_name === 'content' ) {
        $property_name = 'content_' . $this->get_content_type();
 
        if ( ! in_array( $property_name, array( 'content_html', 'content_plaintext', ), true ) ) {
            $property_name = 'content_html';
        }
    }
 
    if ( ! property_exists( $this, $property_name ) ) {
        return null;
    }
 
 
    /**
     * Filters the value of the specified email property before transformation.
     *
     * This is a dynamic filter dependent on the specified key.
     *
     * @since BuddyPress 2.5.0
     *
     * @param mixed $property_value Property value.
     * @param string $property_name
     * @param string $transform How to transform the return value.
     *                          Accepts 'raw' (default) or 'replace-tokens'.
     * @param BP_Email $this Current instance of the email type class.
     */
    $retval = apply_filters( "bp_email_get_{$property_name}", $this->$property_name, $property_name, $transform, $this );
 
    switch ( $transform ) {
        // Special-case to fill the $template with the email $content.
        case 'add-content':
            $retval = str_replace( '{{{content}}}', wpautop( $this->get_content( 'replace-tokens' ) ), $retval );
            // Fall through.
 
        case 'replace-tokens':
            $retval = bp_core_replace_tokens_in_text( $retval, $this->get_tokens( 'raw' ) );
            // Fall through.
 
        case 'raw':
        default:
            // Do nothing.
    }
 
    /**
     * Filters the value of the specified email $property after transformation.
     *
     * @since BuddyPress 2.5.0
     *
     * @param string $retval Property value.
     * @param string $property_name
     * @param string $transform How to transform the return value.
     *                          Accepts 'raw' (default) or 'replace-tokens'.
     * @param BP_Email $this Current instance of the email type class.
     */
    return apply_filters( 'bp_email_get_property', $retval, $property_name, $transform, $this );
}

Changelog

Changelog
Version Description
BuddyPress 2.5.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.