* @license GPL-2.0+ * @link http://rahularyan.com * @copyright 2014 Rahul Aryan */ class AP_Tags { /** * Instance of this class. */ protected static $instance = null; /** * Return an instance of this class. * @return object A single instance of this class. */ public static function get_instance() { // If the single instance hasn't been set, set it now. if (null == self::$instance) { self::$instance = new self; } return self::$instance; } /** * Initialize the plugin by setting localization and loading public scripts * and styles. */ public function __construct() { } public function register_question_tags(){ } public function custom_tags_link($url, $term, $taxonomy){ if(ap_opt('enable_tags')){ /* change tags link if permalink not enabled */ if ( 'question_tags' == $term->taxonomy && !get_option('permalink_structure')) { return add_query_arg( array('question_tags' => false, 'p' => ap_opt('base_page'), 'qtag_id' =>$term->term_id), $url ); }elseif('question_tags' == $term->taxonomy && get_option('permalink_structure')){ return ap_get_link_to('tag/'.$term->slug); } } return $url; } } function ap_question_tags_html($post_id = false, $list = true){ /* return if tags is disabled */ if(!ap_opt('enable_tags')) return; if(!$post_id) $post_id = get_the_ID(); $tags = get_the_terms( $post_id, 'question_tags' ); if($tags){ if($list){ $o = ''; echo $o; }else{ $o = 'Tags:'; $o .= ' '; foreach($tags as $t){ $o .= ''. $t->name .','; } $o .= ''; echo $o; } } } function ap_tag_details(){ /* return if tags is disabled */ if(!ap_opt('enable_tags')) return; $var = get_query_var('question_tags'); $tag = get_term_by('slug', $var, 'question_tags'); echo '
'; echo '

'. $tag->name .'

'; echo '
'; echo ''. $tag->count .' '.__('Questions', 'ap').''; echo ''; echo '
'; echo '
'; echo '

'. $tag->description .'

'; } function ap_question_have_tags($post_id = false){ if(!$post_id) $post_id = get_the_ID(); if(!ap_opt('enable_tags')) return false; $tags = wp_get_post_terms( $post_id, 'question_tags'); if(!empty($tags)) return true; return false; }