Advertisement
rdusnr

Untitled

Jul 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. <?php
  2. namespace Elementor;
  3.  
  4. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  5.  
  6. class ElementorProfileSearch extends Widget_Base {
  7.  
  8. public function get_name() {
  9. return 'profile-search';
  10. }
  11. public function get_title() {
  12. return __( 'Profile Search', 'kleo_framework' );
  13. }
  14. public function get_icon() {
  15. return 'eicon-person';
  16. }
  17. public function get_categories() {
  18. return [ 'sweetdate-elements' ];
  19. }
  20.  
  21. public function get_forms() {
  22. $data = [];
  23. $query = new \WP_Query( array( 'post_type' => 'bps_form') );
  24.  
  25. while ( $query->have_posts() ) : $query->the_post();
  26. $data[ get_the_ID() ] = get_the_title();
  27. endwhile;
  28. wp_reset_postdata();
  29.  
  30. return $data;
  31.  
  32. }
  33.  
  34. protected function _register_controls() {
  35.  
  36. $this->start_controls_section(
  37. 'section_profile_search',
  38. [
  39. 'label' => __( 'Settings', 'kleo_framework' ),
  40. ]
  41. );
  42.  
  43. $this->add_control(
  44. 'form',
  45. [
  46. 'label' => __( 'Form', 'kleo_framework' ),
  47. 'type' => Controls_Manager::SELECT2,
  48. 'options' => $this->get_forms(),
  49. 'default' => 'all',
  50. ]
  51. );
  52.  
  53. $this->add_control(
  54. 'profiles',
  55. [
  56. 'label' => __( 'Show Profiles', 'kleo_framework' ),
  57. 'type' => Controls_Manager::SWITCHER,
  58. 'label_off' => __( 'No', 'kleo_framework' ),
  59. 'label_on' => __( 'Yes', 'kleo_framework' ),
  60. 'default' => '1',
  61. 'return_value' => '1'
  62. ]
  63. );
  64.  
  65. $this->add_control(
  66. 'details',
  67. [
  68. 'label' => __( 'Details', 'kleo_framework' ),
  69. 'type' => Controls_Manager::WYSIWYG,
  70. 'default' => __( 'Serious dating with <strong>Sweet date</strong>.<br>Your perfect match is just a click away', 'kleo_framework' ),
  71. ]
  72. );
  73.  
  74. $this->add_group_control(
  75. Group_Control_Typography::get_type(),
  76. [
  77. 'name' => 'typography',
  78. 'label' => __( 'Typography', 'elementor' ),
  79. 'scheme' => Scheme_Typography::TYPOGRAPHY_4,
  80. 'selector' => '{{WRAPPER}} .form-header, {{WRAPPER}} .form-header p',
  81. ]
  82. );
  83.  
  84. $this->add_control(
  85. 'visibility',
  86. [
  87. 'label' => __( 'Visibility', 'kleo_framework' ),
  88. 'type' => Controls_Manager::SELECT2,
  89. 'options' => [
  90. 'all' => 'Everyone',
  91. 'logged-in' => 'Logged-in Users',
  92. 'guest' => 'Guest users'
  93. ],
  94. 'default' => 'all',
  95. ]
  96. );
  97.  
  98. $this->end_controls_section();
  99.  
  100. }
  101. protected function render() {
  102. $settings = $this->get_settings();
  103. if ( $settings['visibility'] == '' || $settings['visibility'] == 'all'
  104. || ( $settings['visibility'] =='logged-in' && is_user_logged_in() )
  105. || ( $settings['visibility'] == 'guest' && ! is_user_logged_in() )
  106. ) {
  107.  
  108. if ( $settings['form'] ) {
  109. $shortcode = sprintf( '[bps_display form=%s]', $settings['form']);
  110. } else {
  111. $shortcode = '';
  112. }
  113. $class = '';
  114. if ( ! $settings['profiles'] ) {
  115. $class .= ' hide-notch';
  116. }
  117.  
  118. echo '<div class="form-wrapper' . $class . '">';
  119.  
  120. echo '<div class="form-header">';
  121. echo $settings['details'];
  122. echo '</div>';
  123.  
  124. echo do_shortcode( $shortcode );
  125. if ( $settings['profiles'] ) {
  126. echo '<div class="form-footer">';
  127. do_action('kleo_bps_before_carousel');
  128. echo do_shortcode('[kleo_members_carousel]');
  129. echo '</div>';
  130. }
  131.  
  132. echo '</div>';
  133.  
  134. } elseif ( Plugin::$instance->editor->is_edit_mode() ) {
  135. echo '<div class="make-me-visible">Search Form. Visibility setting is preventing this to show element!</div>';
  136. }
  137. }
  138.  
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement