PluginProbe
Ultimate Store Kit / 3.1.3
Ultimate Store Kit v3.1.3
3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.0.7 3.0.5 3.0.4 3.0.3 3.0.2 trunk 1.5.0 1.5.1 1.5.2 1.6.1 1.6.2 1.6.3 1.6.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 92 releases
ultimate-store-kit / base / support / helpers.php

helpers.php in Ultimate Store Kit 3.1.3, at base/support/helpers.php

32 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (! defined('ABSPATH')) {
4 exit; // Exit if accessed directly
5 }
6
7 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals -- usk_ / BDTUSK_ / ultimate-store-kit- are this plugin's established public prefixes. Ultimate Store Kit Pro calls into these names, as does third-party integration code, so renaming them is a breaking change. Plugin Check only recognises prefixes derived verbatim from the slug and so reports them as unprefixed.
8
9 use UltimateStoreKit\Base\Support\Optional;
10
11 if (! function_exists('ultimate_store_kit_optional')) {
12 /**
13 * Provide access to optional objects.
14 *
15 * Named ultimate_store_kit_optional() rather than optional(): the unprefixed name is the
16 * Laravel helper, which any plugin bundling illuminate/support also declares.
17 * Behind a function_exists() guard the first declaration wins, so an
18 * unprefixed version would silently hand this plugin a foreign Optional class.
19 *
20 * @param mixed $value
21 * @param callable|null $callback
22 * @return mixed
23 */
24 function ultimate_store_kit_optional($value = null, ?callable $callback = null) {
25 if (is_null($callback)) {
26 return new Optional($value);
27 } elseif (! is_null($value)) {
28 return $callback($value);
29 }
30 }
31 }
32