AnsPress::instance()

Description #

Initializes the plugin by setting localization, hooks, filters, and administrative functions.

Source #

File: anspress-question-answer.php

		public static function instance() {
			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
				self::$instance = new self();
				self::$instance->setup_constants();
				self::$instance->actions = array();
				self::$instance->filters = array();

				self::$instance->includes();
				self::$instance->session = AnsPress\Session::init();

				self::$instance->site_include();
				self::$instance->ajax_hooks();
				AnsPress_PostTypes::init();

				// Add roles.
				$ap_roles = new AP_Roles();
				$ap_roles->add_roles();
				$ap_roles->add_capabilities();

				/*
				* Dashboard and Administrative Functionality
				*/
				if ( is_admin() ) {
					require_once ANSPRESS_DIR . 'admin/anspress-admin.php';
					require_once ANSPRESS_DIR . 'admin/class-list-table-hooks.php';

					AnsPress_Admin::init();
					AnsPress_Post_Table_Hooks::init();
				}

				new AnsPress_Process_Form();

				/*
				 * Hooks for extension to load their codes after AnsPress is loaded.
				 */
				do_action( 'anspress_loaded' );

				if ( class_exists( 'WP_CLI' ) ) {
					WP_CLI::add_command( 'anspress', 'AnsPress_Cli' );
				}
			}

			return self::$instance;
		}

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