# b-blocks/2.0.40/includes/Ajax.php

bBlocks – Essential Gutenberg Blocks &amp; Patterns Collection, version 2.0.40. 22 lines.

- Page: https://pluginprobe.com/plugins/b-blocks/2.0.40/code/includes/Ajax.php
- Raw: https://pluginprobe.com/plugins/b-blocks/2.0.40/raw/includes/Ajax.php
- Modified: 2026-04-29T03:40:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/b-blocks/2.0.40/code/includes/Ajax.php#L10-L20`.

```php
<?php
namespace BBlocks\Inc;

class BBlocksAjax{
	function __construct(){
		add_action( 'wp_ajax_bBlocksUserRoles', [$this, 'bBlocksUserRoles'] );
		add_action( 'wp_ajax_nopriv_bBlocksUserRoles', [$this, 'bBlocksUserRoles'] );
	}

	function bBlocksUserRoles(){
		$nonce = sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) ?? null;

		if( !wp_verify_nonce( $nonce, 'wp_ajax' )){
			wp_send_json_error( 'Invalid Request' );
		}

		global $wp_roles;
		wp_send_json_success( $wp_roles->get_names() );
	}
}

new BBlocksAjax();
```
