ActionScheduler_Abstract_ListTable::maybe_render_actions()protectedWC 1.0

Renders the row-actions.

This method renders the action menu, it reads the definition from the $row_actions property, and it checks that the row action method exists before rendering it.

Method of the class: ActionScheduler_Abstract_ListTable{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->maybe_render_actions( $row, $column_name );
$row(array) (required)
Row to be rendered.
$column_name(string) (required)
Column name.

ActionScheduler_Abstract_ListTable::maybe_render_actions() code WC 8.7.0

protected function maybe_render_actions( $row, $column_name ) {
	if ( empty( $this->row_actions[ $column_name ] ) ) {
		return;
	}

	$row_id = $row[ $this->ID ];

	$actions      = '<div class="row-actions">';
	$action_count = 0;
	foreach ( $this->row_actions[ $column_name ] as $action_key => $action ) {

		$action_count++;

		if ( ! method_exists( $this, 'row_action_' . $action_key ) ) {
			continue;
		}

		$action_link = ! empty( $action['link'] ) ? $action['link'] : add_query_arg(
			array(
				'row_action' => $action_key,
				'row_id'     => $row_id,
				'nonce'      => wp_create_nonce( $action_key . '::' . $row_id ),
			)
		);
		$span_class  = ! empty( $action['class'] ) ? $action['class'] : $action_key;
		$separator   = ( $action_count < count( $this->row_actions[ $column_name ] ) ) ? ' | ' : '';

		$actions .= sprintf( '<span class="%s">', esc_attr( $span_class ) );
		$actions .= sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', esc_url( $action_link ), esc_attr( $action['desc'] ), esc_html( $action['name'] ) );
		$actions .= sprintf( '%s</span>', $separator );
	}
	$actions .= '</div>';
	return $actions;
}