Clean up spaces, tabs, indentation, and bracket formatting
This commit is contained in:
@@ -4,11 +4,11 @@
|
||||
*
|
||||
* The SportsPress custom post class handles individual post data.
|
||||
*
|
||||
* @class SP_Custom_Post
|
||||
* @version 2.6.5
|
||||
* @package SportsPress/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author ThemeBoy
|
||||
* @class SP_Custom_Post
|
||||
* @version 2.6.5
|
||||
* @package SportsPress/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
abstract class SP_Custom_Post {
|
||||
|
||||
@@ -25,11 +25,11 @@ abstract class SP_Custom_Post {
|
||||
* @param mixed $post
|
||||
*/
|
||||
public function __construct( $post ) {
|
||||
if ( $post instanceof WP_Post || $post instanceof SP_Custom_Post ):
|
||||
if ( $post instanceof WP_Post || $post instanceof SP_Custom_Post ) :
|
||||
$this->ID = absint( $post->ID );
|
||||
$this->post = $post;
|
||||
else:
|
||||
$this->ID = absint( $post );
|
||||
else :
|
||||
$this->ID = absint( $post );
|
||||
$this->post = get_post( $this->ID );
|
||||
endif;
|
||||
}
|
||||
@@ -53,9 +53,9 @@ abstract class SP_Custom_Post {
|
||||
* @return bool
|
||||
*/
|
||||
public function __get( $key ) {
|
||||
if ( ! isset( $key ) ):
|
||||
if ( ! isset( $key ) ) :
|
||||
return $this->post;
|
||||
else:
|
||||
else :
|
||||
$value = get_post_meta( $this->ID, 'sp_' . $key, true );
|
||||
endif;
|
||||
|
||||
@@ -77,7 +77,7 @@ abstract class SP_Custom_Post {
|
||||
*
|
||||
* @access public
|
||||
* @param string $taxonomy The taxonomy.
|
||||
* @return array|false|WP_Error See `get_the_terms()`
|
||||
* @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 );
|
||||
|
||||
@@ -4,70 +4,70 @@
|
||||
*
|
||||
* The SportsPress secondary post class extends custom posts with handling of secondary post types.
|
||||
*
|
||||
* @class SP_Secondary_Post
|
||||
* @class SP_Secondary_Post
|
||||
* @version 2.5.3
|
||||
* @package SportsPress/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
abstract class SP_Secondary_Post extends SP_Custom_Post {
|
||||
|
||||
/** @var string The date filter for events. */
|
||||
public $date = 0;
|
||||
/** @var string The date filter for events. */
|
||||
public $date = 0;
|
||||
|
||||
/** @var string The date to range from. */
|
||||
public $from = 'now';
|
||||
/** @var string The date to range from. */
|
||||
public $from = 'now';
|
||||
|
||||
/** @var string The date to range to. */
|
||||
public $to = 'now';
|
||||
/** @var string The date to range to. */
|
||||
public $to = 'now';
|
||||
|
||||
/** @var string The number of days to query in the past. */
|
||||
public $past = 0;
|
||||
/** @var string The number of days to query in the past. */
|
||||
public $past = 0;
|
||||
|
||||
/** @var string The number of days to query in the future. */
|
||||
public $future = 0;
|
||||
/** @var string The number of days to query in the future. */
|
||||
public $future = 0;
|
||||
|
||||
/** @var boolean Determines whether the date range is relative. */
|
||||
public $relative = false;
|
||||
/** @var boolean Determines whether the date range is relative. */
|
||||
public $relative = false;
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $post
|
||||
*/
|
||||
public function __construct( $post ) {
|
||||
if ( $post instanceof WP_Post || $post instanceof SP_Secondary_Post ):
|
||||
$this->ID = absint( $post->ID );
|
||||
$this->post = $post;
|
||||
else:
|
||||
$this->ID = absint( $post );
|
||||
$this->post = get_post( $this->ID );
|
||||
endif;
|
||||
}
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $post
|
||||
*/
|
||||
public function __construct( $post ) {
|
||||
if ( $post instanceof WP_Post || $post instanceof SP_Secondary_Post ) :
|
||||
$this->ID = absint( $post->ID );
|
||||
$this->post = $post;
|
||||
else :
|
||||
$this->ID = absint( $post );
|
||||
$this->post = get_post( $this->ID );
|
||||
endif;
|
||||
}
|
||||
|
||||
public function range( $where = '', $format = 'Y-m-d' ) {
|
||||
$from = new DateTime( $this->from );
|
||||
$to = new DateTime( $this->to );
|
||||
public function range( $where = '', $format = 'Y-m-d' ) {
|
||||
$from = new DateTime( $this->from );
|
||||
$to = new DateTime( $this->to );
|
||||
|
||||
$to->modify( '+1 day' );
|
||||
$to->modify( '+1 day' );
|
||||
|
||||
$where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
|
||||
$where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
|
||||
|
||||
return $where;
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function relative( $where = '', $format = 'Y-m-d' ) {
|
||||
$from = new DateTime( 'now' );
|
||||
$to = new DateTime( 'now' );
|
||||
public function relative( $where = '', $format = 'Y-m-d' ) {
|
||||
$from = new DateTime( 'now' );
|
||||
$to = new DateTime( 'now' );
|
||||
|
||||
$from->modify( '-' . abs( (int) $this->past ) . ' day' );
|
||||
$to->modify( '+' . abs( (int) $this->future ) . ' day' );
|
||||
$from->modify( '-' . abs( (int) $this->past ) . ' day' );
|
||||
$to->modify( '+' . abs( (int) $this->future ) . ' day' );
|
||||
|
||||
$to->modify( '+1 day' );
|
||||
$to->modify( '+1 day' );
|
||||
|
||||
$where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
|
||||
$where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
|
||||
|
||||
return $where;
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user