private function format_arg($text, $value) { $col = array('slug' => '', 'title' => '', 'sortable' => false, 'editable' => false, 'icon' => '', 'content' => ''); // if contains caret, it's sortable if (strpos($text, '^')) { $text = trim($text, '^'); $col['sortable'] = true; } $col['slug'] = H_Elper::to_param($text); // if comments, set the default icon if ($col['slug'] === 'comments') { $col['icon'] = 'dashicons-admin-comments'; } // if value is array, get [content], if not just put the plain value if (is_array($value)) { $col['content'] = isset($value['content']) ? $value['content'] : $text; // add icon if exist if (isset($value['icon'])) { $col['icon'] = H_Elper::to_icon($value['icon']); } } else { $col['content'] = $value; } // if icon exist $title = H_Elper::to_title($text); if ($col['icon']) { $title = "<span class='dashicons {$col['icon']}'></span> <span class='screen-reader-text'>{$title}</span>"; } $col['title'] = $title; return $col; }
function check_raw_args($args) { // if plain text, form the array format if (is_string($args)) { $args = array('name' => $args, 'label' => $args, 'slug' => $args); } else { // complete the args by adding the missing one $args['name'] = isset($args['name']) ? $args['name'] : $args['slug']; $args['slug'] = isset($args['slug']) ? $args['slug'] : $args['name']; } // format the args $new_args = array('name' => H_Elper::to_param($args['name']), 'label' => H_Elper::to_title($args['label']), 'slug' => H_Elper::to_param($args['slug'])); return $new_args; }
public function __construct($name, $args) { $this->name = H_Elper::to_param($name); $this->args = $args; }