From 2e354173dbb4280944cf256eaa02bddb0c4436cb Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 15 Sep 2021 10:50:25 -0300 Subject: [PATCH] Deprecated old archive filters and add new ones Using new filters is needed as the parameters passed to the filters changed. If we continued using the same filters, users might run into fatal errors. [MAILPOET-3629] --- lib/Config/Shortcodes.php | 29 +++++++++++++++++++++++++---- lib/WP/Functions.php | 4 ++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/Config/Shortcodes.php b/lib/Config/Shortcodes.php index 497a404b71..d30df3f998 100644 --- a/lib/Config/Shortcodes.php +++ b/lib/Config/Shortcodes.php @@ -67,12 +67,33 @@ class Shortcodes { $this, 'getArchive', ]); - $this->wp->addFilter('mailpoet_archive_date', [ + $this->wp->addFilter('mailpoet_archive_email_processed_date', [ $this, 'renderArchiveDate', ], 2); - $this->wp->addFilter('mailpoet_archive_subject', [ + $this->wp->addFilter('mailpoet_archive_email_subject', [ $this, 'renderArchiveSubject', ], 2, 3); + + // This deprecated notice can be removed after 2022-06-01 + if ($this->wp->hasFilter('mailpoet_archive_date')) { + $this->wp->deprecatedHook( + 'mailpoet_archive_date', + '3.69.2', + 'mailpoet_archive_email_processed_date', + __('Please note that mailpoet_archive_date no longer runs and that the list of parameters of the new filter is different.', 'mailpoet') + ); + } + + // This deprecated notice can be removed after 2022-06-01 + if ($this->wp->hasFilter('mailpoet_archive_subject')) { + $this->wp->deprecatedHook( + 'mailpoet_archive_subject', + '3.69.2', + 'mailpoet_archive_email_subject', + __('Please note that mailpoet_archive_subject no longer runs and that the list of parameters of the new filter is different.', 'mailpoet') + ); + } + // initialize subscription pages data $this->subscriptionPages->init(); // initialize subscription management shortcodes @@ -145,10 +166,10 @@ class Shortcodes { $html .= '
  • ' . '' . - $this->wp->applyFilters('mailpoet_archive_date', $task) . + $this->wp->applyFilters('mailpoet_archive_email_processed_date', $task) . ' ' . - $this->wp->applyFilters('mailpoet_archive_subject', $newsletter, $subscriber, $queue) . + $this->wp->applyFilters('mailpoet_archive_email_subject', $newsletter, $subscriber, $queue) . '
  • '; } diff --git a/lib/WP/Functions.php b/lib/WP/Functions.php index 1330467fc5..30fdbc3a56 100644 --- a/lib/WP/Functions.php +++ b/lib/WP/Functions.php @@ -724,4 +724,8 @@ class Functions { public function wpKses(string $string, $allowedHtml, $allowedProtocols = []) { return wp_kses($string, $allowedHtml, $allowedProtocols); } + + public function deprecatedHook(string $hook_name, string $version, string $replacement, string $message) { + _deprecated_hook($hook_name, $version, $replacement, $message); + } }