Skip to content

Commit

Permalink
Add support for <blockquote> tag (#73)
Browse files Browse the repository at this point in the history
* Extract send_files_by_url logic

* Update gulpfile.esm.js

* Update translations

* Update RulesController.php

* Update format-text

* Update format-text

* Add support for `<blockquote>` tag

* Prepare for v4.0.14

---------

Co-authored-by: irshadahmad21 <[email protected]>
  • Loading branch information
irshadahmad21 and irshadahmad21 authored Nov 22, 2023
1 parent 3876a4e commit 0d35a4c
Show file tree
Hide file tree
Showing 27 changed files with 230 additions and 360 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:** 6.0
**Requires PHP:** 7.0
**Tested up to:** 6.3.1
**Stable tag:** 4.0.13
**Stable tag:** 4.0.14
**License:** GPLv2 or later
**License URI:** [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)
**Donate link:** [wpsocio.com/donate](https://wpsocio.com/donate)
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.14 - 2023-11-22](https://github.com/wpsocio/wptelegram/releases/tag/v4.0.14)

### Enhancements

- Added support for `<blockquote>` tag

## [4.0.13 - 2023-09-17](https://github.com/wpsocio/wptelegram/releases/tag/v4.0.13)

### 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.13",
"version": "4.0.14",
"description": "Integrate your WordPress site perfectly with Telegram with full control.",
"require-dev": {
"wp-coding-standards/wpcs": "^3.0"
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const generatePotFile = (done) => {
potFilename: config.potFilename,
type: 'wp-plugin',
cwd: config.srcDir,
mainFile: `${config.srcDir}/${pkg.name}.php`,
mainFile: `${pkg.name}.php`,
updateTimestamp: true,
updatePoFiles: true,
potHeaders: {
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.13",
"version": "4.0.14",
"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: 6.0
Requires PHP: 7.0
Tested up to: 6.3.1
Stable tag: 4.0.13
Stable tag: 4.0.14
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.14 =
- Added support for `<blockquote>` tag

= 4.0.13 =
- Fixed the failure of sending posts with large size images

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.14 - 2023-11-22](https://github.com/wpsocio/wptelegram/releases/tag/v4.0.14)

### Enhancements

- Added support for `<blockquote>` tag

## [4.0.13 - 2023-09-17](https://github.com/wpsocio/wptelegram/releases/tag/v4.0.13)

### Bug fixes
Expand Down
55 changes: 42 additions & 13 deletions src/includes/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,27 @@ class Utils {
*/
const SUPPORTED_HTML_TAGS = [
// Link.
'a' => [
'a' => [
'href' => true,
],
// bold.
'b' => [],
'strong' => [],
'b' => [],
'strong' => [],
// blockquote.
'blockquote' => [
'cite' => true,
],
// italic.
'em' => [],
'i' => [],
'em' => [],
'i' => [],
// code.
'pre' => [],
'code' => [
'pre' => [],
'code' => [
'class' => true,
],
// underline.
'u' => [],
'ins' => [],
'u' => [],
'ins' => [],
];

/**
Expand Down Expand Up @@ -702,18 +706,22 @@ public static function get_max_text_length( $for = 'text', $padding = 20 ) {
*
* @param int $id The attachment ID.
* @param int $filesize The maximum file size.
* @param string $return The return type. Can be 'path' or 'url'. Default 'url'.
* @param string $return The return type. Can be 'path' or 'url'. Default null.
*
* @return string|false The attachment path or URL.
*/
public static function get_attachment_by_filesize( $id, $filesize, $return = 'url' ) {
public static function get_attachment_by_filesize( $id, $filesize, $return = null ) {

if ( ! get_post( $id ) ) {
return false;
}

$file_path = get_attached_file( $id );

if ( null === $return ) {
$return = self::send_files_by_url() ? 'url' : 'path';
}

$path = 'url' === $return ? wp_get_attachment_url( $id ) : $file_path;

// For now, we only deal with images.
Expand All @@ -737,11 +745,11 @@ public static function get_attachment_by_filesize( $id, $filesize, $return = 'ur
return $path;
}

$directory = dirname( $file_path );

if ( ! empty( $meta['sizes'] ) ) {
$size_data = [];

$directory = dirname( $file_path );

foreach ( $meta['sizes'] as $data ) {
if ( empty( $data['file'] ) ) {
continue;
Expand Down Expand Up @@ -773,4 +781,25 @@ public static function get_attachment_by_filesize( $id, $filesize, $return = 'ur

return $path;
}

/**
* Get the limit of the image size to send to Telegram.
*
* @return int
*/
public static function get_image_size_limit() {

return self::send_files_by_url() ? self::IMAGE_BY_URL_SIZE_LIMIT : self::IMAGE_BY_FILE_SIZE_LIMIT;
}

/**
* Whether to send files by URL.
*
* @since 4.0.14
*/
public static function send_files_by_url() {
$send_files_by_url = WPTG()->options()->get_path( 'advanced.send_files_by_url', true );

return (bool) apply_filters( 'wptelegram_send_files_by_url', $send_files_by_url );
}
}
19 changes: 2 additions & 17 deletions src/languages/wptelegram-ar.po
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (C) 2017 WP Telegram
# Copyright (C) 2017 WP Telegram
msgid ""
msgstr ""
"Project-Id-Version: WP Telegram - Stable\n"
"Report-Msgid-Bugs-To: https://github.com/wpsocio/wptelegram\n"
"POT-Creation-Date: 2023-07-07 09:56:05+00:00\n"
"POT-Creation-Date: 2023-11-22 14:20:05+00:00\n"
"PO-Revision-Date: 2021-03-14 01:37+0530\n"
"Last-Translator: \n"
"Language-Team: WPTelegram\n"
Expand All @@ -29,10 +29,6 @@ msgid ""
"and do lot more :)"
msgstr ""

#: includes/Main.php:316
msgid "WP Telegram"
msgstr ""

#: includes/Requirements.php:121
msgid "This plugin is not compatible with your website configuration."
msgstr ""
Expand Down Expand Up @@ -111,14 +107,6 @@ msgstr ""
msgid "channel"
msgstr ""

#: languages/wptelegram-js-translations.php:41
msgid ""
"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."
msgstr ""

#: languages/wptelegram-js-translations.php:44
msgid "Get LIVE support on Telegram"
msgstr ""
Expand Down Expand Up @@ -1056,6 +1044,3 @@ msgstr ""
#: modules/p2tg/Rules.php:59
msgid "Custom Taxonomy"
msgstr ""

#~ msgid "Markdown style"
#~ msgstr "نمط Markdown"
19 changes: 2 additions & 17 deletions src/languages/wptelegram-ca.po
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (C) 2017 WP Telegram
# Copyright (C) 2017 WP Telegram
msgid ""
msgstr ""
"Project-Id-Version: WP Telegram - Stable\n"
"Report-Msgid-Bugs-To: https://github.com/wpsocio/wptelegram\n"
"POT-Creation-Date: 2023-07-07 09:56:05+00:00\n"
"POT-Creation-Date: 2023-11-22 14:20:05+00:00\n"
"PO-Revision-Date: 2021-03-14 01:37+0530\n"
"Last-Translator: \n"
"Language-Team: WPTelegram\n"
Expand All @@ -29,10 +29,6 @@ msgid ""
"and do lot more :)"
msgstr ""

#: includes/Main.php:316
msgid "WP Telegram"
msgstr ""

#: includes/Requirements.php:121
msgid "This plugin is not compatible with your website configuration."
msgstr ""
Expand Down Expand Up @@ -111,14 +107,6 @@ msgstr ""
msgid "channel"
msgstr ""

#: languages/wptelegram-js-translations.php:41
msgid ""
"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."
msgstr ""

#: languages/wptelegram-js-translations.php:44
msgid "Get LIVE support on Telegram"
msgstr ""
Expand Down Expand Up @@ -1058,6 +1046,3 @@ msgstr ""
#: modules/p2tg/Rules.php:59
msgid "Custom Taxonomy"
msgstr ""

#~ msgid "Markdown style"
#~ msgstr "estil de Marcatge"
Binary file modified src/languages/wptelegram-de_DE.mo
Binary file not shown.
Loading

0 comments on commit 0d35a4c

Please sign in to comment.