コード例 #1
0
function eme_get_calendar_shortcode($atts)
{
    extract(shortcode_atts(array('category' => 0, 'notcategory' => 0, 'full' => 0, 'month' => '', 'year' => '', 'echo' => 0, 'long_events' => 0, 'author' => '', 'contact_person' => '', 'location_id' => '', 'template_id' => 0), $atts));
    $echo = $echo === "true" || $echo === "1" ? true : $echo;
    $full = $full === "true" || $full === "1" ? true : $full;
    $long_events = $long_events === "true" || $long_events === "1" ? true : $long_events;
    $echo = $echo === "false" || $echo === "0" ? false : $echo;
    $full = $full === "false" || $full === "0" ? false : $full;
    $long_events = $long_events === "false" || $long_events === "0" ? false : $long_events;
    // this allows people to use specific months/years to show the calendar on
    if (isset($_GET['calmonth']) && $_GET['calmonth'] != '') {
        $month = eme_sanitize_request($_GET['calmonth']);
    }
    if (isset($_GET['calyear']) && $_GET['calyear'] != '') {
        $year = eme_sanitize_request($_GET['calyear']);
    }
    // the filter list overrides the settings
    if (isset($_REQUEST['eme_eventAction']) && $_REQUEST['eme_eventAction'] == 'filter') {
        if (isset($_REQUEST['eme_scope_filter'])) {
            $scope = eme_sanitize_request($_REQUEST['eme_scope_filter']);
            if (preg_match("/^([0-9]{4})-([0-9]{2})-[0-9]{2}--[0-9]{4}-[0-9]{2}-[0-9]{2}\$/", $scope, $matches)) {
                $year = $matches[1];
                $month = $matches[2];
            }
        }
        if (isset($_REQUEST['eme_loc_filter'])) {
            if (is_array($_REQUEST['eme_loc_filter'])) {
                $location_id = join(',', eme_sanitize_request($_REQUEST['eme_loc_filter']));
            } else {
                $location_id = eme_sanitize_request($_REQUEST['eme_loc_filter']);
            }
        }
        if (isset($_REQUEST['eme_town_filter'])) {
            $towns = eme_sanitize_request($_REQUEST['eme_town_filter']);
            if (empty($location_id)) {
                $location_id = join(',', eme_get_town_location_ids($towns));
            } else {
                $location_id .= "," . join(',', eme_get_town_location_ids($towns));
            }
        }
        if (isset($_REQUEST['eme_cat_filter'])) {
            if (is_array($_REQUEST['eme_cat_filter'])) {
                $category = join(',', eme_sanitize_request($_REQUEST['eme_cat_filter']));
            } else {
                $category = eme_sanitize_request($_REQUEST['eme_cat_filter']);
            }
        }
    }
    $result = eme_get_calendar("full={$full}&month={$month}&year={$year}&echo={$echo}&long_events={$long_events}&category={$category}&author={$author}&contact_person={$contact_person}&location_id={$location_id}&notcategory={$notcategory}&template_id={$template_id}");
    return $result;
}
コード例 #2
0
ファイル: eme_events.php プロジェクト: johnmanlove/Bridgeland
function eme_get_events_list_shortcode($atts)
{
    $eme_event_list_number_events = get_option('eme_event_list_number_items');
    extract(shortcode_atts(array('limit' => $eme_event_list_number_events, 'scope' => 'future', 'order' => 'ASC', 'format' => '', 'category' => '', 'showperiod' => '', 'author' => '', 'contact_person' => '', 'paging' => 0, 'long_events' => 0, 'location_id' => 0, 'user_registered_only' => 0, 'show_ongoing' => 1, 'link_showperiod' => 0, 'notcategory' => '', 'show_recurrent_events_once' => 0, 'template_id' => 0, 'template_id_header' => 0, 'template_id_footer' => 0, 'no_events_message' => ''), $atts));
    // the filter list overrides the settings
    if (isset($_REQUEST['eme_eventAction']) && $_REQUEST['eme_eventAction'] == 'filter') {
        if (isset($_REQUEST['eme_scope_filter']) && !empty($_REQUEST['eme_scope_filter'])) {
            $scope = eme_sanitize_request($_REQUEST['eme_scope_filter']);
        }
        if (isset($_REQUEST['eme_loc_filter']) && !empty($_REQUEST['eme_loc_filter'])) {
            if (is_array($_REQUEST['eme_loc_filter'])) {
                $location_id = join(',', eme_sanitize_request($_REQUEST['eme_loc_filter']));
            } else {
                $location_id = eme_sanitize_request($_REQUEST['eme_loc_filter']);
            }
        }
        if (isset($_REQUEST['eme_town_filter']) && !empty($_REQUEST['eme_town_filter'])) {
            $towns = eme_sanitize_request($_REQUEST['eme_town_filter']);
            if (empty($location_id)) {
                $location_id = join(',', eme_get_town_location_ids($towns));
            } else {
                $location_id .= "," . join(',', eme_get_town_location_ids($towns));
            }
        }
        if (isset($_REQUEST['eme_cat_filter']) && !empty($_REQUEST['eme_cat_filter'])) {
            if (is_array($_REQUEST['eme_cat_filter'])) {
                $category = join(',', eme_sanitize_request($_REQUEST['eme_cat_filter']));
            } else {
                $category = eme_sanitize_request($_REQUEST['eme_cat_filter']);
            }
        }
    }
    // if format is given as argument, sometimes people need url-encoded strings inside so wordpress doesn't get confused, so we decode them here again
    $format = urldecode($format);
    // for format: sometimes people want to give placeholders as options, but when using the shortcode inside
    // another (e.g. when putting[eme_events format="#_EVENTNAME"] inside the "display single event" setting,
    // the replacement of the placeholders happens too soon (placeholders get replaced first, before any other
    // shortcode is interpreted). So we add the option that people can use "#OTHER_", and we replace this with
    // "#_" here
    $format = preg_replace('/#OTHER/', "#", $format);
    $result = eme_get_events_list($limit, $scope, $order, $format, '', '', 0, $category, $showperiod, $long_events, $author, $contact_person, $paging, $location_id, $user_registered_only, $show_ongoing, $link_showperiod, $notcategory, $show_recurrent_events_once, $template_id, $template_id_header, $template_id_footer, $no_events_message);
    return $result;
}