| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
// Import WP_List_Table class. |
| 10 |
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
| 11 |
|
| 12 |
/** |
| 13 |
* |
| 14 |
*/ |
| 15 |
class CJTPackagesManagerListTable extends WP_List_Table { |
| 16 |
|
| 17 |
/** |
| 18 |
* put your comment there... |
| 19 |
* |
| 20 |
*/ |
| 21 |
public function __construct() { |
| 22 |
// Set hook suffix (E_ALL complain)! |
| 23 |
$GLOBALS['hook_suffix'] = 'cjt'; |
| 24 |
// Table list arguments. |
| 25 |
$args = array(); |
| 26 |
parent::__construct($args); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* |
| 31 |
*/ |
| 32 |
protected function column_default($item, $name) { |
| 33 |
$value = null; |
| 34 |
switch ($name) { |
| 35 |
case '_selection_': |
| 36 |
echo "<input type='checkbox' name='id[]' value='{$item->id}' />"; |
| 37 |
break; |
| 38 |
case 'name': |
| 39 |
// Package name! |
| 40 |
$value = "<span class='package-name'>{$item->{$name}}</span>"; |
| 41 |
// Description underneath the name! |
| 42 |
$value .= "<br /><div class='description'><span>{$item->description}</span></div>"; |
| 43 |
// Display row actions underneath template name column. |
| 44 |
$actions = array(); |
| 45 |
// ----$actions['info'] = "<a href='#info({$item->id})'>" . cssJSToolbox::getText('Info') . '</a>'; |
| 46 |
$actions['delete'] = "<a href='#delete({$item->id})'>" . cssJSToolbox::getText('Delete') . '</a>'; |
| 47 |
// Show actions row underneath template name!! |
| 48 |
$value .= $this->row_actions($actions, false); |
| 49 |
break; |
| 50 |
case 'webSite': |
| 51 |
$value = "<a target='_blank' href='{$item->$name}'>{$item->$name}</a>"; |
| 52 |
break; |
| 53 |
case 'license': |
| 54 |
case 'readme': |
| 55 |
if ($item->$name) { |
| 56 |
// Upper casxe first letter. |
| 57 |
$fileName = ucfirst($name); |
| 58 |
// Generate view file link for each file name (readmem license)! |
| 59 |
$value = "<a class='view-package-file' href='#get{$fileName}File({$item->id})'>" . cssJSToolbox::getText('View') . "</a>"; |
| 60 |
} |
| 61 |
else { |
| 62 |
$value = cssJSToolbox::getText('N/A'); |
| 63 |
} |
| 64 |
break; |
| 65 |
default; |
| 66 |
$value = $item->{$name}; |
| 67 |
break; |
| 68 |
} |
| 69 |
return $value; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* put your comment there... |
| 74 |
* |
| 75 |
*/ |
| 76 |
public function get_bulk_actions() { |
| 77 |
// Bulk ations. |
| 78 |
$actions = array( |
| 79 |
'delete' => cssJSToolbox::getText('Delete'), |
| 80 |
); |
| 81 |
// Return actions! |
| 82 |
return $actions; |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Get a list of columns. The format is: |
| 87 |
* 'internal-name' => 'Title' |
| 88 |
* |
| 89 |
* @since 3.1.0 |
| 90 |
* @access protected |
| 91 |
* @abstract |
| 92 |
* |
| 93 |
* @return array |
| 94 |
*/ |
| 95 |
public function get_columns() { |
| 96 |
return array( |
| 97 |
'_selection_' => '<input type="checkbox" class="select-all" />', |
| 98 |
'name' => cssJSToolbox::getText('Name'), |
| 99 |
'author' => cssJSToolbox::getText('Author'), |
| 100 |
'webSite' => cssJSToolbox::getText('Website'), |
| 101 |
'license' => cssJSToolbox::getText('License'), |
| 102 |
'readme' => cssJSToolbox::getText('Readme'), |
| 103 |
'id' => cssJSToolbox::getText('ID'), |
| 104 |
); |
| 105 |
} |
| 106 |
|
| 107 |
} // End class. |