BP_Invites_Component::late_includes()

Late includes method.

Description

Only load up certain code when on specific pages.

Source

File: bp-invites/classes/class-bp-invites-component.php

	public function late_includes() {
		// Bail if PHPUnit is running.
		if ( defined( 'BP_TESTS_DIR' ) ) {
			return;
		}

		// Bail if not on Settings component.
		if ( ! bp_is_invites_component() ) {
			return;
		}

		$actions = array( 'invites', 'sent-invites', 'send-invites' );

		// Authenticated actions.
		if ( is_user_logged_in() ) {
			if ( ! bp_current_action() || bp_is_current_action( 'invites' ) ) {
				require $this->path . 'bp-invites/actions/invites.php';

				// Specific to post requests.
			} elseif ( bp_is_post_request() && in_array( bp_current_action(), $actions, true ) ) {
				require $this->path . 'bp-invites/actions/' . bp_current_action() . '.php';
			}

			if ( is_user_logged_in() &&
			     in_array( bp_current_action(), array( 'revoke-invite' ), true )
			) {
				require $this->path . 'bp-invites/actions/' . bp_current_action() . '.php';
			}

			if ( is_user_logged_in() &&
			     in_array( bp_current_action(), array( 'revoke-invite-admin' ), true )
			) {
				require $this->path . 'bp-invites/actions/' . bp_current_action() . '.php';
			}
		}

		// Screens - User profile integration.
		if ( bp_is_user() ) {
			require $this->path . 'bp-invites/screens/send-invites.php';

			// Sub-nav items.
			if ( in_array( bp_current_action(), $actions, true ) ) {
				require $this->path . 'bp-invites/screens/' . bp_current_action() . '.php';
			}
		}

	}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.