From ab9ca28ec856cf5dd311b0acf1ab52501e0f63a7 Mon Sep 17 00:00:00 2001 From: Kevin Pliester <5339107+pixelbart@users.noreply.github.com> Date: Tue, 22 Mar 2022 11:53:59 +0100 Subject: [PATCH] 4.5.6 --- core/helpers/class-feedback.php | 27 +++++++--- core/modules/class-core.php | 61 ++++++++++++++++++++--- core/services/class-options.php | 2 +- core/tabs/class-system.php | 10 +++- helpful.php | 2 +- readme.txt | 2 +- templates/emails/feedback-email-voter.txt | 11 ++++ templates/emails/feedback-email.txt | 10 ++++ templates/tabs/tab-system.php | 28 +++++++---- 9 files changed, 123 insertions(+), 30 deletions(-) create mode 100644 templates/emails/feedback-email-voter.txt create mode 100644 templates/emails/feedback-email.txt diff --git a/core/helpers/class-feedback.php b/core/helpers/class-feedback.php index 5cb958f..bab3f5e 100644 --- a/core/helpers/class-feedback.php +++ b/core/helpers/class-feedback.php @@ -237,7 +237,7 @@ public static function feedback_exists($data) /** * Send feedback email. * - * @version 4.4.63 + * @version 4.5.6 * * @param array $feedback feedback data. * @@ -547,7 +547,6 @@ public static function after_vote($post_id, $show_feedback = false) } if ('none' === $type) { - if ('off' === $ap && 'off' === $ac && false === $show_feedback) { $content = do_shortcode($options->get_option('helpful_after_fallback', '', 'kses')); @@ -625,24 +624,36 @@ public static function after_vote($post_id, $show_feedback = false) /** * Get feedback email content. * + * @version 4.5.6 + * * @return string */ public static function get_email_content() { - $file = plugins_url('templates/feedback-email.txt', HELPFUL_FILE); - $content = file_get_contents($file); - return apply_filters('helpful_pre_get_email_content', $content); + $file = plugins_url('templates/emails/feedback-email.txt', HELPFUL_FILE); + $file = apply_filters('helpful_pre_get_email_content_voter_file', $file); + + $response = wp_remote_get($file); + $response = wp_remote_retrieve_body($response); + + return apply_filters('helpful_pre_get_email_content_voter', $response); } /** * Get feedback email content for voters. * + * @version 4.5.6 + * * @return string */ public static function get_email_content_voter() { - $file = plugins_url('templates/feedback-email-voter.txt', HELPFUL_FILE); - $content = file_get_contents($file); - return apply_filters('helpful_pre_get_email_content_voter', $content); + $file = plugins_url('templates/emails/feedback-email-voter.txt', HELPFUL_FILE); + $file = apply_filters('helpful_pre_get_email_content_voter_file', $file); + + $response = wp_remote_get($file); + $response = wp_remote_retrieve_body($response); + + return apply_filters('helpful_pre_get_email_content_voter', $response); } } diff --git a/core/modules/class-core.php b/core/modules/class-core.php index 3b3ed20..531a689 100644 --- a/core/modules/class-core.php +++ b/core/modules/class-core.php @@ -54,6 +54,10 @@ public function __construct() add_action('helpful/plugin/updated', [ & $this, 'setup_tables_and_settings']); add_action('upgrader_process_complete', [ & $this, 'on_plugin_update'], 10, 2); + + add_action('wp_mail_failed', [ & $this, 'log_mailer_errors'], 10, 1); + + add_filter('use_widgets_block_editor', [ & $this, 'disable_widgets_block_editor'], 10, 1); } /** @@ -305,13 +309,13 @@ public function editor_settings() /** * A fallback in case Helpful options are updated with WordPress default options. - * + * * @version 4.5.0 - * + * * @param string $option * @param mixed $old_value * @param mixed $value - * + * * @return void */ public function update_option_hook($option, $old_value, $value) @@ -328,9 +332,9 @@ public function update_option_hook($option, $old_value, $value) /** * Checks if there are changes in the database and synchronizes old settings formats once Helpful has been updated. - * + * * @version 4.5.0 - * + * * @return void */ public function setup_tables_and_settings() @@ -343,12 +347,12 @@ public function setup_tables_and_settings() /** * Checks if there are changes in the database and synchronizes old settings formats once Helpful has been updated. * Initializes a hook that can be controlled by other classes once Helpful has been updated. - * + * * @version 4.5.0 - * + * * @param WP_Upgrader $upgrader * @param array $hook_extra - * + * * @return void */ public function on_plugin_update($upgrader, $hook_extra) @@ -361,4 +365,45 @@ public function on_plugin_update($upgrader, $hook_extra) } } } + + /** + * @version 4.5.6 + * + * @param WP_Error $wp_error + * + * @return void + */ + public function log_mailer_errors($wp_error) + { + if (!is_wp_error($wp_error)) { + return; + } + + $options = new Services\Options(); + + if ('off' === $options->get_option('helpful_log_mailer_errors', 'off', 'on_off')) { + return; + } + + $message = 'Helpful Error: ' . $wp_error->get_error_message(); + helpful_error_log($message); + } + + /** + * @version 4.5.6 + * + * @param bool $current_status + * + * @return bool + */ + public function disable_widgets_block_editor($current_status) + { + $options = new Services\Options(); + + if ('off' === $options->get_option('helpful_log_mailer_errors', 'off', 'on_off')) { + return $current_status; + } + + return false; + } } diff --git a/core/services/class-options.php b/core/services/class-options.php index 649d3c6..804ddaa 100644 --- a/core/services/class-options.php +++ b/core/services/class-options.php @@ -2,7 +2,7 @@ /** * @package Helpful * @subpackage Core\Services - * @version 4.5.5 + * @version 4.5.6 * @since 4.4.47 */ namespace Helpful\Core\Services; diff --git a/core/tabs/class-system.php b/core/tabs/class-system.php index 0662b97..e51d7e9 100644 --- a/core/tabs/class-system.php +++ b/core/tabs/class-system.php @@ -2,7 +2,7 @@ /** * @package Helpful * @subpackage Core\Tabs - * @version 4.5.5 + * @version 4.5.6 * @since 4.3.0 */ namespace Helpful\Core\Tabs; @@ -96,6 +96,10 @@ public function register_settings() 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], + 'helpful_classic_widgets' => [ + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + ], 'helpful_caching' => [ 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', @@ -128,6 +132,10 @@ public function register_settings() 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', ], + 'helpful_log_mailer_errors' => [ + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + ], 'helpful_cookies_samesite' => [ 'type' => 'string', 'sanitize_callback' => [ & $this, 'sanitize_input_without_tags' ], diff --git a/helpful.php b/helpful.php index 446a8cd..b0cd01d 100644 --- a/helpful.php +++ b/helpful.php @@ -2,7 +2,7 @@ /** * Plugin Name: Helpful * Description: Add a fancy feedback form under your posts or post-types and ask your visitors a question. Give them the abbility to vote with yes or no. - * Version: 4.5.5 + * Version: 4.5.6 * Author: Pixelbart * Author URI: https://pixelbart.de * Text Domain: helpful diff --git a/readme.txt b/readme.txt index 8de2308..7ca3249 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: helpful, poll, feedback, reviews, vote, review, voting Requires at least: 4.6 Tested up to: 5.9 Requires PHP: 5.6.20 -Stable tag: 4.5.5 +Stable tag: 4.5.6 License: MIT License License URI: https://opensource.org/licenses/MIT diff --git a/templates/emails/feedback-email-voter.txt b/templates/emails/feedback-email-voter.txt new file mode 100644 index 0000000..88bd88a --- /dev/null +++ b/templates/emails/feedback-email-voter.txt @@ -0,0 +1,11 @@ +
Hello!
+ +You receive this e-mail because you gave feedback on {blog_name}. This data was submitted by you:
+ +Name: {name}
+Email: {email}
+Message: {message}
Thank you for your feedback!
+ +This message was sent by {blog_name}.
\ No newline at end of file diff --git a/templates/emails/feedback-email.txt b/templates/emails/feedback-email.txt new file mode 100644 index 0000000..48d4580 --- /dev/null +++ b/templates/emails/feedback-email.txt @@ -0,0 +1,10 @@ +Hi!
+ +You have received new {type} feedback for your post.
+ +Post: {post_title}
+Name: {name}
+Email: {email}
+Message: {message}
This message was sent by {blog_name}.
\ No newline at end of file diff --git a/templates/tabs/tab-system.php b/templates/tabs/tab-system.php index 4088da4..e43fc5e 100644 --- a/templates/tabs/tab-system.php +++ b/templates/tabs/tab-system.php @@ -1,7 +1,7 @@ - get_option('helpful_timezone', date_default_timezone_get(), 'esc_attr'); ?> + get_option('helpful_timezone', '', 'esc_attr'); ?>