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
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
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.