Last active
July 20, 2017 15:35
-
-
Save Mosharush/ddfdbf57a91e8efeeb478b7b2d269dc9 to your computer and use it in GitHub Desktop.
Post content partial schedule - Wordpress Shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add Shortcode sc_schedule_content - Post content partial schedule | |
function sc_schedule_content( $atts , $content = null ) { | |
// Attributes | |
$atts = shortcode_atts( | |
array( | |
'time' => '', | |
'date' => '', | |
), | |
$atts, | |
'schedule-content' | |
); | |
if( is_numeric( $atts['time'] ) && empty( $atts['date'] ) ){ | |
$time = intval( $atts['time'] ); | |
} else{ | |
$time = strtotime( $atts['date'] . ' ' . $atts['time'] ); | |
} | |
if( get_the_time('U') < $time ){ | |
return $content; | |
} | |
} | |
add_shortcode( 'schedule-content', 'sc_schedule_content' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use:
Add the code to your functions.php file on the active theme.
Put shortcode in post content, Text or any content inside tags of shortcode.
Shortcode attributes:
Examples:
For unix time
For regular date or/and time: