function form($instance) { $instance = wp_parse_args((array) $instance, array('title' => '', 'id' => null, 'caption' => '', 'status' => 'default', 'date' => 'default', 'date_from' => date_i18n('Y-m-d'), 'date_to' => date_i18n('Y-m-d'), 'day' => '', 'number' => 5, 'order' => 'default', 'show_all_events_link' => true)); $title = strip_tags($instance['title']); $id = intval($instance['id']); $caption = strip_tags($instance['caption']); $status = $instance['status']; $date = $instance['date']; $date_from = $instance['date_from']; $date_to = $instance['date_to']; $day = $instance['day']; $number = intval($instance['number']); $order = strip_tags($instance['order']); $show_all_events_link = $instance['show_all_events_link']; // Action to hook into do_action('sportspress_before_widget_template_form', $this, $instance, 'event-blocks'); ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'sportspress'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /></p> <p><label for="<?php echo $this->get_field_id('caption'); ?> "><?php _e('Heading:', 'sportspress'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('caption'); ?> " name="<?php echo $this->get_field_name('caption'); ?> " type="text" value="<?php echo esc_attr($caption); ?> " /></p> <p><label for="<?php echo $this->get_field_id('id'); ?> "><?php printf(__('Select %s:', 'sportspress'), __('Calendar', 'sportspress')); ?> </label> <?php $args = array('post_type' => 'sp_calendar', 'show_option_all' => __('All', 'sportspress'), 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'selected' => $id, 'values' => 'ID', 'class' => 'sp-event-calendar-select widefat'); if (!sp_dropdown_pages($args)) { sp_post_adder('sp_calendar', __('Add New', 'sportspress')); } ?> </p> <p><label for="<?php echo $this->get_field_id('status'); ?> "><?php _e('Status:', 'sportspress'); ?> </label> <?php $args = array('show_option_default' => __('Default', 'sportspress'), 'name' => $this->get_field_name('status'), 'id' => $this->get_field_id('status'), 'selected' => $status, 'class' => 'sp-event-status-select widefat'); sp_dropdown_statuses($args); ?> </p> <div class="sp-date-selector"> <p><label for="<?php echo $this->get_field_id('date'); ?> "><?php _e('Date:', 'sportspress'); ?> </label> <?php $args = array('show_option_default' => __('Default', 'sportspress'), 'name' => $this->get_field_name('date'), 'id' => $this->get_field_id('date'), 'selected' => $date, 'class' => 'sp-event-date-select widefat'); sp_dropdown_dates($args); ?> </p> <p class="sp-date-range<?php if ('range' !== $date) { ?> hidden<?php } ?> "> <input type="text" name="<?php echo $this->get_field_name('date_from'); ?> " value="<?php echo $date_from; ?> " placeholder="yyyy-mm-dd" size="10"> : <input type="text" name="<?php echo $this->get_field_name('date_to'); ?> " value="<?php echo $date_to; ?> " placeholder="yyyy-mm-dd" size="10"> </p> </div> <p><label for="<?php echo $this->get_field_id('day'); ?> "><?php _e('Match Day:', 'sportspress'); ?> </label> <input id="<?php echo $this->get_field_id('day'); ?> " name="<?php echo $this->get_field_name('day'); ?> " type="text" placeholder="<?php _e('All', 'sportspress'); ?> " value="<?php echo esc_attr($day); ?> " size="10"></p> <p><label for="<?php echo $this->get_field_id('number'); ?> "><?php _e('Number of events to show:', 'sportspress'); ?> </label> <input id="<?php echo $this->get_field_id('number'); ?> " name="<?php echo $this->get_field_name('number'); ?> " type="text" value="<?php echo esc_attr($number); ?> " size="3"></p> <p><label for="<?php echo $this->get_field_id('order'); ?> "><?php _e('Sort Order:', 'sportspress'); ?> </label> <select name="<?php echo $this->get_field_name('order'); ?> " id="<?php echo $this->get_field_id('order'); ?> " class="sp-select-order widefat"> <option value="default" <?php selected('default', $order); ?> ><?php _e('Default', 'sportspress'); ?> </option> <option value="ASC" <?php selected('ASC', $order); ?> ><?php _e('Ascending', 'sportspress'); ?> </option> <option value="DESC" <?php selected('DESC', $order); ?> ><?php _e('Descending', 'sportspress'); ?> </option> </select></p> <p class="sp-event-calendar-show-all-toggle<?php if (!$id) { ?> hidden<?php } ?> "><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?> " name="<?php echo $this->get_field_name('show_all_events_link'); ?> " value="1" <?php checked($show_all_events_link, 1); ?> > <label for="<?php echo $this->get_field_id('show_all_events_link'); ?> "><?php _e('Display link to view all events', 'sportspress'); ?> </label></p> <?php // Action to hook into do_action('sportspress_after_widget_template_form', $this, $instance, 'event-blocks'); }
function form($instance) { $instance = wp_parse_args((array) $instance, array('title' => '', 'id' => null, 'status' => 'default', 'date' => 'default', 'date_from' => date_i18n('Y-m-d'), 'date_to' => date_i18n('Y-m-d'), 'show_all_events_link' => false)); $title = strip_tags($instance['title']); $id = intval($instance['id']); $status = $instance['status']; $date = $instance['date']; $date_from = $instance['date_from']; $date_to = $instance['date_to']; $show_all_events_link = $instance['show_all_events_link']; // Action to hook into do_action('prosports_before_widget_template_form', $this, $instance, 'event-calendar'); ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'prosports'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /></p> <p><label for="<?php echo $this->get_field_id('id'); ?> "><?php printf(__('Select %s:', 'prosports'), __('Calendar', 'prosports')); ?> </label> <?php $args = array('post_type' => 'sp_calendar', 'show_option_all' => __('All', 'prosports'), 'name' => $this->get_field_name('id'), 'id' => $this->get_field_id('id'), 'selected' => $id, 'values' => 'ID', 'class' => 'sp-event-calendar-select widefat'); if (!sp_dropdown_pages($args)) { sp_post_adder('sp_calendar', __('Add New', 'prosports')); } ?> </p> <p><label for="<?php echo $this->get_field_id('status'); ?> "><?php _e('Status:', 'prosports'); ?> </label> <?php $args = array('show_option_default' => __('Default', 'prosports'), 'name' => $this->get_field_name('status'), 'id' => $this->get_field_id('status'), 'selected' => $status, 'class' => 'sp-event-status-select widefat'); sp_dropdown_statuses($args); ?> </p> <div class="sp-date-selector sp-event-calendar-show-all-toggle<?php if (!$id) { ?> hidden<?php } ?> "> <p><label for="<?php echo $this->get_field_id('date'); ?> "><?php _e('Date:', 'prosports'); ?> </label> <?php $args = array('show_option_default' => __('Default', 'prosports'), 'name' => $this->get_field_name('date'), 'id' => $this->get_field_id('date'), 'selected' => $date, 'class' => 'sp-event-date-select widefat'); sp_dropdown_dates($args); ?> </p> <p class="sp-date-range<?php if ('range' !== $date) { ?> hidden<?php } ?> "> <input type="text" name="<?php echo $this->get_field_name('date_from'); ?> " value="<?php echo $date_from; ?> " placeholder="yyyy-mm-dd" size="10"> : <input type="text" name="<?php echo $this->get_field_name('date_to'); ?> " value="<?php echo $date_to; ?> " placeholder="yyyy-mm-dd" size="10"> </p> </div> <p class="sp-event-calendar-show-all-toggle<?php if (!$id) { ?> hidden<?php } ?> "><input class="checkbox" type="checkbox" id="<?php echo $this->get_field_id('show_all_events_link'); ?> " name="<?php echo $this->get_field_name('show_all_events_link'); ?> " value="1" <?php checked($show_all_events_link, 1); ?> > <label for="<?php echo $this->get_field_id('show_all_events_link'); ?> "><?php _e('Display link to view all events', 'prosports'); ?> </label></p> <?php // Action to hook into do_action('prosports_after_widget_template_form', $this, $instance, 'event-calendar'); }
/** * Output the metabox */ public static function output($post) { $status = get_post_meta($post->ID, 'sp_status', true); $date = get_post_meta($post->ID, 'sp_date', true); $date_from = get_post_meta($post->ID, 'sp_date_from', true); $date_to = get_post_meta($post->ID, 'sp_date_to', true); $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0); $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0); $venue_id = sp_get_the_term_id($post->ID, 'sp_venue', 0); $team_id = get_post_meta($post->ID, 'sp_team', true); $order = get_post_meta($post->ID, 'sp_order', true); ?> <div> <p><strong><?php _e('Status', 'prosports'); ?> </strong></p> <p> <?php $args = array('name' => 'sp_status', 'id' => 'sp_status', 'selected' => $status); sp_dropdown_statuses($args); ?> </p> <div class="sp-date-selector"> <p><strong><?php _e('Date', 'prosports'); ?> </strong></p> <p> <?php $args = array('name' => 'sp_date', 'id' => 'sp_date', 'selected' => $date); sp_dropdown_dates($args); ?> </p> <p class="sp-date-range"> <input type="text" class="sp-datepicker-from" name="sp_date_from" value="<?php echo $date_from ? $date_from : date_i18n('Y-m-d'); ?> " size="10"> : <input type="text" class="sp-datepicker-to" name="sp_date_to" value="<?php echo $date_to ? $date_to : date_i18n('Y-m-d'); ?> " size="10"> </p> </div> <p><strong><?php _e('Competition', 'prosports'); ?> </strong></p> <p> <?php $args = array('show_option_all' => __('All', 'prosports'), 'taxonomy' => 'sp_league', 'name' => 'sp_league', 'selected' => $league_id, 'values' => 'term_id'); if (!sp_dropdown_taxonomies($args)) { sp_taxonomy_adder('sp_league', 'sp_team', __('Add New', 'prosports')); } ?> </p> <p><strong><?php _e('Season', 'prosports'); ?> </strong></p> <p class="sp-tab-select"> <?php $args = array('show_option_all' => __('All', 'prosports'), 'taxonomy' => 'sp_season', 'name' => 'sp_season', 'selected' => $season_id, 'values' => 'term_id'); if (!sp_dropdown_taxonomies($args)) { sp_taxonomy_adder('sp_season', 'sp_team', __('Add New', 'prosports')); } ?> </p> <p><strong><?php _e('Venue', 'prosports'); ?> </strong></p> <p> <?php $args = array('show_option_all' => __('All', 'prosports'), 'taxonomy' => 'sp_venue', 'name' => 'sp_venue', 'selected' => $venue_id, 'values' => 'term_id'); if (!sp_dropdown_taxonomies($args)) { sp_taxonomy_adder('sp_season', 'sp_team', __('Add New', 'prosports')); } ?> </p> <p><strong><?php _e('Team', 'prosports'); ?> </strong></p> <p> <?php $args = array('show_option_all' => __('All', 'prosports'), 'post_type' => 'sp_team', 'name' => 'sp_team', 'selected' => $team_id, 'values' => 'ID'); if (!sp_dropdown_pages($args)) { sp_post_adder('sp_team', __('Add New', 'prosports')); } ?> </p> <p><strong><?php _e('Sort Order', 'prosports'); ?> </strong></p> <p> <select name="sp_order"> <option value="ASC" <?php selected('ASC', $order); ?> ><?php _e('Ascending', 'prosports'); ?> </option> <option value="DESC" <?php selected('DESC', $order); ?> ><?php _e('Descending', 'prosports'); ?> </option> </select> </p> </div> <?php }
/** * Output the metabox */ public static function output($post) { $taxonomies = get_object_taxonomies('sp_calendar'); $caption = get_post_meta($post->ID, 'sp_caption', true); $status = get_post_meta($post->ID, 'sp_status', true); $date = get_post_meta($post->ID, 'sp_date', true); $date_from = get_post_meta($post->ID, 'sp_date_from', true); $date_to = get_post_meta($post->ID, 'sp_date_to', true); $day = get_post_meta($post->ID, 'sp_day', true); $teams = get_post_meta($post->ID, 'sp_team', false); $table_id = get_post_meta($post->ID, 'sp_table', true); $orderby = get_post_meta($post->ID, 'sp_orderby', true); $order = get_post_meta($post->ID, 'sp_order', true); ?> <div> <p><strong><?php _e('Heading', 'sportspress'); ?> </strong></p> <p><input type="text" id="sp_caption" name="sp_caption" value="<?php echo esc_attr($caption); ?> " placeholder="<?php echo esc_attr(get_the_title()); ?> "></p> <p><strong><?php _e('Status', 'sportspress'); ?> </strong></p> <p> <?php $args = array('name' => 'sp_status', 'id' => 'sp_status', 'selected' => $status); sp_dropdown_statuses($args); ?> </p> <div class="sp-date-selector"> <p><strong><?php _e('Date', 'sportspress'); ?> </strong></p> <p> <?php $args = array('name' => 'sp_date', 'id' => 'sp_date', 'selected' => $date); sp_dropdown_dates($args); ?> </p> <p class="sp-date-range"> <input type="text" class="sp-datepicker-from" name="sp_date_from" value="<?php echo $date_from ? $date_from : date_i18n('Y-m-d'); ?> " size="10"> : <input type="text" class="sp-datepicker-to" name="sp_date_to" value="<?php echo $date_to ? $date_to : date_i18n('Y-m-d'); ?> " size="10"> </p> </div> <div class="sp-event-day-field"> <p><strong><?php _e('Match Day', 'sportspress'); ?> </strong></p> <p> <input name="sp_day" type="text" class="medium-text" placeholder="<?php _e('All', 'sportspress'); ?> " value="<?php echo esc_attr($day); ?> "> </p> </div> <?php foreach ($taxonomies as $taxonomy) { sp_taxonomy_field($taxonomy, $post, true); } ?> <p><strong><?php _e('Team', 'sportspress'); ?> </strong></p> <p> <?php $args = array('post_type' => 'sp_team', 'name' => 'sp_team[]', 'selected' => $teams, 'values' => 'ID', 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true, 'placeholder' => __('All', 'sportspress')); if (!sp_dropdown_pages($args)) { sp_post_adder('sp_team', __('Add New', 'sportspress')); } ?> </p> <p><strong><?php _e('Sort by', 'sportspress'); ?> </strong></p> <p> <select name="sp_orderby"> <option value="date" <?php selected('date', $orderby); ?> ><?php _e('Date', 'sportspress'); ?> </option> <option value="day" <?php selected('day', $orderby); ?> ><?php _e('Match Day', 'sportspress'); ?> </option> </select> </p> <p><strong><?php _e('Sort Order', 'sportspress'); ?> </strong></p> <p> <select name="sp_order"> <option value="ASC" <?php selected('ASC', $order); ?> ><?php _e('Ascending', 'sportspress'); ?> </option> <option value="DESC" <?php selected('DESC', $order); ?> ><?php _e('Descending', 'sportspress'); ?> </option> </select> </p> </div> <?php }