@@ -12,186 +12,186 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * holds values for registered messages shortcode libraries |
|
17 | - * |
|
18 | - * @var array |
|
19 | - */ |
|
20 | - protected static $_ee_messages_shortcode_registry = array(); |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * Helper method for registring a new shortcodes library class for the messages system. |
|
25 | - * |
|
26 | - * Note this is not used for adding shortcodes to existing libraries. It's for registering anything |
|
27 | - * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class. |
|
28 | - * |
|
29 | - * @since 4.3.0 |
|
30 | - * |
|
31 | - * @param array $setup_args { |
|
32 | - * An array of arguments provided for registering the new messages |
|
33 | - * shortcode library. |
|
34 | - * |
|
35 | - * @type string $name What is the name of this shortcode library |
|
36 | - * (e.g. 'question_list'); |
|
37 | - * @type array $autoloadpaths An array of paths to add to the messages |
|
38 | - * autoloader for the new shortcode |
|
39 | - * library class file. |
|
40 | - * @type string $msgr_validator_callback Callback for a method that will register the |
|
41 | - * library with the messenger |
|
42 | - * _validator_config. Optional. |
|
43 | - * @type string $msgr_template_fields_callback Callback for changing adding the |
|
44 | - * _template_fields property for |
|
45 | - * messenger. For example, the |
|
46 | - * shortcode library may add a new |
|
47 | - * field to the message templates. |
|
48 | - * Optional. |
|
49 | - * @type string $valid_shortcodes_callback Callback for message types |
|
50 | - * _valid_shortcodes array setup. |
|
51 | - * Optional. |
|
52 | - * @type array $list_type_shortcodes If there are any specific shortcodes with this |
|
53 | - * message shortcode library that |
|
54 | - * should be considered "list type" |
|
55 | - * then include them in an array. List |
|
56 | - * Type shortcodes are shortcodes that |
|
57 | - * have a corresponding field that |
|
58 | - * indicates how they are parsed. |
|
59 | - * Optional. |
|
60 | - * } |
|
61 | - * @return void |
|
62 | - */ |
|
63 | - public static function register($name = null, $setup_args = array()) |
|
64 | - { |
|
65 | - |
|
66 | - // required fields MUST be present, so let's make sure they are. |
|
67 | - if (empty($name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) { |
|
68 | - throw new EE_Error( |
|
69 | - __( |
|
70 | - 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', |
|
71 | - 'event_espresso' |
|
72 | - ) |
|
73 | - ); |
|
74 | - } |
|
75 | - |
|
76 | - // make sure we don't register twice |
|
77 | - if (isset(self::$_ee_messages_shortcode_registry[ $name ])) { |
|
78 | - return; |
|
79 | - } |
|
80 | - |
|
81 | - // make sure this was called in the right place! |
|
82 | - if (! did_action('EE_Brewing_Regular___messages_caf') |
|
83 | - || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
84 | - ) { |
|
85 | - EE_Error::doing_it_wrong( |
|
86 | - __METHOD__, |
|
87 | - sprintf( |
|
88 | - __( |
|
89 | - 'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).', |
|
90 | - 'event_espresso' |
|
91 | - ), |
|
92 | - $name |
|
93 | - ), |
|
94 | - '4.3.0' |
|
95 | - ); |
|
96 | - } |
|
97 | - |
|
98 | - $name = (string) $name; |
|
99 | - self::$_ee_messages_shortcode_registry[ $name ] = array( |
|
100 | - 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
101 | - 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) |
|
102 | - ? (array) $setup_args['list_type_shortcodes'] : array(), |
|
103 | - ); |
|
104 | - |
|
105 | - // add filters |
|
106 | - add_filter( |
|
107 | - 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
108 | - array('EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), |
|
109 | - 10 |
|
110 | - ); |
|
111 | - |
|
112 | - // add below filters if the required callback is provided. |
|
113 | - if (! empty($setup_args['msgr_validator_callback'])) { |
|
114 | - add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
|
115 | - } |
|
116 | - |
|
117 | - if (! empty($setup_args['msgr_template_fields_callback'])) { |
|
118 | - add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
|
119 | - } |
|
120 | - |
|
121 | - if (! empty($setup_args['valid_shortcodes_callback'])) { |
|
122 | - add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
|
123 | - } |
|
124 | - |
|
125 | - if (! empty($setup_args['list_type_shortcodes'])) { |
|
126 | - add_filter( |
|
127 | - 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
|
128 | - array('EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), |
|
129 | - 10 |
|
130 | - ); |
|
131 | - } |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * This deregisters any messages shortcode library previously registered with the given name. |
|
137 | - * |
|
138 | - * @since 4.3.0 |
|
139 | - * @param string $name name used to register the shortcode library. |
|
140 | - * @return void |
|
141 | - */ |
|
142 | - public static function deregister($name = null) |
|
143 | - { |
|
144 | - if (! empty(self::$_ee_messages_shortcode_registry[ $name ])) { |
|
145 | - unset(self::$_ee_messages_shortcode_registry[ $name ]); |
|
146 | - } |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
152 | - * |
|
153 | - * @since 4.3.0 |
|
154 | - * |
|
155 | - * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
156 | - * @return array |
|
157 | - */ |
|
158 | - public static function register_msgs_autoload_paths($paths) |
|
159 | - { |
|
160 | - |
|
161 | - if (! empty(self::$_ee_messages_shortcode_registry)) { |
|
162 | - foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
|
163 | - if (empty($st_reg['autoloadpaths'])) { |
|
164 | - continue; |
|
165 | - } |
|
166 | - $paths = array_merge($paths, $st_reg['autoloadpaths']); |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - return $paths; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes |
|
176 | - * filter which is used to add additional list type shortcodes. |
|
177 | - * |
|
178 | - * @since 4.3.0 |
|
179 | - * |
|
180 | - * @param array $original_shortcodes |
|
181 | - * @return array Modifications to original shortcodes. |
|
182 | - */ |
|
183 | - public static function register_list_type_shortcodes($original_shortcodes) |
|
184 | - { |
|
185 | - if (empty(self::$_ee_messages_shortcode_registry)) { |
|
186 | - return $original_shortcodes; |
|
187 | - } |
|
188 | - |
|
189 | - foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
|
190 | - if (! empty($sc_reg['list_type_shortcodes'])) { |
|
191 | - $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']); |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - return $original_shortcodes; |
|
196 | - } |
|
15 | + /** |
|
16 | + * holds values for registered messages shortcode libraries |
|
17 | + * |
|
18 | + * @var array |
|
19 | + */ |
|
20 | + protected static $_ee_messages_shortcode_registry = array(); |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * Helper method for registring a new shortcodes library class for the messages system. |
|
25 | + * |
|
26 | + * Note this is not used for adding shortcodes to existing libraries. It's for registering anything |
|
27 | + * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class. |
|
28 | + * |
|
29 | + * @since 4.3.0 |
|
30 | + * |
|
31 | + * @param array $setup_args { |
|
32 | + * An array of arguments provided for registering the new messages |
|
33 | + * shortcode library. |
|
34 | + * |
|
35 | + * @type string $name What is the name of this shortcode library |
|
36 | + * (e.g. 'question_list'); |
|
37 | + * @type array $autoloadpaths An array of paths to add to the messages |
|
38 | + * autoloader for the new shortcode |
|
39 | + * library class file. |
|
40 | + * @type string $msgr_validator_callback Callback for a method that will register the |
|
41 | + * library with the messenger |
|
42 | + * _validator_config. Optional. |
|
43 | + * @type string $msgr_template_fields_callback Callback for changing adding the |
|
44 | + * _template_fields property for |
|
45 | + * messenger. For example, the |
|
46 | + * shortcode library may add a new |
|
47 | + * field to the message templates. |
|
48 | + * Optional. |
|
49 | + * @type string $valid_shortcodes_callback Callback for message types |
|
50 | + * _valid_shortcodes array setup. |
|
51 | + * Optional. |
|
52 | + * @type array $list_type_shortcodes If there are any specific shortcodes with this |
|
53 | + * message shortcode library that |
|
54 | + * should be considered "list type" |
|
55 | + * then include them in an array. List |
|
56 | + * Type shortcodes are shortcodes that |
|
57 | + * have a corresponding field that |
|
58 | + * indicates how they are parsed. |
|
59 | + * Optional. |
|
60 | + * } |
|
61 | + * @return void |
|
62 | + */ |
|
63 | + public static function register($name = null, $setup_args = array()) |
|
64 | + { |
|
65 | + |
|
66 | + // required fields MUST be present, so let's make sure they are. |
|
67 | + if (empty($name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) { |
|
68 | + throw new EE_Error( |
|
69 | + __( |
|
70 | + 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', |
|
71 | + 'event_espresso' |
|
72 | + ) |
|
73 | + ); |
|
74 | + } |
|
75 | + |
|
76 | + // make sure we don't register twice |
|
77 | + if (isset(self::$_ee_messages_shortcode_registry[ $name ])) { |
|
78 | + return; |
|
79 | + } |
|
80 | + |
|
81 | + // make sure this was called in the right place! |
|
82 | + if (! did_action('EE_Brewing_Regular___messages_caf') |
|
83 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
84 | + ) { |
|
85 | + EE_Error::doing_it_wrong( |
|
86 | + __METHOD__, |
|
87 | + sprintf( |
|
88 | + __( |
|
89 | + 'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).', |
|
90 | + 'event_espresso' |
|
91 | + ), |
|
92 | + $name |
|
93 | + ), |
|
94 | + '4.3.0' |
|
95 | + ); |
|
96 | + } |
|
97 | + |
|
98 | + $name = (string) $name; |
|
99 | + self::$_ee_messages_shortcode_registry[ $name ] = array( |
|
100 | + 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
101 | + 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) |
|
102 | + ? (array) $setup_args['list_type_shortcodes'] : array(), |
|
103 | + ); |
|
104 | + |
|
105 | + // add filters |
|
106 | + add_filter( |
|
107 | + 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
108 | + array('EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), |
|
109 | + 10 |
|
110 | + ); |
|
111 | + |
|
112 | + // add below filters if the required callback is provided. |
|
113 | + if (! empty($setup_args['msgr_validator_callback'])) { |
|
114 | + add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
|
115 | + } |
|
116 | + |
|
117 | + if (! empty($setup_args['msgr_template_fields_callback'])) { |
|
118 | + add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
|
119 | + } |
|
120 | + |
|
121 | + if (! empty($setup_args['valid_shortcodes_callback'])) { |
|
122 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
|
123 | + } |
|
124 | + |
|
125 | + if (! empty($setup_args['list_type_shortcodes'])) { |
|
126 | + add_filter( |
|
127 | + 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
|
128 | + array('EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), |
|
129 | + 10 |
|
130 | + ); |
|
131 | + } |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * This deregisters any messages shortcode library previously registered with the given name. |
|
137 | + * |
|
138 | + * @since 4.3.0 |
|
139 | + * @param string $name name used to register the shortcode library. |
|
140 | + * @return void |
|
141 | + */ |
|
142 | + public static function deregister($name = null) |
|
143 | + { |
|
144 | + if (! empty(self::$_ee_messages_shortcode_registry[ $name ])) { |
|
145 | + unset(self::$_ee_messages_shortcode_registry[ $name ]); |
|
146 | + } |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
152 | + * |
|
153 | + * @since 4.3.0 |
|
154 | + * |
|
155 | + * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
156 | + * @return array |
|
157 | + */ |
|
158 | + public static function register_msgs_autoload_paths($paths) |
|
159 | + { |
|
160 | + |
|
161 | + if (! empty(self::$_ee_messages_shortcode_registry)) { |
|
162 | + foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
|
163 | + if (empty($st_reg['autoloadpaths'])) { |
|
164 | + continue; |
|
165 | + } |
|
166 | + $paths = array_merge($paths, $st_reg['autoloadpaths']); |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + return $paths; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes |
|
176 | + * filter which is used to add additional list type shortcodes. |
|
177 | + * |
|
178 | + * @since 4.3.0 |
|
179 | + * |
|
180 | + * @param array $original_shortcodes |
|
181 | + * @return array Modifications to original shortcodes. |
|
182 | + */ |
|
183 | + public static function register_list_type_shortcodes($original_shortcodes) |
|
184 | + { |
|
185 | + if (empty(self::$_ee_messages_shortcode_registry)) { |
|
186 | + return $original_shortcodes; |
|
187 | + } |
|
188 | + |
|
189 | + foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
|
190 | + if (! empty($sc_reg['list_type_shortcodes'])) { |
|
191 | + $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']); |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + return $original_shortcodes; |
|
196 | + } |
|
197 | 197 | } |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | // make sure we don't register twice |
77 | - if (isset(self::$_ee_messages_shortcode_registry[ $name ])) { |
|
77 | + if (isset(self::$_ee_messages_shortcode_registry[$name])) { |
|
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | 81 | // make sure this was called in the right place! |
82 | - if (! did_action('EE_Brewing_Regular___messages_caf') |
|
82 | + if ( ! did_action('EE_Brewing_Regular___messages_caf') |
|
83 | 83 | || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
84 | 84 | ) { |
85 | 85 | EE_Error::doing_it_wrong( |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | $name = (string) $name; |
99 | - self::$_ee_messages_shortcode_registry[ $name ] = array( |
|
99 | + self::$_ee_messages_shortcode_registry[$name] = array( |
|
100 | 100 | 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
101 | 101 | 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) |
102 | 102 | ? (array) $setup_args['list_type_shortcodes'] : array(), |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | ); |
111 | 111 | |
112 | 112 | // add below filters if the required callback is provided. |
113 | - if (! empty($setup_args['msgr_validator_callback'])) { |
|
113 | + if ( ! empty($setup_args['msgr_validator_callback'])) { |
|
114 | 114 | add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
115 | 115 | } |
116 | 116 | |
117 | - if (! empty($setup_args['msgr_template_fields_callback'])) { |
|
117 | + if ( ! empty($setup_args['msgr_template_fields_callback'])) { |
|
118 | 118 | add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
119 | 119 | } |
120 | 120 | |
121 | - if (! empty($setup_args['valid_shortcodes_callback'])) { |
|
121 | + if ( ! empty($setup_args['valid_shortcodes_callback'])) { |
|
122 | 122 | add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
123 | 123 | } |
124 | 124 | |
125 | - if (! empty($setup_args['list_type_shortcodes'])) { |
|
125 | + if ( ! empty($setup_args['list_type_shortcodes'])) { |
|
126 | 126 | add_filter( |
127 | 127 | 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
128 | 128 | array('EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public static function deregister($name = null) |
143 | 143 | { |
144 | - if (! empty(self::$_ee_messages_shortcode_registry[ $name ])) { |
|
145 | - unset(self::$_ee_messages_shortcode_registry[ $name ]); |
|
144 | + if ( ! empty(self::$_ee_messages_shortcode_registry[$name])) { |
|
145 | + unset(self::$_ee_messages_shortcode_registry[$name]); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | public static function register_msgs_autoload_paths($paths) |
159 | 159 | { |
160 | 160 | |
161 | - if (! empty(self::$_ee_messages_shortcode_registry)) { |
|
161 | + if ( ! empty(self::$_ee_messages_shortcode_registry)) { |
|
162 | 162 | foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
163 | 163 | if (empty($st_reg['autoloadpaths'])) { |
164 | 164 | continue; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
190 | - if (! empty($sc_reg['list_type_shortcodes'])) { |
|
190 | + if ( ! empty($sc_reg['list_type_shortcodes'])) { |
|
191 | 191 | $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']); |
192 | 192 | } |
193 | 193 | } |
@@ -14,99 +14,99 @@ |
||
14 | 14 | class EE_Register_Widget implements EEI_Plugin_API |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Holds values for registered widgets |
|
19 | - * |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected static $_settings = array(); |
|
17 | + /** |
|
18 | + * Holds values for registered widgets |
|
19 | + * |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected static $_settings = array(); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Method for registering new EED_Widgets |
|
27 | - * |
|
28 | - * @since 4.3.0 |
|
29 | - * @param string $widget_id a unique identifier for this set of widgets |
|
30 | - * @param array $setup_args an array of arguments provided for registering widgets |
|
31 | - * @type array widget_paths an array of full server paths to folders containing any EED_Widgets, or to the |
|
32 | - * EED_Widget files themselves |
|
33 | - * @throws EE_Error |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public static function register($widget_id = null, $setup_args = array()) |
|
37 | - { |
|
25 | + /** |
|
26 | + * Method for registering new EED_Widgets |
|
27 | + * |
|
28 | + * @since 4.3.0 |
|
29 | + * @param string $widget_id a unique identifier for this set of widgets |
|
30 | + * @param array $setup_args an array of arguments provided for registering widgets |
|
31 | + * @type array widget_paths an array of full server paths to folders containing any EED_Widgets, or to the |
|
32 | + * EED_Widget files themselves |
|
33 | + * @throws EE_Error |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public static function register($widget_id = null, $setup_args = array()) |
|
37 | + { |
|
38 | 38 | |
39 | - // required fields MUST be present, so let's make sure they are. |
|
40 | - if (empty($widget_id) || ! is_array($setup_args) || empty($setup_args['widget_paths'])) { |
|
41 | - throw new EE_Error( |
|
42 | - __( |
|
43 | - 'In order to register Widgets with EE_Register_Widget::register(), you must include a "widget_id" (a unique identifier for this set of widgets), and an array containing the following keys: "widget_paths" (an array of full server paths to folders that contain widgets, or to the widget files themselves)', |
|
44 | - 'event_espresso' |
|
45 | - ) |
|
46 | - ); |
|
47 | - } |
|
39 | + // required fields MUST be present, so let's make sure they are. |
|
40 | + if (empty($widget_id) || ! is_array($setup_args) || empty($setup_args['widget_paths'])) { |
|
41 | + throw new EE_Error( |
|
42 | + __( |
|
43 | + 'In order to register Widgets with EE_Register_Widget::register(), you must include a "widget_id" (a unique identifier for this set of widgets), and an array containing the following keys: "widget_paths" (an array of full server paths to folders that contain widgets, or to the widget files themselves)', |
|
44 | + 'event_espresso' |
|
45 | + ) |
|
46 | + ); |
|
47 | + } |
|
48 | 48 | |
49 | - // make sure we don't register twice |
|
50 | - if (isset(self::$_settings[ $widget_id ])) { |
|
51 | - return; |
|
52 | - } |
|
49 | + // make sure we don't register twice |
|
50 | + if (isset(self::$_settings[ $widget_id ])) { |
|
51 | + return; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - // make sure this was called in the right place! |
|
56 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
57 | - || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
58 | - ) { |
|
59 | - EE_Error::doing_it_wrong( |
|
60 | - __METHOD__, |
|
61 | - __( |
|
62 | - 'An attempt to register widgets has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register widgets.', |
|
63 | - 'event_espresso' |
|
64 | - ), |
|
65 | - '4.3.0' |
|
66 | - ); |
|
67 | - } |
|
68 | - // setup $_settings array from incoming values. |
|
69 | - self::$_settings[ $widget_id ] = array( |
|
70 | - // array of full server paths to any EED_Widgets used by the widget |
|
71 | - 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(), |
|
72 | - ); |
|
73 | - // add to list of widgets to be registered |
|
74 | - add_filter( |
|
75 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
76 | - array('EE_Register_Widget', 'add_widgets') |
|
77 | - ); |
|
78 | - } |
|
55 | + // make sure this was called in the right place! |
|
56 | + if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
57 | + || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
58 | + ) { |
|
59 | + EE_Error::doing_it_wrong( |
|
60 | + __METHOD__, |
|
61 | + __( |
|
62 | + 'An attempt to register widgets has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register widgets.', |
|
63 | + 'event_espresso' |
|
64 | + ), |
|
65 | + '4.3.0' |
|
66 | + ); |
|
67 | + } |
|
68 | + // setup $_settings array from incoming values. |
|
69 | + self::$_settings[ $widget_id ] = array( |
|
70 | + // array of full server paths to any EED_Widgets used by the widget |
|
71 | + 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(), |
|
72 | + ); |
|
73 | + // add to list of widgets to be registered |
|
74 | + add_filter( |
|
75 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
76 | + array('EE_Register_Widget', 'add_widgets') |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * Filters the list of widgets to add ours. |
|
83 | - * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg. |
|
84 | - * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/widgets/espresso_monkey',...) |
|
85 | - * |
|
86 | - * @param array $widgets_to_register array of paths to all widgets that require registering |
|
87 | - * @return array |
|
88 | - */ |
|
89 | - public static function add_widgets($widgets_to_register = array()) |
|
90 | - { |
|
91 | - foreach (self::$_settings as $settings) { |
|
92 | - $widgets_to_register = array_merge($widgets_to_register, $settings['widget_paths']); |
|
93 | - } |
|
94 | - return $widgets_to_register; |
|
95 | - } |
|
81 | + /** |
|
82 | + * Filters the list of widgets to add ours. |
|
83 | + * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg. |
|
84 | + * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/widgets/espresso_monkey',...) |
|
85 | + * |
|
86 | + * @param array $widgets_to_register array of paths to all widgets that require registering |
|
87 | + * @return array |
|
88 | + */ |
|
89 | + public static function add_widgets($widgets_to_register = array()) |
|
90 | + { |
|
91 | + foreach (self::$_settings as $settings) { |
|
92 | + $widgets_to_register = array_merge($widgets_to_register, $settings['widget_paths']); |
|
93 | + } |
|
94 | + return $widgets_to_register; |
|
95 | + } |
|
96 | 96 | |
97 | 97 | |
98 | - /** |
|
99 | - * This deregisters a widget that was previously registered with a specific $widget_id. |
|
100 | - * |
|
101 | - * @since 4.3.0 |
|
102 | - * |
|
103 | - * @param string $widget_id the name for the widget that was previously registered |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public static function deregister($widget_id = null) |
|
107 | - { |
|
108 | - if (isset(self::$_settings[ $widget_id ])) { |
|
109 | - unset(self::$_settings[ $widget_id ]); |
|
110 | - } |
|
111 | - } |
|
98 | + /** |
|
99 | + * This deregisters a widget that was previously registered with a specific $widget_id. |
|
100 | + * |
|
101 | + * @since 4.3.0 |
|
102 | + * |
|
103 | + * @param string $widget_id the name for the widget that was previously registered |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public static function deregister($widget_id = null) |
|
107 | + { |
|
108 | + if (isset(self::$_settings[ $widget_id ])) { |
|
109 | + unset(self::$_settings[ $widget_id ]); |
|
110 | + } |
|
111 | + } |
|
112 | 112 | } |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | // make sure we don't register twice |
50 | - if (isset(self::$_settings[ $widget_id ])) { |
|
50 | + if (isset(self::$_settings[$widget_id])) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | // make sure this was called in the right place! |
56 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
56 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
57 | 57 | || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
58 | 58 | ) { |
59 | 59 | EE_Error::doing_it_wrong( |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ); |
67 | 67 | } |
68 | 68 | // setup $_settings array from incoming values. |
69 | - self::$_settings[ $widget_id ] = array( |
|
69 | + self::$_settings[$widget_id] = array( |
|
70 | 70 | // array of full server paths to any EED_Widgets used by the widget |
71 | 71 | 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(), |
72 | 72 | ); |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public static function deregister($widget_id = null) |
107 | 107 | { |
108 | - if (isset(self::$_settings[ $widget_id ])) { |
|
109 | - unset(self::$_settings[ $widget_id ]); |
|
108 | + if (isset(self::$_settings[$widget_id])) { |
|
109 | + unset(self::$_settings[$widget_id]); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
@@ -14,99 +14,99 @@ |
||
14 | 14 | class EE_Register_Module implements EEI_Plugin_API |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Holds values for registered modules |
|
19 | - * |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected static $_settings = array(); |
|
17 | + /** |
|
18 | + * Holds values for registered modules |
|
19 | + * |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected static $_settings = array(); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Method for registering new EED_Modules |
|
27 | - * |
|
28 | - * @since 4.3.0 |
|
29 | - * @param string $module_id a unique identifier for this set of modules Required. |
|
30 | - * @param array $setup_args an array of full server paths to folders containing any EED_Modules, or to the |
|
31 | - * EED_Module files themselves Required. |
|
32 | - * @type array module_paths an array of full server paths to folders containing any EED_Modules, or to the |
|
33 | - * EED_Module files themselves |
|
34 | - * @throws EE_Error |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - public static function register($module_id = null, $setup_args = array()) |
|
38 | - { |
|
25 | + /** |
|
26 | + * Method for registering new EED_Modules |
|
27 | + * |
|
28 | + * @since 4.3.0 |
|
29 | + * @param string $module_id a unique identifier for this set of modules Required. |
|
30 | + * @param array $setup_args an array of full server paths to folders containing any EED_Modules, or to the |
|
31 | + * EED_Module files themselves Required. |
|
32 | + * @type array module_paths an array of full server paths to folders containing any EED_Modules, or to the |
|
33 | + * EED_Module files themselves |
|
34 | + * @throws EE_Error |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + public static function register($module_id = null, $setup_args = array()) |
|
38 | + { |
|
39 | 39 | |
40 | - // required fields MUST be present, so let's make sure they are. |
|
41 | - if (empty($module_id) || ! is_array($setup_args) || empty($setup_args['module_paths'])) { |
|
42 | - throw new EE_Error( |
|
43 | - __( |
|
44 | - 'In order to register Modules with EE_Register_Module::register(), you must include a "module_id" (a unique identifier for this set of modules), and an array containing the following keys: "module_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', |
|
45 | - 'event_espresso' |
|
46 | - ) |
|
47 | - ); |
|
48 | - } |
|
40 | + // required fields MUST be present, so let's make sure they are. |
|
41 | + if (empty($module_id) || ! is_array($setup_args) || empty($setup_args['module_paths'])) { |
|
42 | + throw new EE_Error( |
|
43 | + __( |
|
44 | + 'In order to register Modules with EE_Register_Module::register(), you must include a "module_id" (a unique identifier for this set of modules), and an array containing the following keys: "module_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', |
|
45 | + 'event_espresso' |
|
46 | + ) |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | |
50 | - // make sure we don't register twice |
|
51 | - if (isset(self::$_settings[ $module_id ])) { |
|
52 | - return; |
|
53 | - } |
|
50 | + // make sure we don't register twice |
|
51 | + if (isset(self::$_settings[ $module_id ])) { |
|
52 | + return; |
|
53 | + } |
|
54 | 54 | |
55 | - // make sure this was called in the right place! |
|
56 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
57 | - || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
58 | - ) { |
|
59 | - EE_Error::doing_it_wrong( |
|
60 | - __METHOD__, |
|
61 | - __( |
|
62 | - 'An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', |
|
63 | - 'event_espresso' |
|
64 | - ), |
|
65 | - '4.3.0' |
|
66 | - ); |
|
67 | - } |
|
68 | - // setup $_settings array from incoming values. |
|
69 | - self::$_settings[ $module_id ] = array( |
|
70 | - // array of full server paths to any EED_Modules used by the module |
|
71 | - 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(), |
|
72 | - ); |
|
73 | - // add to list of modules to be registered |
|
74 | - add_filter( |
|
75 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
76 | - array('EE_Register_Module', 'add_modules') |
|
77 | - ); |
|
78 | - } |
|
55 | + // make sure this was called in the right place! |
|
56 | + if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
57 | + || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
58 | + ) { |
|
59 | + EE_Error::doing_it_wrong( |
|
60 | + __METHOD__, |
|
61 | + __( |
|
62 | + 'An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', |
|
63 | + 'event_espresso' |
|
64 | + ), |
|
65 | + '4.3.0' |
|
66 | + ); |
|
67 | + } |
|
68 | + // setup $_settings array from incoming values. |
|
69 | + self::$_settings[ $module_id ] = array( |
|
70 | + // array of full server paths to any EED_Modules used by the module |
|
71 | + 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(), |
|
72 | + ); |
|
73 | + // add to list of modules to be registered |
|
74 | + add_filter( |
|
75 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
76 | + array('EE_Register_Module', 'add_modules') |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * Filters the list of modules to add ours. |
|
83 | - * and they're just full filepaths to FOLDERS containing a module class file. Eg. |
|
84 | - * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey',...) |
|
85 | - * |
|
86 | - * @param array $modules_to_register array of paths to all modules that require registering |
|
87 | - * @return array |
|
88 | - */ |
|
89 | - public static function add_modules($modules_to_register) |
|
90 | - { |
|
91 | - foreach (self::$_settings as $settings) { |
|
92 | - $modules_to_register = array_merge($modules_to_register, $settings['module_paths']); |
|
93 | - } |
|
94 | - return $modules_to_register; |
|
95 | - } |
|
81 | + /** |
|
82 | + * Filters the list of modules to add ours. |
|
83 | + * and they're just full filepaths to FOLDERS containing a module class file. Eg. |
|
84 | + * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey',...) |
|
85 | + * |
|
86 | + * @param array $modules_to_register array of paths to all modules that require registering |
|
87 | + * @return array |
|
88 | + */ |
|
89 | + public static function add_modules($modules_to_register) |
|
90 | + { |
|
91 | + foreach (self::$_settings as $settings) { |
|
92 | + $modules_to_register = array_merge($modules_to_register, $settings['module_paths']); |
|
93 | + } |
|
94 | + return $modules_to_register; |
|
95 | + } |
|
96 | 96 | |
97 | 97 | |
98 | - /** |
|
99 | - * This deregisters a module that was previously registered with a specific $module_id. |
|
100 | - * |
|
101 | - * @since 4.3.0 |
|
102 | - * |
|
103 | - * @param string $module_id the name for the module that was previously registered |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public static function deregister($module_id = null) |
|
107 | - { |
|
108 | - if (isset(self::$_settings[ $module_id ])) { |
|
109 | - unset(self::$_settings[ $module_id ]); |
|
110 | - } |
|
111 | - } |
|
98 | + /** |
|
99 | + * This deregisters a module that was previously registered with a specific $module_id. |
|
100 | + * |
|
101 | + * @since 4.3.0 |
|
102 | + * |
|
103 | + * @param string $module_id the name for the module that was previously registered |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public static function deregister($module_id = null) |
|
107 | + { |
|
108 | + if (isset(self::$_settings[ $module_id ])) { |
|
109 | + unset(self::$_settings[ $module_id ]); |
|
110 | + } |
|
111 | + } |
|
112 | 112 | } |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | // make sure we don't register twice |
51 | - if (isset(self::$_settings[ $module_id ])) { |
|
51 | + if (isset(self::$_settings[$module_id])) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
55 | 55 | // make sure this was called in the right place! |
56 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
56 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
57 | 57 | || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
58 | 58 | ) { |
59 | 59 | EE_Error::doing_it_wrong( |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ); |
67 | 67 | } |
68 | 68 | // setup $_settings array from incoming values. |
69 | - self::$_settings[ $module_id ] = array( |
|
69 | + self::$_settings[$module_id] = array( |
|
70 | 70 | // array of full server paths to any EED_Modules used by the module |
71 | 71 | 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(), |
72 | 72 | ); |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public static function deregister($module_id = null) |
107 | 107 | { |
108 | - if (isset(self::$_settings[ $module_id ])) { |
|
109 | - unset(self::$_settings[ $module_id ]); |
|
108 | + if (isset(self::$_settings[$module_id])) { |
|
109 | + unset(self::$_settings[$module_id]); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
@@ -18,162 +18,162 @@ |
||
18 | 18 | class EE_Register_Shortcode implements EEI_Plugin_API |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Holds values for registered shortcodes |
|
23 | - * |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - protected static $_settings = array(); |
|
21 | + /** |
|
22 | + * Holds values for registered shortcodes |
|
23 | + * |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + protected static $_settings = array(); |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * Method for registering new EE_Shortcodes |
|
31 | - * |
|
32 | - * @since 4.3.0 |
|
33 | - * @since 4.9.46.rc.025 for the new `shortcode_fqcns` array argument. |
|
34 | - * @param string $shortcode_id a unique identifier for this set of modules Required. |
|
35 | - * @param array $setup_args an array of arguments provided for registering shortcodes |
|
36 | - * Required. |
|
37 | - * @type array shortcode_paths an array of full server paths to folders containing any |
|
38 | - * EES_Shortcodes |
|
39 | - * @type array shortcode_fqcns an array of fully qualified class names for any new shortcode |
|
40 | - * classes to register. Shortcode classes should extend |
|
41 | - * EspressoShortcode and be properly namespaced so they are |
|
42 | - * autoloaded. |
|
43 | - * @throws EE_Error |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public static function register($shortcode_id = null, $setup_args = array()) |
|
47 | - { |
|
48 | - // required fields MUST be present, so let's make sure they are. |
|
49 | - if (empty($shortcode_id) |
|
50 | - || ! is_array($setup_args) |
|
51 | - || ( |
|
52 | - empty($setup_args['shortcode_paths'])) |
|
53 | - && empty($setup_args['shortcode_fqcns']) |
|
54 | - ) { |
|
55 | - throw new EE_Error( |
|
56 | - esc_html__( |
|
57 | - 'In order to register Modules with EE_Register_Shortcode::register(), you must include a "shortcode_id" (a unique identifier for this set of shortcodes), and an array containing the following keys: "shortcode_paths" (an array of full server paths to folders that contain shortcodes, or to the shortcode files themselves)', |
|
58 | - 'event_espresso' |
|
59 | - ) |
|
60 | - ); |
|
61 | - } |
|
29 | + /** |
|
30 | + * Method for registering new EE_Shortcodes |
|
31 | + * |
|
32 | + * @since 4.3.0 |
|
33 | + * @since 4.9.46.rc.025 for the new `shortcode_fqcns` array argument. |
|
34 | + * @param string $shortcode_id a unique identifier for this set of modules Required. |
|
35 | + * @param array $setup_args an array of arguments provided for registering shortcodes |
|
36 | + * Required. |
|
37 | + * @type array shortcode_paths an array of full server paths to folders containing any |
|
38 | + * EES_Shortcodes |
|
39 | + * @type array shortcode_fqcns an array of fully qualified class names for any new shortcode |
|
40 | + * classes to register. Shortcode classes should extend |
|
41 | + * EspressoShortcode and be properly namespaced so they are |
|
42 | + * autoloaded. |
|
43 | + * @throws EE_Error |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public static function register($shortcode_id = null, $setup_args = array()) |
|
47 | + { |
|
48 | + // required fields MUST be present, so let's make sure they are. |
|
49 | + if (empty($shortcode_id) |
|
50 | + || ! is_array($setup_args) |
|
51 | + || ( |
|
52 | + empty($setup_args['shortcode_paths'])) |
|
53 | + && empty($setup_args['shortcode_fqcns']) |
|
54 | + ) { |
|
55 | + throw new EE_Error( |
|
56 | + esc_html__( |
|
57 | + 'In order to register Modules with EE_Register_Shortcode::register(), you must include a "shortcode_id" (a unique identifier for this set of shortcodes), and an array containing the following keys: "shortcode_paths" (an array of full server paths to folders that contain shortcodes, or to the shortcode files themselves)', |
|
58 | + 'event_espresso' |
|
59 | + ) |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | - // make sure we don't register twice |
|
64 | - if (isset(self::$_settings[ $shortcode_id ])) { |
|
65 | - return; |
|
66 | - } |
|
63 | + // make sure we don't register twice |
|
64 | + if (isset(self::$_settings[ $shortcode_id ])) { |
|
65 | + return; |
|
66 | + } |
|
67 | 67 | |
68 | - // make sure this was called in the right place! |
|
69 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
70 | - || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
71 | - ) { |
|
72 | - EE_Error::doing_it_wrong( |
|
73 | - __METHOD__, |
|
74 | - esc_html__( |
|
75 | - 'An attempt to register shortcodes has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register shortcodes.', |
|
76 | - 'event_espresso' |
|
77 | - ), |
|
78 | - '4.3.0' |
|
79 | - ); |
|
80 | - } |
|
81 | - // setup $_settings array from incoming values. |
|
82 | - self::$_settings[ $shortcode_id ] = array( |
|
83 | - // array of full server paths to any EES_Shortcodes used by the shortcode |
|
84 | - 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
85 | - ? (array) $setup_args['shortcode_paths'] |
|
86 | - : array(), |
|
87 | - 'shortcode_fqcns' => isset($setup_args['shortcode_fqcns']) |
|
88 | - ? (array) $setup_args['shortcode_fqcns'] |
|
89 | - : array(), |
|
90 | - ); |
|
91 | - // add to list of shortcodes to be registered |
|
92 | - add_filter( |
|
93 | - 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
94 | - array('EE_Register_Shortcode', 'add_shortcodes') |
|
95 | - ); |
|
68 | + // make sure this was called in the right place! |
|
69 | + if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
70 | + || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
71 | + ) { |
|
72 | + EE_Error::doing_it_wrong( |
|
73 | + __METHOD__, |
|
74 | + esc_html__( |
|
75 | + 'An attempt to register shortcodes has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register shortcodes.', |
|
76 | + 'event_espresso' |
|
77 | + ), |
|
78 | + '4.3.0' |
|
79 | + ); |
|
80 | + } |
|
81 | + // setup $_settings array from incoming values. |
|
82 | + self::$_settings[ $shortcode_id ] = array( |
|
83 | + // array of full server paths to any EES_Shortcodes used by the shortcode |
|
84 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
85 | + ? (array) $setup_args['shortcode_paths'] |
|
86 | + : array(), |
|
87 | + 'shortcode_fqcns' => isset($setup_args['shortcode_fqcns']) |
|
88 | + ? (array) $setup_args['shortcode_fqcns'] |
|
89 | + : array(), |
|
90 | + ); |
|
91 | + // add to list of shortcodes to be registered |
|
92 | + add_filter( |
|
93 | + 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
94 | + array('EE_Register_Shortcode', 'add_shortcodes') |
|
95 | + ); |
|
96 | 96 | |
97 | - add_filter( |
|
98 | - 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
99 | - array('EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection') |
|
100 | - ); |
|
101 | - } |
|
97 | + add_filter( |
|
98 | + 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
99 | + array('EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection') |
|
100 | + ); |
|
101 | + } |
|
102 | 102 | |
103 | 103 | |
104 | - /** |
|
105 | - * Filters the list of shortcodes to add ours. |
|
106 | - * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg. |
|
107 | - * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey',...) |
|
108 | - * |
|
109 | - * @param array $shortcodes_to_register array of paths to all shortcodes that require registering |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - public static function add_shortcodes($shortcodes_to_register) |
|
113 | - { |
|
114 | - foreach (self::$_settings as $settings) { |
|
115 | - $shortcodes_to_register = array_merge($shortcodes_to_register, $settings['shortcode_paths']); |
|
116 | - } |
|
117 | - return $shortcodes_to_register; |
|
118 | - } |
|
104 | + /** |
|
105 | + * Filters the list of shortcodes to add ours. |
|
106 | + * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg. |
|
107 | + * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey',...) |
|
108 | + * |
|
109 | + * @param array $shortcodes_to_register array of paths to all shortcodes that require registering |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + public static function add_shortcodes($shortcodes_to_register) |
|
113 | + { |
|
114 | + foreach (self::$_settings as $settings) { |
|
115 | + $shortcodes_to_register = array_merge($shortcodes_to_register, $settings['shortcode_paths']); |
|
116 | + } |
|
117 | + return $shortcodes_to_register; |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | - /** |
|
122 | - * Hooks into |
|
123 | - * FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection and |
|
124 | - * registers any provided shortcode fully qualified class names. |
|
125 | - * |
|
126 | - * @param CollectionInterface $shortcodes_collection |
|
127 | - * @return CollectionInterface |
|
128 | - * @throws InvalidArgumentException |
|
129 | - * @throws InvalidClassException |
|
130 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
131 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
132 | - */ |
|
133 | - public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection) |
|
134 | - { |
|
135 | - foreach (self::$_settings as $settings) { |
|
136 | - if (! empty($settings['shortcode_fqcns'])) { |
|
137 | - foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) { |
|
138 | - if (! class_exists($shortcode_fqcn)) { |
|
139 | - throw new InvalidClassException( |
|
140 | - sprintf( |
|
141 | - esc_html__( |
|
142 | - 'Are you sure %s is the right fully qualified class name for the shortcode class?', |
|
143 | - 'event_espresso' |
|
144 | - ), |
|
145 | - $shortcode_fqcn |
|
146 | - ) |
|
147 | - ); |
|
148 | - } |
|
149 | - if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) { |
|
150 | - // register dependencies |
|
151 | - EE_Dependency_Map::register_dependencies( |
|
152 | - $shortcode_fqcn, |
|
153 | - array( |
|
154 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
155 | - ) |
|
156 | - ); |
|
157 | - } |
|
158 | - $shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn)); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - return $shortcodes_collection; |
|
163 | - } |
|
121 | + /** |
|
122 | + * Hooks into |
|
123 | + * FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection and |
|
124 | + * registers any provided shortcode fully qualified class names. |
|
125 | + * |
|
126 | + * @param CollectionInterface $shortcodes_collection |
|
127 | + * @return CollectionInterface |
|
128 | + * @throws InvalidArgumentException |
|
129 | + * @throws InvalidClassException |
|
130 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
131 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
132 | + */ |
|
133 | + public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection) |
|
134 | + { |
|
135 | + foreach (self::$_settings as $settings) { |
|
136 | + if (! empty($settings['shortcode_fqcns'])) { |
|
137 | + foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) { |
|
138 | + if (! class_exists($shortcode_fqcn)) { |
|
139 | + throw new InvalidClassException( |
|
140 | + sprintf( |
|
141 | + esc_html__( |
|
142 | + 'Are you sure %s is the right fully qualified class name for the shortcode class?', |
|
143 | + 'event_espresso' |
|
144 | + ), |
|
145 | + $shortcode_fqcn |
|
146 | + ) |
|
147 | + ); |
|
148 | + } |
|
149 | + if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) { |
|
150 | + // register dependencies |
|
151 | + EE_Dependency_Map::register_dependencies( |
|
152 | + $shortcode_fqcn, |
|
153 | + array( |
|
154 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
155 | + ) |
|
156 | + ); |
|
157 | + } |
|
158 | + $shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn)); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + return $shortcodes_collection; |
|
163 | + } |
|
164 | 164 | |
165 | 165 | |
166 | - /** |
|
167 | - * This deregisters a shortcode that was previously registered with a specific $shortcode_id. |
|
168 | - * |
|
169 | - * @since 4.3.0 |
|
170 | - * @param string $shortcode_id the name for the shortcode that was previously registered |
|
171 | - * @return void |
|
172 | - */ |
|
173 | - public static function deregister($shortcode_id = null) |
|
174 | - { |
|
175 | - if (isset(self::$_settings[ $shortcode_id ])) { |
|
176 | - unset(self::$_settings[ $shortcode_id ]); |
|
177 | - } |
|
178 | - } |
|
166 | + /** |
|
167 | + * This deregisters a shortcode that was previously registered with a specific $shortcode_id. |
|
168 | + * |
|
169 | + * @since 4.3.0 |
|
170 | + * @param string $shortcode_id the name for the shortcode that was previously registered |
|
171 | + * @return void |
|
172 | + */ |
|
173 | + public static function deregister($shortcode_id = null) |
|
174 | + { |
|
175 | + if (isset(self::$_settings[ $shortcode_id ])) { |
|
176 | + unset(self::$_settings[ $shortcode_id ]); |
|
177 | + } |
|
178 | + } |
|
179 | 179 | } |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // make sure we don't register twice |
64 | - if (isset(self::$_settings[ $shortcode_id ])) { |
|
64 | + if (isset(self::$_settings[$shortcode_id])) { |
|
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | 68 | // make sure this was called in the right place! |
69 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
69 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
70 | 70 | || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
71 | 71 | ) { |
72 | 72 | EE_Error::doing_it_wrong( |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | ); |
80 | 80 | } |
81 | 81 | // setup $_settings array from incoming values. |
82 | - self::$_settings[ $shortcode_id ] = array( |
|
82 | + self::$_settings[$shortcode_id] = array( |
|
83 | 83 | // array of full server paths to any EES_Shortcodes used by the shortcode |
84 | 84 | 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
85 | 85 | ? (array) $setup_args['shortcode_paths'] |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection) |
134 | 134 | { |
135 | 135 | foreach (self::$_settings as $settings) { |
136 | - if (! empty($settings['shortcode_fqcns'])) { |
|
136 | + if ( ! empty($settings['shortcode_fqcns'])) { |
|
137 | 137 | foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) { |
138 | - if (! class_exists($shortcode_fqcn)) { |
|
138 | + if ( ! class_exists($shortcode_fqcn)) { |
|
139 | 139 | throw new InvalidClassException( |
140 | 140 | sprintf( |
141 | 141 | esc_html__( |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | ) |
147 | 147 | ); |
148 | 148 | } |
149 | - if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) { |
|
149 | + if ( ! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) { |
|
150 | 150 | // register dependencies |
151 | 151 | EE_Dependency_Map::register_dependencies( |
152 | 152 | $shortcode_fqcn, |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public static function deregister($shortcode_id = null) |
174 | 174 | { |
175 | - if (isset(self::$_settings[ $shortcode_id ])) { |
|
176 | - unset(self::$_settings[ $shortcode_id ]); |
|
175 | + if (isset(self::$_settings[$shortcode_id])) { |
|
176 | + unset(self::$_settings[$shortcode_id]); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
76 | - if (! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) { |
|
76 | + if ( ! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) { |
|
77 | 77 | throw new EE_Error( |
78 | 78 | __( |
79 | 79 | 'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | // make sure we don't register twice |
86 | - if (isset(self::$_registry[ $cpt_ref ])) { |
|
86 | + if (isset(self::$_registry[$cpt_ref])) { |
|
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // make sure cpt ref is unique. |
91 | - if (isset(self::$_registry[ $cpt_ref ])) { |
|
92 | - $cpt_ref = uniqid() . '_' . $cpt_ref; |
|
91 | + if (isset(self::$_registry[$cpt_ref])) { |
|
92 | + $cpt_ref = uniqid().'_'.$cpt_ref; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // make sure this was called in the right place! |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | : array(), |
120 | 120 | ); |
121 | 121 | |
122 | - self::$_registry[ $cpt_ref ] = $validated; |
|
122 | + self::$_registry[$cpt_ref] = $validated; |
|
123 | 123 | |
124 | 124 | // hook into to cpt system |
125 | 125 | add_filter( |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | { |
153 | 153 | foreach (self::$_registry as $registries) { |
154 | 154 | foreach ($registries['cpts'] as $cpt_name => $cpt_settings) { |
155 | - $custom_post_type_definitions[ $cpt_name ] = $cpt_settings; |
|
155 | + $custom_post_type_definitions[$cpt_name] = $cpt_settings; |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | return $custom_post_type_definitions; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | { |
172 | 172 | foreach (self::$_registry as $registries) { |
173 | 173 | foreach ($registries['cts'] as $ct_name => $ct_settings) { |
174 | - $custom_taxonomy_definitions[ $ct_name ] = $ct_settings; |
|
174 | + $custom_taxonomy_definitions[$ct_name] = $ct_settings; |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | return $custom_taxonomy_definitions; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | { |
212 | 212 | foreach (self::$_registry as $registries) { |
213 | 213 | foreach ($registries['cpts'] as $cpt_name => $cpt_settings) { |
214 | - $cpts[ $cpt_name ] = $cpt_settings; |
|
214 | + $cpts[$cpt_name] = $cpt_settings; |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | return $cpts; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | { |
228 | 228 | foreach (self::$_registry as $registries) { |
229 | 229 | foreach ($registries['cts'] as $ct_name => $ct_settings) { |
230 | - $cts[ $ct_name ] = $ct_settings; |
|
230 | + $cts[$ct_name] = $ct_settings; |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | return $cts; |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public static function deregister($cpt_ref = null) |
264 | 264 | { |
265 | - if (! empty(self::$_registry[ $cpt_ref ])) { |
|
266 | - unset(self::$_registry[ $cpt_ref ]); |
|
265 | + if ( ! empty(self::$_registry[$cpt_ref])) { |
|
266 | + unset(self::$_registry[$cpt_ref]); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | } |
@@ -13,257 +13,257 @@ |
||
13 | 13 | class EE_Register_CPT implements EEI_Plugin_API |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Holds values for registered variations |
|
18 | - * |
|
19 | - * @since 4.5.0 |
|
20 | - * |
|
21 | - * @var array[][][] |
|
22 | - */ |
|
23 | - protected static $_registry = array(); |
|
16 | + /** |
|
17 | + * Holds values for registered variations |
|
18 | + * |
|
19 | + * @since 4.5.0 |
|
20 | + * |
|
21 | + * @var array[][][] |
|
22 | + */ |
|
23 | + protected static $_registry = array(); |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Used to register new CPTs and Taxonomies. |
|
28 | - * |
|
29 | - * @param string $cpt_ref reference used for the addon registering cpts and cts |
|
30 | - * @param array $setup_args { |
|
31 | - * An array of required values for registering the cpts and taxonomies |
|
32 | - * @type array $cpts { |
|
33 | - * An array of cpts and their arguments.(short example below) |
|
34 | - * @see CustomPostTypeDefinitions::setDefinitions for a more complete example. |
|
35 | - * 'people' => array( |
|
36 | - * 'singular_name' => __('People', 'event_espresso'), |
|
37 | - * 'plural_name' => __('People', 'event_espresso'), |
|
38 | - * 'singular_slug' => __('people', 'event_espresso'), |
|
39 | - * 'plural_slug' => __('peoples', 'event_espresso'), |
|
40 | - * 'class_name' => 'EE_People' |
|
41 | - * ) |
|
42 | - * }, |
|
43 | - * @type array $cts { |
|
44 | - * An array of custom taxonomies and their arguments (short example below). |
|
45 | - * @see CustomTaxonomyDefinitions::setTaxonomies() for a more complete example. |
|
46 | - * 'espresso_people_type' => array( |
|
47 | - * 'singular_name' => __('People Type', 'event_espresso'), |
|
48 | - * 'plural_name' => __('People Types', 'event_espresso'), |
|
49 | - * 'args' => array() |
|
50 | - * ) |
|
51 | - * }, |
|
52 | - * @type array $default_terms { |
|
53 | - * An array of terms to set as the default for a given taxonomy and the |
|
54 | - * custom post types applied to. |
|
55 | - * 'taxonomy_name' => array( |
|
56 | - * 'term' => array( 'cpt_a_name', 'cpt_b_name' ) |
|
57 | - * ) |
|
58 | - * } |
|
59 | - * } |
|
60 | - * @throws EE_Error |
|
61 | - * @return void |
|
62 | - */ |
|
63 | - public static function register($cpt_ref = null, $setup_args = array()) |
|
64 | - { |
|
26 | + /** |
|
27 | + * Used to register new CPTs and Taxonomies. |
|
28 | + * |
|
29 | + * @param string $cpt_ref reference used for the addon registering cpts and cts |
|
30 | + * @param array $setup_args { |
|
31 | + * An array of required values for registering the cpts and taxonomies |
|
32 | + * @type array $cpts { |
|
33 | + * An array of cpts and their arguments.(short example below) |
|
34 | + * @see CustomPostTypeDefinitions::setDefinitions for a more complete example. |
|
35 | + * 'people' => array( |
|
36 | + * 'singular_name' => __('People', 'event_espresso'), |
|
37 | + * 'plural_name' => __('People', 'event_espresso'), |
|
38 | + * 'singular_slug' => __('people', 'event_espresso'), |
|
39 | + * 'plural_slug' => __('peoples', 'event_espresso'), |
|
40 | + * 'class_name' => 'EE_People' |
|
41 | + * ) |
|
42 | + * }, |
|
43 | + * @type array $cts { |
|
44 | + * An array of custom taxonomies and their arguments (short example below). |
|
45 | + * @see CustomTaxonomyDefinitions::setTaxonomies() for a more complete example. |
|
46 | + * 'espresso_people_type' => array( |
|
47 | + * 'singular_name' => __('People Type', 'event_espresso'), |
|
48 | + * 'plural_name' => __('People Types', 'event_espresso'), |
|
49 | + * 'args' => array() |
|
50 | + * ) |
|
51 | + * }, |
|
52 | + * @type array $default_terms { |
|
53 | + * An array of terms to set as the default for a given taxonomy and the |
|
54 | + * custom post types applied to. |
|
55 | + * 'taxonomy_name' => array( |
|
56 | + * 'term' => array( 'cpt_a_name', 'cpt_b_name' ) |
|
57 | + * ) |
|
58 | + * } |
|
59 | + * } |
|
60 | + * @throws EE_Error |
|
61 | + * @return void |
|
62 | + */ |
|
63 | + public static function register($cpt_ref = null, $setup_args = array()) |
|
64 | + { |
|
65 | 65 | |
66 | - // check for required params |
|
67 | - if (empty($cpt_ref)) { |
|
68 | - throw new EE_Error( |
|
69 | - __( |
|
70 | - 'In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', |
|
71 | - 'event_espresso' |
|
72 | - ) |
|
73 | - ); |
|
74 | - } |
|
66 | + // check for required params |
|
67 | + if (empty($cpt_ref)) { |
|
68 | + throw new EE_Error( |
|
69 | + __( |
|
70 | + 'In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', |
|
71 | + 'event_espresso' |
|
72 | + ) |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | |
76 | - if (! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) { |
|
77 | - throw new EE_Error( |
|
78 | - __( |
|
79 | - 'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', |
|
80 | - 'event_espresso' |
|
81 | - ) |
|
82 | - ); |
|
83 | - } |
|
76 | + if (! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) { |
|
77 | + throw new EE_Error( |
|
78 | + __( |
|
79 | + 'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', |
|
80 | + 'event_espresso' |
|
81 | + ) |
|
82 | + ); |
|
83 | + } |
|
84 | 84 | |
85 | - // make sure we don't register twice |
|
86 | - if (isset(self::$_registry[ $cpt_ref ])) { |
|
87 | - return; |
|
88 | - } |
|
85 | + // make sure we don't register twice |
|
86 | + if (isset(self::$_registry[ $cpt_ref ])) { |
|
87 | + return; |
|
88 | + } |
|
89 | 89 | |
90 | - // make sure cpt ref is unique. |
|
91 | - if (isset(self::$_registry[ $cpt_ref ])) { |
|
92 | - $cpt_ref = uniqid() . '_' . $cpt_ref; |
|
93 | - } |
|
90 | + // make sure cpt ref is unique. |
|
91 | + if (isset(self::$_registry[ $cpt_ref ])) { |
|
92 | + $cpt_ref = uniqid() . '_' . $cpt_ref; |
|
93 | + } |
|
94 | 94 | |
95 | - // make sure this was called in the right place! |
|
96 | - if (did_action('AHEE__EE_System__load_CPTs_and_session__complete')) { |
|
97 | - EE_Error::doing_it_wrong( |
|
98 | - __METHOD__, |
|
99 | - sprintf( |
|
100 | - __( |
|
101 | - 'EE_Register_CPT has been called and given a reference of "%s". It may or may not work because it should be called on or before "AHEE__EE_System__load_CPTs_and_session__complete" action hook.', |
|
102 | - 'event_espresso' |
|
103 | - ), |
|
104 | - $cpt_ref |
|
105 | - ), |
|
106 | - '4.5.0' |
|
107 | - ); |
|
108 | - } |
|
109 | - // validate incoming args |
|
110 | - $validated = array( |
|
111 | - 'cpts' => isset($setup_args['cpts']) |
|
112 | - ? (array) $setup_args['cpts'] |
|
113 | - : array(), |
|
114 | - 'cts' => isset($setup_args['cts']) |
|
115 | - ? (array) $setup_args['cts'] |
|
116 | - : array(), |
|
117 | - 'default_terms' => isset($setup_args['default_terms']) |
|
118 | - ? (array) $setup_args['default_terms'] |
|
119 | - : array(), |
|
120 | - ); |
|
95 | + // make sure this was called in the right place! |
|
96 | + if (did_action('AHEE__EE_System__load_CPTs_and_session__complete')) { |
|
97 | + EE_Error::doing_it_wrong( |
|
98 | + __METHOD__, |
|
99 | + sprintf( |
|
100 | + __( |
|
101 | + 'EE_Register_CPT has been called and given a reference of "%s". It may or may not work because it should be called on or before "AHEE__EE_System__load_CPTs_and_session__complete" action hook.', |
|
102 | + 'event_espresso' |
|
103 | + ), |
|
104 | + $cpt_ref |
|
105 | + ), |
|
106 | + '4.5.0' |
|
107 | + ); |
|
108 | + } |
|
109 | + // validate incoming args |
|
110 | + $validated = array( |
|
111 | + 'cpts' => isset($setup_args['cpts']) |
|
112 | + ? (array) $setup_args['cpts'] |
|
113 | + : array(), |
|
114 | + 'cts' => isset($setup_args['cts']) |
|
115 | + ? (array) $setup_args['cts'] |
|
116 | + : array(), |
|
117 | + 'default_terms' => isset($setup_args['default_terms']) |
|
118 | + ? (array) $setup_args['default_terms'] |
|
119 | + : array(), |
|
120 | + ); |
|
121 | 121 | |
122 | - self::$_registry[ $cpt_ref ] = $validated; |
|
122 | + self::$_registry[ $cpt_ref ] = $validated; |
|
123 | 123 | |
124 | - // hook into to cpt system |
|
125 | - add_filter( |
|
126 | - 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
127 | - array(__CLASS__, 'filterCustomPostTypeDefinitions'), |
|
128 | - 5 |
|
129 | - ); |
|
130 | - add_filter( |
|
131 | - 'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies', |
|
132 | - array(__CLASS__, 'filterCustomTaxonomyDefinitions'), |
|
133 | - 5 |
|
134 | - ); |
|
135 | - add_action( |
|
136 | - 'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end', |
|
137 | - array(__CLASS__, 'registerCustomTaxonomyTerm'), |
|
138 | - 5 |
|
139 | - ); |
|
140 | - } |
|
124 | + // hook into to cpt system |
|
125 | + add_filter( |
|
126 | + 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
127 | + array(__CLASS__, 'filterCustomPostTypeDefinitions'), |
|
128 | + 5 |
|
129 | + ); |
|
130 | + add_filter( |
|
131 | + 'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies', |
|
132 | + array(__CLASS__, 'filterCustomTaxonomyDefinitions'), |
|
133 | + 5 |
|
134 | + ); |
|
135 | + add_action( |
|
136 | + 'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end', |
|
137 | + array(__CLASS__, 'registerCustomTaxonomyTerm'), |
|
138 | + 5 |
|
139 | + ); |
|
140 | + } |
|
141 | 141 | |
142 | 142 | |
143 | - /** |
|
144 | - * Callback for |
|
145 | - * FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes |
|
146 | - * that adds additional custom post types to be registered. |
|
147 | - * |
|
148 | - * @param array $custom_post_type_definitions array of cpts that are already set |
|
149 | - * @return array new array of cpts and their registration information |
|
150 | - */ |
|
151 | - public static function filterCustomPostTypeDefinitions($custom_post_type_definitions) |
|
152 | - { |
|
153 | - foreach (self::$_registry as $registries) { |
|
154 | - foreach ($registries['cpts'] as $cpt_name => $cpt_settings) { |
|
155 | - $custom_post_type_definitions[ $cpt_name ] = $cpt_settings; |
|
156 | - } |
|
157 | - } |
|
158 | - return $custom_post_type_definitions; |
|
159 | - } |
|
143 | + /** |
|
144 | + * Callback for |
|
145 | + * FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes |
|
146 | + * that adds additional custom post types to be registered. |
|
147 | + * |
|
148 | + * @param array $custom_post_type_definitions array of cpts that are already set |
|
149 | + * @return array new array of cpts and their registration information |
|
150 | + */ |
|
151 | + public static function filterCustomPostTypeDefinitions($custom_post_type_definitions) |
|
152 | + { |
|
153 | + foreach (self::$_registry as $registries) { |
|
154 | + foreach ($registries['cpts'] as $cpt_name => $cpt_settings) { |
|
155 | + $custom_post_type_definitions[ $cpt_name ] = $cpt_settings; |
|
156 | + } |
|
157 | + } |
|
158 | + return $custom_post_type_definitions; |
|
159 | + } |
|
160 | 160 | |
161 | 161 | |
162 | - /** |
|
163 | - * Callback for |
|
164 | - * FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies |
|
165 | - * that adds additional custom taxonomies to be registered. |
|
166 | - * |
|
167 | - * @param array $custom_taxonomy_definitions array of cts that are already set. |
|
168 | - * @return array new array of cts and their registration information. |
|
169 | - */ |
|
170 | - public static function filterCustomTaxonomyDefinitions($custom_taxonomy_definitions) |
|
171 | - { |
|
172 | - foreach (self::$_registry as $registries) { |
|
173 | - foreach ($registries['cts'] as $ct_name => $ct_settings) { |
|
174 | - $custom_taxonomy_definitions[ $ct_name ] = $ct_settings; |
|
175 | - } |
|
176 | - } |
|
177 | - return $custom_taxonomy_definitions; |
|
178 | - } |
|
162 | + /** |
|
163 | + * Callback for |
|
164 | + * FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies |
|
165 | + * that adds additional custom taxonomies to be registered. |
|
166 | + * |
|
167 | + * @param array $custom_taxonomy_definitions array of cts that are already set. |
|
168 | + * @return array new array of cts and their registration information. |
|
169 | + */ |
|
170 | + public static function filterCustomTaxonomyDefinitions($custom_taxonomy_definitions) |
|
171 | + { |
|
172 | + foreach (self::$_registry as $registries) { |
|
173 | + foreach ($registries['cts'] as $ct_name => $ct_settings) { |
|
174 | + $custom_taxonomy_definitions[ $ct_name ] = $ct_settings; |
|
175 | + } |
|
176 | + } |
|
177 | + return $custom_taxonomy_definitions; |
|
178 | + } |
|
179 | 179 | |
180 | 180 | |
181 | - /** |
|
182 | - * Callback for |
|
183 | - * AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end |
|
184 | - * which is used to set the default terms |
|
185 | - * |
|
186 | - * @param RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms |
|
187 | - * @return void |
|
188 | - */ |
|
189 | - public static function registerCustomTaxonomyTerm(RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms) |
|
190 | - { |
|
191 | - foreach (self::$_registry as $registries) { |
|
192 | - foreach ($registries['default_terms'] as $taxonomy => $terms) { |
|
193 | - foreach ($terms as $term => $cpts) { |
|
194 | - $register_custom_taxonomy_terms->registerCustomTaxonomyTerm( |
|
195 | - $taxonomy, |
|
196 | - $term, |
|
197 | - $cpts |
|
198 | - ); |
|
199 | - } |
|
200 | - } |
|
201 | - } |
|
202 | - } |
|
181 | + /** |
|
182 | + * Callback for |
|
183 | + * AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end |
|
184 | + * which is used to set the default terms |
|
185 | + * |
|
186 | + * @param RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms |
|
187 | + * @return void |
|
188 | + */ |
|
189 | + public static function registerCustomTaxonomyTerm(RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms) |
|
190 | + { |
|
191 | + foreach (self::$_registry as $registries) { |
|
192 | + foreach ($registries['default_terms'] as $taxonomy => $terms) { |
|
193 | + foreach ($terms as $term => $cpts) { |
|
194 | + $register_custom_taxonomy_terms->registerCustomTaxonomyTerm( |
|
195 | + $taxonomy, |
|
196 | + $term, |
|
197 | + $cpts |
|
198 | + ); |
|
199 | + } |
|
200 | + } |
|
201 | + } |
|
202 | + } |
|
203 | 203 | |
204 | 204 | |
205 | - /** |
|
206 | - * @deprecated 4.9.62.p |
|
207 | - * @param array $cpts array of cpts that are already set |
|
208 | - * @return array new array of cpts and their registration information |
|
209 | - */ |
|
210 | - public static function filter_cpts($cpts) |
|
211 | - { |
|
212 | - foreach (self::$_registry as $registries) { |
|
213 | - foreach ($registries['cpts'] as $cpt_name => $cpt_settings) { |
|
214 | - $cpts[ $cpt_name ] = $cpt_settings; |
|
215 | - } |
|
216 | - } |
|
217 | - return $cpts; |
|
218 | - } |
|
205 | + /** |
|
206 | + * @deprecated 4.9.62.p |
|
207 | + * @param array $cpts array of cpts that are already set |
|
208 | + * @return array new array of cpts and their registration information |
|
209 | + */ |
|
210 | + public static function filter_cpts($cpts) |
|
211 | + { |
|
212 | + foreach (self::$_registry as $registries) { |
|
213 | + foreach ($registries['cpts'] as $cpt_name => $cpt_settings) { |
|
214 | + $cpts[ $cpt_name ] = $cpt_settings; |
|
215 | + } |
|
216 | + } |
|
217 | + return $cpts; |
|
218 | + } |
|
219 | 219 | |
220 | 220 | |
221 | - /** |
|
222 | - * @deprecated 4.9.62.p |
|
223 | - * @param array $cts array of cts that are already set. |
|
224 | - * @return array new array of cts and their registration information. |
|
225 | - */ |
|
226 | - public static function filter_cts($cts) |
|
227 | - { |
|
228 | - foreach (self::$_registry as $registries) { |
|
229 | - foreach ($registries['cts'] as $ct_name => $ct_settings) { |
|
230 | - $cts[ $ct_name ] = $ct_settings; |
|
231 | - } |
|
232 | - } |
|
233 | - return $cts; |
|
234 | - } |
|
221 | + /** |
|
222 | + * @deprecated 4.9.62.p |
|
223 | + * @param array $cts array of cts that are already set. |
|
224 | + * @return array new array of cts and their registration information. |
|
225 | + */ |
|
226 | + public static function filter_cts($cts) |
|
227 | + { |
|
228 | + foreach (self::$_registry as $registries) { |
|
229 | + foreach ($registries['cts'] as $ct_name => $ct_settings) { |
|
230 | + $cts[ $ct_name ] = $ct_settings; |
|
231 | + } |
|
232 | + } |
|
233 | + return $cts; |
|
234 | + } |
|
235 | 235 | |
236 | 236 | |
237 | - /** |
|
238 | - * @deprecated 4.9.62.p |
|
239 | - * @param EE_Register_CPTs $cpt_class |
|
240 | - * @return void |
|
241 | - */ |
|
242 | - public static function default_terms(EE_Register_CPTs $cpt_class) |
|
243 | - { |
|
244 | - foreach (self::$_registry as $registries) { |
|
245 | - foreach ($registries['default_terms'] as $taxonomy => $terms) { |
|
246 | - foreach ($terms as $term => $cpts) { |
|
247 | - $cpt_class->set_default_term($taxonomy, $term, $cpts); |
|
248 | - } |
|
249 | - } |
|
250 | - } |
|
251 | - } |
|
237 | + /** |
|
238 | + * @deprecated 4.9.62.p |
|
239 | + * @param EE_Register_CPTs $cpt_class |
|
240 | + * @return void |
|
241 | + */ |
|
242 | + public static function default_terms(EE_Register_CPTs $cpt_class) |
|
243 | + { |
|
244 | + foreach (self::$_registry as $registries) { |
|
245 | + foreach ($registries['default_terms'] as $taxonomy => $terms) { |
|
246 | + foreach ($terms as $term => $cpts) { |
|
247 | + $cpt_class->set_default_term($taxonomy, $term, $cpts); |
|
248 | + } |
|
249 | + } |
|
250 | + } |
|
251 | + } |
|
252 | 252 | |
253 | 253 | |
254 | - /** |
|
255 | - * This deregisters whats been registered on this class (for the given slug). |
|
256 | - * |
|
257 | - * @since 4.5.0 |
|
258 | - * |
|
259 | - * @param string $cpt_ref The reference for the item registered to be removed. |
|
260 | - * |
|
261 | - * @return void |
|
262 | - */ |
|
263 | - public static function deregister($cpt_ref = null) |
|
264 | - { |
|
265 | - if (! empty(self::$_registry[ $cpt_ref ])) { |
|
266 | - unset(self::$_registry[ $cpt_ref ]); |
|
267 | - } |
|
268 | - } |
|
254 | + /** |
|
255 | + * This deregisters whats been registered on this class (for the given slug). |
|
256 | + * |
|
257 | + * @since 4.5.0 |
|
258 | + * |
|
259 | + * @param string $cpt_ref The reference for the item registered to be removed. |
|
260 | + * |
|
261 | + * @return void |
|
262 | + */ |
|
263 | + public static function deregister($cpt_ref = null) |
|
264 | + { |
|
265 | + if (! empty(self::$_registry[ $cpt_ref ])) { |
|
266 | + unset(self::$_registry[ $cpt_ref ]); |
|
267 | + } |
|
268 | + } |
|
269 | 269 | } |
@@ -12,475 +12,475 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * Holds values for registered message types |
|
17 | - * |
|
18 | - * @var array |
|
19 | - */ |
|
20 | - protected static $_ee_message_type_registry = array(); |
|
15 | + /** |
|
16 | + * Holds values for registered message types |
|
17 | + * |
|
18 | + * @var array |
|
19 | + */ |
|
20 | + protected static $_ee_message_type_registry = array(); |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * Method for registering new message types in the EE_messages system. |
|
25 | - * Note: All message types must have the following files in order to work: |
|
26 | - * Template files for default templates getting setup. |
|
27 | - * See /core/libraries/messages/defaults/default/ for examples |
|
28 | - * (note that template files match a specific naming schema). |
|
29 | - * These templates will need to be registered with the default template pack. |
|
30 | - * - EE_Messages_Validator extended class(es). See /core/libraries/messages/validators/email/ |
|
31 | - * for examples. Note for any new message types, there will need to be a validator for each |
|
32 | - * messenger combo this message type can activate with. |
|
33 | - * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new |
|
34 | - * message type and its properties. |
|
35 | - * |
|
36 | - * @since 4.3.0 |
|
37 | - * @param string $mt_name Whatever is defined for the $name property of |
|
38 | - * the message type you are registering (eg. |
|
39 | - * declined_registration). Required. |
|
40 | - * @param array $setup_args An array of arguments provided for registering the message type. |
|
41 | - * @see inline docs in the register method for what can be passed in as arguments. |
|
42 | - * @throws \EE_Error |
|
43 | - * } |
|
44 | - */ |
|
45 | - public static function register($mt_name = null, $setup_args = array()) |
|
46 | - { |
|
47 | - // required fields MUST be present, so let's make sure they are. |
|
48 | - if (! isset($mt_name) |
|
49 | - || ! is_array($setup_args) |
|
50 | - || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']) |
|
51 | - ) { |
|
52 | - throw new EE_Error( |
|
53 | - __( |
|
54 | - 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', |
|
55 | - 'event_espresso' |
|
56 | - ) |
|
57 | - ); |
|
58 | - } |
|
23 | + /** |
|
24 | + * Method for registering new message types in the EE_messages system. |
|
25 | + * Note: All message types must have the following files in order to work: |
|
26 | + * Template files for default templates getting setup. |
|
27 | + * See /core/libraries/messages/defaults/default/ for examples |
|
28 | + * (note that template files match a specific naming schema). |
|
29 | + * These templates will need to be registered with the default template pack. |
|
30 | + * - EE_Messages_Validator extended class(es). See /core/libraries/messages/validators/email/ |
|
31 | + * for examples. Note for any new message types, there will need to be a validator for each |
|
32 | + * messenger combo this message type can activate with. |
|
33 | + * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new |
|
34 | + * message type and its properties. |
|
35 | + * |
|
36 | + * @since 4.3.0 |
|
37 | + * @param string $mt_name Whatever is defined for the $name property of |
|
38 | + * the message type you are registering (eg. |
|
39 | + * declined_registration). Required. |
|
40 | + * @param array $setup_args An array of arguments provided for registering the message type. |
|
41 | + * @see inline docs in the register method for what can be passed in as arguments. |
|
42 | + * @throws \EE_Error |
|
43 | + * } |
|
44 | + */ |
|
45 | + public static function register($mt_name = null, $setup_args = array()) |
|
46 | + { |
|
47 | + // required fields MUST be present, so let's make sure they are. |
|
48 | + if (! isset($mt_name) |
|
49 | + || ! is_array($setup_args) |
|
50 | + || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']) |
|
51 | + ) { |
|
52 | + throw new EE_Error( |
|
53 | + __( |
|
54 | + 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', |
|
55 | + 'event_espresso' |
|
56 | + ) |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | |
60 | - // make sure we don't register twice |
|
61 | - if (isset(self::$_ee_message_type_registry[ $mt_name ])) { |
|
62 | - return; |
|
63 | - } |
|
60 | + // make sure we don't register twice |
|
61 | + if (isset(self::$_ee_message_type_registry[ $mt_name ])) { |
|
62 | + return; |
|
63 | + } |
|
64 | 64 | |
65 | - // make sure this was called in the right place! |
|
66 | - if (! did_action('EE_Brewing_Regular___messages_caf') |
|
67 | - || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
68 | - ) { |
|
69 | - EE_Error::doing_it_wrong( |
|
70 | - __METHOD__, |
|
71 | - sprintf( |
|
72 | - __( |
|
73 | - 'A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', |
|
74 | - 'event_espresso' |
|
75 | - ), |
|
76 | - $mt_name |
|
77 | - ), |
|
78 | - '4.3.0' |
|
79 | - ); |
|
80 | - } |
|
81 | - // setup $__ee_message_type_registry array from incoming values. |
|
82 | - self::$_ee_message_type_registry[ $mt_name ] = array( |
|
83 | - /** |
|
84 | - * The file name for the message type being registered. |
|
85 | - * Required. |
|
86 | - * |
|
87 | - * @type string |
|
88 | - */ |
|
89 | - 'mtfilename' => (string) $setup_args['mtfilename'], |
|
90 | - /** |
|
91 | - * Autoload paths for classes used by the message type. |
|
92 | - * Required. |
|
93 | - * |
|
94 | - * @type array |
|
95 | - */ |
|
96 | - 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
97 | - /** |
|
98 | - * Messengers that the message type should be able to activate with. |
|
99 | - * Use messenger slugs. |
|
100 | - * |
|
101 | - * @type array |
|
102 | - */ |
|
103 | - 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) |
|
104 | - ? (array) $setup_args['messengers_to_activate_with'] |
|
105 | - : array(), |
|
106 | - /** |
|
107 | - * Messengers that the message type should validate with. |
|
108 | - * Use messenger slugs. |
|
109 | - * |
|
110 | - * @type array |
|
111 | - */ |
|
112 | - 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) |
|
113 | - ? (array) $setup_args['messengers_to_validate_with'] |
|
114 | - : array(), |
|
115 | - /** |
|
116 | - * Whether to force activate this message type the first time it is registered. |
|
117 | - * |
|
118 | - * @type bool False means its not activated by default and left up to the end user to activate. |
|
119 | - */ |
|
120 | - 'force_activation' => ! empty($setup_args['force_activation']) |
|
121 | - ? (bool) $setup_args['force_activation'] |
|
122 | - : false, |
|
123 | - /** |
|
124 | - * What messengers this message type supports the default template pack for. |
|
125 | - * Note: If you do not set this (or any of the following template pack/variation related arguments) to true, |
|
126 | - * then it is expected that the message type being registered is doing its own custom default template |
|
127 | - * pack/variation registration. |
|
128 | - * |
|
129 | - * If this is set and has values, then it is expected that the following arguments are also set in the incoming options |
|
130 | - * $setup_arguments array as well: |
|
131 | - * - 'base_path_for_default_templates' |
|
132 | - * |
|
133 | - * @type array Expect an array of messengers this supports default template packs for. |
|
134 | - */ |
|
135 | - 'messengers_supporting_default_template_pack_with' => isset($setup_args['messengers_supporting_default_template_pack_with']) |
|
136 | - ? (array) $setup_args['messengers_supporting_default_template_pack_with'] |
|
137 | - : array(), |
|
138 | - /** |
|
139 | - * The base path where the default templates for this message type can be found. |
|
140 | - * |
|
141 | - * @type string |
|
142 | - */ |
|
143 | - 'base_path_for_default_templates' => isset($setup_args['base_path_for_default_templates']) |
|
144 | - ? $setup_args['base_path_for_default_templates'] |
|
145 | - : '', |
|
146 | - /** |
|
147 | - * The base path where the default variations for this message type can be found. |
|
148 | - * |
|
149 | - * @type string |
|
150 | - */ |
|
151 | - 'base_path_for_default_variation' => isset($setup_args['base_path_for_default_variation']) |
|
152 | - ? $setup_args['base_path_for_default_variation'] |
|
153 | - : '', |
|
154 | - /** |
|
155 | - * The base url for the default variations for this message type. |
|
156 | - * |
|
157 | - * @type string |
|
158 | - */ |
|
159 | - 'base_url_for_default_variation' => isset($setup_args['base_url_for_default_variation']) |
|
160 | - ? $setup_args['base_url_for_default_variation'] |
|
161 | - : '', |
|
162 | - ); |
|
163 | - // add filters but only if they haven't already been set (these filters only need to be registered ONCE because |
|
164 | - // the callback handles all registered message types. |
|
165 | - if (false === has_filter( |
|
166 | - 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
167 | - array('EE_Register_Message_Type', 'register_msgs_autoload_paths') |
|
168 | - )) { |
|
169 | - add_filter( |
|
170 | - 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
171 | - array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), |
|
172 | - 10 |
|
173 | - ); |
|
174 | - add_filter( |
|
175 | - 'FHEE__EE_messages__get_installed__messagetype_files', |
|
176 | - array('EE_Register_Message_Type', 'register_messagetype_files'), |
|
177 | - 10, |
|
178 | - 1 |
|
179 | - ); |
|
180 | - add_filter( |
|
181 | - 'FHEE__EE_messenger__get_default_message_types__default_types', |
|
182 | - array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), |
|
183 | - 10, |
|
184 | - 2 |
|
185 | - ); |
|
186 | - add_filter( |
|
187 | - 'FHEE__EE_messenger__get_valid_message_types__valid_types', |
|
188 | - array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), |
|
189 | - 10, |
|
190 | - 2 |
|
191 | - ); |
|
192 | - // actions |
|
193 | - add_action( |
|
194 | - 'AHEE__EE_Addon__initialize_default_data__begin', |
|
195 | - array('EE_Register_Message_Type', 'set_defaults') |
|
196 | - ); |
|
65 | + // make sure this was called in the right place! |
|
66 | + if (! did_action('EE_Brewing_Regular___messages_caf') |
|
67 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
68 | + ) { |
|
69 | + EE_Error::doing_it_wrong( |
|
70 | + __METHOD__, |
|
71 | + sprintf( |
|
72 | + __( |
|
73 | + 'A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', |
|
74 | + 'event_espresso' |
|
75 | + ), |
|
76 | + $mt_name |
|
77 | + ), |
|
78 | + '4.3.0' |
|
79 | + ); |
|
80 | + } |
|
81 | + // setup $__ee_message_type_registry array from incoming values. |
|
82 | + self::$_ee_message_type_registry[ $mt_name ] = array( |
|
83 | + /** |
|
84 | + * The file name for the message type being registered. |
|
85 | + * Required. |
|
86 | + * |
|
87 | + * @type string |
|
88 | + */ |
|
89 | + 'mtfilename' => (string) $setup_args['mtfilename'], |
|
90 | + /** |
|
91 | + * Autoload paths for classes used by the message type. |
|
92 | + * Required. |
|
93 | + * |
|
94 | + * @type array |
|
95 | + */ |
|
96 | + 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
97 | + /** |
|
98 | + * Messengers that the message type should be able to activate with. |
|
99 | + * Use messenger slugs. |
|
100 | + * |
|
101 | + * @type array |
|
102 | + */ |
|
103 | + 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) |
|
104 | + ? (array) $setup_args['messengers_to_activate_with'] |
|
105 | + : array(), |
|
106 | + /** |
|
107 | + * Messengers that the message type should validate with. |
|
108 | + * Use messenger slugs. |
|
109 | + * |
|
110 | + * @type array |
|
111 | + */ |
|
112 | + 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) |
|
113 | + ? (array) $setup_args['messengers_to_validate_with'] |
|
114 | + : array(), |
|
115 | + /** |
|
116 | + * Whether to force activate this message type the first time it is registered. |
|
117 | + * |
|
118 | + * @type bool False means its not activated by default and left up to the end user to activate. |
|
119 | + */ |
|
120 | + 'force_activation' => ! empty($setup_args['force_activation']) |
|
121 | + ? (bool) $setup_args['force_activation'] |
|
122 | + : false, |
|
123 | + /** |
|
124 | + * What messengers this message type supports the default template pack for. |
|
125 | + * Note: If you do not set this (or any of the following template pack/variation related arguments) to true, |
|
126 | + * then it is expected that the message type being registered is doing its own custom default template |
|
127 | + * pack/variation registration. |
|
128 | + * |
|
129 | + * If this is set and has values, then it is expected that the following arguments are also set in the incoming options |
|
130 | + * $setup_arguments array as well: |
|
131 | + * - 'base_path_for_default_templates' |
|
132 | + * |
|
133 | + * @type array Expect an array of messengers this supports default template packs for. |
|
134 | + */ |
|
135 | + 'messengers_supporting_default_template_pack_with' => isset($setup_args['messengers_supporting_default_template_pack_with']) |
|
136 | + ? (array) $setup_args['messengers_supporting_default_template_pack_with'] |
|
137 | + : array(), |
|
138 | + /** |
|
139 | + * The base path where the default templates for this message type can be found. |
|
140 | + * |
|
141 | + * @type string |
|
142 | + */ |
|
143 | + 'base_path_for_default_templates' => isset($setup_args['base_path_for_default_templates']) |
|
144 | + ? $setup_args['base_path_for_default_templates'] |
|
145 | + : '', |
|
146 | + /** |
|
147 | + * The base path where the default variations for this message type can be found. |
|
148 | + * |
|
149 | + * @type string |
|
150 | + */ |
|
151 | + 'base_path_for_default_variation' => isset($setup_args['base_path_for_default_variation']) |
|
152 | + ? $setup_args['base_path_for_default_variation'] |
|
153 | + : '', |
|
154 | + /** |
|
155 | + * The base url for the default variations for this message type. |
|
156 | + * |
|
157 | + * @type string |
|
158 | + */ |
|
159 | + 'base_url_for_default_variation' => isset($setup_args['base_url_for_default_variation']) |
|
160 | + ? $setup_args['base_url_for_default_variation'] |
|
161 | + : '', |
|
162 | + ); |
|
163 | + // add filters but only if they haven't already been set (these filters only need to be registered ONCE because |
|
164 | + // the callback handles all registered message types. |
|
165 | + if (false === has_filter( |
|
166 | + 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
167 | + array('EE_Register_Message_Type', 'register_msgs_autoload_paths') |
|
168 | + )) { |
|
169 | + add_filter( |
|
170 | + 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
171 | + array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), |
|
172 | + 10 |
|
173 | + ); |
|
174 | + add_filter( |
|
175 | + 'FHEE__EE_messages__get_installed__messagetype_files', |
|
176 | + array('EE_Register_Message_Type', 'register_messagetype_files'), |
|
177 | + 10, |
|
178 | + 1 |
|
179 | + ); |
|
180 | + add_filter( |
|
181 | + 'FHEE__EE_messenger__get_default_message_types__default_types', |
|
182 | + array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), |
|
183 | + 10, |
|
184 | + 2 |
|
185 | + ); |
|
186 | + add_filter( |
|
187 | + 'FHEE__EE_messenger__get_valid_message_types__valid_types', |
|
188 | + array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), |
|
189 | + 10, |
|
190 | + 2 |
|
191 | + ); |
|
192 | + // actions |
|
193 | + add_action( |
|
194 | + 'AHEE__EE_Addon__initialize_default_data__begin', |
|
195 | + array('EE_Register_Message_Type', 'set_defaults') |
|
196 | + ); |
|
197 | 197 | |
198 | - // default template packs and variations related |
|
199 | - add_filter( |
|
200 | - 'FHEE__EE_Messages_Template_Pack_Default__get_supports', |
|
201 | - array('EE_Register_Message_Type', 'register_default_template_pack_supports') |
|
202 | - ); |
|
203 | - add_filter( |
|
204 | - 'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', |
|
205 | - array('EE_Register_Message_Type', 'register_base_template_path'), |
|
206 | - 10, |
|
207 | - 6 |
|
208 | - ); |
|
209 | - add_filter( |
|
210 | - 'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', |
|
211 | - array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
212 | - 10, |
|
213 | - 8 |
|
214 | - ); |
|
215 | - add_filter( |
|
216 | - 'FHEE__EE_Messages_Template_Pack__get_variation__base_path', |
|
217 | - array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
218 | - 10, |
|
219 | - 8 |
|
220 | - ); |
|
221 | - } |
|
222 | - } |
|
198 | + // default template packs and variations related |
|
199 | + add_filter( |
|
200 | + 'FHEE__EE_Messages_Template_Pack_Default__get_supports', |
|
201 | + array('EE_Register_Message_Type', 'register_default_template_pack_supports') |
|
202 | + ); |
|
203 | + add_filter( |
|
204 | + 'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', |
|
205 | + array('EE_Register_Message_Type', 'register_base_template_path'), |
|
206 | + 10, |
|
207 | + 6 |
|
208 | + ); |
|
209 | + add_filter( |
|
210 | + 'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', |
|
211 | + array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
212 | + 10, |
|
213 | + 8 |
|
214 | + ); |
|
215 | + add_filter( |
|
216 | + 'FHEE__EE_Messages_Template_Pack__get_variation__base_path', |
|
217 | + array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
218 | + 10, |
|
219 | + 8 |
|
220 | + ); |
|
221 | + } |
|
222 | + } |
|
223 | 223 | |
224 | 224 | |
225 | - /** |
|
226 | - * This just ensures that when an addon registers a message type that on initial activation/reactivation the |
|
227 | - * defaults the addon sets are taken care of. |
|
228 | - */ |
|
229 | - public static function set_defaults() |
|
230 | - { |
|
231 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
232 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
225 | + /** |
|
226 | + * This just ensures that when an addon registers a message type that on initial activation/reactivation the |
|
227 | + * defaults the addon sets are taken care of. |
|
228 | + */ |
|
229 | + public static function set_defaults() |
|
230 | + { |
|
231 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
232 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
233 | 233 | |
234 | - // for any message types with force activation, let's ensure they are activated |
|
235 | - foreach (self::$_ee_message_type_registry as $message_type_name => $settings) { |
|
236 | - if ($settings['force_activation']) { |
|
237 | - foreach ($settings['messengers_to_activate_with'] as $messenger) { |
|
238 | - // DO not force activation if this message type has already been activated in the system |
|
239 | - if (! $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
240 | - $message_type_name, |
|
241 | - $messenger |
|
242 | - ) |
|
243 | - ) { |
|
244 | - $message_resource_manager->ensure_message_type_is_active($message_type_name, $messenger); |
|
245 | - } |
|
246 | - } |
|
247 | - } |
|
248 | - } |
|
249 | - } |
|
234 | + // for any message types with force activation, let's ensure they are activated |
|
235 | + foreach (self::$_ee_message_type_registry as $message_type_name => $settings) { |
|
236 | + if ($settings['force_activation']) { |
|
237 | + foreach ($settings['messengers_to_activate_with'] as $messenger) { |
|
238 | + // DO not force activation if this message type has already been activated in the system |
|
239 | + if (! $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
240 | + $message_type_name, |
|
241 | + $messenger |
|
242 | + ) |
|
243 | + ) { |
|
244 | + $message_resource_manager->ensure_message_type_is_active($message_type_name, $messenger); |
|
245 | + } |
|
246 | + } |
|
247 | + } |
|
248 | + } |
|
249 | + } |
|
250 | 250 | |
251 | 251 | |
252 | - /** |
|
253 | - * This deregisters a message type that was previously registered with a specific message_type_name. |
|
254 | - * |
|
255 | - * @since 4.3.0 |
|
256 | - * @param string $message_type_name the name for the message type that was previously registered |
|
257 | - * @return void |
|
258 | - */ |
|
259 | - public static function deregister($message_type_name = null) |
|
260 | - { |
|
261 | - if (! empty(self::$_ee_message_type_registry[ $message_type_name ])) { |
|
262 | - // let's make sure that we remove any place this message type was made active |
|
263 | - /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
|
264 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
265 | - // ensures that if this message type is registered again that it retains its previous active state vs |
|
266 | - // remaining inactive. |
|
267 | - $Message_Resource_Manager->remove_message_type_has_been_activated_from_all_messengers( |
|
268 | - $message_type_name, |
|
269 | - true |
|
270 | - ); |
|
271 | - $Message_Resource_Manager->deactivate_message_type($message_type_name, false); |
|
272 | - unset(self::$_ee_message_type_registry[ $message_type_name ]); |
|
273 | - } |
|
274 | - } |
|
252 | + /** |
|
253 | + * This deregisters a message type that was previously registered with a specific message_type_name. |
|
254 | + * |
|
255 | + * @since 4.3.0 |
|
256 | + * @param string $message_type_name the name for the message type that was previously registered |
|
257 | + * @return void |
|
258 | + */ |
|
259 | + public static function deregister($message_type_name = null) |
|
260 | + { |
|
261 | + if (! empty(self::$_ee_message_type_registry[ $message_type_name ])) { |
|
262 | + // let's make sure that we remove any place this message type was made active |
|
263 | + /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
|
264 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
265 | + // ensures that if this message type is registered again that it retains its previous active state vs |
|
266 | + // remaining inactive. |
|
267 | + $Message_Resource_Manager->remove_message_type_has_been_activated_from_all_messengers( |
|
268 | + $message_type_name, |
|
269 | + true |
|
270 | + ); |
|
271 | + $Message_Resource_Manager->deactivate_message_type($message_type_name, false); |
|
272 | + unset(self::$_ee_message_type_registry[ $message_type_name ]); |
|
273 | + } |
|
274 | + } |
|
275 | 275 | |
276 | 276 | |
277 | - /** |
|
278 | - * callback for FHEE__EE_messages__get_installed__messagetype_files filter. |
|
279 | - * |
|
280 | - * @since 4.3.0 |
|
281 | - * @param array $messagetype_files The current array of message type file names |
|
282 | - * @return array Array of message type file names |
|
283 | - */ |
|
284 | - public static function register_messagetype_files($messagetype_files) |
|
285 | - { |
|
286 | - if (empty(self::$_ee_message_type_registry)) { |
|
287 | - return $messagetype_files; |
|
288 | - } |
|
289 | - foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
290 | - if (empty($mt_reg['mtfilename'])) { |
|
291 | - continue; |
|
292 | - } |
|
293 | - $messagetype_files[] = $mt_reg['mtfilename']; |
|
294 | - } |
|
295 | - return $messagetype_files; |
|
296 | - } |
|
277 | + /** |
|
278 | + * callback for FHEE__EE_messages__get_installed__messagetype_files filter. |
|
279 | + * |
|
280 | + * @since 4.3.0 |
|
281 | + * @param array $messagetype_files The current array of message type file names |
|
282 | + * @return array Array of message type file names |
|
283 | + */ |
|
284 | + public static function register_messagetype_files($messagetype_files) |
|
285 | + { |
|
286 | + if (empty(self::$_ee_message_type_registry)) { |
|
287 | + return $messagetype_files; |
|
288 | + } |
|
289 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
290 | + if (empty($mt_reg['mtfilename'])) { |
|
291 | + continue; |
|
292 | + } |
|
293 | + $messagetype_files[] = $mt_reg['mtfilename']; |
|
294 | + } |
|
295 | + return $messagetype_files; |
|
296 | + } |
|
297 | 297 | |
298 | 298 | |
299 | - /** |
|
300 | - * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
301 | - * |
|
302 | - * @since 4.3.0 |
|
303 | - * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
304 | - * @return array |
|
305 | - */ |
|
306 | - public static function register_msgs_autoload_paths($paths) |
|
307 | - { |
|
308 | - if (! empty(self::$_ee_message_type_registry)) { |
|
309 | - foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
310 | - if (empty($mt_reg['autoloadpaths'])) { |
|
311 | - continue; |
|
312 | - } |
|
313 | - $paths = array_merge($paths, $mt_reg['autoloadpaths']); |
|
314 | - } |
|
315 | - } |
|
316 | - return $paths; |
|
317 | - } |
|
299 | + /** |
|
300 | + * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
301 | + * |
|
302 | + * @since 4.3.0 |
|
303 | + * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
304 | + * @return array |
|
305 | + */ |
|
306 | + public static function register_msgs_autoload_paths($paths) |
|
307 | + { |
|
308 | + if (! empty(self::$_ee_message_type_registry)) { |
|
309 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
310 | + if (empty($mt_reg['autoloadpaths'])) { |
|
311 | + continue; |
|
312 | + } |
|
313 | + $paths = array_merge($paths, $mt_reg['autoloadpaths']); |
|
314 | + } |
|
315 | + } |
|
316 | + return $paths; |
|
317 | + } |
|
318 | 318 | |
319 | 319 | |
320 | - /** |
|
321 | - * callback for FHEE__EE_messenger__get_default_message_types__default_types filter. |
|
322 | - * |
|
323 | - * @since 4.3.0 |
|
324 | - * @param array $default_types array of message types activated with messenger ( |
|
325 | - * corresponds to the $name property of message type) |
|
326 | - * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
327 | - * @return array |
|
328 | - */ |
|
329 | - public static function register_messengers_to_activate_mt_with($default_types, EE_messenger $messenger) |
|
330 | - { |
|
331 | - if (empty(self::$_ee_message_type_registry)) { |
|
332 | - return $default_types; |
|
333 | - } |
|
334 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
335 | - if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) { |
|
336 | - continue; |
|
337 | - } |
|
338 | - // loop through each of the messengers and if it matches the loaded class |
|
339 | - // then we add this message type to the |
|
340 | - foreach ($mt_reg['messengers_to_activate_with'] as $msgr) { |
|
341 | - if ($messenger->name == $msgr) { |
|
342 | - $default_types[] = $message_type_name; |
|
343 | - } |
|
344 | - } |
|
345 | - } |
|
320 | + /** |
|
321 | + * callback for FHEE__EE_messenger__get_default_message_types__default_types filter. |
|
322 | + * |
|
323 | + * @since 4.3.0 |
|
324 | + * @param array $default_types array of message types activated with messenger ( |
|
325 | + * corresponds to the $name property of message type) |
|
326 | + * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
327 | + * @return array |
|
328 | + */ |
|
329 | + public static function register_messengers_to_activate_mt_with($default_types, EE_messenger $messenger) |
|
330 | + { |
|
331 | + if (empty(self::$_ee_message_type_registry)) { |
|
332 | + return $default_types; |
|
333 | + } |
|
334 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
335 | + if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) { |
|
336 | + continue; |
|
337 | + } |
|
338 | + // loop through each of the messengers and if it matches the loaded class |
|
339 | + // then we add this message type to the |
|
340 | + foreach ($mt_reg['messengers_to_activate_with'] as $msgr) { |
|
341 | + if ($messenger->name == $msgr) { |
|
342 | + $default_types[] = $message_type_name; |
|
343 | + } |
|
344 | + } |
|
345 | + } |
|
346 | 346 | |
347 | - return $default_types; |
|
348 | - } |
|
347 | + return $default_types; |
|
348 | + } |
|
349 | 349 | |
350 | 350 | |
351 | - /** |
|
352 | - * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
353 | - * |
|
354 | - * @since 4.3.0 |
|
355 | - * @param array $valid_types array of message types valid with messenger ( |
|
356 | - * corresponds to the $name property of message type) |
|
357 | - * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
358 | - * @return array |
|
359 | - */ |
|
360 | - public static function register_messengers_to_validate_mt_with($valid_types, EE_messenger $messenger) |
|
361 | - { |
|
362 | - if (empty(self::$_ee_message_type_registry)) { |
|
363 | - return $valid_types; |
|
364 | - } |
|
365 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
366 | - if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) { |
|
367 | - continue; |
|
368 | - } |
|
369 | - // loop through each of the messengers and if it matches the loaded class |
|
370 | - // then we add this message type to the |
|
371 | - foreach ($mt_reg['messengers_to_validate_with'] as $msgr) { |
|
372 | - if ($messenger->name == $msgr) { |
|
373 | - $valid_types[] = $message_type_name; |
|
374 | - } |
|
375 | - } |
|
376 | - } |
|
351 | + /** |
|
352 | + * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
353 | + * |
|
354 | + * @since 4.3.0 |
|
355 | + * @param array $valid_types array of message types valid with messenger ( |
|
356 | + * corresponds to the $name property of message type) |
|
357 | + * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
358 | + * @return array |
|
359 | + */ |
|
360 | + public static function register_messengers_to_validate_mt_with($valid_types, EE_messenger $messenger) |
|
361 | + { |
|
362 | + if (empty(self::$_ee_message_type_registry)) { |
|
363 | + return $valid_types; |
|
364 | + } |
|
365 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
366 | + if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) { |
|
367 | + continue; |
|
368 | + } |
|
369 | + // loop through each of the messengers and if it matches the loaded class |
|
370 | + // then we add this message type to the |
|
371 | + foreach ($mt_reg['messengers_to_validate_with'] as $msgr) { |
|
372 | + if ($messenger->name == $msgr) { |
|
373 | + $valid_types[] = $message_type_name; |
|
374 | + } |
|
375 | + } |
|
376 | + } |
|
377 | 377 | |
378 | - return $valid_types; |
|
379 | - } |
|
378 | + return $valid_types; |
|
379 | + } |
|
380 | 380 | |
381 | 381 | |
382 | - /** |
|
383 | - * Callback for `FHEE__EE_Messages_Template_Pack_Default__get_supports` filter to register this message type as |
|
384 | - * supporting the default template pack |
|
385 | - * |
|
386 | - * @param array $supports |
|
387 | - * |
|
388 | - * @return array |
|
389 | - */ |
|
390 | - public static function register_default_template_pack_supports($supports) |
|
391 | - { |
|
392 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
393 | - if (empty($mt_reg['messengers_supporting_default_template_pack_with'])) { |
|
394 | - continue; |
|
395 | - } |
|
396 | - foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) { |
|
397 | - $supports[ $messenger_slug ][] = $message_type_name; |
|
398 | - } |
|
399 | - } |
|
400 | - return $supports; |
|
401 | - } |
|
382 | + /** |
|
383 | + * Callback for `FHEE__EE_Messages_Template_Pack_Default__get_supports` filter to register this message type as |
|
384 | + * supporting the default template pack |
|
385 | + * |
|
386 | + * @param array $supports |
|
387 | + * |
|
388 | + * @return array |
|
389 | + */ |
|
390 | + public static function register_default_template_pack_supports($supports) |
|
391 | + { |
|
392 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
393 | + if (empty($mt_reg['messengers_supporting_default_template_pack_with'])) { |
|
394 | + continue; |
|
395 | + } |
|
396 | + foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) { |
|
397 | + $supports[ $messenger_slug ][] = $message_type_name; |
|
398 | + } |
|
399 | + } |
|
400 | + return $supports; |
|
401 | + } |
|
402 | 402 | |
403 | 403 | |
404 | - /** |
|
405 | - * Callback for FHEE__EE_Template_Pack___get_specific_template__filtered_base_path |
|
406 | - * |
|
407 | - * @param string $base_path The original base path for message templates |
|
408 | - * @param EE_messenger $messenger |
|
409 | - * @param EE_message_type $message_type |
|
410 | - * @param string $field The field requesting a template |
|
411 | - * @param string $context The context requesting a template |
|
412 | - * @param EE_Messages_Template_Pack $template_pack |
|
413 | - * |
|
414 | - * @return string |
|
415 | - */ |
|
416 | - public static function register_base_template_path( |
|
417 | - $base_path, |
|
418 | - $messenger, |
|
419 | - $message_type, |
|
420 | - $field, |
|
421 | - $context, |
|
422 | - $template_pack |
|
423 | - ) { |
|
424 | - if (! $template_pack instanceof EE_Messages_Template_Pack_Default |
|
425 | - || ! $message_type instanceof EE_message_type |
|
426 | - ) { |
|
427 | - return $base_path; |
|
428 | - } |
|
429 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
430 | - if ($message_type->name === $message_type_name |
|
431 | - && ! empty($mt_reg['base_path_for_default_templates']) |
|
432 | - ) { |
|
433 | - return $mt_reg['base_path_for_default_templates']; |
|
434 | - } |
|
435 | - } |
|
436 | - return $base_path; |
|
437 | - } |
|
404 | + /** |
|
405 | + * Callback for FHEE__EE_Template_Pack___get_specific_template__filtered_base_path |
|
406 | + * |
|
407 | + * @param string $base_path The original base path for message templates |
|
408 | + * @param EE_messenger $messenger |
|
409 | + * @param EE_message_type $message_type |
|
410 | + * @param string $field The field requesting a template |
|
411 | + * @param string $context The context requesting a template |
|
412 | + * @param EE_Messages_Template_Pack $template_pack |
|
413 | + * |
|
414 | + * @return string |
|
415 | + */ |
|
416 | + public static function register_base_template_path( |
|
417 | + $base_path, |
|
418 | + $messenger, |
|
419 | + $message_type, |
|
420 | + $field, |
|
421 | + $context, |
|
422 | + $template_pack |
|
423 | + ) { |
|
424 | + if (! $template_pack instanceof EE_Messages_Template_Pack_Default |
|
425 | + || ! $message_type instanceof EE_message_type |
|
426 | + ) { |
|
427 | + return $base_path; |
|
428 | + } |
|
429 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
430 | + if ($message_type->name === $message_type_name |
|
431 | + && ! empty($mt_reg['base_path_for_default_templates']) |
|
432 | + ) { |
|
433 | + return $mt_reg['base_path_for_default_templates']; |
|
434 | + } |
|
435 | + } |
|
436 | + return $base_path; |
|
437 | + } |
|
438 | 438 | |
439 | 439 | |
440 | - /** |
|
441 | - * Callback for FHEE__EE_Messages_Template_Pack__get_variation__base_path and |
|
442 | - * FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url hooks |
|
443 | - * |
|
444 | - * @param string $base_path_or_url The original incoming base url or path |
|
445 | - * @param string $messenger_slug The slug of the messenger the template is being generated |
|
446 | - * for. |
|
447 | - * @param string $message_type_slug The slug of the message type the template is being generated |
|
448 | - * for. |
|
449 | - * @param string $type The "type" of css being requested. |
|
450 | - * @param string $variation The variation being requested. |
|
451 | - * @param string $file_extension What file extension is expected for the variation file. |
|
452 | - * @param bool $url whether a url or path is being requested. |
|
453 | - * @param EE_Messages_Template_Pack $template_pack |
|
454 | - * |
|
455 | - * @return string |
|
456 | - */ |
|
457 | - public static function register_variation_base_path_or_url( |
|
458 | - $base_path_or_url, |
|
459 | - $messenger_slug, |
|
460 | - $message_type_slug, |
|
461 | - $type, |
|
462 | - $variation, |
|
463 | - $url, |
|
464 | - $file_extension, |
|
465 | - $template_pack |
|
466 | - ) { |
|
467 | - if (! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
468 | - return $base_path_or_url; |
|
469 | - } |
|
470 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
471 | - if ($message_type_name === $message_type_slug |
|
472 | - ) { |
|
473 | - if ($url |
|
474 | - && ! empty($mt_reg['base_url_for_default_variation']) |
|
475 | - ) { |
|
476 | - return $mt_reg['base_url_for_default_variation']; |
|
477 | - } elseif (! $url |
|
478 | - && ! empty($mt_reg['base_path_for_default_variation']) |
|
479 | - ) { |
|
480 | - return $mt_reg['base_path_for_default_variation']; |
|
481 | - } |
|
482 | - } |
|
483 | - } |
|
484 | - return $base_path_or_url; |
|
485 | - } |
|
440 | + /** |
|
441 | + * Callback for FHEE__EE_Messages_Template_Pack__get_variation__base_path and |
|
442 | + * FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url hooks |
|
443 | + * |
|
444 | + * @param string $base_path_or_url The original incoming base url or path |
|
445 | + * @param string $messenger_slug The slug of the messenger the template is being generated |
|
446 | + * for. |
|
447 | + * @param string $message_type_slug The slug of the message type the template is being generated |
|
448 | + * for. |
|
449 | + * @param string $type The "type" of css being requested. |
|
450 | + * @param string $variation The variation being requested. |
|
451 | + * @param string $file_extension What file extension is expected for the variation file. |
|
452 | + * @param bool $url whether a url or path is being requested. |
|
453 | + * @param EE_Messages_Template_Pack $template_pack |
|
454 | + * |
|
455 | + * @return string |
|
456 | + */ |
|
457 | + public static function register_variation_base_path_or_url( |
|
458 | + $base_path_or_url, |
|
459 | + $messenger_slug, |
|
460 | + $message_type_slug, |
|
461 | + $type, |
|
462 | + $variation, |
|
463 | + $url, |
|
464 | + $file_extension, |
|
465 | + $template_pack |
|
466 | + ) { |
|
467 | + if (! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
468 | + return $base_path_or_url; |
|
469 | + } |
|
470 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
471 | + if ($message_type_name === $message_type_slug |
|
472 | + ) { |
|
473 | + if ($url |
|
474 | + && ! empty($mt_reg['base_url_for_default_variation']) |
|
475 | + ) { |
|
476 | + return $mt_reg['base_url_for_default_variation']; |
|
477 | + } elseif (! $url |
|
478 | + && ! empty($mt_reg['base_path_for_default_variation']) |
|
479 | + ) { |
|
480 | + return $mt_reg['base_path_for_default_variation']; |
|
481 | + } |
|
482 | + } |
|
483 | + } |
|
484 | + return $base_path_or_url; |
|
485 | + } |
|
486 | 486 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public static function register($mt_name = null, $setup_args = array()) |
46 | 46 | { |
47 | 47 | // required fields MUST be present, so let's make sure they are. |
48 | - if (! isset($mt_name) |
|
48 | + if ( ! isset($mt_name) |
|
49 | 49 | || ! is_array($setup_args) |
50 | 50 | || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']) |
51 | 51 | ) { |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | // make sure we don't register twice |
61 | - if (isset(self::$_ee_message_type_registry[ $mt_name ])) { |
|
61 | + if (isset(self::$_ee_message_type_registry[$mt_name])) { |
|
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | 65 | // make sure this was called in the right place! |
66 | - if (! did_action('EE_Brewing_Regular___messages_caf') |
|
66 | + if ( ! did_action('EE_Brewing_Regular___messages_caf') |
|
67 | 67 | || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
68 | 68 | ) { |
69 | 69 | EE_Error::doing_it_wrong( |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | ); |
80 | 80 | } |
81 | 81 | // setup $__ee_message_type_registry array from incoming values. |
82 | - self::$_ee_message_type_registry[ $mt_name ] = array( |
|
82 | + self::$_ee_message_type_registry[$mt_name] = array( |
|
83 | 83 | /** |
84 | 84 | * The file name for the message type being registered. |
85 | 85 | * Required. |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | if ($settings['force_activation']) { |
237 | 237 | foreach ($settings['messengers_to_activate_with'] as $messenger) { |
238 | 238 | // DO not force activation if this message type has already been activated in the system |
239 | - if (! $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
239 | + if ( ! $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
240 | 240 | $message_type_name, |
241 | 241 | $messenger |
242 | 242 | ) |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public static function deregister($message_type_name = null) |
260 | 260 | { |
261 | - if (! empty(self::$_ee_message_type_registry[ $message_type_name ])) { |
|
261 | + if ( ! empty(self::$_ee_message_type_registry[$message_type_name])) { |
|
262 | 262 | // let's make sure that we remove any place this message type was made active |
263 | 263 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
264 | 264 | $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | true |
270 | 270 | ); |
271 | 271 | $Message_Resource_Manager->deactivate_message_type($message_type_name, false); |
272 | - unset(self::$_ee_message_type_registry[ $message_type_name ]); |
|
272 | + unset(self::$_ee_message_type_registry[$message_type_name]); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public static function register_msgs_autoload_paths($paths) |
307 | 307 | { |
308 | - if (! empty(self::$_ee_message_type_registry)) { |
|
308 | + if ( ! empty(self::$_ee_message_type_registry)) { |
|
309 | 309 | foreach (self::$_ee_message_type_registry as $mt_reg) { |
310 | 310 | if (empty($mt_reg['autoloadpaths'])) { |
311 | 311 | continue; |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | continue; |
395 | 395 | } |
396 | 396 | foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) { |
397 | - $supports[ $messenger_slug ][] = $message_type_name; |
|
397 | + $supports[$messenger_slug][] = $message_type_name; |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | return $supports; |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $context, |
422 | 422 | $template_pack |
423 | 423 | ) { |
424 | - if (! $template_pack instanceof EE_Messages_Template_Pack_Default |
|
424 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default |
|
425 | 425 | || ! $message_type instanceof EE_message_type |
426 | 426 | ) { |
427 | 427 | return $base_path; |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | $file_extension, |
465 | 465 | $template_pack |
466 | 466 | ) { |
467 | - if (! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
467 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
468 | 468 | return $base_path_or_url; |
469 | 469 | } |
470 | 470 | foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | && ! empty($mt_reg['base_url_for_default_variation']) |
475 | 475 | ) { |
476 | 476 | return $mt_reg['base_url_for_default_variation']; |
477 | - } elseif (! $url |
|
477 | + } elseif ( ! $url |
|
478 | 478 | && ! empty($mt_reg['base_path_for_default_variation']) |
479 | 479 | ) { |
480 | 480 | return $mt_reg['base_path_for_default_variation']; |
@@ -11,326 +11,326 @@ |
||
11 | 11 | class EE_Register_Messages_Template_Variations implements EEI_Plugin_API |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Holds values for registered variations |
|
16 | - * |
|
17 | - * @since 4.5.0 |
|
18 | - * |
|
19 | - * @var array |
|
20 | - */ |
|
21 | - protected static $_registry = array(); |
|
14 | + /** |
|
15 | + * Holds values for registered variations |
|
16 | + * |
|
17 | + * @since 4.5.0 |
|
18 | + * |
|
19 | + * @var array |
|
20 | + */ |
|
21 | + protected static $_registry = array(); |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * Used to register new variations |
|
26 | - * |
|
27 | - * Variations are attached to template packs and do not typically change any structural layout but merely tweak the |
|
28 | - * style of the layout. The most commonly known variation is css. CSS does not affect html structure just the |
|
29 | - * style of existing structure. |
|
30 | - * |
|
31 | - * It's important to remember that when variation files are loaded, the file structure looked for is: |
|
32 | - * '{$messenger}_{$messenger_variation_type}_{$variation_slug}.{$extension}'. |
|
33 | - * |
|
34 | - * - Every variation applies to specific messengers. That's why the variation file includes the messenger name |
|
35 | - * it. This ensures that if a template pack the variation is registered with supports multiple variations that |
|
36 | - * you can have the correct variation loaded. |
|
37 | - * - EE_messengers also implicitly define variation "types" which typically are the context in which a specific |
|
38 | - * variation is loaded. For instance the email messenger has: 'inline', which is the css added inline to the |
|
39 | - * email templates; 'preview', which is the same css only customized for when emails are previewed; and |
|
40 | - * 'wpeditor', which is the same css only customized so that it works with the wpeditor fields for templates to |
|
41 | - * give a accurate representation of the style in the wysiwyg editor. This means that for each variation, if |
|
42 | - * you want it to be accurately represented in various temlpate contexts you need to have that relevant |
|
43 | - * variation file available. |
|
44 | - * - $variation_slug is simply the variation slug for that variation. |
|
45 | - * - $extension = whatever the extension is for the variation used for the messenger calling it. In MOST cases |
|
46 | - * messenger variations are .css files. Note: if your file names are not formatted correctly then they will NOT |
|
47 | - * be loaded. The EE messages template pack system will fallback to corresponding default template pack for the |
|
48 | - * given messenger or as a last resort (i.e. no default variation for the given messenger) will not load any |
|
49 | - * variation (so the template pack would be unstyled) |
|
50 | - * |
|
51 | - * @see /core/libraries/messages/defaults/default/variations/* for example variation files for the email and html |
|
52 | - * messengers. |
|
53 | - * |
|
54 | - * @param string $variation_ref unique reference used to describe this variation registry. If |
|
55 | - * this ISN'T unique then this method will make it unique (and it |
|
56 | - * becomes harder to deregister). |
|
57 | - * @param array $setup_args { |
|
58 | - * an array of required values for registering the variations. |
|
59 | - * @type array $variations { |
|
60 | - * An array indexed by template_pack->dbref. and values are an array |
|
61 | - * indexed by messenger name and values are an array indexed by |
|
62 | - * message_type and values are an array indexed by variation_slug |
|
63 | - * and value is the localized label for the variation. Note this |
|
64 | - * api reserves the "default" variation name for the default |
|
65 | - * template pack so you can't register a default variation. Also, |
|
66 | - * try to use unique variation slugs to reference your variations |
|
67 | - * because this api checks if any existing varations are in place |
|
68 | - * with that name. If there are then subsequent variations for that |
|
69 | - * template pack with that same name will fail to register with a |
|
70 | - * persistent notice put up for the user. Required. |
|
71 | - * 'default' => array( |
|
72 | - * 'email' => array( |
|
73 | - * 'registration_approved' => array( |
|
74 | - * my_ee_addon_blue_lagoon' => __('Blue Lagoon', |
|
75 | - * 'text_domain'), |
|
76 | - * 'my_ee_addon_red_sunset' => __('Red Sunset', |
|
77 | - * 'text_domain') |
|
78 | - * ) |
|
79 | - * ) |
|
80 | - * ) |
|
81 | - * } |
|
82 | - * @type string $base_path The base path for where all your variations are found. Although |
|
83 | - * the full path to your variation files should include '/variations/' in it, do not include the |
|
84 | - * 'variations/' in this. Required. |
|
85 | - * @type string $base_url The base url for where all your variations are found. See note |
|
86 | - * above about the 'variations/' string. Required. |
|
87 | - * } |
|
88 | - * } |
|
89 | - * |
|
90 | - * @throws EE_Error |
|
91 | - * @return void |
|
92 | - */ |
|
93 | - public static function register($variation_ref = null, $setup_args = array()) |
|
94 | - { |
|
24 | + /** |
|
25 | + * Used to register new variations |
|
26 | + * |
|
27 | + * Variations are attached to template packs and do not typically change any structural layout but merely tweak the |
|
28 | + * style of the layout. The most commonly known variation is css. CSS does not affect html structure just the |
|
29 | + * style of existing structure. |
|
30 | + * |
|
31 | + * It's important to remember that when variation files are loaded, the file structure looked for is: |
|
32 | + * '{$messenger}_{$messenger_variation_type}_{$variation_slug}.{$extension}'. |
|
33 | + * |
|
34 | + * - Every variation applies to specific messengers. That's why the variation file includes the messenger name |
|
35 | + * it. This ensures that if a template pack the variation is registered with supports multiple variations that |
|
36 | + * you can have the correct variation loaded. |
|
37 | + * - EE_messengers also implicitly define variation "types" which typically are the context in which a specific |
|
38 | + * variation is loaded. For instance the email messenger has: 'inline', which is the css added inline to the |
|
39 | + * email templates; 'preview', which is the same css only customized for when emails are previewed; and |
|
40 | + * 'wpeditor', which is the same css only customized so that it works with the wpeditor fields for templates to |
|
41 | + * give a accurate representation of the style in the wysiwyg editor. This means that for each variation, if |
|
42 | + * you want it to be accurately represented in various temlpate contexts you need to have that relevant |
|
43 | + * variation file available. |
|
44 | + * - $variation_slug is simply the variation slug for that variation. |
|
45 | + * - $extension = whatever the extension is for the variation used for the messenger calling it. In MOST cases |
|
46 | + * messenger variations are .css files. Note: if your file names are not formatted correctly then they will NOT |
|
47 | + * be loaded. The EE messages template pack system will fallback to corresponding default template pack for the |
|
48 | + * given messenger or as a last resort (i.e. no default variation for the given messenger) will not load any |
|
49 | + * variation (so the template pack would be unstyled) |
|
50 | + * |
|
51 | + * @see /core/libraries/messages/defaults/default/variations/* for example variation files for the email and html |
|
52 | + * messengers. |
|
53 | + * |
|
54 | + * @param string $variation_ref unique reference used to describe this variation registry. If |
|
55 | + * this ISN'T unique then this method will make it unique (and it |
|
56 | + * becomes harder to deregister). |
|
57 | + * @param array $setup_args { |
|
58 | + * an array of required values for registering the variations. |
|
59 | + * @type array $variations { |
|
60 | + * An array indexed by template_pack->dbref. and values are an array |
|
61 | + * indexed by messenger name and values are an array indexed by |
|
62 | + * message_type and values are an array indexed by variation_slug |
|
63 | + * and value is the localized label for the variation. Note this |
|
64 | + * api reserves the "default" variation name for the default |
|
65 | + * template pack so you can't register a default variation. Also, |
|
66 | + * try to use unique variation slugs to reference your variations |
|
67 | + * because this api checks if any existing varations are in place |
|
68 | + * with that name. If there are then subsequent variations for that |
|
69 | + * template pack with that same name will fail to register with a |
|
70 | + * persistent notice put up for the user. Required. |
|
71 | + * 'default' => array( |
|
72 | + * 'email' => array( |
|
73 | + * 'registration_approved' => array( |
|
74 | + * my_ee_addon_blue_lagoon' => __('Blue Lagoon', |
|
75 | + * 'text_domain'), |
|
76 | + * 'my_ee_addon_red_sunset' => __('Red Sunset', |
|
77 | + * 'text_domain') |
|
78 | + * ) |
|
79 | + * ) |
|
80 | + * ) |
|
81 | + * } |
|
82 | + * @type string $base_path The base path for where all your variations are found. Although |
|
83 | + * the full path to your variation files should include '/variations/' in it, do not include the |
|
84 | + * 'variations/' in this. Required. |
|
85 | + * @type string $base_url The base url for where all your variations are found. See note |
|
86 | + * above about the 'variations/' string. Required. |
|
87 | + * } |
|
88 | + * } |
|
89 | + * |
|
90 | + * @throws EE_Error |
|
91 | + * @return void |
|
92 | + */ |
|
93 | + public static function register($variation_ref = null, $setup_args = array()) |
|
94 | + { |
|
95 | 95 | |
96 | - // check for required params |
|
97 | - if (empty($variation_ref)) { |
|
98 | - throw new EE_Error( |
|
99 | - __( |
|
100 | - 'In order to register variations for a EE_Message_Template_Pack, you must include a value to reference the variations being registered', |
|
101 | - 'event_espresso' |
|
102 | - ) |
|
103 | - ); |
|
104 | - } |
|
96 | + // check for required params |
|
97 | + if (empty($variation_ref)) { |
|
98 | + throw new EE_Error( |
|
99 | + __( |
|
100 | + 'In order to register variations for a EE_Message_Template_Pack, you must include a value to reference the variations being registered', |
|
101 | + 'event_espresso' |
|
102 | + ) |
|
103 | + ); |
|
104 | + } |
|
105 | 105 | |
106 | - if (! is_array($setup_args) |
|
107 | - || empty($setup_args['variations']) |
|
108 | - || empty($setup_args['base_path']) |
|
109 | - || empty($setup_args['base_url']) |
|
110 | - ) { |
|
111 | - throw new EE_Error( |
|
112 | - __( |
|
113 | - 'In order to register variations for a EE_Message_Template_Pack, you must include an array containing the following keys: "variations", "base_path", "base_url", "extension"', |
|
114 | - 'event_espresso' |
|
115 | - ) |
|
116 | - ); |
|
117 | - } |
|
106 | + if (! is_array($setup_args) |
|
107 | + || empty($setup_args['variations']) |
|
108 | + || empty($setup_args['base_path']) |
|
109 | + || empty($setup_args['base_url']) |
|
110 | + ) { |
|
111 | + throw new EE_Error( |
|
112 | + __( |
|
113 | + 'In order to register variations for a EE_Message_Template_Pack, you must include an array containing the following keys: "variations", "base_path", "base_url", "extension"', |
|
114 | + 'event_espresso' |
|
115 | + ) |
|
116 | + ); |
|
117 | + } |
|
118 | 118 | |
119 | - // make sure we don't register twice |
|
120 | - if (isset(self::$_registry[ $variation_ref ])) { |
|
121 | - return; |
|
122 | - } |
|
119 | + // make sure we don't register twice |
|
120 | + if (isset(self::$_registry[ $variation_ref ])) { |
|
121 | + return; |
|
122 | + } |
|
123 | 123 | |
124 | - // make sure variation ref is unique. |
|
125 | - if (isset(self::$_registry[ $variation_ref ])) { |
|
126 | - $variation_ref = uniqid() . '_' . $variation_ref; |
|
127 | - } |
|
124 | + // make sure variation ref is unique. |
|
125 | + if (isset(self::$_registry[ $variation_ref ])) { |
|
126 | + $variation_ref = uniqid() . '_' . $variation_ref; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | |
130 | - // make sure this was called in the right place! |
|
131 | - if (! did_action('EE_Brewing_Regular___messages_caf') |
|
132 | - || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
133 | - ) { |
|
134 | - EE_Error::doing_it_wrong( |
|
135 | - __METHOD__, |
|
136 | - sprintf( |
|
137 | - __( |
|
138 | - 'Messages Templates Variations given the reference "%s" has been attempted to be registered with the EE Messages Template Pack System. It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.', |
|
139 | - 'event_espresso' |
|
140 | - ), |
|
141 | - $variation_ref |
|
142 | - ), |
|
143 | - '4.5.0' |
|
144 | - ); |
|
145 | - } |
|
130 | + // make sure this was called in the right place! |
|
131 | + if (! did_action('EE_Brewing_Regular___messages_caf') |
|
132 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
133 | + ) { |
|
134 | + EE_Error::doing_it_wrong( |
|
135 | + __METHOD__, |
|
136 | + sprintf( |
|
137 | + __( |
|
138 | + 'Messages Templates Variations given the reference "%s" has been attempted to be registered with the EE Messages Template Pack System. It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.', |
|
139 | + 'event_espresso' |
|
140 | + ), |
|
141 | + $variation_ref |
|
142 | + ), |
|
143 | + '4.5.0' |
|
144 | + ); |
|
145 | + } |
|
146 | 146 | |
147 | - // validate/sanitize incoming args. |
|
148 | - $validated = array( |
|
149 | - 'variations' => (array) $setup_args['variations'], |
|
150 | - 'base_path' => (string) $setup_args['base_path'], |
|
151 | - 'base_url' => (string) $setup_args['base_url'], |
|
152 | - ); |
|
147 | + // validate/sanitize incoming args. |
|
148 | + $validated = array( |
|
149 | + 'variations' => (array) $setup_args['variations'], |
|
150 | + 'base_path' => (string) $setup_args['base_path'], |
|
151 | + 'base_url' => (string) $setup_args['base_url'], |
|
152 | + ); |
|
153 | 153 | |
154 | 154 | |
155 | - // check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack. The former will throw an error. The latter will remove the conflicting variation name but still register the others and will add EE_Error notice. |
|
156 | - $validated = self::_verify_variations($variation_ref, $validated); |
|
157 | - self::$_registry[ $variation_ref ] = $validated; |
|
155 | + // check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack. The former will throw an error. The latter will remove the conflicting variation name but still register the others and will add EE_Error notice. |
|
156 | + $validated = self::_verify_variations($variation_ref, $validated); |
|
157 | + self::$_registry[ $variation_ref ] = $validated; |
|
158 | 158 | |
159 | - add_filter( |
|
160 | - 'FHEE__EE_Messages_Template_Pack__get_variations', |
|
161 | - array('EE_Register_Messages_Template_Variations', 'get_variations'), |
|
162 | - 10, |
|
163 | - 4 |
|
164 | - ); |
|
165 | - add_filter( |
|
166 | - 'FHEE__EE_Messages_Template_Pack__get_variation', |
|
167 | - array('EE_Register_Messages_Template_Variations', 'get_variation'), |
|
168 | - 10, |
|
169 | - 8 |
|
170 | - ); |
|
171 | - } |
|
159 | + add_filter( |
|
160 | + 'FHEE__EE_Messages_Template_Pack__get_variations', |
|
161 | + array('EE_Register_Messages_Template_Variations', 'get_variations'), |
|
162 | + 10, |
|
163 | + 4 |
|
164 | + ); |
|
165 | + add_filter( |
|
166 | + 'FHEE__EE_Messages_Template_Pack__get_variation', |
|
167 | + array('EE_Register_Messages_Template_Variations', 'get_variation'), |
|
168 | + 10, |
|
169 | + 8 |
|
170 | + ); |
|
171 | + } |
|
172 | 172 | |
173 | 173 | |
174 | - /** |
|
175 | - * Cycles through the variations registered and makes sure there are no reserved variations being registered which |
|
176 | - * throws an error. Also checks if there is already a |
|
177 | - * |
|
178 | - * @since 4.5.0 |
|
179 | - * |
|
180 | - * @param string $variation_ref the reference for the variations being registered |
|
181 | - * @param array $validated_variations The variations setup array that's being registered (and verified). |
|
182 | - * @throws EE_Error |
|
183 | - * @return bool |
|
184 | - */ |
|
185 | - private static function _verify_variations($variation_ref, $validated_variations) |
|
186 | - { |
|
187 | - foreach (self::$_registry as $variation_ref => $settings) { |
|
188 | - foreach ($settings['variations'] as $template_pack => $messenger) { |
|
189 | - foreach ($messenger as $all_variations) { |
|
190 | - if (isset($all_variations['default'])) { |
|
191 | - throw new EE_Error( |
|
192 | - sprintf( |
|
193 | - __( |
|
194 | - 'Variations registered through the EE_Register_Messages_Template_Variations api cannot override the default variation for the default template. Please check the code registering variations with this reference, "%s" and modify.', |
|
195 | - 'event_espresso' |
|
196 | - ), |
|
197 | - $variation_ref |
|
198 | - ) |
|
199 | - ); |
|
200 | - } |
|
201 | - } |
|
202 | - } |
|
203 | - } |
|
174 | + /** |
|
175 | + * Cycles through the variations registered and makes sure there are no reserved variations being registered which |
|
176 | + * throws an error. Also checks if there is already a |
|
177 | + * |
|
178 | + * @since 4.5.0 |
|
179 | + * |
|
180 | + * @param string $variation_ref the reference for the variations being registered |
|
181 | + * @param array $validated_variations The variations setup array that's being registered (and verified). |
|
182 | + * @throws EE_Error |
|
183 | + * @return bool |
|
184 | + */ |
|
185 | + private static function _verify_variations($variation_ref, $validated_variations) |
|
186 | + { |
|
187 | + foreach (self::$_registry as $variation_ref => $settings) { |
|
188 | + foreach ($settings['variations'] as $template_pack => $messenger) { |
|
189 | + foreach ($messenger as $all_variations) { |
|
190 | + if (isset($all_variations['default'])) { |
|
191 | + throw new EE_Error( |
|
192 | + sprintf( |
|
193 | + __( |
|
194 | + 'Variations registered through the EE_Register_Messages_Template_Variations api cannot override the default variation for the default template. Please check the code registering variations with this reference, "%s" and modify.', |
|
195 | + 'event_espresso' |
|
196 | + ), |
|
197 | + $variation_ref |
|
198 | + ) |
|
199 | + ); |
|
200 | + } |
|
201 | + } |
|
202 | + } |
|
203 | + } |
|
204 | 204 | |
205 | - // is there already a variation registered with a given variation slug? |
|
206 | - foreach ($validated_variations['variations'] as $template_pack => $messenger) { |
|
207 | - foreach ($messenger as $message_type => $variations) { |
|
208 | - foreach ($variations as $slug => $label) { |
|
209 | - foreach (self::$_registry as $registered_var => $reg_settings) { |
|
210 | - if (isset($reg_settings['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ])) { |
|
211 | - unset($validated_variations['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ]); |
|
212 | - EE_Error::add_error( |
|
213 | - sprintf( |
|
214 | - __( |
|
215 | - 'Unable to register the %s variation for the %s template pack with the %s messenger and %s message_type because a variation with this slug was already registered for this template pack and messenger and message type by an addon using this key %s.', |
|
216 | - 'event_espresso' |
|
217 | - ), |
|
218 | - $label, |
|
219 | - $template_pack, |
|
220 | - $messenger, |
|
221 | - $message_type, |
|
222 | - $registered_var |
|
223 | - ) |
|
224 | - ); |
|
225 | - } |
|
226 | - } |
|
227 | - } |
|
228 | - } |
|
229 | - } |
|
230 | - return $validated_variations; |
|
231 | - } |
|
205 | + // is there already a variation registered with a given variation slug? |
|
206 | + foreach ($validated_variations['variations'] as $template_pack => $messenger) { |
|
207 | + foreach ($messenger as $message_type => $variations) { |
|
208 | + foreach ($variations as $slug => $label) { |
|
209 | + foreach (self::$_registry as $registered_var => $reg_settings) { |
|
210 | + if (isset($reg_settings['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ])) { |
|
211 | + unset($validated_variations['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ]); |
|
212 | + EE_Error::add_error( |
|
213 | + sprintf( |
|
214 | + __( |
|
215 | + 'Unable to register the %s variation for the %s template pack with the %s messenger and %s message_type because a variation with this slug was already registered for this template pack and messenger and message type by an addon using this key %s.', |
|
216 | + 'event_espresso' |
|
217 | + ), |
|
218 | + $label, |
|
219 | + $template_pack, |
|
220 | + $messenger, |
|
221 | + $message_type, |
|
222 | + $registered_var |
|
223 | + ) |
|
224 | + ); |
|
225 | + } |
|
226 | + } |
|
227 | + } |
|
228 | + } |
|
229 | + } |
|
230 | + return $validated_variations; |
|
231 | + } |
|
232 | 232 | |
233 | 233 | |
234 | - /** |
|
235 | - * Callback for the FHEE__EE_Messages_Template_Pack__get_variation filter to ensure registered variations are used. |
|
236 | - * |
|
237 | - * @since 4.5.0 |
|
238 | - * |
|
239 | - * @param string $variation_path The path generated for the current variation |
|
240 | - * @param string $messenger The messenger the variation is for |
|
241 | - * @param string $message_type EE_message_type->name |
|
242 | - * @param string $type The type of variation being requested |
|
243 | - * @param string $variation The slug for the variation being requested |
|
244 | - * @param string $file_extension What the file extension is for the variation |
|
245 | - * @param bool $url Whether url or path is being returned. |
|
246 | - * @param EE_Messages_Template_Pack $template_pack |
|
247 | - * |
|
248 | - * @return string The path to the requested variation. |
|
249 | - */ |
|
250 | - public static function get_variation( |
|
251 | - $variation_path, |
|
252 | - $messenger, |
|
253 | - $message_type, |
|
254 | - $type, |
|
255 | - $variation, |
|
256 | - $file_extension, |
|
257 | - $url, |
|
258 | - EE_Messages_Template_Pack $template_pack |
|
259 | - ) { |
|
234 | + /** |
|
235 | + * Callback for the FHEE__EE_Messages_Template_Pack__get_variation filter to ensure registered variations are used. |
|
236 | + * |
|
237 | + * @since 4.5.0 |
|
238 | + * |
|
239 | + * @param string $variation_path The path generated for the current variation |
|
240 | + * @param string $messenger The messenger the variation is for |
|
241 | + * @param string $message_type EE_message_type->name |
|
242 | + * @param string $type The type of variation being requested |
|
243 | + * @param string $variation The slug for the variation being requested |
|
244 | + * @param string $file_extension What the file extension is for the variation |
|
245 | + * @param bool $url Whether url or path is being returned. |
|
246 | + * @param EE_Messages_Template_Pack $template_pack |
|
247 | + * |
|
248 | + * @return string The path to the requested variation. |
|
249 | + */ |
|
250 | + public static function get_variation( |
|
251 | + $variation_path, |
|
252 | + $messenger, |
|
253 | + $message_type, |
|
254 | + $type, |
|
255 | + $variation, |
|
256 | + $file_extension, |
|
257 | + $url, |
|
258 | + EE_Messages_Template_Pack $template_pack |
|
259 | + ) { |
|
260 | 260 | |
261 | - // so let's loop through our registered variations and then pull any details matching the request. |
|
262 | - foreach (self::$_registry as $registry_slug => $registry_settings) { |
|
263 | - $base = $url ? $registry_settings['base_url'] : $registry_settings['base_path']; |
|
264 | - $file_string = $messenger . '_' . $type . '_' . $variation . $file_extension; |
|
265 | - // see if this file exists |
|
266 | - if (is_readable($registry_settings['base_path'] . $file_string)) { |
|
267 | - return $base . $file_string; |
|
268 | - } |
|
269 | - } |
|
261 | + // so let's loop through our registered variations and then pull any details matching the request. |
|
262 | + foreach (self::$_registry as $registry_slug => $registry_settings) { |
|
263 | + $base = $url ? $registry_settings['base_url'] : $registry_settings['base_path']; |
|
264 | + $file_string = $messenger . '_' . $type . '_' . $variation . $file_extension; |
|
265 | + // see if this file exists |
|
266 | + if (is_readable($registry_settings['base_path'] . $file_string)) { |
|
267 | + return $base . $file_string; |
|
268 | + } |
|
269 | + } |
|
270 | 270 | |
271 | - // no match |
|
272 | - return $variation_path; |
|
273 | - } |
|
271 | + // no match |
|
272 | + return $variation_path; |
|
273 | + } |
|
274 | 274 | |
275 | 275 | |
276 | - /** |
|
277 | - * callback for the FHEE__EE_Messages_Template_Pack__get_variations filter. |
|
278 | - * |
|
279 | - * |
|
280 | - * @since 4.5.0 |
|
281 | - * |
|
282 | - * @param array $variations The original contents for the template pack variations property. |
|
283 | - * @see $_variation property definition in EE_Messages_Template_Pack |
|
284 | - * @param string $messenger The messenger requesting the variations. |
|
285 | - * @param EE_Messages_Template_Pack $template_pack |
|
286 | - * |
|
287 | - * @return array new variations array (or existing one if nothing registered) |
|
288 | - */ |
|
289 | - public static function get_variations( |
|
290 | - $variations, |
|
291 | - $messenger, |
|
292 | - $message_type, |
|
293 | - EE_Messages_Template_Pack $template_pack |
|
294 | - ) { |
|
295 | - // first let's check if we even have registered variations and get out early. |
|
296 | - if (empty(self::$_registry)) { |
|
297 | - return $variations; |
|
298 | - } |
|
276 | + /** |
|
277 | + * callback for the FHEE__EE_Messages_Template_Pack__get_variations filter. |
|
278 | + * |
|
279 | + * |
|
280 | + * @since 4.5.0 |
|
281 | + * |
|
282 | + * @param array $variations The original contents for the template pack variations property. |
|
283 | + * @see $_variation property definition in EE_Messages_Template_Pack |
|
284 | + * @param string $messenger The messenger requesting the variations. |
|
285 | + * @param EE_Messages_Template_Pack $template_pack |
|
286 | + * |
|
287 | + * @return array new variations array (or existing one if nothing registered) |
|
288 | + */ |
|
289 | + public static function get_variations( |
|
290 | + $variations, |
|
291 | + $messenger, |
|
292 | + $message_type, |
|
293 | + EE_Messages_Template_Pack $template_pack |
|
294 | + ) { |
|
295 | + // first let's check if we even have registered variations and get out early. |
|
296 | + if (empty(self::$_registry)) { |
|
297 | + return $variations; |
|
298 | + } |
|
299 | 299 | |
300 | - // do we have any new variations for the given messenger, $message_type, and template packs |
|
301 | - foreach (self::$_registry as $registry_slug => $registry_settings) { |
|
302 | - // allow for different conditions. |
|
303 | - if (empty($messenger)) { |
|
304 | - $variations = array_merge($registry_settings['variations'], $variations); |
|
305 | - } elseif (! empty($messenger) && empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ])) { |
|
306 | - $variations = array_merge( |
|
307 | - $registry_settings['variations'][ $template_pack->dbref ][ $messenger ], |
|
308 | - $variations |
|
309 | - ); |
|
310 | - } elseif (! empty($messenger) && ! empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ])) { |
|
311 | - $variations = array_merge( |
|
312 | - $registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ], |
|
313 | - $variations |
|
314 | - ); |
|
315 | - } |
|
316 | - } |
|
317 | - return $variations; |
|
318 | - } |
|
300 | + // do we have any new variations for the given messenger, $message_type, and template packs |
|
301 | + foreach (self::$_registry as $registry_slug => $registry_settings) { |
|
302 | + // allow for different conditions. |
|
303 | + if (empty($messenger)) { |
|
304 | + $variations = array_merge($registry_settings['variations'], $variations); |
|
305 | + } elseif (! empty($messenger) && empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ])) { |
|
306 | + $variations = array_merge( |
|
307 | + $registry_settings['variations'][ $template_pack->dbref ][ $messenger ], |
|
308 | + $variations |
|
309 | + ); |
|
310 | + } elseif (! empty($messenger) && ! empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ])) { |
|
311 | + $variations = array_merge( |
|
312 | + $registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ], |
|
313 | + $variations |
|
314 | + ); |
|
315 | + } |
|
316 | + } |
|
317 | + return $variations; |
|
318 | + } |
|
319 | 319 | |
320 | 320 | |
321 | - /** |
|
322 | - * This deregisters a variation set that was previously registered with the given slug. |
|
323 | - * |
|
324 | - * @since 4.5.0 |
|
325 | - * |
|
326 | - * @param string $variation_ref The name for the variation set that was previously registered. |
|
327 | - * |
|
328 | - * @return void |
|
329 | - */ |
|
330 | - public static function deregister($variation_ref = null) |
|
331 | - { |
|
332 | - if (! empty(self::$_registry[ $variation_ref ])) { |
|
333 | - unset(self::$_registry[ $variation_ref ]); |
|
334 | - } |
|
335 | - } |
|
321 | + /** |
|
322 | + * This deregisters a variation set that was previously registered with the given slug. |
|
323 | + * |
|
324 | + * @since 4.5.0 |
|
325 | + * |
|
326 | + * @param string $variation_ref The name for the variation set that was previously registered. |
|
327 | + * |
|
328 | + * @return void |
|
329 | + */ |
|
330 | + public static function deregister($variation_ref = null) |
|
331 | + { |
|
332 | + if (! empty(self::$_registry[ $variation_ref ])) { |
|
333 | + unset(self::$_registry[ $variation_ref ]); |
|
334 | + } |
|
335 | + } |
|
336 | 336 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | ); |
104 | 104 | } |
105 | 105 | |
106 | - if (! is_array($setup_args) |
|
106 | + if ( ! is_array($setup_args) |
|
107 | 107 | || empty($setup_args['variations']) |
108 | 108 | || empty($setup_args['base_path']) |
109 | 109 | || empty($setup_args['base_url']) |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | // make sure we don't register twice |
120 | - if (isset(self::$_registry[ $variation_ref ])) { |
|
120 | + if (isset(self::$_registry[$variation_ref])) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | 123 | |
124 | 124 | // make sure variation ref is unique. |
125 | - if (isset(self::$_registry[ $variation_ref ])) { |
|
126 | - $variation_ref = uniqid() . '_' . $variation_ref; |
|
125 | + if (isset(self::$_registry[$variation_ref])) { |
|
126 | + $variation_ref = uniqid().'_'.$variation_ref; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | 130 | // make sure this was called in the right place! |
131 | - if (! did_action('EE_Brewing_Regular___messages_caf') |
|
131 | + if ( ! did_action('EE_Brewing_Regular___messages_caf') |
|
132 | 132 | || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
133 | 133 | ) { |
134 | 134 | EE_Error::doing_it_wrong( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | // check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack. The former will throw an error. The latter will remove the conflicting variation name but still register the others and will add EE_Error notice. |
156 | 156 | $validated = self::_verify_variations($variation_ref, $validated); |
157 | - self::$_registry[ $variation_ref ] = $validated; |
|
157 | + self::$_registry[$variation_ref] = $validated; |
|
158 | 158 | |
159 | 159 | add_filter( |
160 | 160 | 'FHEE__EE_Messages_Template_Pack__get_variations', |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | foreach ($messenger as $message_type => $variations) { |
208 | 208 | foreach ($variations as $slug => $label) { |
209 | 209 | foreach (self::$_registry as $registered_var => $reg_settings) { |
210 | - if (isset($reg_settings['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ])) { |
|
211 | - unset($validated_variations['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ]); |
|
210 | + if (isset($reg_settings['variations'][$template_pack][$messenger][$message_type][$slug])) { |
|
211 | + unset($validated_variations['variations'][$template_pack][$messenger][$message_type][$slug]); |
|
212 | 212 | EE_Error::add_error( |
213 | 213 | sprintf( |
214 | 214 | __( |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | // so let's loop through our registered variations and then pull any details matching the request. |
262 | 262 | foreach (self::$_registry as $registry_slug => $registry_settings) { |
263 | 263 | $base = $url ? $registry_settings['base_url'] : $registry_settings['base_path']; |
264 | - $file_string = $messenger . '_' . $type . '_' . $variation . $file_extension; |
|
264 | + $file_string = $messenger.'_'.$type.'_'.$variation.$file_extension; |
|
265 | 265 | // see if this file exists |
266 | - if (is_readable($registry_settings['base_path'] . $file_string)) { |
|
267 | - return $base . $file_string; |
|
266 | + if (is_readable($registry_settings['base_path'].$file_string)) { |
|
267 | + return $base.$file_string; |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
@@ -302,14 +302,14 @@ discard block |
||
302 | 302 | // allow for different conditions. |
303 | 303 | if (empty($messenger)) { |
304 | 304 | $variations = array_merge($registry_settings['variations'], $variations); |
305 | - } elseif (! empty($messenger) && empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ])) { |
|
305 | + } elseif ( ! empty($messenger) && empty($message_type) && ! empty($registry_settings['variations'][$template_pack->dbref][$messenger])) { |
|
306 | 306 | $variations = array_merge( |
307 | - $registry_settings['variations'][ $template_pack->dbref ][ $messenger ], |
|
307 | + $registry_settings['variations'][$template_pack->dbref][$messenger], |
|
308 | 308 | $variations |
309 | 309 | ); |
310 | - } elseif (! empty($messenger) && ! empty($message_type) && ! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ])) { |
|
310 | + } elseif ( ! empty($messenger) && ! empty($message_type) && ! empty($registry_settings['variations'][$template_pack->dbref][$messenger][$message_type])) { |
|
311 | 311 | $variations = array_merge( |
312 | - $registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ], |
|
312 | + $registry_settings['variations'][$template_pack->dbref][$messenger][$message_type], |
|
313 | 313 | $variations |
314 | 314 | ); |
315 | 315 | } |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | */ |
330 | 330 | public static function deregister($variation_ref = null) |
331 | 331 | { |
332 | - if (! empty(self::$_registry[ $variation_ref ])) { |
|
333 | - unset(self::$_registry[ $variation_ref ]); |
|
332 | + if ( ! empty(self::$_registry[$variation_ref])) { |
|
333 | + unset(self::$_registry[$variation_ref]); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | } |
@@ -12,116 +12,116 @@ |
||
12 | 12 | class EE_Register_Config implements EEI_Plugin_API |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Holds registered EE_Config items |
|
17 | - * |
|
18 | - * @var array |
|
19 | - */ |
|
20 | - protected static $_ee_config_registry = array(); |
|
15 | + /** |
|
16 | + * Holds registered EE_Config items |
|
17 | + * |
|
18 | + * @var array |
|
19 | + */ |
|
20 | + protected static $_ee_config_registry = array(); |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * Handles registering the new config with the EE_Config::instance()->addons property |
|
25 | - * |
|
26 | - * @since 4.3.0 |
|
27 | - * @throws EE_Error |
|
28 | - * |
|
29 | - * @param string $config_class The name of the Config class being registered. |
|
30 | - * Note this class must extend EE_Config Base and must have |
|
31 | - * already been registered with an autoloader. |
|
32 | - * @param array $setup_args { |
|
33 | - * |
|
34 | - * @type string $config_name Optional. by default the new config will be registered to |
|
35 | - * EE_Config::instance()->addons->{config_class}, but supplying a "config_name" will set the property name |
|
36 | - * that this variable is accessible by. ie: EE_Config::instance()->addons->{config_name} |
|
37 | - * } |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public static function register($config_class = null, $setup_args = array()) |
|
41 | - { |
|
23 | + /** |
|
24 | + * Handles registering the new config with the EE_Config::instance()->addons property |
|
25 | + * |
|
26 | + * @since 4.3.0 |
|
27 | + * @throws EE_Error |
|
28 | + * |
|
29 | + * @param string $config_class The name of the Config class being registered. |
|
30 | + * Note this class must extend EE_Config Base and must have |
|
31 | + * already been registered with an autoloader. |
|
32 | + * @param array $setup_args { |
|
33 | + * |
|
34 | + * @type string $config_name Optional. by default the new config will be registered to |
|
35 | + * EE_Config::instance()->addons->{config_class}, but supplying a "config_name" will set the property name |
|
36 | + * that this variable is accessible by. ie: EE_Config::instance()->addons->{config_name} |
|
37 | + * } |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public static function register($config_class = null, $setup_args = array()) |
|
41 | + { |
|
42 | 42 | |
43 | - $setup_args['config_name'] = isset($setup_args['config_name']) && ! empty($setup_args['config_name']) |
|
44 | - ? $setup_args['config_name'] : $config_class; |
|
45 | - $setup_args['config_section'] = isset($setup_args['config_section']) && ! empty($setup_args['config_section']) |
|
46 | - ? $setup_args['config_section'] : 'addons'; |
|
43 | + $setup_args['config_name'] = isset($setup_args['config_name']) && ! empty($setup_args['config_name']) |
|
44 | + ? $setup_args['config_name'] : $config_class; |
|
45 | + $setup_args['config_section'] = isset($setup_args['config_section']) && ! empty($setup_args['config_section']) |
|
46 | + ? $setup_args['config_section'] : 'addons'; |
|
47 | 47 | |
48 | - // required fields MUST be present, so let's make sure they are. |
|
49 | - if (empty($config_class) || ! is_array($setup_args) || empty($setup_args['config_name'])) { |
|
50 | - throw new EE_Error( |
|
51 | - __( |
|
52 | - 'In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', |
|
53 | - 'event_espresso' |
|
54 | - ) |
|
55 | - ); |
|
56 | - } |
|
48 | + // required fields MUST be present, so let's make sure they are. |
|
49 | + if (empty($config_class) || ! is_array($setup_args) || empty($setup_args['config_name'])) { |
|
50 | + throw new EE_Error( |
|
51 | + __( |
|
52 | + 'In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', |
|
53 | + 'event_espresso' |
|
54 | + ) |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - // make sure we don't register twice |
|
59 | - if (isset(self::$_ee_config_registry[ $config_class ])) { |
|
60 | - return; |
|
61 | - } |
|
58 | + // make sure we don't register twice |
|
59 | + if (isset(self::$_ee_config_registry[ $config_class ])) { |
|
60 | + return; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - // first find out if this happened too late. |
|
65 | - if (did_action('AHEE__EE_System__load_core_configuration__begin')) { |
|
66 | - EE_Error::doing_it_wrong( |
|
67 | - __METHOD__, |
|
68 | - sprintf( |
|
69 | - __( |
|
70 | - 'An attempt to register "%s" as an EE_Config object has failed because it was not registered at the correct hookpoint. Please register before the "AHEE__EE_System__load_core_configuration__begin" hook has fired', |
|
71 | - 'event_espresso' |
|
72 | - ), |
|
73 | - $setup_args['config_name'] |
|
74 | - ), |
|
75 | - '4.3' |
|
76 | - ); |
|
77 | - } |
|
78 | - // add incoming stuff to our registry property |
|
79 | - self::$_ee_config_registry[ $config_class ] = array( |
|
80 | - 'section' => $setup_args['config_section'], |
|
81 | - 'name' => $setup_args['config_name'], |
|
82 | - ); |
|
64 | + // first find out if this happened too late. |
|
65 | + if (did_action('AHEE__EE_System__load_core_configuration__begin')) { |
|
66 | + EE_Error::doing_it_wrong( |
|
67 | + __METHOD__, |
|
68 | + sprintf( |
|
69 | + __( |
|
70 | + 'An attempt to register "%s" as an EE_Config object has failed because it was not registered at the correct hookpoint. Please register before the "AHEE__EE_System__load_core_configuration__begin" hook has fired', |
|
71 | + 'event_espresso' |
|
72 | + ), |
|
73 | + $setup_args['config_name'] |
|
74 | + ), |
|
75 | + '4.3' |
|
76 | + ); |
|
77 | + } |
|
78 | + // add incoming stuff to our registry property |
|
79 | + self::$_ee_config_registry[ $config_class ] = array( |
|
80 | + 'section' => $setup_args['config_section'], |
|
81 | + 'name' => $setup_args['config_name'], |
|
82 | + ); |
|
83 | 83 | |
84 | - add_action('AHEE__EE_Config___load_core_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
85 | - add_action('AHEE__EE_Config__update_espresso_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
86 | - } |
|
84 | + add_action('AHEE__EE_Config___load_core_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
85 | + add_action('AHEE__EE_Config__update_espresso_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * Callback for the AHEE__EE_Config___load_core_config__end hook. |
|
91 | - * basically just calls EE_Config->get_config() which will take care of loading or creating our config object for us |
|
92 | - * |
|
93 | - * @since 4.3.0 |
|
94 | - * @throws EE_Error |
|
95 | - * @param \EE_Config $EE_Config |
|
96 | - * @return \StdClass |
|
97 | - */ |
|
98 | - public static function set_config(EE_Config $EE_Config) |
|
99 | - { |
|
100 | - foreach (self::$_ee_config_registry as $config_class => $settings) { |
|
101 | - // first some validation of our incoming class_name. We'll throw an error early if its' not registered correctly |
|
102 | - if (! class_exists($config_class)) { |
|
103 | - throw new EE_Error( |
|
104 | - sprintf( |
|
105 | - __( |
|
106 | - 'The "%s" config class can not be registered with EE_Config because it does not exist. Verify that an autoloader has been set for this class', |
|
107 | - 'event_espresso' |
|
108 | - ), |
|
109 | - $config_class |
|
110 | - ) |
|
111 | - ); |
|
112 | - } |
|
113 | - $EE_Config->get_config($settings['section'], $settings['name'], $config_class); |
|
114 | - } |
|
115 | - } |
|
89 | + /** |
|
90 | + * Callback for the AHEE__EE_Config___load_core_config__end hook. |
|
91 | + * basically just calls EE_Config->get_config() which will take care of loading or creating our config object for us |
|
92 | + * |
|
93 | + * @since 4.3.0 |
|
94 | + * @throws EE_Error |
|
95 | + * @param \EE_Config $EE_Config |
|
96 | + * @return \StdClass |
|
97 | + */ |
|
98 | + public static function set_config(EE_Config $EE_Config) |
|
99 | + { |
|
100 | + foreach (self::$_ee_config_registry as $config_class => $settings) { |
|
101 | + // first some validation of our incoming class_name. We'll throw an error early if its' not registered correctly |
|
102 | + if (! class_exists($config_class)) { |
|
103 | + throw new EE_Error( |
|
104 | + sprintf( |
|
105 | + __( |
|
106 | + 'The "%s" config class can not be registered with EE_Config because it does not exist. Verify that an autoloader has been set for this class', |
|
107 | + 'event_espresso' |
|
108 | + ), |
|
109 | + $config_class |
|
110 | + ) |
|
111 | + ); |
|
112 | + } |
|
113 | + $EE_Config->get_config($settings['section'], $settings['name'], $config_class); |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | - /** |
|
119 | - * @param mixed $config_class_name |
|
120 | - */ |
|
121 | - public static function deregister($config_class_name = null) |
|
122 | - { |
|
123 | - if (! empty(self::$_ee_config_registry[ $config_class_name ])) { |
|
124 | - unset(self::$_ee_config_registry[ $config_class_name ]); |
|
125 | - } |
|
126 | - } |
|
118 | + /** |
|
119 | + * @param mixed $config_class_name |
|
120 | + */ |
|
121 | + public static function deregister($config_class_name = null) |
|
122 | + { |
|
123 | + if (! empty(self::$_ee_config_registry[ $config_class_name ])) { |
|
124 | + unset(self::$_ee_config_registry[ $config_class_name ]); |
|
125 | + } |
|
126 | + } |
|
127 | 127 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | // make sure we don't register twice |
59 | - if (isset(self::$_ee_config_registry[ $config_class ])) { |
|
59 | + if (isset(self::$_ee_config_registry[$config_class])) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ); |
77 | 77 | } |
78 | 78 | // add incoming stuff to our registry property |
79 | - self::$_ee_config_registry[ $config_class ] = array( |
|
79 | + self::$_ee_config_registry[$config_class] = array( |
|
80 | 80 | 'section' => $setup_args['config_section'], |
81 | 81 | 'name' => $setup_args['config_name'], |
82 | 82 | ); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | foreach (self::$_ee_config_registry as $config_class => $settings) { |
101 | 101 | // first some validation of our incoming class_name. We'll throw an error early if its' not registered correctly |
102 | - if (! class_exists($config_class)) { |
|
102 | + if ( ! class_exists($config_class)) { |
|
103 | 103 | throw new EE_Error( |
104 | 104 | sprintf( |
105 | 105 | __( |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public static function deregister($config_class_name = null) |
122 | 122 | { |
123 | - if (! empty(self::$_ee_config_registry[ $config_class_name ])) { |
|
124 | - unset(self::$_ee_config_registry[ $config_class_name ]); |
|
123 | + if ( ! empty(self::$_ee_config_registry[$config_class_name])) { |
|
124 | + unset(self::$_ee_config_registry[$config_class_name]); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
@@ -13,216 +13,216 @@ |
||
13 | 13 | class EE_Register_Capabilities implements EEI_Plugin_API |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Holds the settings for a specific registration. |
|
18 | - * |
|
19 | - * @var array |
|
20 | - */ |
|
21 | - protected static $_registry = array(); |
|
16 | + /** |
|
17 | + * Holds the settings for a specific registration. |
|
18 | + * |
|
19 | + * @var array |
|
20 | + */ |
|
21 | + protected static $_registry = array(); |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * Used to register capability items with EE core. |
|
26 | - * |
|
27 | - * @since 4.5.0 |
|
28 | - * @param string $cap_reference usually will be a class name |
|
29 | - * that references capability |
|
30 | - * related items setup for |
|
31 | - * something. |
|
32 | - * @param array $setup_args { |
|
33 | - * An array of items related to |
|
34 | - * registering capabilities. |
|
35 | - * @type array $capabilities An array mapping capability |
|
36 | - * strings to core WP Role. |
|
37 | - * Something like: array( |
|
38 | - * 'administrator' => array( |
|
39 | - * 'read_cap', 'edit_cap', |
|
40 | - * 'delete_cap'), |
|
41 | - * 'author' => |
|
42 | - * array( 'read_cap' ) |
|
43 | - * ). |
|
44 | - * @type array $capability_maps EE_Meta_Capability_Map[] |
|
45 | - * @see EE_Capabilities.php for php docs on these objects. |
|
46 | - * Should be indexed by the |
|
47 | - * classname for the capability |
|
48 | - * map and values representing |
|
49 | - * the arguments for the map. |
|
50 | - * } |
|
51 | - * @throws EE_Error |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public static function register($cap_reference = null, $setup_args = array()) |
|
55 | - { |
|
56 | - // required fields MUST be present, so let's make sure they are. |
|
57 | - if ($cap_reference === null || ! is_array($setup_args) || empty($setup_args['capabilities'])) { |
|
58 | - throw new EE_Error( |
|
59 | - __( |
|
60 | - 'In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', |
|
61 | - 'event_espresso' |
|
62 | - ) |
|
63 | - ); |
|
64 | - } |
|
65 | - // make sure we don't register twice |
|
66 | - if (isset(self::$_registry[ $cap_reference ])) { |
|
67 | - return; |
|
68 | - } |
|
69 | - // make sure this is not registered too late or too early. |
|
70 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
71 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
72 | - ) { |
|
73 | - EE_Error::doing_it_wrong( |
|
74 | - __METHOD__, |
|
75 | - sprintf( |
|
76 | - __( |
|
77 | - '%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', |
|
78 | - 'event_espresso' |
|
79 | - ), |
|
80 | - $cap_reference |
|
81 | - ), |
|
82 | - '4.5.0' |
|
83 | - ); |
|
84 | - } |
|
85 | - // some preliminary sanitization and setting to the $_registry property |
|
86 | - self::$_registry[ $cap_reference ] = array( |
|
87 | - 'caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) |
|
88 | - ? $setup_args['capabilities'] |
|
89 | - : array(), |
|
90 | - 'cap_maps' => isset($setup_args['capability_maps']) |
|
91 | - ? $setup_args['capability_maps'] |
|
92 | - : array(), |
|
93 | - ); |
|
94 | - // set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once) |
|
95 | - add_filter( |
|
96 | - 'FHEE__EE_Capabilities__addCaps__capabilities_to_add', |
|
97 | - array('EE_Register_Capabilities', 'register_capabilities') |
|
98 | - ); |
|
99 | - // add filter for cap maps |
|
100 | - add_filter( |
|
101 | - 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', |
|
102 | - array('EE_Register_Capabilities', 'register_cap_maps') |
|
103 | - ); |
|
104 | - } |
|
24 | + /** |
|
25 | + * Used to register capability items with EE core. |
|
26 | + * |
|
27 | + * @since 4.5.0 |
|
28 | + * @param string $cap_reference usually will be a class name |
|
29 | + * that references capability |
|
30 | + * related items setup for |
|
31 | + * something. |
|
32 | + * @param array $setup_args { |
|
33 | + * An array of items related to |
|
34 | + * registering capabilities. |
|
35 | + * @type array $capabilities An array mapping capability |
|
36 | + * strings to core WP Role. |
|
37 | + * Something like: array( |
|
38 | + * 'administrator' => array( |
|
39 | + * 'read_cap', 'edit_cap', |
|
40 | + * 'delete_cap'), |
|
41 | + * 'author' => |
|
42 | + * array( 'read_cap' ) |
|
43 | + * ). |
|
44 | + * @type array $capability_maps EE_Meta_Capability_Map[] |
|
45 | + * @see EE_Capabilities.php for php docs on these objects. |
|
46 | + * Should be indexed by the |
|
47 | + * classname for the capability |
|
48 | + * map and values representing |
|
49 | + * the arguments for the map. |
|
50 | + * } |
|
51 | + * @throws EE_Error |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public static function register($cap_reference = null, $setup_args = array()) |
|
55 | + { |
|
56 | + // required fields MUST be present, so let's make sure they are. |
|
57 | + if ($cap_reference === null || ! is_array($setup_args) || empty($setup_args['capabilities'])) { |
|
58 | + throw new EE_Error( |
|
59 | + __( |
|
60 | + 'In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', |
|
61 | + 'event_espresso' |
|
62 | + ) |
|
63 | + ); |
|
64 | + } |
|
65 | + // make sure we don't register twice |
|
66 | + if (isset(self::$_registry[ $cap_reference ])) { |
|
67 | + return; |
|
68 | + } |
|
69 | + // make sure this is not registered too late or too early. |
|
70 | + if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
71 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
72 | + ) { |
|
73 | + EE_Error::doing_it_wrong( |
|
74 | + __METHOD__, |
|
75 | + sprintf( |
|
76 | + __( |
|
77 | + '%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', |
|
78 | + 'event_espresso' |
|
79 | + ), |
|
80 | + $cap_reference |
|
81 | + ), |
|
82 | + '4.5.0' |
|
83 | + ); |
|
84 | + } |
|
85 | + // some preliminary sanitization and setting to the $_registry property |
|
86 | + self::$_registry[ $cap_reference ] = array( |
|
87 | + 'caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) |
|
88 | + ? $setup_args['capabilities'] |
|
89 | + : array(), |
|
90 | + 'cap_maps' => isset($setup_args['capability_maps']) |
|
91 | + ? $setup_args['capability_maps'] |
|
92 | + : array(), |
|
93 | + ); |
|
94 | + // set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once) |
|
95 | + add_filter( |
|
96 | + 'FHEE__EE_Capabilities__addCaps__capabilities_to_add', |
|
97 | + array('EE_Register_Capabilities', 'register_capabilities') |
|
98 | + ); |
|
99 | + // add filter for cap maps |
|
100 | + add_filter( |
|
101 | + 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', |
|
102 | + array('EE_Register_Capabilities', 'register_cap_maps') |
|
103 | + ); |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - /** |
|
108 | - * callback for FHEE__EE_Capabilities__init_caps_map__caps filter. |
|
109 | - * Takes care of registering additional capabilities to the caps map. Note, that this also on the initial |
|
110 | - * registration ensures that new capabilities are added to existing roles. |
|
111 | - * |
|
112 | - * @param array $incoming_caps The original caps map. |
|
113 | - * @return array merged in new caps. |
|
114 | - */ |
|
115 | - public static function register_capabilities($incoming_caps) |
|
116 | - { |
|
117 | - foreach (self::$_registry as $cap_reference => $caps_and_cap_map) { |
|
118 | - $incoming_caps = array_merge_recursive($incoming_caps, $caps_and_cap_map['caps']); |
|
119 | - } |
|
120 | - return $incoming_caps; |
|
121 | - } |
|
107 | + /** |
|
108 | + * callback for FHEE__EE_Capabilities__init_caps_map__caps filter. |
|
109 | + * Takes care of registering additional capabilities to the caps map. Note, that this also on the initial |
|
110 | + * registration ensures that new capabilities are added to existing roles. |
|
111 | + * |
|
112 | + * @param array $incoming_caps The original caps map. |
|
113 | + * @return array merged in new caps. |
|
114 | + */ |
|
115 | + public static function register_capabilities($incoming_caps) |
|
116 | + { |
|
117 | + foreach (self::$_registry as $cap_reference => $caps_and_cap_map) { |
|
118 | + $incoming_caps = array_merge_recursive($incoming_caps, $caps_and_cap_map['caps']); |
|
119 | + } |
|
120 | + return $incoming_caps; |
|
121 | + } |
|
122 | 122 | |
123 | 123 | |
124 | - /** |
|
125 | - * Callback for the 'FHEE__EE_Capabilities___set_meta_caps__meta_caps' filter which registers an array of |
|
126 | - * capability maps for the WP meta_caps filter called in EE_Capabilities. |
|
127 | - * |
|
128 | - * @since 4.5.0 |
|
129 | - * @param EE_Meta_Capability_Map[] $cap_maps The existing cap maps array. |
|
130 | - * @return EE_Meta_Capability_Map[] |
|
131 | - * @throws EE_Error |
|
132 | - */ |
|
133 | - public static function register_cap_maps($cap_maps) |
|
134 | - { |
|
135 | - // loop through and instantiate cap maps. |
|
136 | - foreach (self::$_registry as $cap_reference => $setup) { |
|
137 | - if (! isset($setup['cap_maps'])) { |
|
138 | - continue; |
|
139 | - } |
|
140 | - foreach ($setup['cap_maps'] as $cap_class => $args) { |
|
124 | + /** |
|
125 | + * Callback for the 'FHEE__EE_Capabilities___set_meta_caps__meta_caps' filter which registers an array of |
|
126 | + * capability maps for the WP meta_caps filter called in EE_Capabilities. |
|
127 | + * |
|
128 | + * @since 4.5.0 |
|
129 | + * @param EE_Meta_Capability_Map[] $cap_maps The existing cap maps array. |
|
130 | + * @return EE_Meta_Capability_Map[] |
|
131 | + * @throws EE_Error |
|
132 | + */ |
|
133 | + public static function register_cap_maps($cap_maps) |
|
134 | + { |
|
135 | + // loop through and instantiate cap maps. |
|
136 | + foreach (self::$_registry as $cap_reference => $setup) { |
|
137 | + if (! isset($setup['cap_maps'])) { |
|
138 | + continue; |
|
139 | + } |
|
140 | + foreach ($setup['cap_maps'] as $cap_class => $args) { |
|
141 | 141 | |
142 | - /** |
|
143 | - * account for cases where capability maps may be indexed |
|
144 | - * numerically to allow for the same map class to be utilized |
|
145 | - * In those cases, maps will be setup in an array like: |
|
146 | - * array( |
|
147 | - * 0 => array( 'EE_Meta_Capability' => array( |
|
148 | - * 'ee_edit_cap', array( 'Object_Name', |
|
149 | - * 'ee_edit_published_cap', |
|
150 | - * 'ee_edit_others_cap', 'ee_edit_private_cap' ) |
|
151 | - * ) ) |
|
152 | - * 1 => ... |
|
153 | - * ) |
|
154 | - * instead of: |
|
155 | - * array( |
|
156 | - * 'EE_Meta_Capability' => array( |
|
157 | - * 'ee_edit_cap', array( 'Object_Name', |
|
158 | - * 'ee_edit_published_cap', |
|
159 | - * 'ee_edit_others_cap', 'ee_edit_private_cap' ) |
|
160 | - * ), |
|
161 | - * ... |
|
162 | - * ) |
|
163 | - */ |
|
164 | - if (is_numeric($cap_class)) { |
|
165 | - $cap_class = key($args); |
|
166 | - $args = $args[ $cap_class ]; |
|
167 | - } |
|
142 | + /** |
|
143 | + * account for cases where capability maps may be indexed |
|
144 | + * numerically to allow for the same map class to be utilized |
|
145 | + * In those cases, maps will be setup in an array like: |
|
146 | + * array( |
|
147 | + * 0 => array( 'EE_Meta_Capability' => array( |
|
148 | + * 'ee_edit_cap', array( 'Object_Name', |
|
149 | + * 'ee_edit_published_cap', |
|
150 | + * 'ee_edit_others_cap', 'ee_edit_private_cap' ) |
|
151 | + * ) ) |
|
152 | + * 1 => ... |
|
153 | + * ) |
|
154 | + * instead of: |
|
155 | + * array( |
|
156 | + * 'EE_Meta_Capability' => array( |
|
157 | + * 'ee_edit_cap', array( 'Object_Name', |
|
158 | + * 'ee_edit_published_cap', |
|
159 | + * 'ee_edit_others_cap', 'ee_edit_private_cap' ) |
|
160 | + * ), |
|
161 | + * ... |
|
162 | + * ) |
|
163 | + */ |
|
164 | + if (is_numeric($cap_class)) { |
|
165 | + $cap_class = key($args); |
|
166 | + $args = $args[ $cap_class ]; |
|
167 | + } |
|
168 | 168 | |
169 | - if (! class_exists($cap_class)) { |
|
170 | - throw new EE_Error( |
|
171 | - sprintf( |
|
172 | - __( |
|
173 | - 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments', |
|
174 | - 'event_espresso' |
|
175 | - ), |
|
176 | - $cap_reference |
|
177 | - ) |
|
178 | - ); |
|
179 | - } |
|
169 | + if (! class_exists($cap_class)) { |
|
170 | + throw new EE_Error( |
|
171 | + sprintf( |
|
172 | + __( |
|
173 | + 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments', |
|
174 | + 'event_espresso' |
|
175 | + ), |
|
176 | + $cap_reference |
|
177 | + ) |
|
178 | + ); |
|
179 | + } |
|
180 | 180 | |
181 | - if (count($args) !== 2) { |
|
182 | - throw new EE_Error( |
|
183 | - sprintf( |
|
184 | - __( |
|
185 | - 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments. The array should have two values the first being a string and the second an array.', |
|
186 | - 'event_espresso' |
|
187 | - ), |
|
188 | - $cap_reference |
|
189 | - ) |
|
190 | - ); |
|
191 | - } |
|
192 | - $cap_maps[] = new $cap_class($args[0], $args[1]); |
|
193 | - } |
|
194 | - } |
|
195 | - return $cap_maps; |
|
196 | - } |
|
181 | + if (count($args) !== 2) { |
|
182 | + throw new EE_Error( |
|
183 | + sprintf( |
|
184 | + __( |
|
185 | + 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments. The array should have two values the first being a string and the second an array.', |
|
186 | + 'event_espresso' |
|
187 | + ), |
|
188 | + $cap_reference |
|
189 | + ) |
|
190 | + ); |
|
191 | + } |
|
192 | + $cap_maps[] = new $cap_class($args[0], $args[1]); |
|
193 | + } |
|
194 | + } |
|
195 | + return $cap_maps; |
|
196 | + } |
|
197 | 197 | |
198 | 198 | |
199 | - /** |
|
200 | - * @param string $cap_reference |
|
201 | - * @throws EE_Error |
|
202 | - * @throws \InvalidArgumentException |
|
203 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
204 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
205 | - */ |
|
206 | - public static function deregister($cap_reference = '') |
|
207 | - { |
|
208 | - if (! empty(self::$_registry[ $cap_reference ])) { |
|
209 | - if (! empty(self::$_registry[ $cap_reference ]['caps'])) { |
|
210 | - // if it's too early to remove capabilities, wait to do this until core is loaded and ready |
|
211 | - $caps_to_remove = self::$_registry[ $cap_reference ]['caps']; |
|
212 | - if (did_action('AHEE__EE_System__core_loaded_and_ready')) { |
|
213 | - $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
214 | - $capabilities->removeCaps($caps_to_remove); |
|
215 | - } else { |
|
216 | - add_action( |
|
217 | - 'AHEE__EE_System__core_loaded_and_ready', |
|
218 | - function () use ($caps_to_remove) { |
|
219 | - $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
220 | - $capabilities->removeCaps($caps_to_remove); |
|
221 | - } |
|
222 | - ); |
|
223 | - } |
|
224 | - } |
|
225 | - unset(self::$_registry[ $cap_reference ]); |
|
226 | - } |
|
227 | - } |
|
199 | + /** |
|
200 | + * @param string $cap_reference |
|
201 | + * @throws EE_Error |
|
202 | + * @throws \InvalidArgumentException |
|
203 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
204 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
205 | + */ |
|
206 | + public static function deregister($cap_reference = '') |
|
207 | + { |
|
208 | + if (! empty(self::$_registry[ $cap_reference ])) { |
|
209 | + if (! empty(self::$_registry[ $cap_reference ]['caps'])) { |
|
210 | + // if it's too early to remove capabilities, wait to do this until core is loaded and ready |
|
211 | + $caps_to_remove = self::$_registry[ $cap_reference ]['caps']; |
|
212 | + if (did_action('AHEE__EE_System__core_loaded_and_ready')) { |
|
213 | + $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
214 | + $capabilities->removeCaps($caps_to_remove); |
|
215 | + } else { |
|
216 | + add_action( |
|
217 | + 'AHEE__EE_System__core_loaded_and_ready', |
|
218 | + function () use ($caps_to_remove) { |
|
219 | + $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
220 | + $capabilities->removeCaps($caps_to_remove); |
|
221 | + } |
|
222 | + ); |
|
223 | + } |
|
224 | + } |
|
225 | + unset(self::$_registry[ $cap_reference ]); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | } |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | ); |
64 | 64 | } |
65 | 65 | // make sure we don't register twice |
66 | - if (isset(self::$_registry[ $cap_reference ])) { |
|
66 | + if (isset(self::$_registry[$cap_reference])) { |
|
67 | 67 | return; |
68 | 68 | } |
69 | 69 | // make sure this is not registered too late or too early. |
70 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
70 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
71 | 71 | || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
72 | 72 | ) { |
73 | 73 | EE_Error::doing_it_wrong( |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | ); |
84 | 84 | } |
85 | 85 | // some preliminary sanitization and setting to the $_registry property |
86 | - self::$_registry[ $cap_reference ] = array( |
|
86 | + self::$_registry[$cap_reference] = array( |
|
87 | 87 | 'caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) |
88 | 88 | ? $setup_args['capabilities'] |
89 | 89 | : array(), |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | { |
135 | 135 | // loop through and instantiate cap maps. |
136 | 136 | foreach (self::$_registry as $cap_reference => $setup) { |
137 | - if (! isset($setup['cap_maps'])) { |
|
137 | + if ( ! isset($setup['cap_maps'])) { |
|
138 | 138 | continue; |
139 | 139 | } |
140 | 140 | foreach ($setup['cap_maps'] as $cap_class => $args) { |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | */ |
164 | 164 | if (is_numeric($cap_class)) { |
165 | 165 | $cap_class = key($args); |
166 | - $args = $args[ $cap_class ]; |
|
166 | + $args = $args[$cap_class]; |
|
167 | 167 | } |
168 | 168 | |
169 | - if (! class_exists($cap_class)) { |
|
169 | + if ( ! class_exists($cap_class)) { |
|
170 | 170 | throw new EE_Error( |
171 | 171 | sprintf( |
172 | 172 | __( |
@@ -205,24 +205,24 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public static function deregister($cap_reference = '') |
207 | 207 | { |
208 | - if (! empty(self::$_registry[ $cap_reference ])) { |
|
209 | - if (! empty(self::$_registry[ $cap_reference ]['caps'])) { |
|
208 | + if ( ! empty(self::$_registry[$cap_reference])) { |
|
209 | + if ( ! empty(self::$_registry[$cap_reference]['caps'])) { |
|
210 | 210 | // if it's too early to remove capabilities, wait to do this until core is loaded and ready |
211 | - $caps_to_remove = self::$_registry[ $cap_reference ]['caps']; |
|
211 | + $caps_to_remove = self::$_registry[$cap_reference]['caps']; |
|
212 | 212 | if (did_action('AHEE__EE_System__core_loaded_and_ready')) { |
213 | 213 | $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
214 | 214 | $capabilities->removeCaps($caps_to_remove); |
215 | 215 | } else { |
216 | 216 | add_action( |
217 | 217 | 'AHEE__EE_System__core_loaded_and_ready', |
218 | - function () use ($caps_to_remove) { |
|
218 | + function() use ($caps_to_remove) { |
|
219 | 219 | $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
220 | 220 | $capabilities->removeCaps($caps_to_remove); |
221 | 221 | } |
222 | 222 | ); |
223 | 223 | } |
224 | 224 | } |
225 | - unset(self::$_registry[ $cap_reference ]); |
|
225 | + unset(self::$_registry[$cap_reference]); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | } |