Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Post_Model::___get( string $key, boolean $raw = false )
Private getter.
Parameters Parameters
- $key
-
(string) (Required) The property key.
- $raw
-
(boolean) (Optional) Whether or not we need to get the raw value.
Default value: false
Return Return
(mixed)
Source Source
File: includes/abstracts/abstract.llms.post.model.php
private function ___get( $key, $raw = false ) { // Force numeric id and prevent filtering on the id. if ( 'id' === $key ) { return absint( $this->$key ); } elseif ( in_array( $key, array_keys( $this->get_post_properties() ) ) ) { $post_key = 'post_' . $key; // Ensure post is set globally for filters below. global $post; $temp = $post; $post = $this->post; switch ( $key ) { case 'content': $val = $raw ? $this->post->$post_key : llms_content( $this->post->$post_key ); break; case 'excerpt': /* This is a WordPress filter. */ $val = $raw ? $this->post->$post_key : apply_filters( 'get_the_excerpt', $this->post->$post_key, $this->post ); break; case 'ping_status': case 'comment_status': case 'menu_order': $val = $this->post->$key; break; case 'title': /* This is a WordPress filter. */ $val = $raw ? $this->post->$post_key : apply_filters( 'the_title', $this->post->$post_key, $this->get( 'id' ) ); break; default: $val = $this->post->$post_key; } // Return the original global. $post = $temp; } elseif ( ! in_array( $key, $this->get_unsettable_properties() ) ) { if ( metadata_exists( 'post', $this->id, $this->meta_prefix . $key ) ) { $val = get_post_meta( $this->id, $this->meta_prefix . $key, true ); } else { $val = $this->get_default_value( $key ); } } else { return $this->$key; } // If we found a value, apply default llms get filter and return the value. if ( isset( $val ) ) { /** * Filters the list of properties which should be excluded from scrubbing during a property read. * * The dynamic portion of this hook, `{$this->model_post_type}`, refers to the post's model type, * for example "course" for an `LLMS_Course`, "membership" for an `LLMS_Membership`, etc... * * @since 4.10.0 * * @param string[] $props An array of property keys to be excluded from scrubbing. * @param LLMS_Post_Model $this Instance of the post object. */ $exclude = apply_filters( "llms_get_{$this->model_post_type}_no_scrub_props", array( 'content', 'name' ), $this ); if ( ! $raw && ! in_array( $key, $exclude, true ) ) { $val = $this->scrub( $key, $val ); } /** * Filters the property value * * The first dynamic portion of this hook, `$this->model_post_type`, refers to the model's post type. For example "course", * "lesson", "membership", etc... * The second dynamic part of this hook, `$key`, refers to the property name. * * @since Unknown * * @param mixed $val The property value. * @param LLMS_Post_Model $llms_post The LLMS_Post_Model instance. */ return apply_filters( "llms_get_{$this->model_post_type}_{$key}", $val, $this ); } // Shouldn't ever get here. return false; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.1.2 | Pass second parameter to the get_the_excerpt filter hook (the WP_Post object), introduced in WordPress 4.5.0. |
4.10.0 | Add post_name as a property to skip scrubbing and add a filter on the list of properties to skip scrubbing. |
3.34.0 | Introduced. |