Completed
Branch FET/extract-activation-detecti... (0caf02)
by
unknown
07:12 queued 05:14
created
core/services/request/Response.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public function setNotice($key, $value)
60 60
     {
61
-        $this->notice[ $key ] = $value;
61
+        $this->notice[$key] = $value;
62 62
     }
63 63
 
64 64
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function getNotice($key)
71 71
     {
72
-        return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null;
72
+        return isset($this->notice[$key]) ? $this->notice[$key] : null;
73 73
     }
74 74
 
75 75
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function addOutput($string, $append = true)
92 92
     {
93
-        $this->output = $append ? $this->output . $string : $string . $this->output;
93
+        $this->output = $append ? $this->output.$string : $string.$this->output;
94 94
     }
95 95
 
96 96
 
Please login to merge, or discard this patch.
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -16,119 +16,119 @@
 block discarded – undo
16 16
 class Response implements ResponseInterface, ReservedInstanceInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var array $notice
21
-     */
22
-    protected $notice = array();
23
-
24
-    /**
25
-     * rendered output to be returned to WP
26
-     *
27
-     * @var string $output
28
-     */
29
-    protected $output = '';
30
-
31
-    /**
32
-     * @var bool
33
-     */
34
-    protected $request_terminated = false;
35
-
36
-    /**
37
-     * @var bool $deactivate_plugin
38
-     */
39
-    protected $deactivate_plugin = false;
40
-
41
-
42
-    /**
43
-     * EE_Response constructor.
44
-     */
45
-    public function __construct()
46
-    {
47
-        $this->terminateRequest(false);
48
-    }
49
-
50
-
51
-    /**
52
-     * @param $key
53
-     * @param $value
54
-     * @return    void
55
-     */
56
-    public function setNotice($key, $value)
57
-    {
58
-        $this->notice[ $key ] = $value;
59
-    }
60
-
61
-
62
-    /**
63
-     * @param $key
64
-     * @return    mixed
65
-     */
66
-    public function getNotice($key)
67
-    {
68
-        return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null;
69
-    }
70
-
71
-
72
-    /**
73
-     * @return array
74
-     */
75
-    public function getNotices()
76
-    {
77
-        return $this->notice;
78
-    }
79
-
80
-
81
-    /**
82
-     * @param string $string
83
-     * @param bool   $append
84
-     */
85
-    public function addOutput($string, $append = true)
86
-    {
87
-        $this->output = $append ? $this->output . $string : $string . $this->output;
88
-    }
89
-
90
-
91
-    /**
92
-     * @return string
93
-     */
94
-    public function getOutput()
95
-    {
96
-        return $this->output;
97
-    }
98
-
99
-
100
-    /**
101
-     * @return boolean
102
-     */
103
-    public function requestTerminated()
104
-    {
105
-        return $this->request_terminated;
106
-    }
107
-
108
-
109
-    /**
110
-     * @param boolean $request_terminated
111
-     */
112
-    public function terminateRequest($request_terminated = true)
113
-    {
114
-        $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN);
115
-    }
116
-
117
-
118
-    /**
119
-     * @return boolean
120
-     */
121
-    public function pluginDeactivated()
122
-    {
123
-        return $this->deactivate_plugin;
124
-    }
125
-
126
-
127
-    /**
128
-     * sets $deactivate_plugin to true
129
-     */
130
-    public function deactivatePlugin()
131
-    {
132
-        $this->deactivate_plugin = true;
133
-    }
19
+	/**
20
+	 * @var array $notice
21
+	 */
22
+	protected $notice = array();
23
+
24
+	/**
25
+	 * rendered output to be returned to WP
26
+	 *
27
+	 * @var string $output
28
+	 */
29
+	protected $output = '';
30
+
31
+	/**
32
+	 * @var bool
33
+	 */
34
+	protected $request_terminated = false;
35
+
36
+	/**
37
+	 * @var bool $deactivate_plugin
38
+	 */
39
+	protected $deactivate_plugin = false;
40
+
41
+
42
+	/**
43
+	 * EE_Response constructor.
44
+	 */
45
+	public function __construct()
46
+	{
47
+		$this->terminateRequest(false);
48
+	}
49
+
50
+
51
+	/**
52
+	 * @param $key
53
+	 * @param $value
54
+	 * @return    void
55
+	 */
56
+	public function setNotice($key, $value)
57
+	{
58
+		$this->notice[ $key ] = $value;
59
+	}
60
+
61
+
62
+	/**
63
+	 * @param $key
64
+	 * @return    mixed
65
+	 */
66
+	public function getNotice($key)
67
+	{
68
+		return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null;
69
+	}
70
+
71
+
72
+	/**
73
+	 * @return array
74
+	 */
75
+	public function getNotices()
76
+	{
77
+		return $this->notice;
78
+	}
79
+
80
+
81
+	/**
82
+	 * @param string $string
83
+	 * @param bool   $append
84
+	 */
85
+	public function addOutput($string, $append = true)
86
+	{
87
+		$this->output = $append ? $this->output . $string : $string . $this->output;
88
+	}
89
+
90
+
91
+	/**
92
+	 * @return string
93
+	 */
94
+	public function getOutput()
95
+	{
96
+		return $this->output;
97
+	}
98
+
99
+
100
+	/**
101
+	 * @return boolean
102
+	 */
103
+	public function requestTerminated()
104
+	{
105
+		return $this->request_terminated;
106
+	}
107
+
108
+
109
+	/**
110
+	 * @param boolean $request_terminated
111
+	 */
112
+	public function terminateRequest($request_terminated = true)
113
+	{
114
+		$this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN);
115
+	}
116
+
117
+
118
+	/**
119
+	 * @return boolean
120
+	 */
121
+	public function pluginDeactivated()
122
+	{
123
+		return $this->deactivate_plugin;
124
+	}
125
+
126
+
127
+	/**
128
+	 * sets $deactivate_plugin to true
129
+	 */
130
+	public function deactivatePlugin()
131
+	{
132
+		$this->deactivate_plugin = true;
133
+	}
134 134
 }
Please login to merge, or discard this patch.
core/services/request/middleware/PreProductionVersionWarning.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
     public function preProductionVersionAdminNotice()
79 79
     {
80 80
         new PersistentAdminNotice(
81
-            'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION,
81
+            'preProductionVersionAdminNotice_'.EVENT_ESPRESSO_VERSION,
82 82
             $this->warningNotice()
83 83
         );
84 84
     }
Please login to merge, or discard this patch.
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -18,91 +18,91 @@
 block discarded – undo
18 18
 class PreProductionVersionWarning extends Middleware
19 19
 {
20 20
 
21
-    /**
22
-     * converts a Request to a Response
23
-     *
24
-     * @param RequestInterface  $request
25
-     * @param ResponseInterface $response
26
-     * @return ResponseInterface
27
-     */
28
-    public function handleRequest(RequestInterface $request, ResponseInterface $response)
29
-    {
30
-        $this->request = $request;
31
-        $this->response = $response;
32
-        $this->displayPreProductionVersionWarning();
33
-        $this->response = $this->processRequestStack($this->request, $this->response);
34
-        return $this->response;
35
-    }
21
+	/**
22
+	 * converts a Request to a Response
23
+	 *
24
+	 * @param RequestInterface  $request
25
+	 * @param ResponseInterface $response
26
+	 * @return ResponseInterface
27
+	 */
28
+	public function handleRequest(RequestInterface $request, ResponseInterface $response)
29
+	{
30
+		$this->request = $request;
31
+		$this->response = $response;
32
+		$this->displayPreProductionVersionWarning();
33
+		$this->response = $this->processRequestStack($this->request, $this->response);
34
+		return $this->response;
35
+	}
36 36
 
37 37
 
38
-    /**
39
-     * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode
40
-     *
41
-     * @return void
42
-     */
43
-    public function displayPreProductionVersionWarning()
44
-    {
45
-        // skip AJAX requests
46
-        if ($this->request->isAjax()) {
47
-            return;
48
-        }
49
-        // skip stable releases
50
-        if (substr(EVENT_ESPRESSO_VERSION, -5) !== '.beta') {
51
-            return;
52
-        }
53
-        // site admin has authorized use of non-stable release candidate for production
54
-        if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) {
55
-            return;
56
-        }
57
-        // post release candidate warning
58
-        if ($this->request->isAdmin()) {
59
-            add_action('admin_notices', array($this, 'preProductionVersionAdminNotice'), -999);
60
-        } else {
61
-            add_action('shutdown', array($this, 'preProductionVersionWarningNotice'), 10);
62
-        }
63
-    }
38
+	/**
39
+	 * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode
40
+	 *
41
+	 * @return void
42
+	 */
43
+	public function displayPreProductionVersionWarning()
44
+	{
45
+		// skip AJAX requests
46
+		if ($this->request->isAjax()) {
47
+			return;
48
+		}
49
+		// skip stable releases
50
+		if (substr(EVENT_ESPRESSO_VERSION, -5) !== '.beta') {
51
+			return;
52
+		}
53
+		// site admin has authorized use of non-stable release candidate for production
54
+		if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) {
55
+			return;
56
+		}
57
+		// post release candidate warning
58
+		if ($this->request->isAdmin()) {
59
+			add_action('admin_notices', array($this, 'preProductionVersionAdminNotice'), -999);
60
+		} else {
61
+			add_action('shutdown', array($this, 'preProductionVersionWarningNotice'), 10);
62
+		}
63
+	}
64 64
 
65 65
 
66
-    /**
67
-     * displays admin notice that current version of EE is not a stable release
68
-     *
69
-     * @return void
70
-     * @throws InvalidDataTypeException
71
-     */
72
-    public function preProductionVersionAdminNotice()
73
-    {
74
-        new PersistentAdminNotice(
75
-            'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION,
76
-            $this->warningNotice()
77
-        );
78
-    }
66
+	/**
67
+	 * displays admin notice that current version of EE is not a stable release
68
+	 *
69
+	 * @return void
70
+	 * @throws InvalidDataTypeException
71
+	 */
72
+	public function preProductionVersionAdminNotice()
73
+	{
74
+		new PersistentAdminNotice(
75
+			'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION,
76
+			$this->warningNotice()
77
+		);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * displays message on frontend of site notifying admin that current version of EE is not a stable release
83
-     *
84
-     * @return void
85
-     */
86
-    public function preProductionVersionWarningNotice()
87
-    {
88
-        echo '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>';
89
-        echo $this->warningNotice();
90
-        echo '</p></div>';
91
-    }
81
+	/**
82
+	 * displays message on frontend of site notifying admin that current version of EE is not a stable release
83
+	 *
84
+	 * @return void
85
+	 */
86
+	public function preProductionVersionWarningNotice()
87
+	{
88
+		echo '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>';
89
+		echo $this->warningNotice();
90
+		echo '</p></div>';
91
+	}
92 92
 
93 93
 
94
-    /**
95
-     * @return string
96
-     */
97
-    private function warningNotice()
98
-    {
99
-        return sprintf(
100
-            esc_html__(
101
-                'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.',
102
-                'event_espresso'
103
-            ),
104
-            '<strong>',
105
-            '</strong>'
106
-        );
107
-    }
94
+	/**
95
+	 * @return string
96
+	 */
97
+	private function warningNotice()
98
+	{
99
+		return sprintf(
100
+			esc_html__(
101
+				'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.',
102
+				'event_espresso'
103
+			),
104
+			'<strong>',
105
+			'</strong>'
106
+		);
107
+	}
108 108
 }
Please login to merge, or discard this patch.
core/services/request/RequestStack.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -19,59 +19,59 @@
 block discarded – undo
19 19
 class RequestStack
20 20
 {
21 21
 
22
-    /**
23
-     * @var RequestDecoratorInterface $request_stack_app
24
-     */
25
-    protected $request_stack_app;
22
+	/**
23
+	 * @var RequestDecoratorInterface $request_stack_app
24
+	 */
25
+	protected $request_stack_app;
26 26
 
27
-    /**
28
-     * @var RequestStackCoreAppInterface $core_app
29
-     */
30
-    protected $core_app;
27
+	/**
28
+	 * @var RequestStackCoreAppInterface $core_app
29
+	 */
30
+	protected $core_app;
31 31
 
32
-    /**
33
-     * @var RequestInterface $request
34
-     */
35
-    protected $request;
32
+	/**
33
+	 * @var RequestInterface $request
34
+	 */
35
+	protected $request;
36 36
 
37
-    /**
38
-     * @var ResponseInterface $response
39
-     */
40
-    protected $response;
37
+	/**
38
+	 * @var ResponseInterface $response
39
+	 */
40
+	protected $response;
41 41
 
42 42
 
43
-    /**
44
-     * @param RequestDecoratorInterface    $request_stack_app
45
-     * @param RequestStackCoreAppInterface $core_app
46
-     */
47
-    public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app)
48
-    {
49
-        $this->request_stack_app = $request_stack_app;
50
-        $this->core_app      = $core_app;
51
-    }
43
+	/**
44
+	 * @param RequestDecoratorInterface    $request_stack_app
45
+	 * @param RequestStackCoreAppInterface $core_app
46
+	 */
47
+	public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app)
48
+	{
49
+		$this->request_stack_app = $request_stack_app;
50
+		$this->core_app      = $core_app;
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * @param RequestInterface  $request
56
-     * @param ResponseInterface $response
57
-     * @return ResponseInterface
58
-     */
59
-    public function handleRequest(RequestInterface $request, ResponseInterface $response)
60
-    {
61
-        $this->request  = $request;
62
-        $this->response = $response;
63
-        return $this->request_stack_app->handleRequest($request, $response);
64
-    }
54
+	/**
55
+	 * @param RequestInterface  $request
56
+	 * @param ResponseInterface $response
57
+	 * @return ResponseInterface
58
+	 */
59
+	public function handleRequest(RequestInterface $request, ResponseInterface $response)
60
+	{
61
+		$this->request  = $request;
62
+		$this->response = $response;
63
+		return $this->request_stack_app->handleRequest($request, $response);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * handle_response
69
-     * executes the handle_response() method on the RequestStackCoreAppInterface object
70
-     * after the request stack has been fully processed
71
-     */
72
-    public function handleResponse()
73
-    {
74
-        $this->core_app->handleResponse($this->request, $this->response);
75
-    }
67
+	/**
68
+	 * handle_response
69
+	 * executes the handle_response() method on the RequestStackCoreAppInterface object
70
+	 * after the request stack has been fully processed
71
+	 */
72
+	public function handleResponse()
73
+	{
74
+		$this->core_app->handleResponse($this->request, $this->response);
75
+	}
76 76
 }
77 77
 // Location: RequestStack.php
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
     public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app)
48 48
     {
49 49
         $this->request_stack_app = $request_stack_app;
50
-        $this->core_app      = $core_app;
50
+        $this->core_app = $core_app;
51 51
     }
52 52
 
53 53
 
Please login to merge, or discard this patch.
core/services/collections/iterators/CollectionFilterCallbackIterator.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -9,51 +9,51 @@
 block discarded – undo
9 9
 class CollectionFilterCallbackIterator extends FilterIterator
10 10
 {
11 11
 
12
-    /**
13
-     * Used for determining whether the iterated object in the Collection is "valid" or not.
14
-     * @var Closure
15
-     */
16
-    private $acceptance_callback;
17
-
18
-
19
-    /**
20
-     * CollectionFilterCallbackIterator constructor.
21
-     *
22
-     * @param Collection $collection
23
-     * @param Closure    $acceptance_callback  The closure will receive an instance of whatever object is stored on the
24
-     *                                         collection when iterating over the collection and should return boolean.
25
-     */
26
-    public function __construct(Collection $collection, Closure $acceptance_callback)
27
-    {
28
-        $this->acceptance_callback = $acceptance_callback;
29
-        parent::__construct($collection);
30
-    }
31
-
32
-    /**
33
-     * Check whether the current element of the iterator is acceptable
34
-     *
35
-     * @link  http://php.net/manual/en/filteriterator.accept.php
36
-     * @return bool true if the current element is acceptable, otherwise false.
37
-     */
38
-    public function accept()
39
-    {
40
-        $acceptance_callback = $this->acceptance_callback;
41
-        return $acceptance_callback($this->getInnerIterator()->current());
42
-    }
43
-
44
-
45
-
46
-    /**
47
-     * Returns a filtered array of objects from the collection using the provided acceptance callback
48
-     * @return array
49
-     */
50
-    public function getFiltered()
51
-    {
52
-        $filtered_array = array();
53
-        $this->rewind();
54
-        foreach ($this as $filtered_object) {
55
-            $filtered_array[] = $filtered_object;
56
-        }
57
-        return $filtered_array;
58
-    }
12
+	/**
13
+	 * Used for determining whether the iterated object in the Collection is "valid" or not.
14
+	 * @var Closure
15
+	 */
16
+	private $acceptance_callback;
17
+
18
+
19
+	/**
20
+	 * CollectionFilterCallbackIterator constructor.
21
+	 *
22
+	 * @param Collection $collection
23
+	 * @param Closure    $acceptance_callback  The closure will receive an instance of whatever object is stored on the
24
+	 *                                         collection when iterating over the collection and should return boolean.
25
+	 */
26
+	public function __construct(Collection $collection, Closure $acceptance_callback)
27
+	{
28
+		$this->acceptance_callback = $acceptance_callback;
29
+		parent::__construct($collection);
30
+	}
31
+
32
+	/**
33
+	 * Check whether the current element of the iterator is acceptable
34
+	 *
35
+	 * @link  http://php.net/manual/en/filteriterator.accept.php
36
+	 * @return bool true if the current element is acceptable, otherwise false.
37
+	 */
38
+	public function accept()
39
+	{
40
+		$acceptance_callback = $this->acceptance_callback;
41
+		return $acceptance_callback($this->getInnerIterator()->current());
42
+	}
43
+
44
+
45
+
46
+	/**
47
+	 * Returns a filtered array of objects from the collection using the provided acceptance callback
48
+	 * @return array
49
+	 */
50
+	public function getFiltered()
51
+	{
52
+		$filtered_array = array();
53
+		$this->rewind();
54
+		foreach ($this as $filtered_object) {
55
+			$filtered_array[] = $filtered_object;
56
+		}
57
+		return $filtered_array;
58
+	}
59 59
 }
Please login to merge, or discard this patch.
core/services/helpers/datetime/HelperInterface.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -16,94 +16,94 @@
 block discarded – undo
16 16
 interface HelperInterface
17 17
 {
18 18
 
19
-    /**
20
-     * Ensures that a valid timezone string is returned.
21
-     *
22
-     * @param string $timezone_string  When not provided then attempt to use the timezone_string set in the WP Time
23
-     *                                 settings (or derive from set UTC offset).
24
-     * @return string
25
-     */
26
-    public function getValidTimezoneString($timezone_string = '');
27
-
28
-
29
-    /**
30
-     * The only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
31
-     *
32
-     * @param string $timezone_string
33
-     * @param bool   $throw_error
34
-     * @return bool
35
-     */
36
-    public function validateTimezone($timezone_string, $throw_error = true);
37
-
38
-
39
-    /**
40
-     * Returns a timezone string for the provided gmt_offset.
41
-     * @param float|string $gmt_offset
42
-     * @return string
43
-     */
44
-    public function getTimezoneStringFromGmtOffset($gmt_offset = '');
45
-
46
-
47
-    /**
48
-     * Gets the site's GMT offset based on either the timezone string
49
-     * (in which case the gmt offset will vary depending on the location's
50
-     * observance of daylight savings time) or the gmt_offset wp option
51
-     *
52
-     * @return int  seconds offset
53
-     */
54
-    public function getSiteTimezoneGmtOffset();
55
-
56
-
57
-    /**
58
-     * Get timezone transitions
59
-     * @param DateTimeZone $date_time_zone
60
-     * @param int|null     $time
61
-     * @param bool         $first_only
62
-     * @return array
63
-     */
64
-    public function getTimezoneTransitions(DateTimeZone $date_time_zone, $time = null, $first_only = true);
65
-
66
-
67
-    /**
68
-     * Get Timezone offset for given timezone object
69
-     * @param DateTimeZone $date_time_zone
70
-     * @param null|int         $time
71
-     * @return int
72
-     */
73
-    public function getTimezoneOffset(DateTimeZone $date_time_zone, $time = null);
74
-
75
-
76
-    /**
77
-     * Provide a timezone select input
78
-     * @param string $timezone_string
79
-     * @return string
80
-     */
81
-    public function timezoneSelectInput($timezone_string = '');
82
-
83
-
84
-    /**
85
-     * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
86
-     * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
87
-     * the site is used.
88
-     * This is used typically when using a Unix timestamp any core WP functions that expect their specially
89
-     * computed timestamp (i.e. date_i18n() )
90
-     *
91
-     * @param int    $unix_timestamp    if 0, then time() will be used.
92
-     * @param string $timezone_string timezone_string. If empty, then the current set timezone for the
93
-     *                                site will be used.
94
-     * @return int      unix_timestamp value with the offset applied for the given timezone.
95
-     */
96
-    public function getTimestampWithOffset($unix_timestamp = 0, $timezone_string = '');
97
-
98
-
99
-    /**
100
-     * Depending on PHP version,
101
-     * there might not be valid current timezone strings to match these gmt_offsets in its timezone tables.
102
-     * To get around that, for these fringe timezones we bump them to a known valid offset.
103
-     * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
104
-     *
105
-     * @param int $gmt_offset
106
-     * @return int
107
-     */
108
-    public function adjustInvalidGmtOffsets($gmt_offset);
19
+	/**
20
+	 * Ensures that a valid timezone string is returned.
21
+	 *
22
+	 * @param string $timezone_string  When not provided then attempt to use the timezone_string set in the WP Time
23
+	 *                                 settings (or derive from set UTC offset).
24
+	 * @return string
25
+	 */
26
+	public function getValidTimezoneString($timezone_string = '');
27
+
28
+
29
+	/**
30
+	 * The only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
31
+	 *
32
+	 * @param string $timezone_string
33
+	 * @param bool   $throw_error
34
+	 * @return bool
35
+	 */
36
+	public function validateTimezone($timezone_string, $throw_error = true);
37
+
38
+
39
+	/**
40
+	 * Returns a timezone string for the provided gmt_offset.
41
+	 * @param float|string $gmt_offset
42
+	 * @return string
43
+	 */
44
+	public function getTimezoneStringFromGmtOffset($gmt_offset = '');
45
+
46
+
47
+	/**
48
+	 * Gets the site's GMT offset based on either the timezone string
49
+	 * (in which case the gmt offset will vary depending on the location's
50
+	 * observance of daylight savings time) or the gmt_offset wp option
51
+	 *
52
+	 * @return int  seconds offset
53
+	 */
54
+	public function getSiteTimezoneGmtOffset();
55
+
56
+
57
+	/**
58
+	 * Get timezone transitions
59
+	 * @param DateTimeZone $date_time_zone
60
+	 * @param int|null     $time
61
+	 * @param bool         $first_only
62
+	 * @return array
63
+	 */
64
+	public function getTimezoneTransitions(DateTimeZone $date_time_zone, $time = null, $first_only = true);
65
+
66
+
67
+	/**
68
+	 * Get Timezone offset for given timezone object
69
+	 * @param DateTimeZone $date_time_zone
70
+	 * @param null|int         $time
71
+	 * @return int
72
+	 */
73
+	public function getTimezoneOffset(DateTimeZone $date_time_zone, $time = null);
74
+
75
+
76
+	/**
77
+	 * Provide a timezone select input
78
+	 * @param string $timezone_string
79
+	 * @return string
80
+	 */
81
+	public function timezoneSelectInput($timezone_string = '');
82
+
83
+
84
+	/**
85
+	 * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
86
+	 * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
87
+	 * the site is used.
88
+	 * This is used typically when using a Unix timestamp any core WP functions that expect their specially
89
+	 * computed timestamp (i.e. date_i18n() )
90
+	 *
91
+	 * @param int    $unix_timestamp    if 0, then time() will be used.
92
+	 * @param string $timezone_string timezone_string. If empty, then the current set timezone for the
93
+	 *                                site will be used.
94
+	 * @return int      unix_timestamp value with the offset applied for the given timezone.
95
+	 */
96
+	public function getTimestampWithOffset($unix_timestamp = 0, $timezone_string = '');
97
+
98
+
99
+	/**
100
+	 * Depending on PHP version,
101
+	 * there might not be valid current timezone strings to match these gmt_offsets in its timezone tables.
102
+	 * To get around that, for these fringe timezones we bump them to a known valid offset.
103
+	 * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
104
+	 *
105
+	 * @param int $gmt_offset
106
+	 * @return int
107
+	 */
108
+	public function adjustInvalidGmtOffsets($gmt_offset);
109 109
 }
Please login to merge, or discard this patch.
core/services/context/ContextChecker.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
87 87
     {
88 88
         $this->evaluation_callback = $evaluation_callback instanceof Closure
89 89
             ? $evaluation_callback
90
-            : function (ContextInterface $context, $acceptable_values) {
90
+            : function(ContextInterface $context, $acceptable_values) {
91 91
                 return in_array($context->slug(), $acceptable_values, true);
92 92
             };
93 93
     }
Please login to merge, or discard this patch.
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -17,145 +17,145 @@
 block discarded – undo
17 17
 class ContextChecker
18 18
 {
19 19
 
20
-    /**
21
-     * A unique string used to identify where this ContextChecker is being employed
22
-     * Is currently only used within the hook name for the filterable return value of isAllowed().
23
-     *
24
-     * @var string $identifier
25
-     */
26
-    private $identifier;
27
-
28
-    /**
29
-     * A list of values to be compared against the slug of the Context class passed to isAllowed()
30
-     *
31
-     * @var array $acceptable_values
32
-     */
33
-    private $acceptable_values;
34
-
35
-    /**
36
-     * Closure that will be called to perform the evaluation within isAllowed().
37
-     * If none is provided, then a simple type sensitive in_array() check will be used
38
-     * and return true if the incoming Context::slug() is found within the array of $acceptable_values.
39
-     *
40
-     * @var Closure $evaluation_callback
41
-     */
42
-    private $evaluation_callback;
43
-
44
-
45
-    /**
46
-     * ContextChecker constructor.
47
-     *
48
-     * @param string       $identifier
49
-     * @param array        $acceptable_values
50
-     * @param Closure|null $evaluation_callback [optional]
51
-     */
52
-    public function __construct($identifier, array $acceptable_values, Closure $evaluation_callback = null)
53
-    {
54
-        $this->setIdentifier($identifier);
55
-        $this->setAcceptableValues($acceptable_values);
56
-        $this->setEvaluationCallback($evaluation_callback);
57
-    }
58
-
59
-
60
-    /**
61
-     * @param string $identifier
62
-     */
63
-    private function setIdentifier($identifier)
64
-    {
65
-        $this->identifier = sanitize_key($identifier);
66
-    }
67
-
68
-
69
-    /**
70
-     * @param array $acceptable_values
71
-     */
72
-    private function setAcceptableValues(array $acceptable_values)
73
-    {
74
-        $this->acceptable_values = $acceptable_values;
75
-    }
76
-
77
-
78
-    /**
79
-     * @param Closure $evaluation_callback
80
-     */
81
-    private function setEvaluationCallback(Closure $evaluation_callback = null)
82
-    {
83
-        $this->evaluation_callback = $evaluation_callback instanceof Closure
84
-            ? $evaluation_callback
85
-            : function (ContextInterface $context, $acceptable_values) {
86
-                return in_array($context->slug(), $acceptable_values, true);
87
-            };
88
-    }
89
-
90
-
91
-    /**
92
-     * @return string
93
-     */
94
-    protected function identifier()
95
-    {
96
-        return $this->identifier;
97
-    }
98
-
99
-
100
-    /**
101
-     * @return array
102
-     */
103
-    protected function acceptableValues()
104
-    {
105
-        return apply_filters(
106
-            "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__acceptableValues",
107
-            $this->acceptable_values
108
-        );
109
-    }
110
-
111
-
112
-    /**
113
-     * @return Closure
114
-     */
115
-    protected function evaluationCallback()
116
-    {
117
-        return $this->evaluation_callback;
118
-    }
119
-
120
-
121
-    /**
122
-     * Returns true if the incoming Context class slug matches one of the preset acceptable values.
123
-     * The result is filterable using the identifier for this ContextChecker.
124
-     * example:
125
-     * If this ContextChecker's $identifier was set to "registration-checkout-type",
126
-     * then the filter here would be named:
127
-     *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed".
128
-     * Other code could hook into the filter in isAllowed() using the above name
129
-     * and test for additional acceptable values.
130
-     * So if the set of $acceptable_values was: [ "initial-visit",  "revisit" ]
131
-     * then adding a filter to
132
-     *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed",
133
-     * would allow you to perform your own conditional and allow "wait-list-checkout" as an acceptable value.
134
-     *  example:
135
-     *      add_filter(
136
-     *          'FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed',
137
-     *          function ($is_allowed, ContextInterface $context) { return $context->slug() === 'wait-list-checkout'
138
-     *                  ? true
139
-     *                  : $is_allowed;
140
-     *          },
141
-     *          10,
142
-     *          2
143
-     *      );
144
-     *
145
-     * @param ContextInterface $context
146
-     * @return boolean
147
-     */
148
-    public function isAllowed(ContextInterface $context)
149
-    {
150
-        $evaluation_callback = $this->evaluationCallback();
151
-        return filter_var(
152
-            apply_filters(
153
-                "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__isAllowed",
154
-                $evaluation_callback($context, $this->acceptableValues()),
155
-                $context,
156
-                $this
157
-            ),
158
-            FILTER_VALIDATE_BOOLEAN
159
-        );
160
-    }
20
+	/**
21
+	 * A unique string used to identify where this ContextChecker is being employed
22
+	 * Is currently only used within the hook name for the filterable return value of isAllowed().
23
+	 *
24
+	 * @var string $identifier
25
+	 */
26
+	private $identifier;
27
+
28
+	/**
29
+	 * A list of values to be compared against the slug of the Context class passed to isAllowed()
30
+	 *
31
+	 * @var array $acceptable_values
32
+	 */
33
+	private $acceptable_values;
34
+
35
+	/**
36
+	 * Closure that will be called to perform the evaluation within isAllowed().
37
+	 * If none is provided, then a simple type sensitive in_array() check will be used
38
+	 * and return true if the incoming Context::slug() is found within the array of $acceptable_values.
39
+	 *
40
+	 * @var Closure $evaluation_callback
41
+	 */
42
+	private $evaluation_callback;
43
+
44
+
45
+	/**
46
+	 * ContextChecker constructor.
47
+	 *
48
+	 * @param string       $identifier
49
+	 * @param array        $acceptable_values
50
+	 * @param Closure|null $evaluation_callback [optional]
51
+	 */
52
+	public function __construct($identifier, array $acceptable_values, Closure $evaluation_callback = null)
53
+	{
54
+		$this->setIdentifier($identifier);
55
+		$this->setAcceptableValues($acceptable_values);
56
+		$this->setEvaluationCallback($evaluation_callback);
57
+	}
58
+
59
+
60
+	/**
61
+	 * @param string $identifier
62
+	 */
63
+	private function setIdentifier($identifier)
64
+	{
65
+		$this->identifier = sanitize_key($identifier);
66
+	}
67
+
68
+
69
+	/**
70
+	 * @param array $acceptable_values
71
+	 */
72
+	private function setAcceptableValues(array $acceptable_values)
73
+	{
74
+		$this->acceptable_values = $acceptable_values;
75
+	}
76
+
77
+
78
+	/**
79
+	 * @param Closure $evaluation_callback
80
+	 */
81
+	private function setEvaluationCallback(Closure $evaluation_callback = null)
82
+	{
83
+		$this->evaluation_callback = $evaluation_callback instanceof Closure
84
+			? $evaluation_callback
85
+			: function (ContextInterface $context, $acceptable_values) {
86
+				return in_array($context->slug(), $acceptable_values, true);
87
+			};
88
+	}
89
+
90
+
91
+	/**
92
+	 * @return string
93
+	 */
94
+	protected function identifier()
95
+	{
96
+		return $this->identifier;
97
+	}
98
+
99
+
100
+	/**
101
+	 * @return array
102
+	 */
103
+	protected function acceptableValues()
104
+	{
105
+		return apply_filters(
106
+			"FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__acceptableValues",
107
+			$this->acceptable_values
108
+		);
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return Closure
114
+	 */
115
+	protected function evaluationCallback()
116
+	{
117
+		return $this->evaluation_callback;
118
+	}
119
+
120
+
121
+	/**
122
+	 * Returns true if the incoming Context class slug matches one of the preset acceptable values.
123
+	 * The result is filterable using the identifier for this ContextChecker.
124
+	 * example:
125
+	 * If this ContextChecker's $identifier was set to "registration-checkout-type",
126
+	 * then the filter here would be named:
127
+	 *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed".
128
+	 * Other code could hook into the filter in isAllowed() using the above name
129
+	 * and test for additional acceptable values.
130
+	 * So if the set of $acceptable_values was: [ "initial-visit",  "revisit" ]
131
+	 * then adding a filter to
132
+	 *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed",
133
+	 * would allow you to perform your own conditional and allow "wait-list-checkout" as an acceptable value.
134
+	 *  example:
135
+	 *      add_filter(
136
+	 *          'FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed',
137
+	 *          function ($is_allowed, ContextInterface $context) { return $context->slug() === 'wait-list-checkout'
138
+	 *                  ? true
139
+	 *                  : $is_allowed;
140
+	 *          },
141
+	 *          10,
142
+	 *          2
143
+	 *      );
144
+	 *
145
+	 * @param ContextInterface $context
146
+	 * @return boolean
147
+	 */
148
+	public function isAllowed(ContextInterface $context)
149
+	{
150
+		$evaluation_callback = $this->evaluationCallback();
151
+		return filter_var(
152
+			apply_filters(
153
+				"FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__isAllowed",
154
+				$evaluation_callback($context, $this->acceptableValues()),
155
+				$context,
156
+				$this
157
+			),
158
+			FILTER_VALIDATE_BOOLEAN
159
+		);
160
+	}
161 161
 }
Please login to merge, or discard this patch.
core/domain/entities/contexts/ContextInterface.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@
 block discarded – undo
18 18
 interface ContextInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @return string
23
-     */
24
-    public function slug();
21
+	/**
22
+	 * @return string
23
+	 */
24
+	public function slug();
25 25
 
26 26
 
27
-    /**
28
-     * @return string
29
-     */
30
-    public function description();
27
+	/**
28
+	 * @return string
29
+	 */
30
+	public function description();
31 31
 }
Please login to merge, or discard this patch.
acceptance_tests/tests/b-TestRegistrationSummaryCept.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 
15 15
 //need the MER plugin active for this test (we'll deactivate it after).
16 16
 $I->ensurePluginActive(
17
-    'event-espresso-mer-multi-event-registration',
18
-    'activated'
17
+	'event-espresso-mer-multi-event-registration',
18
+	'activated'
19 19
 );
20 20
 
21 21
 //k now we need to make sure the registration multi-status message type is active because it isn't by default
@@ -73,38 +73,38 @@  discard block
 block discarded – undo
73 73
 $I->loginAsAdmin();
74 74
 $I->amOnMessagesActivityListTablePage();
75 75
 $I->see(
76
-    '[email protected]',
77
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
78
-        'to',
79
-        'Registration Multi-status Summary',
80
-        MessagesAdmin::MESSAGE_STATUS_SENT,
81
-        '',
82
-        'Primary Registrant'
83
-    )
76
+	'[email protected]',
77
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
78
+		'to',
79
+		'Registration Multi-status Summary',
80
+		MessagesAdmin::MESSAGE_STATUS_SENT,
81
+		'',
82
+		'Primary Registrant'
83
+	)
84 84
 );
85 85
 $I->see(
86
-    '[email protected]',
87
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
88
-        'to',
89
-        'Registration Multi-status Summary',
90
-        MessagesAdmin::MESSAGE_STATUS_SENT
91
-    )
86
+	'[email protected]',
87
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
88
+		'to',
89
+		'Registration Multi-status Summary',
90
+		MessagesAdmin::MESSAGE_STATUS_SENT
91
+	)
92 92
 );
93 93
 //verify count
94 94
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
95
-    1,
96
-    '[email protected]',
97
-    'to',
98
-    'Registration Multi-status Summary',
99
-    MessagesAdmin::MESSAGE_STATUS_SENT,
100
-    'Email',
101
-    'Primary Registrant'
95
+	1,
96
+	'[email protected]',
97
+	'to',
98
+	'Registration Multi-status Summary',
99
+	MessagesAdmin::MESSAGE_STATUS_SENT,
100
+	'Email',
101
+	'Primary Registrant'
102 102
 );
103 103
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
104
-    1,
105
-    '[email protected]',
106
-    'to',
107
-    'Registration Multi-status Summary'
104
+	1,
105
+	'[email protected]',
106
+	'to',
107
+	'Registration Multi-status Summary'
108 108
 );
109 109
 
110 110
 //okay now let's do some registrations for just the first event and verify that registration multi-status summary is NOT
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
 $I->loginAsAdmin();
135 135
 $I->amOnMessagesActivityListTablePage();
136 136
 $I->dontSee(
137
-    '[email protected]',
138
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
139
-        'to',
140
-        'Registration Multi-status Summary',
141
-        MessagesAdmin::MESSAGE_STATUS_SENT,
142
-        '',
143
-        'Primary Registrant'
144
-    )
137
+	'[email protected]',
138
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
139
+		'to',
140
+		'Registration Multi-status Summary',
141
+		MessagesAdmin::MESSAGE_STATUS_SENT,
142
+		'',
143
+		'Primary Registrant'
144
+	)
145 145
 );
146 146
 //there should still only be one admin multi-status summary thing.
147 147
 $I->verifyMatchingCountofTextInMessageActivityListTableFor(
148
-    1,
149
-    '[email protected]',
150
-    'to',
151
-    'Registration Multi-status Summary'
148
+	1,
149
+	'[email protected]',
150
+	'to',
151
+	'Registration Multi-status Summary'
152 152
 );
153 153
 
154 154
 //deactivate MER plugin so its not active for future tests
155 155
 $I->ensurePluginDeactivated(
156
-    'event-espresso-mer-multi-event-registration',
157
-    'plugins deactivated'
156
+	'event-espresso-mer-multi-event-registration',
157
+	'plugins deactivated'
158 158
 );
159 159
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/tests/c-TestCustomMessageTemplateCept.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 $event_one_link = $event_two_link = $event_three_link = '';
19 19
 
20 20
 $I->wantTo(
21
-    'Test that when registrations for multiple events are completed, and those events share the same custom'
22
-    . 'template, that that custom template will be used.'
21
+	'Test that when registrations for multiple events are completed, and those events share the same custom'
22
+	. 'template, that that custom template will be used.'
23 23
 );
24 24
 
25 25
 //need the MER plugin active for this test (we'll deactivate it after).
26 26
 $I->ensurePluginActive(
27
-    'event-espresso-mer-multi-event-registration',
28
-    'activated'
27
+	'event-espresso-mer-multi-event-registration',
28
+	'activated'
29 29
 );
30 30
 
31 31
 $I->loginAsAdmin();
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 
81 81
 
82 82
 $test_registration_details = array(
83
-    'fname' => 'CTGuy',
84
-    'lname' => 'Dude',
85
-    'email' => '[email protected]'
83
+	'fname' => 'CTGuy',
84
+	'lname' => 'Dude',
85
+	'email' => '[email protected]'
86 86
 );
87 87
 
88 88
 $I->amGoingTo('Register for Event One and Event Two and verify Custom Template A was used.');
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 $I->loginAsAdmin();
109 109
 $I->amOnMessagesActivityListTablePage();
110 110
 $I->viewMessageInMessagesListTableFor(
111
-    'Registration Approved',
112
-    MessagesAdmin::MESSAGE_STATUS_SENT,
113
-    'Email',
114
-    'Registrant'
111
+	'Registration Approved',
112
+	MessagesAdmin::MESSAGE_STATUS_SENT,
113
+	'Email',
114
+	'Registrant'
115 115
 );
116 116
 $I->seeTextInViewMessageModal($custom_template_a_label);
117 117
 $I->dismissMessageModal();
118 118
 $I->deleteMessageInMessagesListTableFor(
119
-    'Registration Approved',
120
-    MessagesAdmin::MESSAGE_STATUS_SENT,
121
-    'Email',
122
-    'Registrant'
119
+	'Registration Approved',
120
+	MessagesAdmin::MESSAGE_STATUS_SENT,
121
+	'Email',
122
+	'Registrant'
123 123
 );
124 124
 
125 125
 //verify admin context
126 126
 $I->viewMessageInMessagesListTableFor(
127
-    'Registration Approved'
127
+	'Registration Approved'
128 128
 );
129 129
 $I->seeTextInViewMessageModal($custom_template_a_label);
130 130
 $I->dismissMessageModal();
@@ -153,25 +153,25 @@  discard block
 block discarded – undo
153 153
 $I->loginAsAdmin();
154 154
 $I->amOnMessagesActivityListTablePage();
155 155
 $I->viewMessageInMessagesListTableFor(
156
-    'Registration Approved',
157
-    MessagesAdmin::MESSAGE_STATUS_SENT,
158
-    'Email',
159
-    'Registrant'
156
+	'Registration Approved',
157
+	MessagesAdmin::MESSAGE_STATUS_SENT,
158
+	'Email',
159
+	'Registrant'
160 160
 );
161 161
 $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR);
162 162
 $I->dontSeeTextInViewMessageModal($custom_template_a_label);
163 163
 $I->dontSeeTextInViewMessageModal($custom_template_b_label);
164 164
 $I->dismissMessageModal();
165 165
 $I->deleteMessageInMessagesListTableFor(
166
-    'Registration Approved',
167
-    MessagesAdmin::MESSAGE_STATUS_SENT,
168
-    'Email',
169
-    'Registrant'
166
+	'Registration Approved',
167
+	MessagesAdmin::MESSAGE_STATUS_SENT,
168
+	'Email',
169
+	'Registrant'
170 170
 );
171 171
 
172 172
 //verify admin context
173 173
 $I->viewMessageInMessagesListTableFor(
174
-    'Registration Approved'
174
+	'Registration Approved'
175 175
 );
176 176
 $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR);
177 177
 $I->dontSee($custom_template_a_label);
@@ -183,6 +183,6 @@  discard block
 block discarded – undo
183 183
 
184 184
 //deactivate MER plugin so its not active for future tests
185 185
 $I->ensurePluginDeactivated(
186
-    'event-espresso-mer-multi-event-registration',
187
-    'plugins deactivated'
186
+	'event-espresso-mer-multi-event-registration',
187
+	'plugins deactivated'
188 188
 );
189 189
\ No newline at end of file
Please login to merge, or discard this patch.