v1.8.1: allow media-only beeps (image/GIF/voice/quote/poll without text)

- PHP: submit_beep accepts empty content when any attachment flag is set
- JS: composer button enables when text is empty but media is attached
- JS: button refreshes on every media state change via custom event
- Version bump + readme changelog
This commit is contained in:
Krystie
2026-07-04 00:41:33 -07:00
parent 5bb39316b1
commit 64344bfef6
4 changed files with 74 additions and 8 deletions
+15 -3
View File
@@ -37,9 +37,6 @@ class Beep_Replies {
public static function submit_beep($request) {
$content = sanitize_textarea_field($request->get_param('content'));
if (empty($content)) {
return new WP_Error('empty_content', 'Beep cannot be empty.', ['status' => 400]);
}
if (mb_strlen($content) > BEEP_CHAR_LIMIT) {
return new WP_Error('content_too_long', 'Beep exceeds ' . BEEP_CHAR_LIMIT . ' character limit.', ['status' => 400]);
}
@@ -48,6 +45,21 @@ class Beep_Replies {
$quote_id = $request->get_param('quote_id');
$gif_url = $request->get_param('gif_url');
// Allow empty content when media / quote / gif / poll / voice / video is attached.
// The composer is expected to gate this client-side too, but the server is the source of truth.
$has_payload = (
$content !== ''
|| ($quote_id && is_numeric($quote_id))
|| ($gif_url && filter_var($gif_url, FILTER_VALIDATE_URL))
|| !empty($request->get_param('has_images'))
|| !empty($request->get_param('has_voice'))
|| !empty($request->get_param('has_video'))
|| !empty($request->get_param('has_poll'))
);
if (!$has_payload) {
return new WP_Error('empty_content', 'Beep cannot be empty.', ['status' => 400]);
}
$post_id = wp_insert_post([
'post_type' => 'beep',
'post_content' => $content,