1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<?php
namespace TotalPoll\Restrictions; ! defined( 'ABSPATH' ) && exit();
/** * Cookies Restriction. * @package TotalPoll\Restrictions */ class Cookies extends Restriction { /** * @return bool|\WP_Error */ public function check() { $cookieName = $this->getCookieName( 'cookies' ); $cookieValue = absint( $this->getCookie( $cookieName ) ); $result = ! ( $cookieValue >= $this->getVotesPerSession() );
return $result ?: new \WP_Error( 'cookies', $this->getMessage() ); }
/** * Apply restriction. */ public function apply() { $cookieTimeout = $this->getTimeout(); $cookieName = $this->getCookieName( 'cookies' ); $cookieValue = absint( $this->getCookie( $cookieName ) ); $this->setCookie( $cookieName, $cookieValue + 1, $cookieTimeout ); } }
|