PageRenderTime 44ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/accesspress-basic/inc/apbasic-widgets.php

https://gitlab.com/pornmongkon.p/wordpress
PHP | 273 lines | 169 code | 32 blank | 72 comment | 5 complexity | eec7b0a7714d75f7081e7b0c2d567455 MD5 | raw file
  1. <?php
  2. /**
  3. *
  4. * AccessPress Basic Custom Sidebar
  5. * For Widgets
  6. *
  7. */
  8. add_action('widgets_init','accesspress_basic_additional_widgets');
  9. function accesspress_basic_additional_widgets(){
  10. // Registering main right sidebar
  11. register_sidebar( array(
  12. 'name' => __( 'Right Sidebar', 'accesspress-basic' ),
  13. 'id' => 'apbasic_right_sidebar',
  14. 'description' => __( 'Shows widgets at Right side.', 'accesspress-basic' ),
  15. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  16. 'after_widget' => '</aside>',
  17. 'before_title' => '<h3 class="widget-title"><span>',
  18. 'after_title' => '</span></h3>'
  19. ) );
  20. // Registering main left sidebar
  21. register_sidebar( array(
  22. 'name' => __( 'Left Sidebar', 'accesspress-basic' ),
  23. 'id' => 'apbasic_left_sidebar',
  24. 'description' => __( 'Shows widgets at Left side.', 'accesspress-basic' ),
  25. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  26. 'after_widget' => '</aside>',
  27. 'before_title' => '<h3 class="widget-title"><span>',
  28. 'after_title' => '</span></h3>'
  29. ) );
  30. // Registering featured section
  31. register_sidebar( array(
  32. 'name' => __( 'Featured Section', 'accesspress-basic' ),
  33. 'id' => 'apbasic_featured_section',
  34. 'description' => __( 'Shows widgets at Featured Post.', 'accesspress-basic' ),
  35. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  36. 'after_widget' => '</aside>',
  37. 'before_title' => '<h3 class="widget-title"><span>',
  38. 'after_title' => '</span></h3>'
  39. ) );
  40. // Registering call to action section
  41. register_sidebar( array(
  42. 'name' => __( 'Call To Action Section', 'accesspress-basic' ),
  43. 'id' => 'apbasic_cta_section',
  44. 'description' => __( 'Shows widgets at Call To Action.', 'accesspress-basic' ),
  45. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  46. 'after_widget' => '</aside>',
  47. 'before_title' => '<h3 class="widget-title"><span>',
  48. 'after_title' => '</span></h3>'
  49. ) );
  50. // Registering testimonial section
  51. register_sidebar( array(
  52. 'name' => __( 'Icon Text Block Section', 'accesspress-basic' ),
  53. 'id' => 'icon_text_block_section',
  54. 'description' => __( 'Shows widgets at Icon Text Block Section.', 'accesspress-basic' ),
  55. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  56. 'after_widget' => '</aside>',
  57. 'before_title' => '<h3 class="widget-title"><span>',
  58. 'after_title' => '</span></h3>'
  59. ) );
  60. // Registering toggle section
  61. register_sidebar( array(
  62. 'name' => __( 'Toggle Section', 'accesspress-basic' ),
  63. 'id' => 'apbasic_toggle_section',
  64. 'description' => __( 'Shows Toggles at Toggle Section.', 'accesspress-basic' ),
  65. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  66. 'after_widget' => '</aside>',
  67. 'before_title' => '<h3 class="widget-title"><span>',
  68. 'after_title' => '</span></h3>'
  69. ) );
  70. // Registering toggle section
  71. register_sidebar( array(
  72. 'name' => __( 'Featured Page Section', 'accesspress-basic' ),
  73. 'id' => 'apbasic_featured_page_section',
  74. 'description' => __( 'Shows Featured Page In Featured Page Section.', 'accesspress-basic' ),
  75. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  76. 'after_widget' => '</aside>',
  77. 'before_title' => '<h3 class="widget-title"><span>',
  78. 'after_title' => '</span></h3>'
  79. ) );
  80. // Registering testimonial section
  81. register_sidebar( array(
  82. 'name' => __( 'Testimonials Section', 'accesspress-basic' ),
  83. 'id' => 'apbasic_testimonial_section',
  84. 'description' => __( 'Shows widgets at Testimonialss.', 'accesspress-basic' ),
  85. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  86. 'after_widget' => '</aside>',
  87. 'before_title' => '<h3 class="widget-title"><span>',
  88. 'after_title' => '</span></h3>'
  89. ) );
  90. // Registering services section
  91. register_sidebar( array(
  92. 'name' => __( 'Services Section', 'accesspress-basic' ),
  93. 'id' => 'apbasic_services_section',
  94. 'description' => __( 'Shows widgets at Services.', 'accesspress-basic' ),
  95. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  96. 'after_widget' => '</aside>',
  97. 'before_title' => '<h3 class="widget-title"><span>',
  98. 'after_title' => '</span></h3>'
  99. ) );
  100. // Registering Header Text Widget
  101. register_sidebar( array(
  102. 'name' => __( 'Header Text Section', 'accesspress-basic' ),
  103. 'id' => 'apbasic_header_text',
  104. 'description' => __( 'Shows widgets at Header Text Section.', 'accesspress-basic' ),
  105. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  106. 'after_widget' => '</aside>',
  107. 'before_title' => '<h3 class="widget-title"><span>',
  108. 'after_title' => '</span></h3>'
  109. ) );
  110. // Registering Header Social Links Widget
  111. register_sidebar( array(
  112. 'name' => __( 'Header Social Links Section', 'accesspress-basic' ),
  113. 'id' => 'apbasic_header_social_links',
  114. 'description' => __( 'Shows widgets at Header Text Section.', 'accesspress-basic' ),
  115. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  116. 'after_widget' => '</aside>',
  117. 'before_title' => '<h3 class="widget-title"><span>',
  118. 'after_title' => '</span></h3>'
  119. ) );
  120. // Registering Footer Social Links Widget
  121. register_sidebar( array(
  122. 'name' => __( 'Footer Social Links Section', 'accesspress-basic' ),
  123. 'id' => 'apbasic_footer_social_links',
  124. 'description' => __( 'Shows widgets at Footer.', 'accesspress-basic' ),
  125. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  126. 'after_widget' => '</aside>',
  127. 'before_title' => '<h3 class="widget-title"><span>',
  128. 'after_title' => '</span></h3>'
  129. ) );
  130. // Registering footer one section
  131. register_sidebar( array(
  132. 'name' => __( 'Footer One', 'accesspress-basic' ),
  133. 'id' => 'apbasic_footer_one',
  134. 'description' => __( 'Shows widgets at Footer First Section .', 'accesspress-basic' ),
  135. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  136. 'after_widget' => '</aside>',
  137. 'before_title' => '<h3 class="widget-title"><span>',
  138. 'after_title' => '</span></h3>'
  139. ) );
  140. // Registering footer two section
  141. register_sidebar( array(
  142. 'name' => __( 'Footer Two', 'accesspress-basic' ),
  143. 'id' => 'apbasic_footer_two',
  144. 'description' => __( 'Shows widgets at Footer Second Section.', 'accesspress-basic' ),
  145. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  146. 'after_widget' => '</aside>',
  147. 'before_title' => '<h3 class="widget-title"><span>',
  148. 'after_title' => '</span></h3>'
  149. ) );
  150. // Registering footer three section
  151. register_sidebar( array(
  152. 'name' => __( 'Footer Three', 'accesspress-basic' ),
  153. 'id' => 'apbasic_footer_three',
  154. 'description' => __( 'Shows widgets at Footer Third Section.', 'accesspress-basic' ),
  155. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  156. 'after_widget' => '</aside>',
  157. 'before_title' => '<h3 class="widget-title"><span>',
  158. 'after_title' => '</span></h3>'
  159. ) );
  160. // Registering footer four section
  161. register_sidebar( array(
  162. 'name' => __( 'Footer Four', 'accesspress-basic' ),
  163. 'id' => 'apbasic_footer_four',
  164. 'description' => __( 'Shows widgets at Footer Fourth Section.', 'accesspress-basic' ),
  165. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  166. 'after_widget' => '</aside>',
  167. 'before_title' => '<h3 class="widget-title"><span>',
  168. 'after_title' => '</span></h3>'
  169. ) );
  170. } // END OF ACCESSPRESS BASIC REGISTER SIDEBAR FUNCTION
  171. /**
  172. * AccessPress Basic Custom Widgets
  173. *
  174. * @package Accesspress Basic
  175. */
  176. function accesspress_basic_widgets_updated_field_value( $widget_field, $new_field_value ) {
  177. extract( $widget_field );
  178. // Allow only integers in number fields
  179. if( $apbasic_widgets_field_type == 'number' ) {
  180. return absint( $new_field_value );
  181. // Allow some tags in textareas
  182. } elseif( $apbasic_widgets_field_type == 'textarea' ) {
  183. // Check if field array specifed allowed tags
  184. if( !isset( $apbasic_widgets_allowed_tags ) ) {
  185. // If not, fallback to default tags
  186. $apbasic_widgets_allowed_tags = '<p><strong><em><a>';
  187. }
  188. return strip_tags( $new_field_value, $apbasic_widgets_allowed_tags );
  189. // No allowed tags for all other fields
  190. } else {
  191. return strip_tags( $new_field_value );
  192. }
  193. }
  194. /**
  195. * Include helper functions that display widget fields in the dashboard
  196. *
  197. * @since Accesspress Widget Pack 1.0
  198. */
  199. require get_template_directory() . '/inc/widgets/widget-fields.php';
  200. /**
  201. * Register Post Preview Widget
  202. *
  203. * @since accesspress Widget Pack 1.0
  204. */
  205. require get_template_directory() . '/inc/widgets/widget-testimonials.php';
  206. /**
  207. * Register Post Feature Posts
  208. *
  209. * @since accesspress Widget Pack 1.0
  210. */
  211. require get_template_directory() . '/inc/widgets/wigets-features.php';
  212. /**
  213. * Register Post Services Posts
  214. *
  215. * @since accesspress Widget Pack 1.0
  216. */
  217. require get_template_directory() . '/inc/widgets/widgets-services.php';
  218. /**
  219. * Register Post Services Posts
  220. *
  221. * @since accesspress Widget Pack 1.0
  222. */
  223. require get_template_directory() . '/inc/widgets/widgets-cta.php';
  224. /**
  225. * Register Icon Text Block
  226. *
  227. * @since accesspress Widget Pack 1.0
  228. */
  229. require get_template_directory() . '/inc/widgets/widgets-icon-text-block.php';
  230. /**
  231. * Register Toggle
  232. *
  233. * @since accesspress Widget Pack 1.0
  234. */
  235. require get_template_directory() . '/inc/widgets/widgets-toggle.php';
  236. /**
  237. * Register Featured Page
  238. *
  239. * @since accesspress Widget Pack 1.0
  240. */
  241. require get_template_directory() . '/inc/widgets/widgets-featured-page.php';