AnsPress_Admin::options_general_pages()

Description #

Register AnsPress general pages options.

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: admin/anspress-admin.php

	public static function options_general_pages() {
		$opt  = ap_opt();
		$form = array(
			'submit_label' => __( 'Save Pages', 'anspress-question-answer' ),
			'fields'       => array(
				'author_credits' => array(
					'label' => __( 'Hide author credits', 'anspress-question-answer' ),
					'desc'  => __( 'Hide link to AnsPress project site.', 'anspress-question-answer' ),
					'type'  => 'checkbox',
					'order' => 0,
					'value' => $opt['author_credits'],
				),
				'sep-warning'    => array(
					'html' => '<div class="ap-uninstall-warning">' . __( 'If you have created main pages manually then make sure to have [anspress] shortcode in all pages.', 'anspress-question-answer' ) . '</div>',
				),
			),
		);

		foreach ( ap_main_pages() as $slug => $args ) {
			$value = isset( $opt[ $slug ] ) ? $opt[ $slug ] : '';

			$form['fields'][ $slug ] = array(
				'label'      => $args['label'],
				'desc'       => $args['desc'],
				'type'       => 'select',
				'options'    => 'posts',
				'posts_args' => array(
					'post_type' => 'page',
					'showposts' => -1,
				),
				'value'      => $value,
				'sanitize'   => 'absint',
			);
		}

		/**
		 * Filter to override pages options form.
		 *
		 * @param array $form Form arguments.
		 * @since 4.1.0
		 */
		return apply_filters( 'ap_options_form_pages', $form );
	}

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