ID = absint( $post->ID ); $this->post = $post; else : $this->ID = absint( $post ); $this->post = get_post( $this->ID ); endif; } /** * __isset function. * * @access public * @param mixed $key * @return bool */ public function __isset( $key ) { return metadata_exists( 'post', $this->ID, 'sp_' . $key ); } /** * __get function. * * @access public * @param mixed $key * @return bool */ public function __get( $key ) { if ( ! isset( $key ) ) : return $this->post; else : $value = get_post_meta( $this->ID, 'sp_' . $key, true ); endif; return $value; } /** * Get the post data. * * @access public * @return object */ public function get_post_data() { return $this->post; } /** * Get terms sorted by order. * * @access public * @param string $taxonomy The taxonomy. * @return array|false|WP_Error See `get_the_terms()` */ public function get_terms_sorted_by_sp_order( $taxonomy ) { $terms = get_the_terms( $this->ID, $taxonomy ); if ( $terms ) { usort( $terms, 'sp_sort_terms' ); } return $terms; } }