← All changes
|
includes/Core/Integration/Telegram/TelegramHandler.php
+6
-27
3.3.1
→
2.15.3
View file →
| @@ -6,15 +6,10 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\Telegram; |
| 9 | 9 | |
| 10 | -if (!defined('ABSPATH')) { | |
| 11 | - exit; | |
| 12 | -} | |
| 13 | - | |
| 14 | 10 | use BitCode\BitForm\Core\Integration\IntegrationHandler; |
| 15 | 11 | use BitCode\BitForm\Core\Util\HttpHelper; |
| 16 | -use BitCode\BitForm\GlobalHelper; | |
| 17 | 12 | use WP_Error; |
| 18 | 13 | |
| 19 | 14 | /** |
| 20 | 15 | * Provide functionality for Telegram integration |
| @@ -49,17 +44,11 @@ | ||
| 49 | 44 | */ |
| 50 | 45 | public static function telegramAuthorize() |
| 51 | 46 | { |
| 52 | 47 | $authorizationHeader = null; |
| 53 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 54 | - GlobalHelper::requirePostMethod(); | |
| 55 | - | |
| 56 | - try { | |
| 57 | - $requestsParams = GlobalHelper::formatRequestData(); | |
| 58 | - } catch (\InvalidArgumentException $e) { | |
| 59 | - wp_send_json_error($e->getMessage(), 400); | |
| 60 | - } | |
| 61 | - | |
| 48 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 49 | + $inputJSON = file_get_contents('php://input'); | |
| 50 | + $requestsParams = json_decode($inputJSON); | |
| 62 | 51 | if ( |
| 63 | 52 | empty($requestsParams->bot_api_key) |
| 64 | 53 | ) { |
| 65 | 54 | wp_send_json_error( |
| @@ -112,16 +101,11 @@ | ||
| 112 | 101 | public static function refreshGetUpdates() |
| 113 | 102 | { |
| 114 | 103 | $authorizationHeader = null; |
| 115 | 104 | $response = null; |
| 116 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 117 | - GlobalHelper::requirePostMethod(); | |
| 118 | - | |
| 119 | - try { | |
| 120 | - $requestsParams = GlobalHelper::formatRequestData(); | |
| 121 | - } catch (\InvalidArgumentException $e) { | |
| 122 | - wp_send_json_error($e->getMessage(), 400); | |
| 123 | - } | |
| 105 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 106 | + $inputJSON = file_get_contents('php://input'); | |
| 107 | + $requestsParams = json_decode($inputJSON); | |
| 124 | 108 | if ( |
| 125 | 109 | empty($requestsParams->bot_api_key) |
| 126 | 110 | ) { |
| 127 | 111 | wp_send_json_error( |
| @@ -144,13 +128,8 @@ | ||
| 144 | 128 | if (!empty($list->my_chat_member->chat->title) && !empty($list->my_chat_member->chat->id)) { |
| 145 | 129 | $allList[$list->my_chat_member->chat->title] = (object) [ |
| 146 | 130 | 'id' => $list->my_chat_member->chat->id, |
| 147 | 131 | 'name' => $list->my_chat_member->chat->title, |
| 148 | - ]; | |
| 149 | - } elseif (isset($list->channel_post->chat->title, $list->channel_post->chat->id)) { | |
| 150 | - $allList[$list->channel_post->chat->title] = (object) [ | |
| 151 | - 'id' => $list->channel_post->chat->id, | |
| 152 | - 'name' => $list->channel_post->chat->title, | |
| 153 | 132 | ]; |
| 154 | 133 | } |
| 155 | 134 | } |
| 156 | 135 | uksort($allList, 'strnatcasecmp'); |