/** * Get index value for an object stored in a list. * * Can be reindex on a post property. * * @param WPLib_Post_Base $element * * @return bool|mixed */ function get_element_index($element) { /** * Give the parent first change. */ if (!($index = parent::get_element_index($element))) { if ($this->_index_by && $element instanceof WPLib_Post_Base) { if (property_exists($post = $element->post(), $index_by = $this->_index_by)) { $index = $post->{$index_by}; } } } return $index; }
/** * @param array $terms * @param array $args */ function __construct($terms, $args = array()) { if (isset($terms) && is_array($terms)) { $args = wp_parse_args($args, array('list_owner' => 'WPLib_Terms')); /** * @var WPLib_Terms $list_owner */ $list_owner = $args['list_owner']; foreach ($terms as $index => $term) { $terms[$index] = $list_owner::make_new_item($term, $args); } } parent::__construct($terms, $args); }