Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

BP_Admin_Types::handle_action( string $action )

Handle BP Type actions.


Parameters Parameters

$action

(string) (Required) Required. The action to handle ('add-tag', 'editedtag' or 'delete' ).


Source Source

File: bp-core/classes/class-bp-admin-types.php

	private function handle_action( $action ) {
		$referer = wp_get_referer();

		if ( ! bp_current_user_can( 'bp_moderate' ) ) {
			return;
		}

		// Adding a new type into the database.
		if ( 'add-tag' === $action ) {
			check_admin_referer( 'add-tag', '_wpnonce_add-tag' );

			$result = bp_core_admin_insert_type( $_POST );

			if ( is_wp_error( $result ) ) {
				$referer = add_query_arg(
					array_merge(
						$result->get_error_data(),
						array(
							'error' => 1,
						)
					),
					$referer
				);

				wp_safe_redirect( $referer );
				exit;
			}

			wp_safe_redirect( add_query_arg( 'message', 2, $referer ) );
			exit;

			// Updating an existing type intot the Database.
		} elseif ( 'editedtag' === $action ) {
			$args                 = $_POST;
			$args['type_term_id'] = 0;
			unset( $args['tag_ID'] );

			if ( isset( $_POST['tag_ID'] ) ) {
				$args['type_term_id'] = $_POST['tag_ID'];
			}

			if ( isset( $_POST['taxonomy'] ) ) {
				$args['taxonomy'] = $_POST['taxonomy'];
			}

			check_admin_referer( 'update-tag_' . $args['type_term_id'] );

			$result = bp_core_admin_update_type( $args );

			if ( is_wp_error( $result ) ) {
				$referer = add_query_arg(
					array_merge(
						$result->get_error_data(),
						array(
							'error' => 1,
						)
					),
					$referer
				);

				wp_safe_redirect( $referer );
				exit;
			}

			wp_safe_redirect( add_query_arg( 'message', 4, $referer ) );
			exit;

			// Deletes a type.
		} elseif ( 'delete' === $action ) {
			$args                 = $_GET;
			$args['type_term_id'] = 0;
			unset( $args['tag_ID'] );

			if ( isset( $_GET['tag_ID'] ) ) {
				$args['type_term_id'] = $_GET['tag_ID'];
			}

			if ( isset( $_GET['taxonomy'] ) ) {
				$args['taxonomy'] = $_GET['taxonomy'];
			}

			check_admin_referer( 'delete-tag_' . $args['type_term_id'] );
			$referer = remove_query_arg( array( 'action', 'tag_ID', '_wpnonce' ), $referer );

			// Delete the type.
			$result = bp_core_admin_delete_type( $args );

			if ( is_wp_error( $result ) ) {
				$referer = add_query_arg(
					array_merge(
						$result->get_error_data(),
						array(
							'error' => 1,
						)
					),
					$referer
				);

				wp_safe_redirect( $referer );
				exit;
			}

			wp_safe_redirect( add_query_arg( 'message', 9, $referer ) );
			exit;
		}
	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.