AnsPress_Admin::append_post_status_list()

Description #

Add AnsPress post status to post edit select box.

Source #

File: admin/anspress-admin.php

	public static function append_post_status_list() {
		global $post;

		$complete = '';
		$label    = '';

		if ( in_array( $post->post_type, array( 'question', 'answer' ), true ) ) {
			if ( 'moderate' === $post->post_status ) {
					$complete = ' selected=\'selected\'';
					$label    = '<span id=\'post-status-display\'>' . esc_attr__( 'Moderate', 'anspress-question-answer' ) . '</span>';
			} elseif ( 'private_post' === $post->post_status ) {
					$complete = ' selected=\'selected\'';
					$label    = '<span id=\'post-status-display\'>' . esc_attr__( 'Private Post', 'anspress-question-answer' ) . '</span>';
			}

			// @codingStandardsIgnoreStart
			echo '<script>
				jQuery(document).ready(function(){
					jQuery("select#post_status").append("<option value=\'moderate\' ' . $complete . '>' . esc_attr__( 'Moderate', 'anspress-question-answer' ) . '</option>");
					jQuery("select#post_status").append("<option value=\'private_post\' ' . $complete . '>' . esc_attr__( 'Private Post', 'anspress-question-answer' ) . '</option>");
					jQuery(".misc-pub-section label").append("' . $label . '");
				});
			</script>';
			// @codingStandardsIgnoreEnd
		}
	}

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