bp_core_optouts_admin_manage( string $action = '' )

This is the confirmation screen for actions.


Parameters Parameters

$action

(string) (Optional) Delete or resend optout.

Default value: ''


Top ↑

Return Return

(null|false)


Source Source

File: bp-core/admin/bp-core-admin-optouts.php

function bp_core_optouts_admin_manage( $action = '' ) {
	$capability = bp_core_do_network_admin() ? 'manage_network_options' : 'manage_options';
	if ( ! current_user_can( $capability ) || empty( $action ) ) {
		die( '-1' );
	}

	// Get the IDs from the URL.
	$ids = false;
	if ( ! empty( $_POST['optout_ids'] ) ) {
		$ids = wp_parse_id_list( $_POST['optout_ids'] );
	} elseif ( ! empty( $_GET['optout_id'] ) ) {
		$ids = absint( $_GET['optout_id'] );
	}

	if ( empty( $ids ) ) {
		return false;
	}

	// Query for matching optouts, and filter out bad IDs.
	$args = array(
		'id'     => $ids,
	);
	$optouts    = bp_get_optouts( $args );
	$optout_ids = wp_list_pluck( $optouts, 'id' );

	// Check optout IDs and set up strings.
	switch ( $action ) {
		case 'delete' :
			if ( 0 === count( $optouts ) ) {
				$helper_text = __( 'No opt-out requests were found.', 'buddypress' );
			} else {
				$helper_text = _n( 'You are about to delete the following opt-out request:', 'You are about to delete the following opt-out requests:', count( $optouts ), 'buddypress' );
			}
			break;
	}

	// These arguments are added to all URLs.
	$url_args = array( 'page' => 'bp-optouts' );

	// These arguments are only added when performing an action.
	$action_args = array(
		'action'     => 'do_' . $action,
		'optout_ids' => implode( ',', $optout_ids )
	);

	if ( is_network_admin() ) {
		$base_url = network_admin_url( 'admin.php' );
	} else {
		$base_url = bp_get_admin_url( 'tools.php' );
	}

	$cancel_url = add_query_arg( $url_args, $base_url );
	$action_url = wp_nonce_url(
		add_query_arg(
			array_merge( $url_args, $action_args ),
			$base_url
		),
		'optouts_' . $action
	);

	?>

	<div class="wrap">
		<h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress tools', 'buddypress' ); ?></h1>
		<hr class="wp-header-end">

		<h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Manage Opt-outs', 'buddypress' ), 'tools' ); ?></h2>

		<p><?php echo esc_html( $helper_text ); ?></p>

		<ol class="bp-optouts-list">
		<?php foreach ( $optouts as $optout ) :	?>

			<li>
				<strong><?php echo esc_html( $optout->email_address ) ?></strong>
				<p class="description">
					<?php
					$last_modified = mysql2date( 'Y/m/d g:i:s a', $optout->date_modified );
					/* translators: %s: modification date */
					printf( esc_html__( 'Date modified: %s', 'buddypress'), $last_modified );
					?>
				</p>
			</li>

		<?php endforeach; ?>
		</ol>

		<?php if ( 'delete' === $action && count( $optouts ) ) : ?>

			<p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p>

		<?php endif ; ?>

		<?php if ( count( $optouts ) ) : ?>

			<a class="button-primary" href="<?php echo esc_url( $action_url ); ?>"><?php esc_html_e( 'Confirm', 'buddypress' ); ?></a>

		<?php endif; ?>

		<a class="button" href="<?php echo esc_url( $cancel_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ) ?></a>
	</div>

	<?php
}


Top ↑

Changelog Changelog

Changelog
Version Description
8.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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