/** * Register the term type inside of an Item classes' on_load() method. * * @param null|string|array $object_types * @param array $args * @todo Allow taxonomy name to be passed optionally. * * @link http://codex.wordpress.org/Function_Reference/register_taxonomy#Parameters */ static function register_taxonomy($object_types, $args = array()) { if (is_string($object_types)) { $object_types = explode(',', $object_types); } $args = wp_parse_args($args, array('label' => WPLib_Terms::_get_taxonomy_label(static::TAXONOMY, 'name'), 'labels' => WPLib_Terms::_get_taxonomy_labels(static::TAXONOMY))); if (is_array($object_types)) { foreach ($object_types as $object_type) { WPLib_Terms::add_object_type(static::TAXONOMY, $object_type); } } WPLib_Terms::_set_taxonomy_args(static::TAXONOMY, $args); }
/** * Run on WordPress's 'init' hook to register all the term types defined in classes that extend this class. */ static function _clear_taxonomy_args() { /* * No need to hang on to this data anymore. */ self::$_labels = null; self::$_taxonomy_args = null; self::$_object_types = null; }
/** * Check to see if this instance has a valid term object in $_term property. * * @return bool */ function has_term() { return WPLib_Terms::is_term($this->_term); }
/** * @param array|string|WPLib_Query $query * @param array $args * @return WPLib_Term_List_Default[] */ static function get_list($query = array(), $args = array()) { $args = wp_parse_args($args, array('default_list' => 'WPLib_Term_List_Default', 'items' => function ($query) { return WPLib_Terms::get_terms($query); })); return parent::get_list($query, $args); }
/** * @param array|string|WPLib_Query $query * @param array $args * @return WPLib_Term_List_Default[] */ static function get_list($query = array(), $args = array()) { $query = wp_parse_args($query); $query['taxonomy'] = static::TAXONOMY; $args = wp_parse_args($args, array('list_owner' => get_called_class())); return WPLib_Terms::get_list($query, $args); }
/** * @param WPLib_Item_Base|WP_Post|WP_Term $item * @param array $args * * @return WPLib_Term_Base|WPLib_Post_Base */ static function make_new_item($item, $args = array()) { $class = get_called_class(); if (WPLib::get_constant('POST_TYPE', $class)) { $item = WPLib_Posts::make_new_item($item, $args); } else { if (WPLib::get_constant('TAXONOMY', $class)) { $item = WPLib_Terms::make_new_item($item, $args); } else { $err_msg = __('Cannot make new item. Class %s does not have POST_TYPE or TAXONOMY constant.', 'wplib'); WPLib::trigger_error(sprintf($err_msg, $class)); } } return $item; }