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

bBlocks – Essential Gutenberg Blocks &amp; Patterns Collection, version 2.1.3. 25 lines.

- Page: https://pluginprobe.com/plugins/b-blocks/2.1.3/code/includes/Ajax.php
- Raw: https://pluginprobe.com/plugins/b-blocks/2.1.3/raw/includes/Ajax.php
- Modified: 2026-09-02T03:17:32+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.1.3/code/includes/Ajax.php#L10-L20`.

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