Move common custom post functions into abstract
This commit is contained in:
@@ -10,46 +10,7 @@
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
class SP_Team {
|
||||
|
||||
/** @var int The team (post) ID. */
|
||||
public $ID;
|
||||
|
||||
/** @var object The actual post object. */
|
||||
public $post;
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $post
|
||||
*/
|
||||
public function __construct( $post ) {
|
||||
if ( $post instanceof WP_Post || $post instanceof SP_Team ):
|
||||
$this->ID = absint( $post->ID );
|
||||
$this->post = $post;
|
||||
else:
|
||||
$this->ID = absint( $post );
|
||||
$this->post = get_post( $this->ID );
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* __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;
|
||||
}
|
||||
class SP_Team extends SP_Custom_Post {
|
||||
|
||||
/**
|
||||
* Returns formatted data
|
||||
@@ -274,5 +235,4 @@ class SP_Team {
|
||||
return $merged;
|
||||
endif;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user