Completed
Branch master (724475)
by
unknown
05:49
created
core/domain/services/contexts/RequestTypeContextFactoryInterface.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@
 block discarded – undo
14 14
  */
15 15
 interface RequestTypeContextFactoryInterface
16 16
 {
17
-    /**
18
-     * @param string $slug
19
-     * @return RequestTypeContext
20
-     */
21
-    public function create(string $slug): RequestTypeContext;
17
+	/**
18
+	 * @param string $slug
19
+	 * @return RequestTypeContext
20
+	 */
21
+	public function create(string $slug): RequestTypeContext;
22 22
 }
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextFactory.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -16,80 +16,80 @@
 block discarded – undo
16 16
  */
17 17
 class RequestTypeContextFactory implements RequestTypeContextFactoryInterface
18 18
 {
19
-    private LoaderInterface $loader;
19
+	private LoaderInterface $loader;
20 20
 
21 21
 
22
-    /**
23
-     * RequestTypeContextFactory constructor.
24
-     *
25
-     * @param LoaderInterface $loader
26
-     */
27
-    public function __construct(LoaderInterface $loader)
28
-    {
29
-        $this->loader = $loader;
30
-    }
22
+	/**
23
+	 * RequestTypeContextFactory constructor.
24
+	 *
25
+	 * @param LoaderInterface $loader
26
+	 */
27
+	public function __construct(LoaderInterface $loader)
28
+	{
29
+		$this->loader = $loader;
30
+	}
31 31
 
32 32
 
33
-    /**
34
-     * @param string $slug
35
-     * @return RequestTypeContext
36
-     */
37
-    public function create(string $slug): RequestTypeContext
38
-    {
39
-        switch ($slug) {
40
-            case RequestTypeContext::ACTIVATION:
41
-                $description = 'The current request is for some form of activation';
42
-                break;
43
-            case RequestTypeContext::API:
44
-                $description = 'The current request is for the EE REST API';
45
-                break;
46
-            case RequestTypeContext::AJAX_FRONT:
47
-                $description = 'The current request is for the frontend via AJAX';
48
-                break;
49
-            case RequestTypeContext::AJAX_ADMIN:
50
-                $description = 'The current request is for the admin via AJAX';
51
-                break;
52
-            case RequestTypeContext::AJAX_HEARTBEAT:
53
-                $description = 'The current request is for the WP Heartbeat';
54
-                break;
55
-            case RequestTypeContext::AJAX_OTHER:
56
-                $description = 'The current request is for non-EE related code via AJAX';
57
-                break;
58
-            case RequestTypeContext::CRON:
59
-                $description = 'The current request is for a WP_Cron';
60
-                break;
61
-            case RequestTypeContext::CLI:
62
-                $description = 'The current request is from the command line';
63
-                break;
64
-            case RequestTypeContext::ADMIN:
65
-                $description = 'The current request is for the admin';
66
-                break;
67
-            case RequestTypeContext::IFRAME:
68
-                $description = 'The current request is for an iframe';
69
-                break;
70
-            case RequestTypeContext::FEED:
71
-                $description = 'The current request is for a feed (ie: RSS)';
72
-                break;
73
-            case RequestTypeContext::GQL:
74
-                $description = 'The current request is for the EE GraphQL Manager';
75
-                break;
76
-            case RequestTypeContext::WP_API:
77
-                $description = 'The current request is for the WordPress REST API';
78
-                break;
79
-            case RequestTypeContext::WP_SCRAPE:
80
-                $description = 'The current request is for a WordPress loopback scrape';
81
-                break;
82
-            case RequestTypeContext::FRONTEND:
83
-            default:
84
-                $description = 'The current request is for the frontend';
85
-                break;
86
-        }
87
-        // we're using the Loader with sharing turned on,
88
-        // so that the generated RequestTypeContext object is accessible anywhere
89
-        // by simply requesting it again from the loader
90
-        return $this->loader->getShared(
91
-            'EventEspresso\core\domain\entities\contexts\RequestTypeContext',
92
-            array($slug, $description)
93
-        );
94
-    }
33
+	/**
34
+	 * @param string $slug
35
+	 * @return RequestTypeContext
36
+	 */
37
+	public function create(string $slug): RequestTypeContext
38
+	{
39
+		switch ($slug) {
40
+			case RequestTypeContext::ACTIVATION:
41
+				$description = 'The current request is for some form of activation';
42
+				break;
43
+			case RequestTypeContext::API:
44
+				$description = 'The current request is for the EE REST API';
45
+				break;
46
+			case RequestTypeContext::AJAX_FRONT:
47
+				$description = 'The current request is for the frontend via AJAX';
48
+				break;
49
+			case RequestTypeContext::AJAX_ADMIN:
50
+				$description = 'The current request is for the admin via AJAX';
51
+				break;
52
+			case RequestTypeContext::AJAX_HEARTBEAT:
53
+				$description = 'The current request is for the WP Heartbeat';
54
+				break;
55
+			case RequestTypeContext::AJAX_OTHER:
56
+				$description = 'The current request is for non-EE related code via AJAX';
57
+				break;
58
+			case RequestTypeContext::CRON:
59
+				$description = 'The current request is for a WP_Cron';
60
+				break;
61
+			case RequestTypeContext::CLI:
62
+				$description = 'The current request is from the command line';
63
+				break;
64
+			case RequestTypeContext::ADMIN:
65
+				$description = 'The current request is for the admin';
66
+				break;
67
+			case RequestTypeContext::IFRAME:
68
+				$description = 'The current request is for an iframe';
69
+				break;
70
+			case RequestTypeContext::FEED:
71
+				$description = 'The current request is for a feed (ie: RSS)';
72
+				break;
73
+			case RequestTypeContext::GQL:
74
+				$description = 'The current request is for the EE GraphQL Manager';
75
+				break;
76
+			case RequestTypeContext::WP_API:
77
+				$description = 'The current request is for the WordPress REST API';
78
+				break;
79
+			case RequestTypeContext::WP_SCRAPE:
80
+				$description = 'The current request is for a WordPress loopback scrape';
81
+				break;
82
+			case RequestTypeContext::FRONTEND:
83
+			default:
84
+				$description = 'The current request is for the frontend';
85
+				break;
86
+		}
87
+		// we're using the Loader with sharing turned on,
88
+		// so that the generated RequestTypeContext object is accessible anywhere
89
+		// by simply requesting it again from the loader
90
+		return $this->loader->getShared(
91
+			'EventEspresso\core\domain\entities\contexts\RequestTypeContext',
92
+			array($slug, $description)
93
+		);
94
+	}
95 95
 }
Please login to merge, or discard this patch.
core/domain/deprecated/EE_Load_Textdomain.core.php 2 patches
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -16,156 +16,156 @@
 block discarded – undo
16 16
  */
17 17
 class EE_Load_Textdomain extends EE_Base
18 18
 {
19
-    private const REPO_BASE_URL    = 'https://github.com/eventespresso/languages-ee4/raw/refs/heads/master/event_espresso';
20
-
21
-    private const FILE_NAME_PREFIX = 'event_espresso-';
22
-
23
-
24
-    /**
25
-     * holds the current lang in WP
26
-     *
27
-     * @var string
28
-     */
29
-    public static string $locale = '';
30
-
31
-
32
-    /**
33
-     * this takes care of retrieving a matching textdomain for event espresso for the current WPLANG from EE GitHub
34
-     * repo (if necessary) and then loading it for translations. should only be called in wp plugins_loaded callback
35
-     *
36
-     * @return void
37
-     * @depecated 5.0.42
38
-     */
39
-    public static function loadTextdomain()
40
-    {
41
-        EE_Load_Textdomain::$locale = get_locale();
42
-        if (empty(EE_Load_Textdomain::$locale)) {
43
-            // can't download a language file if a language isn't set <taps temple>
44
-            return;
45
-        }
46
-        // hook into init to load the textdomain
47
-        add_action('init', [EE_Load_Textdomain::class, 'loadTranslationsForLocale'], 9);
48
-        add_action('init', [EE_Load_Textdomain::class, 'loadPluginTextdomain']);
49
-    }
50
-
51
-
52
-    /**
53
-     * @return void
54
-     * @depecated 5.0.42
55
-     */
56
-    public static function loadPluginTextdomain()
57
-    {
58
-        $locale_mo      = EE_Load_Textdomain::$locale . '.mo';
59
-        $github_mo_path = EE_LANGUAGES_SAFE_DIR . EE_Load_Textdomain::FILE_NAME_PREFIX . $locale_mo;
60
-        if (is_readable($github_mo_path)) {
61
-            load_plugin_textdomain('event_espresso', false, EE_LANGUAGES_SAFE_LOC);
62
-            return;
63
-        }
64
-        $glotpress_mo_path = EE_LANGUAGES_SAFE_DIR . EE_Load_Textdomain::FILE_NAME_PREFIX . '4-' . $locale_mo;
65
-        if (is_readable($glotpress_mo_path)) {
66
-            load_textdomain('event_espresso', $glotpress_mo_path);
67
-            return;
68
-        }
69
-        load_plugin_textdomain('event_espresso', false, dirname(EE_PLUGIN_BASENAME) . '/languages/');
70
-    }
71
-
72
-
73
-    /**
74
-     * The purpose of this method is to side-load the language files for EE,
75
-     * this includes the POT file and the PO/MO files for the given WPLANG locale (if necessary).
76
-     *
77
-     * @return void
78
-     * @throws EE_Error
79
-     * @throws ReflectionException
80
-     * @depecated 5.0.42
81
-     */
82
-    public static function loadTranslationsForLocale()
83
-    {
84
-        $loaded_text_domains = new LoadedTextDomains();
85
-        // check if language files has already been side-loaded
86
-        if ($loaded_text_domains->hasVersion(EE_Load_Textdomain::$locale, EVENT_ESPRESSO_VERSION)) {
87
-            return;
88
-        }
89
-
90
-        // if locale is "en_US" then lets just get out, since Event Espresso core is already "en_US"
91
-        if (EE_Load_Textdomain::$locale === 'en_US') {
92
-            // but set option first else we'll forever be downloading the pot file
93
-            $loaded_text_domains->versionLoaded(EE_Load_Textdomain::$locale, EVENT_ESPRESSO_VERSION);
94
-            return;
95
-        }
96
-
97
-        /** @var Request $request */
98
-        $request = LoaderFactory::getShared(Request::class);
99
-        if ($request->isActivation()) {
100
-            // clean up old text domain tracking
101
-            $LegacyTextDomainOptions = new LegacyTextDomainOptions($loaded_text_domains);
102
-            $LegacyTextDomainOptions->convertToConsolidatedFormat();
103
-        }
104
-
105
-        [$mo_loaded, $po_loaded] = EE_Load_Textdomain::sideLoadMoPo();
106
-
107
-        // set option so the above only runs when EE updates.
108
-        $loaded_text_domains->versionLoaded(EE_Load_Textdomain::$locale, EVENT_ESPRESSO_VERSION);
109
-
110
-        if ($mo_loaded && $po_loaded) {
111
-            EE_Error::add_success(
112
-                sprintf(
113
-                    esc_html__(
114
-                        'Successfully downloaded the Event Espresso text domain for the "%1$s" locale.',
115
-                        'event_espresso'
116
-                    ),
117
-                    EE_Load_Textdomain::$locale
118
-                ),
119
-                __FILE__,
120
-                __FUNCTION__,
121
-                __LINE__
122
-            );
123
-        }
124
-    }
125
-
126
-
127
-    /**
128
-     * @throws ReflectionException
129
-     * @throws EE_Error
130
-     * @depecated 5.0.42
131
-     */
132
-    private static function sideLoadMoPo(): array
133
-    {
134
-        // load side-loader and side-load the .POT file as this should always be included.
135
-        $side_loader_args = [
136
-            'upload_path'   => EE_PLUGIN_DIR_PATH . 'languages/',
137
-            'download_url'  => EE_Load_Textdomain::REPO_BASE_URL . '.pot',
138
-            'new_file_name' => 'event_espresso.pot',
139
-        ];
140
-        EE_Registry::instance()->load_helper('Sideloader');
141
-        $side_loader = new EEH_Sideloader($side_loader_args);
142
-        // side-load the .POT file only for main site of the network, or if not running Multisite.
143
-        if (is_main_site()) {
144
-            $side_loader->sideload();
145
-        }
146
-        $repo_locale_URL = EE_Load_Textdomain::REPO_BASE_URL . '-' . EE_Load_Textdomain::$locale;
147
-        $file_name_base  = EE_Load_Textdomain::FILE_NAME_PREFIX . EE_Load_Textdomain::$locale;
148
-
149
-        // made it here so let's get the language files from the GitHub repo, first the .mo file
150
-        $side_loader->setDownloadUrl("$repo_locale_URL.mo");
151
-        $side_loader->setNewFileName("$file_name_base.mo");
152
-        $mo_loaded = $side_loader->sideload();
153
-
154
-        // now the .po file:
155
-        $side_loader->setDownloadUrl("$repo_locale_URL.po");
156
-        $side_loader->setNewFileName("$file_name_base.po");
157
-        $po_loaded = $side_loader->sideload();
158
-
159
-        return [$mo_loaded, $po_loaded];
160
-    }
161
-
162
-
163
-    /**
164
-     * @depecated 5.0.42
165
-     */
166
-    public static function load_textdomain()
167
-    {
168
-        EE_Load_Textdomain::loadTextdomain();
169
-    }
19
+	private const REPO_BASE_URL    = 'https://github.com/eventespresso/languages-ee4/raw/refs/heads/master/event_espresso';
20
+
21
+	private const FILE_NAME_PREFIX = 'event_espresso-';
22
+
23
+
24
+	/**
25
+	 * holds the current lang in WP
26
+	 *
27
+	 * @var string
28
+	 */
29
+	public static string $locale = '';
30
+
31
+
32
+	/**
33
+	 * this takes care of retrieving a matching textdomain for event espresso for the current WPLANG from EE GitHub
34
+	 * repo (if necessary) and then loading it for translations. should only be called in wp plugins_loaded callback
35
+	 *
36
+	 * @return void
37
+	 * @depecated 5.0.42
38
+	 */
39
+	public static function loadTextdomain()
40
+	{
41
+		EE_Load_Textdomain::$locale = get_locale();
42
+		if (empty(EE_Load_Textdomain::$locale)) {
43
+			// can't download a language file if a language isn't set <taps temple>
44
+			return;
45
+		}
46
+		// hook into init to load the textdomain
47
+		add_action('init', [EE_Load_Textdomain::class, 'loadTranslationsForLocale'], 9);
48
+		add_action('init', [EE_Load_Textdomain::class, 'loadPluginTextdomain']);
49
+	}
50
+
51
+
52
+	/**
53
+	 * @return void
54
+	 * @depecated 5.0.42
55
+	 */
56
+	public static function loadPluginTextdomain()
57
+	{
58
+		$locale_mo      = EE_Load_Textdomain::$locale . '.mo';
59
+		$github_mo_path = EE_LANGUAGES_SAFE_DIR . EE_Load_Textdomain::FILE_NAME_PREFIX . $locale_mo;
60
+		if (is_readable($github_mo_path)) {
61
+			load_plugin_textdomain('event_espresso', false, EE_LANGUAGES_SAFE_LOC);
62
+			return;
63
+		}
64
+		$glotpress_mo_path = EE_LANGUAGES_SAFE_DIR . EE_Load_Textdomain::FILE_NAME_PREFIX . '4-' . $locale_mo;
65
+		if (is_readable($glotpress_mo_path)) {
66
+			load_textdomain('event_espresso', $glotpress_mo_path);
67
+			return;
68
+		}
69
+		load_plugin_textdomain('event_espresso', false, dirname(EE_PLUGIN_BASENAME) . '/languages/');
70
+	}
71
+
72
+
73
+	/**
74
+	 * The purpose of this method is to side-load the language files for EE,
75
+	 * this includes the POT file and the PO/MO files for the given WPLANG locale (if necessary).
76
+	 *
77
+	 * @return void
78
+	 * @throws EE_Error
79
+	 * @throws ReflectionException
80
+	 * @depecated 5.0.42
81
+	 */
82
+	public static function loadTranslationsForLocale()
83
+	{
84
+		$loaded_text_domains = new LoadedTextDomains();
85
+		// check if language files has already been side-loaded
86
+		if ($loaded_text_domains->hasVersion(EE_Load_Textdomain::$locale, EVENT_ESPRESSO_VERSION)) {
87
+			return;
88
+		}
89
+
90
+		// if locale is "en_US" then lets just get out, since Event Espresso core is already "en_US"
91
+		if (EE_Load_Textdomain::$locale === 'en_US') {
92
+			// but set option first else we'll forever be downloading the pot file
93
+			$loaded_text_domains->versionLoaded(EE_Load_Textdomain::$locale, EVENT_ESPRESSO_VERSION);
94
+			return;
95
+		}
96
+
97
+		/** @var Request $request */
98
+		$request = LoaderFactory::getShared(Request::class);
99
+		if ($request->isActivation()) {
100
+			// clean up old text domain tracking
101
+			$LegacyTextDomainOptions = new LegacyTextDomainOptions($loaded_text_domains);
102
+			$LegacyTextDomainOptions->convertToConsolidatedFormat();
103
+		}
104
+
105
+		[$mo_loaded, $po_loaded] = EE_Load_Textdomain::sideLoadMoPo();
106
+
107
+		// set option so the above only runs when EE updates.
108
+		$loaded_text_domains->versionLoaded(EE_Load_Textdomain::$locale, EVENT_ESPRESSO_VERSION);
109
+
110
+		if ($mo_loaded && $po_loaded) {
111
+			EE_Error::add_success(
112
+				sprintf(
113
+					esc_html__(
114
+						'Successfully downloaded the Event Espresso text domain for the "%1$s" locale.',
115
+						'event_espresso'
116
+					),
117
+					EE_Load_Textdomain::$locale
118
+				),
119
+				__FILE__,
120
+				__FUNCTION__,
121
+				__LINE__
122
+			);
123
+		}
124
+	}
125
+
126
+
127
+	/**
128
+	 * @throws ReflectionException
129
+	 * @throws EE_Error
130
+	 * @depecated 5.0.42
131
+	 */
132
+	private static function sideLoadMoPo(): array
133
+	{
134
+		// load side-loader and side-load the .POT file as this should always be included.
135
+		$side_loader_args = [
136
+			'upload_path'   => EE_PLUGIN_DIR_PATH . 'languages/',
137
+			'download_url'  => EE_Load_Textdomain::REPO_BASE_URL . '.pot',
138
+			'new_file_name' => 'event_espresso.pot',
139
+		];
140
+		EE_Registry::instance()->load_helper('Sideloader');
141
+		$side_loader = new EEH_Sideloader($side_loader_args);
142
+		// side-load the .POT file only for main site of the network, or if not running Multisite.
143
+		if (is_main_site()) {
144
+			$side_loader->sideload();
145
+		}
146
+		$repo_locale_URL = EE_Load_Textdomain::REPO_BASE_URL . '-' . EE_Load_Textdomain::$locale;
147
+		$file_name_base  = EE_Load_Textdomain::FILE_NAME_PREFIX . EE_Load_Textdomain::$locale;
148
+
149
+		// made it here so let's get the language files from the GitHub repo, first the .mo file
150
+		$side_loader->setDownloadUrl("$repo_locale_URL.mo");
151
+		$side_loader->setNewFileName("$file_name_base.mo");
152
+		$mo_loaded = $side_loader->sideload();
153
+
154
+		// now the .po file:
155
+		$side_loader->setDownloadUrl("$repo_locale_URL.po");
156
+		$side_loader->setNewFileName("$file_name_base.po");
157
+		$po_loaded = $side_loader->sideload();
158
+
159
+		return [$mo_loaded, $po_loaded];
160
+	}
161
+
162
+
163
+	/**
164
+	 * @depecated 5.0.42
165
+	 */
166
+	public static function load_textdomain()
167
+	{
168
+		EE_Load_Textdomain::loadTextdomain();
169
+	}
170 170
 
171 171
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public static function loadPluginTextdomain()
57 57
     {
58
-        $locale_mo      = EE_Load_Textdomain::$locale . '.mo';
59
-        $github_mo_path = EE_LANGUAGES_SAFE_DIR . EE_Load_Textdomain::FILE_NAME_PREFIX . $locale_mo;
58
+        $locale_mo      = EE_Load_Textdomain::$locale.'.mo';
59
+        $github_mo_path = EE_LANGUAGES_SAFE_DIR.EE_Load_Textdomain::FILE_NAME_PREFIX.$locale_mo;
60 60
         if (is_readable($github_mo_path)) {
61 61
             load_plugin_textdomain('event_espresso', false, EE_LANGUAGES_SAFE_LOC);
62 62
             return;
63 63
         }
64
-        $glotpress_mo_path = EE_LANGUAGES_SAFE_DIR . EE_Load_Textdomain::FILE_NAME_PREFIX . '4-' . $locale_mo;
64
+        $glotpress_mo_path = EE_LANGUAGES_SAFE_DIR.EE_Load_Textdomain::FILE_NAME_PREFIX.'4-'.$locale_mo;
65 65
         if (is_readable($glotpress_mo_path)) {
66 66
             load_textdomain('event_espresso', $glotpress_mo_path);
67 67
             return;
68 68
         }
69
-        load_plugin_textdomain('event_espresso', false, dirname(EE_PLUGIN_BASENAME) . '/languages/');
69
+        load_plugin_textdomain('event_espresso', false, dirname(EE_PLUGIN_BASENAME).'/languages/');
70 70
     }
71 71
 
72 72
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
     {
134 134
         // load side-loader and side-load the .POT file as this should always be included.
135 135
         $side_loader_args = [
136
-            'upload_path'   => EE_PLUGIN_DIR_PATH . 'languages/',
137
-            'download_url'  => EE_Load_Textdomain::REPO_BASE_URL . '.pot',
136
+            'upload_path'   => EE_PLUGIN_DIR_PATH.'languages/',
137
+            'download_url'  => EE_Load_Textdomain::REPO_BASE_URL.'.pot',
138 138
             'new_file_name' => 'event_espresso.pot',
139 139
         ];
140 140
         EE_Registry::instance()->load_helper('Sideloader');
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
         if (is_main_site()) {
144 144
             $side_loader->sideload();
145 145
         }
146
-        $repo_locale_URL = EE_Load_Textdomain::REPO_BASE_URL . '-' . EE_Load_Textdomain::$locale;
147
-        $file_name_base  = EE_Load_Textdomain::FILE_NAME_PREFIX . EE_Load_Textdomain::$locale;
146
+        $repo_locale_URL = EE_Load_Textdomain::REPO_BASE_URL.'-'.EE_Load_Textdomain::$locale;
147
+        $file_name_base  = EE_Load_Textdomain::FILE_NAME_PREFIX.EE_Load_Textdomain::$locale;
148 148
 
149 149
         // made it here so let's get the language files from the GitHub repo, first the .mo file
150 150
         $side_loader->setDownloadUrl("$repo_locale_URL.mo");
Please login to merge, or discard this patch.
core/services/notifications/PersistentAdminNoticeManager.php 1 patch
Indentation   +420 added lines, -420 removed lines patch added patch discarded remove patch
@@ -29,424 +29,424 @@
 block discarded – undo
29 29
  */
30 30
 class PersistentAdminNoticeManager
31 31
 {
32
-    const WP_OPTION_KEY = 'ee_pers_admin_notices';
33
-
34
-    private CapabilitiesChecker $capabilities_checker;
35
-
36
-    private RequestInterface $request;
37
-
38
-    /**
39
-     * @var Collection|PersistentAdminNotice[]|null $notice_collection
40
-     */
41
-    private ?Collection $notice_collection = null;
42
-
43
-    /**
44
-     * if AJAX is not enabled, then the return URL will be used for redirecting back to the admin page where the
45
-     * persistent admin notice was displayed, and ultimately dismissed from.
46
-     *
47
-     * @var string $return_url
48
-     */
49
-    private string $return_url;
50
-
51
-
52
-    /**
53
-     * PersistentAdminNoticeManager constructor
54
-     *
55
-     * @param CapabilitiesChecker $capabilities_checker
56
-     * @param RequestInterface    $request
57
-     * @param string              $return_url where to  redirect to after dismissing notices
58
-     */
59
-    public function __construct(
60
-        CapabilitiesChecker $capabilities_checker,
61
-        RequestInterface $request,
62
-        string $return_url = ''
63
-    ) {
64
-        $this->capabilities_checker = $capabilities_checker;
65
-        $this->request              = $request;
66
-        $this->setReturnUrl($return_url);
67
-        add_action('wp_ajax_dismiss_ee_nag_notice', [$this, 'dismissNotice']);
68
-        add_action('shutdown', [$this, 'registerAndSaveNotices'], 998);
69
-    }
70
-
71
-
72
-    public function loadAdminNotices()
73
-    {
74
-        // setup up notices at priority 9 because `EE_Admin::display_admin_notices()` runs at priority 10,
75
-        // and we want to retrieve and generate any nag notices at the last possible moment
76
-        add_action('admin_notices', [$this, 'displayNotices'], 9);
77
-        add_action('network_admin_notices', [$this, 'displayNotices'], 9);
78
-    }
79
-
80
-
81
-    /**
82
-     * @param string $return_url
83
-     */
84
-    public function setReturnUrl(string $return_url)
85
-    {
86
-        $this->return_url = $return_url;
87
-    }
88
-
89
-
90
-    /**
91
-     * @return Collection
92
-     * @throws InvalidEntityException
93
-     * @throws InvalidInterfaceException
94
-     * @throws DomainException
95
-     * @throws DuplicateCollectionIdentifierException
96
-     */
97
-    protected function getPersistentAdminNoticeCollection(): Collection
98
-    {
99
-        if (! $this->notice_collection instanceof Collection) {
100
-            $this->notice_collection = new Collection(
101
-                'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
102
-            );
103
-            $this->retrieveStoredNotices();
104
-            $this->registerNotices();
105
-        }
106
-        return $this->notice_collection;
107
-    }
108
-
109
-
110
-    /**
111
-     * generates PersistentAdminNotice objects for all non-dismissed notices saved to the db
112
-     *
113
-     * @return void
114
-     * @throws InvalidEntityException
115
-     * @throws DomainException
116
-     * @throws DuplicateCollectionIdentifierException
117
-     */
118
-    protected function retrieveStoredNotices()
119
-    {
120
-        $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, []);
121
-        if (! empty($persistent_admin_notices)) {
122
-            foreach ($persistent_admin_notices as $name => $details) {
123
-                if (is_array($details)) {
124
-                    if (
125
-                        ! isset(
126
-                            $details['message'],
127
-                            $details['capability'],
128
-                            $details['cap_context'],
129
-                            $details['dismissed']
130
-                        )
131
-                    ) {
132
-                        throw new DomainException(
133
-                            sprintf(
134
-                                esc_html__(
135
-                                    'The "%1$s" PersistentAdminNotice could not be retrieved from the database.',
136
-                                    'event_espresso'
137
-                                ),
138
-                                $name
139
-                            )
140
-                        );
141
-                    }
142
-                    $notice = new PersistentAdminNotice(
143
-                        (string) $name,
144
-                        (string) $details['message'],
145
-                        (bool) ($details['force_update'] ?? false),
146
-                        (string) $details['capability'],
147
-                        (string) $details['cap_context'],
148
-                        (bool) $details['dismissed'],
149
-                        (string) ($details['type'] ?? 'info'),
150
-                        (string) ($details['extra_css'] ?? '')
151
-                    );
152
-                    // new format for nag notices
153
-                    $this->notice_collection->add($notice, sanitize_key($name));
154
-                } else {
155
-                    try {
156
-                        // old nag notices, that we want to convert to the new format
157
-                        $this->notice_collection->add(
158
-                            new PersistentAdminNotice(
159
-                                (string) $name,
160
-                                (string) $details,
161
-                                false,
162
-                                '',
163
-                                '',
164
-                                empty($details)
165
-                            ),
166
-                            sanitize_key($name)
167
-                        );
168
-                    } catch (Exception $e) {
169
-                        EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
170
-                    }
171
-                }
172
-                // each notice will self register when the action hook in registerNotices is triggered
173
-            }
174
-        }
175
-    }
176
-
177
-
178
-    /**
179
-     * exposes the Persistent Admin Notice Collection via an action
180
-     * so that PersistentAdminNotice objects can be added and/or removed
181
-     * without compromising the actual collection like a filter would
182
-     */
183
-    protected function registerNotices()
184
-    {
185
-        do_action(
186
-            'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
187
-            $this->notice_collection
188
-        );
189
-    }
190
-
191
-
192
-    /**
193
-     * @throws DomainException
194
-     * @throws InvalidClassException
195
-     * @throws InvalidInterfaceException
196
-     * @throws InvalidEntityException
197
-     * @throws DuplicateCollectionIdentifierException
198
-     */
199
-    public function displayNotices()
200
-    {
201
-        $this->notice_collection = $this->getPersistentAdminNoticeCollection();
202
-        if ($this->notice_collection->hasObjects()) {
203
-            $enqueue_assets = false;
204
-            // and display notices
205
-            foreach ($this->notice_collection as $persistent_admin_notice) {
206
-                /** @var PersistentAdminNotice $persistent_admin_notice */
207
-                // don't display notices that have already been dismissed
208
-                if ($persistent_admin_notice->getDismissed()) {
209
-                    continue;
210
-                }
211
-                try {
212
-                    $this->capabilities_checker->processCapCheck(
213
-                        $persistent_admin_notice->getCapCheck()
214
-                    );
215
-                } catch (InsufficientPermissionsException $e) {
216
-                    // user does not have required cap, so skip to next notice
217
-                    // and just eat the exception - nom nom nom nom
218
-                    continue;
219
-                }
220
-                if ($persistent_admin_notice->getMessage() === '') {
221
-                    continue;
222
-                }
223
-                $this->displayPersistentAdminNotice($persistent_admin_notice);
224
-                $enqueue_assets = true;
225
-            }
226
-            if ($enqueue_assets) {
227
-                $this->enqueueAssets();
228
-            }
229
-        }
230
-    }
231
-
232
-
233
-    /**
234
-     * does what it's named
235
-     *
236
-     * @return void
237
-     */
238
-    public function enqueueAssets()
239
-    {
240
-        wp_register_script(
241
-            'espresso_core',
242
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
243
-            ['jquery'],
244
-            EVENT_ESPRESSO_VERSION,
245
-            true
246
-        );
247
-        wp_register_script(
248
-            'ee_error_js',
249
-            EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
250
-            ['espresso_core'],
251
-            EVENT_ESPRESSO_VERSION,
252
-            true
253
-        );
254
-        wp_localize_script(
255
-            'ee_error_js',
256
-            'ee_dismiss',
257
-            [
258
-                'return_url'    => urlencode($this->return_url),
259
-                'ajax_url'      => WP_AJAX_URL,
260
-                'unknown_error' => wp_strip_all_tags(
261
-                    __(
262
-                        'An unknown error has occurred on the server while attempting to dismiss this notice.',
263
-                        'event_espresso'
264
-                    )
265
-                ),
266
-            ]
267
-        );
268
-        wp_enqueue_script('ee_error_js');
269
-    }
270
-
271
-
272
-    /**
273
-     * displayPersistentAdminNoticeHtml
274
-     *
275
-     * @param PersistentAdminNotice $persistent_admin_notice
276
-     */
277
-    protected function displayPersistentAdminNotice(PersistentAdminNotice $persistent_admin_notice)
278
-    {
279
-        // used in template
280
-        $persistent_admin_notice_name    = $persistent_admin_notice->getName();
281
-        $persistent_admin_notice_message = $persistent_admin_notice->getMessage();
282
-        $persistent_admin_notice_type    = $persistent_admin_notice->getType();
283
-        $persistent_admin_notice_css     = $persistent_admin_notice->extraCss();
284
-        $is_dismissible                  = $persistent_admin_notice->getForceUpdate() !== true;
285
-        require EE_TEMPLATES . '/notifications/persistent_admin_notice.template.php';
286
-    }
287
-
288
-
289
-    /**
290
-     * dismissNotice
291
-     *
292
-     * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
293
-     * @param bool   $purge    if true, then delete it from the db
294
-     * @param bool   $return   forget all of this AJAX or redirect nonsense, and just return
295
-     * @return void
296
-     * @throws InvalidEntityException
297
-     * @throws InvalidInterfaceException
298
-     * @throws DomainException
299
-     * @throws InvalidArgumentException
300
-     * @throws InvalidArgumentException
301
-     * @throws InvalidArgumentException
302
-     * @throws InvalidArgumentException
303
-     * @throws DuplicateCollectionIdentifierException
304
-     */
305
-    public function dismissNotice(string $pan_name = '', bool $purge = false, bool $return = false)
306
-    {
307
-        $pan_name                = $this->request->getRequestParam('ee_nag_notice', $pan_name);
308
-        $this->notice_collection = $this->getPersistentAdminNoticeCollection();
309
-        if (! empty($pan_name) && $this->notice_collection->has($pan_name)) {
310
-            /** @var PersistentAdminNotice $persistent_admin_notice */
311
-            $persistent_admin_notice = $this->notice_collection->get($pan_name);
312
-            try {
313
-                $this->capabilities_checker->processCapCheck(
314
-                    $persistent_admin_notice->getCapCheck()
315
-                );
316
-            } catch (InsufficientPermissionsException $e) {
317
-                // user does not have required cap, so just eat the exception - nom nom nom nom
318
-                return;
319
-            }
320
-            $persistent_admin_notice->setDismissed(true);
321
-            $persistent_admin_notice->setPurge($purge);
322
-            $this->saveNotices();
323
-        }
324
-        if ($return) {
325
-            return;
326
-        }
327
-        if ($this->request->isAjax()) {
328
-            // grab any notices and concatenate into string
329
-            echo wp_json_encode(
330
-                [
331
-                    'errors' => implode('<br />', EE_Error::get_notices(false)),
332
-                ]
333
-            );
334
-            exit();
335
-        }
336
-        // save errors to a transient to be displayed on next request (after redirect)
337
-        EE_Error::get_notices(false, true);
338
-        wp_safe_redirect(
339
-            urldecode(
340
-                $this->request->getRequestParam('return_url', '')
341
-            )
342
-        );
343
-    }
344
-
345
-
346
-    /**
347
-     * saveNotices
348
-     *
349
-     * @throws DomainException
350
-     * @throws InvalidInterfaceException
351
-     * @throws InvalidEntityException
352
-     * @throws DuplicateCollectionIdentifierException
353
-     */
354
-    public function saveNotices()
355
-    {
356
-        $this->notice_collection = $this->getPersistentAdminNoticeCollection();
357
-        $new_notices_array = [];
358
-        if ($this->notice_collection->hasObjects()) {
359
-            $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, []);
360
-            // maybe initialize persistent_admin_notices
361
-            if (empty($persistent_admin_notices)) {
362
-                add_option(PersistentAdminNoticeManager::WP_OPTION_KEY, [], '', 'no');
363
-            }
364
-            foreach ($this->notice_collection as $persistent_admin_notice) {
365
-                // remove this notice ?
366
-                if ($persistent_admin_notice->getPurge()) {
367
-                    continue;
368
-                }
369
-                /** @var PersistentAdminNotice $persistent_admin_notice */
370
-                $new_notices_array[ $persistent_admin_notice->getName() ] = [
371
-                    'message'      => $persistent_admin_notice->getMessage(),
372
-                    'capability'   => $persistent_admin_notice->getCapability(),
373
-                    'cap_context'  => $persistent_admin_notice->getCapContext(),
374
-                    'dismissed'    => $persistent_admin_notice->getDismissed(),
375
-                    'force_update' => $persistent_admin_notice->getForceUpdate(),
376
-                    'type'         => $persistent_admin_notice->getType(),
377
-                    'extra_css'    => $persistent_admin_notice->extraCss(),
378
-                ];
379
-            }
380
-        }
381
-        update_option(PersistentAdminNoticeManager::WP_OPTION_KEY, $new_notices_array);
382
-    }
383
-
384
-
385
-    /**
386
-     * @throws DomainException
387
-     * @throws InvalidEntityException
388
-     * @throws InvalidInterfaceException
389
-     * @throws DuplicateCollectionIdentifierException
390
-     */
391
-    public function registerAndSaveNotices()
392
-    {
393
-        $this->getPersistentAdminNoticeCollection();
394
-        $this->registerNotices();
395
-        $this->saveNotices();
396
-        add_filter(
397
-            'PersistentAdminNoticeManager__registerAndSaveNotices__complete',
398
-            '__return_true'
399
-        );
400
-    }
401
-
402
-
403
-    /**
404
-     * @throws DomainException
405
-     * @throws InvalidEntityException
406
-     * @throws InvalidInterfaceException
407
-     * @throws InvalidArgumentException
408
-     * @throws DuplicateCollectionIdentifierException
409
-     */
410
-    public static function loadRegisterAndSaveNotices()
411
-    {
412
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
413
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
414
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
415
-        );
416
-        // if shutdown has already run, then call registerAndSaveNotices() manually
417
-        if (did_action('shutdown')) {
418
-            $persistent_admin_notice_manager->registerAndSaveNotices();
419
-        }
420
-    }
421
-
422
-
423
-    public static function hasPersistentAdminNotice(string $notice_name): bool
424
-    {
425
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
426
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(PersistentAdminNoticeManager::class);
427
-        $persistent_admin_notice_manager->getPersistentAdminNoticeCollection();
428
-        return $persistent_admin_notice_manager->notice_collection->has(sanitize_key($notice_name));
429
-    }
430
-
431
-
432
-    public static function dismissPersistentAdminNotice(string $notice_name)
433
-    {
434
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
435
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(PersistentAdminNoticeManager::class);
436
-        $persistent_admin_notice_manager->dismissNotice(sanitize_key($notice_name), true, true);
437
-    }
438
-
439
-
440
-    public static function deletePersistentAdminNotice(string $notice_name)
441
-    {
442
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
443
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(PersistentAdminNoticeManager::class);
444
-        $persistent_admin_notice_manager->getPersistentAdminNoticeCollection();
445
-        $notice = $persistent_admin_notice_manager->notice_collection->get(sanitize_key($notice_name));
446
-        if ($notice) {
447
-            $notice->setPurge(true);
448
-            $persistent_admin_notice_manager->notice_collection->remove($notice);
449
-            $persistent_admin_notice_manager->saveNotices();
450
-        }
451
-    }
32
+	const WP_OPTION_KEY = 'ee_pers_admin_notices';
33
+
34
+	private CapabilitiesChecker $capabilities_checker;
35
+
36
+	private RequestInterface $request;
37
+
38
+	/**
39
+	 * @var Collection|PersistentAdminNotice[]|null $notice_collection
40
+	 */
41
+	private ?Collection $notice_collection = null;
42
+
43
+	/**
44
+	 * if AJAX is not enabled, then the return URL will be used for redirecting back to the admin page where the
45
+	 * persistent admin notice was displayed, and ultimately dismissed from.
46
+	 *
47
+	 * @var string $return_url
48
+	 */
49
+	private string $return_url;
50
+
51
+
52
+	/**
53
+	 * PersistentAdminNoticeManager constructor
54
+	 *
55
+	 * @param CapabilitiesChecker $capabilities_checker
56
+	 * @param RequestInterface    $request
57
+	 * @param string              $return_url where to  redirect to after dismissing notices
58
+	 */
59
+	public function __construct(
60
+		CapabilitiesChecker $capabilities_checker,
61
+		RequestInterface $request,
62
+		string $return_url = ''
63
+	) {
64
+		$this->capabilities_checker = $capabilities_checker;
65
+		$this->request              = $request;
66
+		$this->setReturnUrl($return_url);
67
+		add_action('wp_ajax_dismiss_ee_nag_notice', [$this, 'dismissNotice']);
68
+		add_action('shutdown', [$this, 'registerAndSaveNotices'], 998);
69
+	}
70
+
71
+
72
+	public function loadAdminNotices()
73
+	{
74
+		// setup up notices at priority 9 because `EE_Admin::display_admin_notices()` runs at priority 10,
75
+		// and we want to retrieve and generate any nag notices at the last possible moment
76
+		add_action('admin_notices', [$this, 'displayNotices'], 9);
77
+		add_action('network_admin_notices', [$this, 'displayNotices'], 9);
78
+	}
79
+
80
+
81
+	/**
82
+	 * @param string $return_url
83
+	 */
84
+	public function setReturnUrl(string $return_url)
85
+	{
86
+		$this->return_url = $return_url;
87
+	}
88
+
89
+
90
+	/**
91
+	 * @return Collection
92
+	 * @throws InvalidEntityException
93
+	 * @throws InvalidInterfaceException
94
+	 * @throws DomainException
95
+	 * @throws DuplicateCollectionIdentifierException
96
+	 */
97
+	protected function getPersistentAdminNoticeCollection(): Collection
98
+	{
99
+		if (! $this->notice_collection instanceof Collection) {
100
+			$this->notice_collection = new Collection(
101
+				'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
102
+			);
103
+			$this->retrieveStoredNotices();
104
+			$this->registerNotices();
105
+		}
106
+		return $this->notice_collection;
107
+	}
108
+
109
+
110
+	/**
111
+	 * generates PersistentAdminNotice objects for all non-dismissed notices saved to the db
112
+	 *
113
+	 * @return void
114
+	 * @throws InvalidEntityException
115
+	 * @throws DomainException
116
+	 * @throws DuplicateCollectionIdentifierException
117
+	 */
118
+	protected function retrieveStoredNotices()
119
+	{
120
+		$persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, []);
121
+		if (! empty($persistent_admin_notices)) {
122
+			foreach ($persistent_admin_notices as $name => $details) {
123
+				if (is_array($details)) {
124
+					if (
125
+						! isset(
126
+							$details['message'],
127
+							$details['capability'],
128
+							$details['cap_context'],
129
+							$details['dismissed']
130
+						)
131
+					) {
132
+						throw new DomainException(
133
+							sprintf(
134
+								esc_html__(
135
+									'The "%1$s" PersistentAdminNotice could not be retrieved from the database.',
136
+									'event_espresso'
137
+								),
138
+								$name
139
+							)
140
+						);
141
+					}
142
+					$notice = new PersistentAdminNotice(
143
+						(string) $name,
144
+						(string) $details['message'],
145
+						(bool) ($details['force_update'] ?? false),
146
+						(string) $details['capability'],
147
+						(string) $details['cap_context'],
148
+						(bool) $details['dismissed'],
149
+						(string) ($details['type'] ?? 'info'),
150
+						(string) ($details['extra_css'] ?? '')
151
+					);
152
+					// new format for nag notices
153
+					$this->notice_collection->add($notice, sanitize_key($name));
154
+				} else {
155
+					try {
156
+						// old nag notices, that we want to convert to the new format
157
+						$this->notice_collection->add(
158
+							new PersistentAdminNotice(
159
+								(string) $name,
160
+								(string) $details,
161
+								false,
162
+								'',
163
+								'',
164
+								empty($details)
165
+							),
166
+							sanitize_key($name)
167
+						);
168
+					} catch (Exception $e) {
169
+						EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
170
+					}
171
+				}
172
+				// each notice will self register when the action hook in registerNotices is triggered
173
+			}
174
+		}
175
+	}
176
+
177
+
178
+	/**
179
+	 * exposes the Persistent Admin Notice Collection via an action
180
+	 * so that PersistentAdminNotice objects can be added and/or removed
181
+	 * without compromising the actual collection like a filter would
182
+	 */
183
+	protected function registerNotices()
184
+	{
185
+		do_action(
186
+			'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
187
+			$this->notice_collection
188
+		);
189
+	}
190
+
191
+
192
+	/**
193
+	 * @throws DomainException
194
+	 * @throws InvalidClassException
195
+	 * @throws InvalidInterfaceException
196
+	 * @throws InvalidEntityException
197
+	 * @throws DuplicateCollectionIdentifierException
198
+	 */
199
+	public function displayNotices()
200
+	{
201
+		$this->notice_collection = $this->getPersistentAdminNoticeCollection();
202
+		if ($this->notice_collection->hasObjects()) {
203
+			$enqueue_assets = false;
204
+			// and display notices
205
+			foreach ($this->notice_collection as $persistent_admin_notice) {
206
+				/** @var PersistentAdminNotice $persistent_admin_notice */
207
+				// don't display notices that have already been dismissed
208
+				if ($persistent_admin_notice->getDismissed()) {
209
+					continue;
210
+				}
211
+				try {
212
+					$this->capabilities_checker->processCapCheck(
213
+						$persistent_admin_notice->getCapCheck()
214
+					);
215
+				} catch (InsufficientPermissionsException $e) {
216
+					// user does not have required cap, so skip to next notice
217
+					// and just eat the exception - nom nom nom nom
218
+					continue;
219
+				}
220
+				if ($persistent_admin_notice->getMessage() === '') {
221
+					continue;
222
+				}
223
+				$this->displayPersistentAdminNotice($persistent_admin_notice);
224
+				$enqueue_assets = true;
225
+			}
226
+			if ($enqueue_assets) {
227
+				$this->enqueueAssets();
228
+			}
229
+		}
230
+	}
231
+
232
+
233
+	/**
234
+	 * does what it's named
235
+	 *
236
+	 * @return void
237
+	 */
238
+	public function enqueueAssets()
239
+	{
240
+		wp_register_script(
241
+			'espresso_core',
242
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
243
+			['jquery'],
244
+			EVENT_ESPRESSO_VERSION,
245
+			true
246
+		);
247
+		wp_register_script(
248
+			'ee_error_js',
249
+			EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
250
+			['espresso_core'],
251
+			EVENT_ESPRESSO_VERSION,
252
+			true
253
+		);
254
+		wp_localize_script(
255
+			'ee_error_js',
256
+			'ee_dismiss',
257
+			[
258
+				'return_url'    => urlencode($this->return_url),
259
+				'ajax_url'      => WP_AJAX_URL,
260
+				'unknown_error' => wp_strip_all_tags(
261
+					__(
262
+						'An unknown error has occurred on the server while attempting to dismiss this notice.',
263
+						'event_espresso'
264
+					)
265
+				),
266
+			]
267
+		);
268
+		wp_enqueue_script('ee_error_js');
269
+	}
270
+
271
+
272
+	/**
273
+	 * displayPersistentAdminNoticeHtml
274
+	 *
275
+	 * @param PersistentAdminNotice $persistent_admin_notice
276
+	 */
277
+	protected function displayPersistentAdminNotice(PersistentAdminNotice $persistent_admin_notice)
278
+	{
279
+		// used in template
280
+		$persistent_admin_notice_name    = $persistent_admin_notice->getName();
281
+		$persistent_admin_notice_message = $persistent_admin_notice->getMessage();
282
+		$persistent_admin_notice_type    = $persistent_admin_notice->getType();
283
+		$persistent_admin_notice_css     = $persistent_admin_notice->extraCss();
284
+		$is_dismissible                  = $persistent_admin_notice->getForceUpdate() !== true;
285
+		require EE_TEMPLATES . '/notifications/persistent_admin_notice.template.php';
286
+	}
287
+
288
+
289
+	/**
290
+	 * dismissNotice
291
+	 *
292
+	 * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
293
+	 * @param bool   $purge    if true, then delete it from the db
294
+	 * @param bool   $return   forget all of this AJAX or redirect nonsense, and just return
295
+	 * @return void
296
+	 * @throws InvalidEntityException
297
+	 * @throws InvalidInterfaceException
298
+	 * @throws DomainException
299
+	 * @throws InvalidArgumentException
300
+	 * @throws InvalidArgumentException
301
+	 * @throws InvalidArgumentException
302
+	 * @throws InvalidArgumentException
303
+	 * @throws DuplicateCollectionIdentifierException
304
+	 */
305
+	public function dismissNotice(string $pan_name = '', bool $purge = false, bool $return = false)
306
+	{
307
+		$pan_name                = $this->request->getRequestParam('ee_nag_notice', $pan_name);
308
+		$this->notice_collection = $this->getPersistentAdminNoticeCollection();
309
+		if (! empty($pan_name) && $this->notice_collection->has($pan_name)) {
310
+			/** @var PersistentAdminNotice $persistent_admin_notice */
311
+			$persistent_admin_notice = $this->notice_collection->get($pan_name);
312
+			try {
313
+				$this->capabilities_checker->processCapCheck(
314
+					$persistent_admin_notice->getCapCheck()
315
+				);
316
+			} catch (InsufficientPermissionsException $e) {
317
+				// user does not have required cap, so just eat the exception - nom nom nom nom
318
+				return;
319
+			}
320
+			$persistent_admin_notice->setDismissed(true);
321
+			$persistent_admin_notice->setPurge($purge);
322
+			$this->saveNotices();
323
+		}
324
+		if ($return) {
325
+			return;
326
+		}
327
+		if ($this->request->isAjax()) {
328
+			// grab any notices and concatenate into string
329
+			echo wp_json_encode(
330
+				[
331
+					'errors' => implode('<br />', EE_Error::get_notices(false)),
332
+				]
333
+			);
334
+			exit();
335
+		}
336
+		// save errors to a transient to be displayed on next request (after redirect)
337
+		EE_Error::get_notices(false, true);
338
+		wp_safe_redirect(
339
+			urldecode(
340
+				$this->request->getRequestParam('return_url', '')
341
+			)
342
+		);
343
+	}
344
+
345
+
346
+	/**
347
+	 * saveNotices
348
+	 *
349
+	 * @throws DomainException
350
+	 * @throws InvalidInterfaceException
351
+	 * @throws InvalidEntityException
352
+	 * @throws DuplicateCollectionIdentifierException
353
+	 */
354
+	public function saveNotices()
355
+	{
356
+		$this->notice_collection = $this->getPersistentAdminNoticeCollection();
357
+		$new_notices_array = [];
358
+		if ($this->notice_collection->hasObjects()) {
359
+			$persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, []);
360
+			// maybe initialize persistent_admin_notices
361
+			if (empty($persistent_admin_notices)) {
362
+				add_option(PersistentAdminNoticeManager::WP_OPTION_KEY, [], '', 'no');
363
+			}
364
+			foreach ($this->notice_collection as $persistent_admin_notice) {
365
+				// remove this notice ?
366
+				if ($persistent_admin_notice->getPurge()) {
367
+					continue;
368
+				}
369
+				/** @var PersistentAdminNotice $persistent_admin_notice */
370
+				$new_notices_array[ $persistent_admin_notice->getName() ] = [
371
+					'message'      => $persistent_admin_notice->getMessage(),
372
+					'capability'   => $persistent_admin_notice->getCapability(),
373
+					'cap_context'  => $persistent_admin_notice->getCapContext(),
374
+					'dismissed'    => $persistent_admin_notice->getDismissed(),
375
+					'force_update' => $persistent_admin_notice->getForceUpdate(),
376
+					'type'         => $persistent_admin_notice->getType(),
377
+					'extra_css'    => $persistent_admin_notice->extraCss(),
378
+				];
379
+			}
380
+		}
381
+		update_option(PersistentAdminNoticeManager::WP_OPTION_KEY, $new_notices_array);
382
+	}
383
+
384
+
385
+	/**
386
+	 * @throws DomainException
387
+	 * @throws InvalidEntityException
388
+	 * @throws InvalidInterfaceException
389
+	 * @throws DuplicateCollectionIdentifierException
390
+	 */
391
+	public function registerAndSaveNotices()
392
+	{
393
+		$this->getPersistentAdminNoticeCollection();
394
+		$this->registerNotices();
395
+		$this->saveNotices();
396
+		add_filter(
397
+			'PersistentAdminNoticeManager__registerAndSaveNotices__complete',
398
+			'__return_true'
399
+		);
400
+	}
401
+
402
+
403
+	/**
404
+	 * @throws DomainException
405
+	 * @throws InvalidEntityException
406
+	 * @throws InvalidInterfaceException
407
+	 * @throws InvalidArgumentException
408
+	 * @throws DuplicateCollectionIdentifierException
409
+	 */
410
+	public static function loadRegisterAndSaveNotices()
411
+	{
412
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
413
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
414
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
415
+		);
416
+		// if shutdown has already run, then call registerAndSaveNotices() manually
417
+		if (did_action('shutdown')) {
418
+			$persistent_admin_notice_manager->registerAndSaveNotices();
419
+		}
420
+	}
421
+
422
+
423
+	public static function hasPersistentAdminNotice(string $notice_name): bool
424
+	{
425
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
426
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(PersistentAdminNoticeManager::class);
427
+		$persistent_admin_notice_manager->getPersistentAdminNoticeCollection();
428
+		return $persistent_admin_notice_manager->notice_collection->has(sanitize_key($notice_name));
429
+	}
430
+
431
+
432
+	public static function dismissPersistentAdminNotice(string $notice_name)
433
+	{
434
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
435
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(PersistentAdminNoticeManager::class);
436
+		$persistent_admin_notice_manager->dismissNotice(sanitize_key($notice_name), true, true);
437
+	}
438
+
439
+
440
+	public static function deletePersistentAdminNotice(string $notice_name)
441
+	{
442
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
443
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(PersistentAdminNoticeManager::class);
444
+		$persistent_admin_notice_manager->getPersistentAdminNoticeCollection();
445
+		$notice = $persistent_admin_notice_manager->notice_collection->get(sanitize_key($notice_name));
446
+		if ($notice) {
447
+			$notice->setPurge(true);
448
+			$persistent_admin_notice_manager->notice_collection->remove($notice);
449
+			$persistent_admin_notice_manager->saveNotices();
450
+		}
451
+	}
452 452
 }
Please login to merge, or discard this patch.
core/services/deprecated/DeprecationManager.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@
 block discarded – undo
10 10
  */
11 11
 class DeprecationManager
12 12
 {
13
-    /**
14
-     * Load Deprecations
15
-     *
16
-     * @return void
17
-     */
18
-    public static function loadDeprecations(): void
19
-    {
20
-        $files = glob(EE_CORE . 'domain/deprecated/*.php');
21
-        foreach ($files as $filename) {
22
-            include $filename;
23
-        }
24
-    }
13
+	/**
14
+	 * Load Deprecations
15
+	 *
16
+	 * @return void
17
+	 */
18
+	public static function loadDeprecations(): void
19
+	{
20
+		$files = glob(EE_CORE . 'domain/deprecated/*.php');
21
+		foreach ($files as $filename) {
22
+			include $filename;
23
+		}
24
+	}
25 25
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
      */
18 18
     public static function loadDeprecations(): void
19 19
     {
20
-        $files = glob(EE_CORE . 'domain/deprecated/*.php');
20
+        $files = glob(EE_CORE.'domain/deprecated/*.php');
21 21
         foreach ($files as $filename) {
22 22
             include $filename;
23 23
         }
Please login to merge, or discard this patch.
core/services/request/middleware/SkipRequests.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,23 +15,23 @@
 block discarded – undo
15 15
  */
16 16
 class SkipRequests extends Middleware
17 17
 {
18
-    /**
19
-     * converts a Request to a Response
20
-     *
21
-     * @param RequestInterface  $request
22
-     * @param ResponseInterface $response
23
-     * @return ResponseInterface
24
-     */
25
-    public function handleRequest(RequestInterface $request, ResponseInterface $response): ResponseInterface
26
-    {
27
-        $this->request  = $request;
28
-        $this->response = $response;
18
+	/**
19
+	 * converts a Request to a Response
20
+	 *
21
+	 * @param RequestInterface  $request
22
+	 * @param ResponseInterface $response
23
+	 * @return ResponseInterface
24
+	 */
25
+	public function handleRequest(RequestInterface $request, ResponseInterface $response): ResponseInterface
26
+	{
27
+		$this->request  = $request;
28
+		$this->response = $response;
29 29
 
30
-        // don't load EE for favicon requests
31
-        if ($this->request->getServerParam('REQUEST_URI') === '/favicon.ico') {
32
-            $this->response->terminateRequest();
33
-        }
34
-        $this->response = $this->processRequestStack($this->request, $this->response);
35
-        return $this->response;
36
-    }
30
+		// don't load EE for favicon requests
31
+		if ($this->request->getServerParam('REQUEST_URI') === '/favicon.ico') {
32
+			$this->response->terminateRequest();
33
+		}
34
+		$this->response = $this->processRequestStack($this->request, $this->response);
35
+		return $this->response;
36
+	}
37 37
 }
Please login to merge, or discard this patch.
core/services/request/DataType.php 2 patches
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -15,147 +15,147 @@
 block discarded – undo
15 15
  */
16 16
 class DataType
17 17
 {
18
-    const ARRAY   = 'array';
19
-
20
-    const BOOL    = 'bool';
21
-
22
-    const BOOLEAN = 'bool';
23
-
24
-    const DOUBLE  = 'float';
25
-
26
-    const FLOAT   = 'float';
27
-
28
-    const EDITOR  = 'editor';
29
-
30
-    const EMAIL   = 'email';
31
-
32
-    const FQCN    = 'fqcn';
33
-
34
-    const HTML    = 'html';
35
-
36
-    const INT     = 'int';
37
-
38
-    const INTEGER = 'int';
39
-
40
-    const KEY     = 'key';
41
-
42
-    const OBJECT  = 'object';
43
-
44
-    const NULL    = 'null';
45
-
46
-    const TITLE   = 'title';
47
-
48
-    const URL     = 'url';
49
-
50
-    const STRING  = 'string';
51
-
52
-
53
-    private static array $valid_types = [
54
-        DataType::ARRAY,
55
-        DataType::BOOL,
56
-        DataType::BOOLEAN,
57
-        DataType::DOUBLE,
58
-        DataType::FLOAT,
59
-        DataType::EDITOR,
60
-        DataType::EMAIL,
61
-        DataType::FQCN,
62
-        DataType::HTML,
63
-        DataType::INT,
64
-        DataType::INTEGER,
65
-        DataType::KEY,
66
-        DataType::OBJECT,
67
-        DataType::NULL,
68
-        DataType::TITLE,
69
-        DataType::URL,
70
-        DataType::STRING,
71
-    ];
72
-
73
-
74
-    /**
75
-     * @param string $data_type
76
-     * @param bool   $throw_exception
77
-     * @return bool
78
-     * @throws InvalidArgumentException
79
-     * @since 5.0.42
80
-     */
81
-    public static function isValidDataType(string $data_type, bool $throw_exception = false): bool
82
-    {
83
-        if (in_array($data_type, DataType::$valid_types, true)) {
84
-            return true;
85
-        }
86
-        if (! $throw_exception) {
87
-            return false;
88
-        }
89
-        throw new InvalidArgumentException(
90
-            sprintf(
91
-                esc_html__(
92
-                    'The incoming argument (%1$s) must be one of the allowable types: %2$s',
93
-                    'event_espresso'
94
-                ),
95
-                $data_type,
96
-                implode(',', DataType::$valid_types)
97
-            )
98
-        );
99
-    }
100
-
101
-
102
-    /**
103
-     * @param mixed  $param
104
-     * @param string $type
105
-     * @return mixed
106
-     */
107
-    public static function setDataType($param, string $type)
108
-    {
109
-        switch ($type) {
110
-            case DataType::NULL:
111
-                return null;
112
-            case DataType::OBJECT:
113
-                return $param;
114
-            case DataType::EDITOR:
115
-            case DataType::EMAIL:
116
-            case DataType::FQCN:
117
-            case DataType::HTML:
118
-            case DataType::KEY:
119
-            case DataType::STRING:
120
-            case DataType::TITLE:
121
-            case DataType::URL:
122
-                settype($param, DataType::STRING);
123
-                break;
124
-            default:
125
-                settype($param, $type);
126
-        }
127
-        return $param;
128
-    }
129
-
130
-
131
-    public static function convertModelFieldSchemaType($schema_type): ?string
132
-    {
133
-        if (is_array($schema_type)) {
134
-            foreach ($schema_type as $type) {
135
-                $data_type = DataType::convertModelFieldSchemaType($type);
136
-                if ($data_type) {
137
-                    return $data_type;
138
-                }
139
-            }
140
-            $schema_type = reset($schema_type);
141
-        }
142
-        switch ($schema_type) {
143
-            case 'array':
144
-                return DataType::ARRAY;
145
-            case 'boolean':
146
-                return DataType::BOOL;
147
-            case 'integer':
148
-                return DataType::INT;
149
-            case 'null':
150
-                return DataType::NULL;
151
-            case 'number':
152
-                return DataType::FLOAT;
153
-            case 'object':
154
-                return DataType::OBJECT;
155
-            case 'string':
156
-                return DataType::STRING;
157
-            default:
158
-                return null;
159
-        }
160
-    }
18
+	const ARRAY   = 'array';
19
+
20
+	const BOOL    = 'bool';
21
+
22
+	const BOOLEAN = 'bool';
23
+
24
+	const DOUBLE  = 'float';
25
+
26
+	const FLOAT   = 'float';
27
+
28
+	const EDITOR  = 'editor';
29
+
30
+	const EMAIL   = 'email';
31
+
32
+	const FQCN    = 'fqcn';
33
+
34
+	const HTML    = 'html';
35
+
36
+	const INT     = 'int';
37
+
38
+	const INTEGER = 'int';
39
+
40
+	const KEY     = 'key';
41
+
42
+	const OBJECT  = 'object';
43
+
44
+	const NULL    = 'null';
45
+
46
+	const TITLE   = 'title';
47
+
48
+	const URL     = 'url';
49
+
50
+	const STRING  = 'string';
51
+
52
+
53
+	private static array $valid_types = [
54
+		DataType::ARRAY,
55
+		DataType::BOOL,
56
+		DataType::BOOLEAN,
57
+		DataType::DOUBLE,
58
+		DataType::FLOAT,
59
+		DataType::EDITOR,
60
+		DataType::EMAIL,
61
+		DataType::FQCN,
62
+		DataType::HTML,
63
+		DataType::INT,
64
+		DataType::INTEGER,
65
+		DataType::KEY,
66
+		DataType::OBJECT,
67
+		DataType::NULL,
68
+		DataType::TITLE,
69
+		DataType::URL,
70
+		DataType::STRING,
71
+	];
72
+
73
+
74
+	/**
75
+	 * @param string $data_type
76
+	 * @param bool   $throw_exception
77
+	 * @return bool
78
+	 * @throws InvalidArgumentException
79
+	 * @since 5.0.42
80
+	 */
81
+	public static function isValidDataType(string $data_type, bool $throw_exception = false): bool
82
+	{
83
+		if (in_array($data_type, DataType::$valid_types, true)) {
84
+			return true;
85
+		}
86
+		if (! $throw_exception) {
87
+			return false;
88
+		}
89
+		throw new InvalidArgumentException(
90
+			sprintf(
91
+				esc_html__(
92
+					'The incoming argument (%1$s) must be one of the allowable types: %2$s',
93
+					'event_espresso'
94
+				),
95
+				$data_type,
96
+				implode(',', DataType::$valid_types)
97
+			)
98
+		);
99
+	}
100
+
101
+
102
+	/**
103
+	 * @param mixed  $param
104
+	 * @param string $type
105
+	 * @return mixed
106
+	 */
107
+	public static function setDataType($param, string $type)
108
+	{
109
+		switch ($type) {
110
+			case DataType::NULL:
111
+				return null;
112
+			case DataType::OBJECT:
113
+				return $param;
114
+			case DataType::EDITOR:
115
+			case DataType::EMAIL:
116
+			case DataType::FQCN:
117
+			case DataType::HTML:
118
+			case DataType::KEY:
119
+			case DataType::STRING:
120
+			case DataType::TITLE:
121
+			case DataType::URL:
122
+				settype($param, DataType::STRING);
123
+				break;
124
+			default:
125
+				settype($param, $type);
126
+		}
127
+		return $param;
128
+	}
129
+
130
+
131
+	public static function convertModelFieldSchemaType($schema_type): ?string
132
+	{
133
+		if (is_array($schema_type)) {
134
+			foreach ($schema_type as $type) {
135
+				$data_type = DataType::convertModelFieldSchemaType($type);
136
+				if ($data_type) {
137
+					return $data_type;
138
+				}
139
+			}
140
+			$schema_type = reset($schema_type);
141
+		}
142
+		switch ($schema_type) {
143
+			case 'array':
144
+				return DataType::ARRAY;
145
+			case 'boolean':
146
+				return DataType::BOOL;
147
+			case 'integer':
148
+				return DataType::INT;
149
+			case 'null':
150
+				return DataType::NULL;
151
+			case 'number':
152
+				return DataType::FLOAT;
153
+			case 'object':
154
+				return DataType::OBJECT;
155
+			case 'string':
156
+				return DataType::STRING;
157
+			default:
158
+				return null;
159
+		}
160
+	}
161 161
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
         if (in_array($data_type, DataType::$valid_types, true)) {
84 84
             return true;
85 85
         }
86
-        if (! $throw_exception) {
86
+        if ( ! $throw_exception) {
87 87
             return false;
88 88
         }
89 89
         throw new InvalidArgumentException(
Please login to merge, or discard this patch.
core/services/request/RequestStackCoreApp.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -30,92 +30,92 @@
 block discarded – undo
30 30
  */
31 31
 class RequestStackCoreApp implements RequestDecoratorInterface, RequestStackCoreAppInterface
32 32
 {
33
-    protected RequestInterface $request;
33
+	protected RequestInterface $request;
34 34
 
35
-    protected ResponseInterface $response;
35
+	protected ResponseInterface $response;
36 36
 
37 37
 
38
-    /**
39
-     * handle
40
-     * sets hooks for running rest of system
41
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
42
-     * starting EE Addons from any other point may lead to problems
43
-     *
44
-     * @param RequestInterface  $request
45
-     * @param ResponseInterface $response
46
-     * @return ResponseInterface
47
-     * @throws InvalidClassException
48
-     * @throws EE_Error
49
-     * @throws InvalidDataTypeException
50
-     * @throws InvalidInterfaceException
51
-     * @throws InvalidArgumentException
52
-     */
53
-    public function handleRequest(RequestInterface $request, ResponseInterface $response): ResponseInterface
54
-    {
55
-        $this->request  = $request;
56
-        $this->response = $response;
57
-        espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php');
58
-        DeprecationManager::loadDeprecations();
59
-        // workarounds for PHP < 5.3
60
-        espresso_load_required('EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php');
61
-        do_action(
62
-            'EE_EventEspresso_core_services_request_RequestStackCoreApp__handle_request__initialize_core_loading'
63
-        );
64
-        // legacy action for backwards compatibility
65
-        do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading');
66
-        espressoLoadWpGraphQL();
67
-        $this->setupFramework();
68
-        $capabilities_checker = LoaderFactory::getShared(CapabilitiesChecker::class, [EE_Capabilities::instance()]);
69
-        LoaderFactory::getShared(PersistentAdminNoticeManager::class, [$capabilities_checker, $request]);
70
-        // needed
71
-        LoaderFactory::getShared(EE_Maintenance_Mode::class);
72
-        // load legacy Cron Tasks and new Cron Manager
73
-        LoaderFactory::getShared(EE_Cron_Tasks::class);
74
-        /** @var CronManager $cron_manager */
75
-        $cron_manager = LoaderFactory::getShared(CronManager::class, [LoaderFactory::getLoader()]);
76
-        $cron_manager->initialize();
77
-        LoaderFactory::getShared(EE_System::class);
78
-        return $this->response;
79
-    }
38
+	/**
39
+	 * handle
40
+	 * sets hooks for running rest of system
41
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
42
+	 * starting EE Addons from any other point may lead to problems
43
+	 *
44
+	 * @param RequestInterface  $request
45
+	 * @param ResponseInterface $response
46
+	 * @return ResponseInterface
47
+	 * @throws InvalidClassException
48
+	 * @throws EE_Error
49
+	 * @throws InvalidDataTypeException
50
+	 * @throws InvalidInterfaceException
51
+	 * @throws InvalidArgumentException
52
+	 */
53
+	public function handleRequest(RequestInterface $request, ResponseInterface $response): ResponseInterface
54
+	{
55
+		$this->request  = $request;
56
+		$this->response = $response;
57
+		espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php');
58
+		DeprecationManager::loadDeprecations();
59
+		// workarounds for PHP < 5.3
60
+		espresso_load_required('EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php');
61
+		do_action(
62
+			'EE_EventEspresso_core_services_request_RequestStackCoreApp__handle_request__initialize_core_loading'
63
+		);
64
+		// legacy action for backwards compatibility
65
+		do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading');
66
+		espressoLoadWpGraphQL();
67
+		$this->setupFramework();
68
+		$capabilities_checker = LoaderFactory::getShared(CapabilitiesChecker::class, [EE_Capabilities::instance()]);
69
+		LoaderFactory::getShared(PersistentAdminNoticeManager::class, [$capabilities_checker, $request]);
70
+		// needed
71
+		LoaderFactory::getShared(EE_Maintenance_Mode::class);
72
+		// load legacy Cron Tasks and new Cron Manager
73
+		LoaderFactory::getShared(EE_Cron_Tasks::class);
74
+		/** @var CronManager $cron_manager */
75
+		$cron_manager = LoaderFactory::getShared(CronManager::class, [LoaderFactory::getLoader()]);
76
+		$cron_manager->initialize();
77
+		LoaderFactory::getShared(EE_System::class);
78
+		return $this->response;
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * set framework for the rest of EE to hook into when loading
84
-     *
85
-     * @throws EE_Error
86
-     */
87
-    private function setupFramework()
88
-    {
89
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
90
-        add_action('plugins_loaded', ['EE_Bootstrap', 'load_espresso_addons']);
91
-        add_action('setup_theme', ['EE_Bootstrap', 'detect_activations_or_upgrades']);
92
-        add_action('after_setup_theme', ['EE_Bootstrap', 'load_core_configuration']);
93
-        add_action('after_setup_theme', ['EE_Bootstrap', 'register_shortcodes_modules_and_widgets'], 15);
94
-        add_action('init', ['EE_Bootstrap', 'brew_espresso'], 1);
95
-    }
82
+	/**
83
+	 * set framework for the rest of EE to hook into when loading
84
+	 *
85
+	 * @throws EE_Error
86
+	 */
87
+	private function setupFramework()
88
+	{
89
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
90
+		add_action('plugins_loaded', ['EE_Bootstrap', 'load_espresso_addons']);
91
+		add_action('setup_theme', ['EE_Bootstrap', 'detect_activations_or_upgrades']);
92
+		add_action('after_setup_theme', ['EE_Bootstrap', 'load_core_configuration']);
93
+		add_action('after_setup_theme', ['EE_Bootstrap', 'register_shortcodes_modules_and_widgets'], 15);
94
+		add_action('init', ['EE_Bootstrap', 'brew_espresso'], 1);
95
+	}
96 96
 
97 97
 
98
-    /**
99
-     * called after the request stack has been fully processed
100
-     * if any of the middleware apps has requested the plugin be deactivated, then we do that now
101
-     *
102
-     * @param RequestInterface  $request
103
-     * @param ResponseInterface $response
104
-     */
105
-    public function handleResponse(RequestInterface $request, ResponseInterface $response)
106
-    {
107
-        if ($response->pluginDeactivated()) {
108
-            espresso_deactivate_plugin(EE_PLUGIN_BASENAME);
109
-        }
110
-        $request_headers = $response->requestHeaders();
111
-        if ($request_headers) {
112
-            foreach ($request_headers as $request_header) {
113
-                header($request_header);
114
-            }
115
-            // headers set AND request terminated? then kill the current request
116
-            if ($response->requestTerminated()) {
117
-                exit;
118
-            }
119
-        }
120
-    }
98
+	/**
99
+	 * called after the request stack has been fully processed
100
+	 * if any of the middleware apps has requested the plugin be deactivated, then we do that now
101
+	 *
102
+	 * @param RequestInterface  $request
103
+	 * @param ResponseInterface $response
104
+	 */
105
+	public function handleResponse(RequestInterface $request, ResponseInterface $response)
106
+	{
107
+		if ($response->pluginDeactivated()) {
108
+			espresso_deactivate_plugin(EE_PLUGIN_BASENAME);
109
+		}
110
+		$request_headers = $response->requestHeaders();
111
+		if ($request_headers) {
112
+			foreach ($request_headers as $request_header) {
113
+				header($request_header);
114
+			}
115
+			// headers set AND request terminated? then kill the current request
116
+			if ($response->requestTerminated()) {
117
+				exit;
118
+			}
119
+		}
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $this->request  = $request;
56 56
         $this->response = $response;
57
-        espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php');
57
+        espresso_load_required('EE_Base', EE_CORE.'EE_Base.core.php');
58 58
         DeprecationManager::loadDeprecations();
59 59
         // workarounds for PHP < 5.3
60
-        espresso_load_required('EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php');
60
+        espresso_load_required('EEH_Class_Tools', EE_HELPERS.'EEH_Class_Tools.helper.php');
61 61
         do_action(
62 62
             'EE_EventEspresso_core_services_request_RequestStackCoreApp__handle_request__initialize_core_loading'
63 63
         );
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     private function setupFramework()
88 88
     {
89
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
89
+        espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php');
90 90
         add_action('plugins_loaded', ['EE_Bootstrap', 'load_espresso_addons']);
91 91
         add_action('setup_theme', ['EE_Bootstrap', 'detect_activations_or_upgrades']);
92 92
         add_action('after_setup_theme', ['EE_Bootstrap', 'load_core_configuration']);
Please login to merge, or discard this patch.
core/services/request/sanitizers/RequestSanitizer.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -7,90 +7,90 @@
 block discarded – undo
7 7
 
8 8
 class RequestSanitizer
9 9
 {
10
-    private Basic $email_validator;
10
+	private Basic $email_validator;
11 11
 
12 12
 
13
-    /**
14
-     * @param Basic $email_validator
15
-     */
16
-    public function __construct(Basic $email_validator)
17
-    {
18
-        $this->email_validator = $email_validator;
19
-    }
13
+	/**
14
+	 * @param Basic $email_validator
15
+	 */
16
+	public function __construct(Basic $email_validator)
17
+	{
18
+		$this->email_validator = $email_validator;
19
+	}
20 20
 
21 21
 
22
-    /**
23
-     * Will sanitize the supplied request parameter based on the specified data type
24
-     *
25
-     * @param mixed  $param     the supplied request parameter
26
-     * @param string $type      the specified data type (default: "string")
27
-     *                          valid values: "bool", "float", "int", "key", "url", or "string"
28
-     * @param bool   $is_array  if true, then $param will be treated as an array of $type
29
-     * @param string $delimiter if $param is a CSV like value (ex: 1,2,3,4,5...) then this is the value separator
30
-     * @return array|bool|float|int|string
31
-     * @since 4.10.14.p
32
-     */
33
-    public function clean(
34
-        $param,
35
-        string $type = DataType::STRING,
36
-        bool $is_array = false,
37
-        string $delimiter = ''
38
-    ) {
39
-        if ($delimiter !== '' && is_string($param)) {
40
-            $param    = explode($delimiter, $param);
41
-            $is_array = is_array($param);
42
-            // unset the delimiter else this function will recurse forever when we loop over the array of results
43
-            $delimiter = '';
44
-        }
45
-        // check if we are getting an improperly typed array and correct
46
-        $is_array = $is_array && is_array($param);
47
-        if ($is_array) {
48
-            return array_map(
49
-                fn ($value) => $this->clean($value, $type, is_array($value), $delimiter),
50
-                (array) $param
51
-            );
52
-        }
53
-        return $this->sanitizeParam($param, $type);
54
-    }
22
+	/**
23
+	 * Will sanitize the supplied request parameter based on the specified data type
24
+	 *
25
+	 * @param mixed  $param     the supplied request parameter
26
+	 * @param string $type      the specified data type (default: "string")
27
+	 *                          valid values: "bool", "float", "int", "key", "url", or "string"
28
+	 * @param bool   $is_array  if true, then $param will be treated as an array of $type
29
+	 * @param string $delimiter if $param is a CSV like value (ex: 1,2,3,4,5...) then this is the value separator
30
+	 * @return array|bool|float|int|string
31
+	 * @since 4.10.14.p
32
+	 */
33
+	public function clean(
34
+		$param,
35
+		string $type = DataType::STRING,
36
+		bool $is_array = false,
37
+		string $delimiter = ''
38
+	) {
39
+		if ($delimiter !== '' && is_string($param)) {
40
+			$param    = explode($delimiter, $param);
41
+			$is_array = is_array($param);
42
+			// unset the delimiter else this function will recurse forever when we loop over the array of results
43
+			$delimiter = '';
44
+		}
45
+		// check if we are getting an improperly typed array and correct
46
+		$is_array = $is_array && is_array($param);
47
+		if ($is_array) {
48
+			return array_map(
49
+				fn ($value) => $this->clean($value, $type, is_array($value), $delimiter),
50
+				(array) $param
51
+			);
52
+		}
53
+		return $this->sanitizeParam($param, $type);
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * @param mixed  $param
59
-     * @param string $type
60
-     * @return mixed
61
-     * @since   4.10.20.p
62
-     */
63
-    public function sanitizeParam($param, string $type = DataType::STRING)
64
-    {
65
-        switch ($type) {
66
-            case DataType::BOOL:
67
-                return filter_var($param, FILTER_VALIDATE_BOOLEAN);
68
-            case DataType::EDITOR:
69
-                if ($param === null) {
70
-                    return '';
71
-                }
72
-                $allowed_tags = AllowedTags::getWithFullTags();
73
-                return wp_kses($param, $allowed_tags);
74
-            case DataType::EMAIL:
75
-                return $this->email_validator->validate($param) ? $param : '';
76
-            case DataType::FLOAT:
77
-                return (float) $param;
78
-            case DataType::FQCN:
79
-                return preg_replace('[^\\\w\d]', '', $param);
80
-            case DataType::HTML:
81
-                $allowed_tags = AllowedTags::getAllowedTags();
82
-                return wp_kses($param, $allowed_tags);
83
-            case DataType::INT:
84
-                return (int) $param;
85
-            case DataType::KEY:
86
-                return sanitize_key($param);
87
-            case DataType::TITLE:
88
-                return sanitize_title($param);
89
-            case DataType::URL:
90
-                return esc_url_raw($param);
91
-            case DataType::STRING:
92
-            default:
93
-                return sanitize_text_field($param);
94
-        }
95
-    }
57
+	/**
58
+	 * @param mixed  $param
59
+	 * @param string $type
60
+	 * @return mixed
61
+	 * @since   4.10.20.p
62
+	 */
63
+	public function sanitizeParam($param, string $type = DataType::STRING)
64
+	{
65
+		switch ($type) {
66
+			case DataType::BOOL:
67
+				return filter_var($param, FILTER_VALIDATE_BOOLEAN);
68
+			case DataType::EDITOR:
69
+				if ($param === null) {
70
+					return '';
71
+				}
72
+				$allowed_tags = AllowedTags::getWithFullTags();
73
+				return wp_kses($param, $allowed_tags);
74
+			case DataType::EMAIL:
75
+				return $this->email_validator->validate($param) ? $param : '';
76
+			case DataType::FLOAT:
77
+				return (float) $param;
78
+			case DataType::FQCN:
79
+				return preg_replace('[^\\\w\d]', '', $param);
80
+			case DataType::HTML:
81
+				$allowed_tags = AllowedTags::getAllowedTags();
82
+				return wp_kses($param, $allowed_tags);
83
+			case DataType::INT:
84
+				return (int) $param;
85
+			case DataType::KEY:
86
+				return sanitize_key($param);
87
+			case DataType::TITLE:
88
+				return sanitize_title($param);
89
+			case DataType::URL:
90
+				return esc_url_raw($param);
91
+			case DataType::STRING:
92
+			default:
93
+				return sanitize_text_field($param);
94
+		}
95
+	}
96 96
 }
Please login to merge, or discard this patch.