function get_vc_map_params_for_supe() { global $rhc_plugin; require_once RHC_PATH . 'includes/class.rh_templates.php'; $t = new rh_templates(array('template_directory' => $rhc_plugin->get_template_path())); $templates = $t->get_template_files('widget_upcoming_events'); $templates = is_array($templates) && count($templates) > 0 ? $templates : array('widget_upcoming_events.php'); $templates = apply_filters('rhc_uew_templates', $templates); //--- $t = array(); $i = 0; $t[$i]->options[] = (object) array('id' => 'vc_tab_general', 'type' => 'vc_tab', 'label' => __('General', 'rhc'), 'vc_tab' => true); $t[$i]->options[] = (object) array('id' => 'cal_template', 'type' => 'select', 'label' => __('Template', 'rhc'), 'options' => $templates); $t[$i]->options[] = (object) array('id' => 'cal_nav', 'label' => __('Navigation', 'rhc'), 'type' => 'onoff', 'default' => '0', 'description' => __('Display navigation controls.', 'rhc'), 'el_properties' => array(), 'save_option' => true, 'load_option' => true); $t[$i]->options[] = (object) array('id' => 'cal_number', 'type' => 'range', 'label' => '', 'vc_label' => __('Number of events', 'rhc'), 'vc_admin_label' => true, 'min' => 0, 'max' => 500, 'step' => 1, 'vc_default' => 20); $t[$i]->options[] = (object) array('id' => 'cal_order', 'type' => 'select', 'label' => __('Order', 'rhc'), 'options' => array('ASC' => __('Ascending', 'rhc'), 'DESC' => __('Descending', 'rhc'))); $t[$i]->options[] = (object) array('id' => 'cal_horizon', 'type' => 'select', 'label' => __('Remove event by', 'rhc'), 'options' => array('day' => __('Day', 'rhc'), 'hour' => __('Hour', 'rhc'), 'end' => __('By event end', 'rhc'))); $t[$i]->options[] = (object) array('id' => 'cal_no_events_message', 'type' => 'text', 'label' => __('No events message', 'rhc'), 'description' => __('Specify a text to show if there are no more events.', 'rhc')); $t[$i]->options[] = (object) array('id' => 'vc_tab_filter', 'type' => 'vc_tab', 'label' => __('Filter', 'rhc'), 'vc_tab' => true); $t[$i]->options[] = (object) array('id' => 'cal_current_post', 'name' => 'current_post', 'type' => 'checkbox', 'label' => __('Current event recurring instances', 'rhc'), 'vc_label' => __('Display recurring events.', 'rhc'), 'option_value' => '1', 'description' => __('Check this option to display recurring instances of the current post. Expected inside a loop (get_the_ID).', 'rhc')); $t[$i]->options[] = (object) array('id' => 'cal_post_id', 'type' => 'text', 'label' => __('Post ID', 'rhc'), 'description' => __('Specify a post ID if you want to show a list of recurring instances for that particular event. This is overwritten by the previous option.', 'rhc')); //----------- $post_types = $rhc_plugin->get_option('post_types', array()); $post_types = is_array($post_types) ? $post_types : array(); array_unshift($post_types, RHC_EVENTS); $post_types = apply_filters('rhc_calendar_metabox_post_types', $post_types); $j = 0; foreach ($post_types as $post_type) { $rhc_post_type_labels = array(RHC_EVENTS => __('Events', 'rhc')); $rhc_post_type_labels = apply_filters('rhc_post_type_labels', $rhc_post_type_labels); if ($pt = get_post_type_object($post_type)) { } else { //for some reason the events post type is not registered at this stage. $pt = (object) array('name' => $post_type, 'labels' => (object) array('name' => isset($rhc_post_type_labels[$post_type]) ? $rhc_post_type_labels[$post_type] : str_replace('_', ' ', ucfirst($post_type)))); } $tmp = (object) array('id' => 'cal_post_type_' . $pt->name, 'name' => 'cal_post_type[]', 'type' => 'checkbox', 'option_value' => $post_type, 'default' => '', 'label' => $pt->labels->name, 'el_properties' => array(), 'save_option' => true, 'load_option' => true, 'vc_label' => __('Post types')); if ($j == 0) { $tmp->description = __("Choose post types to include in the list.", 'rhc'); } $t[$i]->options[] = $tmp; $j++; } $t[$i]->options[] = (object) array('id' => 'cal_author_current', 'name' => 'author_current', 'type' => 'checkbox', 'label' => __('Display events authored by the user that is logged in.', 'rhc'), 'vc_label' => __('Logged user events', 'rhc'), 'option_value' => '1', 'description' => __('Check this option to display events from the logged in user.', 'rhc')); $t[$i]->options[] = (object) array('id' => 'cal_author', 'type' => 'text', 'label' => __('Author', 'rhc'), 'description' => __('Write an author user_login to display events from that author only', 'rhc')); $t[$i]->options[] = (object) array('id' => 'cal_auto', 'label' => __('Related events', 'rhc'), 'type' => 'onoff', 'default' => '0', 'description' => __('Choose yes to only show events with the same taxonomy and term as the loaded page. Used on venue template content.', 'rhc')); $default_taxonomies = array('' => __('--none--', 'rhc'), RHC_CALENDAR => __('Calendar', 'rhc'), RHC_ORGANIZER => __('Organizer', 'rhc'), RHC_VENUE => __('Venues', 'rhc')); $taxonomies = apply_filters('rhc-taxonomies', $default_taxonomies); foreach ($post_types as $post_type) { $tmp = get_object_taxonomies(array('post_type' => $post_type), 'objects'); if (is_array($tmp) && count($tmp) > 0) { foreach ($tmp as $taxonomy => $tax) { $taxonomies[$taxonomy] = $tax->labels->name; } } } $t[$i]->options[] = (object) array('id' => 'cal_taxonomy', 'type' => 'select', 'label' => __('Taxonomy', 'rhc'), 'options' => $taxonomies, 'description' => __('Choose a taxonomy and terms to filter events.', 'rhc')); if ('dropdown' == $rhc_plugin->get_option('vc_term_input', 'text', true)) { } else { $t[$i]->options[] = (object) array('id' => 'cal_terms', 'type' => 'text', 'label' => __('Terms', 'rhc'), 'description' => __('Comma separated term slug. (Not label)', 'rhc')); } $t[$i]->options[] = (object) array('id' => 'vc_tab_format', 'type' => 'vc_tab', 'label' => __('Format', 'rhc'), 'vc_tab' => true); $t[$i]->options[] = (object) array('id' => 'cal_date_format', 'type' => 'text', 'label' => __('Date format', 'rhc')); $t[$i]->options[] = (object) array('id' => 'cal_time_format', 'type' => 'text', 'label' => __('Time format', 'rhc')); $t[$i]->options[] = (object) array('id' => 'cal_premiere', 'label' => __('Premiere', 'rhc'), 'type' => 'onoff', 'default' => '0', 'description' => __('Choose yes to only show the first event in a recurring set.', 'rhc'), 'el_properties' => array(), 'save_option' => true, 'load_option' => true); $t[$i]->options[] = (object) array('id' => 'vc_tab_other', 'type' => 'vc_tab', 'label' => __('Other', 'rhc'), 'vc_tab' => true); $this->set_pop_conditional_options($t, $i); return $this->convert_rhc_options_to_vc_params($t); }
function form($instance) { $taxmap = array('venue' => RHC_VENUE, 'organizer' => RHC_ORGANIZER, 'calendar' => RHC_CALENDAR); foreach (array('taxonomy' => '', 'terms' => '', 'loading_method' => 'server', 'calendar_url' => '', 'auto' => 0, 'premiere' => 0, 'title' => '', 'horizon' => 'hour', 'number' => 5, 'showimage' => 0, 'words' => 10, 'dayspast' => '', 'fcdate_format' => 'MMM d, yyyy', 'fctime_format' => 'h:mmtt', 'specific_date' => '', 'specific_date_end' => '', 'author_name' => '') as $field => $default) { ${$field} = isset($instance[$field]) ? $instance[$field] : $default; } //--- global $rhc_plugin; $post_types = $rhc_plugin->get_option('post_types', array(), true); array_unshift($post_types, RHC_EVENTS); $checked = isset($instance['post_type']) && is_array($instance['post_type']) && count($instance['post_type']) > 0 ? $instance['post_type'] : array(RHC_EVENTS); //---- require_once RHC_PATH . 'includes/class.rh_templates.php'; $t = new rh_templates(array('template_directory' => $rhc_plugin->get_template_path())); $templates = $t->get_template_files('widget_upcoming_events'); $templates = is_array($templates) && count($templates) > 0 ? $templates : array('widget_upcoming_events.php'); $templates = apply_filters('rhc_uew_templates', $templates); $current_template = isset($instance['template']) ? $instance['template'] : 'widget_upcoming_events.php'; ?> <div> <div class="" style="margin-top:10px;"> <label><?php _e('Title', 'rhc'); ?> </label> <input type="text" id="<?php echo $this->get_field_id('title'); ?> " class="widefat" name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $title; ?> " /> </div> <div class="" style="margin-top:10px;"> <?php _e('Date format', 'rhc'); ?> <input type="text" class="widefat" value="<?php echo $fcdate_format; ?> " id="<?php echo $this->get_field_id('fcdate_format'); ?> " name="<?php echo $this->get_field_name('fcdate_format'); ?> " /> </div> <div class="" style="margin-top:10px;"> <?php _e('Time format', 'rhc'); ?> <input type="text" class="widefat" value="<?php echo $fctime_format; ?> " id="<?php echo $this->get_field_id('fctime_format'); ?> " name="<?php echo $this->get_field_name('fctime_format'); ?> " /> </div> <div class="" style="margin:10px 0 10px 0;"> <label><?php _e('Post type', 'rhc'); ?> </label> <div class="widefat" style="border:none;"> <?php foreach ($post_types as $post_type) { ?> <input type="checkbox" <?php echo in_array($post_type, $checked) ? 'checked="checked"' : ''; ?> name="<?php echo $this->get_field_name('post_type'); ?> []" value="<?php echo $post_type; ?> " /> <?php echo $post_type; ?> <br /> <?php } ?> </div> </div> <?php $this->form_author_name($author_name); ?> <div class="" style="margin:10px 0 10px 0;"> <?php _e('Template', 'rhc'); ?> <select id="<?php echo $this->get_field_id('template'); ?> " name="<?php echo $this->get_field_name('template'); ?> " class="widefat"> <?php foreach ($templates as $value => $label) { ?> <option <?php echo $current_template == $value ? 'selected="selected"' : ''; ?> value="<?php echo $value; ?> "><?php echo $label; ?> </option> <?php } ?> </select> </div> <label><?php _e('Event taxonomies:', 'rhc'); ?> </label> <?php foreach (array('calendar' => __('Calendar', 'rhc'), 'venue' => __('Venue', 'rhc'), 'organizer' => __('Organizer', 'rhc')) as $field => $label) { ${$field} = isset($instance[$field]) ? $instance[$field] : ''; ?> <div class="tax-events tax-field" style="margin-top:10px;"> <label for="<?php echo $field; ?> "><?php echo $label; ?> </label> <?php $this->taxonomy_dropdown($taxmap[$field], $this->get_field_id($field), $this->get_field_name($field), isset($instance[$field]) ? $instance[$field] : ''); ?> </div> <?php } ?> <div class="tax-custom tax-field" style="margin-top:10px;"> <label><?php _e('Custom taxonomies:', 'rhc'); ?> </label> <?php _e('Taxonomy', 'rhc'); ?> <input type="text" class="widefat" value="<?php echo $taxonomy; ?> " id="<?php echo $this->get_field_id('taxonomy'); ?> " name="<?php echo $this->get_field_name('taxonomy'); ?> " /> </div> <p style="margin-top:3px;"> <?php _e('*Overwrites event taxonomies filter.', 'rhc'); ?> </p> <div class="tax-custom tax-field" style="margin-top:10px;"> <?php _e('Terms', 'rhc'); ?> <input type="text" class="widefat" value="<?php echo $terms; ?> " id="<?php echo $this->get_field_id('terms'); ?> " name="<?php echo $this->get_field_name('terms'); ?> " /> </div> <div class="" style="margin-top:10px;"> <?php _e('Max number of posts', 'rhc'); ?> <input type="text" class="widefat" value="<?php echo $number; ?> " id="<?php echo $this->get_field_id('number'); ?> " name="<?php echo $this->get_field_name('number'); ?> " /> </div> <div class="" style="margin-top:10px;"> <?php _e('Max description word count', 'rhc'); ?> <input type="text" class="widefat" value="<?php echo $words; ?> " id="<?php echo $this->get_field_id('words'); ?> " name="<?php echo $this->get_field_name('words'); ?> " /> </div> <div class="" style="margin-top:10px;"> <?php _e('Remove event by', 'rhc'); ?> <select id="<?php echo $this->get_field_id('horizon'); ?> " name="<?php echo $this->get_field_name('horizon'); ?> " class="widefat"> <option value="hour" <?php echo $horizon == 'hour' ? 'selected="selected"' : ''; ?> ><?php _e('Hour', 'rhc'); ?> </option> <option value="end" <?php echo $horizon == 'end' ? 'selected="selected"' : ''; ?> ><?php _e('At event end', 'rhc'); ?> </option> <option value="day" <?php echo $horizon == 'day' ? 'selected="selected"' : ''; ?> ><?php _e('Day', 'rhc'); ?> </option> </select> </div> <div class="" style="margin-top:10px;"> <?php _e('Days in the past', 'rhc'); ?> <input type="text" class="widefat" value="<?php echo $dayspast; ?> " id="<?php echo $this->get_field_id('dayspast'); ?> " name="<?php echo $this->get_field_name('dayspast'); ?> " /> </div> <div class="" style="margin-top:10px;"> <?php _e('Show featured image', 'rhc'); ?> <select id="<?php echo $this->get_field_id('showimage'); ?> " name="<?php echo $this->get_field_name('showimage'); ?> " class="widefat"> <option value="0" <?php echo $showimage == '0' ? 'selected="selected"' : ''; ?> ><?php _e('No image', 'rhc'); ?> </option> <option value="1" <?php echo $showimage == '1' ? 'selected="selected"' : ''; ?> ><?php _e('Show image', 'rhc'); ?> </option> </select> </div> <div class="" style="margin-top:10px;"> <?php _e('Loading method', 'rhc'); ?> <select id="<?php echo $this->get_field_id('loading_method'); ?> " name="<?php echo $this->get_field_name('loading_method'); ?> " class="widefat"> <option value="server" <?php echo $loading_method == 'server' ? 'selected="selected"' : ''; ?> ><?php _e('Server side', 'rhc'); ?> </option> <option value="ajax" <?php echo $loading_method == 'ajax' ? 'selected="selected"' : ''; ?> ><?php _e('Ajax', 'rhc'); ?> </option> </select> </div> <div class="" style="margin-top:10px;"> <?php _e('Specific date (Y-m-d)', 'rhc'); ?> <input type="text" class="widefat rhc-date-picker" value="<?php echo $specific_date; ?> " id="<?php echo $this->get_field_id('specific_date'); ?> " name="<?php echo $this->get_field_name('specific_date'); ?> " /> </div> <div class="" style="margin-top:10px;"> <?php _e('Specific date End (Y-m-d)', 'rhc'); ?> <input type="text" class="widefat rhc-date-picker" value="<?php echo $specific_date_end; ?> " id="<?php echo $this->get_field_id('specific_date_end'); ?> " name="<?php echo $this->get_field_name('specific_date_end'); ?> " /> </div> <div class="" style="margin-top:10px;"> <input type="checkbox" id="<?php echo $this->get_field_id('auto'); ?> " name="<?php echo $this->get_field_name('auto'); ?> " <?php echo $auto == 1 ? 'checked="checked"' : ''; ?> value=1 /> *<?php _e('Only related events.', 'rhc'); ?> </div> <p style="margin-top:3px;">*<?php _e('If the loaded page is a calendar, venue or organizer (taxonomy), only show events from the same taxonomy.', 'rhc'); ?> </p> <div class="" style="margin-top:10px;"> <?php _e('Only premiere events.', 'rhc'); ?> <select id="<?php echo $this->get_field_id('premiere'); ?> " name="<?php echo $this->get_field_name('premiere'); ?> " class="widefat"> <option value="" <?php echo $premiere == '' ? 'selected="selected"' : ''; ?> ><?php _e('disabled', 'rhc'); ?> </option> <option value="1" <?php echo $premiere == '1' ? 'selected="selected"' : ''; ?> ><?php _e('Premiere date', 'rhc'); ?> </option> <option value="2" <?php echo $premiere == '2' ? 'selected="selected"' : ''; ?> ><?php _e('First date in range', 'rhc'); ?> </option> </select> </div> <p style="margin-top:3px;">*<?php _e('Premiere: The first event in a series.', 'rhc'); ?> </p> <p style="margin-top:3px;">*<?php _e('First date in range: Show only the first repetition of an event in the requested range', 'rhc'); ?> </p> <div class="" style="margin-top:10px;"> <?php _e('Calendar url(optional)', 'rhc'); ?> <input type="text" class="widefat" value="<?php echo $calendar_url; ?> " id="<?php echo $this->get_field_id('calendar_url'); ?> " name="<?php echo $this->get_field_name('calendar_url'); ?> " /> </div> <?php do_action('rhc_widget_upcoming_events_form', $this, $instance); ?> </div> <script>jQuery(document).ready(function($) {init_datepicker();});</script> <?php add_action('admin_footer', array(&$this, 'admin_footer')); add_action('customize_controls_print_footer_scripts', array(&$this, 'admin_footer')); }