PageRenderTime 39ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/nonus/theme/shortcodes/accordion/ctDrillDownMenuShortcode.class.php

https://github.com/alniko009/magic
PHP | 140 lines | 70 code | 21 blank | 49 comment | 4 complexity | c5fee0d7a49b94e8e1545dd16ae1d9c0 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * ctJqueryDrillDown
  4. * @author alex
  5. */
  6. class ctDrillDownMenuShortcode extends ctShortcode {
  7. /**
  8. * Default skin
  9. */
  10. const THEME_SKIN_NAME = 'default';
  11. /**
  12. * Registers additional custom stuff
  13. */
  14. public function __construct() {
  15. parent::__construct();
  16. add_filter('ct_jquery_drilldown.skins_list', array($this, 'extendDefaultPlugin'));
  17. add_filter('ct_jquery_drilldown.skin', array($this, 'getDefaultSkin'), 10, 2);
  18. add_filter('ct_jquery_drilldown.defaults', array($this, 'setupDefaults'), 10, 2);
  19. add_filter('ct_jquery_drilldown.filter_menu', array($this, 'filterResult'), 10, 1);
  20. }
  21. /**
  22. * Filter result
  23. * @param string $result
  24. * @return mixed
  25. */
  26. public function filterResult($result) {
  27. return str_replace(array('dropdown-menu', 'dropdown', 'active'), '', $result);
  28. }
  29. /**
  30. * Setup default values
  31. * @param array $data
  32. * @return mixed
  33. */
  34. public function setupDefaults($data) {
  35. $data['skin'] = self::THEME_SKIN_NAME;
  36. $data['search']='';
  37. $data['back']='top';
  38. $data['backName']='&laquo; Back';
  39. return $data;
  40. }
  41. /**
  42. * Returns current skin path
  43. * @param $skin
  44. * @param $skinPath
  45. * @return mixed
  46. */
  47. public function getDefaultSkin($skinPath,$skin) {
  48. if ($skin == 'skin-'.self::THEME_SKIN_NAME) {
  49. return '';
  50. }
  51. return $skinPath;
  52. }
  53. /**
  54. * Extend drilldown to support new theme
  55. * @param array $skins
  56. * @return mixed
  57. */
  58. public function extendDefaultPlugin($skins) {
  59. $skins = array_merge(array(self::THEME_SKIN_NAME => self::THEME_SKIN_NAME), $skins);
  60. return $skins;
  61. }
  62. /**
  63. * Returns shortcode label
  64. * @return mixed
  65. */
  66. public function getName() {
  67. return "createIT Drilldown Menu";
  68. }
  69. /**
  70. * Returns shortcode name
  71. * @return string
  72. */
  73. public function getShortcodeName() {
  74. return 'drilldown';
  75. }
  76. /**
  77. * Handles shortcode
  78. * @param $atts
  79. * @param null $content
  80. * @return mixed
  81. */
  82. public function handle($atts, $content = null) {
  83. if ($this->getOverwrittenCallback()) {
  84. return call_user_func($this->getOverwrittenCallback(), $atts, $content);
  85. }
  86. return $this->getName() . ' Plugin not installed';
  87. }
  88. /**
  89. * Returns config
  90. * @return array
  91. */
  92. public function getAttributes() {
  93. $m = array();
  94. $menus = get_terms('nav_menu', array('hide_empty' => false));
  95. foreach ($menus as $e) {
  96. $m[$e->slug] = $e->name;
  97. }
  98. return array(
  99. 'title' => array('label' => __('Title', 'ct_theme'), 'default' => '', 'type' => 'input'),
  100. 'menu' => array('label' => __('Menu', 'ct_theme'), 'default' => '', 'type' => 'select', 'choices' => $m),
  101. 'skin' => array('label' => __('Skin', 'ct_theme'), 'type' => 'select', 'default' => self::THEME_SKIN_NAME, 'choices' => ct_jquery_drilldown_menu_widget::getAvailableSkins()),
  102. 'event' => array('label' => __('Event', 'ct_theme'), 'type' => 'select', 'default' => 'click', 'choices' => array('click' => __('click', 'ct_theme'), 'mouseenter' => __('hover', 'ct_theme'))),
  103. 'heightautoadjust' => array('label' => __('Auto height', 'ct_theme'), 'default' => "true", 'type' => 'checkbox'),
  104. 'speed' => array('label' => __('Speed', 'ct_theme'), 'default' => 'normal', 'type' => 'select', 'choices' => array('slow' => __('slow', 'ct_theme'), 'normal' => __('normal', 'ct_theme'), 'fast' => __("fast", 'ct_theme'))),
  105. 'easing' => array('label' => __('Animation type', 'ct_theme'), 'type' => 'select', 'default' => 'easeInOutQuad', 'choices' => array('easeInOutQuint' => __('standard', 'ct_theme'), 'linear' => __('linear', 'ct_theme'), 'easeInOutQuad' => __('smooth', 'ct_theme'), 'easeOutBounce' => __("jumpy", 'ct_theme'))),
  106. 'breadcrumb' => array('label' => __('Breadcrumb position', 'ct_theme'), 'type' => 'select', 'default' => '', 'choices' => array('' => __('hidden', 'ct_theme'), 'top' => __('top', 'ct_theme'), 'bottom' => __('bottom', 'ct_theme'))),
  107. 'startname' => array('label' => __('Breadcrumb start', 'ct_theme'), 'default' => '', 'type' => 'input'),
  108. 'back' => array('label' => __('Back link position', 'ct_theme'), 'type' => 'select', 'default' => '', 'choices' => array('' => __('hidden', 'ct_theme'), 'top' => __('top', 'ct_theme'), 'bottom' => __('bottom', 'ct_theme'))),
  109. 'backname' => array('label' => __('Breadcrumb start', 'ct_theme'), 'default' => '', 'type' => 'input'),
  110. 'backanimation' => array('label' => __('Back link animation', 'ct_theme'), 'default' => "true", 'type' => 'checkbox'),
  111. 'currentposition' => array('label' => __('Current item position', 'ct_theme'), 'type' => 'select', 'default' => '', 'choices' => array('' => __('hidden', 'ct_theme'), 'top' => __('top', 'ct_theme'), 'bottom' => __('bottom', 'ct_theme'))),
  112. 'search' => array('label' => __('Search position', 'ct_theme'), 'type' => 'select', 'default' => '', 'choices' => array('' => __('hidden', 'ct_theme'), 'top' => __('top', 'ct_theme'), 'bottom' => __('bottom', 'ct_theme'))),
  113. 'searchtext' => array('label' => __('Search label', 'ct_theme'), 'type' => 'input', 'default' => __('Search here', 'ct_theme')),
  114. );
  115. }
  116. }
  117. if(class_exists('ct_jquery_drilldown_menu_widget')){
  118. new ctDrillDownMenuShortcode();
  119. }