AnsPress_Category::hover_card_category( integer $id )
Description #
Output hover card for term.
Parameters #
- $idinteger (Required) User ID.
Source #
File: addons/free/category.php
public static function hover_card_category( $id ) {
$cache = get_transient( 'ap_category_card_' . $id );
if ( false !== $cache ) {
ap_ajax_json( $cache );
}
$category = get_term( $id, 'question_category' );
$sub_cat_count = count( get_term_children( $category->term_id, 'question_category' ) );
$data = array(
'template' => 'category-hover',
'disableAutoLoad' => 'true',
'apData' => array(
'id' => $category->term_id,
'name' => $category->name,
'link' => get_category_link( $category ), // @codingStandardsIgnoreLine.
'image' => ap_get_category_image( $category->term_id, 90 ),
'icon' => ap_get_category_icon( $category->term_id ),
'description' => $category->description,
'question_count' => sprintf( _n( '%d Question', '%d Questions', $category->count, 'anspress-question-answer' ), $category->count ),
'sub_category' => array(
'have' => $sub_cat_count > 0,
'count' => sprintf( _n( '%d Sub category', '%d Sub categories', $sub_cat_count, 'anspress-question-answer' ), $sub_cat_count ),
),
),
);
/**
* Filter user hover card data.
*
* @param array $data Card data.
* @return array
* @since 3.0.0
*/
$data = apply_filters( 'ap_category_hover_data', $data );
set_transient( 'ap_category_card_' . $id, $data, HOUR_IN_SECONDS );
ap_ajax_json( $data );
}
Expand full source code Collapse full source code View on GitHub: addons/free/category.php:711
Add your comment