@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
42 | 42 | { |
43 | - if (! isset($arguments[0], $arguments[1])) { |
|
43 | + if ( ! isset($arguments[0], $arguments[1])) { |
|
44 | 44 | throw new InvalidArgumentException( |
45 | 45 | esc_html__( |
46 | 46 | 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | ); |
50 | 50 | } |
51 | 51 | $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
52 | - if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
52 | + if ( ! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
53 | 53 | throw new DomainException( |
54 | 54 | sprintf( |
55 | 55 | esc_html__( |
@@ -28,63 +28,63 @@ |
||
28 | 28 | class DomainFactory |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
33 | - * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
34 | - * constructor. Must at least include the following two value objects: |
|
35 | - * array( |
|
36 | - * EventEspresso\core\domain\values\FilePath $plugin_file |
|
37 | - * EventEspresso\core\domain\values\Version $version |
|
38 | - * ) |
|
39 | - * @return mixed |
|
40 | - * @throws DomainException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidDataTypeException |
|
43 | - * @throws InvalidInterfaceException |
|
44 | - */ |
|
45 | - public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
|
46 | - { |
|
47 | - if (! isset($arguments[0], $arguments[1])) { |
|
48 | - throw new InvalidArgumentException( |
|
49 | - esc_html__( |
|
50 | - 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
51 | - 'event_espresso' |
|
52 | - ) |
|
53 | - ); |
|
54 | - } |
|
55 | - $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
|
56 | - if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
57 | - throw new DomainException( |
|
58 | - sprintf( |
|
59 | - esc_html__( |
|
60 | - 'The requested Domain class "%1$s" could not be loaded.', |
|
61 | - 'event_espresso' |
|
62 | - ), |
|
63 | - $domain_fqcn |
|
64 | - ) |
|
65 | - ); |
|
66 | - } |
|
67 | - return $domain; |
|
68 | - } |
|
31 | + /** |
|
32 | + * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
33 | + * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
34 | + * constructor. Must at least include the following two value objects: |
|
35 | + * array( |
|
36 | + * EventEspresso\core\domain\values\FilePath $plugin_file |
|
37 | + * EventEspresso\core\domain\values\Version $version |
|
38 | + * ) |
|
39 | + * @return mixed |
|
40 | + * @throws DomainException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidDataTypeException |
|
43 | + * @throws InvalidInterfaceException |
|
44 | + */ |
|
45 | + public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
|
46 | + { |
|
47 | + if (! isset($arguments[0], $arguments[1])) { |
|
48 | + throw new InvalidArgumentException( |
|
49 | + esc_html__( |
|
50 | + 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
51 | + 'event_espresso' |
|
52 | + ) |
|
53 | + ); |
|
54 | + } |
|
55 | + $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
|
56 | + if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
57 | + throw new DomainException( |
|
58 | + sprintf( |
|
59 | + esc_html__( |
|
60 | + 'The requested Domain class "%1$s" could not be loaded.', |
|
61 | + 'event_espresso' |
|
62 | + ), |
|
63 | + $domain_fqcn |
|
64 | + ) |
|
65 | + ); |
|
66 | + } |
|
67 | + return $domain; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @return Domain |
|
73 | - * @throws DomainException |
|
74 | - * @throws InvalidArgumentException |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidFilePathException |
|
77 | - * @throws InvalidInterfaceException |
|
78 | - */ |
|
79 | - public static function getEventEspressoCoreDomain() |
|
80 | - { |
|
81 | - $domain = new Domain( |
|
82 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
83 | - Version::fromString(espresso_version()) |
|
84 | - ); |
|
85 | - LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain); |
|
86 | - return $domain; |
|
87 | - } |
|
71 | + /** |
|
72 | + * @return Domain |
|
73 | + * @throws DomainException |
|
74 | + * @throws InvalidArgumentException |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidFilePathException |
|
77 | + * @throws InvalidInterfaceException |
|
78 | + */ |
|
79 | + public static function getEventEspressoCoreDomain() |
|
80 | + { |
|
81 | + $domain = new Domain( |
|
82 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
83 | + Version::fromString(espresso_version()) |
|
84 | + ); |
|
85 | + LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain); |
|
86 | + return $domain; |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | |
90 | 90 |
@@ -20,42 +20,42 @@ |
||
20 | 20 | class FilePath |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var string file_path |
|
25 | - */ |
|
26 | - private $file_path; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * FilePath constructor. |
|
31 | - * |
|
32 | - * @param string $file_path |
|
33 | - * @throws InvalidDataTypeException |
|
34 | - * @throws InvalidFilePathException |
|
35 | - */ |
|
36 | - public function __construct($file_path) |
|
37 | - { |
|
38 | - if (! is_string($file_path)) { |
|
39 | - throw new InvalidDataTypeException( |
|
40 | - '$file_path', |
|
41 | - $file_path, |
|
42 | - 'string' |
|
43 | - ); |
|
44 | - } |
|
45 | - if (! is_readable($file_path)) { |
|
46 | - throw new InvalidFilePathException($file_path); |
|
47 | - } |
|
48 | - $this->file_path = $file_path; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function __toString() |
|
56 | - { |
|
57 | - return $this->file_path; |
|
58 | - } |
|
23 | + /** |
|
24 | + * @var string file_path |
|
25 | + */ |
|
26 | + private $file_path; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * FilePath constructor. |
|
31 | + * |
|
32 | + * @param string $file_path |
|
33 | + * @throws InvalidDataTypeException |
|
34 | + * @throws InvalidFilePathException |
|
35 | + */ |
|
36 | + public function __construct($file_path) |
|
37 | + { |
|
38 | + if (! is_string($file_path)) { |
|
39 | + throw new InvalidDataTypeException( |
|
40 | + '$file_path', |
|
41 | + $file_path, |
|
42 | + 'string' |
|
43 | + ); |
|
44 | + } |
|
45 | + if (! is_readable($file_path)) { |
|
46 | + throw new InvalidFilePathException($file_path); |
|
47 | + } |
|
48 | + $this->file_path = $file_path; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function __toString() |
|
56 | + { |
|
57 | + return $this->file_path; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | 61 | } |
@@ -35,14 +35,14 @@ |
||
35 | 35 | */ |
36 | 36 | public function __construct($file_path) |
37 | 37 | { |
38 | - if (! is_string($file_path)) { |
|
38 | + if ( ! is_string($file_path)) { |
|
39 | 39 | throw new InvalidDataTypeException( |
40 | 40 | '$file_path', |
41 | 41 | $file_path, |
42 | 42 | 'string' |
43 | 43 | ); |
44 | 44 | } |
45 | - if (! is_readable($file_path)) { |
|
45 | + if ( ! is_readable($file_path)) { |
|
46 | 46 | throw new InvalidFilePathException($file_path); |
47 | 47 | } |
48 | 48 | $this->file_path = $file_path; |
@@ -37,14 +37,14 @@ |
||
37 | 37 | */ |
38 | 38 | public function __construct($fully_qualified_name) |
39 | 39 | { |
40 | - if (! is_string($fully_qualified_name)) { |
|
40 | + if ( ! is_string($fully_qualified_name)) { |
|
41 | 41 | throw new InvalidDataTypeException( |
42 | 42 | '$fully_qualified_name', |
43 | 43 | $fully_qualified_name, |
44 | 44 | 'string' |
45 | 45 | ); |
46 | 46 | } |
47 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
47 | + if ( ! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
48 | 48 | if (strpos($fully_qualified_name, 'Interface') !== false) { |
49 | 49 | throw new InvalidInterfaceException($fully_qualified_name); |
50 | 50 | } |
@@ -21,54 +21,54 @@ |
||
21 | 21 | class FullyQualifiedName |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var string $fully_qualified_name |
|
26 | - */ |
|
27 | - private $fully_qualified_name; |
|
24 | + /** |
|
25 | + * @var string $fully_qualified_name |
|
26 | + */ |
|
27 | + private $fully_qualified_name; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * FullyQualifiedName constructor. |
|
32 | - * |
|
33 | - * @param string $fully_qualified_name |
|
34 | - * @throws InvalidClassException |
|
35 | - * @throws InvalidInterfaceException |
|
36 | - * @throws InvalidDataTypeException |
|
37 | - */ |
|
38 | - public function __construct($fully_qualified_name) |
|
39 | - { |
|
40 | - if (! is_string($fully_qualified_name)) { |
|
41 | - throw new InvalidDataTypeException( |
|
42 | - '$fully_qualified_name', |
|
43 | - $fully_qualified_name, |
|
44 | - 'string' |
|
45 | - ); |
|
46 | - } |
|
47 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
48 | - if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
49 | - throw new InvalidInterfaceException($fully_qualified_name); |
|
50 | - } |
|
51 | - throw new InvalidClassException($fully_qualified_name); |
|
52 | - } |
|
53 | - $this->fully_qualified_name = $fully_qualified_name; |
|
54 | - } |
|
30 | + /** |
|
31 | + * FullyQualifiedName constructor. |
|
32 | + * |
|
33 | + * @param string $fully_qualified_name |
|
34 | + * @throws InvalidClassException |
|
35 | + * @throws InvalidInterfaceException |
|
36 | + * @throws InvalidDataTypeException |
|
37 | + */ |
|
38 | + public function __construct($fully_qualified_name) |
|
39 | + { |
|
40 | + if (! is_string($fully_qualified_name)) { |
|
41 | + throw new InvalidDataTypeException( |
|
42 | + '$fully_qualified_name', |
|
43 | + $fully_qualified_name, |
|
44 | + 'string' |
|
45 | + ); |
|
46 | + } |
|
47 | + if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
48 | + if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
49 | + throw new InvalidInterfaceException($fully_qualified_name); |
|
50 | + } |
|
51 | + throw new InvalidClassException($fully_qualified_name); |
|
52 | + } |
|
53 | + $this->fully_qualified_name = $fully_qualified_name; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function string() |
|
61 | - { |
|
62 | - return $this->fully_qualified_name; |
|
63 | - } |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function string() |
|
61 | + { |
|
62 | + return $this->fully_qualified_name; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function __toString() |
|
70 | - { |
|
71 | - return $this->fully_qualified_name; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function __toString() |
|
70 | + { |
|
71 | + return $this->fully_qualified_name; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | } |
@@ -121,7 +121,7 @@ |
||
121 | 121 | |
122 | 122 | |
123 | 123 | /** |
124 | - * @return Version |
|
124 | + * @return string |
|
125 | 125 | */ |
126 | 126 | public function versionValueObject() |
127 | 127 | { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function distributionAssetsPath() |
138 | 138 | { |
139 | - return $this->pluginPath() . 'assets/dist/'; |
|
139 | + return $this->pluginPath().'assets/dist/'; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function distributionAssetsUrl() |
147 | 147 | { |
148 | - return $this->pluginUrl() . 'assets/dist/'; |
|
148 | + return $this->pluginUrl().'assets/dist/'; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 |
@@ -16,153 +16,153 @@ |
||
16 | 16 | abstract class DomainBase implements DomainInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Equivalent to `__FILE__` for main plugin file. |
|
21 | - * |
|
22 | - * @var FilePath |
|
23 | - */ |
|
24 | - private $plugin_file; |
|
25 | - |
|
26 | - /** |
|
27 | - * String indicating version for plugin |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - private $version; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var string $plugin_basename |
|
35 | - */ |
|
36 | - private $plugin_basename; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var string $plugin_path |
|
40 | - */ |
|
41 | - private $plugin_path; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var string $plugin_url |
|
45 | - */ |
|
46 | - private $plugin_url; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var string $asset_namespace |
|
50 | - */ |
|
51 | - private $asset_namespace; |
|
52 | - |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Initializes internal properties. |
|
57 | - * |
|
58 | - * @param FilePath $plugin_file |
|
59 | - * @param Version $version |
|
60 | - */ |
|
61 | - public function __construct(FilePath $plugin_file, Version $version) |
|
62 | - { |
|
63 | - $this->plugin_file = $plugin_file; |
|
64 | - $this->version = $version; |
|
65 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
66 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
67 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
68 | - $this->setAssetNamespace(); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function pluginFile() |
|
76 | - { |
|
77 | - return (string) $this->plugin_file; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function pluginBasename() |
|
86 | - { |
|
87 | - return $this->plugin_basename; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function pluginPath() |
|
96 | - { |
|
97 | - return $this->plugin_path; |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @return string |
|
104 | - */ |
|
105 | - public function pluginUrl() |
|
106 | - { |
|
107 | - return $this->plugin_url; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public function version() |
|
116 | - { |
|
117 | - return (string) $this->version; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return Version |
|
124 | - */ |
|
125 | - public function versionValueObject() |
|
126 | - { |
|
127 | - return $this->version; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function distributionAssetsPath() |
|
135 | - { |
|
136 | - return $this->pluginPath() . 'assets/dist/'; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - public function distributionAssetsUrl() |
|
144 | - { |
|
145 | - return $this->pluginUrl() . 'assets/dist/'; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * @return string |
|
151 | - */ |
|
152 | - public function assetNamespace() |
|
153 | - { |
|
154 | - return $this->asset_namespace; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * @return void |
|
160 | - */ |
|
161 | - private function setAssetNamespace() |
|
162 | - { |
|
163 | - $this->asset_namespace = sanitize_key( |
|
164 | - // convert directory separators to dashes and remove file extension |
|
165 | - str_replace(array('/', '.php'), array('-', ''), $this->plugin_basename) |
|
166 | - ); |
|
167 | - } |
|
19 | + /** |
|
20 | + * Equivalent to `__FILE__` for main plugin file. |
|
21 | + * |
|
22 | + * @var FilePath |
|
23 | + */ |
|
24 | + private $plugin_file; |
|
25 | + |
|
26 | + /** |
|
27 | + * String indicating version for plugin |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + private $version; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var string $plugin_basename |
|
35 | + */ |
|
36 | + private $plugin_basename; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var string $plugin_path |
|
40 | + */ |
|
41 | + private $plugin_path; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var string $plugin_url |
|
45 | + */ |
|
46 | + private $plugin_url; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var string $asset_namespace |
|
50 | + */ |
|
51 | + private $asset_namespace; |
|
52 | + |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Initializes internal properties. |
|
57 | + * |
|
58 | + * @param FilePath $plugin_file |
|
59 | + * @param Version $version |
|
60 | + */ |
|
61 | + public function __construct(FilePath $plugin_file, Version $version) |
|
62 | + { |
|
63 | + $this->plugin_file = $plugin_file; |
|
64 | + $this->version = $version; |
|
65 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
66 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
67 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
68 | + $this->setAssetNamespace(); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function pluginFile() |
|
76 | + { |
|
77 | + return (string) $this->plugin_file; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function pluginBasename() |
|
86 | + { |
|
87 | + return $this->plugin_basename; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function pluginPath() |
|
96 | + { |
|
97 | + return $this->plugin_path; |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @return string |
|
104 | + */ |
|
105 | + public function pluginUrl() |
|
106 | + { |
|
107 | + return $this->plugin_url; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public function version() |
|
116 | + { |
|
117 | + return (string) $this->version; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return Version |
|
124 | + */ |
|
125 | + public function versionValueObject() |
|
126 | + { |
|
127 | + return $this->version; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function distributionAssetsPath() |
|
135 | + { |
|
136 | + return $this->pluginPath() . 'assets/dist/'; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + public function distributionAssetsUrl() |
|
144 | + { |
|
145 | + return $this->pluginUrl() . 'assets/dist/'; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * @return string |
|
151 | + */ |
|
152 | + public function assetNamespace() |
|
153 | + { |
|
154 | + return $this->asset_namespace; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * @return void |
|
160 | + */ |
|
161 | + private function setAssetNamespace() |
|
162 | + { |
|
163 | + $this->asset_namespace = sanitize_key( |
|
164 | + // convert directory separators to dashes and remove file extension |
|
165 | + str_replace(array('/', '.php'), array('-', ''), $this->plugin_basename) |
|
166 | + ); |
|
167 | + } |
|
168 | 168 | } |
@@ -91,7 +91,7 @@ |
||
91 | 91 | public function __construct($slug, $description) |
92 | 92 | { |
93 | 93 | parent::__construct($slug, $description); |
94 | - if (! in_array($this->slug(), $this->validRequestTypes(), true)) { |
|
94 | + if ( ! in_array($this->slug(), $this->validRequestTypes(), true)) { |
|
95 | 95 | throw new InvalidArgumentException( |
96 | 96 | sprintf( |
97 | 97 | esc_html__( |
@@ -16,155 +16,155 @@ |
||
16 | 16 | class RequestTypeContext extends Context |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * indicates that the current request involves some form of activation |
|
21 | - */ |
|
22 | - const ACTIVATION = 'activation-request'; |
|
23 | - |
|
24 | - /** |
|
25 | - * indicates that the current request is for the admin but is not being made via AJAX |
|
26 | - */ |
|
27 | - const ADMIN = 'non-ajax-admin-request'; |
|
28 | - |
|
29 | - /** |
|
30 | - * indicates that the current request is for the admin AND is being made via AJAX |
|
31 | - */ |
|
32 | - const AJAX_ADMIN = 'admin-ajax-request'; |
|
33 | - |
|
34 | - /** |
|
35 | - * indicates that the current request is for the frontend AND is being made via AJAX |
|
36 | - */ |
|
37 | - const AJAX_FRONT = 'frontend-ajax-request'; |
|
38 | - |
|
39 | - /** |
|
40 | - * indicates that the current request is for the WP Heartbeat |
|
41 | - */ |
|
42 | - const AJAX_HEARTBEAT = 'admin-ajax-heartbeat'; |
|
43 | - |
|
44 | - /** |
|
45 | - * indicates that the current request is being made via AJAX, but is NOT for EE |
|
46 | - */ |
|
47 | - const AJAX_OTHER = 'other-ajax-request'; |
|
48 | - |
|
49 | - /** |
|
50 | - * indicates that the current request is for the EE REST API |
|
51 | - */ |
|
52 | - const API = 'rest-api'; |
|
53 | - |
|
54 | - /** |
|
55 | - * indicates that the current request is from the command line |
|
56 | - */ |
|
57 | - const CLI = 'command-line'; |
|
58 | - |
|
59 | - /** |
|
60 | - * indicates that the current request is for a WP_Cron |
|
61 | - */ |
|
62 | - const CRON = 'wp-cron'; |
|
63 | - |
|
64 | - /** |
|
65 | - * indicates that the current request is for a feed (ie: RSS) |
|
66 | - */ |
|
67 | - const FEED = 'feed-request'; |
|
68 | - |
|
69 | - /** |
|
70 | - * indicates that the current request is for the frontend but is not being made via AJAX |
|
71 | - */ |
|
72 | - const FRONTEND = 'non-ajax-frontend-request'; |
|
73 | - |
|
74 | - /** |
|
75 | - * indicates that the current request is for content that is to be displayed within an iframe |
|
76 | - */ |
|
77 | - const IFRAME = 'iframe-request'; |
|
78 | - |
|
79 | - /** |
|
80 | - * indicates that the current request is for the WP REST API |
|
81 | - */ |
|
82 | - const WP_API = 'wp-rest-api'; |
|
83 | - |
|
84 | - /** |
|
85 | - * indicates that the current request is a loopback sent from WP core to test for errors |
|
86 | - */ |
|
87 | - const WP_SCRAPE = 'wordpress-scrape'; |
|
88 | - |
|
89 | - /** |
|
90 | - * @var boolean $is_activation |
|
91 | - */ |
|
92 | - private $is_activation = false; |
|
93 | - |
|
94 | - /** |
|
95 | - * @var array $valid_request_types |
|
96 | - */ |
|
97 | - private $valid_request_types = array(); |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * RequestTypeContext constructor. |
|
102 | - * |
|
103 | - * @param string $slug |
|
104 | - * @param string $description |
|
105 | - * @throws InvalidArgumentException |
|
106 | - */ |
|
107 | - public function __construct($slug, $description) |
|
108 | - { |
|
109 | - parent::__construct($slug, $description); |
|
110 | - if (! in_array($this->slug(), $this->validRequestTypes(), true)) { |
|
111 | - throw new InvalidArgumentException( |
|
112 | - sprintf( |
|
113 | - esc_html__( |
|
114 | - 'The RequestTypeContext slug must be one of the following values: %1$s %2$s', |
|
115 | - 'event_espresso' |
|
116 | - ), |
|
117 | - var_export($this->validRequestTypes(), true) |
|
118 | - ) |
|
119 | - ); |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @return array |
|
126 | - */ |
|
127 | - public function validRequestTypes() |
|
128 | - { |
|
129 | - if (empty($this->valid_request_types)) { |
|
130 | - $this->valid_request_types = apply_filters( |
|
131 | - 'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes', |
|
132 | - array( |
|
133 | - RequestTypeContext::ACTIVATION, |
|
134 | - RequestTypeContext::ADMIN, |
|
135 | - RequestTypeContext::AJAX_ADMIN, |
|
136 | - RequestTypeContext::AJAX_FRONT, |
|
137 | - RequestTypeContext::AJAX_HEARTBEAT, |
|
138 | - RequestTypeContext::AJAX_OTHER, |
|
139 | - RequestTypeContext::API, |
|
140 | - RequestTypeContext::CLI, |
|
141 | - RequestTypeContext::CRON, |
|
142 | - RequestTypeContext::FEED, |
|
143 | - RequestTypeContext::FRONTEND, |
|
144 | - RequestTypeContext::IFRAME, |
|
145 | - RequestTypeContext::WP_API, |
|
146 | - RequestTypeContext::WP_SCRAPE, |
|
147 | - ) |
|
148 | - ); |
|
149 | - } |
|
150 | - return $this->valid_request_types; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * @return bool |
|
156 | - */ |
|
157 | - public function isActivation() |
|
158 | - { |
|
159 | - return $this->is_activation; |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * @param bool $is_activation |
|
165 | - */ |
|
166 | - public function setIsActivation($is_activation) |
|
167 | - { |
|
168 | - $this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN); |
|
169 | - } |
|
19 | + /** |
|
20 | + * indicates that the current request involves some form of activation |
|
21 | + */ |
|
22 | + const ACTIVATION = 'activation-request'; |
|
23 | + |
|
24 | + /** |
|
25 | + * indicates that the current request is for the admin but is not being made via AJAX |
|
26 | + */ |
|
27 | + const ADMIN = 'non-ajax-admin-request'; |
|
28 | + |
|
29 | + /** |
|
30 | + * indicates that the current request is for the admin AND is being made via AJAX |
|
31 | + */ |
|
32 | + const AJAX_ADMIN = 'admin-ajax-request'; |
|
33 | + |
|
34 | + /** |
|
35 | + * indicates that the current request is for the frontend AND is being made via AJAX |
|
36 | + */ |
|
37 | + const AJAX_FRONT = 'frontend-ajax-request'; |
|
38 | + |
|
39 | + /** |
|
40 | + * indicates that the current request is for the WP Heartbeat |
|
41 | + */ |
|
42 | + const AJAX_HEARTBEAT = 'admin-ajax-heartbeat'; |
|
43 | + |
|
44 | + /** |
|
45 | + * indicates that the current request is being made via AJAX, but is NOT for EE |
|
46 | + */ |
|
47 | + const AJAX_OTHER = 'other-ajax-request'; |
|
48 | + |
|
49 | + /** |
|
50 | + * indicates that the current request is for the EE REST API |
|
51 | + */ |
|
52 | + const API = 'rest-api'; |
|
53 | + |
|
54 | + /** |
|
55 | + * indicates that the current request is from the command line |
|
56 | + */ |
|
57 | + const CLI = 'command-line'; |
|
58 | + |
|
59 | + /** |
|
60 | + * indicates that the current request is for a WP_Cron |
|
61 | + */ |
|
62 | + const CRON = 'wp-cron'; |
|
63 | + |
|
64 | + /** |
|
65 | + * indicates that the current request is for a feed (ie: RSS) |
|
66 | + */ |
|
67 | + const FEED = 'feed-request'; |
|
68 | + |
|
69 | + /** |
|
70 | + * indicates that the current request is for the frontend but is not being made via AJAX |
|
71 | + */ |
|
72 | + const FRONTEND = 'non-ajax-frontend-request'; |
|
73 | + |
|
74 | + /** |
|
75 | + * indicates that the current request is for content that is to be displayed within an iframe |
|
76 | + */ |
|
77 | + const IFRAME = 'iframe-request'; |
|
78 | + |
|
79 | + /** |
|
80 | + * indicates that the current request is for the WP REST API |
|
81 | + */ |
|
82 | + const WP_API = 'wp-rest-api'; |
|
83 | + |
|
84 | + /** |
|
85 | + * indicates that the current request is a loopback sent from WP core to test for errors |
|
86 | + */ |
|
87 | + const WP_SCRAPE = 'wordpress-scrape'; |
|
88 | + |
|
89 | + /** |
|
90 | + * @var boolean $is_activation |
|
91 | + */ |
|
92 | + private $is_activation = false; |
|
93 | + |
|
94 | + /** |
|
95 | + * @var array $valid_request_types |
|
96 | + */ |
|
97 | + private $valid_request_types = array(); |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * RequestTypeContext constructor. |
|
102 | + * |
|
103 | + * @param string $slug |
|
104 | + * @param string $description |
|
105 | + * @throws InvalidArgumentException |
|
106 | + */ |
|
107 | + public function __construct($slug, $description) |
|
108 | + { |
|
109 | + parent::__construct($slug, $description); |
|
110 | + if (! in_array($this->slug(), $this->validRequestTypes(), true)) { |
|
111 | + throw new InvalidArgumentException( |
|
112 | + sprintf( |
|
113 | + esc_html__( |
|
114 | + 'The RequestTypeContext slug must be one of the following values: %1$s %2$s', |
|
115 | + 'event_espresso' |
|
116 | + ), |
|
117 | + var_export($this->validRequestTypes(), true) |
|
118 | + ) |
|
119 | + ); |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @return array |
|
126 | + */ |
|
127 | + public function validRequestTypes() |
|
128 | + { |
|
129 | + if (empty($this->valid_request_types)) { |
|
130 | + $this->valid_request_types = apply_filters( |
|
131 | + 'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes', |
|
132 | + array( |
|
133 | + RequestTypeContext::ACTIVATION, |
|
134 | + RequestTypeContext::ADMIN, |
|
135 | + RequestTypeContext::AJAX_ADMIN, |
|
136 | + RequestTypeContext::AJAX_FRONT, |
|
137 | + RequestTypeContext::AJAX_HEARTBEAT, |
|
138 | + RequestTypeContext::AJAX_OTHER, |
|
139 | + RequestTypeContext::API, |
|
140 | + RequestTypeContext::CLI, |
|
141 | + RequestTypeContext::CRON, |
|
142 | + RequestTypeContext::FEED, |
|
143 | + RequestTypeContext::FRONTEND, |
|
144 | + RequestTypeContext::IFRAME, |
|
145 | + RequestTypeContext::WP_API, |
|
146 | + RequestTypeContext::WP_SCRAPE, |
|
147 | + ) |
|
148 | + ); |
|
149 | + } |
|
150 | + return $this->valid_request_types; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * @return bool |
|
156 | + */ |
|
157 | + public function isActivation() |
|
158 | + { |
|
159 | + return $this->is_activation; |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * @param bool $is_activation |
|
165 | + */ |
|
166 | + public function setIsActivation($is_activation) |
|
167 | + { |
|
168 | + $this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN); |
|
169 | + } |
|
170 | 170 | } |
@@ -11,14 +11,14 @@ |
||
11 | 11 | |
12 | 12 | |
13 | 13 | |
14 | - /** |
|
15 | - * removes all tags which a WP Post wouldn't allow in its content normally |
|
16 | - * |
|
17 | - * @param string $value |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public function prepare_for_set($value) |
|
21 | - { |
|
22 | - return parent::prepare_for_set(wp_kses("$value", EEH_HTML::get_simple_tags())); |
|
23 | - } |
|
14 | + /** |
|
15 | + * removes all tags which a WP Post wouldn't allow in its content normally |
|
16 | + * |
|
17 | + * @param string $value |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public function prepare_for_set($value) |
|
21 | + { |
|
22 | + return parent::prepare_for_set(wp_kses("$value", EEH_HTML::get_simple_tags())); |
|
23 | + } |
|
24 | 24 | } |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | /** |
604 | 604 | * returns any events attached to this attendee ($_Event property); |
605 | 605 | * |
606 | - * @return array |
|
606 | + * @return EE_Base_Class[] |
|
607 | 607 | * @throws EE_Error |
608 | 608 | */ |
609 | 609 | public function events() |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * used to save the billing info |
619 | 619 | * |
620 | 620 | * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
621 | - * @return EE_Form_Section_Proper|null |
|
621 | + * @return null|EE_Billing_Info_Form |
|
622 | 622 | * @throws EE_Error |
623 | 623 | */ |
624 | 624 | public function billing_info_for_payment_method($payment_method) |
@@ -25,746 +25,746 @@ |
||
25 | 25 | class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Sets some dynamic defaults |
|
30 | - * |
|
31 | - * @param array $fieldValues |
|
32 | - * @param bool $bydb |
|
33 | - * @param string $timezone |
|
34 | - * @param array $date_formats |
|
35 | - * @throws EE_Error |
|
36 | - */ |
|
37 | - protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
38 | - { |
|
39 | - if (! isset($fieldValues['ATT_full_name'])) { |
|
40 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
41 | - $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
42 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
43 | - } |
|
44 | - if (! isset($fieldValues['ATT_slug'])) { |
|
45 | - // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
46 | - $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
47 | - } |
|
48 | - if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
49 | - $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
50 | - } |
|
51 | - parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @param array $props_n_values incoming values |
|
57 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
58 | - * used.) |
|
59 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
60 | - * date_format and the second value is the time format |
|
61 | - * @return EE_Attendee |
|
62 | - * @throws EE_Error |
|
63 | - */ |
|
64 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
65 | - { |
|
66 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
67 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @param array $props_n_values incoming values from the database |
|
73 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
74 | - * the website will be used. |
|
75 | - * @return EE_Attendee |
|
76 | - */ |
|
77 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
78 | - { |
|
79 | - return new self($props_n_values, true, $timezone); |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * Set Attendee First Name |
|
85 | - * |
|
86 | - * @access public |
|
87 | - * @param string $fname |
|
88 | - * @throws EE_Error |
|
89 | - */ |
|
90 | - public function set_fname($fname = '') |
|
91 | - { |
|
92 | - $this->set('ATT_fname', $fname); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Set Attendee Last Name |
|
98 | - * |
|
99 | - * @access public |
|
100 | - * @param string $lname |
|
101 | - * @throws EE_Error |
|
102 | - */ |
|
103 | - public function set_lname($lname = '') |
|
104 | - { |
|
105 | - $this->set('ATT_lname', $lname); |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * Set Attendee Address |
|
111 | - * |
|
112 | - * @access public |
|
113 | - * @param string $address |
|
114 | - * @throws EE_Error |
|
115 | - */ |
|
116 | - public function set_address($address = '') |
|
117 | - { |
|
118 | - $this->set('ATT_address', $address); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * Set Attendee Address2 |
|
124 | - * |
|
125 | - * @access public |
|
126 | - * @param string $address2 |
|
127 | - * @throws EE_Error |
|
128 | - */ |
|
129 | - public function set_address2($address2 = '') |
|
130 | - { |
|
131 | - $this->set('ATT_address2', $address2); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * Set Attendee City |
|
137 | - * |
|
138 | - * @access public |
|
139 | - * @param string $city |
|
140 | - * @throws EE_Error |
|
141 | - */ |
|
142 | - public function set_city($city = '') |
|
143 | - { |
|
144 | - $this->set('ATT_city', $city); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * Set Attendee State ID |
|
150 | - * |
|
151 | - * @access public |
|
152 | - * @param int $STA_ID |
|
153 | - * @throws EE_Error |
|
154 | - */ |
|
155 | - public function set_state($STA_ID = 0) |
|
156 | - { |
|
157 | - $this->set('STA_ID', $STA_ID); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Set Attendee Country ISO Code |
|
163 | - * |
|
164 | - * @access public |
|
165 | - * @param string $CNT_ISO |
|
166 | - * @throws EE_Error |
|
167 | - */ |
|
168 | - public function set_country($CNT_ISO = '') |
|
169 | - { |
|
170 | - $this->set('CNT_ISO', $CNT_ISO); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * Set Attendee Zip/Postal Code |
|
176 | - * |
|
177 | - * @access public |
|
178 | - * @param string $zip |
|
179 | - * @throws EE_Error |
|
180 | - */ |
|
181 | - public function set_zip($zip = '') |
|
182 | - { |
|
183 | - $this->set('ATT_zip', $zip); |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * Set Attendee Email Address |
|
189 | - * |
|
190 | - * @access public |
|
191 | - * @param string $email |
|
192 | - * @throws EE_Error |
|
193 | - */ |
|
194 | - public function set_email($email = '') |
|
195 | - { |
|
196 | - $this->set('ATT_email', $email); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * Set Attendee Phone |
|
202 | - * |
|
203 | - * @access public |
|
204 | - * @param string $phone |
|
205 | - * @throws EE_Error |
|
206 | - */ |
|
207 | - public function set_phone($phone = '') |
|
208 | - { |
|
209 | - $this->set('ATT_phone', $phone); |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * set deleted |
|
215 | - * |
|
216 | - * @access public |
|
217 | - * @param bool $ATT_deleted |
|
218 | - * @throws EE_Error |
|
219 | - */ |
|
220 | - public function set_deleted($ATT_deleted = false) |
|
221 | - { |
|
222 | - $this->set('ATT_deleted', $ATT_deleted); |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * Returns the value for the post_author id saved with the cpt |
|
228 | - * |
|
229 | - * @since 4.5.0 |
|
230 | - * @return int |
|
231 | - * @throws EE_Error |
|
232 | - */ |
|
233 | - public function wp_user() |
|
234 | - { |
|
235 | - return $this->get('ATT_author'); |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * get Attendee First Name |
|
241 | - * |
|
242 | - * @access public |
|
243 | - * @return string |
|
244 | - * @throws EE_Error |
|
245 | - */ |
|
246 | - public function fname() |
|
247 | - { |
|
248 | - return $this->get('ATT_fname'); |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * echoes out the attendee's first name |
|
254 | - * |
|
255 | - * @return void |
|
256 | - * @throws EE_Error |
|
257 | - */ |
|
258 | - public function e_full_name() |
|
259 | - { |
|
260 | - echo $this->full_name(); |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - /** |
|
265 | - * Returns the first and last name concatenated together with a space. |
|
266 | - * |
|
267 | - * @param bool $apply_html_entities |
|
268 | - * @return string |
|
269 | - * @throws EE_Error |
|
270 | - */ |
|
271 | - public function full_name($apply_html_entities = false) |
|
272 | - { |
|
273 | - $full_name = array( |
|
274 | - $this->fname(), |
|
275 | - $this->lname(), |
|
276 | - ); |
|
277 | - $full_name = array_filter($full_name); |
|
278 | - $full_name = implode(' ', $full_name); |
|
279 | - return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless |
|
285 | - * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this |
|
286 | - * attendee. |
|
287 | - * |
|
288 | - * @param bool $apply_html_entities |
|
289 | - * @return string |
|
290 | - * @throws EE_Error |
|
291 | - */ |
|
292 | - public function ATT_full_name($apply_html_entities = false) |
|
293 | - { |
|
294 | - return $apply_html_entities |
|
295 | - ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8') |
|
296 | - : $this->get('ATT_full_name'); |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * get Attendee Last Name |
|
302 | - * |
|
303 | - * @access public |
|
304 | - * @return string |
|
305 | - * @throws EE_Error |
|
306 | - */ |
|
307 | - public function lname() |
|
308 | - { |
|
309 | - return $this->get('ATT_lname'); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
315 | - * |
|
316 | - * @return array numerically indexed, with each part of the address that is known. |
|
317 | - * Eg, if the user only responded to state and country, |
|
318 | - * it would be array(0=>'Alabama',1=>'USA') |
|
319 | - * @return array |
|
320 | - * @throws EE_Error |
|
321 | - */ |
|
322 | - public function full_address_as_array() |
|
323 | - { |
|
324 | - $full_address_array = array(); |
|
325 | - $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
326 | - foreach ($initial_address_fields as $address_field_name) { |
|
327 | - $address_fields_value = $this->get($address_field_name); |
|
328 | - if (! empty($address_fields_value)) { |
|
329 | - $full_address_array[] = $address_fields_value; |
|
330 | - } |
|
331 | - } |
|
332 | - // now handle state and country |
|
333 | - $state_obj = $this->state_obj(); |
|
334 | - if ($state_obj instanceof EE_State) { |
|
335 | - $full_address_array[] = $state_obj->name(); |
|
336 | - } |
|
337 | - $country_obj = $this->country_obj(); |
|
338 | - if ($country_obj instanceof EE_Country) { |
|
339 | - $full_address_array[] = $country_obj->name(); |
|
340 | - } |
|
341 | - // lastly get the xip |
|
342 | - $zip_value = $this->zip(); |
|
343 | - if (! empty($zip_value)) { |
|
344 | - $full_address_array[] = $zip_value; |
|
345 | - } |
|
346 | - return $full_address_array; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * get Attendee Address |
|
352 | - * |
|
353 | - * @return string |
|
354 | - * @throws EE_Error |
|
355 | - */ |
|
356 | - public function address() |
|
357 | - { |
|
358 | - return $this->get('ATT_address'); |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * get Attendee Address2 |
|
364 | - * |
|
365 | - * @return string |
|
366 | - * @throws EE_Error |
|
367 | - */ |
|
368 | - public function address2() |
|
369 | - { |
|
370 | - return $this->get('ATT_address2'); |
|
371 | - } |
|
372 | - |
|
373 | - |
|
374 | - /** |
|
375 | - * get Attendee City |
|
376 | - * |
|
377 | - * @return string |
|
378 | - * @throws EE_Error |
|
379 | - */ |
|
380 | - public function city() |
|
381 | - { |
|
382 | - return $this->get('ATT_city'); |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * get Attendee State ID |
|
388 | - * |
|
389 | - * @return string |
|
390 | - * @throws EE_Error |
|
391 | - */ |
|
392 | - public function state_ID() |
|
393 | - { |
|
394 | - return $this->get('STA_ID'); |
|
395 | - } |
|
396 | - |
|
397 | - |
|
398 | - /** |
|
399 | - * @return string |
|
400 | - * @throws EE_Error |
|
401 | - */ |
|
402 | - public function state_abbrev() |
|
403 | - { |
|
404 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * Gets the state set to this attendee |
|
410 | - * |
|
411 | - * @return EE_State |
|
412 | - * @throws EE_Error |
|
413 | - */ |
|
414 | - public function state_obj() |
|
415 | - { |
|
416 | - return $this->get_first_related('State'); |
|
417 | - } |
|
418 | - |
|
419 | - |
|
420 | - /** |
|
421 | - * Returns the state's name, otherwise 'Unknown' |
|
422 | - * |
|
423 | - * @return string |
|
424 | - * @throws EE_Error |
|
425 | - */ |
|
426 | - public function state_name() |
|
427 | - { |
|
428 | - if ($this->state_obj()) { |
|
429 | - return $this->state_obj()->name(); |
|
430 | - } else { |
|
431 | - return ''; |
|
432 | - } |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * either displays the state abbreviation or the state name, as determined |
|
438 | - * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
439 | - * defaults to abbreviation |
|
440 | - * |
|
441 | - * @return string |
|
442 | - * @throws EE_Error |
|
443 | - */ |
|
444 | - public function state() |
|
445 | - { |
|
446 | - if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
447 | - return $this->state_abbrev(); |
|
448 | - } |
|
449 | - return $this->state_name(); |
|
450 | - } |
|
451 | - |
|
452 | - |
|
453 | - /** |
|
454 | - * get Attendee Country ISO Code |
|
455 | - * |
|
456 | - * @return string |
|
457 | - * @throws EE_Error |
|
458 | - */ |
|
459 | - public function country_ID() |
|
460 | - { |
|
461 | - return $this->get('CNT_ISO'); |
|
462 | - } |
|
463 | - |
|
464 | - |
|
465 | - /** |
|
466 | - * Gets country set for this attendee |
|
467 | - * |
|
468 | - * @return EE_Country |
|
469 | - * @throws EE_Error |
|
470 | - */ |
|
471 | - public function country_obj() |
|
472 | - { |
|
473 | - return $this->get_first_related('Country'); |
|
474 | - } |
|
475 | - |
|
476 | - |
|
477 | - /** |
|
478 | - * Returns the country's name if known, otherwise 'Unknown' |
|
479 | - * |
|
480 | - * @return string |
|
481 | - * @throws EE_Error |
|
482 | - */ |
|
483 | - public function country_name() |
|
484 | - { |
|
485 | - if ($this->country_obj()) { |
|
486 | - return $this->country_obj()->name(); |
|
487 | - } |
|
488 | - return ''; |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * either displays the country ISO2 code or the country name, as determined |
|
494 | - * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
495 | - * defaults to abbreviation |
|
496 | - * |
|
497 | - * @return string |
|
498 | - * @throws EE_Error |
|
499 | - */ |
|
500 | - public function country() |
|
501 | - { |
|
502 | - if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
503 | - return $this->country_ID(); |
|
504 | - } |
|
505 | - return $this->country_name(); |
|
506 | - } |
|
507 | - |
|
508 | - |
|
509 | - /** |
|
510 | - * get Attendee Zip/Postal Code |
|
511 | - * |
|
512 | - * @return string |
|
513 | - * @throws EE_Error |
|
514 | - */ |
|
515 | - public function zip() |
|
516 | - { |
|
517 | - return $this->get('ATT_zip'); |
|
518 | - } |
|
519 | - |
|
520 | - |
|
521 | - /** |
|
522 | - * get Attendee Email Address |
|
523 | - * |
|
524 | - * @return string |
|
525 | - * @throws EE_Error |
|
526 | - */ |
|
527 | - public function email() |
|
528 | - { |
|
529 | - return $this->get('ATT_email'); |
|
530 | - } |
|
531 | - |
|
532 | - |
|
533 | - /** |
|
534 | - * get Attendee Phone # |
|
535 | - * |
|
536 | - * @return string |
|
537 | - * @throws EE_Error |
|
538 | - */ |
|
539 | - public function phone() |
|
540 | - { |
|
541 | - return $this->get('ATT_phone'); |
|
542 | - } |
|
543 | - |
|
544 | - |
|
545 | - /** |
|
546 | - * get deleted |
|
547 | - * |
|
548 | - * @return bool |
|
549 | - * @throws EE_Error |
|
550 | - */ |
|
551 | - public function deleted() |
|
552 | - { |
|
553 | - return $this->get('ATT_deleted'); |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * Gets registrations of this attendee |
|
559 | - * |
|
560 | - * @param array $query_params |
|
561 | - * @return EE_Registration[] |
|
562 | - * @throws EE_Error |
|
563 | - */ |
|
564 | - public function get_registrations($query_params = array()) |
|
565 | - { |
|
566 | - return $this->get_many_related('Registration', $query_params); |
|
567 | - } |
|
568 | - |
|
569 | - |
|
570 | - /** |
|
571 | - * Gets the most recent registration of this attendee |
|
572 | - * |
|
573 | - * @return EE_Registration |
|
574 | - * @throws EE_Error |
|
575 | - */ |
|
576 | - public function get_most_recent_registration() |
|
577 | - { |
|
578 | - return $this->get_first_related( |
|
579 | - 'Registration', |
|
580 | - array('order_by' => array('REG_date' => 'DESC')) |
|
581 | - ); // null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
582 | - } |
|
583 | - |
|
584 | - |
|
585 | - /** |
|
586 | - * Gets the most recent registration for this attend at this event |
|
587 | - * |
|
588 | - * @param int $event_id |
|
589 | - * @return EE_Registration |
|
590 | - * @throws EE_Error |
|
591 | - */ |
|
592 | - public function get_most_recent_registration_for_event($event_id) |
|
593 | - { |
|
594 | - return $this->get_first_related( |
|
595 | - 'Registration', |
|
596 | - array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')) |
|
597 | - ); |
|
598 | - } |
|
599 | - |
|
600 | - |
|
601 | - /** |
|
602 | - * returns any events attached to this attendee ($_Event property); |
|
603 | - * |
|
604 | - * @return array |
|
605 | - * @throws EE_Error |
|
606 | - */ |
|
607 | - public function events() |
|
608 | - { |
|
609 | - return $this->get_many_related('Event'); |
|
610 | - } |
|
611 | - |
|
612 | - |
|
613 | - /** |
|
614 | - * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
615 | - * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
616 | - * used to save the billing info |
|
617 | - * |
|
618 | - * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
619 | - * @return EE_Form_Section_Proper|null |
|
620 | - * @throws EE_Error |
|
621 | - */ |
|
622 | - public function billing_info_for_payment_method($payment_method) |
|
623 | - { |
|
624 | - $pm_type = $payment_method->type_obj(); |
|
625 | - if (! $pm_type instanceof EE_PMT_Base) { |
|
626 | - return null; |
|
627 | - } |
|
628 | - $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
629 | - if (! $billing_info) { |
|
630 | - return null; |
|
631 | - } |
|
632 | - $billing_form = $pm_type->billing_form(); |
|
633 | - // double-check the form isn't totally hidden, in which case pretend there is no form |
|
634 | - $form_totally_hidden = true; |
|
635 | - foreach ($billing_form->inputs_in_subsections() as $input) { |
|
636 | - if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
637 | - $form_totally_hidden = false; |
|
638 | - break; |
|
639 | - } |
|
640 | - } |
|
641 | - if ($form_totally_hidden) { |
|
642 | - return null; |
|
643 | - } |
|
644 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
645 | - $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
646 | - } |
|
647 | - |
|
648 | - return $billing_form; |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - /** |
|
653 | - * Gets the postmeta key that holds this attendee's billing info for the |
|
654 | - * specified payment method |
|
655 | - * |
|
656 | - * @param EE_Payment_Method $payment_method |
|
657 | - * @return string |
|
658 | - * @throws EE_Error |
|
659 | - */ |
|
660 | - public function get_billing_info_postmeta_name($payment_method) |
|
661 | - { |
|
662 | - if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
663 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
664 | - } |
|
665 | - return null; |
|
666 | - } |
|
667 | - |
|
668 | - |
|
669 | - /** |
|
670 | - * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
671 | - * retrieve it |
|
672 | - * |
|
673 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
674 | - * @param EE_Payment_Method $payment_method |
|
675 | - * @return boolean |
|
676 | - * @throws EE_Error |
|
677 | - */ |
|
678 | - public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
679 | - { |
|
680 | - if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
681 | - EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
682 | - return false; |
|
683 | - } |
|
684 | - $billing_form->clean_sensitive_data(); |
|
685 | - return update_post_meta( |
|
686 | - $this->ID(), |
|
687 | - $this->get_billing_info_postmeta_name($payment_method), |
|
688 | - $billing_form->input_values(true) |
|
689 | - ); |
|
690 | - } |
|
691 | - |
|
692 | - |
|
693 | - /** |
|
694 | - * Return the link to the admin details for the object. |
|
695 | - * |
|
696 | - * @return string |
|
697 | - * @throws EE_Error |
|
698 | - * @throws InvalidArgumentException |
|
699 | - * @throws InvalidDataTypeException |
|
700 | - * @throws InvalidInterfaceException |
|
701 | - * @throws ReflectionException |
|
702 | - */ |
|
703 | - public function get_admin_details_link() |
|
704 | - { |
|
705 | - return $this->get_admin_edit_link(); |
|
706 | - } |
|
707 | - |
|
708 | - |
|
709 | - /** |
|
710 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
711 | - * |
|
712 | - * @return string |
|
713 | - * @throws EE_Error |
|
714 | - * @throws InvalidArgumentException |
|
715 | - * @throws ReflectionException |
|
716 | - * @throws InvalidDataTypeException |
|
717 | - * @throws InvalidInterfaceException |
|
718 | - */ |
|
719 | - public function get_admin_edit_link() |
|
720 | - { |
|
721 | - EE_Registry::instance()->load_helper('URL'); |
|
722 | - return EEH_URL::add_query_args_and_nonce( |
|
723 | - array( |
|
724 | - 'page' => 'espresso_registrations', |
|
725 | - 'action' => 'edit_attendee', |
|
726 | - 'post' => $this->ID(), |
|
727 | - ), |
|
728 | - admin_url('admin.php') |
|
729 | - ); |
|
730 | - } |
|
731 | - |
|
732 | - |
|
733 | - /** |
|
734 | - * Returns the link to a settings page for the object. |
|
735 | - * |
|
736 | - * @return string |
|
737 | - * @throws EE_Error |
|
738 | - * @throws InvalidArgumentException |
|
739 | - * @throws InvalidDataTypeException |
|
740 | - * @throws InvalidInterfaceException |
|
741 | - * @throws ReflectionException |
|
742 | - */ |
|
743 | - public function get_admin_settings_link() |
|
744 | - { |
|
745 | - return $this->get_admin_edit_link(); |
|
746 | - } |
|
747 | - |
|
748 | - |
|
749 | - /** |
|
750 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
751 | - * |
|
752 | - * @return string |
|
753 | - * @throws EE_Error |
|
754 | - * @throws InvalidArgumentException |
|
755 | - * @throws ReflectionException |
|
756 | - * @throws InvalidDataTypeException |
|
757 | - * @throws InvalidInterfaceException |
|
758 | - */ |
|
759 | - public function get_admin_overview_link() |
|
760 | - { |
|
761 | - EE_Registry::instance()->load_helper('URL'); |
|
762 | - return EEH_URL::add_query_args_and_nonce( |
|
763 | - array( |
|
764 | - 'page' => 'espresso_registrations', |
|
765 | - 'action' => 'contact_list', |
|
766 | - ), |
|
767 | - admin_url('admin.php') |
|
768 | - ); |
|
769 | - } |
|
28 | + /** |
|
29 | + * Sets some dynamic defaults |
|
30 | + * |
|
31 | + * @param array $fieldValues |
|
32 | + * @param bool $bydb |
|
33 | + * @param string $timezone |
|
34 | + * @param array $date_formats |
|
35 | + * @throws EE_Error |
|
36 | + */ |
|
37 | + protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
38 | + { |
|
39 | + if (! isset($fieldValues['ATT_full_name'])) { |
|
40 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
41 | + $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
42 | + $fieldValues['ATT_full_name'] = $fname . $lname; |
|
43 | + } |
|
44 | + if (! isset($fieldValues['ATT_slug'])) { |
|
45 | + // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
46 | + $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
47 | + } |
|
48 | + if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
49 | + $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
50 | + } |
|
51 | + parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @param array $props_n_values incoming values |
|
57 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
58 | + * used.) |
|
59 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
60 | + * date_format and the second value is the time format |
|
61 | + * @return EE_Attendee |
|
62 | + * @throws EE_Error |
|
63 | + */ |
|
64 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
65 | + { |
|
66 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
67 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @param array $props_n_values incoming values from the database |
|
73 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
74 | + * the website will be used. |
|
75 | + * @return EE_Attendee |
|
76 | + */ |
|
77 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
78 | + { |
|
79 | + return new self($props_n_values, true, $timezone); |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * Set Attendee First Name |
|
85 | + * |
|
86 | + * @access public |
|
87 | + * @param string $fname |
|
88 | + * @throws EE_Error |
|
89 | + */ |
|
90 | + public function set_fname($fname = '') |
|
91 | + { |
|
92 | + $this->set('ATT_fname', $fname); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Set Attendee Last Name |
|
98 | + * |
|
99 | + * @access public |
|
100 | + * @param string $lname |
|
101 | + * @throws EE_Error |
|
102 | + */ |
|
103 | + public function set_lname($lname = '') |
|
104 | + { |
|
105 | + $this->set('ATT_lname', $lname); |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * Set Attendee Address |
|
111 | + * |
|
112 | + * @access public |
|
113 | + * @param string $address |
|
114 | + * @throws EE_Error |
|
115 | + */ |
|
116 | + public function set_address($address = '') |
|
117 | + { |
|
118 | + $this->set('ATT_address', $address); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * Set Attendee Address2 |
|
124 | + * |
|
125 | + * @access public |
|
126 | + * @param string $address2 |
|
127 | + * @throws EE_Error |
|
128 | + */ |
|
129 | + public function set_address2($address2 = '') |
|
130 | + { |
|
131 | + $this->set('ATT_address2', $address2); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * Set Attendee City |
|
137 | + * |
|
138 | + * @access public |
|
139 | + * @param string $city |
|
140 | + * @throws EE_Error |
|
141 | + */ |
|
142 | + public function set_city($city = '') |
|
143 | + { |
|
144 | + $this->set('ATT_city', $city); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * Set Attendee State ID |
|
150 | + * |
|
151 | + * @access public |
|
152 | + * @param int $STA_ID |
|
153 | + * @throws EE_Error |
|
154 | + */ |
|
155 | + public function set_state($STA_ID = 0) |
|
156 | + { |
|
157 | + $this->set('STA_ID', $STA_ID); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Set Attendee Country ISO Code |
|
163 | + * |
|
164 | + * @access public |
|
165 | + * @param string $CNT_ISO |
|
166 | + * @throws EE_Error |
|
167 | + */ |
|
168 | + public function set_country($CNT_ISO = '') |
|
169 | + { |
|
170 | + $this->set('CNT_ISO', $CNT_ISO); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * Set Attendee Zip/Postal Code |
|
176 | + * |
|
177 | + * @access public |
|
178 | + * @param string $zip |
|
179 | + * @throws EE_Error |
|
180 | + */ |
|
181 | + public function set_zip($zip = '') |
|
182 | + { |
|
183 | + $this->set('ATT_zip', $zip); |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * Set Attendee Email Address |
|
189 | + * |
|
190 | + * @access public |
|
191 | + * @param string $email |
|
192 | + * @throws EE_Error |
|
193 | + */ |
|
194 | + public function set_email($email = '') |
|
195 | + { |
|
196 | + $this->set('ATT_email', $email); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * Set Attendee Phone |
|
202 | + * |
|
203 | + * @access public |
|
204 | + * @param string $phone |
|
205 | + * @throws EE_Error |
|
206 | + */ |
|
207 | + public function set_phone($phone = '') |
|
208 | + { |
|
209 | + $this->set('ATT_phone', $phone); |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * set deleted |
|
215 | + * |
|
216 | + * @access public |
|
217 | + * @param bool $ATT_deleted |
|
218 | + * @throws EE_Error |
|
219 | + */ |
|
220 | + public function set_deleted($ATT_deleted = false) |
|
221 | + { |
|
222 | + $this->set('ATT_deleted', $ATT_deleted); |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * Returns the value for the post_author id saved with the cpt |
|
228 | + * |
|
229 | + * @since 4.5.0 |
|
230 | + * @return int |
|
231 | + * @throws EE_Error |
|
232 | + */ |
|
233 | + public function wp_user() |
|
234 | + { |
|
235 | + return $this->get('ATT_author'); |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * get Attendee First Name |
|
241 | + * |
|
242 | + * @access public |
|
243 | + * @return string |
|
244 | + * @throws EE_Error |
|
245 | + */ |
|
246 | + public function fname() |
|
247 | + { |
|
248 | + return $this->get('ATT_fname'); |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * echoes out the attendee's first name |
|
254 | + * |
|
255 | + * @return void |
|
256 | + * @throws EE_Error |
|
257 | + */ |
|
258 | + public function e_full_name() |
|
259 | + { |
|
260 | + echo $this->full_name(); |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + /** |
|
265 | + * Returns the first and last name concatenated together with a space. |
|
266 | + * |
|
267 | + * @param bool $apply_html_entities |
|
268 | + * @return string |
|
269 | + * @throws EE_Error |
|
270 | + */ |
|
271 | + public function full_name($apply_html_entities = false) |
|
272 | + { |
|
273 | + $full_name = array( |
|
274 | + $this->fname(), |
|
275 | + $this->lname(), |
|
276 | + ); |
|
277 | + $full_name = array_filter($full_name); |
|
278 | + $full_name = implode(' ', $full_name); |
|
279 | + return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless |
|
285 | + * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this |
|
286 | + * attendee. |
|
287 | + * |
|
288 | + * @param bool $apply_html_entities |
|
289 | + * @return string |
|
290 | + * @throws EE_Error |
|
291 | + */ |
|
292 | + public function ATT_full_name($apply_html_entities = false) |
|
293 | + { |
|
294 | + return $apply_html_entities |
|
295 | + ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8') |
|
296 | + : $this->get('ATT_full_name'); |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * get Attendee Last Name |
|
302 | + * |
|
303 | + * @access public |
|
304 | + * @return string |
|
305 | + * @throws EE_Error |
|
306 | + */ |
|
307 | + public function lname() |
|
308 | + { |
|
309 | + return $this->get('ATT_lname'); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
315 | + * |
|
316 | + * @return array numerically indexed, with each part of the address that is known. |
|
317 | + * Eg, if the user only responded to state and country, |
|
318 | + * it would be array(0=>'Alabama',1=>'USA') |
|
319 | + * @return array |
|
320 | + * @throws EE_Error |
|
321 | + */ |
|
322 | + public function full_address_as_array() |
|
323 | + { |
|
324 | + $full_address_array = array(); |
|
325 | + $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
326 | + foreach ($initial_address_fields as $address_field_name) { |
|
327 | + $address_fields_value = $this->get($address_field_name); |
|
328 | + if (! empty($address_fields_value)) { |
|
329 | + $full_address_array[] = $address_fields_value; |
|
330 | + } |
|
331 | + } |
|
332 | + // now handle state and country |
|
333 | + $state_obj = $this->state_obj(); |
|
334 | + if ($state_obj instanceof EE_State) { |
|
335 | + $full_address_array[] = $state_obj->name(); |
|
336 | + } |
|
337 | + $country_obj = $this->country_obj(); |
|
338 | + if ($country_obj instanceof EE_Country) { |
|
339 | + $full_address_array[] = $country_obj->name(); |
|
340 | + } |
|
341 | + // lastly get the xip |
|
342 | + $zip_value = $this->zip(); |
|
343 | + if (! empty($zip_value)) { |
|
344 | + $full_address_array[] = $zip_value; |
|
345 | + } |
|
346 | + return $full_address_array; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * get Attendee Address |
|
352 | + * |
|
353 | + * @return string |
|
354 | + * @throws EE_Error |
|
355 | + */ |
|
356 | + public function address() |
|
357 | + { |
|
358 | + return $this->get('ATT_address'); |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * get Attendee Address2 |
|
364 | + * |
|
365 | + * @return string |
|
366 | + * @throws EE_Error |
|
367 | + */ |
|
368 | + public function address2() |
|
369 | + { |
|
370 | + return $this->get('ATT_address2'); |
|
371 | + } |
|
372 | + |
|
373 | + |
|
374 | + /** |
|
375 | + * get Attendee City |
|
376 | + * |
|
377 | + * @return string |
|
378 | + * @throws EE_Error |
|
379 | + */ |
|
380 | + public function city() |
|
381 | + { |
|
382 | + return $this->get('ATT_city'); |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * get Attendee State ID |
|
388 | + * |
|
389 | + * @return string |
|
390 | + * @throws EE_Error |
|
391 | + */ |
|
392 | + public function state_ID() |
|
393 | + { |
|
394 | + return $this->get('STA_ID'); |
|
395 | + } |
|
396 | + |
|
397 | + |
|
398 | + /** |
|
399 | + * @return string |
|
400 | + * @throws EE_Error |
|
401 | + */ |
|
402 | + public function state_abbrev() |
|
403 | + { |
|
404 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * Gets the state set to this attendee |
|
410 | + * |
|
411 | + * @return EE_State |
|
412 | + * @throws EE_Error |
|
413 | + */ |
|
414 | + public function state_obj() |
|
415 | + { |
|
416 | + return $this->get_first_related('State'); |
|
417 | + } |
|
418 | + |
|
419 | + |
|
420 | + /** |
|
421 | + * Returns the state's name, otherwise 'Unknown' |
|
422 | + * |
|
423 | + * @return string |
|
424 | + * @throws EE_Error |
|
425 | + */ |
|
426 | + public function state_name() |
|
427 | + { |
|
428 | + if ($this->state_obj()) { |
|
429 | + return $this->state_obj()->name(); |
|
430 | + } else { |
|
431 | + return ''; |
|
432 | + } |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * either displays the state abbreviation or the state name, as determined |
|
438 | + * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
439 | + * defaults to abbreviation |
|
440 | + * |
|
441 | + * @return string |
|
442 | + * @throws EE_Error |
|
443 | + */ |
|
444 | + public function state() |
|
445 | + { |
|
446 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
447 | + return $this->state_abbrev(); |
|
448 | + } |
|
449 | + return $this->state_name(); |
|
450 | + } |
|
451 | + |
|
452 | + |
|
453 | + /** |
|
454 | + * get Attendee Country ISO Code |
|
455 | + * |
|
456 | + * @return string |
|
457 | + * @throws EE_Error |
|
458 | + */ |
|
459 | + public function country_ID() |
|
460 | + { |
|
461 | + return $this->get('CNT_ISO'); |
|
462 | + } |
|
463 | + |
|
464 | + |
|
465 | + /** |
|
466 | + * Gets country set for this attendee |
|
467 | + * |
|
468 | + * @return EE_Country |
|
469 | + * @throws EE_Error |
|
470 | + */ |
|
471 | + public function country_obj() |
|
472 | + { |
|
473 | + return $this->get_first_related('Country'); |
|
474 | + } |
|
475 | + |
|
476 | + |
|
477 | + /** |
|
478 | + * Returns the country's name if known, otherwise 'Unknown' |
|
479 | + * |
|
480 | + * @return string |
|
481 | + * @throws EE_Error |
|
482 | + */ |
|
483 | + public function country_name() |
|
484 | + { |
|
485 | + if ($this->country_obj()) { |
|
486 | + return $this->country_obj()->name(); |
|
487 | + } |
|
488 | + return ''; |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * either displays the country ISO2 code or the country name, as determined |
|
494 | + * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
495 | + * defaults to abbreviation |
|
496 | + * |
|
497 | + * @return string |
|
498 | + * @throws EE_Error |
|
499 | + */ |
|
500 | + public function country() |
|
501 | + { |
|
502 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
503 | + return $this->country_ID(); |
|
504 | + } |
|
505 | + return $this->country_name(); |
|
506 | + } |
|
507 | + |
|
508 | + |
|
509 | + /** |
|
510 | + * get Attendee Zip/Postal Code |
|
511 | + * |
|
512 | + * @return string |
|
513 | + * @throws EE_Error |
|
514 | + */ |
|
515 | + public function zip() |
|
516 | + { |
|
517 | + return $this->get('ATT_zip'); |
|
518 | + } |
|
519 | + |
|
520 | + |
|
521 | + /** |
|
522 | + * get Attendee Email Address |
|
523 | + * |
|
524 | + * @return string |
|
525 | + * @throws EE_Error |
|
526 | + */ |
|
527 | + public function email() |
|
528 | + { |
|
529 | + return $this->get('ATT_email'); |
|
530 | + } |
|
531 | + |
|
532 | + |
|
533 | + /** |
|
534 | + * get Attendee Phone # |
|
535 | + * |
|
536 | + * @return string |
|
537 | + * @throws EE_Error |
|
538 | + */ |
|
539 | + public function phone() |
|
540 | + { |
|
541 | + return $this->get('ATT_phone'); |
|
542 | + } |
|
543 | + |
|
544 | + |
|
545 | + /** |
|
546 | + * get deleted |
|
547 | + * |
|
548 | + * @return bool |
|
549 | + * @throws EE_Error |
|
550 | + */ |
|
551 | + public function deleted() |
|
552 | + { |
|
553 | + return $this->get('ATT_deleted'); |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * Gets registrations of this attendee |
|
559 | + * |
|
560 | + * @param array $query_params |
|
561 | + * @return EE_Registration[] |
|
562 | + * @throws EE_Error |
|
563 | + */ |
|
564 | + public function get_registrations($query_params = array()) |
|
565 | + { |
|
566 | + return $this->get_many_related('Registration', $query_params); |
|
567 | + } |
|
568 | + |
|
569 | + |
|
570 | + /** |
|
571 | + * Gets the most recent registration of this attendee |
|
572 | + * |
|
573 | + * @return EE_Registration |
|
574 | + * @throws EE_Error |
|
575 | + */ |
|
576 | + public function get_most_recent_registration() |
|
577 | + { |
|
578 | + return $this->get_first_related( |
|
579 | + 'Registration', |
|
580 | + array('order_by' => array('REG_date' => 'DESC')) |
|
581 | + ); // null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
582 | + } |
|
583 | + |
|
584 | + |
|
585 | + /** |
|
586 | + * Gets the most recent registration for this attend at this event |
|
587 | + * |
|
588 | + * @param int $event_id |
|
589 | + * @return EE_Registration |
|
590 | + * @throws EE_Error |
|
591 | + */ |
|
592 | + public function get_most_recent_registration_for_event($event_id) |
|
593 | + { |
|
594 | + return $this->get_first_related( |
|
595 | + 'Registration', |
|
596 | + array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')) |
|
597 | + ); |
|
598 | + } |
|
599 | + |
|
600 | + |
|
601 | + /** |
|
602 | + * returns any events attached to this attendee ($_Event property); |
|
603 | + * |
|
604 | + * @return array |
|
605 | + * @throws EE_Error |
|
606 | + */ |
|
607 | + public function events() |
|
608 | + { |
|
609 | + return $this->get_many_related('Event'); |
|
610 | + } |
|
611 | + |
|
612 | + |
|
613 | + /** |
|
614 | + * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
615 | + * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
616 | + * used to save the billing info |
|
617 | + * |
|
618 | + * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
619 | + * @return EE_Form_Section_Proper|null |
|
620 | + * @throws EE_Error |
|
621 | + */ |
|
622 | + public function billing_info_for_payment_method($payment_method) |
|
623 | + { |
|
624 | + $pm_type = $payment_method->type_obj(); |
|
625 | + if (! $pm_type instanceof EE_PMT_Base) { |
|
626 | + return null; |
|
627 | + } |
|
628 | + $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
629 | + if (! $billing_info) { |
|
630 | + return null; |
|
631 | + } |
|
632 | + $billing_form = $pm_type->billing_form(); |
|
633 | + // double-check the form isn't totally hidden, in which case pretend there is no form |
|
634 | + $form_totally_hidden = true; |
|
635 | + foreach ($billing_form->inputs_in_subsections() as $input) { |
|
636 | + if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
637 | + $form_totally_hidden = false; |
|
638 | + break; |
|
639 | + } |
|
640 | + } |
|
641 | + if ($form_totally_hidden) { |
|
642 | + return null; |
|
643 | + } |
|
644 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
645 | + $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
646 | + } |
|
647 | + |
|
648 | + return $billing_form; |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + /** |
|
653 | + * Gets the postmeta key that holds this attendee's billing info for the |
|
654 | + * specified payment method |
|
655 | + * |
|
656 | + * @param EE_Payment_Method $payment_method |
|
657 | + * @return string |
|
658 | + * @throws EE_Error |
|
659 | + */ |
|
660 | + public function get_billing_info_postmeta_name($payment_method) |
|
661 | + { |
|
662 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
663 | + return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
664 | + } |
|
665 | + return null; |
|
666 | + } |
|
667 | + |
|
668 | + |
|
669 | + /** |
|
670 | + * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
671 | + * retrieve it |
|
672 | + * |
|
673 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
674 | + * @param EE_Payment_Method $payment_method |
|
675 | + * @return boolean |
|
676 | + * @throws EE_Error |
|
677 | + */ |
|
678 | + public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
679 | + { |
|
680 | + if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
681 | + EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
682 | + return false; |
|
683 | + } |
|
684 | + $billing_form->clean_sensitive_data(); |
|
685 | + return update_post_meta( |
|
686 | + $this->ID(), |
|
687 | + $this->get_billing_info_postmeta_name($payment_method), |
|
688 | + $billing_form->input_values(true) |
|
689 | + ); |
|
690 | + } |
|
691 | + |
|
692 | + |
|
693 | + /** |
|
694 | + * Return the link to the admin details for the object. |
|
695 | + * |
|
696 | + * @return string |
|
697 | + * @throws EE_Error |
|
698 | + * @throws InvalidArgumentException |
|
699 | + * @throws InvalidDataTypeException |
|
700 | + * @throws InvalidInterfaceException |
|
701 | + * @throws ReflectionException |
|
702 | + */ |
|
703 | + public function get_admin_details_link() |
|
704 | + { |
|
705 | + return $this->get_admin_edit_link(); |
|
706 | + } |
|
707 | + |
|
708 | + |
|
709 | + /** |
|
710 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
711 | + * |
|
712 | + * @return string |
|
713 | + * @throws EE_Error |
|
714 | + * @throws InvalidArgumentException |
|
715 | + * @throws ReflectionException |
|
716 | + * @throws InvalidDataTypeException |
|
717 | + * @throws InvalidInterfaceException |
|
718 | + */ |
|
719 | + public function get_admin_edit_link() |
|
720 | + { |
|
721 | + EE_Registry::instance()->load_helper('URL'); |
|
722 | + return EEH_URL::add_query_args_and_nonce( |
|
723 | + array( |
|
724 | + 'page' => 'espresso_registrations', |
|
725 | + 'action' => 'edit_attendee', |
|
726 | + 'post' => $this->ID(), |
|
727 | + ), |
|
728 | + admin_url('admin.php') |
|
729 | + ); |
|
730 | + } |
|
731 | + |
|
732 | + |
|
733 | + /** |
|
734 | + * Returns the link to a settings page for the object. |
|
735 | + * |
|
736 | + * @return string |
|
737 | + * @throws EE_Error |
|
738 | + * @throws InvalidArgumentException |
|
739 | + * @throws InvalidDataTypeException |
|
740 | + * @throws InvalidInterfaceException |
|
741 | + * @throws ReflectionException |
|
742 | + */ |
|
743 | + public function get_admin_settings_link() |
|
744 | + { |
|
745 | + return $this->get_admin_edit_link(); |
|
746 | + } |
|
747 | + |
|
748 | + |
|
749 | + /** |
|
750 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
751 | + * |
|
752 | + * @return string |
|
753 | + * @throws EE_Error |
|
754 | + * @throws InvalidArgumentException |
|
755 | + * @throws ReflectionException |
|
756 | + * @throws InvalidDataTypeException |
|
757 | + * @throws InvalidInterfaceException |
|
758 | + */ |
|
759 | + public function get_admin_overview_link() |
|
760 | + { |
|
761 | + EE_Registry::instance()->load_helper('URL'); |
|
762 | + return EEH_URL::add_query_args_and_nonce( |
|
763 | + array( |
|
764 | + 'page' => 'espresso_registrations', |
|
765 | + 'action' => 'contact_list', |
|
766 | + ), |
|
767 | + admin_url('admin.php') |
|
768 | + ); |
|
769 | + } |
|
770 | 770 | } |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | */ |
37 | 37 | protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
38 | 38 | { |
39 | - if (! isset($fieldValues['ATT_full_name'])) { |
|
40 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
39 | + if ( ! isset($fieldValues['ATT_full_name'])) { |
|
40 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : ''; |
|
41 | 41 | $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
42 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
42 | + $fieldValues['ATT_full_name'] = $fname.$lname; |
|
43 | 43 | } |
44 | - if (! isset($fieldValues['ATT_slug'])) { |
|
44 | + if ( ! isset($fieldValues['ATT_slug'])) { |
|
45 | 45 | // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
46 | 46 | $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
47 | 47 | } |
48 | - if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
48 | + if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
49 | 49 | $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
50 | 50 | } |
51 | 51 | parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
326 | 326 | foreach ($initial_address_fields as $address_field_name) { |
327 | 327 | $address_fields_value = $this->get($address_field_name); |
328 | - if (! empty($address_fields_value)) { |
|
328 | + if ( ! empty($address_fields_value)) { |
|
329 | 329 | $full_address_array[] = $address_fields_value; |
330 | 330 | } |
331 | 331 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | } |
341 | 341 | // lastly get the xip |
342 | 342 | $zip_value = $this->zip(); |
343 | - if (! empty($zip_value)) { |
|
343 | + if ( ! empty($zip_value)) { |
|
344 | 344 | $full_address_array[] = $zip_value; |
345 | 345 | } |
346 | 346 | return $full_address_array; |
@@ -622,18 +622,18 @@ discard block |
||
622 | 622 | public function billing_info_for_payment_method($payment_method) |
623 | 623 | { |
624 | 624 | $pm_type = $payment_method->type_obj(); |
625 | - if (! $pm_type instanceof EE_PMT_Base) { |
|
625 | + if ( ! $pm_type instanceof EE_PMT_Base) { |
|
626 | 626 | return null; |
627 | 627 | } |
628 | 628 | $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
629 | - if (! $billing_info) { |
|
629 | + if ( ! $billing_info) { |
|
630 | 630 | return null; |
631 | 631 | } |
632 | 632 | $billing_form = $pm_type->billing_form(); |
633 | 633 | // double-check the form isn't totally hidden, in which case pretend there is no form |
634 | 634 | $form_totally_hidden = true; |
635 | 635 | foreach ($billing_form->inputs_in_subsections() as $input) { |
636 | - if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
636 | + if ( ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
637 | 637 | $form_totally_hidden = false; |
638 | 638 | break; |
639 | 639 | } |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | public function get_billing_info_postmeta_name($payment_method) |
661 | 661 | { |
662 | 662 | if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
663 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
663 | + return 'billing_info_'.$payment_method->type_obj()->system_name(); |
|
664 | 664 | } |
665 | 665 | return null; |
666 | 666 | } |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | */ |
678 | 678 | public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
679 | 679 | { |
680 | - if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
680 | + if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
681 | 681 | EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
682 | 682 | return false; |
683 | 683 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | */ |
52 | 52 | public function wp_user_obj() |
53 | 53 | { |
54 | - if (! $this->_wp_user_obj) { |
|
54 | + if ( ! $this->_wp_user_obj) { |
|
55 | 55 | $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
56 | 56 | } |
57 | 57 | return $this->_wp_user_obj; |
@@ -11,91 +11,91 @@ |
||
11 | 11 | class EE_WP_User extends EE_Base_Class implements EEI_Admin_Links |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @var WP_User |
|
16 | - */ |
|
17 | - protected $_wp_user_obj; |
|
14 | + /** |
|
15 | + * @var WP_User |
|
16 | + */ |
|
17 | + protected $_wp_user_obj; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @param array $props_n_values |
|
21 | - * @return EE_WP_User|mixed |
|
22 | - */ |
|
23 | - public static function new_instance($props_n_values = array()) |
|
24 | - { |
|
25 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
26 | - return $has_object ? $has_object : new self($props_n_values); |
|
27 | - } |
|
19 | + /** |
|
20 | + * @param array $props_n_values |
|
21 | + * @return EE_WP_User|mixed |
|
22 | + */ |
|
23 | + public static function new_instance($props_n_values = array()) |
|
24 | + { |
|
25 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
26 | + return $has_object ? $has_object : new self($props_n_values); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @param array $props_n_values |
|
32 | - * @return EE_WP_User |
|
33 | - */ |
|
34 | - public static function new_instance_from_db($props_n_values = array()) |
|
35 | - { |
|
36 | - return new self($props_n_values, true); |
|
37 | - } |
|
30 | + /** |
|
31 | + * @param array $props_n_values |
|
32 | + * @return EE_WP_User |
|
33 | + */ |
|
34 | + public static function new_instance_from_db($props_n_values = array()) |
|
35 | + { |
|
36 | + return new self($props_n_values, true); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Return a normal WP_User object (caches the object for future calls) |
|
41 | - * |
|
42 | - * @return WP_User |
|
43 | - */ |
|
44 | - public function wp_user_obj() |
|
45 | - { |
|
46 | - if (! $this->_wp_user_obj) { |
|
47 | - $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
48 | - } |
|
49 | - return $this->_wp_user_obj; |
|
50 | - } |
|
39 | + /** |
|
40 | + * Return a normal WP_User object (caches the object for future calls) |
|
41 | + * |
|
42 | + * @return WP_User |
|
43 | + */ |
|
44 | + public function wp_user_obj() |
|
45 | + { |
|
46 | + if (! $this->_wp_user_obj) { |
|
47 | + $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
48 | + } |
|
49 | + return $this->_wp_user_obj; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Return the link to the admin details for the object. |
|
54 | - * |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function get_admin_details_link() |
|
58 | - { |
|
59 | - return $this->get_admin_edit_link(); |
|
60 | - } |
|
52 | + /** |
|
53 | + * Return the link to the admin details for the object. |
|
54 | + * |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function get_admin_details_link() |
|
58 | + { |
|
59 | + return $this->get_admin_edit_link(); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
64 | - * |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function get_admin_edit_link() |
|
68 | - { |
|
69 | - return esc_url( |
|
70 | - add_query_arg( |
|
71 | - 'wp_http_referer', |
|
72 | - urlencode( |
|
73 | - wp_unslash( |
|
74 | - $_SERVER['REQUEST_URI'] |
|
75 | - ) |
|
76 | - ), |
|
77 | - get_edit_user_link($this->ID()) |
|
78 | - ) |
|
79 | - ); |
|
80 | - } |
|
62 | + /** |
|
63 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
64 | + * |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function get_admin_edit_link() |
|
68 | + { |
|
69 | + return esc_url( |
|
70 | + add_query_arg( |
|
71 | + 'wp_http_referer', |
|
72 | + urlencode( |
|
73 | + wp_unslash( |
|
74 | + $_SERVER['REQUEST_URI'] |
|
75 | + ) |
|
76 | + ), |
|
77 | + get_edit_user_link($this->ID()) |
|
78 | + ) |
|
79 | + ); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Returns the link to a settings page for the object. |
|
84 | - * |
|
85 | - * @return string |
|
86 | - */ |
|
87 | - public function get_admin_settings_link() |
|
88 | - { |
|
89 | - return $this->get_admin_edit_link(); |
|
90 | - } |
|
82 | + /** |
|
83 | + * Returns the link to a settings page for the object. |
|
84 | + * |
|
85 | + * @return string |
|
86 | + */ |
|
87 | + public function get_admin_settings_link() |
|
88 | + { |
|
89 | + return $this->get_admin_edit_link(); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
94 | - * |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function get_admin_overview_link() |
|
98 | - { |
|
99 | - return admin_url('users.php'); |
|
100 | - } |
|
92 | + /** |
|
93 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
94 | + * |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function get_admin_overview_link() |
|
98 | + { |
|
99 | + return admin_url('users.php'); |
|
100 | + } |
|
101 | 101 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * this method instantiates modules and calls the method that was defined when the route was registered |
183 | 183 | * |
184 | 184 | * @param string $module_name |
185 | - * @return EED_Module|object|null |
|
185 | + * @return null|EED_Module |
|
186 | 186 | * @throws ReflectionException |
187 | 187 | */ |
188 | 188 | public static function module_factory($module_name) |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | |
254 | 254 | /** |
255 | - * @param $current_route |
|
255 | + * @param string $current_route |
|
256 | 256 | * @return string |
257 | 257 | */ |
258 | 258 | public function get_view($current_route) |
@@ -15,255 +15,255 @@ |
||
15 | 15 | final class EE_Module_Request_Router implements InterminableInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var EE_Request $request |
|
20 | - */ |
|
21 | - private $request; |
|
18 | + /** |
|
19 | + * @var EE_Request $request |
|
20 | + */ |
|
21 | + private $request; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var array $_previous_routes |
|
25 | - */ |
|
26 | - private static $_previous_routes = array(); |
|
23 | + /** |
|
24 | + * @var array $_previous_routes |
|
25 | + */ |
|
26 | + private static $_previous_routes = array(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var WP_Query $WP_Query |
|
30 | - */ |
|
31 | - public $WP_Query; |
|
28 | + /** |
|
29 | + * @var WP_Query $WP_Query |
|
30 | + */ |
|
31 | + public $WP_Query; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * EE_Module_Request_Router constructor. |
|
36 | - * |
|
37 | - * @param EE_Request $request |
|
38 | - */ |
|
39 | - public function __construct(EE_Request $request) |
|
40 | - { |
|
41 | - $this->request = $request; |
|
42 | - } |
|
34 | + /** |
|
35 | + * EE_Module_Request_Router constructor. |
|
36 | + * |
|
37 | + * @param EE_Request $request |
|
38 | + */ |
|
39 | + public function __construct(EE_Request $request) |
|
40 | + { |
|
41 | + $this->request = $request; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * on the first call to this method, it checks the EE_Request_Handler for a "route" |
|
47 | - * on subsequent calls to this method, |
|
48 | - * instead of checking the EE_Request_Handler for a route, it checks the previous routes array, |
|
49 | - * and checks if the last called route has any forwarding routes registered for it |
|
50 | - * |
|
51 | - * @param WP_Query $WP_Query |
|
52 | - * @return NULL|string |
|
53 | - * @throws EE_Error |
|
54 | - * @throws ReflectionException |
|
55 | - */ |
|
56 | - public function get_route(WP_Query $WP_Query) |
|
57 | - { |
|
58 | - $this->WP_Query = $WP_Query; |
|
59 | - // assume this if first route being called |
|
60 | - $previous_route = false; |
|
61 | - // but is it really ??? |
|
62 | - if (! empty(self::$_previous_routes)) { |
|
63 | - // get last run route |
|
64 | - $previous_routes = array_values(self::$_previous_routes); |
|
65 | - $previous_route = array_pop($previous_routes); |
|
66 | - } |
|
67 | - // has another route already been run ? |
|
68 | - if ($previous_route) { |
|
69 | - // check if forwarding has been set |
|
70 | - $current_route = $this->get_forward($previous_route); |
|
71 | - try { |
|
72 | - // check for recursive forwarding |
|
73 | - if (isset(self::$_previous_routes[ $current_route ])) { |
|
74 | - throw new EE_Error( |
|
75 | - sprintf( |
|
76 | - __( |
|
77 | - 'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.', |
|
78 | - 'event_espresso' |
|
79 | - ), |
|
80 | - $current_route |
|
81 | - ) |
|
82 | - ); |
|
83 | - } |
|
84 | - } catch (EE_Error $e) { |
|
85 | - $e->get_error(); |
|
86 | - return null; |
|
87 | - } |
|
88 | - } else { |
|
89 | - // first route called |
|
90 | - $current_route = null; |
|
91 | - // grab all routes |
|
92 | - $routes = EE_Config::get_routes(); |
|
93 | - foreach ($routes as $key => $route) { |
|
94 | - // first determine if route key uses w?ldc*rds |
|
95 | - $uses_wildcards = strpos($key, '?') !== false |
|
96 | - || strpos($key, '*') !== false; |
|
97 | - // check request for module route |
|
98 | - $route_found = $uses_wildcards |
|
99 | - ? $this->request->matches($key) |
|
100 | - : $this->request->is_set($key); |
|
101 | - if ($route_found) { |
|
102 | - $current_route = $uses_wildcards |
|
103 | - ? $this->request->getMatch($key) |
|
104 | - : $this->request->get($key); |
|
105 | - $current_route = sanitize_text_field($current_route); |
|
106 | - if ($current_route) { |
|
107 | - $current_route = array($key, $current_route); |
|
108 | - break; |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
112 | - } |
|
113 | - // sorry, but I can't read what you route ! |
|
114 | - if (empty($current_route)) { |
|
115 | - return null; |
|
116 | - } |
|
117 | - // add route to previous routes array |
|
118 | - self::$_previous_routes[] = $current_route; |
|
119 | - return $current_route; |
|
120 | - } |
|
45 | + /** |
|
46 | + * on the first call to this method, it checks the EE_Request_Handler for a "route" |
|
47 | + * on subsequent calls to this method, |
|
48 | + * instead of checking the EE_Request_Handler for a route, it checks the previous routes array, |
|
49 | + * and checks if the last called route has any forwarding routes registered for it |
|
50 | + * |
|
51 | + * @param WP_Query $WP_Query |
|
52 | + * @return NULL|string |
|
53 | + * @throws EE_Error |
|
54 | + * @throws ReflectionException |
|
55 | + */ |
|
56 | + public function get_route(WP_Query $WP_Query) |
|
57 | + { |
|
58 | + $this->WP_Query = $WP_Query; |
|
59 | + // assume this if first route being called |
|
60 | + $previous_route = false; |
|
61 | + // but is it really ??? |
|
62 | + if (! empty(self::$_previous_routes)) { |
|
63 | + // get last run route |
|
64 | + $previous_routes = array_values(self::$_previous_routes); |
|
65 | + $previous_route = array_pop($previous_routes); |
|
66 | + } |
|
67 | + // has another route already been run ? |
|
68 | + if ($previous_route) { |
|
69 | + // check if forwarding has been set |
|
70 | + $current_route = $this->get_forward($previous_route); |
|
71 | + try { |
|
72 | + // check for recursive forwarding |
|
73 | + if (isset(self::$_previous_routes[ $current_route ])) { |
|
74 | + throw new EE_Error( |
|
75 | + sprintf( |
|
76 | + __( |
|
77 | + 'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.', |
|
78 | + 'event_espresso' |
|
79 | + ), |
|
80 | + $current_route |
|
81 | + ) |
|
82 | + ); |
|
83 | + } |
|
84 | + } catch (EE_Error $e) { |
|
85 | + $e->get_error(); |
|
86 | + return null; |
|
87 | + } |
|
88 | + } else { |
|
89 | + // first route called |
|
90 | + $current_route = null; |
|
91 | + // grab all routes |
|
92 | + $routes = EE_Config::get_routes(); |
|
93 | + foreach ($routes as $key => $route) { |
|
94 | + // first determine if route key uses w?ldc*rds |
|
95 | + $uses_wildcards = strpos($key, '?') !== false |
|
96 | + || strpos($key, '*') !== false; |
|
97 | + // check request for module route |
|
98 | + $route_found = $uses_wildcards |
|
99 | + ? $this->request->matches($key) |
|
100 | + : $this->request->is_set($key); |
|
101 | + if ($route_found) { |
|
102 | + $current_route = $uses_wildcards |
|
103 | + ? $this->request->getMatch($key) |
|
104 | + : $this->request->get($key); |
|
105 | + $current_route = sanitize_text_field($current_route); |
|
106 | + if ($current_route) { |
|
107 | + $current_route = array($key, $current_route); |
|
108 | + break; |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | + } |
|
113 | + // sorry, but I can't read what you route ! |
|
114 | + if (empty($current_route)) { |
|
115 | + return null; |
|
116 | + } |
|
117 | + // add route to previous routes array |
|
118 | + self::$_previous_routes[] = $current_route; |
|
119 | + return $current_route; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * this method simply takes a valid route, and resolves what module class method the route points to |
|
125 | - * |
|
126 | - * @param string $key |
|
127 | - * @param string $current_route |
|
128 | - * @return mixed EED_Module | boolean |
|
129 | - * @throws EE_Error |
|
130 | - * @throws ReflectionException |
|
131 | - */ |
|
132 | - public function resolve_route($key, $current_route) |
|
133 | - { |
|
134 | - // get module method that route has been mapped to |
|
135 | - $module_method = EE_Config::get_route($current_route, $key); |
|
136 | - // verify result was returned |
|
137 | - if (empty($module_method)) { |
|
138 | - $msg = sprintf( |
|
139 | - __('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), |
|
140 | - $current_route |
|
141 | - ); |
|
142 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
143 | - return false; |
|
144 | - } |
|
145 | - // verify that result is an array |
|
146 | - if (! is_array($module_method)) { |
|
147 | - $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
148 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
149 | - return false; |
|
150 | - } |
|
151 | - // grab module name |
|
152 | - $module_name = $module_method[0]; |
|
153 | - // verify that a class method was registered properly |
|
154 | - if (! isset($module_method[1])) { |
|
155 | - $msg = sprintf( |
|
156 | - __('A class method for the %s route has not been properly registered.', 'event_espresso'), |
|
157 | - $current_route |
|
158 | - ); |
|
159 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
160 | - return false; |
|
161 | - } |
|
162 | - // grab method |
|
163 | - $method = $module_method[1]; |
|
164 | - // verify that class exists |
|
165 | - if (! class_exists($module_name)) { |
|
166 | - $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
|
167 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
168 | - return false; |
|
169 | - } |
|
170 | - // verify that method exists |
|
171 | - if (! method_exists($module_name, $method)) { |
|
172 | - $msg = sprintf( |
|
173 | - __('The class method %s for the %s route is in invalid.', 'event_espresso'), |
|
174 | - $method, |
|
175 | - $current_route |
|
176 | - ); |
|
177 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
178 | - return false; |
|
179 | - } |
|
180 | - // instantiate module and call route method |
|
181 | - return $this->_module_router($module_name, $method); |
|
182 | - } |
|
123 | + /** |
|
124 | + * this method simply takes a valid route, and resolves what module class method the route points to |
|
125 | + * |
|
126 | + * @param string $key |
|
127 | + * @param string $current_route |
|
128 | + * @return mixed EED_Module | boolean |
|
129 | + * @throws EE_Error |
|
130 | + * @throws ReflectionException |
|
131 | + */ |
|
132 | + public function resolve_route($key, $current_route) |
|
133 | + { |
|
134 | + // get module method that route has been mapped to |
|
135 | + $module_method = EE_Config::get_route($current_route, $key); |
|
136 | + // verify result was returned |
|
137 | + if (empty($module_method)) { |
|
138 | + $msg = sprintf( |
|
139 | + __('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), |
|
140 | + $current_route |
|
141 | + ); |
|
142 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
143 | + return false; |
|
144 | + } |
|
145 | + // verify that result is an array |
|
146 | + if (! is_array($module_method)) { |
|
147 | + $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
148 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
149 | + return false; |
|
150 | + } |
|
151 | + // grab module name |
|
152 | + $module_name = $module_method[0]; |
|
153 | + // verify that a class method was registered properly |
|
154 | + if (! isset($module_method[1])) { |
|
155 | + $msg = sprintf( |
|
156 | + __('A class method for the %s route has not been properly registered.', 'event_espresso'), |
|
157 | + $current_route |
|
158 | + ); |
|
159 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
160 | + return false; |
|
161 | + } |
|
162 | + // grab method |
|
163 | + $method = $module_method[1]; |
|
164 | + // verify that class exists |
|
165 | + if (! class_exists($module_name)) { |
|
166 | + $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
|
167 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
168 | + return false; |
|
169 | + } |
|
170 | + // verify that method exists |
|
171 | + if (! method_exists($module_name, $method)) { |
|
172 | + $msg = sprintf( |
|
173 | + __('The class method %s for the %s route is in invalid.', 'event_espresso'), |
|
174 | + $method, |
|
175 | + $current_route |
|
176 | + ); |
|
177 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
178 | + return false; |
|
179 | + } |
|
180 | + // instantiate module and call route method |
|
181 | + return $this->_module_router($module_name, $method); |
|
182 | + } |
|
183 | 183 | |
184 | 184 | |
185 | - /** |
|
186 | - * this method instantiates modules and calls the method that was defined when the route was registered |
|
187 | - * |
|
188 | - * @param string $module_name |
|
189 | - * @return EED_Module|object|null |
|
190 | - * @throws ReflectionException |
|
191 | - */ |
|
192 | - public static function module_factory($module_name) |
|
193 | - { |
|
194 | - if ($module_name === 'EED_Module') { |
|
195 | - EE_Error::add_error( |
|
196 | - sprintf( |
|
197 | - __( |
|
198 | - 'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.', |
|
199 | - 'event_espresso' |
|
200 | - ), |
|
201 | - $module_name |
|
202 | - ), |
|
203 | - __FILE__, |
|
204 | - __FUNCTION__, |
|
205 | - __LINE__ |
|
206 | - ); |
|
207 | - return null; |
|
208 | - } |
|
209 | - // instantiate module class |
|
210 | - $module = new $module_name(); |
|
211 | - // ensure that class is actually a module |
|
212 | - if (! $module instanceof EED_Module) { |
|
213 | - EE_Error::add_error( |
|
214 | - sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
|
215 | - __FILE__, |
|
216 | - __FUNCTION__, |
|
217 | - __LINE__ |
|
218 | - ); |
|
219 | - return null; |
|
220 | - } |
|
221 | - return $module; |
|
222 | - } |
|
185 | + /** |
|
186 | + * this method instantiates modules and calls the method that was defined when the route was registered |
|
187 | + * |
|
188 | + * @param string $module_name |
|
189 | + * @return EED_Module|object|null |
|
190 | + * @throws ReflectionException |
|
191 | + */ |
|
192 | + public static function module_factory($module_name) |
|
193 | + { |
|
194 | + if ($module_name === 'EED_Module') { |
|
195 | + EE_Error::add_error( |
|
196 | + sprintf( |
|
197 | + __( |
|
198 | + 'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.', |
|
199 | + 'event_espresso' |
|
200 | + ), |
|
201 | + $module_name |
|
202 | + ), |
|
203 | + __FILE__, |
|
204 | + __FUNCTION__, |
|
205 | + __LINE__ |
|
206 | + ); |
|
207 | + return null; |
|
208 | + } |
|
209 | + // instantiate module class |
|
210 | + $module = new $module_name(); |
|
211 | + // ensure that class is actually a module |
|
212 | + if (! $module instanceof EED_Module) { |
|
213 | + EE_Error::add_error( |
|
214 | + sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
|
215 | + __FILE__, |
|
216 | + __FUNCTION__, |
|
217 | + __LINE__ |
|
218 | + ); |
|
219 | + return null; |
|
220 | + } |
|
221 | + return $module; |
|
222 | + } |
|
223 | 223 | |
224 | 224 | |
225 | - /** |
|
226 | - * this method instantiates modules and calls the method that was defined when the route was registered |
|
227 | - * |
|
228 | - * @param string $module_name |
|
229 | - * @param string $method |
|
230 | - * @return EED_Module|null |
|
231 | - * @throws EE_Error |
|
232 | - * @throws ReflectionException |
|
233 | - */ |
|
234 | - private function _module_router($module_name, $method) |
|
235 | - { |
|
236 | - // instantiate module class |
|
237 | - $module = EE_Module_Request_Router::module_factory($module_name); |
|
238 | - if ($module instanceof EED_Module) { |
|
239 | - // and call whatever action the route was for |
|
240 | - try { |
|
241 | - call_user_func(array($module, $method), $this->WP_Query); |
|
242 | - } catch (EE_Error $e) { |
|
243 | - $e->get_error(); |
|
244 | - return null; |
|
245 | - } |
|
246 | - } |
|
247 | - return $module; |
|
248 | - } |
|
225 | + /** |
|
226 | + * this method instantiates modules and calls the method that was defined when the route was registered |
|
227 | + * |
|
228 | + * @param string $module_name |
|
229 | + * @param string $method |
|
230 | + * @return EED_Module|null |
|
231 | + * @throws EE_Error |
|
232 | + * @throws ReflectionException |
|
233 | + */ |
|
234 | + private function _module_router($module_name, $method) |
|
235 | + { |
|
236 | + // instantiate module class |
|
237 | + $module = EE_Module_Request_Router::module_factory($module_name); |
|
238 | + if ($module instanceof EED_Module) { |
|
239 | + // and call whatever action the route was for |
|
240 | + try { |
|
241 | + call_user_func(array($module, $method), $this->WP_Query); |
|
242 | + } catch (EE_Error $e) { |
|
243 | + $e->get_error(); |
|
244 | + return null; |
|
245 | + } |
|
246 | + } |
|
247 | + return $module; |
|
248 | + } |
|
249 | 249 | |
250 | 250 | |
251 | - /** |
|
252 | - * @param $current_route |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public function get_forward($current_route) |
|
256 | - { |
|
257 | - return EE_Config::get_forward($current_route); |
|
258 | - } |
|
251 | + /** |
|
252 | + * @param $current_route |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public function get_forward($current_route) |
|
256 | + { |
|
257 | + return EE_Config::get_forward($current_route); |
|
258 | + } |
|
259 | 259 | |
260 | 260 | |
261 | - /** |
|
262 | - * @param $current_route |
|
263 | - * @return string |
|
264 | - */ |
|
265 | - public function get_view($current_route) |
|
266 | - { |
|
267 | - return EE_Config::get_view($current_route); |
|
268 | - } |
|
261 | + /** |
|
262 | + * @param $current_route |
|
263 | + * @return string |
|
264 | + */ |
|
265 | + public function get_view($current_route) |
|
266 | + { |
|
267 | + return EE_Config::get_view($current_route); |
|
268 | + } |
|
269 | 269 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // assume this if first route being called |
60 | 60 | $previous_route = false; |
61 | 61 | // but is it really ??? |
62 | - if (! empty(self::$_previous_routes)) { |
|
62 | + if ( ! empty(self::$_previous_routes)) { |
|
63 | 63 | // get last run route |
64 | 64 | $previous_routes = array_values(self::$_previous_routes); |
65 | 65 | $previous_route = array_pop($previous_routes); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $current_route = $this->get_forward($previous_route); |
71 | 71 | try { |
72 | 72 | // check for recursive forwarding |
73 | - if (isset(self::$_previous_routes[ $current_route ])) { |
|
73 | + if (isset(self::$_previous_routes[$current_route])) { |
|
74 | 74 | throw new EE_Error( |
75 | 75 | sprintf( |
76 | 76 | __( |
@@ -143,38 +143,38 @@ discard block |
||
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | // verify that result is an array |
146 | - if (! is_array($module_method)) { |
|
146 | + if ( ! is_array($module_method)) { |
|
147 | 147 | $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
148 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
148 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
149 | 149 | return false; |
150 | 150 | } |
151 | 151 | // grab module name |
152 | 152 | $module_name = $module_method[0]; |
153 | 153 | // verify that a class method was registered properly |
154 | - if (! isset($module_method[1])) { |
|
154 | + if ( ! isset($module_method[1])) { |
|
155 | 155 | $msg = sprintf( |
156 | 156 | __('A class method for the %s route has not been properly registered.', 'event_espresso'), |
157 | 157 | $current_route |
158 | 158 | ); |
159 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
159 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | // grab method |
163 | 163 | $method = $module_method[1]; |
164 | 164 | // verify that class exists |
165 | - if (! class_exists($module_name)) { |
|
165 | + if ( ! class_exists($module_name)) { |
|
166 | 166 | $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
167 | 167 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | // verify that method exists |
171 | - if (! method_exists($module_name, $method)) { |
|
171 | + if ( ! method_exists($module_name, $method)) { |
|
172 | 172 | $msg = sprintf( |
173 | 173 | __('The class method %s for the %s route is in invalid.', 'event_espresso'), |
174 | 174 | $method, |
175 | 175 | $current_route |
176 | 176 | ); |
177 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
177 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | // instantiate module and call route method |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | // instantiate module class |
210 | 210 | $module = new $module_name(); |
211 | 211 | // ensure that class is actually a module |
212 | - if (! $module instanceof EED_Module) { |
|
212 | + if ( ! $module instanceof EED_Module) { |
|
213 | 213 | EE_Error::add_error( |
214 | 214 | sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
215 | 215 | __FILE__, |