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; }
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>
/** * 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; } }