ap_featured_post_args( boolean|integer $post_id = false )

Description #

Return set featured question action args.

Parameters #

  • $post_id
    boolean | integer (Optional) Post ID. Default value: false

Source #

File: includes/theme.php

function ap_featured_post_args( $post_id = false ) {
	if ( ! is_user_logged_in() || ! ap_user_can_toggle_featured() ) {
		return array();
	}

	if ( false === $post_id ) {
		$post_id = get_question_id();
	}

	$is_featured = ap_is_featured_question( $post_id );

	if ( $is_featured ) {
		$title = __( 'Unmark this question as featured', 'anspress-question-answer' );
		$label = __( 'Unfeature', 'anspress-question-answer' );
	} else {
		$title = __( 'Mark this question as featured', 'anspress-question-answer' );
		$label = __( 'Feature', 'anspress-question-answer' );
	}

	return array(
		'cb'     => 'toggle_featured',
		'active' => $is_featured,
		'query'  => array(
			'__nonce' => wp_create_nonce( 'set_featured_' . $post_id ),
			'post_id' => $post_id,
		),
		'title'  => esc_attr( $title ),
		'label'  => esc_attr( $label ),
	);
}

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