/** * get_context * * @return mixed */ protected function get_context() { $this->context['page_title'] = $this->get_page_title(); // TODO get from config $this->context[Pluralizer::pluralize($this->post_type)] = $this->context['posts'] = $this->get_posts(); $this->context['pagination'] = $this->get_pagination(); return $this->context; }
/** * footer * * Register theme widgets, filter with 'widget_{$key}' * */ public static function init() { self::$custom_post_types = Config::get('custom-post-types'); foreach (static::$custom_post_types as $key => &$args) { $name = __(ucfirst($key), THEMENAME); $defaults = array('labels' => array('name' => Pluralizer::pluralize($name), 'singular_name' => $name, 'add_new_item' => __(sprintf("Add new %s", ucfirst($key)), THEMENAME))); $args = wp_parse_args($args, $defaults); $key = apply_filters("pressgang_cpt_{$key}", $key); $args = apply_filters("pressgang_cpt_{$key}_args", $args); register_post_type($key, $args); } }
/** * footer * * Register theme widgets, filter with 'widget_{$key}' * */ public static function init() { self::$custom_post_types = Config::get('custom-post-types'); foreach (static::$custom_post_types as $key => &$args) { // TODO DRY - also in custom-taxonomies.php $name = __(ucwords(str_replace('_', ' ', $key)), THEMENAME); $plural = Pluralizer::pluralize($name); $defaults = array('labels' => array('name' => $plural, 'singular_name' => $name, 'add_new_item' => __(sprintf("Add new %s", $name), THEMENAME), 'search_items' => __(sprintf("Search %s", $name), THEMENAME), 'all_items' => __(sprintf("All %s", $plural), THEMENAME), 'edit_item' => __(sprintf("Edit %s", $name), THEMENAME), 'update_item' => __(sprintf("Update %s", $name), THEMENAME), 'new_item_name' => __(sprintf("New %s", $name), THEMENAME), 'menu_name' => $plural)); $args = wp_parse_args($args, $defaults); $key = apply_filters("pressgang_cpt_{$key}", $key); $args = apply_filters("pressgang_cpt_{$key}_args", $args); register_post_type($key, $args); } }
/** * get_custom_taxonomies * */ protected function get_custom_taxonomy_terms() { if (empty($this->custom_taxonomy_terms)) { $taxonomies = get_object_taxonomies($this->post_type, 'objects'); foreach ($taxonomies as $slug => &$taxonomy) { $terms = get_the_terms($this->get_post()->ID, $slug); if (is_array($terms) && count($terms)) { foreach ($terms as &$term) { $term = new \TimberTerm($term); } $name = Pluralizer::pluralize($slug); $this->custom_taxonomy_terms[$name] = $terms; } } } return $this->custom_taxonomy_terms; }
/** * Get the singular form of an English word. * * @param string $value * @return string */ public static function singular($value) { return Pluralizer::singular($value); }
public function toXML($data = null, $structure = null, $basenode = 'result') { if ($data === null and !func_num_args()) { $data = $this->_data; } // turn off compatibility mode as simple xml throws a wobbly if you don't. if (ini_get('zend.ze1_compatibility_mode') == 1) { ini_set('zend.ze1_compatibility_mode', 0); } if ($structure === null) { $structure = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><{$basenode} />"); } // Force it to be something useful if (!is_array($data) and !is_object($data)) { $data = (array) $data; } foreach ($data as $key => $value) { //change false/true to 0/1 if (is_bool($value)) { $value = (int) $value; } // no numeric keys in our xml please! if (is_numeric($key)) { // make string key... $key = Pluralizer::singular($basenode) != $basenode ? Pluralizer::singular($basenode) : 'item'; } // replace anything not alpha numeric $key = preg_replace('/[^a-z_\\-0-9]/i', '', $key); // if there is another array found recursively call this function if (is_array($value) or is_object($value)) { $node = $structure->addChild($key); // recursive call. $this->toXML($value, $node, $key); } else { // add single node. $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, "UTF-8"); $structure->addChild($key, $value); } } return $structure->asXML(); }
/** * @param string $string * @return string * @internal param string $locale */ public function translate($string) { return $this->pluralizer->pluralize($string, $this->locale); }