get_taxonomies() public static method

public static get_taxonomies ( boolean $objects = false ) : array
$objects boolean
return array
Ejemplo n.º 1
0
 /**
  *
  * Fix taxonomy = parent/child => taxonomy => child
  * @since 0.9.3
  *
  * @param WP $obj
  */
 public function parse_request($obj)
 {
     $taxes = CPTP_Util::get_taxonomies();
     foreach ($taxes as $key => $tax) {
         if (isset($obj->query_vars[$tax])) {
             if (false !== strpos($obj->query_vars[$tax], '/')) {
                 $query_vars = explode('/', $obj->query_vars[$tax]);
                 if (is_array($query_vars)) {
                     $obj->query_vars[$tax] = array_pop($query_vars);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  *
  * Fix taxonomy = parent/child => taxonomy => child
  * @since 0.9.3
  *
  */
 public function parse_request($obj)
 {
     $taxes = CPTP_Util::get_taxonomies();
     foreach ($taxes as $key => $tax) {
         if (isset($obj->query_vars[$tax])) {
             if (strpos($obj->query_vars[$tax], "/") !== false) {
                 $obj->query_vars[$tax] = array_pop(explode("/", $obj->query_vars[$tax]));
             }
         }
     }
 }
 /**
  *
  * create %tax% -> term
  *
  * @param int $post_id
  * @param string $permalink
  *
  * @return array
  */
 private function create_taxonomy_replace_tag($post_id, $permalink)
 {
     $search = array();
     $replace = array();
     $taxonomies = CPTP_Util::get_taxonomies(true);
     //%taxnomomy% -> parent/child
     //運用でケアすべきかも。
     foreach ($taxonomies as $taxonomy => $objects) {
         if (false !== strpos($permalink, '%' . $taxonomy . '%')) {
             $terms = wp_get_post_terms($post_id, $taxonomy, array('orderby' => 'term_id'));
             if ($terms and !is_wp_error($terms)) {
                 $parents = array_map(array(__CLASS__, 'get_term_parent'), $terms);
                 //親の一覧
                 $newTerms = array();
                 foreach ($terms as $key => $term) {
                     if (!in_array($term->term_id, $parents)) {
                         $newTerms[] = $term;
                     }
                 }
                 //このブロックだけで良いはず。
                 $term_obj = reset($newTerms);
                 //最初のOBjectのみを対象。
                 $term_slug = $term_obj->slug;
                 if (isset($term_obj->parent) and 0 != $term_obj->parent) {
                     $term_slug = CPTP_Util::get_taxonomy_parents($term_obj->parent, $taxonomy, false, '/', true) . $term_slug;
                 }
             }
             if (isset($term_slug)) {
                 $search[] = '%' . $taxonomy . '%';
                 $replace[] = $term_slug;
             }
         }
     }
     return array('search' => $search, 'replace' => $replace);
 }
Ejemplo n.º 4
0
 /**
  *
  * create %tax% -> term
  *
  * */
 private function create_taxonomy_replace_tag($post_id, $permalink)
 {
     $search = array();
     $replace = array();
     $taxonomies = CPTP_Util::get_taxonomies(true);
     //%taxnomomy% -> parent/child
     //運用でケアすべきかも。
     foreach ($taxonomies as $taxonomy => $objects) {
         $term = null;
         if (strpos($permalink, "%{$taxonomy}%") !== false) {
             $terms = wp_get_post_terms($post_id, $taxonomy, array('orderby' => 'term_id'));
             if ($terms and count($terms) > 1) {
                 if (reset($terms)->parent == 0) {
                     $keys = array_keys($terms);
                     $term = $terms[$keys[1]]->slug;
                     if ($terms[$keys[0]]->term_id == $terms[$keys[1]]->parent) {
                         $term = CPTP_Util::get_taxonomy_parents($terms[$keys[1]]->parent, $taxonomy, false, '/', true) . $term;
                     }
                 } else {
                     $keys = array_keys($terms);
                     $term = $terms[$keys[0]]->slug;
                     if ($terms[$keys[1]]->term_id == $terms[$keys[0]]->parent) {
                         $term = CPTP_Util::get_taxonomy_parents($terms[$keys[0]]->parent, $taxonomy, false, '/', true) . $term;
                     }
                 }
             } else {
                 if ($terms) {
                     $term_obj = array_shift($terms);
                     $term = $term_obj->slug;
                     if (isset($term_obj->parent) and $term_obj->parent != 0) {
                         $term = CPTP_Util::get_taxonomy_parents($term_obj->parent, $taxonomy, false, '/', true) . $term;
                     }
                 }
             }
             if (isset($term)) {
                 $search[] = "%{$taxonomy}%";
                 $replace[] = $term;
             }
         }
     }
     return array("search" => $search, "replace" => $replace);
 }