/** * 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 } } }
/** * Show a category filter box */ public function filters() { global $typenow, $wp_query; if ($typenow != 'sp_table') { return; } $selected = isset($_REQUEST['sp_league']) ? $_REQUEST['sp_league'] : null; $args = array('show_option_all' => __('Show all competitions', 'sportspress'), 'taxonomy' => 'sp_league', 'name' => 'sp_league', 'selected' => $selected); sp_dropdown_taxonomies($args); $selected = isset($_REQUEST['sp_season']) ? $_REQUEST['sp_season'] : null; $args = array('show_option_all' => __('Show all seasons', 'sportspress'), 'taxonomy' => 'sp_season', 'name' => 'sp_season', 'selected' => $selected); sp_dropdown_taxonomies($args); $selected = isset($_REQUEST['team']) ? $_REQUEST['team'] : null; $args = array('post_type' => 'sp_team', 'name' => 'team', 'show_option_none' => __('Show all teams', 'sportspress'), 'selected' => $selected, 'values' => 'ID'); wp_dropdown_pages($args); }
/** * Output the metabox */ public static function output($post) { $limit = get_option('prosports_event_teams', 2); $teams = (array) get_post_meta($post->ID, 'sp_team', false); $league_id = sp_get_the_term_id($post->ID, 'sp_league', 0); $season_id = sp_get_the_term_id($post->ID, 'sp_season', 0); for ($i = 0; $i < $limit; $i++) { $team = array_shift($teams); ?> <div class="sp-instance"> <p class="sp-tab-select sp-tab-select-dummy"> <?php $args = array('taxonomy' => 'sp_league', 'name' => 'sp_league_dummy', 'class' => 'sp-dummy sp_league-dummy', 'show_option_all' => __('All', 'prosports'), 'selected' => $league_id, 'values' => 'term_id'); sp_dropdown_taxonomies($args); ?> </p> <p class="sp-tab-select sp-tab-select-dummy"> <?php $args = array('taxonomy' => 'sp_season', 'name' => 'sp_season_dummy', 'class' => 'sp-dummy sp_season-dummy', 'show_option_all' => __('All', 'prosports'), 'selected' => $season_id, 'values' => 'term_id'); sp_dropdown_taxonomies($args); ?> </p> <p class="sp-tab-select sp-title-generator"> <?php $args = array('post_type' => 'sp_team', 'name' => 'sp_team[]', 'class' => 'prosports-pages', 'show_option_none' => __('— None —', 'prosports'), 'show_option_all' => __('— Individual —', 'prosports'), 'values' => 'ID', 'selected' => $team); sp_dropdown_pages($args); ?> </p> <ul id="sp_team-tabs" class="wp-tab-bar sp-tab-bar"> <li class="wp-tab-active"><a href="#sp_player-all"><?php _e('Players', 'prosports'); ?> </a></li> <li class="wp-tab"><a href="#sp_staff-all"><?php _e('Staff', 'prosports'); ?> </a></li> </ul> <?php sp_post_checklist($post->ID, 'sp_player', 'block', array('sp_league', 'sp_season', 'sp_current_team'), $i); sp_post_checklist($post->ID, 'sp_staff', 'none', array('sp_league', 'sp_season', 'sp_current_team'), $i); ?> </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 }
/** * 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 }
/** * Admin edit table */ public static function table($columns = array(), $data = array(), $placeholders = array(), $adjustments = array(), $orderby = 'number') { $show_player_photo = get_option('sportspress_list_show_photos', 'no') == 'yes' ? true : false; ?> <ul class="subsubsub sp-table-bar"> <li><a href="#sp-table-values" class="current"><?php _e('Values', 'sportspress'); ?> </a></li> | <li><a href="#sp-table-adjustments" class=""><?php _e('Adjustments', 'sportspress'); ?> </a></li> </ul> <div class="sp-data-table-container sp-table-panel sp-table-values" id="sp-table-values"> <table class="widefat sp-data-table sp-player-list-table"> <thead> <tr> <?php if (array_key_exists('number', $columns)) { ?> <th><?php echo in_array($orderby, array('number', 'name')) ? '#' : __('Rank', 'sportspress'); ?> </th> <?php } ?> <th><?php _e('Player', 'sportspress'); ?> </th> <?php if (array_key_exists('team', $columns) && apply_filters('sportspress_has_teams', true)) { ?> <th><?php _e('Team', 'sportspress'); ?> </th> <?php } ?> <?php if (array_key_exists('position', $columns)) { ?> <th><?php _e('Position', 'sportspress'); ?> </th> <?php } ?> <?php foreach ($columns as $key => $label) { ?> <?php if (in_array($key, array('number', 'team', 'position'))) { continue; } ?> <th><label for="sp_columns_<?php echo $key; ?> "> <?php echo $label; ?> </label></th> <?php } ?> </tr> </thead> <tbody> <?php if (is_array($data) && sizeof($data) > 0) { $i = 0; foreach ($data as $player_id => $player_stats) { if (!$player_id) { continue; } $teams = get_post_meta($player_id, 'sp_team', false); $div = get_term($player_id, 'sp_season'); $number = get_post_meta($player_id, 'sp_number', true); $default_name = sp_array_value($player_stats, 'name', ''); if ($default_name == null) { $default_name = get_the_title($player_id); } ?> <tr class="sp-row sp-post<?php if ($i % 2 == 0) { echo ' alternate'; } ?> "> <?php if (array_key_exists('number', $columns)) { ?> <td> <?php if ('number' == $orderby) { echo $number ? $number : ' '; } else { echo $i + 1; } ?> </td> <?php } ?> <td> <?php if ($show_player_photo) { echo get_the_post_thumbnail($player_id, 'sportspress-fit-mini'); } ?> <span class="sp-default-value"> <span class="sp-default-value-input"><?php echo $default_name; ?> </span> <a class="dashicons dashicons-edit sp-edit" title="<?php _e('Edit', 'sportspress'); ?> "></a> </span> <span class="hidden sp-custom-value"> <input type="text" name="sp_players[<?php echo $player_id; ?> ][name]" class="name sp-custom-value-input" value="<?php echo esc_attr(sp_array_value($player_stats, 'name', '')); ?> " placeholder="<?php echo esc_attr(get_the_title($player_id)); ?> " size="6"> <a class="button button-secondary sp-cancel"><?php _e('Cancel', 'sportspress'); ?> </a> <a class="button button-primary sp-save"><?php _e('Save', 'sportspress'); ?> </a> </span> </td> <?php if (array_key_exists('team', $columns) && apply_filters('sportspress_has_teams', true)) { ?> <td> <?php $selected = sp_array_value($player_stats, 'team', get_post_meta(get_the_ID(), 'sp_team', true)); if (!$selected) { $selected = get_post_meta($player_id, 'sp_team', true); } $include = get_post_meta($player_id, 'sp_team'); $args = array('post_type' => 'sp_team', 'name' => 'sp_players[' . $player_id . '][team]', 'include' => $include, 'selected' => $selected, 'values' => 'ID'); wp_dropdown_pages($args); ?> </td> <?php } ?> <?php if (array_key_exists('position', $columns)) { ?> <td> <?php $selected = sp_array_value($player_stats, 'position', null); $args = array('taxonomy' => 'sp_position', 'name' => 'sp_players[' . $player_id . '][position]', 'show_option_blank' => __('(Auto)', 'sportspress'), 'values' => 'term_id', 'orderby' => 'slug', 'selected' => $selected, 'include_children' => 'no' == get_option('sportspress_event_hide_child_positions', 'no')); sp_dropdown_taxonomies($args); ?> </td> <?php } ?> <?php foreach ($columns as $column => $label) { if (in_array($column, array('number', 'team', 'position'))) { continue; } $value = sp_array_value($player_stats, $column, ''); $placeholder = sp_array_value(sp_array_value($placeholders, $player_id, array()), $column, 0); ?> <td><input type="text" name="sp_players[<?php echo $player_id; ?> ][<?php echo $column; ?> ]" value="<?php echo esc_attr($value); ?> " placeholder="<?php echo esc_attr($placeholder); ?> " data-placeholder="<?php echo esc_attr($placeholder); ?> " data-matrix="<?php echo $player_id; ?> _<?php echo $column; ?> " data-adjustment="<?php echo sp_array_value(sp_array_value($adjustments, $player_id, array()), $column, 0); ?> " /></td> <?php } ?> </tr> <?php $i++; } } else { ?> <tr class="sp-row alternate"> <td colspan="<?php $colspan = sizeof($columns) + (apply_filters('sportspress_has_teams', true) ? 3 : 2); echo $colspan; ?> "> <?php printf(__('Select %s', 'sportspress'), __('Data', 'sportspress')); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <div class="sp-data-table-container sp-table-panel sp-table-adjustments hidden" id="sp-table-adjustments"> <table class="widefat sp-data-table sp-player-list-table"> <thead> <tr> <th>#</th> <th><?php _e('Player', 'sportspress'); ?> </th> <?php foreach ($columns as $key => $label) { if (in_array($key, array('number', 'team', 'position'))) { continue; } ?> <th><?php echo $label; ?> </th> <?php } ?> </tr> </thead> <tbody> <?php if (is_array($data) && sizeof($data) > 0) { $i = 0; foreach ($data as $player_id => $player_stats) { if (!$player_id) { continue; } $div = get_term($player_id, 'sp_season'); $number = get_post_meta($player_id, 'sp_number', true); ?> <tr class="sp-row sp-post<?php if ($i % 2 == 0) { echo ' alternate'; } ?> "> <td><?php echo $number ? $number : ' '; ?> </td> <td> <?php echo get_the_title($player_id); ?> </td> <?php foreach ($columns as $column => $label) { if (in_array($column, array('number', 'team', 'position'))) { continue; } $value = sp_array_value(sp_array_value($adjustments, $player_id, array()), $column, ''); ?> <td><input type="text" name="sp_adjustments[<?php echo $player_id; ?> ][<?php echo $column; ?> ]" value="<?php echo esc_attr($value); ?> " placeholder="0" data-matrix="<?php echo $player_id; ?> _<?php echo $column; ?> " /></td> <?php } ?> </tr> <?php $i++; } } else { ?> <tr class="sp-row alternate"> <td colspan="<?php $colspan = sizeof($columns) + 3; echo $colspan; ?> "> <?php printf(__('Select %s', 'sportspress'), __('Details', 'sportspress')); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php }
/** * AJAX event_blocks shortcode */ public function event_blocks_shortcode() { ?> <div class="wrap sp-thickbox-content" id="sp-thickbox-event_blocks"> <p> <label> <?php _e('Title:', 'sportspress'); ?> <input class="regular-text" type="text" name="title"> </label> </p> <p> <label> <?php printf(__('Select %s:', 'sportspress'), __('Calendar', 'sportspress')); ?> <?php $args = array('post_type' => 'sp_calendar', 'show_option_all' => __('All', 'sportspress'), 'name' => 'id', 'values' => 'ID'); sp_dropdown_pages($args); ?> </label> </p> <p> <label> <?php _e('Team:', 'sportspress'); ?> <?php $args = array('post_type' => 'sp_team', 'show_option_all' => __('Default', 'sportspress'), 'name' => 'team', 'values' => 'ID'); sp_dropdown_pages($args); ?> </label> </p> <p> <label> <?php _e('Competition:', 'sportspress'); ?> <?php $args = array('taxonomy' => 'sp_league', 'show_option_all' => __('Default', 'sportspress'), 'name' => 'league', 'values' => 'term_id'); sp_dropdown_taxonomies($args); ?> </label> </p> <p> <label> <?php _e('Season:', 'sportspress'); ?> <?php $args = array('taxonomy' => 'sp_season', 'show_option_all' => __('Default', 'sportspress'), 'name' => 'season', 'values' => 'term_id'); sp_dropdown_taxonomies($args); ?> </label> </p> <p> <label> <?php _e('Venue:', 'sportspress'); ?> <?php $args = array('taxonomy' => 'sp_venue', 'show_option_all' => __('Default', 'sportspress'), 'name' => 'venue', 'values' => 'term_id'); sp_dropdown_taxonomies($args); ?> </label> </p> <p> <label> <?php _e('Status:', 'sportspress'); ?> <?php $args = array('name' => 'status', 'show_option_default' => __('Default', 'sportspress')); sp_dropdown_statuses($args); ?> </label> </p> <p> <label> <?php _e('Date:', 'sportspress'); ?> <select id="date" name="date"> <option value="default"><?php _e('Default', 'sportspress'); ?> </option> <option value=""><?php _e('All', 'sportspress'); ?> </option> <option value="w"><?php _e('This week', 'sportspress'); ?> </option> <option value="day"><?php _e('Today', 'sportspress'); ?> </option> </select> </label> </p> <p> <label> <?php _e('Match Day:', 'sportspress'); ?> <input type="text" size="3" name="day" id="day" placeholder="<?php _e('All', 'sportspress'); ?> "> </label> </p> <p> <label> <?php _e('Number of events to show:', 'sportspress'); ?> <input type="text" size="3" name="number" id="number" value="5"> </label> </p> <p> <label> <?php _e('Sort by:', 'sportspress'); ?> <select id="orderby" name="orderby"> <option value="default"><?php _e('Default', 'sportspress'); ?> </option> <option value="date"><?php _e('Date', 'sportspress'); ?> </option> <option value="day"><?php _e('Match Day', 'sportspress'); ?> </option> </select> </label> </p> <p> <label> <?php _e('Sort Order:', 'sportspress'); ?> <select id="order" name="order"> <option value="default"><?php _e('Default', 'sportspress'); ?> </option> <option value="ASC"><?php _e('Ascending', 'sportspress'); ?> </option> <option value="DESC"><?php _e('Descending', 'sportspress'); ?> </option> </select> </label> </p> <p> <label> <input type="checkbox" name="show_all_events_link" id="show_all_events_link"> <?php _e('Display link to view all events', 'sportspress'); ?> </label> </p> <?php do_action('sportspress_ajax_shortcode_form', 'event-blocks'); ?> <p class="submit"> <input type="button" class="button-primary" value="<?php _e('Insert Shortcode', 'sportspress'); ?> " onclick="insertSportsPress('event_blocks');" /> <a class="button-secondary" onclick="tb_remove();" title="<?php _e('Cancel', 'sportspress'); ?> "><?php _e('Cancel', 'sportspress'); ?> </a> </p> </div> <?php self::scripts(); die; }
/** * Show a category filter box */ public function filters() { global $typenow, $wp_query; if ($typenow != 'sp_event') { return; } $selected = isset($_REQUEST['team']) ? $_REQUEST['team'] : null; $args = array('post_type' => 'sp_team', 'name' => 'team', 'show_option_none' => __('Show all teams', 'sportspress'), 'selected' => $selected, 'values' => 'ID'); wp_dropdown_pages($args); $selected = isset($_REQUEST['sp_league']) ? $_REQUEST['sp_league'] : null; $args = array('show_option_all' => __('Show all competitions', 'sportspress'), 'taxonomy' => 'sp_league', 'name' => 'sp_league', 'selected' => $selected); sp_dropdown_taxonomies($args); $selected = isset($_REQUEST['sp_season']) ? $_REQUEST['sp_season'] : null; $args = array('show_option_all' => __('Show all seasons', 'sportspress'), 'taxonomy' => 'sp_season', 'name' => 'sp_season', 'selected' => $selected); sp_dropdown_taxonomies($args); if (current_user_can('edit_others_sp_events')) { wp_nonce_field('sp-save-inline-results', 'sp-inline-nonce', false); } }
/** * Output the metabox */ public static function output($post) { wp_nonce_field('sportspress_save_data', 'sportspress_meta_nonce'); $continents = SP()->countries->continents; $number = get_post_meta($post->ID, 'sp_number', true); $nationality = get_post_meta($post->ID, 'sp_nationality', true); if (2 == strlen($nationality)) { $legacy = SP()->countries->legacy; $nationality = strtolower($nationality); $nationality = sp_array_value($legacy, $nationality, null); } $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; } } $positions = get_the_terms($post->ID, 'sp_position'); $position_ids = array(); if ($positions) { foreach ($positions as $position) { $position_ids[] = $position->term_id; } } $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('Squad Number', 'sportspress'); ?> </strong></p> <p><input type="text" size="4" id="sp_number" name="sp_number" value="<?php echo $number; ?> "></p> <p><strong><?php _e('Nationality', 'sportspress'); ?> </strong></p> <p><select id="sp_nationality" name="sp_nationality" data-placeholder="<?php printf(__('Select %s', 'sportspress'), __('Nationality', 'sportspress')); ?> " 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('Positions', 'sportspress'); ?> </strong></p> <p><?php $args = array('taxonomy' => 'sp_position', 'name' => 'tax_input[sp_position][]', 'selected' => $position_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Positions', 'sportspress')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_taxonomies($args); ?> </p> <?php if (apply_filters('sportspress_player_teams', true)) { ?> <p><strong><?php _e('Current Teams', 'sportspress'); ?> </strong></p> <p><?php $args = array('post_type' => 'sp_team', 'name' => 'sp_current_team[]', 'selected' => $current_teams, 'values' => 'ID', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Teams', 'sportspress')), 'class' => 'sp-current-teams widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_pages($args); ?> </p> <p><strong><?php _e('Past Teams', 'sportspress'); ?> </strong></p> <p><?php $args = array('post_type' => 'sp_team', 'name' => 'sp_past_team[]', 'selected' => $past_teams, 'values' => 'ID', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Teams', 'sportspress')), 'class' => 'sp-past-teams widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_pages($args); ?> </p> <?php } ?> <p><strong><?php _e('Competitions', 'sportspress'); ?> </strong></p> <p><?php $args = array('taxonomy' => 'sp_league', 'name' => 'tax_input[sp_league][]', 'selected' => $league_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Competitions', 'sportspress')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_taxonomies($args); ?> </p> <p><strong><?php _e('Seasons', 'sportspress'); ?> </strong></p> <p><?php $args = array('taxonomy' => 'sp_season', 'name' => 'tax_input[sp_season][]', 'selected' => $season_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Seasons', 'sportspress')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_taxonomies($args); ?> </p> <?php }
/** * Show a category filter box */ public function filters() { global $typenow, $wp_query; if ($typenow != 'sp_team') { return; } $selected = isset($_REQUEST['sp_league']) ? $_REQUEST['sp_league'] : null; $args = array('show_option_all' => __('Show all competitions', 'prosports'), 'taxonomy' => 'sp_league', 'name' => 'sp_league', 'selected' => $selected); sp_dropdown_taxonomies($args); $selected = isset($_REQUEST['sp_season']) ? $_REQUEST['sp_season'] : null; $args = array('show_option_all' => __('Show all seasons', 'prosports'), 'taxonomy' => 'sp_season', 'name' => 'sp_season', 'selected' => $selected); sp_dropdown_taxonomies($args); }
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 } }
/** * 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 }
/** * Admin edit table */ public static function table($labels = array(), $columns = array(), $data = array(), $team_id, $has_checkboxes = false) { ?> <div class="sp-data-table-container"> <table class="widefat sp-data-table sp-performance-table sp-sortable-table"> <thead> <tr> <th class="icon"> </th> <th>#</th> <th><?php _e('Player', 'prosports'); ?> </th> <th> <?php if ($has_checkboxes) { ?> <label for="sp_columns_position"> <input type="checkbox" name="sp_columns[]" value="position" id="sp_columns_position" <?php checked(!is_array($columns) || in_array('position', $columns)); ?> > <?php _e('Position', 'prosports'); ?> </label> <?php } else { ?> <?php _e('Position', 'prosports'); ?> <?php } ?> </th> <?php foreach ($labels as $key => $label) { ?> <th> <?php if ($has_checkboxes) { ?> <label for="sp_columns_<?php echo $key; ?> "> <input type="checkbox" name="sp_columns[]" value="<?php echo $key; ?> " id="sp_columns_<?php echo $key; ?> " <?php checked(!is_array($columns) || in_array($key, $columns)); ?> > <?php echo $label; ?> </label> <?php } else { ?> <?php echo $label; ?> <?php } ?> </th> <?php } ?> <?php if ($team_id) { ?> <th> <?php _e('Status', 'prosports'); ?> </th> <?php } else { ?> <th> <?php _e('Outcome', 'prosports'); ?> </th> <?php } ?> </tr> </thead> <tfoot> <tr class="sp-row sp-total"> <td> </td> <td> </td> <td><strong><?php _e('Total', 'prosports'); ?> </strong></td> <td> </td> <?php foreach ($labels as $column => $label) { $player_id = 0; $player_performance = sp_array_value($data, 0, array()); $value = sp_array_value($player_performance, $column, ''); ?> <td><input type="text" name="sp_players[<?php echo $team_id; ?> ][<?php echo $player_id; ?> ][<?php echo $column; ?> ]" value="<?php echo $value; ?> " placeholder="0" /></td> <?php } ?> <td> </td> </tr> </tfoot> <tbody> <?php foreach ($data as $player_id => $player_performance) { if (!$player_id) { continue; } $number = get_post_meta($player_id, 'sp_number', true); $value = sp_array_value($player_performance, 'number', ''); ?> <tr class="sp-row sp-post" data-player="<?php echo $player_id; ?> "> <td class="icon"><span class="dashicons dashicons-menu post-state-format"></span></td> <td> <input class="small-text sp-player-number-input" type="text" name="sp_players[<?php echo $team_id; ?> ][<?php echo $player_id; ?> ][number]" value="<?php echo $value; ?> " /> </td> <td><?php echo get_the_title($player_id); ?> </td> <td> <?php $selected = sp_array_value($player_performance, 'position', null); if ($selected == null) { $selected = sp_get_the_term_id($player_id, 'sp_position', 0); } $args = array('taxonomy' => 'sp_position', 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position]', 'values' => 'term_id', 'orderby' => 'slug', 'selected' => $selected); sp_dropdown_taxonomies($args); ?> </td> <?php foreach ($labels as $column => $label) { $value = sp_array_value($player_performance, $column, ''); ?> <td> <input class="sp-player-<?php echo $column; ?> -input" type="text" name="sp_players[<?php echo $team_id; ?> ][<?php echo $player_id; ?> ][<?php echo $column; ?> ]" value="<?php echo $value; ?> " placeholder="0" /> </td> <?php } ?> <?php if ($team_id) { ?> <td class="sp-status-selector"> <?php echo self::status_select($team_id, $player_id, sp_array_value($player_performance, 'status', null)); ?> <?php echo self::sub_select($team_id, $player_id, sp_array_value($player_performance, 'sub', null), $data); ?> </td> <?php } else { ?> <td> <?php $values = sp_array_value($player_performance, 'outcome', ''); if (!is_array($values)) { $values = array($values); } $args = array('post_type' => 'sp_outcome', 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][outcome][]', 'option_none_value' => '', 'sort_order' => 'ASC', 'sort_column' => 'menu_order', 'selected' => $values, 'class' => 'sp-outcome', 'property' => 'multiple', 'chosen' => true, 'placeholder' => __('None', 'prosports')); sp_dropdown_pages($args); ?> </td> <?php } ?> </tr> <?php } ?> </tbody> </table> </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 }
/** * Output the metabox */ public static function output($post) { wp_nonce_field('sportspress_save_data', 'sportspress_meta_nonce'); if (taxonomy_exists('sp_league')) { $leagues = get_the_terms($post->ID, 'sp_league'); $league_ids = array(); if ($leagues) { foreach ($leagues as $league) { $league_ids[] = $league->term_id; } } } if (taxonomy_exists('sp_season')) { $seasons = get_the_terms($post->ID, 'sp_season'); $season_ids = array(); if ($seasons) { foreach ($seasons as $season) { $season_ids[] = $season->term_id; } } } if (taxonomy_exists('sp_venue')) { $venues = get_the_terms($post->ID, 'sp_venue'); $venue_ids = array(); if ($venues) { foreach ($venues as $venue) { $venue_ids[] = $venue->term_id; } } } $abbreviation = get_post_meta($post->ID, 'sp_abbreviation', true); $url = get_post_meta($post->ID, 'sp_url', true); ?> <?php if (taxonomy_exists('sp_league')) { ?> <p><strong><?php _e('Competitions', 'sportspress'); ?> </strong></p> <p><?php $args = array('taxonomy' => 'sp_league', 'name' => 'tax_input[sp_league][]', 'selected' => $league_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Competitions', 'sportspress')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_taxonomies($args); ?> </p> <?php } ?> <?php if (taxonomy_exists('sp_season')) { ?> <p><strong><?php _e('Seasons', 'sportspress'); ?> </strong></p> <p><?php $args = array('taxonomy' => 'sp_season', 'name' => 'tax_input[sp_season][]', 'selected' => $season_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Seasons', 'sportspress')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_taxonomies($args); ?> </p> <?php } ?> <?php if (taxonomy_exists('sp_venue')) { ?> <p><strong><?php _e('Home', 'sportspress'); ?> </strong></p> <p><?php $args = array('taxonomy' => 'sp_venue', 'name' => 'tax_input[sp_venue][]', 'selected' => $venue_ids, 'values' => 'term_id', 'placeholder' => sprintf(__('Select %s', 'sportspress'), __('Venue', 'sportspress')), 'class' => 'widefat', 'property' => 'multiple', 'chosen' => true); sp_dropdown_taxonomies($args); ?> </p> <?php } ?> <p><strong><?php _e('Site URL', 'sportspress'); ?> </strong></p> <p><input type="text" class="widefat" id="sp_url" name="sp_url" value="<?php echo esc_url($url); ?> "></p> <?php if ($url) { ?> <p><a class="sp-link" title="<?php _e('Visit Site', 'sportspress'); ?> " href="<?php echo $url; ?> " target="_blank"><?php _e('Visit Site', 'sportspress'); ?> </a></p> <?php } ?> <p><strong><?php _e('Abbreviation', 'sportspress'); ?> </strong></p> <p><input type="text" id="sp_abbreviation" name="sp_abbreviation" value="<?php echo esc_attr($abbreviation); ?> "></p> <?php }
/** * Admin edit table row */ public static function row($labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array(), $positions = true, $status = true, $sortable = true, $numbers = true) { if ($player_id <= 0) { return; } $number = get_post_meta($player_id, 'sp_number', true); $value = sp_array_value($player_performance, 'number', ''); ?> <tr class="sp-row sp-post" data-player="<?php echo $player_id; ?> "> <?php if ($sortable) { ?> <td class="icon"><span class="dashicons dashicons-menu post-state-format"></span></td> <?php } ?> <?php if ($numbers) { ?> <td> <input class="small-text sp-player-number-input" type="text" name="sp_players[<?php echo $team_id; ?> ][<?php echo $player_id; ?> ][number]" value="<?php echo esc_attr($value); ?> " /> </td> <?php } ?> <td><?php echo get_the_title($player_id); ?> </td> <?php if ($positions) { ?> <td> <?php $selected = (array) sp_array_value($player_performance, 'position', null); if ($selected == null) { $selected = (array) sp_get_the_term_id($player_id, 'sp_position', 0); } $args = array('taxonomy' => 'sp_position', 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position][]', 'values' => 'term_id', 'orderby' => 'slug', 'selected' => $selected, 'class' => 'sp-position', 'property' => 'multiple', 'chosen' => true, 'include_children' => 'no' == get_option('sportspress_event_hide_child_positions', 'no')); sp_dropdown_taxonomies($args); ?> </td> <?php } ?> <?php foreach ($labels as $column => $label) { $value = sp_array_value($player_performance, $column, ''); ?> <td> <input class="sp-player-<?php echo $column; ?> -input" type="text" name="sp_players[<?php echo $team_id; ?> ][<?php echo $player_id; ?> ][<?php echo $column; ?> ]" value="<?php echo esc_attr($value); ?> " placeholder="0" /> </td> <?php } ?> <?php if ($status) { ?> <td class="sp-status-selector"> <?php echo self::status_select($team_id, $player_id, sp_array_value($player_performance, 'status', null)); ?> <?php echo self::sub_select($team_id, $player_id, sp_array_value($player_performance, 'sub', null), $data); ?> </td> <?php } ?> </tr> <?php }
/** * Admin edit table row */ public static function row($labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array(), $positions = true, $status = true, $sortable = true, $numbers = true, $section = -1, $formats = array(), $player_timeline = array()) { if ($player_id <= 0) { return; } $value = sp_array_value($player_performance, 'number', ''); ?> <tr class="sp-row sp-post" data-player="<?php echo $player_id; ?> "> <?php if ($sortable) { ?> <td class="icon"><span class="dashicons dashicons-menu post-state-format"></span></td> <?php } ?> <?php if (apply_filters('sportspress_event_performance_show_numbers', $numbers, $section)) { ?> <td> <input class="small-text sp-player-number-input sp-sync-input" type="text" name="sp_players[<?php echo $team_id; ?> ][<?php echo $player_id; ?> ][number]" value="<?php echo esc_attr($value); ?> " /> </td> <?php } ?> <td> <?php echo get_the_title($player_id); ?> <?php if (1 == $section) { ?> <input type="hidden" name="sp_order[<?php echo $team_id; ?> ][]" value="<?php echo $player_id; ?> "> <?php } ?> </td> <?php if ($positions) { ?> <td> <?php $selected = (array) sp_array_value($player_performance, 'position', null); if ($selected == null) { $selected = (array) sp_get_the_term_id($player_id, 'sp_position', 0); } $args = array('taxonomy' => 'sp_position', 'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position][]', 'values' => 'term_id', 'orderby' => 'slug', 'selected' => $selected, 'class' => 'sp-position', 'property' => 'multiple', 'chosen' => true, 'include_children' => 'no' == get_option('sportspress_event_hide_child_positions', 'no')); sp_dropdown_taxonomies($args); ?> </td> <?php } ?> <?php foreach ($labels as $column => $label) { $value = sp_array_value($player_performance, $column, ''); $intval = intval($value); $placeholder = sp_get_format_placeholder(sp_array_value($formats, $column, 'number')); ?> <td> <input class="sp-player-<?php echo $column; ?> -input sp-sync-input" type="text" name="sp_players[<?php echo $team_id; ?> ][<?php echo $player_id; ?> ][<?php echo $column; ?> ]" value="<?php echo esc_attr($value); ?> " placeholder="<?php echo $placeholder; ?> " /> <?php if ($intval) { ?> <?php // Get performance times if (is_array($player_timeline)) { $times = sp_array_value($player_timeline, $column, array()); } else { $times = false; } if (is_array($times)) { ?> <hr> <?php for ($i = 0; $i < $intval; $i++) { ?> <input class="sp-sync-input small-text" type="text" name="sp_timeline[<?php echo $team_id; ?> ][<?php echo $player_id; ?> ][<?php echo $column; ?> ][<?php echo $i; ?> ]" value="<?php echo esc_attr(sp_array_value($times, $i, '')); ?> " placeholder="-" /><?php } ?> <span class="description"><?php _e('mins', 'sportspress'); ?> </span> <?php } } ?> </td> <?php } ?> <?php if (apply_filters('sportspress_event_performance_show_status', $status, $section)) { ?> <td class="sp-status-selector"> <?php // Get substitute times if (is_array($player_timeline)) { $times = sp_array_value($player_timeline, 'sub', array()); } else { $times = false; } ?> <?php echo self::status_select($team_id, $player_id, sp_array_value($player_performance, 'status', null)); ?> <?php echo self::sub_select($team_id, $player_id, sp_array_value($player_performance, 'sub', null), $data); ?> <input class="sp-sync-input small-text" type="text" name="sp_timeline[<?php echo $team_id; ?> ][<?php echo $player_id; ?> ][sub][]" value="<?php echo esc_attr(sp_array_value($times, 0, '')); ?> " placeholder="-" /> <span class="description"><?php _e('mins', 'sportspress'); ?> </span> </td> <?php } ?> </tr> <?php }
function prosports_dropdown_taxonomies($args = array()) { return sp_dropdown_taxonomies($args); }
/** * 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 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 }
/** * 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 }