/**
  * Output the data metabox
  */
 public static function data($post)
 {
     $directory = new SP_Staff_Directory($post);
     list($labels, $columns, $data) = $directory->data(true);
     $staff = get_post_meta($post->ID, 'sp_staff', true);
     self::table($labels, $columns, $data, $staff);
 }
Exemplo n.º 2
0
<?php

/**
 * Staff List
 *
 * @author 		ThemeBoy
 * @package 	SportsPress_Staff_Directories
 * @version     1.6
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
$defaults = array('id' => get_the_ID(), 'title' => false, 'number' => -1, 'columns' => null, 'show_all_staff_link' => false, 'link_posts' => get_option('sportspress_link_staff', 'yes') == 'yes' ? true : false, 'link_phone' => get_option('sportspress_staff_link_phone', 'yes') == 'yes' ? true : false, 'link_email' => get_option('sportspress_staff_link_email', 'yes') == 'yes' ? true : false, 'sortable' => get_option('sportspress_enable_sortable_tables', 'yes') == 'yes' ? true : false, 'scrollable' => get_option('sportspress_enable_scrollable_tables', 'yes') == 'yes' ? true : false, 'paginated' => get_option('sportspress_directory_paginated', 'yes') == 'yes' ? true : false, 'rows' => get_option('sportspress_directory_rows', 10));
extract($defaults, EXTR_SKIP);
$directory = new SP_Staff_Directory($id);
if (isset($columns) && null !== $columns) {
    $directory->columns = $columns;
}
$data = $directory->data();
// The first row should be column labels
$labels = $data[0];
// Remove the first row to leave us with the actual data
unset($data[0]);
$output = '';
$output .= '<div class="sp-table-wrapper">' . '<table class="sp-staff-directory sp-data-table' . ($sortable ? ' sp-sortable-table' : '') . ($scrollable ? ' sp-scrollable-table' : '') . ($paginated ? ' sp-paginated-table' : '') . '" data-sp-rows="' . $rows . '">' . '<thead>' . '<tr>';
foreach ($labels as $key => $label) {
    if (!is_array($columns) || $key == 'name' || in_array($key, $columns)) {
        $output .= '<th class="data-' . $key . '">' . $label . '</th>';
    }
}