PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / trunk
bBlocks – Essential Gutenberg Blocks & Patterns Collection vtrunk
2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 106 releases
b-blocks / includes / Ajax.php

Ajax.php in bBlocks – Essential Gutenberg Blocks & Patterns Collection trunk, at includes/Ajax.php

25 lines 560 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace BBlocks\Inc;
3
4 class BBlocksAjax{
5 function __construct(){
6 add_action( 'wp_ajax_bBlocksUserRoles', [$this, 'bBlocksUserRoles'] );
7 }
8
9 function bBlocksUserRoles(){
10 $nonce = sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? '' ) );
11
12 if( !wp_verify_nonce( $nonce, 'wp_ajax' )){
13 wp_send_json_error( 'Invalid Request' );
14 }
15
16 if ( !current_user_can( 'edit_posts' ) ) {
17 wp_send_json_error( 'Unauthorized' );
18 }
19
20 global $wp_roles;
21 wp_send_json_success( $wp_roles->get_names() );
22 }
23 }
24
25 new BBlocksAjax();