/** * Generate an HTML tag * * @uses attributes * @static * @param string $name The tag name, e.g. div, input, p, li, etc. * @param array $attr Optional. The HTML attributes as an associative array * @param mixed $text Optional. The HTML to go within the tag. If false, it's a self-closing tag (< />) * @return string * @author Matthew Boynes */ public static function tag($name, $attr = array(), $text = false) { if ($attr) { $attr = SCPT_Markup::attributes($attr); } else { $attr = ''; } if (false !== $text) { $text = '>' . $text . '</' . esc_attr($name) . '>'; } else { $text = ' />'; } return '<' . esc_attr($name) . $attr . $text; }
/** * Generate an HTML tag * * @uses attributes * @static * @param string $name The tag name, e.g. div, input, p, li, etc. * @param array $attr Optional. The HTML attributes as an associative array * @param mixed $text Optional. The HTML to go within the tag. If false, it's a self-closing tag (< />) * @return string * @author Matthew Boynes */ public static function tag($name, $attr = array(), $text = false) { if ($attr) { $attr = SCPT_Markup::attributes($attr); } else { $attr = ''; } if (false !== $text) { $text = ">{$text}</{$name}>"; } else { $text = ' />'; } return '<' . $name . $attr . $text; }
/** * Initialize a Custom Post Type * * @uses SCPT_Markup::labelify * @param string $name The Custom Post Type slug. Should be singular, all lowercase, letters and numbers only, dashes for spaces * @param string $singular Optional. The singular form of our tax to be used in menus, etc. If absent, $name gets converted to words * @param string $plural Optional. The plural form of our tax to be used in menus, etc. If absent, 's' is added to $singular * @param string|bool $acts_like Optional. Define if this should act like categories or tags. If this starts with 'cat' the tax will act like a category; any other value and it will act like a tag * @param array|bool $register Optional. If false, the tax won't be automatically registered. If an array, can override any of the tax defaults. See {@link http://codex.wordpress.org/Function_Reference/register_taxonomy the WordPress Codex} for possible values. * @author Matthew Boynes */ public function __construct($name, $singular = false, $plural = false, $acts_like = false, $register = array()) { $this->name = $name; if (!$singular) { $singular = SCPT_Markup::labelify($this->name); } if (!$plural) { $plural = $singular . 's'; } $this->singular = $singular; $this->plural = $plural; $this->hierarchical = $acts_like && false !== strpos(strtolower($acts_like), 'cat'); if (false !== $register) { $this->register_taxonomy($register); } }
/** * Initialize a Custom Post Type * * @uses SCPT_Markup::labelify * @param string $type The Custom Post Type slug. Should be singular, all lowercase, letters and numbers only, dashes for spaces * @param string $singular Optional. The singular form of our CPT to be used in menus, etc. If absent, $type gets converted to words * @param string $plural Optional. The plural form of our CTP to be used in menus, etc. If absent, 's' is added to $singular * @param array|bool $register Optional. If false, the CPT won't be automatically registered. If an array, can override any of the CPT defaults. See {@link http://codex.wordpress.org/Function_Reference/register_post_type the WordPress Codex} for possible values. * @author Matthew Boynes */ function __construct($type, $singular = false, $plural = false, $register = array()) { $this->type = $type; if (!$singular) { $singular = SCPT_Markup::labelify($this->type); } if (!$plural) { $plural = $singular . 's'; } $this->singular = $singular; $this->plural = $plural; if (false !== $register) { $this->register_post_type($register); } parent::__construct($type); }
public function add_to_columns($column) { if (is_array($column)) { $this->columns = $this->columns + $column; } else { $this->columns[$column] = SCPT_Markup::labelify($column); } $this->register_custom_columns(); }