function settings_page()
 {
     if ($_POST) {
         $this->set_options();
     }
     $v = $this->get_options();
     $data['epl_fields'] = $this->fields;
     $data['tabs'] = array('general' => epl__('General'), 'registrations' => epl__('Registrations'), 'event-management' => epl__('Event Management'), 'fullcalendar-settings' => epl__('Calendar'), 'api-settings' => epl__('Advanced'));
     $_field_args = array('section' => $this->fields['epl_general_options'], 'fields_to_display' => array_keys($this->fields['epl_general_options']), 'meta' => array('_view' => 3, 'value' => $v['epl_general_options']));
     $data['epl_general_option_fields'] = $this->epl_util->render_fields($_field_args);
     $data['settings_updated'] = '';
     $_field_args = array('section' => $this->fields['epl_registration_options'], 'fields_to_display' => array_keys($this->fields['epl_registration_options']), 'meta' => array('_view' => 3, 'value' => $v['epl_registration_options']));
     $data['epl_registration_options'] = $this->epl_util->render_fields($_field_args);
     $_field_args = array('section' => $this->fields['epl_event_options'], 'fields_to_display' => array_keys($this->fields['epl_event_options']), 'meta' => array('_view' => 3, 'value' => $v['epl_event_options']));
     $data['epl_event_options'] = $this->epl_util->render_fields($_field_args);
     if (apply_filters('epl_enable_feature_override', false)) {
         $data['tabs']['feature-override'] = epl__('Override');
     }
     if (epl_is_addon_active('ETDFGWETSDFGR')) {
         $data['tabs']['shopping-cart'] = epl__('Event Cart');
         epl_sort_array_by_array($this->fields['epl_sc_options']['epl_sc_primary_regis_forms']['options'], $v['epl_sc_options']['epl_sc_primary_regis_forms']);
         epl_sort_array_by_array($this->fields['epl_sc_options']['epl_sc_addit_regis_forms']['options'], $v['epl_sc_options']['epl_sc_addit_regis_forms']);
         epl_sort_array_by_array($this->fields['epl_sc_options']['epl_sc_payment_choices']['options'], $v['epl_sc_options']['epl_sc_payment_choices']);
         $_field_args = array('section' => $this->fields['epl_sc_options'], 'fields_to_display' => array_keys($this->fields['epl_sc_options']), 'meta' => array('_view' => 3, 'value' => $v['epl_sc_options']));
         $data['epl_sc_options'] = $this->epl_util->render_fields($_field_args);
     }
     unset($this->fields['epl_fullcalendar_options']['epl_fullcalendar_tax_bcg_color']);
     unset($this->fields['epl_fullcalendar_options']['epl_fullcalendar_tax_font_color']);
     $terms = epl_object_to_array(get_terms('epl_event_categories', array('hide_empty' => false)));
     if (!epl_is_empty_array($terms)) {
         $vals = epl_get_element('epl_fullcalendar_options', $v, array());
         foreach ($terms as $k => $_v) {
             $_bcg_val = epl_get_element($_v['slug'], epl_get_element('epl_fullcalendar_tax_bcg_color', $vals), '#ffffff');
             $_font_val = epl_get_element($_v['slug'], epl_get_element('epl_fullcalendar_tax_font_color', $vals), 'blue');
             $_d = array('input_type' => 'text', 'label' => $_v['name'], 'class' => 'epl_w80');
             $f = $_d + array('input_name' => 'epl_fullcalendar_tax_bcg_color[' . $_v['slug'] . ']', 'value' => $_bcg_val, 'style' => 'background-color:' . $_bcg_val);
             $data['_tax_color'][$_v['slug']] = $this->epl_util->create_element($f, 0);
             $f = $_d + array('input_name' => 'epl_fullcalendar_tax_font_color[' . $_v['slug'] . ']', 'value' => $_font_val, 'style' => 'background-color:' . $_font_val);
             $data['_font_color'][$_v['slug']] = $this->epl_util->create_element($f, 0);
         }
     }
     $_field_args = array('section' => $this->fields['epl_fullcalendar_options'], 'fields_to_display' => array_keys($this->fields['epl_fullcalendar_options']), 'meta' => array('_view' => 3, 'value' => $v['epl_fullcalendar_options']));
     $data['epl_fullcalendar_options'] = $this->epl_util->render_fields($_field_args);
     if (epl_check_for_it()) {
         $_field_args = array('section' => $this->fields['epl_api_option_fields'], 'fields_to_display' => array_keys($this->fields['epl_api_option_fields']), 'meta' => array('_view' => 3, 'value' => $v['epl_api_option_fields']));
         $data['epl_api_options'] = $this->epl_util->render_fields($_field_args);
     }
     $this->epl->load_view('admin/settings/settings-page', $data);
 }
function epl_term_list($raw = false)
{
    $terms = epl_object_to_array(get_terms('epl_event_categories'));
    if ($raw) {
        return $terms;
    }
    $_o = array();
    $f = array();
    foreach ($terms as $k => $v) {
        $_o[$v['slug']] = $v['name'];
    }
    return $_o;
}
<?php

$legend_location = epl_nz(epl_get_setting('epl_fullcalendar_options', 'epl_fullcalendar_show_legend'), 0);
$legend = array();
if ($legend_location != 0) {
    $legend[$legend_location] = '';
    $terms = epl_object_to_array(get_terms('epl_event_categories'));
    $event_bcg_color = epl_get_setting('epl_fullcalendar_options', 'epl_fullcalendar_tax_bcg_color');
    $event_font_color = epl_get_setting('epl_fullcalendar_options', 'epl_fullcalendar_tax_font_color');
    foreach ($terms as $term) {
        $bc = epl_get_element($term['slug'], $event_bcg_color, '#ffffff');
        $tc = epl_get_element($term['slug'], $event_font_color, 'blue');
        $legend[$legend_location] .= "<span class='epl_fc_legend_cat' style='background-color:{$bc};color:{$tc}'>{$term['name']}</span>";
    }
    $legend[$legend_location] = '<div class="epl_fc_legend">' . $legend[$legend_location] . '</div>';
}
?>

<?php 
echo epl_get_element(1, $legend);
?>

<div id='calendar'></div>

<?php 
echo epl_get_element(10, $legend);
?>



<script type='text/javascript'>
 function the_list_of_active_events($show_date = false)
 {
     global $wpdb, $event_details;
     static $events = array();
     if (!empty($events)) {
         return $events;
     }
     $_events = $wpdb->get_results("\n\t\t\tSELECT id, post_title\n\t\t\tFROM {$wpdb->posts} WHERE post_type = 'epl_event' and post_status = 'publish'\n\t\t\tORDER BY post_title ASC\n\t\t", OBJECT_K);
     $_events = epl_object_to_array($_events);
     foreach ($_events as $k => $v) {
         setup_event_details($k);
         //if(!epl_event_fully_expired()){
         $events[$k] = $v['post_title'] . epl_wrap($v['id'], ' (', ') ') . ' - ' . epl_formatted_date(current((array) $event_details['_epl_start_date']), 'D, M d ');
         //}
     }
     return $events;
 }
 function get_discount_used_count($discount_id, $discount_code = null)
 {
     global $wpdb;
     $all_used_from_event = wp_cache_get('get_discount_used_count_all_used_from_event');
     $all_used_global = wp_cache_get('get_discount_used_count_all_used_global');
     if ($all_used_from_event === false) {
         $all_used_from_event = $wpdb->get_results("SELECT re.event_id, count(r.ID) as discount_used_count,r.discount_code_id, r.discount_source_id\n                FROM {$wpdb->epl_registration} as r\n                INNER JOIN {$wpdb->epl_regis_events} re ON r.regis_id = re.regis_id\n                WHERE (r.status = 2 OR r.status = 5)                \n                AND NOT r.discount_code_id = '' \n                GROUP BY r.discount_code_id, re.event_id", OBJECT_K);
         $all_used_global = $wpdb->get_results("SELECT CONCAT_WS('_',r.discount_code_id,r.discount_source_id) as discount_code_id, count(r.ID) as discount_used_count, r.discount_source_id\n                FROM {$wpdb->epl_registration} as r\n                INNER JOIN {$wpdb->epl_regis_events} re ON r.regis_id = re.regis_id\n                WHERE (r.status = 2 OR r.status = 5)                \n                AND NOT r.discount_code_id = '' \n                GROUP BY r.discount_code_id, r.discount_source_id", OBJECT_K);
         wp_cache_add('get_discount_used_count_all_used_from_event', $all_used_from_event);
         wp_cache_add('get_discount_used_count_all_used_global', $all_used_global);
     }
     $r = 0;
     if ($all_used_from_event || $all_used_global) {
         $all_used_from_event = epl_object_to_array($all_used_from_event);
         if ($this->discount_source == 'e') {
             if (isset($all_used_from_event[$this->discount_source_id]) && $all_used_from_event[$this->discount_source_id]['discount_code_id'] == $discount_id) {
                 $r = epl_get_element_m('discount_used_count', $this->discount_source_id, $all_used_from_event, 0);
             }
         } else {
             //Using combination $discount_id . '_' . $this->discount_source_id for key to
             //take care of instances when users duplicate discounts with duplicate post plugin
             $all_used_global = epl_object_to_array($all_used_global);
             $r = epl_get_element_m('discount_used_count', $discount_id . '_' . $this->discount_source_id, $all_used_global, 0);
         }
     }
     return $r;
 }
Ejemplo n.º 6
0
 function get_days_for_widget($for = 0, $args = array())
 {
     //echo "<pre class='prettyprint'>" . __LINE__ . "> " . print_r($args, true). "</pre>";
     //$for = 3 = fullcalendar
     global $wpdb;
     $defined_widgets = array(0 => 'widget_epl_upcoming_events_widget', 1 => 'widget_epl_advanced_cal_widget');
     $defined_widgets = apply_filters('epl_defined_widgets', $defined_widgets);
     $widget_options = !epl_is_empty_array($args) ? $args : $this->get_widget_options(epl_get_element($for, $defined_widgets));
     $c_year = isset($_REQUEST['c_year']) ? (int) $_REQUEST['c_year'] : date_i18n("Y");
     $c_month = isset($_REQUEST['c_month']) ? (int) $_REQUEST['c_month'] : date_i18n("m");
     $l_d = $this->epl->epl_calendar->get_total_days($c_month, $c_year);
     $day = 1;
     $from = "{$c_year}-{$c_month}-01";
     $to = "{$c_year}-{$c_month}-{$l_d}";
     $exclude_past_events = false;
     $content_to_show = epl_get_element('content_to_show', $args, 'content');
     $num_words_to_show = epl_get_element('num_words_to_show', $args, 60);
     switch ($for) {
         case 0:
             $from = EPL_DATE;
             $days_to_show = epl_get_element('days_to_show', $widget_options, 60);
             $content_to_show = epl_get_element('content_to_show', $widget_options, 'content');
             $num_words_to_show = epl_get_element('num_words_to_show', $widget_options, 60);
             $taxonomy = epl_get_element('tax_filter', $widget_options, array());
             if (!epl_is_empty_array($taxonomy)) {
                 $args['taxonomy'] = $taxonomy;
             }
             //$to = $from . " + $days_to_show days";
             $to = $from + $days_to_show * 60 * 60 * 24;
             break;
         case 1:
             $exclude_past_events = epl_get_element('exclude_past_events', $widget_options) == 'on';
             break;
         case 0:
         case 3:
             //these will work with ajax method of event retrieval
             //$from = intval( epl_get_element( 'start', $_REQUEST, null ) );
             //$to = intval( epl_get_element( 'end', $_REQUEST, null ) );
             $to = "2100-01-01";
             //TODO - Urgent, why has this been like this all this time?
             $exclude_past_events = true;
             break;
     }
     $from = epl_get_date_timestamp($from);
     $to = epl_get_date_timestamp($to);
     $qry_args = array('post_type' => 'epl_event', 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_key' => '_q__epl_start_date');
     //for the ongoing events
     if (epl_get_element('show_past', $args) == 1) {
         //unset( $qry_args['post__in'] );
         //unset( $qry_args['p'] );
         unset($qry_args['meta_key']);
         $exclude_past_events = false;
     }
     if ($event_id = epl_get_element('event_id', $args, null)) {
         if (strpos($event_id, ',') !== false) {
             $qry_args['post__in'] = explode(',', $event_id);
         } else {
             $qry_args['p'] = intval(epl_get_element('event_id', $args));
         }
     } else {
         $WHERE = "AND pm2.meta_key = '_q__epl_start_date' AND CAST(pm2.meta_value AS SIGNED) >= " . $from . "\n                AND pm2.meta_key = '_q__epl_start_date' AND CAST(pm2.meta_value AS SIGNED) <= " . $to . "";
         if ($exclude_past_events == false && $for > 0) {
             $WHERE = '';
         }
         $post_ids = $wpdb->get_col("\n            SELECT pm.post_id\n            FROM {$wpdb->postmeta} pm\n            INNER JOIN {$wpdb->postmeta} pm2 ON (pm.post_id = pm2.post_id)\n            WHERE\n                ((pm.meta_key = '_epl_event_status' AND CAST(pm.meta_value AS SIGNED) = '1' {$WHERE})\n            OR\n                (pm.meta_key = '_epl_event_status' AND CAST(pm.meta_value AS SIGNED) = '3'))\n            GROUP BY pm.post_id\n\n        ");
         $post_ids = $post_ids;
         $qry_args['post__in'] = $post_ids;
     }
     if (epl_get_element('location', $args) != '') {
         $_l = $args['location'];
         $qry_args['meta_query'][] = array('key' => '_epl_event_location', 'value' => $_l, 'type' => 'NUMERIC', 'compare' => '=');
     }
     if (epl_get_element('org', $args) != '') {
         $_l = $args['org'];
         $qry_args['meta_query'][] = array('key' => '_epl_event_organization', 'value' => $_l, 'type' => 'NUMERIC', 'compare' => '=');
     }
     $qry_args['tax_query'] = array();
     if (($_t = epl_get_element_m('taxonomy', 'shortcode_atts', $args)) == '') {
         $_t = epl_get_element('taxonomy', $args, '');
     }
     if ($_t != '') {
         if (!is_array($_t) && strpos($_t, ',') !== false) {
             $_t = array();
             $_t = explode(',', $args['taxonomy']);
         }
         $qry_args['tax_query'] = array(array('taxonomy' => 'epl_event_categories', 'field' => 'slug', 'terms' => $_t));
     }
     if (($_te = epl_get_element_m('taxonomy_exclude', 'shortcode_atts', $args, '')) == '') {
         $_te = epl_get_element('taxonomy_exclude', $args, '');
     }
     if ($_te != '') {
         if (!is_array($_te) && strpos($_te, ',') !== false) {
             $_t = array();
             $_te = explode(',', $_te);
         }
         $qry_args['tax_query'] += array(array('taxonomy' => 'epl_event_categories', 'terms' => $_te, 'field' => 'slug', 'operator' => 'NOT IN'));
     }
     /* if ( epl_get_element( 'show_past', $args ) == 1 ) {
        //unset( $qry_args['post__in'] );
        //unset( $qry_args['p'] );
        $exclude_past_events = false;
        }
        /* elseif ( epl_is_empty_array( $qry_args['post__in'] ) ) {
        //$meta_query['relation'] = 'AND';
        $qry_args['meta_query'][] = array(
        'key' => '_epl_event_status',
        'value' => 1,
        'type' => 'NUMERIC',
        'compare' => '='
        );
        } */
     $exclude_event_ids = explode(',', epl_get_element('exclude_event_ids', $args));
     global $event_details;
     $d = array();
     $q = new WP_Query($qry_args);
     $new = true;
     while ($q->have_posts()) {
         $q->the_post();
         $s = array();
         $t = get_the_title();
         setup_event_details(get_the_ID());
         $e = $event_details['_epl_end_date'];
         $alt_regis_url = $event_details['_epl_alt_regis_url'] != '' ? 1 : 0;
         $event_status = $event_details['_epl_event_status'];
         $event_type = $event_details['_epl_event_type'];
         $event_rec_frequency = $event_details['_epl_recurrence_frequency'];
         //if class and upcoming widget or fullcalendar
         if ($event_type == 10 && ($for == 0 || $for == 3)) {
             //if there is recurrence formula
             if ($event_rec_frequency != '0') {
                 $this->rm->hide_past = $exclude_past_events;
                 $s = $this->rm->recurrence_dates_from_db($event_details);
                 $s = $this->rm->construct_table_array($s, true);
                 $e = $s['_epl_end_date'];
                 $s = $s['_epl_start_date'];
             } elseif (!epl_is_empty_array($event_details['_epl_class_session_date'])) {
                 $s = $event_details['_epl_class_session_date'];
             }
         }
         if (empty($s) || epl_get_element('class_display_type', $widget_options, 2) == 1 && epl_get_element('class_display_type', $args, 0) == 1) {
             $s = $event_details['_epl_start_date'];
         }
         if (epl_is_empty_array($s) || in_array(get_the_ID(), $exclude_event_ids) || $event_status == 2) {
             continue;
         }
         $d = $this->make_cal_day_array(array('event_id' => get_the_ID(), 'event_status' => $event_status, 'event_type' => epl_get_element('_epl_event_type', $event_details), 'start_dates' => $s, 'end_dates' => $e, 'event_times' => array('start' => $event_details['_epl_start_time'], 'end' => $event_details['_epl_end_time']), 'description' => epl_trunc($content_to_show == 'content' ? do_shortcode(get_the_content()) : get_the_excerpt(), $num_words_to_show), 'register_link_type' => $alt_regis_url == 1 ? $alt_regis_url : epl_get_element('_epl_cal_link_destination', $event_details, 0), 'register_link' => epl_get_element('_epl_cal_link_destination', $event_details, 0) == 0 ? $this->get_the_register_button(get_the_ID(), true, array('for' => $for)) : get_permalink(), 'title' => $t, 'current_month' => $c_month, 'from' => $from, 'to' => $to, 'to' => $to, 'exclude_past_events' => $exclude_past_events, 'term_list' => substr(array_reduce((array) epl_object_to_array(get_the_terms(get_the_ID(), 'epl_event_categories')), create_function('$t,$_terms', '$t .= "{$_terms["slug"]},"; return $t;')), 0, -1)), $for, $d);
         $new = false;
         //echo "<pre class='prettyprint'>" . __LINE__ . "> " . print_r($d, true). "</pre>";
     }
     wp_reset_query();
     ksort($d);
     $num_events_to_show = epl_get_element('num_events_to_show', $args, '');
     if ($num_events_to_show != '' && $for == 0) {
         $d = array_slice($d, 0, $num_events_to_show);
     }
     return $d;
 }