Skip to content

Commit

Permalink
Fix the images being retained in post content links (#63)
Browse files Browse the repository at this point in the history
* Fix the images being retained in post content links

* Prepare for v4.0.7

---------

Co-authored-by: irshadahmad21 <irshadahmad21@users.noreply.github.com>
  • Loading branch information
irshadahmad21 and irshadahmad21 authored Mar 3, 2023
1 parent 54ab86e commit 9eb5097
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
**Requires at least:** 5.8
**Requires PHP:** 7.2
**Tested up to:** 6.1.1
**Stable tag:** 4.0.6
**Stable tag:** 4.0.7
**License:** GPLv2 or later
**License URI:** [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)

Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project are documented in this file.

## Unreleased

## [4.0.7 - 2023-03-3](https://github.com/wpsocio/wptelegram/releases/tag/v4.0.7)

### Bug fixes

- Fixed the issue of images being retained in post content links

## [4.0.6 - 2023-03-2](https://github.com/wpsocio/wptelegram/releases/tag/v4.0.6)

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wptelegram/core",
"version": "4.0.6",
"version": "4.0.7",
"description": "Integrate your WordPress site perfectly with Telegram with full control.",
"require-dev": {
"wp-coding-standards/wpcs": "*"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wptelegram",
"title": "WP Telegram",
"version": "4.0.6",
"version": "4.0.7",
"description": "Integrate your WordPress site perfectly with Telegram with full control.",
"repository": {
"type": "git",
Expand Down
5 changes: 4 additions & 1 deletion src/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: telegram, notifications, posts, channel, group
Requires at least: 5.8
Requires PHP: 7.2
Tested up to: 6.1.1
Stable tag: 4.0.6
Stable tag: 4.0.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -205,6 +205,9 @@ Yes, all you need to do is to setup **Private Notifications** module and use the

== Changelog ==

= 4.0.7 =
- Fixed the issue of images being retained in post content links

= 4.0.6 =
- Fixed the issue of shortcodes being sent to Telegram

Expand Down
6 changes: 6 additions & 0 deletions src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project are documented in this file.

## Unreleased

## [4.0.7 - 2023-03-3](https://github.com/wpsocio/wptelegram/releases/tag/v4.0.7)

### Bug fixes

- Fixed the issue of images being retained in post content links

## [4.0.6 - 2023-03-2](https://github.com/wpsocio/wptelegram/releases/tag/v4.0.6)

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion src/includes/format-text
4 changes: 2 additions & 2 deletions src/languages/wptelegram.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/wpsocio/wptelegram\n"
"POT-Creation-Date: 2023-03-02 16:18:32+00:00\n"
"POT-Creation-Date: 2023-03-03 10:00:32+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2023-03-2 16:180\n"
"PO-Revision-Date: 2023-03-3 10:00\n"
"Last-Translator: WP Telegram\n"
"Language-Team: WP Telegram\n"
"Language: en_US\n"
Expand Down
53 changes: 34 additions & 19 deletions src/modules/notify/NotifySender.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,15 @@ private function prepare_default_responses() {

if ( ! empty( $text ) ) {

$parse_mode = Utils::valid_parse_mode( $this->module->options()->get( 'parse_mode', 'HTML' ) );

$options = [
'format_to' => $parse_mode,
'id' => 'p2tg',
'limit' => Utils::get_max_text_length( 'text' ),
'limit_by' => 'chars',
];

$text = Utils::prepare_content( $text, $options );

$disable_web_page_preview = true;
$options = $this->get_prepare_content_options( Utils::get_max_text_length( 'text' ) );

$this->responses = [
[
'sendMessage' => compact( 'text', 'parse_mode', 'disable_web_page_preview' ),
'sendMessage' => [
'text' => Utils::prepare_content( $text, $options ),
'parse_mode' => $options['format_to'],
'disable_web_page_preview' => true,
],
],
];
}
Expand Down Expand Up @@ -260,15 +253,10 @@ private function get_response_text( $template ) {
* @return string The text for the given macro.
*/
private function get_macro_value( $macro ) {
$parse_mode = Utils::valid_parse_mode( $this->module->options()->get( 'parse_mode', 'HTML' ) );

$value = '';

$options = [
'format_to' => $parse_mode,
'id' => 'notify',
'limit' => 0,
];
$options = $this->get_prepare_content_options();

switch ( $macro ) {
case 'email_message':
Expand All @@ -287,6 +275,33 @@ private function get_macro_value( $macro ) {
return apply_filters( "wptelegram_notify_macro_{$macro}_value", $value, $this->wp_mail_args, $this->module->options() );
}


/**
* Get the options for prepare_content
*
* @since 4.0.7
*
* @param int $limit The limit.
*
* @return array
*/
private function get_prepare_content_options( $limit = 0 ) {
$parse_mode = Utils::valid_parse_mode( $this->module->options()->get( 'parse_mode', 'HTML' ) );

$options = [
'format_to' => $parse_mode,
'id' => 'notify',
'limit' => $limit,
'limit_by' => 'chars',
'images_in_links' => [
'title_or_alt' => 'retain',
'lone_image_link' => 'retain',
],
];

return apply_filters( 'wptelegram_notify_prepare_content_options', $options, $limit, $this->wp_mail_args, $this->chats2emails, $this->module->options() );
}

/**
* Prepare the email message.
*
Expand Down
4 changes: 2 additions & 2 deletions src/wptelegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: WP Telegram
* Plugin URI: https://t.me/WPTelegram
* Description: Integrate your WordPress website perfectly with Telegram. Send posts automatically to Telegram when published or updated, whether to a Telegram Channel, Group or private chat, with full control. Get your email notifications on Telegram.
* Version: 4.0.6
* Version: 4.0.7
* Requires at least: 5.8
* Requires PHP: 7.2
* Author: WP Socio
Expand All @@ -26,7 +26,7 @@
die;
}

define( 'WPTELEGRAM_VER', '4.0.6' );
define( 'WPTELEGRAM_VER', '4.0.7' );

defined( 'WPTELEGRAM_MAIN_FILE' ) || define( 'WPTELEGRAM_MAIN_FILE', __FILE__ );

Expand Down

0 comments on commit 9eb5097

Please sign in to comment.