/** * 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; }
/** * @param string $string * @return string * @internal param string $locale */ public function translate($string) { return $this->pluralizer->pluralize($string, $this->locale); }