CPTP_Util::get_no_taxonomy_structure PHP Method

get_no_taxonomy_structure() public static method

Get Option no_taxonomy_structure.
Since: 2.2.0
public static get_no_taxonomy_structure ( ) : boolean
return boolean
    public static function get_no_taxonomy_structure()
    {
        return !!intval(get_option('no_taxonomy_structure', true));
    }

Usage Example

 /**
  *
  * Fix taxonomy link outputs.
  *
  * @since 0.6
  * @version 1.0
  *
  * @param string $termlink
  * @param Object $term
  * @param Object $taxonomy
  *
  * @return string
  */
 public function term_link($termlink, $term, $taxonomy)
 {
     /** @var WP_Rewrite $wp_rewrite */
     global $wp_rewrite;
     if (!$wp_rewrite->permalink_structure) {
         return $termlink;
     }
     if (CPTP_Util::get_no_taxonomy_structure()) {
         return $termlink;
     }
     $taxonomy = get_taxonomy($taxonomy);
     if ($taxonomy->_builtin) {
         return $termlink;
     }
     if (empty($taxonomy)) {
         return $termlink;
     }
     $wp_home = rtrim(home_url(), '/');
     if (in_array(get_post_type(), $taxonomy->object_type)) {
         $post_type = get_post_type();
     } else {
         $post_type = $taxonomy->object_type[0];
     }
     $front = substr($wp_rewrite->front, 1);
     $termlink = str_replace($front, '', $termlink);
     // remove front.
     $post_type_obj = get_post_type_object($post_type);
     if (empty($post_type_obj)) {
         return $termlink;
     }
     $slug = $post_type_obj->rewrite['slug'];
     $with_front = $post_type_obj->rewrite['with_front'];
     if ($with_front) {
         $slug = $front . $slug;
     }
     if (!empty($slug)) {
         $termlink = str_replace($wp_home, $wp_home . '/' . $slug, $termlink);
     }
     if (!$taxonomy->rewrite['hierarchical']) {
         $termlink = str_replace($term->slug . '/', CPTP_Util::get_taxonomy_parents_slug($term->term_id, $taxonomy->name, '/', true), $termlink);
     }
     return $termlink;
 }
All Usage Examples Of CPTP_Util::get_no_taxonomy_structure