/** * Output the metabox */ public static function output($post) { $taxonomies = get_object_taxonomies('sp_event'); $minutes = get_post_meta($post->ID, 'sp_minutes', true); ?> <?php do_action('sportspress_event_details_meta_box', $post); ?> <div class="sp-event-minutes-field"> <p><strong><?php _e('Full Time', 'sportspress'); ?> </strong></p> <p> <input name="sp_minutes" type="number" step="1" min="0" class="small-text" placeholder="<?php echo get_option('sportspress_event_minutes', 90); ?> " value="<?php echo esc_attr($minutes); ?> "> <?php _e('mins', 'sportspress'); ?> </p> </div> <?php foreach ($taxonomies as $taxonomy) { if ('sp_venue' == $taxonomy) { continue; } sp_taxonomy_field($taxonomy, $post, true, true); } ?> <div class="sp-event-sp_venue-field"> <p><strong><?php _e('Venue', 'sportspress'); ?> </strong></p> <p> <?php $terms = get_the_terms($post->ID, 'sp_venue'); $args = array('taxonomy' => 'sp_venue', 'name' => 'tax_input[sp_venue][]', 'class' => 'sp-has-dummy', 'selected' => sp_get_the_term_id_or_meta($post->ID, 'sp_venue'), 'values' => 'term_id', 'show_option_none' => __('— Not set —', 'sportspress'), 'chosen' => true); if (in_array('sp_venue', apply_filters('sportspress_event_auto_taxonomies', array('sp_venue')))) { $args['show_option_all'] = __('(Auto)', 'sportspress'); } if (!sp_dropdown_taxonomies($args)) { sp_taxonomy_adder('sp_venue', 'sp_event', __('Add New', 'sportspress')); } ?> </p> </div> <?php }
/** * Output the metabox */ public static function output($post) { $minutes = get_post_meta($post->ID, 'sp_minutes', true); $taxonomies = apply_filters('prosports_event_taxonomies', array('sp_league' => null, 'sp_season' => null, 'sp_venue' => 'sp_event')); ?> <div class="sp-event-minutes-field"> <p><strong><?php _e('Full Time', 'prosports'); ?> </strong></p> <p> <input name="sp_minutes" type="number" step="1" min="0" class="small-text" placeholder="<?php echo get_option('prosports_event_minutes', 90); ?> " value="<?php echo $minutes; ?> "> <?php _e('mins', 'prosports'); ?> </p> </div> <?php foreach ($taxonomies as $taxonomy => $post_type) { $obj = get_taxonomy($taxonomy); if ($obj) { ?> <div class="sp-event-<?php echo $taxonomy; ?> -field"> <p><strong><?php echo $obj->labels->singular_name; ?> </strong></p> <p> <?php $args = array('taxonomy' => $taxonomy, 'name' => $taxonomy, 'class' => 'sp-has-dummy', 'selected' => sp_get_the_term_id_or_meta($post->ID, $taxonomy), 'values' => 'term_id', 'show_option_none' => __('-- Not set --', 'prosports')); if (in_array($taxonomy, apply_filters('prosports_event_auto_taxonomies', array('sp_venue')))) { $args['show_option_all'] = __('(Auto)', 'prosports'); } if (!sp_dropdown_taxonomies($args)) { sp_taxonomy_adder($taxonomy, $post_type, $obj->labels->add_new_item); } ?> </p> </div> <?php } } }
/** * Output the metabox */ public static function output($post) { wp_nonce_field('prosports_save_data', 'prosports_meta_nonce'); $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0); $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0); ?> <div> <p><strong><?php _e('Competition', 'prosports'); ?> </strong></p> <p class="sp-tab-select"> <?php $args = array('taxonomy' => 'sp_league', 'name' => 'sp_league', 'show_option_all' => __('All', 'prosports'), '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('taxonomy' => 'sp_season', 'name' => 'sp_season', 'show_option_all' => __('All', 'prosports'), '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('Teams', 'prosports'); ?> </strong></p> <?php sp_post_checklist($post->ID, 'sp_team', 'block', array('sp_league', 'sp_season')); sp_post_adder('sp_team', __('Add New', 'prosports')); ?> </div> <?php }
/** * Output the details metabox */ public static function details($post) { wp_nonce_field('prosports_save_data', 'prosports_meta_nonce'); $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0); $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0); $rounds = get_post_meta($post->ID, 'sp_rounds', true); if ($rounds === '') { $rounds = 3; } $winner = get_post_meta($post->ID, 'sp_winner', true); ?> <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('Rounds', 'prosports'); ?> </strong></p> <p><input name="sp_rounds" type="number" min="1" max="6" value="<?php echo $rounds; ?> " placeholder="0" class="small-text sp-autosave"></p> <p><strong><?php _e('Winner', 'prosports'); ?> </strong></p> <p> <?php $args = array('show_option_none' => __('-- Not set --', 'prosports'), 'post_type' => 'sp_team', 'name' => 'sp_winner', 'selected' => $winner, 'values' => 'ID'); sp_dropdown_pages($args); ?> </p> </div> <?php }
function sp_taxonomy_field($taxonomy = 'category', $post = null, $multiple = false, $trigger = false) { $obj = get_taxonomy($taxonomy); if ($obj) { $post_type = get_post_type($post); ?> <div class="<?php echo $post_type; ?> -<?php echo $taxonomy; ?> -field"> <p><strong><?php echo $obj->labels->singular_name; ?> </strong></p> <p> <?php $terms = get_the_terms($post->ID, $taxonomy); $term_ids = array(); if ($terms) { foreach ($terms as $term) { $term_ids[] = $term->term_id; } } $args = array('taxonomy' => $taxonomy, 'name' => 'tax_input[' . $taxonomy . '][]', 'selected' => $term_ids, 'values' => 'term_id', 'class' => 'sp-has-dummy widefat' . ($trigger ? ' sp-ajax-trigger' : ''), 'chosen' => true, 'placeholder' => __('All', 'sportspress')); if ($multiple) { $args['property'] = 'multiple'; } if (!sp_dropdown_taxonomies($args)) { sp_taxonomy_adder($taxonomy, $post_type, $obj->labels->add_new_item); } ?> </p> </div> <?php } }
function prosports_taxonomy_adder($taxonomy = 'category', $post_type = 'post', $label = null) { return sp_taxonomy_adder($taxonomy, $post_type, $label); }
/** * 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 }
/** * options function. * * @access public * @return void */ function options() { ?> <table class="form-table"> <tbody> <tr> <th scope="row"><label><?php _e('Format', 'sportspress'); ?> </label><br/></th> <td class="forminp forminp-radio" id="sp_formatdiv"> <fieldset id="post-formats-select"> <ul> <li><input type="radio" name="sp_format" class="post-format" id="post-format-league" value="league" checked="checked"> <label for="post-format-league" class="post-format-icon post-format-league"><?php _e('Competitive', 'sportspress'); ?> </label></li> <li><input type="radio" name="sp_format" class="post-format" id="post-format-friendly" value="friendly"> <label for="post-format-friendly" class="post-format-icon post-format-friendly"><?php _e('Friendly', 'sportspress'); ?> </label></li> <br> </fieldset> </td> </tr> <tr> <th scope="row"><label><?php _e('Competition', 'sportspress'); ?> </label><br/></th> <td><?php $args = array('taxonomy' => 'sp_league', 'name' => 'sp_league', 'values' => 'slug', 'show_option_none' => __('— Not set —', 'sportspress')); if (!sp_dropdown_taxonomies($args)) { echo '<p>' . __('None', 'sportspress') . '</p>'; sp_taxonomy_adder('sp_league', 'sp_team', __('Add New', 'sportspress')); } ?> </td> </tr> <tr> <th scope="row"><label><?php _e('Season', 'sportspress'); ?> </label><br/></th> <td><?php $args = array('taxonomy' => 'sp_season', 'name' => 'sp_season', 'values' => 'slug', 'show_option_none' => __('— Not set —', 'sportspress')); if (!sp_dropdown_taxonomies($args)) { echo '<p>' . __('None', 'sportspress') . '</p>'; sp_taxonomy_adder('sp_season', 'sp_team', __('Add New', 'sportspress')); } ?> </td> </tr> <tr> <th scope="row" class="titledesc"> <?php _e('Date Format', 'sportspress'); ?> </th> <td class="forminp forminp-radio"> <fieldset> <ul> <li> <label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label> </li> <li> <label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label> </li> <li> <label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label> </li> </ul> </fieldset> </td> </tr> </tbody> </table> <?php }
/** * Output the metabox */ public static function output($post) { wp_nonce_field('prosports_save_data', 'prosports_meta_nonce'); $continents = SP()->countries->continents; $nationality = get_post_meta($post->ID, 'sp_nationality', true); $leagues = get_the_terms($post->ID, 'sp_league'); $league_ids = array(); if ($leagues) { foreach ($leagues as $league) { $league_ids[] = $league->term_id; } } $seasons = get_the_terms($post->ID, 'sp_season'); $season_ids = array(); if ($seasons) { foreach ($seasons as $season) { $season_ids[] = $season->term_id; } } $roles = get_the_terms($post->ID, 'sp_role'); if ($roles) { $term = array_shift($roles); $role = $term->term_id; } else { $role = null; } $teams = get_posts(array('post_type' => 'sp_team', 'posts_per_page' => -1)); $past_teams = array_filter(get_post_meta($post->ID, 'sp_past_team', false)); $current_teams = array_filter(get_post_meta($post->ID, 'sp_current_team', false)); ?> <p><strong><?php _e('Job', 'prosports'); ?> </strong></p> <p><?php $args = array('taxonomy' => 'sp_role', 'name' => 'sp_role', 'selected' => $role, 'values' => 'term_id', 'show_option_blank' => true, 'placeholder' => sprintf(__('Select %s', 'prosports'), __('Job', 'prosports')), 'class' => 'widefat', 'chosen' => true); if (!sp_dropdown_taxonomies($args)) { sp_taxonomy_adder('sp_role', 'sp_player', __('Add New', 'prosports')); } ?> </p> <p><strong><?php _e('Nationality', 'prosports'); ?> </strong></p> <p><select id="sp_nationality" name="sp_nationality" data-placeholder="<?php printf(__('Select %s', 'prosports'), __('Nationality', 'prosports')); ?> " class="widefat chosen-select<?php if (is_rtl()) { ?> chosen-rtl<?php } ?> "> <option value=""></option> <?php foreach ($continents as $continent => $countries) { ?> <optgroup label="<?php echo $continent; ?> "> <?php foreach ($countries as $code => $country) { ?> <option value="<?php echo $code; ?> " <?php selected($nationality, $code); ?> ><?php echo $country; ?> </option> <?php } ?> </optgroup> <?php } ?> </select></p> <p><strong><?php _e('Current Teams', 'prosports'); ?> </strong></p> <p><?php $args = array('post_type' => 'sp_team', 'name' => 'sp_current_team[]', 'selected' => $current_teams, 'values' => 'ID', 'placeholder' => sprintf(__('Select %s', 'prosports'), __('Teams', 'prosports')), 'class' => 'sp-current-teams widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_pages($args); ?> </p> <p><strong><?php _e('Past Teams', 'prosports'); ?> </strong></p> <p><?php $args = array('post_type' => 'sp_team', 'name' => 'sp_past_team[]', 'selected' => $past_teams, 'values' => 'ID', 'placeholder' => sprintf(__('Select %s', 'prosports'), __('Teams', 'prosports')), 'class' => 'sp-past-teams widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_pages($args); ?> </p> <p><strong><?php _e('Competitions', 'prosports'); ?> </strong></p> <p><?php $args = array('taxonomy' => 'sp_league', 'name' => 'tax_input[sp_league][]', 'selected' => $league_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'prosports'), __('Competitions', 'prosports')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_taxonomies($args); ?> </p> <p><strong><?php _e('Seasons', 'prosports'); ?> </strong></p> <p><?php $args = array('taxonomy' => 'sp_season', 'name' => 'tax_input[sp_season][]', 'selected' => $season_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'prosports'), __('Seasons', 'prosports')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_taxonomies($args); ?> </p> <?php }
/** * Output the details metabox */ public static function details($post) { $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0); $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0); $team_id = get_post_meta($post->ID, 'sp_team', true); ?> <div> <p><strong><?php _e('Competition', 'prosports'); ?> </strong></p> <p> <?php $args = array('taxonomy' => 'sp_league', 'name' => 'sp_league', 'show_option_all' => __('All', 'prosports'), '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('taxonomy' => 'sp_season', 'name' => 'sp_season', 'show_option_all' => __('All', 'prosports'), '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('Team', 'prosports'); ?> </strong></p> <p class="sp-tab-select"> <?php $args = array('post_type' => 'sp_team', 'name' => 'sp_team', 'show_option_all' => __('All', 'prosports'), 'selected' => $team_id, 'values' => 'ID'); if (!sp_dropdown_pages($args)) { sp_post_adder('sp_team', __('Add New', 'prosports')); } ?> </p> </div> <?php }
/** * Output the metabox */ public static function output($post) { $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0); $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0); $team_id = get_post_meta($post->ID, 'sp_team', true); $grouping = get_post_meta($post->ID, 'sp_grouping', true); $orderby = get_post_meta($post->ID, 'sp_orderby', true); $order = get_post_meta($post->ID, 'sp_order', true); ?> <div> <p><strong><?php _e('Competition', 'prosports'); ?> </strong></p> <p class="sp-tab-select"> <?php $args = array('taxonomy' => 'sp_league', 'name' => 'sp_league', 'show_option_all' => __('All', 'prosports'), '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('taxonomy' => 'sp_season', 'name' => 'sp_season', 'show_option_all' => __('All', 'prosports'), '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('Team', 'prosports'); ?> </strong></p> <p class="sp-tab-select"> <?php $args = array('post_type' => 'sp_team', 'name' => 'sp_team', 'show_option_all' => __('All', 'prosports'), 'selected' => $team_id, 'values' => 'ID'); if (!sp_dropdown_pages($args)) { sp_post_adder('sp_team', __('Add New', 'prosports')); } ?> </p> <p><strong><?php _e('Grouping', 'prosports'); ?> </strong></p> <p> <select name="sp_grouping"> <option value="0"><?php _e('None', 'prosports'); ?> </option> <option value="position" <?php selected($grouping, 'position'); ?> ><?php _e('Position', 'prosports'); ?> </option> </select> </p> <p><strong><?php _e('Sort by', 'prosports'); ?> </strong></p> <p> <?php $args = array('prepend_options' => array('number' => __('Number', 'prosports'), 'name' => __('Name', 'prosports')), 'post_type' => array('sp_performance', 'sp_metric', 'sp_statistic'), 'name' => 'sp_orderby', 'selected' => $orderby, 'values' => 'slug'); sp_dropdown_pages($args); ?> </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> <p><strong><?php _e('Players', 'prosports'); ?> </strong></p> <?php sp_post_checklist($post->ID, 'sp_player', 'block', array('sp_league', 'sp_season', 'sp_current_team')); sp_post_adder('sp_player', __('Add New', 'prosports')); ?> </div> <?php }