AnsPress_PostTypes::question_perm_structure()

Description #

Return question permalink structure.

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: includes/post-types.php

	public static function question_perm_structure() {
		$question_permalink = ap_opt( 'question_page_permalink' );
		$question_slug      = ap_get_page_slug( 'question' );

		$rewrites = array();
		if ( 'question_perma_2' === $question_permalink ) {
			$rewrites['rule'] = $question_slug . '/%question%';
		} elseif ( 'question_perma_3' === $question_permalink ) {
			$rewrites['rule'] = $question_slug . '/%question_id%';
		} elseif ( 'question_perma_4' === $question_permalink ) {
			$rewrites['rule'] = $question_slug . '/%question_id%/%question%';
		} elseif ( 'question_perma_5' === $question_permalink ) {
			$rewrites['rule'] = $question_slug . '/%question%/%question_id%';
		} elseif ( 'question_perma_6' === $question_permalink ) {
			$rewrites['rule'] = $question_slug . '/%question_id%-%question%';
		} elseif ( 'question_perma_7' === $question_permalink ) {
			$rewrites['rule'] = $question_slug . '/%question%-%question_id%';
		} else {
			$rewrites['rule'] = ap_base_page_slug() . '/' . $question_slug . '/%question%';
		}

		/**
		 * Allows filtering question permalink structure.
		 *
		 * @param array $rewrite Question permalink structure.
		 * @since 4.1.0
		 */
		return (object) apply_filters( 'ap_question_perm_structure', $rewrites );
	}

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