Add expiry date column
This commit is contained in:
@@ -38,12 +38,12 @@ class Opalestate_Admin_Property {
|
||||
|
||||
// add_action( 'transition_post_status', array( __CLASS__, 'save_post' ), 10, 3 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function save_post( $new_status, $old_status, $post ){
|
||||
if ( $new_status == 'publish' && $post->post_type == "opalestate_property" ) {
|
||||
public static function save_post( $new_status, $old_status, $post ) {
|
||||
if ( $new_status == 'publish' && $post->post_type == "opalestate_property" ) {
|
||||
$user_id = $post->post_author;
|
||||
$user = get_user_by( 'id', $user_id );
|
||||
if ( ! is_object( $user ) ) {
|
||||
@@ -103,6 +103,7 @@ class Opalestate_Admin_Property {
|
||||
$columns['comments'] = $comments;
|
||||
$columns['author'] = esc_html__( 'Author', 'opalestate-pro' );
|
||||
$columns['date'] = esc_html__( 'Date', 'opalestate-pro' );
|
||||
$columns['expiry_date'] = esc_html__( 'Expiry Date', 'opalestate-pro' );
|
||||
|
||||
return $columns;
|
||||
}
|
||||
@@ -148,6 +149,15 @@ class Opalestate_Admin_Property {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'expiry_date':
|
||||
if ( $property->get_expiry_date() ) {
|
||||
$expired_time = $property->get_expiry_date();
|
||||
echo date_i18n( __( 'Y/m/d g:i:s a', 'opalestate-pro' ), $expired_time );
|
||||
} else {
|
||||
echo esc_html_x( '---', 'expired property', 'opalestate-pro' );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
|
||||
@@ -740,4 +740,11 @@ class Opalestate_Property {
|
||||
public function get_posted() {
|
||||
return human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) . ' ' . esc_html__( 'ago' );
|
||||
}
|
||||
|
||||
public function get_expiry_date() {
|
||||
$expired_activated = get_post_meta( $this->get_id(), OPALESTATE_PROPERTY_PREFIX . 'expired_activated', true );
|
||||
$expired_time = get_post_meta( $this->get_id(), OPALESTATE_PROPERTY_PREFIX . 'expired_time', true );
|
||||
|
||||
return ( $expired_activated && $expired_time ) ? $expired_time : '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user