Manager.php
2 weeks ago
Shortcode_Abstract.php
2 weeks ago
Shortcode_Interface.php
2 weeks ago
Utils.php
2 weeks ago
Shortcode_Interface.php
126 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Tribe\Shortcode; |
| 4 | |
| 5 | /** |
| 6 | * Interface Shortcode_Interface |
| 7 | * |
| 8 | * @package Tribe\Shortcode |
| 9 | * |
| 10 | * @since 4.12.0 |
| 11 | */ |
| 12 | interface Shortcode_Interface { |
| 13 | |
| 14 | /** |
| 15 | * Returns the shortcode slug that allows the shortcode to be built via the shortcode class by slug. |
| 16 | * |
| 17 | * @since 4.12.0 |
| 18 | * |
| 19 | * @return string The shortcode slug. |
| 20 | */ |
| 21 | public function get_registration_slug(); |
| 22 | |
| 23 | /** |
| 24 | * Configures the base variables for an instance of shortcode. |
| 25 | * |
| 26 | * @since 4.12.0 |
| 27 | * |
| 28 | * @param array|string $arguments Set of arguments passed to the Shortcode at hand. Empty string if no args. |
| 29 | * @param string $content Contents passed to the shortcode, inside of the open and close brackets. |
| 30 | */ |
| 31 | public function setup( $arguments, $content ); |
| 32 | |
| 33 | /** |
| 34 | * Sets the aliased arguments array. |
| 35 | * |
| 36 | * @see Tribe__Utils__Array::parse_associative_array_alias() The expected format. |
| 37 | * |
| 38 | * @since 4.12.2 |
| 39 | * |
| 40 | * @param array $alias_map An associative array of aliases: key as alias, value as mapped canonical. |
| 41 | * Example: [ 'alias' => 'canonical', 'from' => 'to', 'that' => 'becomes_this' ] |
| 42 | */ |
| 43 | public function set_aliased_arguments( array $alias_map ); |
| 44 | |
| 45 | /** |
| 46 | * Gets the aliased arguments array. |
| 47 | * |
| 48 | * @since 4.12.2 |
| 49 | * |
| 50 | * @return array<string,string> The associative array map of aliases and their canonical arguments. |
| 51 | */ |
| 52 | public function get_aliased_arguments(); |
| 53 | |
| 54 | /** |
| 55 | * Returns the arguments for the shortcode parsed correctly with defaults applied. |
| 56 | * |
| 57 | * @since 4.12.0 |
| 58 | * |
| 59 | * @param array $arguments Set of arguments passed to the Shortcode at hand. |
| 60 | * |
| 61 | * @return array<string,mixed> The parsed shortcode arguments map. |
| 62 | */ |
| 63 | public function parse_arguments( array $arguments ); |
| 64 | |
| 65 | /** |
| 66 | * Returns the array of arguments for this shortcode after applying the validation callbacks. |
| 67 | * |
| 68 | * @since 4.12.0 |
| 69 | * |
| 70 | * @param array $arguments Set of arguments passed to the Shortcode at hand. |
| 71 | * |
| 72 | * @return array<string,mixed> The validated shortcode arguments map. |
| 73 | */ |
| 74 | public function validate_arguments( array $arguments ); |
| 75 | |
| 76 | /** |
| 77 | * Returns the array of callbacks for this shortcode's arguments. |
| 78 | * |
| 79 | * @since 4.12.0 |
| 80 | * |
| 81 | * @return array<string,mixed> A map of the shortcode arguments that have survived validation. |
| 82 | */ |
| 83 | public function get_validated_arguments_map(); |
| 84 | |
| 85 | /** |
| 86 | * Returns a shortcode default arguments. |
| 87 | * |
| 88 | * @since 4.12.0 |
| 89 | * |
| 90 | * @return array<string,mixed> The shortcode default arguments map. |
| 91 | */ |
| 92 | public function get_default_arguments(); |
| 93 | |
| 94 | /** |
| 95 | * Returns a shortcode arguments after been parsed. |
| 96 | * |
| 97 | * @since 4.12.0 |
| 98 | * |
| 99 | * @return array<string,mixed> The shortcode arguments, as set by the user in the shortcode string. |
| 100 | */ |
| 101 | public function get_arguments(); |
| 102 | |
| 103 | /** |
| 104 | * Returns a shortcode argument after it has been parsed. |
| 105 | * |
| 106 | * @since 4.12.0 |
| 107 | * |
| 108 | * @param array|string $index Which index we indent to fetch from the arguments. |
| 109 | * @param array $default Default value if it doesn't exist. |
| 110 | * |
| 111 | * @uses Tribe__Utils__Array::get For index fetching and Default. |
| 112 | * |
| 113 | * @return mixed Value for the Index passed as the first argument. |
| 114 | */ |
| 115 | public function get_argument( $index, $default = null ); |
| 116 | |
| 117 | /** |
| 118 | * Returns a shortcode's HTML. |
| 119 | * |
| 120 | * @since 4.12.0 |
| 121 | * |
| 122 | * @return string The shortcode rendered HTML code. |
| 123 | */ |
| 124 | public function get_html(); |
| 125 | } |
| 126 |