Skip to content

Commit

Permalink
4.4.54
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelbart committed Sep 24, 2021
1 parent e7f155c commit 107533b
Show file tree
Hide file tree
Showing 29 changed files with 395 additions and 235 deletions.
16 changes: 12 additions & 4 deletions core/class-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
namespace Helpful\Core;

use Helpful\Core\Services as Services;

/* Prevent direct access */
if (!defined('ABSPATH')) {
exit;
Expand Down Expand Up @@ -47,7 +49,9 @@ public static function get_plugin_data()
*/
public static function set_timezone()
{
$timezone = get_option('helpful_timezone');
$options = new Services\Options();

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

if (isset($timezone) && '' !== trim($timezone)) {
date_default_timezone_set($timezone);
Expand Down Expand Up @@ -335,11 +339,13 @@ public static function datatables_language_string()
*/
public static function get_disallowed_keys()
{
$options = new Services\Options();

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

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

/**
Expand Down Expand Up @@ -435,7 +441,9 @@ public static function set_capability($option, $value)
*/
public static function is_feedback_disabled()
{
if ('on' === get_option('helpful_feedback_disabled')) {
$options = new Services\Options();

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

Expand Down
5 changes: 4 additions & 1 deletion core/helpers/class-database.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Helpful\Core\Helpers;

use Helpful\Core\Helper;
use Helpful\Core\Services as Services;

/* Prevent direct access */
if (!defined('ABSPATH')) {
Expand Down Expand Up @@ -183,7 +184,9 @@ public static function handle_table_instances()
*/
public static function update_tables()
{
if (get_option('helpful_update_table_integer')) {
$options = new Services\Options();

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

Expand Down
53 changes: 34 additions & 19 deletions core/helpers/class-feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Helpful\Core\Helpers;

use Helpful\Core\Helper;
use Helpful\Core\Services as Services;

/* Prevent direct access */
if (!defined('ABSPATH')) {
Expand Down Expand Up @@ -76,8 +77,10 @@ public static function get_feedback($entry)
*/
public static function get_feedback_items($limit = null)
{
$options = new Services\Options();

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

global $wpdb;
Expand Down Expand Up @@ -110,6 +113,8 @@ public static function insert_feedback()
$pro = 0;
$contra = 0;
$message = null;

do_action('helpful/insert_feedback');

if (!isset($_REQUEST['post_id'])) {
$message = 'Helpful Notice: Feedback was not saved because the post id is empty in %s on line %d.';
Expand Down Expand Up @@ -215,12 +220,14 @@ public static function insert_feedback()
*/
public static function send_email($feedback)
{
$options = new Services\Options();

/**
* Send email to voter.
*/
self::send_email_voter($feedback);

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

Expand All @@ -229,6 +236,8 @@ public static function send_email($feedback)
if (!$post) {
return;
}

do_action('helpful/send_email');

$feedback['fields'] = maybe_unserialize($feedback['fields']);

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

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

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

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

/* receivers by post meta */
Expand All @@ -280,8 +289,8 @@ public static function send_email($feedback)
/* receivers by helpful options */
$helpful_receivers = [];

if (get_option('helpful_feedback_receivers')) {
$helpful_receivers = get_option('helpful_feedback_receivers');
if ($options->get_option('helpful_feedback_receivers')) {
$helpful_receivers = $options->get_option('helpful_feedback_receivers');
$helpful_receivers = helpful_trim_all($helpful_receivers);
$helpful_receivers = explode(',', $helpful_receivers);
}
Expand Down Expand Up @@ -325,7 +334,9 @@ public static function send_email($feedback)
*/
public static function send_email_voter($feedback)
{
if ('on' !== get_option('helpful_feedback_send_email_voter')) {
$options = new Services\Options();

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

Expand All @@ -334,6 +345,8 @@ public static function send_email_voter($feedback)
if (!$post) {
return;
}

do_action('helpful/send_email_voter');

$feedback['fields'] = maybe_unserialize($feedback['fields']);

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

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

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

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

/* Receivers */
Expand Down Expand Up @@ -439,7 +452,9 @@ public static function get_feedback_count($post_id = null)
*/
public static function after_vote($post_id, $show_feedback = false)
{
// $feedback_text = esc_html_x( 'Thank you very much. Please write us your opinion, so that we can improve ourselves.', 'form user note', 'helpful' );
do_action('helpful/after_vote');

$options = new Services\Options();

$hide_feedback = get_post_meta($post_id, 'helpful_hide_feedback_on_post', true);
$hide_feedback = ('on' === $hide_feedback) ? true : false;
Expand All @@ -461,16 +476,16 @@ public static function after_vote($post_id, $show_feedback = false)

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

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

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

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

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

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

if (get_post_meta($post_id, 'helpful_after_contra', true)) {
$content = do_shortcode(get_post_meta($post_id, 'helpful_after_contra', true));
Expand All @@ -498,8 +513,8 @@ public static function after_vote($post_id, $show_feedback = false)
}

if ('none' === $type) {
if (!get_option('helpful_feedback_after_pro') && !get_option('helpful_feedback_after_contra') && false === $show_feedback) {
$content = do_shortcode(get_option('helpful_after_fallback'));
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'));

if (get_post_meta($post_id, 'helpful_after_fallback', true)) {
$content = do_shortcode(get_post_meta($post_id, 'helpful_after_fallback', true));
Expand Down
7 changes: 5 additions & 2 deletions core/helpers/class-optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Helpful\Core\Helpers;

use Helpful\Core\Helper;
use Helpful\Core\Services as Services;

/* Prevent direct access */
if (!defined('ABSPATH')) {
Expand Down Expand Up @@ -270,8 +271,10 @@ public static function clear_cache()
*/
public static function update_metas()
{
$options = new Services\Options();

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

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

$percentages = false;

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

Expand Down
Loading

0 comments on commit 107533b

Please sign in to comment.