| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * Prepare user input for save/output to shortcode attribute. |
|---|
| 4 | */ |
|---|
| 5 | function shortcode_attr_esc( $input ) { |
|---|
| 6 | $trans = array( |
|---|
| 7 | '&' => '&', |
|---|
| 8 | '"' => '"', |
|---|
| 9 | "'" => ''', |
|---|
| 10 | '[' => '[', |
|---|
| 11 | ']' => ']', |
|---|
| 12 | '<' => '&#lt;', |
|---|
| 13 | '>' => '&#gt;', |
|---|
| 14 | ); |
|---|
| 15 | |
|---|
| 16 | return strtr( $input, $trans ); |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | /** |
|---|
| 20 | * Retrieve the raw input from a shortcode attribute. |
|---|
| 21 | */ |
|---|
| 22 | function shortcode_attr_unesc( $input ) { |
|---|
| 23 | $trans = array( |
|---|
| 24 | '&' => '&', |
|---|
| 25 | '"' => '"', |
|---|
| 26 | ''' => "'", |
|---|
| 27 | '[' => '[', |
|---|
| 28 | ']' => ']', |
|---|
| 29 | '&#lt;' => '<', |
|---|
| 30 | '&#gt;' => '>', |
|---|
| 31 | ); |
|---|
| 32 | |
|---|
| 33 | return strtr( $input, $trans ); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | ?> |
|---|