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;
		$label = '';

		if ( in_array( $post->post_type, array( 'question', 'answer' ), true ) ) {
			if ( 'moderate' === $post->post_status ) {
				$label = esc_attr__( 'Moderate', 'anspress-question-answer' );
			} elseif ( 'private_post' === $post->post_status ) {
				$label = esc_attr__( 'Private Post', 'anspress-question-answer' );
			}

			echo '<script>
				jQuery( document ).ready( function() {
					jQuery( "select#post_status" ).append( "<option value=\'moderate\'' . ( 'moderate' === $post->post_status ? ' selected=\'selected\'' : '' ) . '>' . esc_attr__( 'Moderate', 'anspress-question-answer' ) . '</option>" );
					jQuery( "select#post_status" ).append( "<option value=\'private_post\'' . ( 'private_post' === $post->post_status ? ' selected=\'selected\'' : '' ) . '>' . esc_attr__( 'Private Post', 'anspress-question-answer' ) . '</option>" );'
					. ( ( 'moderate' === $post->post_status || 'private_post' === $post->post_status ) ? 'jQuery( "select#post_status" ).closest( ".misc-pub-section" ).find( "#post-status-display" ).html( "' . esc_html( $label ) . '" );' : '' ) . '
				} );
			</script>';
		}
	}

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