PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 2.1.7
bBlocks – Essential Gutenberg Blocks & Patterns Collection v2.1.7
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 1.5.4 All 107 releases
← All changes | includes/ApiKeys.php +14 -5 2.0.432.1.7 View file →
@@ -2,9 +2,9 @@
2 2 namespace BBlocks\Inc;
3 3 class BBlocksApiKeys{
4 4 function __construct(){
5 5 add_action( 'wp_ajax_bblocks_api_keys', [$this, 'bBlocksApiKeys'] );
6 - add_action( 'wp_ajax_nopriv_bblocks_api_keys', [$this, 'bBlocksApiKeys'] );
6 + // nopriv hook intentionally omitted — this action requires manage_options capability.
7 7 }
8 8
9 9 function bBlocksTestApiKeys($key,$value){
10 10 if ($key == 'openAi') {
@@ -9,8 +9,11 @@
9 9 function bBlocksTestApiKeys($key,$value){
10 10 if ($key == 'openAi') {
11 11 return BBlocksAi::get_instance()->test_api_key($value);
12 12 }
13 + if ($key == 'instagram') {
14 + return BBlocksInstagram::test_token($value);
15 + }
13 16 }
14 17
15 18 function bBlocksApiKeys(){
16 19 $nonce = sanitize_text_field( wp_unslash( $_POST['_wpnonce']?? null ) ) ;
@@ -25,13 +28,19 @@
25 28
26 29 $key = sanitize_text_field(wp_unslash($_POST['key'] ?? ''));
27 30 $value = sanitize_text_field(wp_unslash($_POST['value'] ?? ''));
28 31 $apiKeys = get_option('bBlocksApiKeys',[]);
29 - $error = $this->bBlocksTestApiKeys($key,$value);
30 -
31 - if (isset($error['valid']) && !$error['valid']) {
32 - wp_send_json_error([$key=>$error]);
32 +
33 + if ( '' !== $value ) {
34 + $error = $this->bBlocksTestApiKeys($key,$value);
35 +
36 + if (isset($error['valid']) && !$error['valid']) {
37 + wp_send_json_error([$key=>$error]);
38 + }
39 + } elseif ( 'instagram' === $key && class_exists( __NAMESPACE__ . '\BBlocksInstagram' ) ) {
40 + BBlocksInstagram::flush();
33 41 }
42 +
34 43 if ($key) {
35 44 $apiKeys[$key] = ['key'=> $value];
36 45 update_option( 'bBlocksApiKeys',$apiKeys);
37 46 }