Skip to content

Commit

Permalink
4.4.59
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelbart committed Oct 11, 2021
1 parent 7d23ad4 commit ad7b298
Show file tree
Hide file tree
Showing 28 changed files with 466 additions and 278 deletions.
16 changes: 9 additions & 7 deletions core/class-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @package Helpful
* @subpackage Core
* @version 4.4.53
* @version 4.4.59
* @since 4.3.0
*/
namespace Helpful\Core;
Expand Down Expand Up @@ -44,15 +44,15 @@ public static function get_plugin_data()
/**
* Set custom timezone if set in the options.
*
* @version 4.4.58
* @version 4.4.59
*
* @return void
*/
public static function set_timezone()
{
$options = new Services\Options();

$timezone = $options->get_option('helpful_timezone');
$timezone = $options->get_option('helpful_timezone', date_default_timezone_get(), 'esc_attr');

if (isset($timezone) && '' !== trim($timezone) && false === self::is_timezone($timezone)) {
$options->update_option('helpful_timezone', '');
Expand Down Expand Up @@ -358,17 +358,19 @@ public static function datatables_language_string()
/**
* Returns non-permitted characters and words from the WordPress blacklist.
*
* @version 4.4.59
*
* @return string
*/
public static function get_disallowed_keys()
{
$options = new Services\Options();

if (version_compare(get_bloginfo('version'), '5.5.0') >= 0) {
return trim($options->get_option('disallowed_keys'));
return trim($options->get_option('disallowed_keys', '', 'esc_attr'));
}

return trim($options->get_option('blacklist_keys'));
return trim($options->get_option('blacklist_keys', '', 'esc_attr'));
}

/**
Expand Down Expand Up @@ -458,15 +460,15 @@ public static function set_capability($option, $value)
/**
* Checks if the feedback was deactivated by option.
*
* @version 4.4.53
* @version 4.4.59
*
* @return bool
*/
public static function is_feedback_disabled()
{
$options = new Services\Options();

if ('on' === $options->get_option('helpful_feedback_disabled')) {
if ('on' === $options->get_option('helpful_feedback_disabled', 'off', 'esc_attr')) {
return true;
}

Expand Down
5 changes: 3 additions & 2 deletions core/helpers/class-database.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @package Helpful
* @subpackage Core\Helpers
* @version 4.4.51
* @version 4.4.59
* @since 4.3.0
*/
namespace Helpful\Core\Helpers;
Expand Down Expand Up @@ -179,14 +179,15 @@ public static function handle_table_instances()
* Updates database tables.
*
* @global $wpdb
* @version 4.4.59
*
* @return void
*/
public static function update_tables()
{
$options = new Services\Options();

if ($options->get_option('helpful_update_table_integer')) {
if ($options->get_option('helpful_update_table_integer', false, 'intval')) {
return;
}

Expand Down
37 changes: 21 additions & 16 deletions core/helpers/class-feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ public static function get_feedback($entry)
* Get feedback items.
*
* @global $wpdb
* @version 4.4.59
*
* @param integer $limit posts per page.
* @param int $limit posts per page.
*
* @return object
*/
Expand All @@ -80,7 +81,7 @@ public static function get_feedback_items($limit = null)
$options = new Services\Options();

if (is_null($limit)) {
$limit = absint($options->get_option('helpful_widget_amount'));
$limit = intval($options->get_option('helpful_widget_amount', 3, 'intval'));
}

global $wpdb;
Expand Down Expand Up @@ -214,6 +215,8 @@ public static function insert_feedback()
/**
* Send feedback email.
*
* @version 4.4.59
*
* @param array $feedback feedback data.
*
* @return void
Expand All @@ -227,7 +230,7 @@ public static function send_email($feedback)
*/
self::send_email_voter($feedback);

if ('on' !== $options->get_option('helpful_feedback_send_email')) {
if ('on' !== $options->get_option('helpful_feedback_send_email', 'off', 'esc_attr')) {
return;
}

Expand Down Expand Up @@ -262,7 +265,7 @@ public static function send_email($feedback)
$tags = apply_filters('helpful_feedback_email_tags', $tags);

/* email subject */
$subject = $options->get_option('helpful_feedback_subject');
$subject = $options->get_option('helpful_feedback_subject', '', 'kses_wot');
$subject = str_replace(array_keys($tags), array_values($tags), $subject);

/* unserialize feedback fields */
Expand All @@ -274,7 +277,7 @@ public static function send_email($feedback)
}

/* body */
$body = $options->get_option('helpful_feedback_email_content');
$body = $options->get_option('helpful_feedback_email_content', '', 'kses');
$body = str_replace(array_keys($tags), array_values($tags), $body);

/* receivers by post meta */
Expand All @@ -290,7 +293,7 @@ public static function send_email($feedback)
$helpful_receivers = [];

if ($options->get_option('helpful_feedback_receivers')) {
$helpful_receivers = $options->get_option('helpful_feedback_receivers');
$helpful_receivers = $options->get_option('helpful_feedback_receivers', '', 'esc_attr');
$helpful_receivers = helpful_trim_all($helpful_receivers);
$helpful_receivers = explode(',', $helpful_receivers);
}
Expand Down Expand Up @@ -328,6 +331,8 @@ public static function send_email($feedback)
/**
* Send feedback email to voter.
*
* @version 4.4.59
*
* @param array $feedback feedback data.
*
* @return void
Expand All @@ -336,7 +341,7 @@ public static function send_email_voter($feedback)
{
$options = new Services\Options();

if ('on' !== $options->get_option('helpful_feedback_send_email_voter')) {
if ('on' !== $options->get_option('helpful_feedback_send_email_voter', 'off', 'esc_attr')) {
return;
}

Expand Down Expand Up @@ -365,7 +370,7 @@ public static function send_email_voter($feedback)
$tags = apply_filters('helpful_feedback_email_tags', $tags);

/* subject */
$subject = $options->get_option('helpful_feedback_subject_voter');
$subject = $options->get_option('helpful_feedback_subject_voter', '', 'kses_wot');
$subject = str_replace(array_keys($tags), array_values($tags), $subject);

/* unserialize feedback fields */
Expand All @@ -377,7 +382,7 @@ public static function send_email_voter($feedback)
}

/* Body */
$body = $options->get_option('helpful_feedback_email_content_voter');
$body = $options->get_option('helpful_feedback_email_content_voter', '', 'kses');
$body = str_replace(array_keys($tags), array_values($tags), $body);

/* Receivers */
Expand Down Expand Up @@ -442,7 +447,7 @@ public static function get_feedback_count($post_id = null)
* Render after messages or feedback form, after vote.
* Checks if custom template exists.
*
* @version 4.4.51
* @version 4.4.59
* @since 4.4.0
*
* @param integer $post_id post id.
Expand Down Expand Up @@ -476,16 +481,16 @@ public static function after_vote($post_id, $show_feedback = false)

if (true === $show_feedback) {
$type = 'none';
$feedback_text = $options->get_option('helpful_feedback_message_voted');
$feedback_text = $options->get_option('helpful_feedback_message_voted', '', 'kses');
$feedback_text = apply_filters('helpful_pre_feedback_message_voted', $feedback_text, $post_id);
}

if ('pro' === $type) {
$feedback_text = $options->get_option('helpful_feedback_message_pro');
$feedback_text = $options->get_option('helpful_feedback_message_pro', '', 'kses');

if (false === $show_feedback) {
if (!$options->get_option('helpful_feedback_after_pro') || true === $hide_feedback) {
$content = do_shortcode($options->get_option('helpful_after_pro'));
$content = do_shortcode($options->get_option('helpful_after_pro', '', 'kses'));

if (get_post_meta($post_id, 'helpful_after_pro', true)) {
$content = do_shortcode(get_post_meta($post_id, 'helpful_after_pro', true));
Expand All @@ -497,11 +502,11 @@ public static function after_vote($post_id, $show_feedback = false)
}

if ('contra' === $type) {
$feedback_text = $options->get_option('helpful_feedback_message_contra');
$feedback_text = $options->get_option('helpful_feedback_message_contra', '', 'kses');

if (false === $show_feedback) {
if (!$options->get_option('helpful_feedback_after_contra') || true === $hide_feedback) {
$content = do_shortcode($options->get_option('helpful_after_contra'));
$content = do_shortcode($options->get_option('helpful_after_contra', '', 'kses'));

if (get_post_meta($post_id, 'helpful_after_contra', true)) {
$content = do_shortcode(get_post_meta($post_id, 'helpful_after_contra', true));
Expand All @@ -514,7 +519,7 @@ public static function after_vote($post_id, $show_feedback = false)

if ('none' === $type) {
if (!$options->get_option('helpful_feedback_after_pro') && !$options->get_option('helpful_feedback_after_contra') && false === $show_feedback) {
$content = do_shortcode($options->get_option('helpful_after_fallback'));
$content = do_shortcode($options->get_option('helpful_after_fallback', '', 'kses'));

if (get_post_meta($post_id, 'helpful_after_fallback', true)) {
$content = do_shortcode(get_post_meta($post_id, 'helpful_after_fallback', true));
Expand Down
6 changes: 4 additions & 2 deletions core/helpers/class-optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,16 @@ public static function clear_cache()
/**
* Update meta fields
*
* @version 4.4.59
*
* @return array
*/
public static function update_metas()
{
$options = new Services\Options();

$response = [];
$post_types = $options->get_option('helpful_post_types');
$post_types = $options->get_option('helpful_post_types', [], 'esc_attr');

$args = [
'post_type' => $post_types,
Expand All @@ -289,7 +291,7 @@ public static function update_metas()

$percentages = false;

if ($options->get_option('helpful_percentages')) {
if ('on' === $options->get_option('helpful_percentages', 'off', 'esc_attr')) {
$percentages = true;
}

Expand Down
Loading

0 comments on commit ad7b298

Please sign in to comment.