/** * Output the current category description. * * @access public * @since 0.7.8 * * @param array $atts [optional] * @param array $results [optional] * * @return string */ public static function categoryDescription($atts = array(), $results = array()) { $html = ''; // Check whether or not the category description should be displayed or not. if (!cnSettingsAPI::get('connections', 'connections_display_results', 'cat_desc')) { return $html; } $defaults = array('before' => '', 'after' => '', 'return' => FALSE); $atts = wp_parse_args($atts, $defaults); if (FALSE !== ($current = cnCategory::getCurrent())) { $category = new cnCategory($current); $html = $category->getDescriptionBlock(array('return' => TRUE)); } $html = $atts['before'] . $html . $atts['after'] . PHP_EOL; return self::echoOrReturn($atts['return'], $html); }
/** * Output the current category description. * * @access public * @since 0.7.8 * * @uses get_query_var() * * @param array $atts [optional] * @param array $results [optional] * * @return string */ public static function categoryDescription($atts = array(), $results = array()) { // Check whether or not the category description should be displayed or not. if (!cnSettingsAPI::get('connections', 'connections_display_results', 'cat_desc')) { return ''; } $out = ''; $defaults = array('before' => '', 'after' => '', 'return' => FALSE); $atts = wp_parse_args($atts, $defaults); if (get_query_var('cn-cat-slug')) { // If the category slug is a descendant, use the last slug from the URL for the query. $categorySlug = explode('/', get_query_var('cn-cat-slug')); if (isset($categorySlug[count($categorySlug) - 1])) { $categorySlug = $categorySlug[count($categorySlug) - 1]; } $term = cnTerm::getBy('slug', $categorySlug, 'category'); $category = new cnCategory($term); $out = $category->getDescriptionBlock(array('return' => TRUE)); } if (get_query_var('cn-cat')) { $categoryID = get_query_var('cn-cat'); if (is_array($categoryID)) { if (empty($categoryID)) { return $out; } else { $categoryID = $categoryID[0]; if (empty($categoryID)) { return $out; } } } $term = cnTerm::getBy('id', $categoryID, 'category'); $category = new cnCategory($term); $out = $category->getDescriptionBlock(array('return' => TRUE)); } $out = (empty($atts['before']) ? '' : $atts['before']) . $out . (empty($atts['after']) ? '' : $atts['after']) . PHP_EOL; return self::echoOrReturn($atts['return'], $out); }