| 1 | <?php |
||
| 3 | class ChecIOShortcode extends Object |
||
| 4 | { |
||
| 5 | /** |
||
| 6 | * ShortCode which adds a link to a chec.io buy now popup window |
||
| 7 | * @param array $arguments |
||
| 8 | * @param string $content |
||
| 9 | * @param ShortcodeParser $parser |
||
| 10 | * @param string $tagName |
||
| 11 | * @return string |
||
| 12 | */ |
||
| 13 | public static function BuyNowButton($arguments, $content = null, $parser = null, $tagName) |
||
| 14 | { |
||
| 15 | if (isset($arguments['data-chec-product-id'])) { |
||
| 16 | $id = Convert::raw2att($arguments['data-chec-product-id']); |
||
| 17 | unset($arguments['data-chec-product-id']); |
||
| 18 | $siteURL = self::config()->get('third-party-url'); |
||
| 19 | |||
| 20 | $link = "<a href=\"$siteURL/{$id}\""; |
||
| 21 | // Add all arguments as-is as we could potentially be receiving css class styles |
||
| 22 | foreach ($arguments as $key => $val) { |
||
| 23 | $val = Convert::raw2att($val); |
||
| 24 | $link .= " {$key}=\"{$val}\" "; |
||
| 25 | } |
||
| 26 | $link .= ">{$content}</a>"; |
||
| 27 | return $link; |
||
| 28 | } |
||
| 29 | return ''; |
||
| 30 | } |
||
| 31 | } |
||
| 32 |