C:\xampp\htdocs\landing\wp-content\plugins\totalpoll\src\Limitations\Period.php


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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php

namespace TotalPoll\Limitations;
defined'ABSPATH' ) && exit();


use 
TotalPollVendors\TotalCore\Limitations\Limitation;

/**
 * Period Limitation
 * @package TotalPoll\Limitations
 */
class Period extends Limitation {
    
/**
     * Limitation check logic.
     *
     * @return bool|\WP_Error
     */
    
public function check() {
        
$startDate = empty( $this->args['start'] ) ? false TotalPoll'datetime', [ $this->args['start'] ] );
        
$endDate   = empty( $this->args['end'] ) ? false TotalPoll'datetime', [ $this->args['end'] ] );
        
$now       TotalPoll'datetime' );

        if ( 
$startDate && $startDate->getTimestamp() > $now->getTimestamp() ):
            
$interval $startDate->diff$nowtrue );

            return new \
WP_Error(
                
'start_date',
                
sprintf(
                    
__'This poll has not started yet (%s left).''totalpoll' ),
                    
$this->getDiffForHumans$interval )
                )
            );
        endif;

        if ( 
$endDate && $endDate->getTimestamp() < $now->getTimestamp() ):
            
$interval $endDate->diff$nowtrue );

            return new \
WP_Error(
                
'end_date',
                
sprintf(
                    
__'This poll has ended (since %s).''totalpoll' ),
                    
$this->getDiffForHumans$interval )
                )
            );
        endif;

        return 
true;
    }

    private function 
getDiffForHumans$interval ) {
        if ( 
$interval->):
            return 
$interval->format_n'%y year''%y years'$interval->y'totalpoll' ) );
        elseif ( 
$interval->):
            return 
$interval->format_n'%m month''%m months'$interval->m'totalpoll' ) );
        elseif ( 
$interval->):
            return 
$interval->format_n'%d day''%d days'$interval->d'totalpoll' ) );
        elseif ( 
$interval->):
            return 
$interval->format_n'%h hour''%h hours'$interval->h'totalpoll' ) );
        elseif ( 
$interval->):
            return 
$interval->format_n'%i minute''%i minutes'$interval->i'totalpoll' ) );
        elseif ( 
$interval->):
            return 
$interval->format_n'%s second''%s seconds'$interval->s'totalpoll' ) );
        endif;

        return 
'';
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586