PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.8.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.8.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 2.0.7 All 340 releases
profile-builder / admin / private-website.php

private-website.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.8.3, at admin/private-website.php

172 lines 10.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3 /**
4 * Function that creates the "Private Website" submenu page
5 *
6 * @since v.2.0
7 *
8 * @return void
9 */
10 function wppb_private_website_submenu_page() {
11 add_submenu_page( null, __( 'Private Website', 'profile-builder' ), __( 'Private Website', 'profile-builder' ), 'manage_options', 'profile-builder-private-website', 'wppb_private_website_content' );
12 }
13 add_action( 'admin_menu', 'wppb_private_website_submenu_page' );
14
15
16 /**
17 * Function that generates the default settings for private page
18 */
19 function wppb_private_website_settings_defaults() {
20
21 add_option( 'wppb_private_website_settings',
22 array(
23 'private_website' => 'no',
24 'redirect_to' => '',
25 'allowed_pages' => array(),
26 'hide_menus' => 'no',
27 'disable_rest_api' => 'yes',
28 )
29 );
30
31 }
32
33 /**
34 * Function that generates the content for the settings page
35 */
36 function wppb_private_website_content() {
37
38 wppb_private_website_settings_defaults();
39
40 $wppb_private_website_settings = get_option( 'wppb_private_website_settings', 'not_found' );
41
42 $args = array(
43 'post_type' => 'page',
44 'posts_per_page' => -1
45 );
46
47 if( function_exists( 'wc_get_page_id' ) )
48 $args['exclude'] = wc_get_page_id( 'shop' );
49
50 $all_pages = get_posts( $args );
51 ?>
52 <div class="wrap wppb-wrap wppb-private-website">
53 <h2>
54 <?php esc_html_e( 'Private Website Settings', 'profile-builder' );?>
55 <a href="https://www.cozmoslabs.com/docs/profile-builder-2/general-settings/private-website/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>
56 </h2>
57
58 <?php settings_errors(); ?>
59
60 <?php wppb_generate_settings_tabs() ?>
61
62 <form method="post" action="options.php">
63 <?php settings_fields( 'wppb_private_website_settings' ); ?>
64
65 <table class="form-table">
66 <tbody>
67
68 <tr>
69 <th><?php esc_html_e( 'Enable Private Website', 'profile-builder' ); ?></th>
70 <td>
71 <select id="private-website-enable" class="wppb-select" name="wppb_private_website_settings[private_website]">
72 <option value="no" <?php echo ( ( $wppb_private_website_settings != 'not_found' && $wppb_private_website_settings['private_website'] == 'no' ) ? 'selected' : '' ); ?>><?php esc_html_e( 'No', 'profile-builder' ); ?></option>
73 <option value="yes" <?php echo ( ( $wppb_private_website_settings != 'not_found' && $wppb_private_website_settings['private_website'] == 'yes' ) ? 'selected' : '' ); ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option>
74 </select>
75 <ul>
76 <li class="description"><?php esc_html_e( 'Activate Private Website. It will restrict the content, RSS and REST API for your website', 'profile-builder' ); ?></li>
77 </ul>
78 </td>
79 </tr>
80
81 <tr>
82 <th><?php esc_html_e( 'Redirect to', 'profile-builder' ); ?></th>
83 <td>
84 <select id="private-website-redirect-to-login" class="wppb-select" name="wppb_private_website_settings[redirect_to]">
85 <option value=""><?php esc_html_e( 'Default WordPress login page', 'profile-builder' ); ?></option>
86 <?php
87 if( !empty( $all_pages ) ){
88 foreach ($all_pages as $page){
89 ?>
90 <option value="<?php echo esc_attr( $page->ID ) ?>" <?php echo ( ( $wppb_private_website_settings != 'not_found' && isset( $wppb_private_website_settings['redirect_to'] ) && $wppb_private_website_settings['redirect_to'] == $page->ID ) ? 'selected' : '' ); ?>><?php echo esc_html( $page->post_title ) ?></option>
91 <?php
92 }
93 }
94 ?>
95
96 </select>
97 <ul>
98 <li class="description"><?php esc_html_e( 'Redirects to this page if not logged in. We recommend this page contains the [wppb-login] shortcode.', 'profile-builder' ); ?></li>
99 <li class="description"><?php esc_html_e( 'You can force access to wp-login.php so you don\'t get locked out of the site by accessing the link:', 'profile-builder' ); ?> <a href="<?php echo esc_url( wp_login_url() ).'?wppb_force_wp_login=true' ?>"><?php echo esc_url( wp_login_url() ).'?wppb_force_wp_login=true' ?></a></li>
100 </ul>
101 </td>
102 </tr>
103
104 <tr>
105 <th><?php esc_html_e( 'Allowed Pages', 'profile-builder' ); ?></th>
106 <td>
107 <select id="private-website-allowed-pages" class="wppb-select" name="wppb_private_website_settings[allowed_pages][]" multiple="multiple">
108 <?php
109 if( !empty( $all_pages ) ){
110 foreach ($all_pages as $page){
111 ?>
112 <option value="<?php echo esc_attr( $page->ID ) ?>" <?php echo ( ( $wppb_private_website_settings != 'not_found' && isset( $wppb_private_website_settings['allowed_pages'] ) && in_array( $page->ID, $wppb_private_website_settings['allowed_pages'] ) ) ? 'selected' : '' ); ?>><?php echo esc_html( $page->post_title ) ?></option>
113 <?php
114 }
115 }
116 ?>
117
118 </select>
119 <ul>
120 <li class="description"><?php esc_html_e( 'Allow these pages to be accessed even if you are not logged in', 'profile-builder' ); ?></li>
121 </ul>
122 </td>
123 </tr>
124
125 <tr>
126 <th><?php esc_html_e( 'Allowed Paths', 'profile-builder' ); ?></th>
127 <td>
128 <textarea id="private-website-allowed-paths" class="wppb-textarea" name="wppb_private_website_settings[allowed_paths]"><?php echo ( ( $wppb_private_website_settings != 'not_found' && !empty($wppb_private_website_settings['allowed_paths']) ) ? esc_textarea( $wppb_private_website_settings['allowed_paths'] ) : '' ); ?></textarea>
129 <ul>
130 <li class="description"><?php esc_html_e( 'Allow these paths to be accessed even if you are not logged in (supports wildcard at the end of the path). For example to exclude https://example.com/some/path/ you can either use the rule /some/path/ or /some/* Enter each rule on it\'s own line', 'profile-builder' ); ?></li>
131 </ul>
132 </td>
133 </tr>
134
135 <tr>
136 <th><?php esc_html_e( 'Hide all Menus', 'profile-builder' ); ?></th>
137 <td>
138 <select id="private-website-menu-hide" class="wppb-select" name="wppb_private_website_settings[hide_menus]">
139 <option value="no" <?php echo ( ( $wppb_private_website_settings != 'not_found' && !empty($wppb_private_website_settings['hide_menus']) && $wppb_private_website_settings['hide_menus'] == 'no' ) ? 'selected' : '' ); ?>><?php esc_html_e( 'No', 'profile-builder' ); ?></option>
140 <option value="yes" <?php echo ( ( $wppb_private_website_settings != 'not_found' && !empty($wppb_private_website_settings['hide_menus']) && $wppb_private_website_settings['hide_menus'] == 'yes' ) ? 'selected' : '' ); ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option>
141 </select>
142 <ul>
143 <li class="description"><?php esc_html_e( 'Hide all menu items if you are not logged in.', 'profile-builder' ); ?></li>
144 <li class="description"><?php wp_kses_post( printf( __( 'We recommend "<a href="%s" target="_blank">Custom Profile Menus</a>" addon if you need different menu items for logged in / logged out users.', 'profile-builder' ), 'https://www.cozmoslabs.com/add-ons/custom-profile-menus/' ) ) //phpcs:ignore; ?></li>
145 </ul>
146 </td>
147 </tr>
148
149 <tr>
150 <th><?php esc_html_e( 'Disable REST-API', 'profile-builder' ); ?></th>
151 <td>
152 <select id="private-website-disable-rest-api" class="wppb-select" name="wppb_private_website_settings[disable_rest_api]">
153 <option value="yes" <?php selected ( ( $wppb_private_website_settings != 'not_found' && ( !isset( $wppb_private_website_settings[ 'disable_rest_api' ] ) || ( isset( $wppb_private_website_settings[ 'disable_rest_api' ] ) && $wppb_private_website_settings[ 'disable_rest_api' ] == 'yes' ) ) ), true ); ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option>
154 <option value="no" <?php selected ( ( $wppb_private_website_settings != 'not_found' && isset( $wppb_private_website_settings[ 'disable_rest_api' ] ) && $wppb_private_website_settings[ 'disable_rest_api' ] == 'no' ), true ); ?>><?php esc_html_e( 'No', 'profile-builder' ); ?></option>
155 </select>
156 <ul>
157 <li class="description"><?php esc_html_e( 'Disable the WordPress REST-API for non-logged in users when Private Website is enabled', 'profile-builder' ); ?></li>
158 </ul>
159 </td>
160 </tr>
161
162 </tbody>
163 </table>
164
165 <?php submit_button( esc_html__( 'Save Changes', 'profile-builder' ) ); ?>
166 </form>
167
168
169 </div>
170 <?php
171 }
172