PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 2.1.8
bBlocks – Essential Gutenberg Blocks & Patterns Collection v2.1.8
2.1.8 2.1.7 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 All 108 releases
← All changes | includes/Ajax.php +39 -24 2.1.7 → 2.1.8 View file →
@@ -1,25 +1,40 @@
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 -
1 +<?php
2 +namespace BBlocks\Inc;
3 +
4 +class BBlocksAjax{
5 + function __construct(){
6 + add_action( 'wp_ajax_bBlocksUserRoles', [$this, 'bBlocksUserRoles'] );
7 + add_action( 'wp_ajax_bBlocksPipeChecker', [$this, 'bBlocksPipeChecker'] );
8 + add_action( 'wp_ajax_nopriv_bBlocksPipeChecker', [$this, 'bBlocksPipeChecker'] );
9 + }
10 +
11 + function bBlocksUserRoles(){
12 + $nonce = sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ?? '' ) );
13 +
14 + if( !wp_verify_nonce( $nonce, 'wp_ajax' )){
15 + wp_send_json_error( 'Invalid Request' );
16 + }
17 +
18 + if ( !current_user_can( 'edit_posts' ) ) {
19 + wp_send_json_error( 'Unauthorized' );
20 + }
21 +
22 + global $wp_roles;
23 + wp_send_json_success( $wp_roles->get_names() );
24 + }
25 +
26 + function bBlocksPipeChecker()
27 + {
28 + $nonce = sanitize_text_field(wp_unslash($_POST['_wpnonce'] ?? null ));
29 +
30 + if (!wp_verify_nonce($nonce, 'wp_ajax')) {
31 + wp_send_json_error('Invalid Request');
32 + }
33 +
34 + wp_send_json_success([
35 + 'isPipe' => Utils::isPro()
36 + ]);
37 + }
38 +}
39 +
25 40 new BBlocksAjax();