Move common custom post functions into abstract

This commit is contained in:
Brian Miyaji
2014-04-27 17:35:57 +10:00
parent 284b0f1a5f
commit 100f172adc
13 changed files with 99 additions and 259 deletions

View File

@@ -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;
}
}