| Server IP : 89.108.64.180 / Your IP : 216.73.216.229 Web Server : Apache/2.4.41 (Ubuntu) System : Linux 89-108-64-180.cloudvps.regruhosting.ru 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-root ( 1010) PHP Version : 8.0.30 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/fl-brief.agast.ru/wp-content/plugins/mailpoet/lib/WP/ |
Upload File : |
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
namespace MailPoet\WP;
if (!defined('ABSPATH')) exit;
use MailPoet\WP\Functions as WPFunctions;
class Emoji {
/** @var WPFunctions */
private $wp;
public function __construct(
WPFunctions $wp = null
) {
if ($wp === null) {
$wp = new WPFunctions();
}
$this->wp = $wp;
}
public function encodeEmojisInBody($newsletterRenderedBody) {
if (is_array($newsletterRenderedBody)) {
return array_map([$this, 'encodeRenderedBodyForUTF8Column'], $newsletterRenderedBody);
}
return $this->encodeRenderedBodyForUTF8Column($newsletterRenderedBody);
}
public function decodeEmojisInBody($newsletterRenderedBody) {
if (is_array($newsletterRenderedBody)) {
return array_map([$this, 'decodeEntities'], $newsletterRenderedBody);
}
return $this->decodeEntities($newsletterRenderedBody);
}
public function sanitizeEmojisInFormBody(array $body): array {
$bodyJson = json_encode($body, JSON_UNESCAPED_UNICODE);
$fixedJson = $this->encodeForUTF8Column(MP_FORMS_TABLE, 'body', $bodyJson);
return json_decode($fixedJson, true);
}
private function encodeRenderedBodyForUTF8Column($value) {
return $this->encodeForUTF8Column(
MP_SENDING_QUEUES_TABLE,
'newsletter_rendered_body',
$value
);
}
public function encodeForUTF8Column($table, $field, $value) {
global $wpdb;
$charset = $wpdb->get_col_charset($table, $field);
if ($charset === 'utf8') {
$value = $this->wp->wpEncodeEmoji($value);
}
return $value;
}
public function decodeEntities($content) {
// Based on WPFunctions::get()->wpStaticizeEmoji()
// Loosely match the Emoji Unicode range.
$regex = '/(&#x[2-3][0-9a-f]{3};|[1-6][0-9a-f]{2};)/';
$matches = [];
if (preg_match_all($regex, $content, $matches)) {
if (!empty($matches[1])) {
foreach ($matches[1] as $emoji) {
$entity = html_entity_decode($emoji, ENT_COMPAT, 'UTF-8');
$content = str_replace($emoji, $entity, $content);
}
}
}
return $content;
}
}