function handle_rhc_date($atts, $content = '', $code = "") { global $rhc_plugin; extract(shortcode_atts(array('post_id' => '', 'date_format' => 'MMMM d, yyyy', 'time_format' => 'h:mm tt', 'allday_hide' => '', 'label' => '', 'label_start' => __('Start', 'rhc'), 'label_end' => __('End', 'rhc'), 'class' => 'rhc-sc-date'), $atts)); $post_id = empty($post_id) ? get_the_ID() : intval($post_id); $is_allday = '1' == get_post_meta($post_id, 'fc_allday', true) ? true : false; if (intval($allday_hide) && $is_allday) { return ''; } if (!empty($label)) { if (in_array($code, array('rhc_start', 'rhc_start_date', 'rhc_start_time'))) { $label_start = $label; } else { $label_end = $label; } } $fc_start_datetime = get_post_meta($post_id, 'fc_start_datetime', true); $fc_end_datetime = get_post_meta($post_id, 'fc_end_datetime', true); if (empty($fc_start_datetime) || empty($fc_end_datetime)) { return ''; } $class .= empty($class) ? 'sc-' . $code : ' sc-' . $code; $start = strtotime($fc_start_datetime); $end = strtotime($fc_end_datetime); if (date('Ymd', $start) == date('Ymd', $end)) { $class .= ' same-day'; } else { $class .= ' not-same-day'; } if (date('Ym', $start) == date('Ym', $end)) { $class .= ' same-month'; } else { $class .= ' not-same-month'; } $content = $this->handle_event_date_get_content($atts, $content, $code); //TODO: LOad from settings $date_format = empty($date_format) ? $rhc_plugin->get_option('cal_rhc_sc_date_format', 'MMMM d, yyyy', true) : $date_format; $time_format = empty($time_format) ? $rhc_plugin->get_option('cal_rhc_sc_time_format', 'h:mm tt', true) : $time_format; if ($is_allday) { $class .= ' fc-is-allday'; } return sprintf($content, $class, $label_start, fc_get_repeat_start_date($post_id, $date_format), fc_get_repeat_start_date($post_id, $time_format), $label_end, fc_get_repeat_end_date($post_id, $date_format), fc_get_repeat_end_date($post_id, $time_format)); }
function handle_date_shortcode($atts, $content = null, $code = "") { extract(shortcode_atts(array('post_id' => false, 'date_format' => false), $atts)); do_action('enqueue_frontend_only'); $post_id = false === $post_id ? get_the_ID() : $post_id; if ($code == 'rhc_start_date') { return fc_get_repeat_start_date($post_id, $date_format); } elseif ($code == 'rhc_end_date') { return fc_get_repeat_end_date($post_id, $date_format); } else { return ''; } }