1 | <?php |
||
30 | abstract class EE_Shortcodes extends EE_Base |
||
31 | { |
||
32 | |||
33 | /** |
||
34 | * holds label for library |
||
35 | * This is used for referencing the library label |
||
36 | * |
||
37 | * @access public |
||
38 | * @var string |
||
39 | */ |
||
40 | public $label; |
||
41 | |||
42 | |||
43 | /** |
||
44 | * This property is used for referencing a short description of the library |
||
45 | * |
||
46 | * @access public |
||
47 | * @var string |
||
48 | */ |
||
49 | public $description; |
||
50 | |||
51 | |||
52 | /** |
||
53 | * This will hold an array of shortcodes with the key as the shortcode ([shortcode]) and the value as a |
||
54 | * label/description for the shortcode. |
||
55 | * |
||
56 | * @access protected |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $_shortcodes; |
||
60 | |||
61 | |||
62 | /** |
||
63 | * This will hold the incoming data item sent to the parser method |
||
64 | * |
||
65 | * @access protected |
||
66 | * @var mixed (array|object) |
||
67 | */ |
||
68 | protected $_data; |
||
69 | |||
70 | |||
71 | /** |
||
72 | * some shortcodes may require extra data to parse. This property is provided for that. |
||
73 | * |
||
74 | * @var array |
||
75 | */ |
||
76 | protected $_extra_data; |
||
77 | |||
78 | |||
79 | /** |
||
80 | * EE_messenger used to generate the template being parsed. |
||
81 | * |
||
82 | * @since 4.5.0 |
||
83 | * @var EE_messenger |
||
84 | */ |
||
85 | protected $_messenger; |
||
86 | |||
87 | |||
88 | /** |
||
89 | * message type used to generate the template being parsed. |
||
90 | * |
||
91 | * @since 4.5.0 |
||
92 | * @var EE_message_type |
||
93 | */ |
||
94 | protected $_message_type; |
||
95 | |||
96 | |||
97 | /** |
||
98 | * context used for the template being parsed |
||
99 | * |
||
100 | * @since 4.5.0 |
||
101 | * @var string |
||
102 | */ |
||
103 | protected $_context; |
||
104 | |||
105 | |||
106 | /** |
||
107 | * Specific Message Template Group ID |
||
108 | * |
||
109 | * @since 4.5.0 |
||
110 | * @var int |
||
111 | */ |
||
112 | protected $_GRP_ID; |
||
113 | |||
114 | |||
115 | /** |
||
116 | * @since 4.9.0 |
||
117 | * @type EE_Message |
||
118 | */ |
||
119 | protected $_message; |
||
120 | |||
121 | |||
122 | /** |
||
123 | * This will hold an instance of the EEH_Parse_Shortcodes helper that will be used when handling list type |
||
124 | * shortcodes |
||
125 | * |
||
126 | * @var EEH_Parse_Shortcodes |
||
127 | */ |
||
128 | protected $_shortcode_helper; |
||
129 | |||
130 | |||
131 | public function __construct() |
||
136 | |||
137 | |||
138 | /** |
||
139 | * This sets the defaults for the properties. Child classes will override these properties in their _init_props |
||
140 | * method |
||
141 | */ |
||
142 | private function _set_defaults() |
||
148 | |||
149 | |||
150 | /** |
||
151 | * loads an instance of the EE_Shortcode_Parser helper when requested |
||
152 | */ |
||
153 | protected function _set_shortcode_helper() |
||
158 | |||
159 | |||
160 | public function get_shortcode_helper() |
||
167 | |||
168 | |||
169 | /** |
||
170 | * This is the public method for kicking of the parser included with each child. It can be overridden by child |
||
171 | * classes if necessary (see EE_Questions_Answers for example) |
||
172 | * |
||
173 | * @param string $shortcode incoming shortcode to be parsed |
||
174 | * @param mixed (object|array) $data incoming data to be be used for parsing |
||
175 | * @param mixed (object|array) $extra_data extra incoming data (usually EE_Messages_Addressee) |
||
176 | * @return string parsed shortcode. |
||
177 | */ |
||
178 | public function parser($shortcode, $data, $extra_data = array()) |
||
202 | |||
203 | |||
204 | /** |
||
205 | * This method just returns the shortcodes in the $_shortcodes array property. |
||
206 | * |
||
207 | * @access public |
||
208 | * @return array array of shortcodes => description pairs |
||
209 | */ |
||
210 | public function get_shortcodes() |
||
219 | |||
220 | |||
221 | /** |
||
222 | * Child classes use this method to set the $name, $description, and $_shortcodes properties. |
||
223 | * |
||
224 | * @abstract |
||
225 | * @access protected |
||
226 | * @return void |
||
227 | */ |
||
228 | abstract protected function _init_props(); |
||
229 | |||
230 | |||
231 | /** |
||
232 | * This method will give parsing instructions for each shortcode defined in the _shortcodes array. Child methods |
||
233 | * will have to take care of handling. |
||
234 | * |
||
235 | * @abstract |
||
236 | * @access protected |
||
237 | * @param string $shortcode the shortcode to be parsed. |
||
238 | * @param mixed (object|array) $data incoming data for the parser. The data could be either an object or |
||
239 | * array because there are some shortcodes that might be replaced by prepared data that |
||
240 | * has multiple items in a list (i.e. list of attendees in an event and we're showing |
||
241 | * fname/lname for each attendee). In this case data will be in an array. Otherwise |
||
242 | * the data shoudl be in a properly formatted object. The |
||
243 | * EEH_Parse_Shortcodes.helper.php describes the data object we're expecting. |
||
244 | * @return string parsed shortcode |
||
245 | */ |
||
246 | abstract protected function _parser($shortcode); |
||
247 | |||
248 | |||
249 | /** |
||
250 | * This just validates incoming data for list type shortcode parsers (and they call this method) to make sure it |
||
251 | * meets their requirements |
||
252 | * |
||
253 | * @return mixed (void|exception) If validation fails we'll throw an exception. |
||
254 | */ |
||
255 | protected function _validate_list_requirements() |
||
284 | |||
285 | |||
286 | /** |
||
287 | * This returns any attributes that may be existing on an EE_Shortcode |
||
288 | * |
||
289 | * @since 4.5.0 |
||
290 | * @param string $shortcode incoming shortcode |
||
291 | * @return array An array with the attributes |
||
292 | */ |
||
293 | protected function _get_shortcode_attrs($shortcode) |
||
305 | |||
306 | |||
307 | /** |
||
308 | * Conditional blocks are shortcode patterns with an opening conditional tag `[IF_*]` and a corresponding |
||
309 | * closing tag (eg `[/IF_*]`). The content within the tags will be displayed/hidden depending on whatever conditions |
||
310 | * existed in the opening tag. This method handles parsing the actual template to show/hide this conditional content. |
||
311 | * |
||
312 | * @since 4.9.32 |
||
313 | * |
||
314 | * @param string $shortcode This should be original shortcode as used in the template and passed to the parser. |
||
315 | * @param bool $show true means the opening and closing tags are removed and the content is left showing, false |
||
316 | * means the opening and closing tags and the contained content are removed. |
||
317 | * @return string The template for the shortcode is returned. |
||
318 | */ |
||
319 | protected function _mutate_conditional_block_in_template($shortcode, $show = true) |
||
339 | |||
340 | |||
341 | /** |
||
342 | * This returns the regex pattern to use for conditional shortcodes parsing. |
||
343 | * |
||
344 | * Note: regex comes in part from the WP `get_shortcode_regex` expression in \wp-includes\shortcodes.php |
||
345 | * |
||
346 | * @param $shortcode |
||
347 | * @since 4.9.32 |
||
348 | * @return string |
||
349 | */ |
||
350 | private function _get_conditional_block_regex($shortcode) |
||
392 | |||
393 | |||
394 | /** |
||
395 | * This sets the properties related to the messages system |
||
396 | * |
||
397 | * @since 4.5.0 |
||
398 | * @return void |
||
399 | */ |
||
400 | protected function _set_messages_properties() |
||
411 | |||
412 | |||
413 | /** |
||
414 | * This returns whatever the set message type object is that was set on this shortcode parser. |
||
415 | * |
||
416 | * @since 4.5.0 |
||
417 | * @return EE_message_type |
||
418 | */ |
||
419 | public function get_set_message_type() |
||
423 | |||
424 | |||
425 | /** |
||
426 | * This returns whatever the set messenger object is that was set on this shortcode parser |
||
427 | * |
||
428 | * @since 4.5.0 |
||
429 | * @return EE_messenger |
||
430 | */ |
||
431 | public function get_set_messenger() |
||
435 | |||
436 | |||
437 | /** |
||
438 | * This returns whatever the set context string is on this shortcode parser. |
||
439 | * |
||
440 | * @since 4.5.0 |
||
441 | * @return string |
||
442 | */ |
||
443 | public function get_set_context() |
||
447 | |||
448 | |||
449 | /** |
||
450 | * This returns whatever the set EE_Message object is on this shortcode. |
||
451 | * |
||
452 | * @since 4.9.0 |
||
453 | * @return EE_Message |
||
454 | */ |
||
455 | public function get_set_message() |
||
459 | |||
460 | |||
461 | } //end EE_Shortcodes |
||
462 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.