Astra_Ext_Advanced_Hooks_Markup::get_time_duration_eligibility( $post_id )
Check if post eligible to show on time duration
Description
@param int $post_id post id.
Source
File: addons/advanced-hooks/classes/class-astra-ext-advanced-hooks-markup.php
public static function get_time_duration_eligibility( $post_id ) { $time_duration = get_post_meta( $post_id, 'ast-advanced-time-duration', 'true' ); if ( isset( $time_duration['enabled'] ) && 'enabled' !== $time_duration['enabled'] ) { return true; // Eligible to display as not enabled time duration. } $start_dt = isset( $time_duration['start-dt'] ) ? strtotime( $time_duration['start-dt'] ) : false; $end_dt = isset( $time_duration['end-dt'] ) ? strtotime( $time_duration['end-dt'] ) : false; $current_dt = strtotime( current_time( 'mysql' ) ); if ( $start_dt && $start_dt > $current_dt ) { return false; // Not eligible if not started yet. } if ( $end_dt && $end_dt < $current_dt ) { return false; // Not eligible if already time passed. } return true; // Fallback true. }
Expand full source code Collapse full source code View on Trac