Skip to content

Commit

Permalink
Merge pull request #37 from pixelbart/dev
Browse files Browse the repository at this point in the history
4.5.6
  • Loading branch information
pixelbart authored Mar 22, 2022
2 parents ceb017f + ab9ca28 commit 94396b9
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 30 deletions.
27 changes: 19 additions & 8 deletions core/helpers/class-feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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'));

Expand Down Expand Up @@ -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);
}
}
61 changes: 53 additions & 8 deletions core/modules/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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;
}
}
2 changes: 1 addition & 1 deletion core/services/class-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion core/tabs/class-system.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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' ],
Expand Down
2 changes: 1 addition & 1 deletion helpful.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions templates/emails/feedback-email-voter.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<p>Hello!</p>

<p>You receive this e-mail because you gave feedback on {blog_name}. This data was submitted by you:</p>

<p><strong>Name:</strong> {name}<br>
<strong>Email:</strong> {email}<br>
<strong>Message:</strong> {message}</p>

<p>Thank you for your feedback!</p>

<p>This message was sent by {blog_name}.</p>
10 changes: 10 additions & 0 deletions templates/emails/feedback-email.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<p>Hi!</p>

<p>You have received new {type} feedback for your post.</p>

<p><strong>Post:</strong> <a href="{post_url}">{post_title}</a><br>
<strong>Name:</strong> {name}<br>
<strong>Email:</strong> {email}<br>
<strong>Message:</strong> {message}</p>

<p>This message was sent by {blog_name}.</p>
28 changes: 18 additions & 10 deletions templates/tabs/tab-system.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @package Helpful
* @version 4.5.0
* @version 4.5.6
* @since 1.0.0
*/
use Helpful\Core\Helper;
Expand Down Expand Up @@ -84,65 +84,73 @@

<div class="helpful-admin-group helpful-margin-bottom">
<label class="helpful-block" for="helpful_timezone"><?php _ex('Custom timezone', 'option name', 'helpful'); ?></label>
<?php $value = $options->get_option('helpful_timezone', date_default_timezone_get(), 'esc_attr'); ?>
<?php $value = $options->get_option('helpful_timezone', '', 'esc_attr'); ?>
<input type="text" class="regular-text code" name="helpful_timezone" value="<?php echo esc_attr($value); ?>">
</div><!-- .helpful-admin-group -->

<div class="helpful-admin-group helpful-margin-bottom">
<label>
<?php $value = $options->get_option('helpful_multiple', 'off', 'esc_attr'); ?>
<?php $value = $options->get_option('helpful_multiple', 'off', 'on_off'); ?>
<input id="helpful_multiple" type="checkbox" name="helpful_multiple" <?php checked('on', $value); ?> />
<?php _ex('Enable to allow users to vote more than once in individual posts', 'label', 'helpful'); ?>
</label>
</div><!-- .helpful-admin-group -->

<div class="helpful-admin-group helpful-margin-bottom">
<label>
<?php $value = $options->get_option('helpful_notes', 'off', 'esc_attr'); ?>
<?php $value = $options->get_option('helpful_notes', 'off', 'on_off'); ?>
<input id="helpful_notes" type="checkbox" name="helpful_notes" <?php checked('on', $value); ?> />
<?php _ex('Check to completely disable admin notes for Helpful', 'label', 'helpful'); ?>
</label>
</div><!-- .helpful-admin-group -->

<div class="helpful-admin-group helpful-margin-bottom">
<label>
<?php $value = $options->get_option('helpful_plugin_first', 'off', 'esc_attr'); ?>
<?php $value = $options->get_option('helpful_plugin_first', 'off', 'on_off'); ?>
<input id="helpful_plugin_first" type="checkbox" name="helpful_plugin_first" <?php checked('on', $value); ?> />
<?php _ex('Select so that Helpful is always loaded first', 'label', 'helpful'); ?>
</label>
</div><!-- .helpful-admin-group -->

<div class="helpful-admin-group helpful-margin-bottom">
<label>
<?php $value = $options->get_option('helpful_classic_editor', 'off', 'esc_attr'); ?>
<?php $value = $options->get_option('helpful_classic_editor', 'off', 'on_off'); ?>
<input id="helpful_classic_editor" type="checkbox" name="helpful_classic_editor" <?php checked('on', $value); ?> />
<?php _ex('Activate the classic editor and deactivate the block editor', 'label', 'helpful'); ?>
</label>
</div><!-- .helpful-admin-group -->

<div class="helpful-admin-group helpful-margin-bottom">
<label>
<?php $value = $options->get_option('helpful_classic_widgets', 'off', 'esc_attr'); ?>
<?php $value = $options->get_option('helpful_classic_widgets', 'off', 'on_off'); ?>
<input id="helpful_classic_widgets" type="checkbox" name="helpful_classic_widgets" <?php checked('on', $value); ?> />
<?php _ex('Activate the classic widgets and deactivate the block editor for widgets', 'label', 'helpful'); ?>
</label>
</div><!-- .helpful-admin-group -->

<div class="helpful-admin-group helpful-margin-bottom">
<label>
<?php $value = $options->get_option('helpful_disable_frontend_nonce', 'off', 'esc_attr'); ?>
<?php $value = $options->get_option('helpful_disable_frontend_nonce', 'off', 'on_off'); ?>
<input id="helpful_disable_frontend_nonce" type="checkbox" name="helpful_disable_frontend_nonce" <?php checked('on', $value); ?> />
<?php _ex('Disable frontend nonce (not recommended)', 'label', 'helpful'); ?>
</label>
</div><!-- .helpful-admin-group -->

<div class="helpful-admin-group">
<div class="helpful-admin-group helpful-margin-bottom">
<label>
<?php $value = $options->get_option('helpful_disable_feedback_nonce', 'off', 'esc_attr'); ?>
<?php $value = $options->get_option('helpful_disable_feedback_nonce', 'off', 'on_off'); ?>
<input id="helpful_disable_feedback_nonce" type="checkbox" name="helpful_disable_feedback_nonce" <?php checked('on', $value); ?> />
<?php _ex('Disable feedback nonce (not recommended)', 'label', 'helpful'); ?>
</label>
</div><!-- .helpful-admin-group -->

<div class="helpful-admin-group">
<label>
<?php $value = $options->get_option('helpful_log_mailer_errors', 'off', 'on_off'); ?>
<input id="helpful_log_mailer_errors" type="checkbox" name="helpful_log_mailer_errors" <?php checked('on', $value); ?> />
<?php _ex('Save error messages when sending emails in the error log.', 'label', 'helpful'); ?>
</label>
</div><!-- .helpful-admin-group -->
</div><!-- .helpful-admin-panel-content -->
</div><!-- .helpful-admin-panel -->

Expand Down

0 comments on commit 94396b9

Please sign in to comment.