PageRenderTime 66ms CodeModel.GetById 43ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/nonus/theme/shortcodes/typography/ctPricelistItemShortcode.class.php

https://github.com/alniko009/magic
PHP | 85 lines | 45 code | 13 blank | 27 comment | 1 complexity | 14258e49f457d50ae33daba5c2c30438 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Pricelist item shortcode
  4. */
  5. class ctPricelistItemShortcode extends ctShortcode {
  6. /**
  7. * Returns name
  8. * @return string|void
  9. */
  10. public function getName() {
  11. return 'Pricelist item';
  12. }
  13. /**
  14. * Shortcode name
  15. * @return string
  16. */
  17. public function getShortcodeName() {
  18. return 'pricelist_item';
  19. }
  20. /**
  21. * Returns shortcode type
  22. * @return mixed|string
  23. */
  24. public function getShortcodeType() {
  25. return self::TYPE_SHORTCODE_ENCLOSING;
  26. }
  27. /**
  28. * Handles shortcode
  29. * @param $atts
  30. * @param null $content
  31. * @return string
  32. */
  33. public function handle($atts, $content = null) {
  34. extract(shortcode_atts($this->extractShortcodeAttributes($atts), $atts));
  35. //style
  36. switch ($style) {
  37. case 'basic':
  38. $class = '';
  39. break;
  40. case 'distinctive':
  41. $class = ' price-box-special';
  42. break;
  43. default:
  44. $class = '';
  45. }
  46. //button
  47. $buttonHtml = $buttonlabel ? ('<div><a href="' . $buttonlink . '" class="btn btn-default">' . $buttonlabel . '</a></div>') : '';
  48. return str_replace(array('<p>','</p>'),'',do_shortcode('<div class="price-box' . $class . '">
  49. <h4>' . $title . '</h4>
  50. <span class="price"><sup>' . $currency . '</sup>' . $price . '<sub>' . $subprice . '</sub></span>
  51. ' . $content . '
  52. ' . $buttonHtml . '
  53. </div>'));
  54. }
  55. /**
  56. * Returns config
  57. * @return null
  58. */
  59. public function getAttributes() {
  60. return array(
  61. 'title' => array('label' => __('title', 'ct_theme'), 'default' => '', 'type' => 'input'),
  62. 'currency' => array('label' => __('currency', 'ct_theme'), 'default' => __('$', 'ct_theme'), 'type' => 'input'),
  63. 'price' => array('label' => __('price', 'ct_theme'), 'default' => '', 'type' => 'input','example'=>'456,50'),
  64. 'subprice' => array('label' => __('subprice', 'ct_theme'), 'default' => '', 'type' => 'input'),
  65. 'buttonlabel' => array('default' => '', 'type' => 'input', 'label' => __("button label", 'ct_theme')),
  66. 'buttonlink' => array('default' => '#', 'type' => 'input', 'label' => __("button link", 'ct_theme')),
  67. 'style' => array('label' => __('style', 'ct_theme'), 'default' => 'basic', 'type' => 'select', 'choices' => array('basic' => __('basic', 'ct_theme'), 'distinctive' => __('distinctive', 'ct_theme')), 'help' => __('Section style', 'ct_theme')),
  68. 'content' => array('label' => __('content', 'ct_theme'), 'default' => '', 'type' => 'textarea'),
  69. );
  70. }
  71. }
  72. new ctPricelistItemShortcode();