Skip to content

Commit

Permalink
4.4.55
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelbart committed Oct 6, 2021
1 parent 107533b commit 0492997
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 45 deletions.
2 changes: 1 addition & 1 deletion core/assets/themes/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
background-color: #fff;
border-width: 1px;
padding: 25px;
margin: 25px 0 0 0;
margin-top: 25px;
font-size: 1rem;
line-height: 1.6rem;
box-shadow: 0 2px 5px 0 #f4f4f4;
Expand Down
2 changes: 1 addition & 1 deletion core/assets/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
border-width: 1px;
color: #eff2f6;
padding: 25px;
margin: 25px 0 0 0;
margin-top: 25px;
font-size: 1rem;
line-height: 1.6rem;
box-shadow: 0 2px 5px 0 #2c3e50;
Expand Down
2 changes: 1 addition & 1 deletion core/assets/themes/flat.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
border-color: #e5e5e5;
border-width: 2px 0 0;
padding: 25px;
margin: 25px 0 0 0;
margin-top: 25px;
font-size: 1rem;
line-height: 1.6rem;
-webkit-font-smoothing: antialiased;
Expand Down
2 changes: 1 addition & 1 deletion core/assets/themes/minimal.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
border-width: 1px;
color: #000;
padding: 25px;
margin: 25px 0 0 0;
margin-top: 25px;
font-size: 1rem;
line-height: 1.6rem;
-webkit-font-smoothing: antialiased;
Expand Down
4 changes: 2 additions & 2 deletions core/assets/themes/simple.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
.helpful {
color: #333;
position: relative;
margin: 25px 0 0;
padding: 0 0 25px;
margin-top: 25px;
padding-bottom: 25px;
font-size: 1rem;
line-height: 1.6rem;
-webkit-font-smoothing: antialiased;
Expand Down
38 changes: 8 additions & 30 deletions core/helpers/class-user.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.50
* @version 4.4.55
* @since 4.3.0
*/
namespace Helpful\Core\Helpers;
Expand Down Expand Up @@ -78,15 +78,15 @@ public static function get_user_string()
/**
* Set user string
*
* @version 4.4.55
* @since 4.4.0
*
* @return void
*/
public static function set_user()
{
$options = new Services\Options();
$string = self::get_user_string();
$lifetime = '+30 days';
$lifetime = apply_filters('helpful_user_cookie_time', $lifetime);
$samesite = $options->get_option('helpful_cookies_samesite') ?: 'Strict';

/**
* No more user is set using sessions or cookies.
Expand All @@ -100,31 +100,9 @@ public static function set_user()
define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
}

if (!isset($_COOKIE['helpful_user'])) {
if (70300 <= PHP_VERSION_ID) {

if (!in_array($samesite, Helper::get_samesite_options())) {
$samesite = 'Strict';
}

$cookie_options = [
'expires' => strtotime($lifetime),
'path' => '/',
'secure' => true,
'httponly' => true,
'samesite' => $samesite,
];

setcookie('helpful_user', $string, $cookie_options);
}

if (70300 > PHP_VERSION_ID) {
setcookie('helpful_user', $string, strtotime($lifetime), '/');
}

if (isset($_SESSION['helpful_user']) && isset($_COOKIE['helpful_user'])) {
unset($_SESSION['helpful_user']);
}
$cookie = new Services\Cookie();
if (!$cookie->get('helpful_user')) {
$cookie->set('helpful_user', $string);
}

$session_start = apply_filters('helpful_session_start', true);
Expand All @@ -134,7 +112,7 @@ public static function set_user()
$session_start = true;
}

if ('on' !== $sessions_disabled && !isset($_COOKIE['helpful_user'])) {
if ('on' !== $sessions_disabled && !$cookie->get('helpful_user')) {
$session = new Services\Session();
$session->set('helpful_user', $string);
}
Expand Down
11 changes: 9 additions & 2 deletions core/modules/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @package Helpful
* @subpackage Core\Modules
* @version 4.4.51
* @version 4.4.55
* @since 4.3.0
*/
namespace Helpful\Core\Modules;
Expand Down Expand Up @@ -82,10 +82,17 @@ public function start_session()
/**
* Set users cookie with unique id
*
* @version 4.4.55
* @since 4.4.0
*
* @return void
*/
public function set_user_cookie()
{
if ((isset($GLOBALS['pagenow']) && 'wp-login.php' === $GLOBALS['pagenow']) || is_admin()) {
return;
}

Helpers\User::set_user();
}

Expand All @@ -104,7 +111,7 @@ public function setup_defaults()

$this->set_defaults(true);

update_option('helpful_defaults', 1);
$options->update_option('helpful_defaults', 1);
}

/**
Expand Down
19 changes: 15 additions & 4 deletions core/modules/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @package Helpful
* @subpackage Core\Modules
* @version 4.4.53
* @version 4.4.55
* @since 4.3.0
*/
namespace Helpful\Core\Modules;
Expand Down Expand Up @@ -46,7 +46,7 @@ public static function get_instance()
public function __construct()
{
add_filter('helpful_themes', [ & $this, 'default_themes'], 1);
add_action('wp_enqueue_scripts', [ & $this, 'enqueue_scripts'], PHP_INT_MAX);
add_action('wp_enqueue_scripts', [ & $this, 'enqueue_scripts'], 10);

add_action('wp_ajax_helpful_save_vote', [ & $this, 'save_vote']);
add_action('wp_ajax_helpful_save_feedback', [ & $this, 'save_feedback']);
Expand Down Expand Up @@ -127,6 +127,9 @@ public function default_themes($themes)
* Enqueue styles and scripts
*
* @global $post
*
* @version 4.4.55
* @since 4.4.0
*
* @return void
*/
Expand Down Expand Up @@ -200,7 +203,7 @@ public function enqueue_scripts()
*
* @global $post
*
* @version 4.4.51
* @version 4.4.55
* @since 4.3.0
*
* @param string $content post content.
Expand All @@ -209,7 +212,7 @@ public function enqueue_scripts()
*/
public function the_content($content)
{
global $post;
global $wp_query, $page, $numpages, $multipage, $more, $post;

if (helpful_is_amp()) {
return $content;
Expand Down Expand Up @@ -249,6 +252,14 @@ public function the_content($content)

$shortcode = '[helpful post_id="' . $helpful['post_id'] . '"]';

if (apply_filters('helpful/the_content/is_multipage', $multipage)) {
if ($page === $numpages) {
return $content . $shortcode;
}

return $content;
}

return $content . $shortcode;
}

Expand Down
78 changes: 78 additions & 0 deletions core/services/class-cookie.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* @package Helpful
* @subpackage Core\Services
* @copyright Copyright (c) 2015, Pippin Williamson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @version 4.4.55
* @since 4.4.55
*/
namespace Helpful\Core\Services;

use Helpful\Core\Helper;
use Helpful\Core\Helpers as Helpers;

/* Prevent direct access */
if (!defined('ABSPATH')) {
exit;
}

class Cookie
{
/**
* @param string $key
* @param mixed $value
* @return void
*/
public function set(string $key, $value)
{
if (headers_sent()) {
return;
}

$options = new Options();
$lifetime = '+30 days';
$lifetime = apply_filters('helpful_user_cookie_time', $lifetime);
$samesite = $options->get_option('helpful_cookies_samesite') ?: 'Strict';

if (70300 <= PHP_VERSION_ID) {

if (!in_array($samesite, Helper::get_samesite_options())) {
$samesite = 'Strict';
}

$cookie_options = [
'expires' => strtotime($lifetime),
'path' => '/',
'secure' => true,
'httponly' => true,
'samesite' => $samesite,
];

setcookie($key, $value, $cookie_options);
}

if (70300 > PHP_VERSION_ID) {
setcookie($key, $value, strtotime($lifetime), '/');
}

if (isset($_SESSION[$key]) && isset($_COOKIE[$key])) {
unset($_SESSION[$key]);
}
}

/**
* @param string $key
* @return mixed
*/
public function get(string $key)
{
$data = false;

if (isset($_COOKIE[$key]) && '' !== trim($_COOKIE[$key])) {
$data = sanitize_text_field($_COOKIE[$key]);
}

return $data;
}
}
6 changes: 5 additions & 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.4.47
* @version 4.4.55
* @since 4.4.47
*/
namespace Helpful\Core\Services;
Expand Down Expand Up @@ -50,8 +50,12 @@ public function update_option($name, $value)
return;
}

// not in use
$this->options[$name] = $value;
$this->renew_options();

// should be replaced
update_option($name, $value);
}

/**
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.4.54
* Version: 4.4.55
* 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.8
Requires PHP: 5.6.20
Stable tag: 4.4.54
Stable tag: 4.4.55
License: MIT License
License URI: https://opensource.org/licenses/MIT

Expand Down

0 comments on commit 0492997

Please sign in to comment.