html.php
49 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | /** |
| 15 | * Wraps the results returned by the subscribers. |
| 16 | * Accepts only displayable strings. |
| 17 | * |
| 18 | * @since 1.7.3 |
| 19 | */ |
| 20 | class VAPActionResultHtml extends VAPActionResult |
| 21 | { |
| 22 | /** |
| 23 | * Filters the resulting elements while constructing the object. |
| 24 | * Children classes can override this method to sanitize the |
| 25 | * received results. |
| 26 | * |
| 27 | * @param mixed $elem The element to map. |
| 28 | * |
| 29 | * @return mixed The mapped element. |
| 30 | */ |
| 31 | protected function map($elem) |
| 32 | { |
| 33 | // accepts only strings |
| 34 | return is_string($elem) ? $elem : null; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Implodes all the results into a single string. |
| 39 | * |
| 40 | * @param string $glue The strings separator. |
| 41 | * |
| 42 | * @return string The resulting HTML. |
| 43 | */ |
| 44 | public function display($glue = "\n") |
| 45 | { |
| 46 | return implode($glue, $this->toArray()); |
| 47 | } |
| 48 | } |
| 49 |