Filter Uncanny Redemption Codes

bulk_actions-{$this->screen->id}

Filters the available bulk actions for a specific admin screen, allowing modification before they are displayed.

add_filter( 'bulk_actions-{$this->screen->id}', $callback, 10, 1 );

Description

Fires when displaying bulk action dropdowns in the WordPress admin list table. Developers can use this filter to add, remove, or modify available bulk actions for specific admin screens. The $this parameter refers to the list table instance.


Usage

add_filter( 'bulk_actions-{$this->screen->id}', 'your_function_name', 10, 1 );

Parameters

$this (mixed)
This parameter contains an array of available bulk actions for the current screen.

Return Value

The filtered value.


Examples

add_filter( 'bulk_actions-edit-my_custom_post_type', 'my_custom_post_type_add_bulk_action', 10, 1 );

/**
 * Adds a custom bulk action to the 'my_custom_post_type' admin screen.
 *
 * @param array $bulk_actions An array of existing bulk actions.
 * @return array The modified array of bulk actions, including the new custom action.
 */
function my_custom_post_type_add_bulk_action( $bulk_actions ) {
	// Check if the current screen is indeed the 'edit-my_custom_post_type' screen.
	// While the hook itself usually ensures this, an extra check can be good practice
	// if this function might be reused elsewhere or if there's any doubt.
	// In a real-world scenario, you'd likely already be in the context of the CPT edit screen.

	// Add a new bulk action.
	// The key 'duplicate_selected' is the value that will be sent when the action is chosen.
	// The value 'Duplicate Selected Items' is the display text for the option.
	$bulk_actions['duplicate_selected'] = __( 'Duplicate Selected Items', 'your-text-domain' );

	// You could also remove existing actions if needed, for example:
	// unset( $bulk_actions['edit'] );

	return $bulk_actions;
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/classes/admin/class-view-groups.php:305
src/classes/admin/class-view-codes.php:314

protected function bulk_actions( $which = '' ) {
		if ( is_null( $this->_actions ) ) {
			$no_new_actions = $this->_actions = $this->get_bulk_actions();
			$this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
			$this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
			$two            = '';
		} else {
			$two = '2';
		}

		if ( empty( $this->_actions ) ) {
			return;
		}

		echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
		echo '<div class="uncannyowl-custom-select">';
		echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . '" class="uncannyowl-select-input">';
		echo '<option value="-1" data-placeholder="true">' . __( 'Bulk actions' ) . '</option>';

		foreach ( $this->_actions as $name => $title ) {
			$class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
			$icon = $this->get_bulk_action_icon( $name );

			echo '<option value="' . $name . '"' . $class . ' data-icon="' . $icon . '">' . $title . '</option>';
		}

		echo '</select>';
		echo '<div class="uncannyowl-select-arrow">';
		echo '<svg width="12" height="8" viewBox="0 0 12 8" fill="none">';
		echo '<path d="M1 1.5L6 6.5L11 1.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>';
		echo '</svg>';
		echo '</div>';
		echo '</div>';

		submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
		echo "n";
	}

Scroll to Top