PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.1
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.1
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / assets / misc / divi / includes / modules / user-listing / user-listing.php

user-listing.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.1, at assets/misc/divi/includes/modules/user-listing/user-listing.php

149 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WPPB_UserListing extends ET_Builder_Module {
4
5 public $slug = 'wppb_userlisting';
6 public $vb_support = 'on';
7
8 protected $module_credits = array(
9 'module_uri' => 'https://wordpress.org/plugins/profile-builder/',
10 'author' => 'Cozmoslabs',
11 'author_uri' => 'https://www.cozmoslabs.com/',
12 );
13
14 public function init() {
15 $this->name = esc_html__( 'PB User Listing', 'profile-builder' );
16
17 $this->settings_modal_toggles = array(
18 'general' => array(
19 'toggles' => array(
20 'main_content' => esc_html__( 'Form Settings', 'profile-builder' ),
21 ),
22 ),
23 );
24
25 $this->advanced_fields = array(
26 'link_options' => false,
27 'background' => false,
28 'admin_label' => false,
29 );
30 }
31
32 public function get_fields() {
33
34 // get UL names
35 $ul_names = wppb_get_userlisting_names();
36 $default_key = 'default';
37 $ul_names [ $default_key ] = 'Select a User Listing form';
38 $ul_default_key = is_null( key($ul_names) ) ? '' : key($ul_names);
39
40 // get fields
41 $wppb_manage_fields = get_option( 'wppb_manage_fields', 'not_found' );
42 $field_names = array();
43 $field_names [ $default_key ] = 'None';
44 foreach( $wppb_manage_fields as $value ) {
45 if ( $value['meta-name'] !== '' ) {
46 $field_names[ $value['meta-name'] ] = $value['field-title'];
47 }
48 }
49
50 return array(
51 'userlisting_name' => array(
52 'label' => esc_html__( 'Form', 'profile-builder' ),
53 'type' => 'select',
54 'options' => $ul_names,
55 'default' => $default_key,
56 'option_category' => 'basic_option',
57 'description' => esc_html__( 'Select the desired User Listing form.', 'profile-builder' ),
58 'toggle_slug' => 'main_content',
59 ),
60 'toggle_single' => array(
61 'label' => esc_html__( 'Single-Userlisting', 'profile-builder' ),
62 'type' => 'yes_no_button',
63 'options' => array(
64 'on' => esc_html__( 'Yes', 'profile-builder'),
65 'off' => esc_html__( 'No', 'profile-builder'),
66 ),
67 'default' => 'off',
68 'option_category' => 'basic_option',
69 'description' => esc_html__( 'Use the Single-Userlisting template.', 'profile-builder' ),
70 'toggle_slug' => 'main_content',
71 ),
72 'single_id' => array(
73 'label' => esc_html__( 'ID', 'profile-builder' ),
74 'type' => 'text',
75 'option_category' => 'basic_option',
76 'description' => esc_html__( 'Input User ID.', 'profile-builder' ),
77 'toggle_slug' => 'main_content',
78 'show_if' => array(
79 'toggle_single' => 'on',
80 ),
81 ),
82 'field_name' => array(
83 'label' => esc_html__( 'Field Name', 'profile-builder' ),
84 'type' => 'select',
85 'options' => $field_names,
86 'default' => $default_key,
87 'option_category' => 'basic_option',
88 'description' => esc_html__( 'Select the desired Field Name.', 'profile-builder' ),
89 'toggle_slug' => 'main_content',
90 'show_if' => array(
91 'toggle_single' => 'off',
92 ),
93 ),
94 'meta_value' => array(
95 'label' => esc_html__( 'Field Value', 'profile-builder' ),
96 'type' => 'text',
97 'option_category' => 'basic_option',
98 'description' => esc_html__( 'Input the desired Field Value.', 'profile-builder' ),
99 'toggle_slug' => 'main_content',
100 'show_if' => array(
101 'toggle_single' => 'off',
102 ),
103 ),
104 'include_id' => array(
105 'label' => esc_html__( 'Include', 'profile-builder' ),
106 'type' => 'text',
107 'option_category' => 'basic_option',
108 'description' => esc_html__( 'Input User IDs for users you wish to display.', 'profile-builder' ),
109 'toggle_slug' => 'main_content',
110 'show_if' => array(
111 'toggle_single' => 'off',
112 ),
113 ),
114 'exclude_id' => array(
115 'label' => esc_html__( 'Exclude', 'profile-builder' ),
116 'type' => 'text',
117 'option_category' => 'basic_option',
118 'description' => esc_html__( 'Input User IDs for users you wish to hide.', 'profile-builder' ),
119 'toggle_slug' => 'main_content',
120 'show_if' => array(
121 'toggle_single' => 'off',
122 ),
123 ),
124 );
125 }
126
127 public function render( $attrs, $content, $render_slug ) {
128
129 if ( !is_array( $attrs ) || !array_key_exists( 'userlisting_name', $attrs ) ) {
130 return;
131 }
132
133 include_once( WPPB_PAID_PLUGIN_DIR.'/add-ons/user-listing/userlisting.php' );
134
135 $atts = [
136 'name' => sanitize_text_field($attrs['userlisting_name']),
137 '0' => array_key_exists( 'toggle_single', $attrs ) && $attrs['toggle_single'] === 'on' ? 'single' : '',
138 'id' => array_key_exists( 'single_id', $attrs ) ? absint($attrs['single_id']) : '',
139 'meta_key' => array_key_exists( 'meta_key', $attrs ) && $attrs['meta_key'] !== 'default' ? sanitize_text_field($attrs['meta_key']) : '',
140 'meta_value' => array_key_exists( 'meta_value', $attrs ) && $attrs['meta_value'] !== 'default' ? sanitize_text_field($attrs['meta_value']) : '',
141 'include' => array_key_exists( 'include_id', $attrs ) ? pb_divi_parse_ids($attrs['include_id']) : '',
142 'exclude' => array_key_exists( 'exclude_id', $attrs ) ? pb_divi_parse_ids($attrs['exclude_id']) : '',
143 ];
144 return '<div class="wppb-divi-front-end-container">' . wppb_user_listing_shortcode( $atts ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
145 }
146 }
147
148 new WPPB_UserListing;
149