if (!$staffs) { return; } extract($defaults, EXTR_SKIP); ?> <p class="sp-event-staff"> <?php foreach ($staffs as $staff_id) { if (!$staff_id) { continue; } $name = get_the_title($staff_id); if (!$name) { continue; } $staff = new SP_Staff($staff_id); $role = $staff->role(); if ($role) { echo $role->name; } else { _e('Staff', 'prosports'); } echo ': '; if ($link_posts) { $permalink = get_post_permalink($staff_id); $name = '<a href="' . $permalink . '">' . $name . '</a>'; } echo $name . '<br>'; } ?> </p>
function sportspress_the_title($title, $id = null) { if (!$id) { return $title; } if (!is_admin() && in_the_loop() && $id == get_the_ID()) { if (is_singular('sp_player')) { $number = get_post_meta($id, 'sp_number', true); if ($number != null) { $title = '<strong class="sp-player-number">' . $number . '</strong> ' . $title; } } elseif (is_singular('sp_staff')) { $staff = new SP_Staff($id); $role = $staff->role(); if ($role) { $title = '<strong class="sp-staff-role">' . $role->name . '</strong> ' . $title; } } } return $title; }
* @version 1.8.9 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly if (get_option('sportspress_staff_show_details', 'yes') === 'no') { return; } if (!isset($id)) { $id = get_the_ID(); } $defaults = array('show_nationality' => get_option('sportspress_staff_show_nationality', 'yes') == 'yes' ? true : false, 'show_current_teams' => get_option('sportspress_staff_show_current_teams', 'yes') == 'yes' ? true : false, 'show_past_teams' => get_option('sportspress_staff_show_past_teams', 'yes') == 'yes' ? true : false, 'show_nationality_flags' => get_option('sportspress_staff_show_flags', 'yes') == 'yes' ? true : false, 'link_teams' => get_option('sportspress_link_teams', 'no') == 'yes' ? true : false); extract($defaults, EXTR_SKIP); $countries = SP()->countries->countries; $staff = new SP_Staff($id); $nationalities = $staff->nationalities(); $current_teams = $staff->current_teams(); $past_teams = $staff->past_teams(); $data = array(); if ($show_nationality && $nationalities && is_array($nationalities)) { $values = array(); foreach ($nationalities as $nationality) { if (2 == strlen($nationality)) { $legacy = SP()->countries->legacy; $nationality = strtolower($nationality); $nationality = sp_array_value($legacy, $nationality, null); } $country_name = sp_array_value($countries, $nationality, null); $values[] = $country_name ? ($show_nationality_flags ? '<img src="' . plugin_dir_url(SP_PLUGIN_FILE) . 'assets/images/flags/' . strtolower($nationality) . '.png" alt="' . $nationality . '"> ' : '') . $country_name : '—'; }
/** * Returns formatted data * * @access public * @param bool $admin * @return array */ public function data($admin = false) { global $pagenow; $staffs = get_post_meta($this->ID, 'sp_staffs', true); $args = array('post_type' => 'sp_staff', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => $this->orderby, 'order' => $this->order, 'tax_query' => array('relation' => 'AND')); if ($pagenow != 'post-new.php') { if ($this->ID) { $leagues = get_the_terms($this->ID, 'sp_league'); $seasons = get_the_terms($this->ID, 'sp_season'); $roles = get_the_terms($this->ID, 'sp_role'); $team = get_post_meta($this->ID, 'sp_team', true); if ($leagues) { $league_ids = array(); foreach ($leagues as $league) { $league_ids[] = $league->term_id; } $args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league_ids); } if ($seasons) { $season_ids = array(); foreach ($seasons as $season) { $season_ids[] = $season->term_id; } $args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $season_ids); } if ($roles) { $role_ids = array(); foreach ($roles as $role) { $role_ids[] = $role->term_id; } $args['tax_query'][] = array('taxonomy' => 'sp_role', 'field' => 'id', 'terms' => $role_ids); } if ($team) { $args['meta_query'] = array(array('key' => 'sp_team', 'value' => $team)); } } $posts = get_posts($args); } else { $posts = null; } if ($posts === null) { $data = null; } else { $data = array(); foreach ($posts as $post) { $staff = array('name' => get_the_title($post->ID)); $staff_object = new SP_Staff($post->ID); $role = $staff_object->role(); if (!empty($role)) { $staff['role'] = $role->name; } $phone = get_post_meta($post->ID, 'sp_phone', true); if (!empty($phone)) { $staff['phone'] = $phone; } $email = get_post_meta($post->ID, 'sp_email', true); if (!empty($email)) { $staff['email'] = $email; } $data[$post->ID] = $staff; } // Sort them by manual order if (is_array($staffs)) { $prepend = array(); foreach ($staffs as $staff) { if (array_key_exists($staff, $data)) { $prepend[$staff] = $data[$staff]; unset($data[$staff]); } } $data = $prepend + $data; } } $labels = apply_filters('sportspress_directory_labels', array('phone' => __('Phone', 'sportspress'), 'email' => __('Email', 'sportspress'))); if ($admin) { return array($labels, $this->columns, $data); } else { if (!is_array($this->columns)) { $this->columns = array(); } foreach ($labels as $key => $label) { if (!in_array($key, $this->columns)) { unset($labels[$key]); } } $data[0] = array_merge(array('role' => __('Job', 'sportspress'), 'name' => __('Name', 'sportspress')), $labels); return $data; } }
* @version 1.4 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly if (get_option('prosports_staff_show_details', 'yes') === 'no') { return; } if (!isset($id)) { $id = get_the_ID(); } $defaults = array('show_nationality_flags' => get_option('prosports_staff_show_flags', 'yes') == 'yes' ? true : false); extract($defaults, EXTR_SKIP); $countries = SP()->countries->countries; $staff = new SP_Staff($id); $nationality = $staff->nationality; $current_team = $staff->current_team; $past_teams = $staff->past_teams(); $data = array(); if ($nationality) { $country_name = sp_array_value($countries, $nationality, null); $data[__('Nationality', 'prosports')] = $country_name ? ($show_nationality_flags ? '<img src="' . plugin_dir_url(SP_PLUGIN_FILE) . '/assets/images/flags/' . strtolower($nationality) . '.png" alt="' . $nationality . '"> ' : '') . $country_name : '—'; } if ($current_team) { $data[__('Current Team', 'prosports')] = '<a href="' . get_post_permalink($current_team) . '">' . get_the_title($current_team) . '</a>'; } if ($past_teams) { $teams = array(); foreach ($past_teams as $team) { $teams[] = '<a href="' . get_post_permalink($team) . '">' . get_the_title($team) . '</a>';