コード例 #1
0
 /**
  * Column value added to category admin.
  *
  * @access public
  * @param mixed $columns
  * @param mixed $column
  * @param mixed $id
  * @return array
  */
 public function column_value($columns, $column, $id)
 {
     if ($column == 'sp_address') {
         $term_meta = get_option("taxonomy_{$id}");
         $address = isset($term_meta['sp_address']) ? $term_meta['sp_address'] : '—';
         $columns .= $address;
     } elseif ($column == 'sp_sections') {
         $options = apply_filters('sportspress_performance_sections', array(0 => __('Offense', 'sportspress'), 1 => __('Defense', 'sportspress')));
         $sections = sp_get_term_sections($id);
         $section_names = array();
         if (is_array($sections)) {
             foreach ($sections as $section) {
                 if (array_key_exists($section, $options)) {
                     $section_names[] = $options[$section];
                 }
             }
         }
         $columns .= implode(', ', $section_names);
     }
     return $columns;
 }
コード例 #2
0
// Exit if accessed directly
if ('no' === get_option('sportspress_player_show_statistics', 'yes') && 'no' === get_option('sportspress_player_show_total', 'no')) {
    return;
}
if (!isset($id)) {
    $id = get_the_ID();
}
$player = new SP_Player($id);
$scrollable = get_option('sportspress_enable_scrollable_tables', 'yes') == 'yes' ? true : false;
$sections = get_option('sportspress_player_performance_sections', -1);
$leagues = get_the_terms($id, 'sp_league');
$positions = $player->positions();
$player_sections = array();
if ($positions) {
    foreach ($positions as $position) {
        $player_sections = array_merge($player_sections, sp_get_term_sections($position->term_id));
    }
}
// Determine order of sections
if (1 == $sections) {
    $section_order = array(1 => __('Defense', 'sportspress'), 0 => __('Offense', 'sportspress'));
} elseif (0 == $sections) {
    $section_order = array(__('Offense', 'sportspress'), __('Defense', 'sportspress'));
} else {
    $section_order = array(-1 => null);
}
// Loop through statistics for each league
if (is_array($leagues)) {
    foreach ($section_order as $section_id => $section_label) {
        if (-1 !== $section_id && !empty($player_sections) && !in_array($section_id, $player_sections)) {
            continue;