@@ -33,14 +33,14 @@ |
||
33 | 33 | */ |
34 | 34 | public function __construct(string $fully_qualified_name) |
35 | 35 | { |
36 | - if (! is_string($fully_qualified_name)) { |
|
36 | + if ( ! is_string($fully_qualified_name)) { |
|
37 | 37 | throw new InvalidDataTypeException( |
38 | 38 | '$fully_qualified_name', |
39 | 39 | $fully_qualified_name, |
40 | 40 | 'string' |
41 | 41 | ); |
42 | 42 | } |
43 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
43 | + if ( ! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
44 | 44 | if (strpos($fully_qualified_name, 'Interface') !== false) { |
45 | 45 | throw new InvalidInterfaceException($fully_qualified_name); |
46 | 46 | } |
@@ -16,53 +16,53 @@ |
||
16 | 16 | */ |
17 | 17 | class FullyQualifiedName |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string $fully_qualified_name |
|
21 | - */ |
|
22 | - private $fully_qualified_name; |
|
19 | + /** |
|
20 | + * @var string $fully_qualified_name |
|
21 | + */ |
|
22 | + private $fully_qualified_name; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * FullyQualifiedName constructor. |
|
27 | - * |
|
28 | - * @param string $fully_qualified_name |
|
29 | - * @throws InvalidClassException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws InvalidDataTypeException |
|
32 | - */ |
|
33 | - public function __construct(string $fully_qualified_name) |
|
34 | - { |
|
35 | - if (! is_string($fully_qualified_name)) { |
|
36 | - throw new InvalidDataTypeException( |
|
37 | - '$fully_qualified_name', |
|
38 | - $fully_qualified_name, |
|
39 | - 'string' |
|
40 | - ); |
|
41 | - } |
|
42 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
43 | - if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
44 | - throw new InvalidInterfaceException($fully_qualified_name); |
|
45 | - } |
|
46 | - throw new InvalidClassException($fully_qualified_name); |
|
47 | - } |
|
48 | - $this->fully_qualified_name = $fully_qualified_name; |
|
49 | - } |
|
25 | + /** |
|
26 | + * FullyQualifiedName constructor. |
|
27 | + * |
|
28 | + * @param string $fully_qualified_name |
|
29 | + * @throws InvalidClassException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws InvalidDataTypeException |
|
32 | + */ |
|
33 | + public function __construct(string $fully_qualified_name) |
|
34 | + { |
|
35 | + if (! is_string($fully_qualified_name)) { |
|
36 | + throw new InvalidDataTypeException( |
|
37 | + '$fully_qualified_name', |
|
38 | + $fully_qualified_name, |
|
39 | + 'string' |
|
40 | + ); |
|
41 | + } |
|
42 | + if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
43 | + if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
44 | + throw new InvalidInterfaceException($fully_qualified_name); |
|
45 | + } |
|
46 | + throw new InvalidClassException($fully_qualified_name); |
|
47 | + } |
|
48 | + $this->fully_qualified_name = $fully_qualified_name; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function string(): string |
|
56 | - { |
|
57 | - return $this->fully_qualified_name; |
|
58 | - } |
|
52 | + /** |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function string(): string |
|
56 | + { |
|
57 | + return $this->fully_qualified_name; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function __toString(): string |
|
65 | - { |
|
66 | - return $this->fully_qualified_name; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function __toString(): string |
|
65 | + { |
|
66 | + return $this->fully_qualified_name; |
|
67 | + } |
|
68 | 68 | } |
@@ -22,101 +22,101 @@ |
||
22 | 22 | */ |
23 | 23 | class DomainFactory |
24 | 24 | { |
25 | - /** |
|
26 | - * @var DomainInterface[] |
|
27 | - */ |
|
28 | - protected static $domains = []; |
|
25 | + /** |
|
26 | + * @var DomainInterface[] |
|
27 | + */ |
|
28 | + protected static $domains = []; |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @param string $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
33 | - * @param string $main_file [required] path to the main plugin file |
|
34 | - * @param string $version [required] version string for the plugin |
|
35 | - * @return DomainInterface |
|
36 | - * @throws DomainException |
|
37 | - * @throws InvalidArgumentException |
|
38 | - * @throws InvalidDataTypeException |
|
39 | - * @throws InvalidInterfaceException |
|
40 | - */ |
|
41 | - public static function create(string $domain_fqcn, string $main_file, string $version): DomainInterface |
|
42 | - { |
|
43 | - $fqcn = new FullyQualifiedName($domain_fqcn); |
|
44 | - return DomainFactory::getDomain($fqcn->string(), [$main_file, $version]); |
|
45 | - } |
|
31 | + /** |
|
32 | + * @param string $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
33 | + * @param string $main_file [required] path to the main plugin file |
|
34 | + * @param string $version [required] version string for the plugin |
|
35 | + * @return DomainInterface |
|
36 | + * @throws DomainException |
|
37 | + * @throws InvalidArgumentException |
|
38 | + * @throws InvalidDataTypeException |
|
39 | + * @throws InvalidInterfaceException |
|
40 | + */ |
|
41 | + public static function create(string $domain_fqcn, string $main_file, string $version): DomainInterface |
|
42 | + { |
|
43 | + $fqcn = new FullyQualifiedName($domain_fqcn); |
|
44 | + return DomainFactory::getDomain($fqcn->string(), [$main_file, $version]); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
50 | - * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
51 | - * constructor. Must at least include the following two value objects: |
|
52 | - * [ |
|
53 | - * EventEspresso\core\domain\values\FilePath $plugin_file |
|
54 | - * EventEspresso\core\domain\values\Version $version |
|
55 | - * ] |
|
56 | - * @return DomainInterface |
|
57 | - * @throws DomainException |
|
58 | - * @throws InvalidArgumentException |
|
59 | - * @throws InvalidDataTypeException |
|
60 | - * @throws InvalidInterfaceException |
|
61 | - */ |
|
62 | - public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments): DomainInterface |
|
63 | - { |
|
64 | - return DomainFactory::getDomain($domain_fqcn->string(), $arguments); |
|
65 | - } |
|
48 | + /** |
|
49 | + * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
50 | + * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
51 | + * constructor. Must at least include the following two value objects: |
|
52 | + * [ |
|
53 | + * EventEspresso\core\domain\values\FilePath $plugin_file |
|
54 | + * EventEspresso\core\domain\values\Version $version |
|
55 | + * ] |
|
56 | + * @return DomainInterface |
|
57 | + * @throws DomainException |
|
58 | + * @throws InvalidArgumentException |
|
59 | + * @throws InvalidDataTypeException |
|
60 | + * @throws InvalidInterfaceException |
|
61 | + */ |
|
62 | + public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments): DomainInterface |
|
63 | + { |
|
64 | + return DomainFactory::getDomain($domain_fqcn->string(), $arguments); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @return DomainInterface |
|
70 | - * @throws DomainException |
|
71 | - * @throws InvalidArgumentException |
|
72 | - * @throws InvalidDataTypeException |
|
73 | - * @throws InvalidFilePathException |
|
74 | - * @throws InvalidInterfaceException |
|
75 | - */ |
|
76 | - public static function getEventEspressoCoreDomain(): DomainInterface |
|
77 | - { |
|
78 | - $fqcn = 'EventEspresso\core\domain\Domain'; |
|
79 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
80 | - DomainFactory::getDomain($fqcn, [EVENT_ESPRESSO_MAIN_FILE, espresso_version()]); |
|
81 | - } |
|
82 | - return DomainFactory::$domains[ $fqcn ]; |
|
83 | - } |
|
68 | + /** |
|
69 | + * @return DomainInterface |
|
70 | + * @throws DomainException |
|
71 | + * @throws InvalidArgumentException |
|
72 | + * @throws InvalidDataTypeException |
|
73 | + * @throws InvalidFilePathException |
|
74 | + * @throws InvalidInterfaceException |
|
75 | + */ |
|
76 | + public static function getEventEspressoCoreDomain(): DomainInterface |
|
77 | + { |
|
78 | + $fqcn = 'EventEspresso\core\domain\Domain'; |
|
79 | + if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
80 | + DomainFactory::getDomain($fqcn, [EVENT_ESPRESSO_MAIN_FILE, espresso_version()]); |
|
81 | + } |
|
82 | + return DomainFactory::$domains[ $fqcn ]; |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * @param string $fqcn |
|
88 | - * @param array $arguments |
|
89 | - * @return DomainInterface |
|
90 | - */ |
|
91 | - private static function getDomain(string $fqcn, array $arguments): DomainInterface |
|
92 | - { |
|
93 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
94 | - if (! isset($arguments[0], $arguments[1])) { |
|
95 | - throw new InvalidArgumentException( |
|
96 | - esc_html__( |
|
97 | - 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
98 | - 'event_espresso' |
|
99 | - ) |
|
100 | - ); |
|
101 | - } |
|
102 | - $filepath = $arguments[0] instanceof FilePath ? $arguments[0] : new FilePath($arguments[0]); |
|
103 | - $version = $arguments[1] instanceof Version ? $arguments[1] : Version::fromString($arguments[1]); |
|
104 | - $domain = new $fqcn($filepath, $version); |
|
105 | - if (! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
106 | - throw new DomainException( |
|
107 | - sprintf( |
|
108 | - esc_html__( |
|
109 | - 'The requested Domain class "%1$s" could not be loaded.', |
|
110 | - 'event_espresso' |
|
111 | - ), |
|
112 | - $fqcn |
|
113 | - ) |
|
114 | - ); |
|
115 | - } |
|
116 | - DomainFactory::$domains[ $fqcn ] = $domain; |
|
117 | - // we still need to share this with the core loader to facilitate automatic dependency injection |
|
118 | - LoaderFactory::getLoader()->share($fqcn, $domain, [$filepath, $version, $domain->assetNamespace()]); |
|
119 | - } |
|
120 | - return DomainFactory::$domains[ $fqcn ]; |
|
121 | - } |
|
86 | + /** |
|
87 | + * @param string $fqcn |
|
88 | + * @param array $arguments |
|
89 | + * @return DomainInterface |
|
90 | + */ |
|
91 | + private static function getDomain(string $fqcn, array $arguments): DomainInterface |
|
92 | + { |
|
93 | + if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
94 | + if (! isset($arguments[0], $arguments[1])) { |
|
95 | + throw new InvalidArgumentException( |
|
96 | + esc_html__( |
|
97 | + 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
98 | + 'event_espresso' |
|
99 | + ) |
|
100 | + ); |
|
101 | + } |
|
102 | + $filepath = $arguments[0] instanceof FilePath ? $arguments[0] : new FilePath($arguments[0]); |
|
103 | + $version = $arguments[1] instanceof Version ? $arguments[1] : Version::fromString($arguments[1]); |
|
104 | + $domain = new $fqcn($filepath, $version); |
|
105 | + if (! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
106 | + throw new DomainException( |
|
107 | + sprintf( |
|
108 | + esc_html__( |
|
109 | + 'The requested Domain class "%1$s" could not be loaded.', |
|
110 | + 'event_espresso' |
|
111 | + ), |
|
112 | + $fqcn |
|
113 | + ) |
|
114 | + ); |
|
115 | + } |
|
116 | + DomainFactory::$domains[ $fqcn ] = $domain; |
|
117 | + // we still need to share this with the core loader to facilitate automatic dependency injection |
|
118 | + LoaderFactory::getLoader()->share($fqcn, $domain, [$filepath, $version, $domain->assetNamespace()]); |
|
119 | + } |
|
120 | + return DomainFactory::$domains[ $fqcn ]; |
|
121 | + } |
|
122 | 122 | } |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | public static function getEventEspressoCoreDomain(): DomainInterface |
77 | 77 | { |
78 | 78 | $fqcn = 'EventEspresso\core\domain\Domain'; |
79 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
79 | + if ( ! isset(DomainFactory::$domains[$fqcn])) { |
|
80 | 80 | DomainFactory::getDomain($fqcn, [EVENT_ESPRESSO_MAIN_FILE, espresso_version()]); |
81 | 81 | } |
82 | - return DomainFactory::$domains[ $fqcn ]; |
|
82 | + return DomainFactory::$domains[$fqcn]; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | */ |
91 | 91 | private static function getDomain(string $fqcn, array $arguments): DomainInterface |
92 | 92 | { |
93 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
94 | - if (! isset($arguments[0], $arguments[1])) { |
|
93 | + if ( ! isset(DomainFactory::$domains[$fqcn])) { |
|
94 | + if ( ! isset($arguments[0], $arguments[1])) { |
|
95 | 95 | throw new InvalidArgumentException( |
96 | 96 | esc_html__( |
97 | 97 | 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $filepath = $arguments[0] instanceof FilePath ? $arguments[0] : new FilePath($arguments[0]); |
103 | 103 | $version = $arguments[1] instanceof Version ? $arguments[1] : Version::fromString($arguments[1]); |
104 | 104 | $domain = new $fqcn($filepath, $version); |
105 | - if (! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
105 | + if ( ! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
106 | 106 | throw new DomainException( |
107 | 107 | sprintf( |
108 | 108 | esc_html__( |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | ) |
114 | 114 | ); |
115 | 115 | } |
116 | - DomainFactory::$domains[ $fqcn ] = $domain; |
|
116 | + DomainFactory::$domains[$fqcn] = $domain; |
|
117 | 117 | // we still need to share this with the core loader to facilitate automatic dependency injection |
118 | 118 | LoaderFactory::getLoader()->share($fqcn, $domain, [$filepath, $version, $domain->assetNamespace()]); |
119 | 119 | } |
120 | - return DomainFactory::$domains[ $fqcn ]; |
|
120 | + return DomainFactory::$domains[$fqcn]; |
|
121 | 121 | } |
122 | 122 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function initialize($asset_namespace = Domain::ASSET_NAMESPACE) |
91 | 91 | { |
92 | - if (! $this->initialized) { |
|
92 | + if ( ! $this->initialized) { |
|
93 | 93 | $this->plugin_basename = plugin_basename($this->pluginFile()); |
94 | 94 | $this->plugin_path = plugin_dir_path($this->pluginFile()); |
95 | 95 | $this->plugin_url = plugin_dir_url($this->pluginFile()); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function setAssetNamespace($asset_namespace = Domain::ASSET_NAMESPACE) |
108 | 108 | { |
109 | - if (! $this->asset_namespace) { |
|
109 | + if ( ! $this->asset_namespace) { |
|
110 | 110 | $this->asset_namespace = sanitize_key( |
111 | 111 | // convert directory separators to dashes and remove file extension |
112 | 112 | str_replace(['/', '.php'], ['-', ''], $asset_namespace) |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | private function setDistributionAssetsPath() |
123 | 123 | { |
124 | 124 | $assets_folder_paths = [ |
125 | - $this->plugin_path . DomainBase::ASSETS_FOLDER, |
|
126 | - $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER, |
|
125 | + $this->plugin_path.DomainBase::ASSETS_FOLDER, |
|
126 | + $this->plugin_path.'src/'.DomainBase::ASSETS_FOLDER, |
|
127 | 127 | ]; |
128 | 128 | foreach ($assets_folder_paths as $assets_folder_path) { |
129 | 129 | if (is_readable($assets_folder_path)) { |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | public function pluginPath($additional_path = ''): string |
170 | 170 | { |
171 | 171 | return is_string($additional_path) && $additional_path !== '' |
172 | - ? $this->plugin_path . $additional_path |
|
172 | + ? $this->plugin_path.$additional_path |
|
173 | 173 | : $this->plugin_path; |
174 | 174 | } |
175 | 175 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | public function pluginUrl($additional_path = ''): string |
182 | 182 | { |
183 | 183 | return is_string($additional_path) && $additional_path !== '' |
184 | - ? $this->plugin_url . $additional_path |
|
184 | + ? $this->plugin_url.$additional_path |
|
185 | 185 | : $this->plugin_url; |
186 | 186 | } |
187 | 187 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | public function distributionAssetsPath($additional_path = ''): string |
221 | 221 | { |
222 | 222 | return is_string($additional_path) && $additional_path !== '' |
223 | - ? $this->assets_path . $additional_path |
|
223 | + ? $this->assets_path.$additional_path |
|
224 | 224 | : $this->assets_path; |
225 | 225 | } |
226 | 226 | |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | public function distributionAssetsUrl($additional_path = ''): string |
233 | 233 | { |
234 | 234 | return is_string($additional_path) && $additional_path !== '' |
235 | - ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path |
|
236 | - : $this->plugin_url . DomainBase::ASSETS_FOLDER; |
|
235 | + ? $this->plugin_url.DomainBase::ASSETS_FOLDER.$additional_path |
|
236 | + : $this->plugin_url.DomainBase::ASSETS_FOLDER; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 |
@@ -16,231 +16,231 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class DomainBase implements DomainInterface |
18 | 18 | { |
19 | - const ASSETS_FOLDER = 'assets/'; |
|
20 | - |
|
21 | - /** |
|
22 | - * Equivalent to `__FILE__` for main plugin file. |
|
23 | - * |
|
24 | - * @var FilePath |
|
25 | - */ |
|
26 | - private $plugin_file; |
|
27 | - |
|
28 | - /** |
|
29 | - * String indicating version for plugin |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - private $version; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string $plugin_basename |
|
37 | - */ |
|
38 | - private $plugin_basename; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var string $plugin_path |
|
42 | - */ |
|
43 | - private $plugin_path; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string $plugin_url |
|
47 | - */ |
|
48 | - private $plugin_url; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var string $asset_namespace |
|
52 | - */ |
|
53 | - private $asset_namespace; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var string $assets_path |
|
57 | - */ |
|
58 | - private $assets_path; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var bool |
|
62 | - */ |
|
63 | - protected $initialized = false; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Initializes internal properties. |
|
68 | - * |
|
69 | - * @param FilePath $plugin_file |
|
70 | - * @param Version $version |
|
71 | - * @param string $asset_namespace |
|
72 | - */ |
|
73 | - public function __construct( |
|
74 | - FilePath $plugin_file, |
|
75 | - Version $version, |
|
76 | - string $asset_namespace = Domain::ASSET_NAMESPACE |
|
77 | - ) { |
|
78 | - $this->plugin_file = $plugin_file; |
|
79 | - $this->version = $version; |
|
80 | - $this->initialize($asset_namespace); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @param string $asset_namespace |
|
86 | - * @return void |
|
87 | - * @since 5.0.0.p |
|
88 | - */ |
|
89 | - public function initialize($asset_namespace = Domain::ASSET_NAMESPACE) |
|
90 | - { |
|
91 | - if (! $this->initialized) { |
|
92 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
93 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
94 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
95 | - $this->setAssetNamespace($asset_namespace); |
|
96 | - $this->setDistributionAssetsPath(); |
|
97 | - $this->initialized = true; |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @param string $asset_namespace |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public function setAssetNamespace($asset_namespace = Domain::ASSET_NAMESPACE) |
|
107 | - { |
|
108 | - if (! $this->asset_namespace) { |
|
109 | - $this->asset_namespace = sanitize_key( |
|
110 | - // convert directory separators to dashes and remove file extension |
|
111 | - str_replace(['/', '.php'], ['-', ''], $asset_namespace) |
|
112 | - ); |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @throws DomainException |
|
119 | - * @since 5.0.0.p |
|
120 | - */ |
|
121 | - private function setDistributionAssetsPath() |
|
122 | - { |
|
123 | - $assets_folder_paths = [ |
|
124 | - $this->plugin_path . DomainBase::ASSETS_FOLDER, |
|
125 | - $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER, |
|
126 | - ]; |
|
127 | - foreach ($assets_folder_paths as $assets_folder_path) { |
|
128 | - if (is_readable($assets_folder_path)) { |
|
129 | - $this->assets_path = trailingslashit($assets_folder_path); |
|
130 | - // once we find a valid path, just break out of loop |
|
131 | - break; |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function pluginFile(): string |
|
141 | - { |
|
142 | - return (string) $this->plugin_file; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return FilePath |
|
148 | - */ |
|
149 | - public function pluginFileObject(): FilePath |
|
150 | - { |
|
151 | - return $this->plugin_file; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - public function pluginBasename(): string |
|
159 | - { |
|
160 | - return $this->plugin_basename; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @param string $additional_path |
|
166 | - * @return string |
|
167 | - */ |
|
168 | - public function pluginPath($additional_path = ''): string |
|
169 | - { |
|
170 | - return is_string($additional_path) && $additional_path !== '' |
|
171 | - ? $this->plugin_path . $additional_path |
|
172 | - : $this->plugin_path; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * @param string $additional_path |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public function pluginUrl($additional_path = ''): string |
|
181 | - { |
|
182 | - return is_string($additional_path) && $additional_path !== '' |
|
183 | - ? $this->plugin_url . $additional_path |
|
184 | - : $this->plugin_url; |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * @return string |
|
190 | - */ |
|
191 | - public function version(): string |
|
192 | - { |
|
193 | - return (string) $this->version; |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * @return Version |
|
199 | - */ |
|
200 | - public function versionValueObject() |
|
201 | - { |
|
202 | - return $this->version; |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * @return string |
|
208 | - */ |
|
209 | - public function distributionAssetsFolder(): string |
|
210 | - { |
|
211 | - return DomainBase::ASSETS_FOLDER; |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * @param string $additional_path |
|
217 | - * @return string |
|
218 | - */ |
|
219 | - public function distributionAssetsPath($additional_path = ''): string |
|
220 | - { |
|
221 | - return is_string($additional_path) && $additional_path !== '' |
|
222 | - ? $this->assets_path . $additional_path |
|
223 | - : $this->assets_path; |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * @param string $additional_path |
|
229 | - * @return string |
|
230 | - */ |
|
231 | - public function distributionAssetsUrl($additional_path = ''): string |
|
232 | - { |
|
233 | - return is_string($additional_path) && $additional_path !== '' |
|
234 | - ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path |
|
235 | - : $this->plugin_url . DomainBase::ASSETS_FOLDER; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * @return string |
|
241 | - */ |
|
242 | - public function assetNamespace(): string |
|
243 | - { |
|
244 | - return $this->asset_namespace; |
|
245 | - } |
|
19 | + const ASSETS_FOLDER = 'assets/'; |
|
20 | + |
|
21 | + /** |
|
22 | + * Equivalent to `__FILE__` for main plugin file. |
|
23 | + * |
|
24 | + * @var FilePath |
|
25 | + */ |
|
26 | + private $plugin_file; |
|
27 | + |
|
28 | + /** |
|
29 | + * String indicating version for plugin |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + private $version; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string $plugin_basename |
|
37 | + */ |
|
38 | + private $plugin_basename; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var string $plugin_path |
|
42 | + */ |
|
43 | + private $plugin_path; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string $plugin_url |
|
47 | + */ |
|
48 | + private $plugin_url; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var string $asset_namespace |
|
52 | + */ |
|
53 | + private $asset_namespace; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var string $assets_path |
|
57 | + */ |
|
58 | + private $assets_path; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var bool |
|
62 | + */ |
|
63 | + protected $initialized = false; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Initializes internal properties. |
|
68 | + * |
|
69 | + * @param FilePath $plugin_file |
|
70 | + * @param Version $version |
|
71 | + * @param string $asset_namespace |
|
72 | + */ |
|
73 | + public function __construct( |
|
74 | + FilePath $plugin_file, |
|
75 | + Version $version, |
|
76 | + string $asset_namespace = Domain::ASSET_NAMESPACE |
|
77 | + ) { |
|
78 | + $this->plugin_file = $plugin_file; |
|
79 | + $this->version = $version; |
|
80 | + $this->initialize($asset_namespace); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @param string $asset_namespace |
|
86 | + * @return void |
|
87 | + * @since 5.0.0.p |
|
88 | + */ |
|
89 | + public function initialize($asset_namespace = Domain::ASSET_NAMESPACE) |
|
90 | + { |
|
91 | + if (! $this->initialized) { |
|
92 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
93 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
94 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
95 | + $this->setAssetNamespace($asset_namespace); |
|
96 | + $this->setDistributionAssetsPath(); |
|
97 | + $this->initialized = true; |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @param string $asset_namespace |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public function setAssetNamespace($asset_namespace = Domain::ASSET_NAMESPACE) |
|
107 | + { |
|
108 | + if (! $this->asset_namespace) { |
|
109 | + $this->asset_namespace = sanitize_key( |
|
110 | + // convert directory separators to dashes and remove file extension |
|
111 | + str_replace(['/', '.php'], ['-', ''], $asset_namespace) |
|
112 | + ); |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @throws DomainException |
|
119 | + * @since 5.0.0.p |
|
120 | + */ |
|
121 | + private function setDistributionAssetsPath() |
|
122 | + { |
|
123 | + $assets_folder_paths = [ |
|
124 | + $this->plugin_path . DomainBase::ASSETS_FOLDER, |
|
125 | + $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER, |
|
126 | + ]; |
|
127 | + foreach ($assets_folder_paths as $assets_folder_path) { |
|
128 | + if (is_readable($assets_folder_path)) { |
|
129 | + $this->assets_path = trailingslashit($assets_folder_path); |
|
130 | + // once we find a valid path, just break out of loop |
|
131 | + break; |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function pluginFile(): string |
|
141 | + { |
|
142 | + return (string) $this->plugin_file; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return FilePath |
|
148 | + */ |
|
149 | + public function pluginFileObject(): FilePath |
|
150 | + { |
|
151 | + return $this->plugin_file; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + public function pluginBasename(): string |
|
159 | + { |
|
160 | + return $this->plugin_basename; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @param string $additional_path |
|
166 | + * @return string |
|
167 | + */ |
|
168 | + public function pluginPath($additional_path = ''): string |
|
169 | + { |
|
170 | + return is_string($additional_path) && $additional_path !== '' |
|
171 | + ? $this->plugin_path . $additional_path |
|
172 | + : $this->plugin_path; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * @param string $additional_path |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public function pluginUrl($additional_path = ''): string |
|
181 | + { |
|
182 | + return is_string($additional_path) && $additional_path !== '' |
|
183 | + ? $this->plugin_url . $additional_path |
|
184 | + : $this->plugin_url; |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * @return string |
|
190 | + */ |
|
191 | + public function version(): string |
|
192 | + { |
|
193 | + return (string) $this->version; |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * @return Version |
|
199 | + */ |
|
200 | + public function versionValueObject() |
|
201 | + { |
|
202 | + return $this->version; |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * @return string |
|
208 | + */ |
|
209 | + public function distributionAssetsFolder(): string |
|
210 | + { |
|
211 | + return DomainBase::ASSETS_FOLDER; |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * @param string $additional_path |
|
217 | + * @return string |
|
218 | + */ |
|
219 | + public function distributionAssetsPath($additional_path = ''): string |
|
220 | + { |
|
221 | + return is_string($additional_path) && $additional_path !== '' |
|
222 | + ? $this->assets_path . $additional_path |
|
223 | + : $this->assets_path; |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * @param string $additional_path |
|
229 | + * @return string |
|
230 | + */ |
|
231 | + public function distributionAssetsUrl($additional_path = ''): string |
|
232 | + { |
|
233 | + return is_string($additional_path) && $additional_path !== '' |
|
234 | + ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path |
|
235 | + : $this->plugin_url . DomainBase::ASSETS_FOLDER; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * @return string |
|
241 | + */ |
|
242 | + public function assetNamespace(): string |
|
243 | + { |
|
244 | + return $this->asset_namespace; |
|
245 | + } |
|
246 | 246 | } |
@@ -3,25 +3,25 @@ |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php |
6 | - printf( |
|
7 | - esc_html__( |
|
8 | - 'Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', |
|
9 | - 'event_espresso' |
|
10 | - ), |
|
11 | - '<em>', |
|
12 | - '</em>' |
|
13 | - ); |
|
14 | - ?> |
|
6 | + printf( |
|
7 | + esc_html__( |
|
8 | + 'Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', |
|
9 | + 'event_espresso' |
|
10 | + ), |
|
11 | + '<em>', |
|
12 | + '</em>' |
|
13 | + ); |
|
14 | + ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <?php esc_html_e( |
18 | - 'There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', |
|
19 | - 'event_espresso' |
|
20 | - ); ?> |
|
18 | + 'There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', |
|
19 | + 'event_espresso' |
|
20 | + ); ?> |
|
21 | 21 | </p> |
22 | 22 | <p> |
23 | 23 | <?php esc_html_e( |
24 | - 'With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', |
|
25 | - 'event_espresso' |
|
26 | - ); ?> |
|
24 | + 'With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', |
|
25 | + 'event_espresso' |
|
26 | + ); ?> |
|
27 | 27 | </p> |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | private function _get_datetimes_from_event(EE_Event $event) |
169 | 169 | { |
170 | 170 | return isset($this->_extra_data['data']->events) |
171 | - ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
171 | + ? $this->_extra_data['data']->events[$event->ID()]['dtt_objs'] |
|
172 | 172 | : []; |
173 | 173 | } |
174 | 174 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
183 | 183 | { |
184 | 184 | return isset($this->_extra_data['data']->tickets) |
185 | - ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
185 | + ? $this->_extra_data['data']->tickets[$ticket->ID()]['dtt_objs'] |
|
186 | 186 | : []; |
187 | 187 | } |
188 | 188 | } |
@@ -18,169 +18,169 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Datetime_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - protected function _init_props() |
|
22 | - { |
|
23 | - $this->label = esc_html__('Datetime List Shortcodes', 'event_espresso'); |
|
24 | - $this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso'); |
|
25 | - $this->_shortcodes = [ |
|
26 | - '[DATETIME_LIST]' => esc_html__( |
|
27 | - 'Will output a list of datetimes according to the layout specified in the datetime list field.', |
|
28 | - 'event_espresso' |
|
29 | - ), |
|
30 | - ]; |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @param string $shortcode |
|
36 | - * @return string |
|
37 | - * @throws EE_Error |
|
38 | - * @throws ReflectionException |
|
39 | - */ |
|
40 | - protected function _parser($shortcode) |
|
41 | - { |
|
42 | - switch ($shortcode) { |
|
43 | - case '[DATETIME_LIST]': |
|
44 | - return $this->_get_datetime_list(); |
|
45 | - } |
|
46 | - return ''; |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * figure out what the incoming data is and then return the appropriate parsed value. |
|
52 | - * |
|
53 | - * @return string |
|
54 | - * @throws EE_Error |
|
55 | - * @throws ReflectionException |
|
56 | - */ |
|
57 | - private function _get_datetime_list() |
|
58 | - { |
|
59 | - $this->_validate_list_requirements(); |
|
60 | - |
|
61 | - if ($this->_data['data'] instanceof EE_Ticket) { |
|
62 | - return $this->_get_datetime_list_for_ticket(); |
|
63 | - } |
|
64 | - if ($this->_data['data'] instanceof EE_Event) { |
|
65 | - return $this->_get_datetime_list_for_event(); |
|
66 | - } |
|
67 | - if ( |
|
68 | - $this->_data['data'] instanceof EE_Messages_Addressee |
|
69 | - && $this->_data['data']->reg_obj instanceof EE_Registration |
|
70 | - ) { |
|
71 | - return $this->_get_datetime_list_for_registration(); |
|
72 | - } |
|
73 | - // prevent recursive loop |
|
74 | - return ''; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * return parsed list of datetimes for an event |
|
80 | - * |
|
81 | - * @return string |
|
82 | - * @throws EE_Error |
|
83 | - * @throws ReflectionException |
|
84 | - */ |
|
85 | - private function _get_datetime_list_for_event() |
|
86 | - { |
|
87 | - $event = $this->_data['data']; |
|
88 | - $valid_shortcodes = ['datetime', 'attendee']; |
|
89 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
90 | - ? $this->_data['template']['datetime_list'] |
|
91 | - : $this->_extra_data['template']['datetime_list']; |
|
92 | - |
|
93 | - // here we're setting up the datetimes for the datetime list template for THIS event. |
|
94 | - $dtt_parsed = ''; |
|
95 | - $datetimes = $this->_get_datetimes_from_event($event); |
|
96 | - |
|
97 | - // each datetime in this case should be an datetime object. |
|
98 | - foreach ($datetimes as $datetime) { |
|
99 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
100 | - $template, |
|
101 | - $datetime, |
|
102 | - $valid_shortcodes, |
|
103 | - $this->_extra_data |
|
104 | - ); |
|
105 | - } |
|
106 | - |
|
107 | - return $dtt_parsed; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * return parsed list of datetimes for an ticket |
|
113 | - * |
|
114 | - * @return string |
|
115 | - * @throws EE_Error |
|
116 | - */ |
|
117 | - private function _get_datetime_list_for_ticket() |
|
118 | - { |
|
119 | - $valid_shortcodes = ['datetime', 'attendee']; |
|
120 | - |
|
121 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
122 | - ? $this->_data['template']['datetime_list'] |
|
123 | - : $this->_extra_data['template']['datetime_list']; |
|
124 | - $ticket = $this->_data['data']; |
|
125 | - |
|
126 | - // here we're setting up the datetimes for the datetime list template for THIS ticket. |
|
127 | - $dtt_parsed = ''; |
|
128 | - $datetimes = $this->_get_datetimes_from_ticket($ticket); |
|
129 | - |
|
130 | - // each datetime in this case should be an datetime object. |
|
131 | - foreach ($datetimes as $datetime) { |
|
132 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
133 | - $template, |
|
134 | - $datetime, |
|
135 | - $valid_shortcodes, |
|
136 | - $this->_extra_data |
|
137 | - ); |
|
138 | - } |
|
139 | - |
|
140 | - return $dtt_parsed; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * return parsed list of datetimes from a given registration. |
|
146 | - * |
|
147 | - * @return string |
|
148 | - * @throws EE_Error |
|
149 | - * @throws EE_Error |
|
150 | - */ |
|
151 | - private function _get_datetime_list_for_registration() |
|
152 | - { |
|
153 | - $registration = $this->_data['data']->reg_obj; |
|
154 | - |
|
155 | - // now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket(); |
|
156 | - $this->_data['data'] = $registration->ticket(); |
|
157 | - return $this->_get_datetime_list_for_ticket(); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param EE_Event $event |
|
163 | - * @return array|mixed |
|
164 | - * @throws EE_Error |
|
165 | - * @throws ReflectionException |
|
166 | - */ |
|
167 | - private function _get_datetimes_from_event(EE_Event $event) |
|
168 | - { |
|
169 | - return isset($this->_extra_data['data']->events) |
|
170 | - ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
171 | - : []; |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * @param EE_Ticket $ticket |
|
177 | - * @return array|mixed |
|
178 | - * @throws EE_Error |
|
179 | - */ |
|
180 | - private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
|
181 | - { |
|
182 | - return isset($this->_extra_data['data']->tickets) |
|
183 | - ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
184 | - : []; |
|
185 | - } |
|
21 | + protected function _init_props() |
|
22 | + { |
|
23 | + $this->label = esc_html__('Datetime List Shortcodes', 'event_espresso'); |
|
24 | + $this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso'); |
|
25 | + $this->_shortcodes = [ |
|
26 | + '[DATETIME_LIST]' => esc_html__( |
|
27 | + 'Will output a list of datetimes according to the layout specified in the datetime list field.', |
|
28 | + 'event_espresso' |
|
29 | + ), |
|
30 | + ]; |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @param string $shortcode |
|
36 | + * @return string |
|
37 | + * @throws EE_Error |
|
38 | + * @throws ReflectionException |
|
39 | + */ |
|
40 | + protected function _parser($shortcode) |
|
41 | + { |
|
42 | + switch ($shortcode) { |
|
43 | + case '[DATETIME_LIST]': |
|
44 | + return $this->_get_datetime_list(); |
|
45 | + } |
|
46 | + return ''; |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * figure out what the incoming data is and then return the appropriate parsed value. |
|
52 | + * |
|
53 | + * @return string |
|
54 | + * @throws EE_Error |
|
55 | + * @throws ReflectionException |
|
56 | + */ |
|
57 | + private function _get_datetime_list() |
|
58 | + { |
|
59 | + $this->_validate_list_requirements(); |
|
60 | + |
|
61 | + if ($this->_data['data'] instanceof EE_Ticket) { |
|
62 | + return $this->_get_datetime_list_for_ticket(); |
|
63 | + } |
|
64 | + if ($this->_data['data'] instanceof EE_Event) { |
|
65 | + return $this->_get_datetime_list_for_event(); |
|
66 | + } |
|
67 | + if ( |
|
68 | + $this->_data['data'] instanceof EE_Messages_Addressee |
|
69 | + && $this->_data['data']->reg_obj instanceof EE_Registration |
|
70 | + ) { |
|
71 | + return $this->_get_datetime_list_for_registration(); |
|
72 | + } |
|
73 | + // prevent recursive loop |
|
74 | + return ''; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * return parsed list of datetimes for an event |
|
80 | + * |
|
81 | + * @return string |
|
82 | + * @throws EE_Error |
|
83 | + * @throws ReflectionException |
|
84 | + */ |
|
85 | + private function _get_datetime_list_for_event() |
|
86 | + { |
|
87 | + $event = $this->_data['data']; |
|
88 | + $valid_shortcodes = ['datetime', 'attendee']; |
|
89 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
90 | + ? $this->_data['template']['datetime_list'] |
|
91 | + : $this->_extra_data['template']['datetime_list']; |
|
92 | + |
|
93 | + // here we're setting up the datetimes for the datetime list template for THIS event. |
|
94 | + $dtt_parsed = ''; |
|
95 | + $datetimes = $this->_get_datetimes_from_event($event); |
|
96 | + |
|
97 | + // each datetime in this case should be an datetime object. |
|
98 | + foreach ($datetimes as $datetime) { |
|
99 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
100 | + $template, |
|
101 | + $datetime, |
|
102 | + $valid_shortcodes, |
|
103 | + $this->_extra_data |
|
104 | + ); |
|
105 | + } |
|
106 | + |
|
107 | + return $dtt_parsed; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * return parsed list of datetimes for an ticket |
|
113 | + * |
|
114 | + * @return string |
|
115 | + * @throws EE_Error |
|
116 | + */ |
|
117 | + private function _get_datetime_list_for_ticket() |
|
118 | + { |
|
119 | + $valid_shortcodes = ['datetime', 'attendee']; |
|
120 | + |
|
121 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
122 | + ? $this->_data['template']['datetime_list'] |
|
123 | + : $this->_extra_data['template']['datetime_list']; |
|
124 | + $ticket = $this->_data['data']; |
|
125 | + |
|
126 | + // here we're setting up the datetimes for the datetime list template for THIS ticket. |
|
127 | + $dtt_parsed = ''; |
|
128 | + $datetimes = $this->_get_datetimes_from_ticket($ticket); |
|
129 | + |
|
130 | + // each datetime in this case should be an datetime object. |
|
131 | + foreach ($datetimes as $datetime) { |
|
132 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
133 | + $template, |
|
134 | + $datetime, |
|
135 | + $valid_shortcodes, |
|
136 | + $this->_extra_data |
|
137 | + ); |
|
138 | + } |
|
139 | + |
|
140 | + return $dtt_parsed; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * return parsed list of datetimes from a given registration. |
|
146 | + * |
|
147 | + * @return string |
|
148 | + * @throws EE_Error |
|
149 | + * @throws EE_Error |
|
150 | + */ |
|
151 | + private function _get_datetime_list_for_registration() |
|
152 | + { |
|
153 | + $registration = $this->_data['data']->reg_obj; |
|
154 | + |
|
155 | + // now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket(); |
|
156 | + $this->_data['data'] = $registration->ticket(); |
|
157 | + return $this->_get_datetime_list_for_ticket(); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param EE_Event $event |
|
163 | + * @return array|mixed |
|
164 | + * @throws EE_Error |
|
165 | + * @throws ReflectionException |
|
166 | + */ |
|
167 | + private function _get_datetimes_from_event(EE_Event $event) |
|
168 | + { |
|
169 | + return isset($this->_extra_data['data']->events) |
|
170 | + ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
171 | + : []; |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * @param EE_Ticket $ticket |
|
177 | + * @return array|mixed |
|
178 | + * @throws EE_Error |
|
179 | + */ |
|
180 | + private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
|
181 | + { |
|
182 | + return isset($this->_extra_data['data']->tickets) |
|
183 | + ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
184 | + : []; |
|
185 | + } |
|
186 | 186 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | private function _get_tickets_from_event(EE_Event $event) |
203 | 203 | { |
204 | 204 | return isset($this->_extra_data['data']->events) |
205 | - ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs'] |
|
205 | + ? $this->_extra_data['data']->events[$event->ID()]['tkt_objs'] |
|
206 | 206 | : []; |
207 | 207 | } |
208 | 208 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | private function _get_ticket_list_from_registration(EE_Registration $registration) |
217 | 217 | { |
218 | 218 | return isset($this->_extra_data['data']->registrations) |
219 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']] |
|
219 | + ? [$this->_extra_data['data']->registrations[$registration->ID()]['tkt_obj']] |
|
220 | 220 | : []; |
221 | 221 | } |
222 | 222 | } |
@@ -18,204 +18,204 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Ticket_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - protected function _init_props() |
|
22 | - { |
|
23 | - $this->label = esc_html__('Ticket List Shortcodes', 'event_espresso'); |
|
24 | - $this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso'); |
|
25 | - $this->_shortcodes = [ |
|
26 | - '[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'), |
|
27 | - ]; |
|
28 | - } |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @param string $shortcode |
|
33 | - * @return string |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - protected function _parser($shortcode) |
|
38 | - { |
|
39 | - switch ($shortcode) { |
|
40 | - case '[TICKET_LIST]': |
|
41 | - return $this->_get_ticket_list(); |
|
42 | - } |
|
43 | - return ''; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * figure out what the incoming data is and then return the appropriate parsed value. |
|
49 | - * |
|
50 | - * @return string |
|
51 | - * @throws EE_Error |
|
52 | - * @throws ReflectionException |
|
53 | - */ |
|
54 | - private function _get_ticket_list() |
|
55 | - { |
|
56 | - $this->_validate_list_requirements(); |
|
57 | - |
|
58 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
59 | - return $this->_get_ticket_list_for_main(); |
|
60 | - } |
|
61 | - if ($this->_data['data'] instanceof EE_Registration) { |
|
62 | - return $this->_get_ticket_list_for_attendee(); |
|
63 | - } |
|
64 | - if ($this->_data['data'] instanceof EE_Event) { |
|
65 | - return $this->_get_ticket_list_for_event(); |
|
66 | - } |
|
67 | - // prevent recursive loop |
|
68 | - return ''; |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * This returns the parsed ticket list for main template; |
|
74 | - */ |
|
75 | - private function _get_ticket_list_for_main() |
|
76 | - { |
|
77 | - $valid_shortcodes = [ |
|
78 | - 'ticket', |
|
79 | - 'event_list', |
|
80 | - 'attendee_list', |
|
81 | - 'datetime_list', |
|
82 | - 'attendee', |
|
83 | - 'line_item_list', |
|
84 | - 'primary_registration_details', |
|
85 | - 'recipient_details', |
|
86 | - ]; |
|
87 | - $template = $this->_data['template']; |
|
88 | - $data = $this->_data['data']; |
|
89 | - $ticket_list = ''; |
|
90 | - |
|
91 | - |
|
92 | - // now we need to loop through the ticket list and send data to the EE_Parser helper. |
|
93 | - foreach ($data->tickets as $ticket) { |
|
94 | - $ticket_list .= $this->_shortcode_helper->parse_ticket_list_template( |
|
95 | - $template, |
|
96 | - $ticket['ticket'], |
|
97 | - $valid_shortcodes, |
|
98 | - $this->_extra_data |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - return $ticket_list; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * return parsed list of tickets for an event |
|
108 | - * |
|
109 | - * @return string |
|
110 | - * @throws EE_Error |
|
111 | - * @throws ReflectionException |
|
112 | - */ |
|
113 | - private function _get_ticket_list_for_event() |
|
114 | - { |
|
115 | - $valid_shortcodes = [ |
|
116 | - 'ticket', |
|
117 | - 'attendee_list', |
|
118 | - 'datetime_list', |
|
119 | - 'attendee', |
|
120 | - 'venue', |
|
121 | - 'line_item_list', |
|
122 | - 'primary_registration_details', |
|
123 | - 'recipient_details', |
|
124 | - ]; |
|
125 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
126 | - ? $this->_data['template']['ticket_list'] |
|
127 | - : $this->_extra_data['template']['ticket_list']; |
|
128 | - $event = $this->_data['data']; |
|
129 | - |
|
130 | - // let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion. |
|
131 | - $template = str_replace('[EVENT_LIST]', '', $template); |
|
132 | - |
|
133 | - // here we're setting up the tickets for the ticket list template for THIS event. |
|
134 | - $tkt_parsed = ''; |
|
135 | - $tickets = $this->_get_tickets_from_event($event); |
|
136 | - |
|
137 | - // each ticket in this case should be an ticket object. |
|
138 | - foreach ($tickets as $ticket) { |
|
139 | - $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
140 | - $template, |
|
141 | - $ticket, |
|
142 | - $valid_shortcodes, |
|
143 | - $this->_extra_data |
|
144 | - ); |
|
145 | - } |
|
146 | - |
|
147 | - return $tkt_parsed; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * return parsed list of tickets for an attendee |
|
153 | - * |
|
154 | - * @return string |
|
155 | - * @throws EE_Error |
|
156 | - * @throws ReflectionException |
|
157 | - */ |
|
158 | - private function _get_ticket_list_for_attendee() |
|
159 | - { |
|
160 | - $valid_shortcodes = [ |
|
161 | - 'ticket', |
|
162 | - 'event_list', |
|
163 | - 'datetime_list', |
|
164 | - 'attendee', |
|
165 | - 'primary_registration_details', |
|
166 | - 'recipient_details', |
|
167 | - ]; |
|
168 | - |
|
169 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
170 | - ? $this->_data['template']['ticket_list'] |
|
171 | - : $this->_extra_data['template']['ticket_list']; |
|
172 | - $registration = $this->_data['data']; |
|
173 | - |
|
174 | - // let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
175 | - $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
176 | - |
|
177 | - // here we're setting up the tickets for the ticket list template for THIS attendee. |
|
178 | - $tkt_parsed = ''; |
|
179 | - $tickets = $this->_get_ticket_list_from_registration($registration); |
|
180 | - |
|
181 | - // each ticket in this case should be an ticket object. |
|
182 | - foreach ($tickets as $ticket) { |
|
183 | - $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
184 | - $template, |
|
185 | - $ticket, |
|
186 | - $valid_shortcodes, |
|
187 | - $this->_extra_data |
|
188 | - ); |
|
189 | - } |
|
190 | - |
|
191 | - return $tkt_parsed; |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * @param EE_Event $event |
|
197 | - * @return array|mixed |
|
198 | - * @throws EE_Error |
|
199 | - * @throws ReflectionException |
|
200 | - */ |
|
201 | - private function _get_tickets_from_event(EE_Event $event) |
|
202 | - { |
|
203 | - return isset($this->_extra_data['data']->events) |
|
204 | - ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs'] |
|
205 | - : []; |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * @param EE_Registration $registration |
|
211 | - * @return array |
|
212 | - * @throws EE_Error |
|
213 | - * @throws ReflectionException |
|
214 | - */ |
|
215 | - private function _get_ticket_list_from_registration(EE_Registration $registration) |
|
216 | - { |
|
217 | - return isset($this->_extra_data['data']->registrations) |
|
218 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']] |
|
219 | - : []; |
|
220 | - } |
|
21 | + protected function _init_props() |
|
22 | + { |
|
23 | + $this->label = esc_html__('Ticket List Shortcodes', 'event_espresso'); |
|
24 | + $this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso'); |
|
25 | + $this->_shortcodes = [ |
|
26 | + '[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'), |
|
27 | + ]; |
|
28 | + } |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @param string $shortcode |
|
33 | + * @return string |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + protected function _parser($shortcode) |
|
38 | + { |
|
39 | + switch ($shortcode) { |
|
40 | + case '[TICKET_LIST]': |
|
41 | + return $this->_get_ticket_list(); |
|
42 | + } |
|
43 | + return ''; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * figure out what the incoming data is and then return the appropriate parsed value. |
|
49 | + * |
|
50 | + * @return string |
|
51 | + * @throws EE_Error |
|
52 | + * @throws ReflectionException |
|
53 | + */ |
|
54 | + private function _get_ticket_list() |
|
55 | + { |
|
56 | + $this->_validate_list_requirements(); |
|
57 | + |
|
58 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
59 | + return $this->_get_ticket_list_for_main(); |
|
60 | + } |
|
61 | + if ($this->_data['data'] instanceof EE_Registration) { |
|
62 | + return $this->_get_ticket_list_for_attendee(); |
|
63 | + } |
|
64 | + if ($this->_data['data'] instanceof EE_Event) { |
|
65 | + return $this->_get_ticket_list_for_event(); |
|
66 | + } |
|
67 | + // prevent recursive loop |
|
68 | + return ''; |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * This returns the parsed ticket list for main template; |
|
74 | + */ |
|
75 | + private function _get_ticket_list_for_main() |
|
76 | + { |
|
77 | + $valid_shortcodes = [ |
|
78 | + 'ticket', |
|
79 | + 'event_list', |
|
80 | + 'attendee_list', |
|
81 | + 'datetime_list', |
|
82 | + 'attendee', |
|
83 | + 'line_item_list', |
|
84 | + 'primary_registration_details', |
|
85 | + 'recipient_details', |
|
86 | + ]; |
|
87 | + $template = $this->_data['template']; |
|
88 | + $data = $this->_data['data']; |
|
89 | + $ticket_list = ''; |
|
90 | + |
|
91 | + |
|
92 | + // now we need to loop through the ticket list and send data to the EE_Parser helper. |
|
93 | + foreach ($data->tickets as $ticket) { |
|
94 | + $ticket_list .= $this->_shortcode_helper->parse_ticket_list_template( |
|
95 | + $template, |
|
96 | + $ticket['ticket'], |
|
97 | + $valid_shortcodes, |
|
98 | + $this->_extra_data |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + return $ticket_list; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * return parsed list of tickets for an event |
|
108 | + * |
|
109 | + * @return string |
|
110 | + * @throws EE_Error |
|
111 | + * @throws ReflectionException |
|
112 | + */ |
|
113 | + private function _get_ticket_list_for_event() |
|
114 | + { |
|
115 | + $valid_shortcodes = [ |
|
116 | + 'ticket', |
|
117 | + 'attendee_list', |
|
118 | + 'datetime_list', |
|
119 | + 'attendee', |
|
120 | + 'venue', |
|
121 | + 'line_item_list', |
|
122 | + 'primary_registration_details', |
|
123 | + 'recipient_details', |
|
124 | + ]; |
|
125 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
126 | + ? $this->_data['template']['ticket_list'] |
|
127 | + : $this->_extra_data['template']['ticket_list']; |
|
128 | + $event = $this->_data['data']; |
|
129 | + |
|
130 | + // let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion. |
|
131 | + $template = str_replace('[EVENT_LIST]', '', $template); |
|
132 | + |
|
133 | + // here we're setting up the tickets for the ticket list template for THIS event. |
|
134 | + $tkt_parsed = ''; |
|
135 | + $tickets = $this->_get_tickets_from_event($event); |
|
136 | + |
|
137 | + // each ticket in this case should be an ticket object. |
|
138 | + foreach ($tickets as $ticket) { |
|
139 | + $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
140 | + $template, |
|
141 | + $ticket, |
|
142 | + $valid_shortcodes, |
|
143 | + $this->_extra_data |
|
144 | + ); |
|
145 | + } |
|
146 | + |
|
147 | + return $tkt_parsed; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * return parsed list of tickets for an attendee |
|
153 | + * |
|
154 | + * @return string |
|
155 | + * @throws EE_Error |
|
156 | + * @throws ReflectionException |
|
157 | + */ |
|
158 | + private function _get_ticket_list_for_attendee() |
|
159 | + { |
|
160 | + $valid_shortcodes = [ |
|
161 | + 'ticket', |
|
162 | + 'event_list', |
|
163 | + 'datetime_list', |
|
164 | + 'attendee', |
|
165 | + 'primary_registration_details', |
|
166 | + 'recipient_details', |
|
167 | + ]; |
|
168 | + |
|
169 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
170 | + ? $this->_data['template']['ticket_list'] |
|
171 | + : $this->_extra_data['template']['ticket_list']; |
|
172 | + $registration = $this->_data['data']; |
|
173 | + |
|
174 | + // let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
175 | + $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
176 | + |
|
177 | + // here we're setting up the tickets for the ticket list template for THIS attendee. |
|
178 | + $tkt_parsed = ''; |
|
179 | + $tickets = $this->_get_ticket_list_from_registration($registration); |
|
180 | + |
|
181 | + // each ticket in this case should be an ticket object. |
|
182 | + foreach ($tickets as $ticket) { |
|
183 | + $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
184 | + $template, |
|
185 | + $ticket, |
|
186 | + $valid_shortcodes, |
|
187 | + $this->_extra_data |
|
188 | + ); |
|
189 | + } |
|
190 | + |
|
191 | + return $tkt_parsed; |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * @param EE_Event $event |
|
197 | + * @return array|mixed |
|
198 | + * @throws EE_Error |
|
199 | + * @throws ReflectionException |
|
200 | + */ |
|
201 | + private function _get_tickets_from_event(EE_Event $event) |
|
202 | + { |
|
203 | + return isset($this->_extra_data['data']->events) |
|
204 | + ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs'] |
|
205 | + : []; |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * @param EE_Registration $registration |
|
211 | + * @return array |
|
212 | + * @throws EE_Error |
|
213 | + * @throws ReflectionException |
|
214 | + */ |
|
215 | + private function _get_ticket_list_from_registration(EE_Registration $registration) |
|
216 | + { |
|
217 | + return isset($this->_extra_data['data']->registrations) |
|
218 | + ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']] |
|
219 | + : []; |
|
220 | + } |
|
221 | 221 | } |
@@ -163,7 +163,7 @@ |
||
163 | 163 | private function _get_events_from_registration(EE_Registration $registration) |
164 | 164 | { |
165 | 165 | return isset($this->_extra_data['data']->registrations) |
166 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']] |
|
166 | + ? [$this->_extra_data['data']->registrations[$registration->ID()]['evt_obj']] |
|
167 | 167 | : []; |
168 | 168 | } |
169 | 169 | } |
@@ -18,156 +18,156 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Event_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - public function __construct() |
|
22 | - { |
|
23 | - parent::__construct(); |
|
24 | - } |
|
25 | - |
|
26 | - |
|
27 | - protected function _init_props() |
|
28 | - { |
|
29 | - $this->label = esc_html__('Event List Shortcodes', 'event_espresso'); |
|
30 | - $this->description = esc_html__('All shortcodes specific to event lists', 'event_espresso'); |
|
31 | - $this->_shortcodes = [ |
|
32 | - '[EVENT_LIST]' => esc_html__('Will output a list of events', 'event_espresso'), |
|
33 | - ]; |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @param string $shortcode |
|
39 | - * @return string |
|
40 | - * @throws EE_Error |
|
41 | - * @throws ReflectionException |
|
42 | - */ |
|
43 | - protected function _parser($shortcode) |
|
44 | - { |
|
45 | - switch ($shortcode) { |
|
46 | - case '[EVENT_LIST]': |
|
47 | - return $this->_get_event_list(); |
|
48 | - } |
|
49 | - return ''; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * figure out what the incoming data is and then return the appropriate parsed value. |
|
55 | - * |
|
56 | - * @return string |
|
57 | - * @throws EE_Error |
|
58 | - * @throws ReflectionException |
|
59 | - */ |
|
60 | - private function _get_event_list() |
|
61 | - { |
|
62 | - $this->_validate_list_requirements(); |
|
63 | - |
|
64 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
65 | - return $this->_get_event_list_for_main(); |
|
66 | - } |
|
67 | - if ($this->_data['data'] instanceof EE_Registration) { |
|
68 | - return $this->_get_event_list_for_registration(); |
|
69 | - } |
|
70 | - // prevent recursive loop |
|
71 | - return ''; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * This returns the parsed event list for main template |
|
77 | - * |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - private function _get_event_list_for_main() |
|
81 | - { |
|
82 | - |
|
83 | - $valid_shortcodes = [ |
|
84 | - 'event', |
|
85 | - 'attendee_list', |
|
86 | - 'ticket_list', |
|
87 | - 'datetime_list', |
|
88 | - 'venue', |
|
89 | - 'attendee', |
|
90 | - 'recipient_list', |
|
91 | - 'recipient_details', |
|
92 | - 'primary_registration_list', |
|
93 | - 'primary_registration_details', |
|
94 | - 'event_author', |
|
95 | - 'organization', |
|
96 | - ]; |
|
97 | - $template = $this->_data['template']; |
|
98 | - $data = $this->_data['data']; |
|
99 | - $events = ''; |
|
100 | - |
|
101 | - // now we need to loop through the events array in EE_Messages_Addressee and send data to the EE_Parser helper. |
|
102 | - foreach ($data->events as $event) { |
|
103 | - $events .= $this->_shortcode_helper->parse_event_list_template( |
|
104 | - $template, |
|
105 | - $event['event'], |
|
106 | - $valid_shortcodes, |
|
107 | - $this->_extra_data |
|
108 | - ); |
|
109 | - } |
|
110 | - return $events; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * This returns the parsed event list for an attendee |
|
116 | - * |
|
117 | - * @return string |
|
118 | - * @throws EE_Error |
|
119 | - * @throws ReflectionException |
|
120 | - */ |
|
121 | - private function _get_event_list_for_registration() |
|
122 | - { |
|
123 | - $valid_shortcodes = [ |
|
124 | - 'event', |
|
125 | - 'ticket_list', |
|
126 | - 'datetime_list', |
|
127 | - 'attendee', |
|
128 | - 'event_author', |
|
129 | - 'recipient_details', |
|
130 | - 'recipient_list', |
|
131 | - 'venue', |
|
132 | - 'organization', |
|
133 | - ]; |
|
134 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['event_list']) |
|
135 | - ? $this->_data['template']['event_list'] |
|
136 | - : $this->_extra_data['template']['event_list']; |
|
137 | - $registration = $this->_data['data']; |
|
138 | - |
|
139 | - // let's remove any existing [ATTENDEE_LIST] shortcode from the event list template so that we don't get recursion. |
|
140 | - $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
141 | - |
|
142 | - // here we're setting up the events for the event_list template for THIS registration. |
|
143 | - $all_events = $this->_get_events_from_registration($registration); |
|
144 | - |
|
145 | - // we're NOT going to prepare a list of attendees this time around |
|
146 | - $events = ''; |
|
147 | - |
|
148 | - foreach ($all_events as $event) { |
|
149 | - $events .= $this->_shortcode_helper->parse_event_list_template( |
|
150 | - $template, |
|
151 | - $event, |
|
152 | - $valid_shortcodes, |
|
153 | - $this->_extra_data |
|
154 | - ); |
|
155 | - } |
|
156 | - |
|
157 | - return $events; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param EE_Registration $registration |
|
163 | - * @return array |
|
164 | - * @throws EE_Error |
|
165 | - * @throws ReflectionException |
|
166 | - */ |
|
167 | - private function _get_events_from_registration(EE_Registration $registration) |
|
168 | - { |
|
169 | - return isset($this->_extra_data['data']->registrations) |
|
170 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']] |
|
171 | - : []; |
|
172 | - } |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct(); |
|
24 | + } |
|
25 | + |
|
26 | + |
|
27 | + protected function _init_props() |
|
28 | + { |
|
29 | + $this->label = esc_html__('Event List Shortcodes', 'event_espresso'); |
|
30 | + $this->description = esc_html__('All shortcodes specific to event lists', 'event_espresso'); |
|
31 | + $this->_shortcodes = [ |
|
32 | + '[EVENT_LIST]' => esc_html__('Will output a list of events', 'event_espresso'), |
|
33 | + ]; |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @param string $shortcode |
|
39 | + * @return string |
|
40 | + * @throws EE_Error |
|
41 | + * @throws ReflectionException |
|
42 | + */ |
|
43 | + protected function _parser($shortcode) |
|
44 | + { |
|
45 | + switch ($shortcode) { |
|
46 | + case '[EVENT_LIST]': |
|
47 | + return $this->_get_event_list(); |
|
48 | + } |
|
49 | + return ''; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * figure out what the incoming data is and then return the appropriate parsed value. |
|
55 | + * |
|
56 | + * @return string |
|
57 | + * @throws EE_Error |
|
58 | + * @throws ReflectionException |
|
59 | + */ |
|
60 | + private function _get_event_list() |
|
61 | + { |
|
62 | + $this->_validate_list_requirements(); |
|
63 | + |
|
64 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
65 | + return $this->_get_event_list_for_main(); |
|
66 | + } |
|
67 | + if ($this->_data['data'] instanceof EE_Registration) { |
|
68 | + return $this->_get_event_list_for_registration(); |
|
69 | + } |
|
70 | + // prevent recursive loop |
|
71 | + return ''; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * This returns the parsed event list for main template |
|
77 | + * |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + private function _get_event_list_for_main() |
|
81 | + { |
|
82 | + |
|
83 | + $valid_shortcodes = [ |
|
84 | + 'event', |
|
85 | + 'attendee_list', |
|
86 | + 'ticket_list', |
|
87 | + 'datetime_list', |
|
88 | + 'venue', |
|
89 | + 'attendee', |
|
90 | + 'recipient_list', |
|
91 | + 'recipient_details', |
|
92 | + 'primary_registration_list', |
|
93 | + 'primary_registration_details', |
|
94 | + 'event_author', |
|
95 | + 'organization', |
|
96 | + ]; |
|
97 | + $template = $this->_data['template']; |
|
98 | + $data = $this->_data['data']; |
|
99 | + $events = ''; |
|
100 | + |
|
101 | + // now we need to loop through the events array in EE_Messages_Addressee and send data to the EE_Parser helper. |
|
102 | + foreach ($data->events as $event) { |
|
103 | + $events .= $this->_shortcode_helper->parse_event_list_template( |
|
104 | + $template, |
|
105 | + $event['event'], |
|
106 | + $valid_shortcodes, |
|
107 | + $this->_extra_data |
|
108 | + ); |
|
109 | + } |
|
110 | + return $events; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * This returns the parsed event list for an attendee |
|
116 | + * |
|
117 | + * @return string |
|
118 | + * @throws EE_Error |
|
119 | + * @throws ReflectionException |
|
120 | + */ |
|
121 | + private function _get_event_list_for_registration() |
|
122 | + { |
|
123 | + $valid_shortcodes = [ |
|
124 | + 'event', |
|
125 | + 'ticket_list', |
|
126 | + 'datetime_list', |
|
127 | + 'attendee', |
|
128 | + 'event_author', |
|
129 | + 'recipient_details', |
|
130 | + 'recipient_list', |
|
131 | + 'venue', |
|
132 | + 'organization', |
|
133 | + ]; |
|
134 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['event_list']) |
|
135 | + ? $this->_data['template']['event_list'] |
|
136 | + : $this->_extra_data['template']['event_list']; |
|
137 | + $registration = $this->_data['data']; |
|
138 | + |
|
139 | + // let's remove any existing [ATTENDEE_LIST] shortcode from the event list template so that we don't get recursion. |
|
140 | + $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
141 | + |
|
142 | + // here we're setting up the events for the event_list template for THIS registration. |
|
143 | + $all_events = $this->_get_events_from_registration($registration); |
|
144 | + |
|
145 | + // we're NOT going to prepare a list of attendees this time around |
|
146 | + $events = ''; |
|
147 | + |
|
148 | + foreach ($all_events as $event) { |
|
149 | + $events .= $this->_shortcode_helper->parse_event_list_template( |
|
150 | + $template, |
|
151 | + $event, |
|
152 | + $valid_shortcodes, |
|
153 | + $this->_extra_data |
|
154 | + ); |
|
155 | + } |
|
156 | + |
|
157 | + return $events; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param EE_Registration $registration |
|
163 | + * @return array |
|
164 | + * @throws EE_Error |
|
165 | + * @throws ReflectionException |
|
166 | + */ |
|
167 | + private function _get_events_from_registration(EE_Registration $registration) |
|
168 | + { |
|
169 | + return isset($this->_extra_data['data']->registrations) |
|
170 | + ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']] |
|
171 | + : []; |
|
172 | + } |
|
173 | 173 | } |
@@ -1,17 +1,17 @@ discard block |
||
1 | 1 | <div class="padding"> |
2 | 2 | <p> |
3 | 3 | <?php |
4 | - printf( |
|
5 | - esc_html__( |
|
6 | - 'Upgrade to an %1$sEvent Espresso 4 support license%2$s to get access to dedicated support staff and premium features, such as a calendar, printable tickets and check-in capabilities, MailChimp integration, and more!', |
|
7 | - 'event_espresso' |
|
8 | - ), |
|
9 | - '<a |
|
4 | + printf( |
|
5 | + esc_html__( |
|
6 | + 'Upgrade to an %1$sEvent Espresso 4 support license%2$s to get access to dedicated support staff and premium features, such as a calendar, printable tickets and check-in capabilities, MailChimp integration, and more!', |
|
7 | + 'event_espresso' |
|
8 | + ), |
|
9 | + '<a |
|
10 | 10 | href="https://eventespresso.com/pricing/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=link" |
11 | 11 | target="_blank">', |
12 | - '</a>' |
|
13 | - ); |
|
14 | - ?> |
|
12 | + '</a>' |
|
13 | + ); |
|
14 | + ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <a href='https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=banner' |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | </p> |
24 | 24 | <p> |
25 | 25 | <?php |
26 | - printf( |
|
27 | - esc_html__( |
|
28 | - 'Visit %1$sEvent Espresso%2$s for more details.', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - '<a |
|
26 | + printf( |
|
27 | + esc_html__( |
|
28 | + 'Visit %1$sEvent Espresso%2$s for more details.', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + '<a |
|
32 | 32 | href="https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=link" |
33 | 33 | target="_blank">', |
34 | - '</a>' |
|
35 | - ); |
|
36 | - ?> |
|
34 | + '</a>' |
|
35 | + ); |
|
36 | + ?> |
|
37 | 37 | </p> |
38 | 38 | </div> |
@@ -17,7 +17,7 @@ |
||
17 | 17 | <a href='https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=banner' |
18 | 18 | target='_blank'> |
19 | 19 | <img alt="<?php esc_html_e('manage events faster', 'event_espresso'); ?>" |
20 | - src="<?php echo esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/manage-events-faster-240x240.jpg'); ?>" |
|
20 | + src="<?php echo esc_url_raw(EE_GLOBAL_ASSETS_URL.'images/manage-events-faster-240x240.jpg'); ?>" |
|
21 | 21 | /> |
22 | 22 | </a> |
23 | 23 | </p> |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | 'table_alias' => $field_obj->get_table_alias(), |
84 | 84 | 'table_column' => $field_obj->get_table_column(), |
85 | 85 | ); |
86 | - $fields_json[ $field_json['name'] ] = $field_json; |
|
86 | + $fields_json[$field_json['name']] = $field_json; |
|
87 | 87 | } |
88 | 88 | $fields_json = array_merge( |
89 | 89 | $fields_json, |
90 | 90 | $this->getModelVersionInfo()->extraResourcePropertiesForModel($model) |
91 | 91 | ); |
92 | - $response[ $model_name ]['fields'] = apply_filters( |
|
92 | + $response[$model_name]['fields'] = apply_filters( |
|
93 | 93 | 'FHEE__Meta__handle_request_models_meta__fields', |
94 | 94 | $fields_json, |
95 | 95 | $model |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | 'type' => str_replace('EE_', '', get_class($relation_obj)), |
102 | 102 | 'single' => $relation_obj instanceof EE_Belongs_To_Relation, |
103 | 103 | ); |
104 | - $relations_json[ $relation_name ] = $relation_json; |
|
104 | + $relations_json[$relation_name] = $relation_json; |
|
105 | 105 | } |
106 | - $response[ $model_name ]['relations'] = apply_filters( |
|
106 | + $response[$model_name]['relations'] = apply_filters( |
|
107 | 107 | 'FHEE__Meta__handle_request_models_meta__relations', |
108 | 108 | $relations_json, |
109 | 109 | $model |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | 'name' => $addon->name(), |
129 | 129 | 'version' => $addon->version(), |
130 | 130 | ); |
131 | - $addons[ $addon_json['name'] ] = $addon_json; |
|
131 | + $addons[$addon_json['name']] = $addon_json; |
|
132 | 132 | } |
133 | 133 | $response_data['ee'] = array( |
134 | 134 | 'version' => EEM_System_Status::instance()->get_ee_version(), |
@@ -24,122 +24,122 @@ |
||
24 | 24 | */ |
25 | 25 | class Meta extends Base |
26 | 26 | { |
27 | - /** |
|
28 | - * @param WP_REST_Request $request |
|
29 | - * @param string $version |
|
30 | - * @return array|WP_REST_Response |
|
31 | - */ |
|
32 | - public static function handleRequestModelsMeta(WP_REST_Request $request, $version) |
|
33 | - { |
|
34 | - $controller = new Meta(); |
|
35 | - try { |
|
36 | - $controller->setRequestedVersion($version); |
|
37 | - return $controller->sendResponse($controller->getModelsMetadataEntity()); |
|
38 | - } catch (Exception $e) { |
|
39 | - return $controller->sendResponse($e); |
|
40 | - } |
|
41 | - } |
|
27 | + /** |
|
28 | + * @param WP_REST_Request $request |
|
29 | + * @param string $version |
|
30 | + * @return array|WP_REST_Response |
|
31 | + */ |
|
32 | + public static function handleRequestModelsMeta(WP_REST_Request $request, $version) |
|
33 | + { |
|
34 | + $controller = new Meta(); |
|
35 | + try { |
|
36 | + $controller->setRequestedVersion($version); |
|
37 | + return $controller->sendResponse($controller->getModelsMetadataEntity()); |
|
38 | + } catch (Exception $e) { |
|
39 | + return $controller->sendResponse($e); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /* |
|
44 | + /* |
|
45 | 45 | * Gets the model metadata resource entity |
46 | 46 | * @return array for JSON response, describing all the models available in teh requested version |
47 | 47 | */ |
48 | - protected function getModelsMetadataEntity() |
|
49 | - { |
|
50 | - $response = array(); |
|
51 | - foreach ($this->getModelVersionInfo()->modelsForRequestedVersion() as $model_name => $model_classname) { |
|
52 | - $model = $this->getModelVersionInfo()->loadModel($model_name); |
|
53 | - $fields_json = array(); |
|
54 | - foreach ($this->getModelVersionInfo()->fieldsOnModelInThisVersion($model) as $field_name => $field_obj) { |
|
55 | - if ($this->getModelVersionInfo()->fieldIsIgnored($field_obj)) { |
|
56 | - continue; |
|
57 | - } |
|
58 | - if ($field_obj instanceof EE_Boolean_Field) { |
|
59 | - $datatype = 'Boolean'; |
|
60 | - } elseif ($field_obj->get_wpdb_data_type() == '%d') { |
|
61 | - $datatype = 'Number'; |
|
62 | - } elseif ($field_name instanceof EE_Serialized_Text_Field) { |
|
63 | - $datatype = 'Object'; |
|
64 | - } else { |
|
65 | - $datatype = 'String'; |
|
66 | - } |
|
67 | - $default_value = ModelDataTranslator::prepareFieldValueForJson( |
|
68 | - $field_obj, |
|
69 | - $field_obj->get_default_value(), |
|
70 | - $this->getModelVersionInfo()->requestedVersion() |
|
71 | - ); |
|
72 | - $field_json = array( |
|
73 | - 'name' => $field_name, |
|
74 | - 'nicename' => wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES), |
|
75 | - 'has_rendered_format' => $this->getModelVersionInfo()->fieldHasRenderedFormat($field_obj), |
|
76 | - 'has_pretty_format' => $this->getModelVersionInfo()->fieldHasPrettyFormat($field_obj), |
|
77 | - 'type' => str_replace('EE_', '', get_class($field_obj)), |
|
78 | - 'datatype' => $datatype, |
|
79 | - 'nullable' => $field_obj->is_nullable(), |
|
80 | - 'default' => $default_value, |
|
81 | - 'table_alias' => $field_obj->get_table_alias(), |
|
82 | - 'table_column' => $field_obj->get_table_column(), |
|
83 | - ); |
|
84 | - $fields_json[ $field_json['name'] ] = $field_json; |
|
85 | - } |
|
86 | - $fields_json = array_merge( |
|
87 | - $fields_json, |
|
88 | - $this->getModelVersionInfo()->extraResourcePropertiesForModel($model) |
|
89 | - ); |
|
90 | - $response[ $model_name ]['fields'] = apply_filters( |
|
91 | - 'FHEE__Meta__handle_request_models_meta__fields', |
|
92 | - $fields_json, |
|
93 | - $model |
|
94 | - ); |
|
95 | - $relations_json = array(); |
|
96 | - foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
97 | - $relation_json = array( |
|
98 | - 'name' => $relation_name, |
|
99 | - 'type' => str_replace('EE_', '', get_class($relation_obj)), |
|
100 | - 'single' => $relation_obj instanceof EE_Belongs_To_Relation, |
|
101 | - ); |
|
102 | - $relations_json[ $relation_name ] = $relation_json; |
|
103 | - } |
|
104 | - $response[ $model_name ]['relations'] = apply_filters( |
|
105 | - 'FHEE__Meta__handle_request_models_meta__relations', |
|
106 | - $relations_json, |
|
107 | - $model |
|
108 | - ); |
|
109 | - } |
|
110 | - return $response; |
|
111 | - } |
|
48 | + protected function getModelsMetadataEntity() |
|
49 | + { |
|
50 | + $response = array(); |
|
51 | + foreach ($this->getModelVersionInfo()->modelsForRequestedVersion() as $model_name => $model_classname) { |
|
52 | + $model = $this->getModelVersionInfo()->loadModel($model_name); |
|
53 | + $fields_json = array(); |
|
54 | + foreach ($this->getModelVersionInfo()->fieldsOnModelInThisVersion($model) as $field_name => $field_obj) { |
|
55 | + if ($this->getModelVersionInfo()->fieldIsIgnored($field_obj)) { |
|
56 | + continue; |
|
57 | + } |
|
58 | + if ($field_obj instanceof EE_Boolean_Field) { |
|
59 | + $datatype = 'Boolean'; |
|
60 | + } elseif ($field_obj->get_wpdb_data_type() == '%d') { |
|
61 | + $datatype = 'Number'; |
|
62 | + } elseif ($field_name instanceof EE_Serialized_Text_Field) { |
|
63 | + $datatype = 'Object'; |
|
64 | + } else { |
|
65 | + $datatype = 'String'; |
|
66 | + } |
|
67 | + $default_value = ModelDataTranslator::prepareFieldValueForJson( |
|
68 | + $field_obj, |
|
69 | + $field_obj->get_default_value(), |
|
70 | + $this->getModelVersionInfo()->requestedVersion() |
|
71 | + ); |
|
72 | + $field_json = array( |
|
73 | + 'name' => $field_name, |
|
74 | + 'nicename' => wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES), |
|
75 | + 'has_rendered_format' => $this->getModelVersionInfo()->fieldHasRenderedFormat($field_obj), |
|
76 | + 'has_pretty_format' => $this->getModelVersionInfo()->fieldHasPrettyFormat($field_obj), |
|
77 | + 'type' => str_replace('EE_', '', get_class($field_obj)), |
|
78 | + 'datatype' => $datatype, |
|
79 | + 'nullable' => $field_obj->is_nullable(), |
|
80 | + 'default' => $default_value, |
|
81 | + 'table_alias' => $field_obj->get_table_alias(), |
|
82 | + 'table_column' => $field_obj->get_table_column(), |
|
83 | + ); |
|
84 | + $fields_json[ $field_json['name'] ] = $field_json; |
|
85 | + } |
|
86 | + $fields_json = array_merge( |
|
87 | + $fields_json, |
|
88 | + $this->getModelVersionInfo()->extraResourcePropertiesForModel($model) |
|
89 | + ); |
|
90 | + $response[ $model_name ]['fields'] = apply_filters( |
|
91 | + 'FHEE__Meta__handle_request_models_meta__fields', |
|
92 | + $fields_json, |
|
93 | + $model |
|
94 | + ); |
|
95 | + $relations_json = array(); |
|
96 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
97 | + $relation_json = array( |
|
98 | + 'name' => $relation_name, |
|
99 | + 'type' => str_replace('EE_', '', get_class($relation_obj)), |
|
100 | + 'single' => $relation_obj instanceof EE_Belongs_To_Relation, |
|
101 | + ); |
|
102 | + $relations_json[ $relation_name ] = $relation_json; |
|
103 | + } |
|
104 | + $response[ $model_name ]['relations'] = apply_filters( |
|
105 | + 'FHEE__Meta__handle_request_models_meta__relations', |
|
106 | + $relations_json, |
|
107 | + $model |
|
108 | + ); |
|
109 | + } |
|
110 | + return $response; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * Adds EE metadata to the index |
|
116 | - * |
|
117 | - * @param WP_REST_Response $rest_response_obj |
|
118 | - * @return WP_REST_Response |
|
119 | - */ |
|
120 | - public static function filterEeMetadataIntoIndex(WP_REST_Response $rest_response_obj) |
|
121 | - { |
|
122 | - $response_data = $rest_response_obj->get_data(); |
|
123 | - $addons = array(); |
|
124 | - foreach (EE_Registry::instance()->addons as $addon) { |
|
125 | - $addon_json = array( |
|
126 | - 'name' => $addon->name(), |
|
127 | - 'version' => $addon->version(), |
|
128 | - ); |
|
129 | - $addons[ $addon_json['name'] ] = $addon_json; |
|
130 | - } |
|
131 | - $response_data['ee'] = array( |
|
132 | - 'version' => EEM_System_Status::instance()->get_ee_version(), |
|
133 | - // @codingStandardsIgnoreStart |
|
134 | - 'documentation_url' => 'https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API', |
|
135 | - // @codingStandardsIgnoreEnd |
|
136 | - 'addons' => $addons, |
|
137 | - 'maintenance_mode' => EE_Maintenance_Mode::instance()->real_level(), |
|
138 | - 'served_core_versions' => array_keys(EED_Core_Rest_Api::versions_served()), |
|
139 | - ); |
|
140 | - $rest_response_obj->set_data($response_data); |
|
141 | - return $rest_response_obj; |
|
142 | - } |
|
114 | + /** |
|
115 | + * Adds EE metadata to the index |
|
116 | + * |
|
117 | + * @param WP_REST_Response $rest_response_obj |
|
118 | + * @return WP_REST_Response |
|
119 | + */ |
|
120 | + public static function filterEeMetadataIntoIndex(WP_REST_Response $rest_response_obj) |
|
121 | + { |
|
122 | + $response_data = $rest_response_obj->get_data(); |
|
123 | + $addons = array(); |
|
124 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
125 | + $addon_json = array( |
|
126 | + 'name' => $addon->name(), |
|
127 | + 'version' => $addon->version(), |
|
128 | + ); |
|
129 | + $addons[ $addon_json['name'] ] = $addon_json; |
|
130 | + } |
|
131 | + $response_data['ee'] = array( |
|
132 | + 'version' => EEM_System_Status::instance()->get_ee_version(), |
|
133 | + // @codingStandardsIgnoreStart |
|
134 | + 'documentation_url' => 'https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API', |
|
135 | + // @codingStandardsIgnoreEnd |
|
136 | + 'addons' => $addons, |
|
137 | + 'maintenance_mode' => EE_Maintenance_Mode::instance()->real_level(), |
|
138 | + 'served_core_versions' => array_keys(EED_Core_Rest_Api::versions_served()), |
|
139 | + ); |
|
140 | + $rest_response_obj->set_data($response_data); |
|
141 | + return $rest_response_obj; |
|
142 | + } |
|
143 | 143 | } |
144 | 144 | |
145 | 145 |