Skip to content

Commit

Permalink
WP Telegram | Allow partial input in REST API requests (#113)
Browse files Browse the repository at this point in the history
* WP Telegram | Allow partial input in REST API requests

* Add changeset

* Merge form data with existing
  • Loading branch information
irshadahmad21 authored Feb 21, 2024
1 parent a056899 commit 9594d18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-fishes-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wptelegram": patch
---

Fixed PHP errors in Post to Telegram for partial REST API input
11 changes: 7 additions & 4 deletions plugins/wptelegram/src/modules/p2tg/PostSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,15 @@ public function set_form_data() {
$data = $body[ Main::PREFIX ];

$form_data = MainUtils::sanitize( $data );
// Sanitize the template separately.
$form_data['message_template'] = MainUtils::sanitize_message_template( $data['message_template'] );

$form_data['send2tg'] = $form_data['send2tg'] ? 'yes' : 'no';
if ( isset( $data['message_template'] ) ) {
// Sanitize the template separately.
$form_data['message_template'] = MainUtils::sanitize_message_template( $data['message_template'] );
}

$form_data['send2tg'] = ! empty( $form_data['send2tg'] ) ? 'yes' : 'no';

$this->form_data = $form_data;
$this->form_data = array_merge( $this->form_data, $form_data );
// For logging.
$this->form_data['is_from_gb'] = true;
}
Expand Down

0 comments on commit 9594d18

Please sign in to comment.