AnsPress_Theme::question_answer_post_class( array $classes )

Description #

Add answer-seleted class in post_class.

Parameters #

  • $classes
    array (Required) Post class attribute.

Changelog #

VersionDescription
4.1.8Fixes #426: Undefined property post_type.
2.0.1Introduced.

Source #

File: includes/class-theme.php

	public static function question_answer_post_class( $classes ) {
		global $post;

		if ( ! $post ) {
			return $classes;
		}

		if ( 'question' === $post->post_type ) {
			if ( ap_have_answer_selected( $post->ID ) ) {
				$classes[] = 'answer-selected';
			}

			if ( ap_is_featured_question( $post->ID ) ) {
				$classes[] = 'featured-question';
			}

			$classes[] = 'answer-count-' . ap_get_answers_count();
		} elseif ( 'answer' === $post->post_type ) {
			if ( ap_is_selected( $post->ID ) ) {
				$classes[] = 'best-answer';
			}

			if ( ! ap_user_can_read_answer( $post ) ) {
				$classes[] = 'no-permission';
			}
		}

		return $classes;
	}

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