/library/functions/widgets.php

  1. <?php 
  2. $options = get_option('evl_options'); 
  3. $evolve_widgets_header = (isset($options['evl_widgets_header'])) ? $options['evl_widgets_header'] : 'one'; 
  4. $evolve_widgets_footer = (isset($options['evl_widgets_num'])) ? $options['evl_widgets_num'] : 'disable'; 
  5.  
  6. if (function_exists('register_sidebar')) 
  7. register_sidebar(array( 
  8. 'name' => __('Sidebar 1', 'evolve'),  
  9. 'id' => 'sidebar-1',  
  10. 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-content">',  
  11. 'after_widget' => '</div></div>',  
  12. 'before_title' => '<div class="before-title"><div class="widget-title-background"></div><h3 class="widget-title">',  
  13. 'after_title' => '</h3></div>',  
  14. )); 
  15.  
  16. if (function_exists('register_sidebar')) 
  17. register_sidebar(array( 
  18. 'name' => __('Sidebar 2', 'evolve'),  
  19. 'id' => 'sidebar-2',  
  20. 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-content">',  
  21. 'after_widget' => '</div></div>',  
  22. 'before_title' => '<div class="before-title"><div class="widget-title-background"></div><h3 class="widget-title">',  
  23. 'after_title' => '</h3></div>',  
  24. )); 
  25.  
  26. function evolve_header1() { 
  27. if (function_exists('register_sidebar')) 
  28. register_sidebar(array( 
  29. 'name' => __('Header 1', 'evolve'),  
  30. 'id' => 'header-1',  
  31. 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-content">',  
  32. 'after_widget' => '</div></div>',  
  33. 'before_title' => '<div class="before-title"><div class="widget-title-background"></div><h3 class="widget-title">',  
  34. 'after_title' => '</h3></div>',  
  35. )); 
  36.  
  37. function evolve_header2() { 
  38. if (function_exists('register_sidebar')) 
  39. register_sidebar(array( 
  40. 'name' => __('Header 2', 'evolve'),  
  41. 'id' => 'header-2',  
  42. 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-content">',  
  43. 'after_widget' => '</div></div>',  
  44. 'before_title' => '<div class="before-title"><div class="widget-title-background"></div><h3 class="widget-title">',  
  45. 'after_title' => '</h3></div>',  
  46. )); 
  47.  
  48. function evolve_header3() { 
  49. if (function_exists('register_sidebar')) 
  50. register_sidebar(array( 
  51. 'name' => __('Header 3', 'evolve'),  
  52. 'id' => 'header-3',  
  53. 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-content">',  
  54. 'after_widget' => '</div></div>',  
  55. 'before_title' => '<div class="before-title"><div class="widget-title-background"></div><h3 class="widget-title">',  
  56. 'after_title' => '</h3></div>',  
  57. )); 
  58.  
  59. function evolve_header4() { 
  60. if (function_exists('register_sidebar')) 
  61. register_sidebar(array( 
  62. 'name' => __('Header 4', 'evolve'),  
  63. 'id' => 'header-4',  
  64. 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-content">',  
  65. 'after_widget' => '</div></div>',  
  66. 'before_title' => '<div class="before-title"><div class="widget-title-background"></div><h3 class="widget-title">',  
  67. 'after_title' => '</h3></div>',  
  68. )); 
  69.  
  70. function evolve_footer1() { 
  71. if (function_exists('register_sidebar')) 
  72. register_sidebar(array( 
  73. 'name' => __('Footer 1', 'evolve'),  
  74. 'id' => 'footer-1',  
  75. 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-content">',  
  76. 'after_widget' => '</div></div>',  
  77. 'before_title' => '<div class="before-title"><div class="widget-title-background"></div><h3 class="widget-title">',  
  78. 'after_title' => '</h3></div>',  
  79. )); 
  80.  
  81. function evolve_footer2() { 
  82. if (function_exists('register_sidebar')) 
  83. register_sidebar(array( 
  84. 'name' => __('Footer 2', 'evolve'),  
  85. 'id' => 'footer-2',  
  86. 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-content">',  
  87. 'after_widget' => '</div></div>',  
  88. 'before_title' => '<div class="before-title"><div class="widget-title-background"></div><h3 class="widget-title">',  
  89. 'after_title' => '</h3></div>',  
  90. )); 
  91.  
  92. function evolve_footer3() { 
  93. if (function_exists('register_sidebar')) 
  94. register_sidebar(array( 
  95. 'name' => __('Footer 3', 'evolve'),  
  96. 'id' => 'footer-3',  
  97. 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-content">',  
  98. 'after_widget' => '</div></div>',  
  99. 'before_title' => '<div class="before-title"><div class="widget-title-background"></div><h3 class="widget-title">',  
  100. 'after_title' => '</h3></div>',  
  101. )); 
  102.  
  103. function evolve_footer4() { 
  104. if (function_exists('register_sidebar')) 
  105. register_sidebar(array( 
  106. 'name' => __('Footer 4', 'evolve'),  
  107. 'id' => 'footer-4',  
  108. 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-content">',  
  109. 'after_widget' => '</div></div>',  
  110. 'before_title' => '<div class="before-title"><div class="widget-title-background"></div><h3 class="widget-title">',  
  111. 'after_title' => '</h3></div>',  
  112. )); 
  113.  
  114. // Header widgets 
  115.  
  116. if (($evolve_widgets_header == "one")) { 
  117. evolve_header1(); 
  118. if (($evolve_widgets_header == "two")) { 
  119. evolve_header1(); 
  120. evolve_header2(); 
  121. if (($evolve_widgets_header == "three")) { 
  122. evolve_header1(); 
  123. evolve_header2(); 
  124. evolve_header3(); 
  125. if (($evolve_widgets_header == "four")) { 
  126. evolve_header1(); 
  127. evolve_header2(); 
  128. evolve_header3(); 
  129. evolve_header4(); 
  130. } else { 
  131.  
  132.  
  133. // Footer widgets 
  134.  
  135. if (($evolve_widgets_footer == "one")) { 
  136. evolve_footer1(); 
  137. if (($evolve_widgets_footer == "two")) { 
  138. evolve_footer1(); 
  139. evolve_footer2(); 
  140. if (($evolve_widgets_footer == "three")) { 
  141. evolve_footer1(); 
  142. evolve_footer2(); 
  143. evolve_footer3(); 
  144. if (($evolve_widgets_footer == "four")) { 
  145. evolve_footer1(); 
  146. evolve_footer2(); 
  147. evolve_footer3(); 
  148. evolve_footer4(); 
  149. } else { 
  150.  
  151.  
  152. function evolve_widget_area_active($index) { 
  153. global $wp_registered_sidebars; 
  154.  
  155. $widgetarea = wp_get_sidebars_widgets(); 
  156. if (isset($widgetarea[$index])) { 
  157. return true; 
  158.  
  159. return false; 
  160.  
  161. function evolve_widget_area($name = false) { 
  162. if (!isset($name)) { 
  163. $widget[] = "widget.php"; 
  164. } else { 
  165. $widget[] = "widget-{$name}.php"; 
  166. locate_template($widget, true); 
  167.  
  168. function evolve_widget_before_title() { 
  169. ?> 
  170.  
  171. <div class="before-title"> 
  172. <div class="widget-title-background"></div><h3 class="widget-title"> 
  173.  
  174. <?php 
  175.  
  176. function evolve_widget_after_title() { 
  177. ?> 
  178.  
  179. </h3></div> 
  180.  
  181. <?php 
  182.  
  183. function evolve_widget_before_widget() { 
  184. ?> 
  185.  
  186. <div class="widget"><div class="widget-content"> 
  187.  
  188. <?php 
  189.  
  190. function evolve_widget_after_widget() { 
  191. ?> 
  192.  
  193. </div></div> 
  194.  
  195. <?php 
  196.  
  197. function evolve_widget_text($args, $number = 1) { 
  198. extract($args); 
  199. $options = get_option('evolve_widget_text'); 
  200. $title = $options[$number]['title']; 
  201. if (empty($title)) { 
  202. $title = ''; 
  203.  
  204. class evolve_carousel_WP_Widget extends WP_Widget { 
  205.  
  206. function __construct() { 
  207. $widget_ops = array( 
  208. 'classname' => 'carousel-slider',  
  209. 'description' => __('Insert your custom image slides', 'evolve') 
  210. ); 
  211. $control_ops = array('width' => 400, 'height' => 350); 
  212. parent::__construct('carousel-slider', __('evolve: Carousel Slider', 'evolve'), $widget_ops, $control_ops); 
  213.  
  214. function widget($args, $instance) { 
  215. extract($args); 
  216. $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); 
  217. $text = apply_filters('widget_text', empty($instance['text']) ? '' : $instance['text'], $instance); 
  218. echo $before_widget; 
  219. if (!empty($title)) { 
  220. echo $before_title . $title . $after_title; 
  221. ?> 
  222. <div class="textwidget"><?php echo!empty($instance['filter']) ? wpautop($text) : $text; ?></div> 
  223. <?php 
  224. echo $after_widget; 
  225.  
  226. function update($new_instance, $old_instance) { 
  227. $instance = $old_instance; 
  228. $instance['title'] = strip_tags($new_instance['title']); 
  229. if (current_user_can('unfiltered_html')) { 
  230. $instance['text'] = $new_instance['text']; 
  231. } else { 
  232. $instance['text'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['text']))); 
  233. }// wp_filter_post_kses() expects slashed 
  234. $instance['filter'] = isset($new_instance['filter']); 
  235.  
  236. return $instance; 
  237.  
  238. function form($instance) { 
  239.  
  240. $evolve_defaultslider = "<div id='myCarousel' class='carousel slide' data-ride='carousel'> 
  241.  
  242. <ol class='carousel-indicators'> 
  243. <li data-target='#myCarousel' data-slide-to='0' class='active'></li> 
  244. <li data-target='#myCarousel' data-slide-to='1'></li> 
  245. <li data-target='#myCarousel' data-slide-to='2'></li> 
  246. <li data-target='#myCarousel' data-slide-to='3'></li> 
  247. </ol> 
  248.  
  249. <div class='carousel-inner'> 
  250.  
  251. <div class='item active'> 
  252. <img src='" . get_template_directory_uri() . "/assets/images/bootstrap-slider/1.jpg' alt='' /> 
  253. <div class='carousel-caption'> 
  254. <h4>Built-in Bootstrap Elements and Font Awesome let you do amazing things with your website</h4> 
  255. </div> 
  256. </div> 
  257.  
  258. <div class='item'> 
  259. <img src='" . get_template_directory_uri() . "/assets/images/bootstrap-slider/2.jpg' alt='' /> 
  260. <div class='carousel-caption'> 
  261. <h4>Easy to use control panel with a lot of options</h4>  
  262. </div> 
  263. </div> 
  264.  
  265. <div class='item'> 
  266. <img src='" . get_template_directory_uri() . "/assets/images/bootstrap-slider/3.jpg' alt='' /> 
  267. <div class='carousel-caption'> 
  268. <h4>Fully responsive theme for any device</h4>  
  269. </div> 
  270. </div>  
  271.  
  272. <div class='item'> 
  273. <img src='" . get_template_directory_uri() . "/assets/images/bootstrap-slider/4.jpg' alt='' /> 
  274. <div class='carousel-caption'> 
  275. <h4>Unlimited color schemes</h4>  
  276. </div> 
  277. </div> 
  278.  
  279. </div><!--/.carousel-inner--> 
  280.  
  281. <a class='left carousel-control' href='#myCarousel' data-slide='prev'></a> 
  282.  
  283. <a class='right carousel-control' href='#myCarousel' data-slide='next'></a> 
  284.  
  285. </div><!--/#myCarousel-->"; 
  286.  
  287.  
  288. $instance = wp_parse_args((array) $instance, array('title' => '', 'text' => $evolve_defaultslider)); 
  289. $title = strip_tags($instance['title']); 
  290. $text = esc_textarea($instance['text']); 
  291. ?> 
  292. <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'evolve'); ?></label> 
  293. <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>"/> 
  294. </p> 
  295.  
  296. <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea> 
  297.  
  298. <?php 
  299.  
  300.  
  301. function evolve_carousel_init() { 
  302. register_widget('evolve_carousel_WP_Widget'); 
  303.  
  304. add_action('widgets_init', 'evolve_carousel_init', 1); 
.