Completed
Branch master (a8bf11)
by
unknown
06:59 queued 20s
created
espresso.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -37,138 +37,138 @@
 block discarded – undo
37 37
  * @since       4.0
38 38
  */
39 39
 if (function_exists('espresso_version')) {
40
-    if (! function_exists('espresso_duplicate_plugin_error')) {
41
-        /**
42
-         *    espresso_duplicate_plugin_error
43
-         *    displays if more than one version of EE is activated at the same time.
44
-         */
45
-        function espresso_duplicate_plugin_error()
46
-        {
47
-            ?>
40
+	if (! function_exists('espresso_duplicate_plugin_error')) {
41
+		/**
42
+		 *    espresso_duplicate_plugin_error
43
+		 *    displays if more than one version of EE is activated at the same time.
44
+		 */
45
+		function espresso_duplicate_plugin_error()
46
+		{
47
+			?>
48 48
 <div class="error">
49 49
     <p>
50 50
         <?php
51
-                    echo esc_html__(
52
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
-                        'event_espresso'
54
-                    ); ?>
51
+					echo esc_html__(
52
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
+						'event_espresso'
54
+					); ?>
55 55
     </p>
56 56
 </div>
57 57
 <?php
58
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
59
-        }
60
-    }
61
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
58
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
59
+		}
60
+	}
61
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62 62
 } else {
63
-    define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
64
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
-        /**
66
-         * espresso_minimum_php_version_error
67
-         *
68
-         * @return void
69
-         */
70
-        function espresso_minimum_php_version_error()
71
-        {
72
-            ?>
63
+	define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
64
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
+		/**
66
+		 * espresso_minimum_php_version_error
67
+		 *
68
+		 * @return void
69
+		 */
70
+		function espresso_minimum_php_version_error()
71
+		{
72
+			?>
73 73
 <div class="error">
74 74
     <p>
75 75
         <?php
76
-                    printf(
77
-                        esc_html__(
78
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
-                            'event_espresso'
80
-                        ),
81
-                        EE_MIN_PHP_VER_REQUIRED,
82
-                        PHP_VERSION,
83
-                        '<br/>',
84
-                        '<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>'
85
-                    );
86
-        ?>
76
+					printf(
77
+						esc_html__(
78
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
+							'event_espresso'
80
+						),
81
+						EE_MIN_PHP_VER_REQUIRED,
82
+						PHP_VERSION,
83
+						'<br/>',
84
+						'<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>'
85
+					);
86
+		?>
87 87
     </p>
88 88
 </div>
89 89
 <?php
90
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
91
-        }
90
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
91
+		}
92 92
 
93
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
-    } else {
95
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
93
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
+	} else {
95
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
96 96
 
97
-        require_once __DIR__ . '/vendor/autoload.php';
97
+		require_once __DIR__ . '/vendor/autoload.php';
98 98
 
99
-        /**
100
-         * espresso_version
101
-         * Returns the plugin version
102
-         *
103
-         * @return string
104
-         */
105
-        function espresso_version(): string
106
-        {
107
-            return apply_filters('FHEE__espresso__espresso_version', '5.0.38.rc.000');
108
-        }
99
+		/**
100
+		 * espresso_version
101
+		 * Returns the plugin version
102
+		 *
103
+		 * @return string
104
+		 */
105
+		function espresso_version(): string
106
+		{
107
+			return apply_filters('FHEE__espresso__espresso_version', '5.0.38.rc.000');
108
+		}
109 109
 
110
-        /**
111
-         * espresso_plugin_activation
112
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
113
-         */
114
-        function espresso_plugin_activation()
115
-        {
116
-            update_option('ee_espresso_activation', true);
117
-            update_option('event-espresso-core_allow_tracking', 'no');
118
-            update_option('event-espresso-core_tracking_notice', 'hide');
119
-            // Run WP GraphQL activation callback
120
-            espressoLoadWpGraphQL();
121
-            graphql_activation_callback();
122
-        }
110
+		/**
111
+		 * espresso_plugin_activation
112
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
113
+		 */
114
+		function espresso_plugin_activation()
115
+		{
116
+			update_option('ee_espresso_activation', true);
117
+			update_option('event-espresso-core_allow_tracking', 'no');
118
+			update_option('event-espresso-core_tracking_notice', 'hide');
119
+			// Run WP GraphQL activation callback
120
+			espressoLoadWpGraphQL();
121
+			graphql_activation_callback();
122
+		}
123 123
 
124
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
124
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
125 125
 
126
-        /**
127
-         * espresso_plugin_deactivation
128
-         */
129
-        function espresso_plugin_deactivation()
130
-        {
131
-            // Run WP GraphQL deactivation callback
132
-            espressoLoadWpGraphQL();
133
-            graphql_deactivation_callback();
134
-            delete_option('event-espresso-core_allow_tracking');
135
-            delete_option('event-espresso-core_tracking_notice');
136
-        }
137
-        register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
126
+		/**
127
+		 * espresso_plugin_deactivation
128
+		 */
129
+		function espresso_plugin_deactivation()
130
+		{
131
+			// Run WP GraphQL deactivation callback
132
+			espressoLoadWpGraphQL();
133
+			graphql_deactivation_callback();
134
+			delete_option('event-espresso-core_allow_tracking');
135
+			delete_option('event-espresso-core_tracking_notice');
136
+		}
137
+		register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
138 138
 
139
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
140
-        bootstrap_espresso();
141
-    }
139
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
140
+		bootstrap_espresso();
141
+	}
142 142
 }
143 143
 
144 144
 if (! function_exists('espresso_deactivate_plugin')) {
145
-    /**
146
-     *    deactivate_plugin
147
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
148
-     *
149
-     * @access public
150
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
151
-     * @return    void
152
-     */
153
-    function espresso_deactivate_plugin(string $plugin_basename = '')
154
-    {
155
-        if (! function_exists('deactivate_plugins')) {
156
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
157
-        }
158
-        unset($_GET['activate'], $_REQUEST['activate']);
159
-        deactivate_plugins($plugin_basename);
160
-    }
145
+	/**
146
+	 *    deactivate_plugin
147
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
148
+	 *
149
+	 * @access public
150
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
151
+	 * @return    void
152
+	 */
153
+	function espresso_deactivate_plugin(string $plugin_basename = '')
154
+	{
155
+		if (! function_exists('deactivate_plugins')) {
156
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
157
+		}
158
+		unset($_GET['activate'], $_REQUEST['activate']);
159
+		deactivate_plugins($plugin_basename);
160
+	}
161 161
 }
162 162
 
163 163
 
164 164
 if (! function_exists('espressoLoadWpGraphQL')) {
165
-    function espressoLoadWpGraphQL()
166
-    {
167
-        if (
168
-            ! class_exists('WPGraphQL')
169
-            && is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php')
170
-        ) {
171
-            require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
172
-        }
173
-    }
165
+	function espressoLoadWpGraphQL()
166
+	{
167
+		if (
168
+			! class_exists('WPGraphQL')
169
+			&& is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php')
170
+		) {
171
+			require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
172
+		}
173
+	}
174 174
 }
Please login to merge, or discard this patch.
core/domain/values/Version.php 1 patch
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -15,300 +15,300 @@
 block discarded – undo
15 15
  */
16 16
 class Version
17 17
 {
18
-    const RELEASE_TYPE_RC    = 'rc';
19
-
20
-    const RELEASE_TYPE_BETA  = 'beta';
21
-
22
-    const RELEASE_TYPE_DECAF = 'decaf';
23
-
24
-    const RELEASE_TYPE_PROD  = 'p';
25
-
26
-    private int $major;
27
-
28
-    private int $minor;
29
-
30
-    private int $patch;
31
-
32
-    private string $release;
33
-
34
-    private int $build;
35
-
36
-
37
-    /**
38
-     * Version constructor.
39
-     *
40
-     * @param int    $major
41
-     * @param int    $minor
42
-     * @param int    $patch
43
-     * @param string $release
44
-     * @param int    $build
45
-     * @throws InvalidDataTypeException
46
-     * @throws InvalidArgumentException
47
-     */
48
-    public function __construct(
49
-        int $major,
50
-        int $minor,
51
-        int $patch,
52
-        string $release = Version::RELEASE_TYPE_PROD,
53
-        int $build = 0
54
-    ) {
55
-        $this->setMajor($major);
56
-        $this->setMinor($minor);
57
-        $this->setPatch($patch);
58
-        $this->setRelease($release);
59
-        $this->setBuild($build);
60
-    }
61
-
62
-
63
-    /**
64
-     * @param string $version_string
65
-     * @return Version
66
-     * @throws InvalidArgumentException
67
-     */
68
-    public static function fromString(string $version_string): Version
69
-    {
70
-        $version_string = trim($version_string);
71
-        // compare incoming version string against the lowest possible valid version
72
-        if (version_compare($version_string, '0.0.1.dev.001', '<')) {
73
-            throw new InvalidArgumentException(
74
-                sprintf(
75
-                    esc_html__('"%1$s" is not a valid version string', 'event_espresso'),
76
-                    $version_string
77
-                )
78
-            );
79
-        }
80
-        // break apart incoming version string
81
-        $version_parts = explode('.', $version_string);
82
-        // verify that version string at least contains {major}.{minor}.{patch}
83
-        if (count($version_parts) < 3) {
84
-            throw new InvalidArgumentException(
85
-                sprintf(
86
-                    esc_html__(
87
-                        'At minimum, a version string needs to be in a "{major}.{minor}.{patch}" format, therefore "%1$s" is not valid',
88
-                        'event_espresso'
89
-                    ),
90
-                    $version_string
91
-                )
92
-            );
93
-        }
94
-        // convert semver 1.2.3.001 to 1.2.3.p.001 style... FOR THE TIME BEING
95
-        if (count($version_parts) === 4 && is_numeric($version_parts[3])) {
96
-            $version_parts[4] = $version_parts[3];
97
-            unset($version_parts[3]);
98
-        }
99
-        $release = isset($version_parts[4]) && (string) $version_parts[4] === '000'
100
-            ? Version::RELEASE_TYPE_PROD
101
-            : Version::RELEASE_TYPE_RC;
102
-        // semver styles like 1.2.3 will be considered production releases
103
-        $release = ! isset($version_parts[3], $version_parts[4])
104
-            ? Version::RELEASE_TYPE_PROD
105
-            : $release;
106
-        // add defaults for missing pieces
107
-        $version_parts += ['0', '0', '0', "$release", '000'];
108
-        ksort($version_parts, SORT_NUMERIC);
109
-        $version_parts = array_map('trim', $version_parts);
110
-        // reassign to individual variables
111
-        [$major, $minor, $patch, $release, $build] = $version_parts;
112
-        return new Version(
113
-            (int) $major,
114
-            (int) $minor,
115
-            (int) $patch,
116
-            (string) $release,
117
-            (int) $build
118
-        );
119
-    }
120
-
121
-
122
-    /**
123
-     * @return int
124
-     */
125
-    public function major(): int
126
-    {
127
-        return $this->major;
128
-    }
129
-
130
-
131
-    /**
132
-     * @param int|string $major
133
-     * @throws InvalidDataTypeException
134
-     */
135
-    private function setMajor($major)
136
-    {
137
-        if (! is_int($major)) {
138
-            throw new InvalidDataTypeException(
139
-                '$major',
140
-                $major,
141
-                'integer'
142
-            );
143
-        }
144
-        $this->major = absint($major);
145
-    }
146
-
147
-
148
-    /**
149
-     * @return int
150
-     */
151
-    public function minor(): int
152
-    {
153
-        return $this->minor;
154
-    }
155
-
156
-
157
-    /**
158
-     * @param int|string $minor
159
-     * @throws InvalidDataTypeException
160
-     */
161
-    private function setMinor($minor)
162
-    {
163
-        if (! is_int($minor)) {
164
-            throw new InvalidDataTypeException(
165
-                '$minor',
166
-                $minor,
167
-                'integer'
168
-            );
169
-        }
170
-        $this->minor = absint($minor);
171
-    }
172
-
173
-
174
-    /**
175
-     * @return int
176
-     */
177
-    public function patch(): int
178
-    {
179
-        return $this->patch;
180
-    }
181
-
182
-
183
-    /**
184
-     * @param int|string $patch
185
-     * @throws InvalidDataTypeException
186
-     */
187
-    private function setPatch($patch)
188
-    {
189
-        if (! is_int($patch)) {
190
-            throw new InvalidDataTypeException(
191
-                '$patch',
192
-                $patch,
193
-                'integer'
194
-            );
195
-        }
196
-        $this->patch = absint($patch);
197
-    }
198
-
199
-
200
-    /**
201
-     * @return string
202
-     */
203
-    public function release(): string
204
-    {
205
-        return $this->release;
206
-    }
207
-
208
-
209
-    /**
210
-     * @param string $release
211
-     * @throws InvalidArgumentException
212
-     */
213
-    private function setRelease(string $release)
214
-    {
215
-        $valid_release_types = [
216
-            Version::RELEASE_TYPE_RC,
217
-            Version::RELEASE_TYPE_BETA,
218
-            Version::RELEASE_TYPE_DECAF,
219
-            Version::RELEASE_TYPE_PROD,
220
-        ];
221
-        if (! in_array($release, $valid_release_types, true)) {
222
-            throw new InvalidArgumentException(
223
-                sprintf(
224
-                    esc_html__(
225
-                        '"%1$s" is not a valid release type. Please use one of the following values: %2$s',
226
-                        'event_espresso'
227
-                    ),
228
-                    $release,
229
-                    implode(', ', $valid_release_types)
230
-                )
231
-            );
232
-        }
233
-        $this->release = $release;
234
-    }
235
-
236
-
237
-    /**
238
-     * @return int
239
-     */
240
-    public function build(): int
241
-    {
242
-        return $this->build;
243
-    }
244
-
245
-
246
-    /**
247
-     * @param int|string $build
248
-     * @throws InvalidDataTypeException
249
-     */
250
-    private function setBuild($build)
251
-    {
252
-        if (! is_int($build)) {
253
-            throw new InvalidDataTypeException(
254
-                '$build',
255
-                $build,
256
-                'integer'
257
-            );
258
-        }
259
-        $this->build = absint($build);
260
-    }
261
-
262
-
263
-    /**
264
-     * @param Version $other_version
265
-     * @return int
266
-     */
267
-    public function compare(Version $other_version): int
268
-    {
269
-        return version_compare((string) $this, (string) $other_version);
270
-    }
271
-
272
-
273
-    /**
274
-     * @param Version $other_version
275
-     * @return bool
276
-     */
277
-    public function equals(Version $other_version): bool
278
-    {
279
-        return version_compare((string) $this, (string) $other_version, '==');
280
-    }
281
-
282
-
283
-    /**
284
-     * @param Version $other_version
285
-     * @return bool
286
-     */
287
-    public function newerThan(Version $other_version): bool
288
-    {
289
-        return version_compare((string) $this, (string) $other_version, '>');
290
-    }
291
-
292
-
293
-    /**
294
-     * @param Version $other_version
295
-     * @return bool
296
-     */
297
-    public function olderThan(Version $other_version): bool
298
-    {
299
-        return version_compare((string) $this, (string) $other_version, '<');
300
-    }
301
-
302
-
303
-    /**
304
-     * @return string
305
-     */
306
-    public function __toString()
307
-    {
308
-        $version_string = "$this->major.$this->minor.$this->patch.$this->release";
309
-        if ($this->release !== Version::RELEASE_TYPE_PROD && $this->release !== Version::RELEASE_TYPE_DECAF) {
310
-            $version_string .= '.' . str_pad($this->build, 3, '0', STR_PAD_LEFT);
311
-        }
312
-        return $version_string;
313
-    }
18
+	const RELEASE_TYPE_RC    = 'rc';
19
+
20
+	const RELEASE_TYPE_BETA  = 'beta';
21
+
22
+	const RELEASE_TYPE_DECAF = 'decaf';
23
+
24
+	const RELEASE_TYPE_PROD  = 'p';
25
+
26
+	private int $major;
27
+
28
+	private int $minor;
29
+
30
+	private int $patch;
31
+
32
+	private string $release;
33
+
34
+	private int $build;
35
+
36
+
37
+	/**
38
+	 * Version constructor.
39
+	 *
40
+	 * @param int    $major
41
+	 * @param int    $minor
42
+	 * @param int    $patch
43
+	 * @param string $release
44
+	 * @param int    $build
45
+	 * @throws InvalidDataTypeException
46
+	 * @throws InvalidArgumentException
47
+	 */
48
+	public function __construct(
49
+		int $major,
50
+		int $minor,
51
+		int $patch,
52
+		string $release = Version::RELEASE_TYPE_PROD,
53
+		int $build = 0
54
+	) {
55
+		$this->setMajor($major);
56
+		$this->setMinor($minor);
57
+		$this->setPatch($patch);
58
+		$this->setRelease($release);
59
+		$this->setBuild($build);
60
+	}
61
+
62
+
63
+	/**
64
+	 * @param string $version_string
65
+	 * @return Version
66
+	 * @throws InvalidArgumentException
67
+	 */
68
+	public static function fromString(string $version_string): Version
69
+	{
70
+		$version_string = trim($version_string);
71
+		// compare incoming version string against the lowest possible valid version
72
+		if (version_compare($version_string, '0.0.1.dev.001', '<')) {
73
+			throw new InvalidArgumentException(
74
+				sprintf(
75
+					esc_html__('"%1$s" is not a valid version string', 'event_espresso'),
76
+					$version_string
77
+				)
78
+			);
79
+		}
80
+		// break apart incoming version string
81
+		$version_parts = explode('.', $version_string);
82
+		// verify that version string at least contains {major}.{minor}.{patch}
83
+		if (count($version_parts) < 3) {
84
+			throw new InvalidArgumentException(
85
+				sprintf(
86
+					esc_html__(
87
+						'At minimum, a version string needs to be in a "{major}.{minor}.{patch}" format, therefore "%1$s" is not valid',
88
+						'event_espresso'
89
+					),
90
+					$version_string
91
+				)
92
+			);
93
+		}
94
+		// convert semver 1.2.3.001 to 1.2.3.p.001 style... FOR THE TIME BEING
95
+		if (count($version_parts) === 4 && is_numeric($version_parts[3])) {
96
+			$version_parts[4] = $version_parts[3];
97
+			unset($version_parts[3]);
98
+		}
99
+		$release = isset($version_parts[4]) && (string) $version_parts[4] === '000'
100
+			? Version::RELEASE_TYPE_PROD
101
+			: Version::RELEASE_TYPE_RC;
102
+		// semver styles like 1.2.3 will be considered production releases
103
+		$release = ! isset($version_parts[3], $version_parts[4])
104
+			? Version::RELEASE_TYPE_PROD
105
+			: $release;
106
+		// add defaults for missing pieces
107
+		$version_parts += ['0', '0', '0', "$release", '000'];
108
+		ksort($version_parts, SORT_NUMERIC);
109
+		$version_parts = array_map('trim', $version_parts);
110
+		// reassign to individual variables
111
+		[$major, $minor, $patch, $release, $build] = $version_parts;
112
+		return new Version(
113
+			(int) $major,
114
+			(int) $minor,
115
+			(int) $patch,
116
+			(string) $release,
117
+			(int) $build
118
+		);
119
+	}
120
+
121
+
122
+	/**
123
+	 * @return int
124
+	 */
125
+	public function major(): int
126
+	{
127
+		return $this->major;
128
+	}
129
+
130
+
131
+	/**
132
+	 * @param int|string $major
133
+	 * @throws InvalidDataTypeException
134
+	 */
135
+	private function setMajor($major)
136
+	{
137
+		if (! is_int($major)) {
138
+			throw new InvalidDataTypeException(
139
+				'$major',
140
+				$major,
141
+				'integer'
142
+			);
143
+		}
144
+		$this->major = absint($major);
145
+	}
146
+
147
+
148
+	/**
149
+	 * @return int
150
+	 */
151
+	public function minor(): int
152
+	{
153
+		return $this->minor;
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param int|string $minor
159
+	 * @throws InvalidDataTypeException
160
+	 */
161
+	private function setMinor($minor)
162
+	{
163
+		if (! is_int($minor)) {
164
+			throw new InvalidDataTypeException(
165
+				'$minor',
166
+				$minor,
167
+				'integer'
168
+			);
169
+		}
170
+		$this->minor = absint($minor);
171
+	}
172
+
173
+
174
+	/**
175
+	 * @return int
176
+	 */
177
+	public function patch(): int
178
+	{
179
+		return $this->patch;
180
+	}
181
+
182
+
183
+	/**
184
+	 * @param int|string $patch
185
+	 * @throws InvalidDataTypeException
186
+	 */
187
+	private function setPatch($patch)
188
+	{
189
+		if (! is_int($patch)) {
190
+			throw new InvalidDataTypeException(
191
+				'$patch',
192
+				$patch,
193
+				'integer'
194
+			);
195
+		}
196
+		$this->patch = absint($patch);
197
+	}
198
+
199
+
200
+	/**
201
+	 * @return string
202
+	 */
203
+	public function release(): string
204
+	{
205
+		return $this->release;
206
+	}
207
+
208
+
209
+	/**
210
+	 * @param string $release
211
+	 * @throws InvalidArgumentException
212
+	 */
213
+	private function setRelease(string $release)
214
+	{
215
+		$valid_release_types = [
216
+			Version::RELEASE_TYPE_RC,
217
+			Version::RELEASE_TYPE_BETA,
218
+			Version::RELEASE_TYPE_DECAF,
219
+			Version::RELEASE_TYPE_PROD,
220
+		];
221
+		if (! in_array($release, $valid_release_types, true)) {
222
+			throw new InvalidArgumentException(
223
+				sprintf(
224
+					esc_html__(
225
+						'"%1$s" is not a valid release type. Please use one of the following values: %2$s',
226
+						'event_espresso'
227
+					),
228
+					$release,
229
+					implode(', ', $valid_release_types)
230
+				)
231
+			);
232
+		}
233
+		$this->release = $release;
234
+	}
235
+
236
+
237
+	/**
238
+	 * @return int
239
+	 */
240
+	public function build(): int
241
+	{
242
+		return $this->build;
243
+	}
244
+
245
+
246
+	/**
247
+	 * @param int|string $build
248
+	 * @throws InvalidDataTypeException
249
+	 */
250
+	private function setBuild($build)
251
+	{
252
+		if (! is_int($build)) {
253
+			throw new InvalidDataTypeException(
254
+				'$build',
255
+				$build,
256
+				'integer'
257
+			);
258
+		}
259
+		$this->build = absint($build);
260
+	}
261
+
262
+
263
+	/**
264
+	 * @param Version $other_version
265
+	 * @return int
266
+	 */
267
+	public function compare(Version $other_version): int
268
+	{
269
+		return version_compare((string) $this, (string) $other_version);
270
+	}
271
+
272
+
273
+	/**
274
+	 * @param Version $other_version
275
+	 * @return bool
276
+	 */
277
+	public function equals(Version $other_version): bool
278
+	{
279
+		return version_compare((string) $this, (string) $other_version, '==');
280
+	}
281
+
282
+
283
+	/**
284
+	 * @param Version $other_version
285
+	 * @return bool
286
+	 */
287
+	public function newerThan(Version $other_version): bool
288
+	{
289
+		return version_compare((string) $this, (string) $other_version, '>');
290
+	}
291
+
292
+
293
+	/**
294
+	 * @param Version $other_version
295
+	 * @return bool
296
+	 */
297
+	public function olderThan(Version $other_version): bool
298
+	{
299
+		return version_compare((string) $this, (string) $other_version, '<');
300
+	}
301
+
302
+
303
+	/**
304
+	 * @return string
305
+	 */
306
+	public function __toString()
307
+	{
308
+		$version_string = "$this->major.$this->minor.$this->patch.$this->release";
309
+		if ($this->release !== Version::RELEASE_TYPE_PROD && $this->release !== Version::RELEASE_TYPE_DECAF) {
310
+			$version_string .= '.' . str_pad($this->build, 3, '0', STR_PAD_LEFT);
311
+		}
312
+		return $version_string;
313
+	}
314 314
 }
Please login to merge, or discard this patch.
core/domain/services/service_changes/PaymentMethodDeprecations2025.php 2 patches
Indentation   +523 added lines, -523 removed lines patch added patch discarded remove patch
@@ -26,533 +26,533 @@
 block discarded – undo
26 26
  */
27 27
 class PaymentMethodDeprecations2025
28 28
 {
29
-    public const  DEACTIVATED_PM_OPTION_NAME = 'espresso-pm-deactivations-2025';
29
+	public const  DEACTIVATED_PM_OPTION_NAME = 'espresso-pm-deactivations-2025';
30 30
 
31
-    public const  PM_DEPRECATION_DATE       = '2025-04-15';
32
-
33
-    private const NOTIFICATION_DATE_WARNING = '2025-01-15';
34
-
35
-    private const NOTIFICATION_DATE_URGENT  = '2025-03-15';
36
-
37
-    private const NOTIFICATION_NAME_PREFIX  = 'pm-deprecations-2025-';
38
-
39
-    private const OPTION_NAME               = 'ee_pm_deprecations_2025';
40
-
41
-    private const TYPE_INITIAL              = 'initial';
42
-
43
-    private const TYPE_WARNING              = 'warning';
44
-
45
-    private const TYPE_URGENT               = 'urgent';
46
-
47
-    private const TYPE_FINAL                = 'final';
48
-
49
-    private const URL_ACCEPT                = 'https://eventespresso.com/product/eea-authorizenet-accept/';
50
-
51
-    private const URL_STRIPE                = 'https://eventespresso.com/product/eea-stripe-gateway/';
52
-
53
-    private const URL_SQUARE                = 'https://eventespresso.com/product/eea-square-gateway/';
54
-
55
-    private const URL_SUPPORT_DOCS          = 'https://support.eventespresso.com/article/612-deprecated-payment-methods-2025';
56
-
57
-
58
-
59
-    private EEM_Payment_Method $payment_method_model;
60
-
61
-    private ?array $active_deprecated_payment_methods = null;
62
-
63
-    private array $deactivated_pms;
64
-
65
-    private array $deprecated_payment_methods = [
66
-        'aim'                  => 'aim',
67
-        'authorizenet_sim'     => 'authorizenet_sim',
68
-        'braintree_dropin'     => 'braintree_dropin',
69
-        'payflow_pro_onsite'   => 'payflow_pro_onsite',
70
-        'paypal_express'       => 'paypal_express',
71
-        'paypal_pro'           => 'paypal_pro',
72
-        'paypal_smart_buttons' => 'paypal_smart_buttons',
73
-        'paypal_standard'      => 'paypal_standard',
74
-    ];
75
-
76
-    private Datetime $deprecation_date;
77
-
78
-    private Datetime $now;
79
-
80
-
81
-    /**
82
-     * @param EEM_Payment_Method $payment_method_model
83
-     */
84
-    public function __construct(EEM_Payment_Method $payment_method_model)
85
-    {
86
-        $this->payment_method_model = $payment_method_model;
87
-        $this->deprecation_date     = new DateTime(self::PM_DEPRECATION_DATE);
88
-        $this->now                  = new Datetime('now');
89
-        $this->deactivated_pms      = get_option(self::DEACTIVATED_PM_OPTION_NAME, []);
90
-        // TODO: remove the following comments before release
91
-        // uncomment next line to trigger warning notice
92
-        // $this->now = new Datetime('2025-02-20'); // Feb 20, 2025
93
-        // uncomment next line to trigger urgent notice
94
-        // $this->now = new Datetime('2025-03-20'); // Mar 20, 2025
95
-        // uncomment next line to trigger final notice & PM deactivation
96
-        // $this->now = new Datetime('2025-04-20'); // Apr 20, 2025
97
-        // uncomment the following block of code to "unhide" PMs
98
-        // add_filter(
99
-        //     'FHEE__EventEspresso_PaymentMethods_Manager__hidePaymentMethods__pms_can_hide',
100
-        //     fn() => []
101
-        // );
102
-        // uncomment the following to display ALL notices regardless of dates
103
-        // $this->displayNotification(self::TYPE_INITIAL);
104
-        // $this->displayNotification(self::TYPE_WARNING);
105
-        // $this->displayNotification(self::TYPE_URGENT);
106
-        // $this->displayNotification(self::TYPE_FINAL);
107
-    }
108
-
109
-
110
-    /**
111
-     * @return void
112
-     * @throws EE_Error
113
-     * @throws ReflectionException
114
-     */
115
-    public function setHooks()
116
-    {
117
-        // giving customers more time to migrate,
118
-        if ($this->now < new Datetime(self::NOTIFICATION_DATE_WARNING)) {
119
-            $this->deleteNotifications();
120
-        }
121
-        $this->deactivateDeprecatedPaymentMethods();
122
-        // don't bother if we're 6 months past the deprecation date
123
-        if ($this->now > $this->deprecation_date->modify('+6 months')) {
124
-            return;
125
-        }
126
-        // check for deprecated payment methods on every request
127
-        // jumping in at priority 0 before persistent admin notices are loaded
128
-        add_action(
129
-            'admin_notices',
130
-            [$this, 'loadAdminNotices'],
131
-            0
132
-        );
133
-        // check again whenever a payment method is activated
134
-        add_action(
135
-            'AHEE__EE_Payment_Method_Manager__activate_a_payment_method_of_type__after_activation',
136
-            [$this, 'maybeDismissNotifications']
137
-        );
138
-        // and also when a payment method is deactivated
139
-        add_action(
140
-            'AHEE__EE_Payment_Method_Manager__deactivate_payment_method__after_deactivating_payment_method',
141
-            [$this, 'paymentMethodDeactivation']
142
-        );
143
-    }
144
-
145
-
146
-    /**
147
-     * If there are no active deprecated payment methods, then dismiss all notices.
148
-     * Callback for the `AHEE__EE_Payment_Method_Manager__activate_a_payment_method_of_type__after_activation` action.
149
-     *
150
-     * @return void
151
-     * @throws EE_Error
152
-     * @throws ReflectionException
153
-     */
154
-    public function maybeDismissNotifications()
155
-    {
156
-        if (! $this->activeDeprecatedPaymentMethods()) {
157
-            $notices = [
158
-                self::NOTIFICATION_NAME_PREFIX . self::TYPE_INITIAL,
159
-                self::NOTIFICATION_NAME_PREFIX . self::TYPE_WARNING,
160
-                self::NOTIFICATION_NAME_PREFIX . self::TYPE_URGENT,
161
-            ];
162
-            foreach ($notices as $notice) {
163
-                PersistentAdminNoticeManager::dismissPersistentAdminNotice($notice);
164
-            }
165
-        }
166
-    }
167
-
168
-
169
-    /**
170
-     * If the payment method being deactivated is in the deprecated list,
171
-     * then we need to check if there are any other deprecated payment methods still active.
172
-     * `AHEE__EE_Payment_Method_Manager__deactivate_payment_method__after_deactivating_payment_method` callback
173
-     *
174
-     * @param string $payment_method_slug
175
-     * @return void
176
-     * @throws EE_Error
177
-     * @throws ReflectionException
178
-     */
179
-    public function paymentMethodDeactivation(string $payment_method_slug)
180
-    {
181
-        if (in_array($payment_method_slug, array_keys($this->deprecated_payment_methods), true)) {
182
-            $this->maybeDismissNotifications();
183
-        }
184
-    }
185
-
186
-
187
-    /**
188
-     * IF we are past the deprecation date, then deactivate any active deprecated payment methods
189
-     *
190
-     * @return void
191
-     * @throws EE_Error
192
-     * @throws ReflectionException
193
-     */
194
-    private function deactivateDeprecatedPaymentMethods()
195
-    {
196
-        if ($this->now >= $this->deprecation_date) {
197
-            $active_deprecated_payment_methods = $this->activeDeprecatedPaymentMethods();
198
-            foreach ($active_deprecated_payment_methods as $active_deprecated_pm) {
199
-                if ($active_deprecated_pm instanceof EE_Payment_Method) {
200
-                    $active_deprecated_pm->deactivate();
201
-                    unset($this->active_deprecated_payment_methods[ $active_deprecated_pm->slug() ]);
202
-                    $this->deactivated_pms[ $active_deprecated_pm->slug() ] = $active_deprecated_pm->name();
203
-                    $active_deprecated_pm->save();
204
-                }
205
-            }
206
-            $this->maybeDismissNotifications();
207
-            // get the PM Manager to hide the deprecated PMs
208
-            add_filter(
209
-                'FHEE__EventEspresso_PaymentMethods_Manager__hidePaymentMethods__pms_can_hide',
210
-                [$this, 'hideDeprecatedPaymentMethods']
211
-            );
212
-            update_option(self::DEACTIVATED_PM_OPTION_NAME, $this->deactivated_pms);
213
-        }
214
-    }
215
-
216
-
217
-    /**
218
-     * adds the list of deprecated PMs to the list of PMs to remove from the UI
219
-     * Callback for FHEE__EventEspresso_PaymentMethods_Manager__hidePaymentMethods__pms_can_hide
220
-     *
221
-     * @param array $pms_can_hide
222
-     * @return array
223
-     */
224
-    public function hideDeprecatedPaymentMethods(array $pms_can_hide): array
225
-    {
226
-        return array_merge($pms_can_hide, $this->deprecated_payment_methods);
227
-    }
228
-
229
-
230
-    /**
231
-     * Returns an array of deprecated payment methods that are currently active
232
-     *
233
-     * @return EE_Payment_Method[]
234
-     * @throws EE_Error
235
-     * @throws ReflectionException
236
-     */
237
-    private function activeDeprecatedPaymentMethods(): array
238
-    {
239
-        if ($this->active_deprecated_payment_methods === null) {
240
-            $this->active_deprecated_payment_methods = [];
241
-            $deprecated_payment_methods              = $this->payment_method_model->get_all(
242
-                [['PMD_slug' => ['IN', array_keys($this->deprecated_payment_methods)]]]
243
-            );
244
-            if (! $deprecated_payment_methods) {
245
-                return $this->active_deprecated_payment_methods;
246
-            }
247
-            foreach ($deprecated_payment_methods as $deprecated_pm) {
248
-                if ($deprecated_pm instanceof EE_Payment_Method && $deprecated_pm->active()) {
249
-                    $this->active_deprecated_payment_methods[ $deprecated_pm->slug() ] = $deprecated_pm;
250
-                }
251
-            }
252
-        }
253
-        return $this->active_deprecated_payment_methods;
254
-    }
255
-
256
-
257
-    /**
258
-     * If there are any deprecated payment methods active,
259
-     * then load the appropriate admin notices based on the current date.
260
-     * Callback for the `admin_notices` action.
261
-     *
262
-     * @return void
263
-     * @throws EE_Error
264
-     * @throws ReflectionException
265
-     */
266
-    public function loadAdminNotices()
267
-    {
268
-        if ($this->activeDeprecatedPaymentMethods()) {
269
-            if ($this->now < new DateTime(self::NOTIFICATION_DATE_WARNING)) {
270
-                $this->displayNotification(self::TYPE_INITIAL);
271
-                return;
272
-            }
273
-            if ($this->now < new DateTime(self::NOTIFICATION_DATE_URGENT)) {
274
-                $this->displayNotification(self::TYPE_WARNING);
275
-                return;
276
-            }
277
-            if ($this->now < new DateTime(self::PM_DEPRECATION_DATE)) {
278
-                $this->displayNotification(self::TYPE_URGENT);
279
-                return;
280
-            }
281
-        }
282
-        if (! empty($this->deactivated_pms) && $this->now > new DateTime(self::PM_DEPRECATION_DATE)) {
283
-            $this->displayNotification(self::TYPE_FINAL);
284
-        }
285
-    }
286
-
287
-
288
-    /**
289
-     * @return void
290
-     */
291
-    private function deleteNotifications()
292
-    {
293
-        $pm_deprecations = get_option(self::OPTION_NAME, []);
294
-        // initialize the option if it doesn't exist
295
-        if (empty($pm_deprecations)) {
296
-            add_option(self::OPTION_NAME, [], '', 'no');
297
-        }
298
-        if (! empty($pm_deprecations['jan-6-update'])) {
299
-            return;
300
-        }
301
-        PersistentAdminNoticeManager::deletePersistentAdminNotice(
302
-            self::NOTIFICATION_NAME_PREFIX . self::TYPE_WARNING
303
-        );
304
-        PersistentAdminNoticeManager::deletePersistentAdminNotice(
305
-            self::NOTIFICATION_NAME_PREFIX . self::TYPE_URGENT
306
-        );
307
-        PersistentAdminNoticeManager::deletePersistentAdminNotice(
308
-            self::NOTIFICATION_NAME_PREFIX . self::TYPE_FINAL
309
-        );
310
-        PersistentAdminNoticeManager::deletePersistentAdminNotice(
311
-            self::NOTIFICATION_NAME_PREFIX . self::TYPE_INITIAL
312
-        );
313
-        $pm_deprecations['jan-6-update'] = true;
314
-        update_option(self::OPTION_NAME, $pm_deprecations);
315
-    }
316
-
317
-
318
-    /**
319
-     * @param string $type
320
-     * @return void
321
-     */
322
-    private function displayNotification(string $type)
323
-    {
324
-        switch ($type) {
325
-            case self::TYPE_WARNING:
326
-                $name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_WARNING;
327
-                $notice_type = 'attention';
328
-                break;
329
-            case self::TYPE_URGENT:
330
-                $name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_URGENT;
331
-                $notice_type = 'warning';
332
-                break;
333
-            case self::TYPE_FINAL:
334
-                $name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_FINAL;
335
-                $notice_type = 'error';
336
-                break;
337
-            case self::TYPE_INITIAL:
338
-            default:
339
-                $name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_INITIAL;
340
-                $notice_type = 'info';
341
-        }
342
-
343
-        $message = sprintf(
344
-            '
31
+	public const  PM_DEPRECATION_DATE       = '2025-04-15';
32
+
33
+	private const NOTIFICATION_DATE_WARNING = '2025-01-15';
34
+
35
+	private const NOTIFICATION_DATE_URGENT  = '2025-03-15';
36
+
37
+	private const NOTIFICATION_NAME_PREFIX  = 'pm-deprecations-2025-';
38
+
39
+	private const OPTION_NAME               = 'ee_pm_deprecations_2025';
40
+
41
+	private const TYPE_INITIAL              = 'initial';
42
+
43
+	private const TYPE_WARNING              = 'warning';
44
+
45
+	private const TYPE_URGENT               = 'urgent';
46
+
47
+	private const TYPE_FINAL                = 'final';
48
+
49
+	private const URL_ACCEPT                = 'https://eventespresso.com/product/eea-authorizenet-accept/';
50
+
51
+	private const URL_STRIPE                = 'https://eventespresso.com/product/eea-stripe-gateway/';
52
+
53
+	private const URL_SQUARE                = 'https://eventespresso.com/product/eea-square-gateway/';
54
+
55
+	private const URL_SUPPORT_DOCS          = 'https://support.eventespresso.com/article/612-deprecated-payment-methods-2025';
56
+
57
+
58
+
59
+	private EEM_Payment_Method $payment_method_model;
60
+
61
+	private ?array $active_deprecated_payment_methods = null;
62
+
63
+	private array $deactivated_pms;
64
+
65
+	private array $deprecated_payment_methods = [
66
+		'aim'                  => 'aim',
67
+		'authorizenet_sim'     => 'authorizenet_sim',
68
+		'braintree_dropin'     => 'braintree_dropin',
69
+		'payflow_pro_onsite'   => 'payflow_pro_onsite',
70
+		'paypal_express'       => 'paypal_express',
71
+		'paypal_pro'           => 'paypal_pro',
72
+		'paypal_smart_buttons' => 'paypal_smart_buttons',
73
+		'paypal_standard'      => 'paypal_standard',
74
+	];
75
+
76
+	private Datetime $deprecation_date;
77
+
78
+	private Datetime $now;
79
+
80
+
81
+	/**
82
+	 * @param EEM_Payment_Method $payment_method_model
83
+	 */
84
+	public function __construct(EEM_Payment_Method $payment_method_model)
85
+	{
86
+		$this->payment_method_model = $payment_method_model;
87
+		$this->deprecation_date     = new DateTime(self::PM_DEPRECATION_DATE);
88
+		$this->now                  = new Datetime('now');
89
+		$this->deactivated_pms      = get_option(self::DEACTIVATED_PM_OPTION_NAME, []);
90
+		// TODO: remove the following comments before release
91
+		// uncomment next line to trigger warning notice
92
+		// $this->now = new Datetime('2025-02-20'); // Feb 20, 2025
93
+		// uncomment next line to trigger urgent notice
94
+		// $this->now = new Datetime('2025-03-20'); // Mar 20, 2025
95
+		// uncomment next line to trigger final notice & PM deactivation
96
+		// $this->now = new Datetime('2025-04-20'); // Apr 20, 2025
97
+		// uncomment the following block of code to "unhide" PMs
98
+		// add_filter(
99
+		//     'FHEE__EventEspresso_PaymentMethods_Manager__hidePaymentMethods__pms_can_hide',
100
+		//     fn() => []
101
+		// );
102
+		// uncomment the following to display ALL notices regardless of dates
103
+		// $this->displayNotification(self::TYPE_INITIAL);
104
+		// $this->displayNotification(self::TYPE_WARNING);
105
+		// $this->displayNotification(self::TYPE_URGENT);
106
+		// $this->displayNotification(self::TYPE_FINAL);
107
+	}
108
+
109
+
110
+	/**
111
+	 * @return void
112
+	 * @throws EE_Error
113
+	 * @throws ReflectionException
114
+	 */
115
+	public function setHooks()
116
+	{
117
+		// giving customers more time to migrate,
118
+		if ($this->now < new Datetime(self::NOTIFICATION_DATE_WARNING)) {
119
+			$this->deleteNotifications();
120
+		}
121
+		$this->deactivateDeprecatedPaymentMethods();
122
+		// don't bother if we're 6 months past the deprecation date
123
+		if ($this->now > $this->deprecation_date->modify('+6 months')) {
124
+			return;
125
+		}
126
+		// check for deprecated payment methods on every request
127
+		// jumping in at priority 0 before persistent admin notices are loaded
128
+		add_action(
129
+			'admin_notices',
130
+			[$this, 'loadAdminNotices'],
131
+			0
132
+		);
133
+		// check again whenever a payment method is activated
134
+		add_action(
135
+			'AHEE__EE_Payment_Method_Manager__activate_a_payment_method_of_type__after_activation',
136
+			[$this, 'maybeDismissNotifications']
137
+		);
138
+		// and also when a payment method is deactivated
139
+		add_action(
140
+			'AHEE__EE_Payment_Method_Manager__deactivate_payment_method__after_deactivating_payment_method',
141
+			[$this, 'paymentMethodDeactivation']
142
+		);
143
+	}
144
+
145
+
146
+	/**
147
+	 * If there are no active deprecated payment methods, then dismiss all notices.
148
+	 * Callback for the `AHEE__EE_Payment_Method_Manager__activate_a_payment_method_of_type__after_activation` action.
149
+	 *
150
+	 * @return void
151
+	 * @throws EE_Error
152
+	 * @throws ReflectionException
153
+	 */
154
+	public function maybeDismissNotifications()
155
+	{
156
+		if (! $this->activeDeprecatedPaymentMethods()) {
157
+			$notices = [
158
+				self::NOTIFICATION_NAME_PREFIX . self::TYPE_INITIAL,
159
+				self::NOTIFICATION_NAME_PREFIX . self::TYPE_WARNING,
160
+				self::NOTIFICATION_NAME_PREFIX . self::TYPE_URGENT,
161
+			];
162
+			foreach ($notices as $notice) {
163
+				PersistentAdminNoticeManager::dismissPersistentAdminNotice($notice);
164
+			}
165
+		}
166
+	}
167
+
168
+
169
+	/**
170
+	 * If the payment method being deactivated is in the deprecated list,
171
+	 * then we need to check if there are any other deprecated payment methods still active.
172
+	 * `AHEE__EE_Payment_Method_Manager__deactivate_payment_method__after_deactivating_payment_method` callback
173
+	 *
174
+	 * @param string $payment_method_slug
175
+	 * @return void
176
+	 * @throws EE_Error
177
+	 * @throws ReflectionException
178
+	 */
179
+	public function paymentMethodDeactivation(string $payment_method_slug)
180
+	{
181
+		if (in_array($payment_method_slug, array_keys($this->deprecated_payment_methods), true)) {
182
+			$this->maybeDismissNotifications();
183
+		}
184
+	}
185
+
186
+
187
+	/**
188
+	 * IF we are past the deprecation date, then deactivate any active deprecated payment methods
189
+	 *
190
+	 * @return void
191
+	 * @throws EE_Error
192
+	 * @throws ReflectionException
193
+	 */
194
+	private function deactivateDeprecatedPaymentMethods()
195
+	{
196
+		if ($this->now >= $this->deprecation_date) {
197
+			$active_deprecated_payment_methods = $this->activeDeprecatedPaymentMethods();
198
+			foreach ($active_deprecated_payment_methods as $active_deprecated_pm) {
199
+				if ($active_deprecated_pm instanceof EE_Payment_Method) {
200
+					$active_deprecated_pm->deactivate();
201
+					unset($this->active_deprecated_payment_methods[ $active_deprecated_pm->slug() ]);
202
+					$this->deactivated_pms[ $active_deprecated_pm->slug() ] = $active_deprecated_pm->name();
203
+					$active_deprecated_pm->save();
204
+				}
205
+			}
206
+			$this->maybeDismissNotifications();
207
+			// get the PM Manager to hide the deprecated PMs
208
+			add_filter(
209
+				'FHEE__EventEspresso_PaymentMethods_Manager__hidePaymentMethods__pms_can_hide',
210
+				[$this, 'hideDeprecatedPaymentMethods']
211
+			);
212
+			update_option(self::DEACTIVATED_PM_OPTION_NAME, $this->deactivated_pms);
213
+		}
214
+	}
215
+
216
+
217
+	/**
218
+	 * adds the list of deprecated PMs to the list of PMs to remove from the UI
219
+	 * Callback for FHEE__EventEspresso_PaymentMethods_Manager__hidePaymentMethods__pms_can_hide
220
+	 *
221
+	 * @param array $pms_can_hide
222
+	 * @return array
223
+	 */
224
+	public function hideDeprecatedPaymentMethods(array $pms_can_hide): array
225
+	{
226
+		return array_merge($pms_can_hide, $this->deprecated_payment_methods);
227
+	}
228
+
229
+
230
+	/**
231
+	 * Returns an array of deprecated payment methods that are currently active
232
+	 *
233
+	 * @return EE_Payment_Method[]
234
+	 * @throws EE_Error
235
+	 * @throws ReflectionException
236
+	 */
237
+	private function activeDeprecatedPaymentMethods(): array
238
+	{
239
+		if ($this->active_deprecated_payment_methods === null) {
240
+			$this->active_deprecated_payment_methods = [];
241
+			$deprecated_payment_methods              = $this->payment_method_model->get_all(
242
+				[['PMD_slug' => ['IN', array_keys($this->deprecated_payment_methods)]]]
243
+			);
244
+			if (! $deprecated_payment_methods) {
245
+				return $this->active_deprecated_payment_methods;
246
+			}
247
+			foreach ($deprecated_payment_methods as $deprecated_pm) {
248
+				if ($deprecated_pm instanceof EE_Payment_Method && $deprecated_pm->active()) {
249
+					$this->active_deprecated_payment_methods[ $deprecated_pm->slug() ] = $deprecated_pm;
250
+				}
251
+			}
252
+		}
253
+		return $this->active_deprecated_payment_methods;
254
+	}
255
+
256
+
257
+	/**
258
+	 * If there are any deprecated payment methods active,
259
+	 * then load the appropriate admin notices based on the current date.
260
+	 * Callback for the `admin_notices` action.
261
+	 *
262
+	 * @return void
263
+	 * @throws EE_Error
264
+	 * @throws ReflectionException
265
+	 */
266
+	public function loadAdminNotices()
267
+	{
268
+		if ($this->activeDeprecatedPaymentMethods()) {
269
+			if ($this->now < new DateTime(self::NOTIFICATION_DATE_WARNING)) {
270
+				$this->displayNotification(self::TYPE_INITIAL);
271
+				return;
272
+			}
273
+			if ($this->now < new DateTime(self::NOTIFICATION_DATE_URGENT)) {
274
+				$this->displayNotification(self::TYPE_WARNING);
275
+				return;
276
+			}
277
+			if ($this->now < new DateTime(self::PM_DEPRECATION_DATE)) {
278
+				$this->displayNotification(self::TYPE_URGENT);
279
+				return;
280
+			}
281
+		}
282
+		if (! empty($this->deactivated_pms) && $this->now > new DateTime(self::PM_DEPRECATION_DATE)) {
283
+			$this->displayNotification(self::TYPE_FINAL);
284
+		}
285
+	}
286
+
287
+
288
+	/**
289
+	 * @return void
290
+	 */
291
+	private function deleteNotifications()
292
+	{
293
+		$pm_deprecations = get_option(self::OPTION_NAME, []);
294
+		// initialize the option if it doesn't exist
295
+		if (empty($pm_deprecations)) {
296
+			add_option(self::OPTION_NAME, [], '', 'no');
297
+		}
298
+		if (! empty($pm_deprecations['jan-6-update'])) {
299
+			return;
300
+		}
301
+		PersistentAdminNoticeManager::deletePersistentAdminNotice(
302
+			self::NOTIFICATION_NAME_PREFIX . self::TYPE_WARNING
303
+		);
304
+		PersistentAdminNoticeManager::deletePersistentAdminNotice(
305
+			self::NOTIFICATION_NAME_PREFIX . self::TYPE_URGENT
306
+		);
307
+		PersistentAdminNoticeManager::deletePersistentAdminNotice(
308
+			self::NOTIFICATION_NAME_PREFIX . self::TYPE_FINAL
309
+		);
310
+		PersistentAdminNoticeManager::deletePersistentAdminNotice(
311
+			self::NOTIFICATION_NAME_PREFIX . self::TYPE_INITIAL
312
+		);
313
+		$pm_deprecations['jan-6-update'] = true;
314
+		update_option(self::OPTION_NAME, $pm_deprecations);
315
+	}
316
+
317
+
318
+	/**
319
+	 * @param string $type
320
+	 * @return void
321
+	 */
322
+	private function displayNotification(string $type)
323
+	{
324
+		switch ($type) {
325
+			case self::TYPE_WARNING:
326
+				$name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_WARNING;
327
+				$notice_type = 'attention';
328
+				break;
329
+			case self::TYPE_URGENT:
330
+				$name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_URGENT;
331
+				$notice_type = 'warning';
332
+				break;
333
+			case self::TYPE_FINAL:
334
+				$name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_FINAL;
335
+				$notice_type = 'error';
336
+				break;
337
+			case self::TYPE_INITIAL:
338
+			default:
339
+				$name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_INITIAL;
340
+				$notice_type = 'info';
341
+		}
342
+
343
+		$message = sprintf(
344
+			'
345 345
             <h3>%1$s</h3>
346 346
             %2$s
347 347
             <span class="dashicons dashicons-bank dashicons--huge"></span>',
348
-            $this->heading($type),
349
-            $this->firstPg($type)
350
-            . $this->theFollowingPaymentsPg()
351
-            . $this->whatYouNeedToDoPg($type)
352
-            . $this->toMigratePg()
353
-            . $this->supportPg()
354
-        );
355
-
356
-        new PersistentAdminNotice(
357
-            $name,
358
-            $message,
359
-            $notice_type === 'warning',
360
-            'manage_options',
361
-            'view persistent admin notice',
362
-            false,
363
-            $notice_type,
364
-            'ee-service-change'
365
-        );
366
-    }
367
-
368
-
369
-    private function heading(string $type = self::TYPE_INITIAL): string
370
-    {
371
-        switch ($type) {
372
-            case self::TYPE_WARNING:
373
-                return esc_html__(
374
-                    'Urgent Reminder: To continue processing payments, migrate to a new payment integration today.',
375
-                    'event_espresso'
376
-                );
377
-            case self::TYPE_URGENT:
378
-                return esc_html__(
379
-                    'Immediate Action Required: To continue processing payments, migrate to a new payment integration NOW!',
380
-                    'event_espresso'
381
-                );
382
-            case self::TYPE_FINAL:
383
-                return esc_html__('Payment Gateway Integrations Deactivated!', 'event_espresso');
384
-            case self::TYPE_INITIAL:
385
-            default:
386
-                return esc_html__(
387
-                    'Action Required: To continue processing payments, migrate to a new payment integration soon.',
388
-                    'event_espresso'
389
-                );
390
-        }
391
-    }
392
-
393
-
394
-    private function firstPg(string $type = self::TYPE_INITIAL): string
395
-    {
396
-        switch ($type) {
397
-            case self::TYPE_WARNING:
398
-                return sprintf(
399
-                    esc_html__(
400
-                        '%1$sRemember, we will soon deprecate and remove the following outdated or obsolete payment integrations and ask you to migrate to a new payment integration as soon as possible. Our replacement payment integrations offer more features and security.%2$s',
401
-                        'event_espresso'
402
-                    ),
403
-                    '<p>',
404
-                    '</p>'
405
-                );
406
-            case self::TYPE_URGENT:
407
-                $date = new DateTime(self::PM_DEPRECATION_DATE);
408
-                return sprintf(
409
-                    esc_html__(
410
-                        '%1$sOn %3$s we will deprecate and remove the following outdated or obsolete payment integrations and ask you to migrate to a new payment integration now. Our replacement payment integrations offer more features and security.%2$s',
411
-                        'event_espresso'
412
-                    ),
413
-                    '<p>',
414
-                    '</p>',
415
-                    $date->format('F jS, Y')
416
-                );
417
-            case self::TYPE_FINAL:
418
-                return sprintf(
419
-                    esc_html__(
420
-                        '%1$sThe following payment integrations have been deactivated: PayPal Standard, PayPal Express, PayPal Smart Buttons, PayPal Pro, Braintree, Payflow Pro, Authorize.net SIM and Authorize.net AIM.%2$s',
421
-                        'event_espresso'
422
-                    ),
423
-                    '<p>',
424
-                    '</p>'
425
-                );
426
-            case self::TYPE_INITIAL:
427
-            default:
428
-                return sprintf(
429
-                    esc_html__(
430
-                        '%1$sIn early 2025 we will be deprecating the following outdated or obsolete payment integrations and ask you to migrate to a new payment integration as soon as possible. Our replacement payment integrations offer more features and security.%2$s',
431
-                        'event_espresso'
432
-                    ),
433
-                    '<p>',
434
-                    '</p>'
435
-                );
436
-        }
437
-    }
438
-
439
-
440
-    private function theFollowingPaymentsPg(): string
441
-    {
442
-        return sprintf(
443
-            esc_html__(
444
-                '%1$sThe following payment integrations will be %3$sremoved%4$s: PayPal Standard, PayPal Express, PayPal Smart Buttons, PayPal Pro, Braintree, Payflow Pro, Authorize.net SIM and Authorize.net AIM.%2$s',
445
-                'event_espresso'
446
-            ),
447
-            '<p>',
448
-            '</p>',
449
-            '<strong>',
450
-            '</strong>'
451
-        );
452
-    }
453
-
454
-
455
-    private function whatYouNeedToDoPg(string $type = self::TYPE_INITIAL): string
456
-    {
457
-        // link to the payment settings page
458
-        // ex: '/wp-admin/admin.php?page=espresso_payment_settings&action=default&payment_method=paypalcheckout'
459
-        $paypal_url = add_query_arg(
460
-            [
461
-                'page'           => 'espresso_payment_settings',
462
-                'action'         => 'default',
463
-                'payment_method' => 'paypalcheckout',
464
-            ],
465
-            admin_url('admin.php')
466
-        );
467
-        switch ($type) {
468
-            case self::TYPE_WARNING:
469
-                return sprintf(
470
-                    esc_html__(
471
-                        '%1$sWhat You Need To Do%2$s%3$sPlease begin transitioning to one of our other payment integrations such as %5$sPayPal Commerce,%9$s %6$sStripe,%9$s %7$sSquare,%9$s or %8$sAuthorize.net Accept%9$s soon.%4$s',
472
-                        'event_espresso'
473
-                    ),
474
-                    '<h4>',
475
-                    '</h4>',
476
-                    '<p>',
477
-                    '</p>',
478
-                    '<a href="' . esc_url_raw($paypal_url) . '">',
479
-                    '<a href="' . esc_url_raw(self::URL_STRIPE) . '" target="_blank">',
480
-                    '<a href="' . esc_url_raw(self::URL_SQUARE) . '" target="_blank">',
481
-                    '<a href="' . esc_url_raw(self::URL_ACCEPT) . '" target="_blank">',
482
-                    '</a>',
483
-                );
484
-            case self::TYPE_URGENT:
485
-            case self::TYPE_FINAL:
486
-                return sprintf(
487
-                    esc_html__(
488
-                        '%1$sWhat You Need To Do%2$s%3$sPlease begin transitioning to one of our other payment integrations such as %5$sPayPal Commerce,%9$s %6$sStripe,%9$s %7$sSquare,%9$s or %8$sAuthorize.net Accept%9$s immediately to avoid payment processing interruptions.%4$s',
489
-                        'event_espresso'
490
-                    ),
491
-                    '<h4>',
492
-                    '</h4>',
493
-                    '<p>',
494
-                    '</p>',
495
-                    '<a href="' . esc_url_raw($paypal_url) . '">',
496
-                    '<a href="' . esc_url_raw(self::URL_STRIPE) . '" target="_blank">',
497
-                    '<a href="' . esc_url_raw(self::URL_SQUARE) . '" target="_blank">',
498
-                    '<a href="' . esc_url_raw(self::URL_ACCEPT) . '" target="_blank">',
499
-                    '</a>',
500
-                );
501
-            case self::TYPE_INITIAL:
502
-            default:
503
-                return sprintf(
504
-                    esc_html__(
505
-                        '%1$sWhat You Need To Do%2$s%3$sPlease begin transitioning to one of our other payment integrations such as %5$sPayPal Commerce,%9$s %6$sStripe,%9$s %7$sSquare,%9$s or %8$sAuthorize.net Accept%9$s at your earliest convenience.%4$s',
506
-                        'event_espresso'
507
-                    ),
508
-                    '<h4>',
509
-                    '</h4>',
510
-                    '<p>',
511
-                    '</p>',
512
-                    '<a href="' . esc_url_raw($paypal_url) . '">',
513
-                    '<a href="' . esc_url_raw(self::URL_STRIPE) . '" target="_blank">',
514
-                    '<a href="' . esc_url_raw(self::URL_SQUARE) . '" target="_blank">',
515
-                    '<a href="' . esc_url_raw(self::URL_ACCEPT) . '" target="_blank">',
516
-                    '</a>',
517
-                );
518
-        }
519
-    }
520
-
521
-
522
-    private function toMigratePg(): string
523
-    {
524
-        return sprintf(
525
-            esc_html__(
526
-                '%1$sTo migrate to PayPal Commerce, simply go to %3$sEvent Espresso%4$s > %3$sPayment Methods%4$s > click the PayPal Commerce tab > activate PayPal Commerce > and click the blue "Connect with PayPal" button and follow the prompts.%2$s',
527
-                'event_espresso'
528
-            ),
529
-            '<p>',
530
-            '</p>',
531
-            '<strong>',
532
-            '</strong>'
533
-        );
534
-    }
535
-
536
-
537
-    private function supportPg(): string
538
-    {
539
-        return sprintf(
540
-            esc_html__(
541
-                '%1$sSupport%2$s%3$sOur support team is available to assist you with the transition process and answer any questions you may have. Contact us at %5$s for help, or click the following link to %9$slearn more %10$s. This message will disappear once you deactivate any of the affected gateways.%4$s
348
+			$this->heading($type),
349
+			$this->firstPg($type)
350
+			. $this->theFollowingPaymentsPg()
351
+			. $this->whatYouNeedToDoPg($type)
352
+			. $this->toMigratePg()
353
+			. $this->supportPg()
354
+		);
355
+
356
+		new PersistentAdminNotice(
357
+			$name,
358
+			$message,
359
+			$notice_type === 'warning',
360
+			'manage_options',
361
+			'view persistent admin notice',
362
+			false,
363
+			$notice_type,
364
+			'ee-service-change'
365
+		);
366
+	}
367
+
368
+
369
+	private function heading(string $type = self::TYPE_INITIAL): string
370
+	{
371
+		switch ($type) {
372
+			case self::TYPE_WARNING:
373
+				return esc_html__(
374
+					'Urgent Reminder: To continue processing payments, migrate to a new payment integration today.',
375
+					'event_espresso'
376
+				);
377
+			case self::TYPE_URGENT:
378
+				return esc_html__(
379
+					'Immediate Action Required: To continue processing payments, migrate to a new payment integration NOW!',
380
+					'event_espresso'
381
+				);
382
+			case self::TYPE_FINAL:
383
+				return esc_html__('Payment Gateway Integrations Deactivated!', 'event_espresso');
384
+			case self::TYPE_INITIAL:
385
+			default:
386
+				return esc_html__(
387
+					'Action Required: To continue processing payments, migrate to a new payment integration soon.',
388
+					'event_espresso'
389
+				);
390
+		}
391
+	}
392
+
393
+
394
+	private function firstPg(string $type = self::TYPE_INITIAL): string
395
+	{
396
+		switch ($type) {
397
+			case self::TYPE_WARNING:
398
+				return sprintf(
399
+					esc_html__(
400
+						'%1$sRemember, we will soon deprecate and remove the following outdated or obsolete payment integrations and ask you to migrate to a new payment integration as soon as possible. Our replacement payment integrations offer more features and security.%2$s',
401
+						'event_espresso'
402
+					),
403
+					'<p>',
404
+					'</p>'
405
+				);
406
+			case self::TYPE_URGENT:
407
+				$date = new DateTime(self::PM_DEPRECATION_DATE);
408
+				return sprintf(
409
+					esc_html__(
410
+						'%1$sOn %3$s we will deprecate and remove the following outdated or obsolete payment integrations and ask you to migrate to a new payment integration now. Our replacement payment integrations offer more features and security.%2$s',
411
+						'event_espresso'
412
+					),
413
+					'<p>',
414
+					'</p>',
415
+					$date->format('F jS, Y')
416
+				);
417
+			case self::TYPE_FINAL:
418
+				return sprintf(
419
+					esc_html__(
420
+						'%1$sThe following payment integrations have been deactivated: PayPal Standard, PayPal Express, PayPal Smart Buttons, PayPal Pro, Braintree, Payflow Pro, Authorize.net SIM and Authorize.net AIM.%2$s',
421
+						'event_espresso'
422
+					),
423
+					'<p>',
424
+					'</p>'
425
+				);
426
+			case self::TYPE_INITIAL:
427
+			default:
428
+				return sprintf(
429
+					esc_html__(
430
+						'%1$sIn early 2025 we will be deprecating the following outdated or obsolete payment integrations and ask you to migrate to a new payment integration as soon as possible. Our replacement payment integrations offer more features and security.%2$s',
431
+						'event_espresso'
432
+					),
433
+					'<p>',
434
+					'</p>'
435
+				);
436
+		}
437
+	}
438
+
439
+
440
+	private function theFollowingPaymentsPg(): string
441
+	{
442
+		return sprintf(
443
+			esc_html__(
444
+				'%1$sThe following payment integrations will be %3$sremoved%4$s: PayPal Standard, PayPal Express, PayPal Smart Buttons, PayPal Pro, Braintree, Payflow Pro, Authorize.net SIM and Authorize.net AIM.%2$s',
445
+				'event_espresso'
446
+			),
447
+			'<p>',
448
+			'</p>',
449
+			'<strong>',
450
+			'</strong>'
451
+		);
452
+	}
453
+
454
+
455
+	private function whatYouNeedToDoPg(string $type = self::TYPE_INITIAL): string
456
+	{
457
+		// link to the payment settings page
458
+		// ex: '/wp-admin/admin.php?page=espresso_payment_settings&action=default&payment_method=paypalcheckout'
459
+		$paypal_url = add_query_arg(
460
+			[
461
+				'page'           => 'espresso_payment_settings',
462
+				'action'         => 'default',
463
+				'payment_method' => 'paypalcheckout',
464
+			],
465
+			admin_url('admin.php')
466
+		);
467
+		switch ($type) {
468
+			case self::TYPE_WARNING:
469
+				return sprintf(
470
+					esc_html__(
471
+						'%1$sWhat You Need To Do%2$s%3$sPlease begin transitioning to one of our other payment integrations such as %5$sPayPal Commerce,%9$s %6$sStripe,%9$s %7$sSquare,%9$s or %8$sAuthorize.net Accept%9$s soon.%4$s',
472
+						'event_espresso'
473
+					),
474
+					'<h4>',
475
+					'</h4>',
476
+					'<p>',
477
+					'</p>',
478
+					'<a href="' . esc_url_raw($paypal_url) . '">',
479
+					'<a href="' . esc_url_raw(self::URL_STRIPE) . '" target="_blank">',
480
+					'<a href="' . esc_url_raw(self::URL_SQUARE) . '" target="_blank">',
481
+					'<a href="' . esc_url_raw(self::URL_ACCEPT) . '" target="_blank">',
482
+					'</a>',
483
+				);
484
+			case self::TYPE_URGENT:
485
+			case self::TYPE_FINAL:
486
+				return sprintf(
487
+					esc_html__(
488
+						'%1$sWhat You Need To Do%2$s%3$sPlease begin transitioning to one of our other payment integrations such as %5$sPayPal Commerce,%9$s %6$sStripe,%9$s %7$sSquare,%9$s or %8$sAuthorize.net Accept%9$s immediately to avoid payment processing interruptions.%4$s',
489
+						'event_espresso'
490
+					),
491
+					'<h4>',
492
+					'</h4>',
493
+					'<p>',
494
+					'</p>',
495
+					'<a href="' . esc_url_raw($paypal_url) . '">',
496
+					'<a href="' . esc_url_raw(self::URL_STRIPE) . '" target="_blank">',
497
+					'<a href="' . esc_url_raw(self::URL_SQUARE) . '" target="_blank">',
498
+					'<a href="' . esc_url_raw(self::URL_ACCEPT) . '" target="_blank">',
499
+					'</a>',
500
+				);
501
+			case self::TYPE_INITIAL:
502
+			default:
503
+				return sprintf(
504
+					esc_html__(
505
+						'%1$sWhat You Need To Do%2$s%3$sPlease begin transitioning to one of our other payment integrations such as %5$sPayPal Commerce,%9$s %6$sStripe,%9$s %7$sSquare,%9$s or %8$sAuthorize.net Accept%9$s at your earliest convenience.%4$s',
506
+						'event_espresso'
507
+					),
508
+					'<h4>',
509
+					'</h4>',
510
+					'<p>',
511
+					'</p>',
512
+					'<a href="' . esc_url_raw($paypal_url) . '">',
513
+					'<a href="' . esc_url_raw(self::URL_STRIPE) . '" target="_blank">',
514
+					'<a href="' . esc_url_raw(self::URL_SQUARE) . '" target="_blank">',
515
+					'<a href="' . esc_url_raw(self::URL_ACCEPT) . '" target="_blank">',
516
+					'</a>',
517
+				);
518
+		}
519
+	}
520
+
521
+
522
+	private function toMigratePg(): string
523
+	{
524
+		return sprintf(
525
+			esc_html__(
526
+				'%1$sTo migrate to PayPal Commerce, simply go to %3$sEvent Espresso%4$s > %3$sPayment Methods%4$s > click the PayPal Commerce tab > activate PayPal Commerce > and click the blue "Connect with PayPal" button and follow the prompts.%2$s',
527
+				'event_espresso'
528
+			),
529
+			'<p>',
530
+			'</p>',
531
+			'<strong>',
532
+			'</strong>'
533
+		);
534
+	}
535
+
536
+
537
+	private function supportPg(): string
538
+	{
539
+		return sprintf(
540
+			esc_html__(
541
+				'%1$sSupport%2$s%3$sOur support team is available to assist you with the transition process and answer any questions you may have. Contact us at %5$s for help, or click the following link to %9$slearn more %10$s. This message will disappear once you deactivate any of the affected gateways.%4$s
542 542
 %3$sWe appreciate your understanding and cooperation as we replace legacy integrations with new integrations.%4$s
543 543
 %3$s%6$sThe team at Event Espresso %8$s%7$s%4$s',
544
-                'event_espresso'
545
-            ),
546
-            '<h4>',
547
-            '</h4>',
548
-            '<p>',
549
-            '</p>',
550
-            '<a href="mailto:[email protected]">[email protected]</a>',
551
-            '<h5>',
552
-            '</h5>',
553
-            '<span class="ee-icon ee-icon-ee-cup-thick"></span>',
554
-            '<a href="' . esc_url_raw(self::URL_SUPPORT_DOCS) . '" target="_blank">',
555
-            '</a>'
556
-        );
557
-    }
544
+				'event_espresso'
545
+			),
546
+			'<h4>',
547
+			'</h4>',
548
+			'<p>',
549
+			'</p>',
550
+			'<a href="mailto:[email protected]">[email protected]</a>',
551
+			'<h5>',
552
+			'</h5>',
553
+			'<span class="ee-icon ee-icon-ee-cup-thick"></span>',
554
+			'<a href="' . esc_url_raw(self::URL_SUPPORT_DOCS) . '" target="_blank">',
555
+			'</a>'
556
+		);
557
+	}
558 558
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function maybeDismissNotifications()
155 155
     {
156
-        if (! $this->activeDeprecatedPaymentMethods()) {
156
+        if ( ! $this->activeDeprecatedPaymentMethods()) {
157 157
             $notices = [
158
-                self::NOTIFICATION_NAME_PREFIX . self::TYPE_INITIAL,
159
-                self::NOTIFICATION_NAME_PREFIX . self::TYPE_WARNING,
160
-                self::NOTIFICATION_NAME_PREFIX . self::TYPE_URGENT,
158
+                self::NOTIFICATION_NAME_PREFIX.self::TYPE_INITIAL,
159
+                self::NOTIFICATION_NAME_PREFIX.self::TYPE_WARNING,
160
+                self::NOTIFICATION_NAME_PREFIX.self::TYPE_URGENT,
161 161
             ];
162 162
             foreach ($notices as $notice) {
163 163
                 PersistentAdminNoticeManager::dismissPersistentAdminNotice($notice);
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
             foreach ($active_deprecated_payment_methods as $active_deprecated_pm) {
199 199
                 if ($active_deprecated_pm instanceof EE_Payment_Method) {
200 200
                     $active_deprecated_pm->deactivate();
201
-                    unset($this->active_deprecated_payment_methods[ $active_deprecated_pm->slug() ]);
202
-                    $this->deactivated_pms[ $active_deprecated_pm->slug() ] = $active_deprecated_pm->name();
201
+                    unset($this->active_deprecated_payment_methods[$active_deprecated_pm->slug()]);
202
+                    $this->deactivated_pms[$active_deprecated_pm->slug()] = $active_deprecated_pm->name();
203 203
                     $active_deprecated_pm->save();
204 204
                 }
205 205
             }
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
             $deprecated_payment_methods              = $this->payment_method_model->get_all(
242 242
                 [['PMD_slug' => ['IN', array_keys($this->deprecated_payment_methods)]]]
243 243
             );
244
-            if (! $deprecated_payment_methods) {
244
+            if ( ! $deprecated_payment_methods) {
245 245
                 return $this->active_deprecated_payment_methods;
246 246
             }
247 247
             foreach ($deprecated_payment_methods as $deprecated_pm) {
248 248
                 if ($deprecated_pm instanceof EE_Payment_Method && $deprecated_pm->active()) {
249
-                    $this->active_deprecated_payment_methods[ $deprecated_pm->slug() ] = $deprecated_pm;
249
+                    $this->active_deprecated_payment_methods[$deprecated_pm->slug()] = $deprecated_pm;
250 250
                 }
251 251
             }
252 252
         }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
                 return;
280 280
             }
281 281
         }
282
-        if (! empty($this->deactivated_pms) && $this->now > new DateTime(self::PM_DEPRECATION_DATE)) {
282
+        if ( ! empty($this->deactivated_pms) && $this->now > new DateTime(self::PM_DEPRECATION_DATE)) {
283 283
             $this->displayNotification(self::TYPE_FINAL);
284 284
         }
285 285
     }
@@ -295,20 +295,20 @@  discard block
 block discarded – undo
295 295
         if (empty($pm_deprecations)) {
296 296
             add_option(self::OPTION_NAME, [], '', 'no');
297 297
         }
298
-        if (! empty($pm_deprecations['jan-6-update'])) {
298
+        if ( ! empty($pm_deprecations['jan-6-update'])) {
299 299
             return;
300 300
         }
301 301
         PersistentAdminNoticeManager::deletePersistentAdminNotice(
302
-            self::NOTIFICATION_NAME_PREFIX . self::TYPE_WARNING
302
+            self::NOTIFICATION_NAME_PREFIX.self::TYPE_WARNING
303 303
         );
304 304
         PersistentAdminNoticeManager::deletePersistentAdminNotice(
305
-            self::NOTIFICATION_NAME_PREFIX . self::TYPE_URGENT
305
+            self::NOTIFICATION_NAME_PREFIX.self::TYPE_URGENT
306 306
         );
307 307
         PersistentAdminNoticeManager::deletePersistentAdminNotice(
308
-            self::NOTIFICATION_NAME_PREFIX . self::TYPE_FINAL
308
+            self::NOTIFICATION_NAME_PREFIX.self::TYPE_FINAL
309 309
         );
310 310
         PersistentAdminNoticeManager::deletePersistentAdminNotice(
311
-            self::NOTIFICATION_NAME_PREFIX . self::TYPE_INITIAL
311
+            self::NOTIFICATION_NAME_PREFIX.self::TYPE_INITIAL
312 312
         );
313 313
         $pm_deprecations['jan-6-update'] = true;
314 314
         update_option(self::OPTION_NAME, $pm_deprecations);
@@ -323,20 +323,20 @@  discard block
 block discarded – undo
323 323
     {
324 324
         switch ($type) {
325 325
             case self::TYPE_WARNING:
326
-                $name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_WARNING;
326
+                $name        = self::NOTIFICATION_NAME_PREFIX.self::TYPE_WARNING;
327 327
                 $notice_type = 'attention';
328 328
                 break;
329 329
             case self::TYPE_URGENT:
330
-                $name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_URGENT;
330
+                $name        = self::NOTIFICATION_NAME_PREFIX.self::TYPE_URGENT;
331 331
                 $notice_type = 'warning';
332 332
                 break;
333 333
             case self::TYPE_FINAL:
334
-                $name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_FINAL;
334
+                $name        = self::NOTIFICATION_NAME_PREFIX.self::TYPE_FINAL;
335 335
                 $notice_type = 'error';
336 336
                 break;
337 337
             case self::TYPE_INITIAL:
338 338
             default:
339
-                $name        = self::NOTIFICATION_NAME_PREFIX . self::TYPE_INITIAL;
339
+                $name        = self::NOTIFICATION_NAME_PREFIX.self::TYPE_INITIAL;
340 340
                 $notice_type = 'info';
341 341
         }
342 342
 
@@ -475,10 +475,10 @@  discard block
 block discarded – undo
475 475
                     '</h4>',
476 476
                     '<p>',
477 477
                     '</p>',
478
-                    '<a href="' . esc_url_raw($paypal_url) . '">',
479
-                    '<a href="' . esc_url_raw(self::URL_STRIPE) . '" target="_blank">',
480
-                    '<a href="' . esc_url_raw(self::URL_SQUARE) . '" target="_blank">',
481
-                    '<a href="' . esc_url_raw(self::URL_ACCEPT) . '" target="_blank">',
478
+                    '<a href="'.esc_url_raw($paypal_url).'">',
479
+                    '<a href="'.esc_url_raw(self::URL_STRIPE).'" target="_blank">',
480
+                    '<a href="'.esc_url_raw(self::URL_SQUARE).'" target="_blank">',
481
+                    '<a href="'.esc_url_raw(self::URL_ACCEPT).'" target="_blank">',
482 482
                     '</a>',
483 483
                 );
484 484
             case self::TYPE_URGENT:
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
                     '</h4>',
493 493
                     '<p>',
494 494
                     '</p>',
495
-                    '<a href="' . esc_url_raw($paypal_url) . '">',
496
-                    '<a href="' . esc_url_raw(self::URL_STRIPE) . '" target="_blank">',
497
-                    '<a href="' . esc_url_raw(self::URL_SQUARE) . '" target="_blank">',
498
-                    '<a href="' . esc_url_raw(self::URL_ACCEPT) . '" target="_blank">',
495
+                    '<a href="'.esc_url_raw($paypal_url).'">',
496
+                    '<a href="'.esc_url_raw(self::URL_STRIPE).'" target="_blank">',
497
+                    '<a href="'.esc_url_raw(self::URL_SQUARE).'" target="_blank">',
498
+                    '<a href="'.esc_url_raw(self::URL_ACCEPT).'" target="_blank">',
499 499
                     '</a>',
500 500
                 );
501 501
             case self::TYPE_INITIAL:
@@ -509,10 +509,10 @@  discard block
 block discarded – undo
509 509
                     '</h4>',
510 510
                     '<p>',
511 511
                     '</p>',
512
-                    '<a href="' . esc_url_raw($paypal_url) . '">',
513
-                    '<a href="' . esc_url_raw(self::URL_STRIPE) . '" target="_blank">',
514
-                    '<a href="' . esc_url_raw(self::URL_SQUARE) . '" target="_blank">',
515
-                    '<a href="' . esc_url_raw(self::URL_ACCEPT) . '" target="_blank">',
512
+                    '<a href="'.esc_url_raw($paypal_url).'">',
513
+                    '<a href="'.esc_url_raw(self::URL_STRIPE).'" target="_blank">',
514
+                    '<a href="'.esc_url_raw(self::URL_SQUARE).'" target="_blank">',
515
+                    '<a href="'.esc_url_raw(self::URL_ACCEPT).'" target="_blank">',
516 516
                     '</a>',
517 517
                 );
518 518
         }
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
             '<h5>',
552 552
             '</h5>',
553 553
             '<span class="ee-icon ee-icon-ee-cup-thick"></span>',
554
-            '<a href="' . esc_url_raw(self::URL_SUPPORT_DOCS) . '" target="_blank">',
554
+            '<a href="'.esc_url_raw(self::URL_SUPPORT_DOCS).'" target="_blank">',
555 555
             '</a>'
556 556
         );
557 557
     }
Please login to merge, or discard this patch.
core/services/service_changes/ServiceChangesManager.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -20,61 +20,61 @@
 block discarded – undo
20 20
  */
21 21
 class ServiceChangesManager
22 22
 {
23
-    private EE_Dependency_Map $dependency_map;
23
+	private EE_Dependency_Map $dependency_map;
24 24
 
25
-    private LoaderInterface $loader;
25
+	private LoaderInterface $loader;
26 26
 
27 27
 
28
-    /**
29
-     * @param EE_Dependency_Map $dependency_map
30
-     * @param LoaderInterface   $loader
31
-     * @throws EE_Error
32
-     * @throws ReflectionException
33
-     */
34
-    public function __construct(EE_Dependency_Map $dependency_map, LoaderInterface $loader)
35
-    {
36
-        $this->dependency_map = $dependency_map;
37
-        $this->loader         = $loader;
38
-        if (DbStatus::isOnline()) {
39
-            /** @var RequestInterface $request */
40
-            $request = $this->loader->getShared(RequestInterface::class);
41
-            if ($request->isAdmin() && ! $request->isActivation()) {
42
-                $this->registerDependencies();
43
-                $this->loadServiceChangeNotifications();
44
-            }
45
-        }
46
-    }
28
+	/**
29
+	 * @param EE_Dependency_Map $dependency_map
30
+	 * @param LoaderInterface   $loader
31
+	 * @throws EE_Error
32
+	 * @throws ReflectionException
33
+	 */
34
+	public function __construct(EE_Dependency_Map $dependency_map, LoaderInterface $loader)
35
+	{
36
+		$this->dependency_map = $dependency_map;
37
+		$this->loader         = $loader;
38
+		if (DbStatus::isOnline()) {
39
+			/** @var RequestInterface $request */
40
+			$request = $this->loader->getShared(RequestInterface::class);
41
+			if ($request->isAdmin() && ! $request->isActivation()) {
42
+				$this->registerDependencies();
43
+				$this->loadServiceChangeNotifications();
44
+			}
45
+		}
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * @return void
51
-     */
52
-    private function registerDependencies()
53
-    {
54
-        $this->dependency_map->registerDependencies(
55
-            'EventEspresso\core\domain\services\service_changes\PaymentMethodDeprecations2025',
56
-            [
57
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
58
-            ]
59
-        );
60
-    }
49
+	/**
50
+	 * @return void
51
+	 */
52
+	private function registerDependencies()
53
+	{
54
+		$this->dependency_map->registerDependencies(
55
+			'EventEspresso\core\domain\services\service_changes\PaymentMethodDeprecations2025',
56
+			[
57
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
58
+			]
59
+		);
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @throws EE_Error
65
-     * @throws ReflectionException
66
-     */
67
-    public function loadServiceChangeNotifications()
68
-    {
69
-        if (
70
-            apply_filters(
71
-                'FHEE__EventEspresso_core_services_service_changes_ServiceChangesManager__loadServiceChangeNotifications__loadPaymentMethodDeprecations2025',
72
-                true
73
-            )
74
-        ) {
75
-            /** @var PaymentMethodDeprecations2025 $pm_deps */
76
-            $pm_deps = $this->loader->getShared(PaymentMethodDeprecations2025::class);
77
-            $pm_deps->setHooks();
78
-        }
79
-    }
63
+	/**
64
+	 * @throws EE_Error
65
+	 * @throws ReflectionException
66
+	 */
67
+	public function loadServiceChangeNotifications()
68
+	{
69
+		if (
70
+			apply_filters(
71
+				'FHEE__EventEspresso_core_services_service_changes_ServiceChangesManager__loadServiceChangeNotifications__loadPaymentMethodDeprecations2025',
72
+				true
73
+			)
74
+		) {
75
+			/** @var PaymentMethodDeprecations2025 $pm_deps */
76
+			$pm_deps = $this->loader->getShared(PaymentMethodDeprecations2025::class);
77
+			$pm_deps->setHooks();
78
+		}
79
+	}
80 80
 }
Please login to merge, or discard this patch.