AnsPress_Admin::menu_counts()

Description #

Menu counter

Changelog #

VersionDescription
2.4.6Introduced.

Source #

File: admin/anspress-admin.php

	public static function menu_counts() {
		$flagged   = ap_total_flagged_count();
		$q_flagged = $flagged['questions'];
		$a_flagged = $flagged['answers'];

		$question_count = wp_count_posts( 'question', 'readable' );
		$answer_count   = wp_count_posts( 'answer', 'readable' );

		$types = array(
			'question' => ( ! empty( $question_count->moderate ) ? $question_count->moderate : 0 ) + $q_flagged->total,
			'answer'   => ( ! empty( $answer_count->moderate ) ? $answer_count->moderate : 0 ) + $a_flagged->total,
			'flagged'  => $q_flagged->total + $a_flagged->total,
		);

		$types['total'] = (int) $types['flagged'];
		$types_html     = array();

		foreach ( (array) $types as $k => $count ) {
			if ( $count > 0 ) {
				$types_html[ $k ] = ' <span class="update-plugins count ap-menu-counts"><span class="plugin-count">' . number_format_i18n( $count ) . '</span></span>';
			} else {
				$types_html[ $k ] = '';
			}
		}

		return $types_html;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment