OS : Linux
PHP Version : 7.4.33
Software : Apache/2.4.6 (CentOS) PHP/7.4.33
Information System : Linux apprendre2 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
Disable Function : "",
), $atts));
$output = '';
$output .= '
' . tt_remove_wpautop($content) . '
';
return $output;
}
add_shortcode("tt_items_list", "tt_event_items_list");
//items list
function tt_event_item($atts, $content)
{
extract(shortcode_atts(array(
"type" => "",
"border_color" => "",
"text_color" => "",
"value" => ""
), $atts));
$output = '';
$output .= '
<' . ($type=="info" ? 'label' : 'span') . ($text_color!='' ? ' style="color: #' . $text_color . ';"' : '') . '>' . tt_remove_wpautop($content) . '' . ($type=="info" ? 'label' : 'span') . '>';
if($value!="")
$output .= '' . $value . '
';
$output .= '
';
return $output;
}
add_shortcode("tt_item", "tt_event_item");
//columns
function tt_event_columns($atts, $content)
{
extract(shortcode_atts(array(
"class" => ""
), $atts));
return '' . tt_remove_wpautop($content) . '
';
}
add_shortcode("tt_columns", "tt_event_columns");
//column left
function tt_event_column_left($atts, $content)
{
return '' . tt_remove_wpautop($content) . '
';
}
add_shortcode("tt_column_left", "tt_event_column_left");
//column right
function tt_event_column_right($atts, $content)
{
return '' . tt_remove_wpautop($content) . '
';
}
add_shortcode("tt_column_right", "tt_event_column_right");
//event hours
function tt_event_hours($atts, $content)
{
global $post;
extract(shortcode_atts(array(
"event_id" => $post->ID,
"title" => "Event Hours",
"time_format" => "H.i",
"class" => "",
"hour_category" => "",
"text_color" => "",
"border_color" => "",
"columns" => ""
), $atts));
if($hour_category!=null && $hour_category!="-")
$hour_category = array_values(array_diff(array_filter(array_map('trim', explode(",", $hour_category))), array("-")));
if($columns!="")
{
$weekdays_explode = explode(",", $columns);
$weekdays_in_query = "";
foreach($weekdays_explode as $weekday_explode)
$weekdays_in_query .= "'" . $weekday_explode . "'" . ($weekday_explode!=end($weekdays_explode) ? "," : "");
}
global $wpdb;
$output = '';
//The actual fields for data entry
$query = "SELECT * FROM `" . $wpdb->prefix . "event_hours` AS t1 LEFT JOIN {$wpdb->posts} AS t2 ON t1.weekday_id=t2.ID
WHERE t1.event_id='" . (int)$event_id . "'";
if($hour_category!=null && $hour_category!="-")
$query .= "
AND t1.category IN('" . join("','", $hour_category) . "')";
if(isset($weekdays_in_query) && $weekdays_in_query!="")
$query .= " AND t2.post_name IN(" . $weekdays_in_query . ")";
$query .= " ORDER BY t2.menu_order, t1.start, t1.end";
$event_hours = $wpdb->get_results($query);
$event_hours_count = count($event_hours);
if($event_hours_count)
{
//get weekdays
$query = "SELECT ID, post_title FROM {$wpdb->posts}
WHERE
post_type='timetable_weekdays'
ORDER BY menu_order";
$weekdays = $wpdb->get_results($query);
if($title!="")
$output .= '' . $title . '(' . $event_hours_count . ')
';
$output .= '
';
}
return $output;
}
add_shortcode("tt_event_hours", "tt_event_hours");
?>