PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
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 / content-restriction-start / content-restriction-start.php

content-restriction-start.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at assets/misc/divi/includes/modules/content-restriction-start/content-restriction-start.php

145 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WPPB_Content_Restriction_Start extends ET_Builder_Module {
4
5 public $slug = 'wppb_content_restriction_start';
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 Content Restriction Start', 'profile-builder' );
16
17 $this->settings_modal_toggles = array(
18 'general' => array(
19 'toggles' => array(
20 'main_content' => esc_html__( 'Module 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 if (!function_exists('get_editable_roles')) {
34 require_once ABSPATH . 'wp-admin/includes/user.php';
35 }
36 $user_roles ['default'] = esc_html__( 'All' , 'profile-builder' );
37 $editable_roles = get_editable_roles();
38 foreach ($editable_roles as $key => $role) {
39 $user_roles [$key] = $role['name'];
40 }
41
42 $fields_list['wppb_display_to'] = array(
43 'label' => esc_html__( 'Show content to', 'profile-builder' ),
44 'description' => esc_html__( 'The users you wish to see the content.', 'profile-builder' ),
45 'type' => 'select',
46 'options' => array(
47 'all' => esc_html__( 'All', 'profile-builder' ),
48 'logged_in' => esc_html__( 'Logged in', 'profile-builder' ),
49 'not_logged_in' => esc_html__( 'Not logged in', 'profile-builder' ),
50 ),
51 'default' => 'all',
52 'option_category' => 'basic_option',
53 'toggle_slug' => 'main_content',
54 );
55 $fields_list['wppb_user_roles'] = array(
56 'label' => esc_html__( 'User Roles', 'profile-builder' ),
57 'description' => esc_html__( 'The desired valid user roles. Select none for all roles to be valid.', 'profile-builder' ),
58 'type' => 'select',
59 'options' => $user_roles,
60 'default' => 'default',
61 'option_category' => 'basic_option',
62 'toggle_slug' => 'main_content',
63 'show_if' => array(
64 'wppb_display_to' => 'logged_in',
65 ),
66 );
67 $fields_list['wppb_users_ids'] = array(
68 'label' => esc_html__( 'User IDs', 'profile-builder' ),
69 'description' => esc_html__( 'A comma-separated list of user IDs.', 'profile-builder' ),
70 'type' => 'text',
71 'option_category' => 'basic_option',
72 'toggle_slug' => 'main_content',
73 'show_if' => array(
74 'wppb_display_to' => 'logged_in',
75 ),
76 );
77 $fields_list['wppb_toggle_message'] = array(
78 'label' => esc_html__( 'Enable Message', 'profile-builder' ),
79 'description' => esc_html__( 'Show the Message defined in the Profile Builder Settings.', 'profile-builder' ),
80 'type' => 'yes_no_button',
81 'options' => array(
82 'on' => esc_html__( 'Yes', 'profile-builder'),
83 'off' => esc_html__( 'No', 'profile-builder'),
84 ),
85 'option_category' => 'basic_option',
86 'toggle_slug' => 'main_content',
87 'show_if_not' => array(
88 'wppb_display_to' => 'all',
89 ),
90 );
91 $fields_list['wppb_toggle_custom_message'] = array(
92 'label' => esc_html__( 'Custom Message', 'profile-builder' ),
93 'description' => esc_html__( 'Enable Custom Message.', 'profile-builder' ),
94 'type' => 'yes_no_button',
95 'options' => array(
96 'on' => esc_html__( 'Yes', 'profile-builder'),
97 'off' => esc_html__( 'No', 'profile-builder'),
98 ),
99 'option_category' => 'basic_option',
100 'toggle_slug' => 'main_content',
101 'show_if_not' => array(
102 'wppb_display_to' => 'all',
103 ),
104 'show_if' => array(
105 'wppb_toggle_message' => 'on',
106 ),
107 );
108 $fields_list['wppb_message_logged_in'] = array(
109 'label' => esc_html__( 'Custom message', 'profile-builder' ),
110 'description' => esc_html__( 'Enter the custom message you wish the restricted users to see.', 'profile-builder' ),
111 'type' => 'text',
112 'option_category' => 'basic_option',
113 'toggle_slug' => 'main_content',
114 'show_if' => array(
115 'wppb_toggle_message' => 'on',
116 'wppb_toggle_custom_message' => 'on',
117 'wppb_display_to' => 'logged_in',
118 ),
119 );
120 $fields_list['wppb_message_logged_out'] = array(
121 'label' => esc_html__( 'Custom message', 'profile-builder' ),
122 'description' => esc_html__( 'Custom message for logged-out users.', 'profile-builder' ),
123 'type' => 'text',
124 'option_category' => 'basic_option',
125 'toggle_slug' => 'main_content',
126 'show_if' => array(
127 'wppb_toggle_message' => 'on',
128 'wppb_toggle_custom_message' => 'on',
129 'wppb_display_to' => 'not_logged_in',
130 ),
131 );
132 return $fields_list;
133 }
134
135 public function render( $attrs, $content, $render_slug ) {
136 return;
137 }
138 }
139
140 global $content_restriction_activated;
141 global $wp_version;
142 if ( isset( $content_restriction_activated ) && $content_restriction_activated == 'yes' && version_compare( $wp_version, "5.0.0", ">=" ) ) {
143 new WPPB_Content_Restriction_Start;
144 }
145