bp_activity_admin_edit_metabox_type( object $item )

Activity type metabox for the Activity admin edit screen.

Description

Parameters

$item

(object) (Required) Activity item.

Source

File: bp-activity/bp-activity-admin.php

function bp_activity_admin_edit_metabox_type( $item ) {
	$bp = buddypress();

	$actions  = array();
	$selected = $item->type;

	// Walk through the registered actions, and build an array of actions/values.
	foreach ( bp_activity_get_actions() as $action ) {
		$action = array_values( (array) $action );

		for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
			$actions[ $action[$i]['key'] ] = $action[$i]['value'];
	}

	// This was a mis-named activity type from before BP 1.6.
	unset( $actions['friends_register_activity_action'] );

	// Sort array by the human-readable value.
	natsort( $actions );

	/*
	 * If the activity type is not registered properly (eg, a plugin has
	 * not called bp_activity_set_action()), add the raw type to the end
	 * of the list.
	 */
	if ( ! isset( $actions[ $selected ] ) ) {
		_doing_it_wrong( __FUNCTION__, sprintf( __( 'This activity item has a type (%s) that is not registered using bp_activity_set_action(), so no label is available.', 'buddyboss' ), $selected ), '2.0.0' );
		$actions[ $selected ] = $selected;
	}

	?>

	<label for="bp-activities-type" class="screen-reader-text"><?php
		/* translators: accessibility text */
		esc_html_e( 'Select activity type', 'buddyboss' );
	?></label>
	<select name="bp-activities-type" id="bp-activities-type">
		<?php foreach ( $actions as $k => $v ) : ?>
			<option value="<?php echo esc_attr( $k ); ?>" <?php selected( $k,  $selected ); ?>><?php echo esc_html( $v ); ?></option>
		<?php endforeach; ?>
	</select>

<?php
}

Changelog

Changelog
Version Description
BuddyPress 1.6.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.