Exemplo n.º 1
0
 /**
  * Widget HTML output
  */
 function widget($args, $instance)
 {
     $markup = '';
     extract($args);
     //Output before widget stuff
     echo $before_widget;
     // Check whether any calendars have been added yet
     if (wp_count_posts(ECWD_PLUGIN_PREFIX . '_calendar')->publish > 0) {
         //Output title stuff
         $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
         if (!empty($title)) {
             echo $before_title . $title . $after_title;
         }
         $no_events_exist = true;
         $calendar_ids = array();
         if (!empty($instance['id'])) {
             //Break comma delimited list of event ids into array
             $calendar_ids = explode(',', str_replace(' ', '', $instance['id']));
             //Check each id is an integer, if not, remove it from the array
             foreach ($calendar_ids as $key => $calendar_id) {
                 if (0 == absint($calendar_id)) {
                     unset($calendar_ids[$key]);
                 }
             }
             //If at least one of the event ids entered exists, set no_events_exist to false
             foreach ($calendar_ids as $calendar_id) {
                 if (false !== get_post_meta($calendar_id)) {
                     $no_events_exist = false;
                 }
             }
         } else {
             if (current_user_can('manage_options')) {
                 _e('No valid Event IDs have been entered for this widget. Please check that you have entered the IDs correctly in the widget settings (Appearance > Widgets), and that the Events have not been deleted.', 'ecwd');
             }
         }
         //Check that at least one valid event id has been entered
         if (!empty($calendar_ids)) {
             //Turns event_ids back into string or event ids delimited by '-' ('1-2-3-4' for example)
             $calendar_ids = implode('-', $calendar_ids);
             $title_text = !empty($instance['display_title_text']) ? $instance['display_title_text'] : null;
             $sort_order = isset($instance['order']) ? $instance['order'] : 'asc';
             $page_items = isset($instance['page_items']) ? $instance['page_items'] : '5';
             $args = array('title_text' => $title_text, 'sort' => $sort_order, 'page_items' => $page_items, 'month' => null, 'year' => null, 'widget' => 1);
             //				if( 'list-grouped' == $instance['display_type'] ) {
             //					$args['grouped'] = 1;
             //				}
             //echo $instance['display_type'].'------------<br />';
             $markup = ecwd_print_calendar($calendar_ids, $instance['display_type'], $args, true);
             echo $markup;
         }
     } else {
         if (current_user_can('manage_options')) {
             _e('You have not added any events yet.', 'ecwd');
         } else {
             return;
         }
     }
     //Output after widget stuff
     echo $after_widget;
 }
Exemplo n.º 2
0
function ecwd_shortcode($attr)
{
    extract(shortcode_atts(array('id' => null, 'page_items' => '5', 'event_search' => 'yes', 'display' => 'full', 'displays' => null, 'filters' => null), $attr, ECWD_PLUGIN_PREFIX . '_calendar'));
    // If no ID is specified then return
    if (empty($id)) {
        return;
    }
    $args = array('displays' => $displays, 'filters' => $filters, 'page_items' => $page_items, 'event_search' => $event_search);
    $calendar_ids = explode(',', str_replace(' ', '', $id));
    $result = ecwd_print_calendar($calendar_ids, $display, $args);
    return $result;
}
Exemplo n.º 3
0
/**
 * AJAX function change calendar months
 */
function ecwd_ajax()
{
    // check to see if the submitted nonce matches with the
    // generated nonce
    if (!check_ajax_referer(ECWD_PLUGIN_PREFIX . '_ajax_nonce', ECWD_PLUGIN_PREFIX . '_nonce')) {
        die('Request has failed.');
    }
    $ids = esc_html($_POST[ECWD_PLUGIN_PREFIX . '_calendar_ids']);
    $args = array();
    $display = '';
    if (isset($_POST[ECWD_PLUGIN_PREFIX . '_link'])) {
        $link = esc_html($_POST[ECWD_PLUGIN_PREFIX . '_link']);
        parse_str($link, $link_arr);
        $date = $link_arr['?date'];
        $page = isset($link_arr['amp;cpage']) ? $link_arr['amp;cpage'] : 1;
        $display = isset($link_arr['amp;t']) ? $link_arr['amp;t'] : 'full';
    } else {
        if (isset($_POST[ECWD_PLUGIN_PREFIX . '_prev_display'])) {
            $display = esc_html($_POST[ECWD_PLUGIN_PREFIX . '_prev_display']);
        }
    }
    $type = esc_html($_POST[ECWD_PLUGIN_PREFIX . '_type']);
    if (isset($_POST[ECWD_PLUGIN_PREFIX . '_date']) && $_POST[ECWD_PLUGIN_PREFIX . '_date'] == 1 && !empty($date)) {
        $args['date'] = $date;
    } else {
        $args['date'] = '';
    }
    if ($args['date'] == '' && isset($_POST[ECWD_PLUGIN_PREFIX . '_date_filter'])) {
        $args['date'] = $_POST[ECWD_PLUGIN_PREFIX . '_date_filter'];
    }
    if (isset($_POST[ECWD_PLUGIN_PREFIX . '_prev_display']) && $_POST[ECWD_PLUGIN_PREFIX . '_prev_display'] != '') {
        $args['prev_display'] = $_POST[ECWD_PLUGIN_PREFIX . '_prev_display'];
    } else {
        $args['prev_display'] = '';
    }
    $args['widget'] = 0;
    if ('widget' == $type) {
        $args['widget'] = 1;
    }
    if ($display == '') {
        if ($args['widget'] == 1) {
            $display = 'mini';
        } else {
            $display = 'full';
        }
    }
    if (isset($page)) {
        $args['cpage'] = $page;
    } else {
        $args['cpage'] = 1;
    }
    $args['search_params'] = array();
    if (isset($_POST[ECWD_PLUGIN_PREFIX . '_query']) && $_POST[ECWD_PLUGIN_PREFIX . '_query'] != '' || isset($_POST[ECWD_PLUGIN_PREFIX . '_categories']) || isset($_POST[ECWD_PLUGIN_PREFIX . '_tags']) || isset($_POST[ECWD_PLUGIN_PREFIX . '_venues']) || isset($_POST[ECWD_PLUGIN_PREFIX . '_organizers']) || isset($_POST[ECWD_PLUGIN_PREFIX . '_weekdays'])) {
        $args['search_params']['query'] = isset($_POST[ECWD_PLUGIN_PREFIX . '_query']) ? $_POST[ECWD_PLUGIN_PREFIX . '_query'] : 0;
        $args['search_params']['categories'] = isset($_POST[ECWD_PLUGIN_PREFIX . '_categories']) ? $_POST[ECWD_PLUGIN_PREFIX . '_categories'] : 0;
        $args['search_params']['weekdays'] = isset($_POST[ECWD_PLUGIN_PREFIX . '_weekdays']) ? $_POST[ECWD_PLUGIN_PREFIX . '_weekdays'] : 0;
        $args['search_params']['tags'] = isset($_POST[ECWD_PLUGIN_PREFIX . '_tags']) ? $_POST[ECWD_PLUGIN_PREFIX . '_tags'] : 0;
        $args['search_params']['venues'] = isset($_POST[ECWD_PLUGIN_PREFIX . '_venues']) ? $_POST[ECWD_PLUGIN_PREFIX . '_venues'] : 0;
        $args['search_params']['organizers'] = isset($_POST[ECWD_PLUGIN_PREFIX . '_organizers']) ? $_POST[ECWD_PLUGIN_PREFIX . '_organizers'] : 0;
        $args['search'] = 1;
        //$display = 'list';
    }
    $displays = isset($_POST[ECWD_PLUGIN_PREFIX . '_displays']) ? $_POST[ECWD_PLUGIN_PREFIX . '_displays'] : null;
    $filters = isset($_POST[ECWD_PLUGIN_PREFIX . '_filters']) ? $_POST[ECWD_PLUGIN_PREFIX . '_filters'] : null;
    $page_items = isset($_POST[ECWD_PLUGIN_PREFIX . '_page_items']) ? $_POST[ECWD_PLUGIN_PREFIX . '_page_items'] : null;
    $event_search = isset($_POST[ECWD_PLUGIN_PREFIX . '_event_search']) ? $_POST[ECWD_PLUGIN_PREFIX . '_event_search'] : null;
    $args['displays'] = $displays;
    $args['filters'] = $filters;
    $args['event_search'] = $event_search;
    $args['page_items'] = $page_items;
    echo ecwd_print_calendar($ids, $display, $args, $args['widget'], true);
    wp_die();
}
Exemplo n.º 4
0
                            <span>Dates:</span>
                            <span class="ecwd-dates">

                            </span>
                            <span>Title:</span>
                                <input type="text" name="ecwd_event_name"  id="ecwd_event_name"/>
                                <span class="ecwd_error"></span>
                                <input type="hidden" id="ecwd_event_date_from" name="ecwd_event_date_from" />
                                <input type="hidden" id="ecwd_event_date_to" name="ecwd_event_date_to" />

                                <span id="add_event_to_cal" class="add_event_to_cal"> Save</span>
                                <span class="ecwd_notification"> </span>
                            </div>
                        </div>
                    <?php 
    echo ecwd_print_calendar($post_id, 'full', array(), false, false, array(), true);
    ?>
                    </div>
            </td>
        </tr>

        <tr>
            <th scope="row"><?php 
    _e('Events', 'ecwd');
    ?>
</th>
            <td>
                <div class="ecwd-events">
                    <?php 
    if ($events) {
        ?>