PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.34
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.34
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / admin / settings / class-uwp-settings-redirects.php

class-uwp-settings-redirects.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.34, at admin/settings/class-uwp-settings-redirects.php

174 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * UsersWP Redirects Settings
4 *
5 * @author AyeCode
6 * @category Admin
7 * @package userswp/Admin
8 * @version 1.2.3
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly
13 }
14
15 if ( ! class_exists( 'UsersWP_Settings_Redirects', false ) ) :
16
17 /**
18 * UsersWP_Settings_Redirects.
19 */
20 class UsersWP_Settings_Redirects extends UsersWP_Settings_Page {
21
22 /**
23 * Constructor.
24 */
25 public function __construct() {
26
27 $this->id = 'redirects';
28 $this->label = __( 'Redirects', 'userswp' );
29
30 add_filter( 'uwp_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
31 add_action( 'uwp_settings_' . $this->id, array( $this, 'output' ) );
32 add_action( 'uwp_sections_' . $this->id, array( $this, 'output_toggle_advanced' ) );
33 add_action( 'uwp_settings_save_' . $this->id, array( $this, 'save' ) );
34 add_action( 'uwp_sections_' . $this->id, array( $this, 'output_sections' ) );
35
36
37 }
38
39 /**
40 * Output the settings.
41 */
42 public function output() {
43 global $current_section;
44
45 $settings = $this->get_settings( $current_section );
46
47 UsersWP_Admin_Settings::output_fields( $settings );
48 }
49
50
51 /**
52 * Save settings.
53 */
54 public function save() {
55 global $current_section;
56
57 $settings = $this->get_settings( $current_section );
58 UsersWP_Admin_Settings::save_fields( $settings );
59 }
60
61 /**
62 * Get sections.
63 *
64 * @return array
65 */
66 public function get_sections() {
67
68 $sections = array(
69 '' => __( 'Role based redirects', 'userswp' ),
70 );
71
72 return apply_filters( 'uwp_get_sections_' . $this->id, $sections );
73 }
74
75 /**
76 * Get redirects settings array.
77 *
78 * @return array
79 */
80 public function get_settings( $current_section = '' ) {
81 /**
82 * Filter pages settings array.
83 *
84 * @package userswp
85 */
86
87 global $wp_roles;
88
89 $pages = get_pages(); $desc = '';
90 $pages_options = array(
91 '-1' => __( 'Last User Page', 'userswp' ),
92 '0' => __( 'Default Redirect', 'userswp'),
93 '-2' => __( 'Custom Redirect', 'userswp'),
94 );
95 if ( $pages ) {
96 foreach ( $pages as $page ) {
97 $pages_options[ $page->ID ] = $page->post_title;
98 }
99 }
100
101 if ( - 1 == uwp_get_option( 'login_redirect_to' ) ) {
102 $desc = '<div class="bsui">' . aui()->alert( array(
103 'type' => 'error',
104 'content' => __( 'Login redirect based on user role will not work if "Last User Page" is set in General->Login->Login Redirect Page.', 'userswp' )
105 ) ) . '</div>';
106 }
107
108 $settings_array = array(
109 array(
110 'title' => __( 'Role based redirect settings', 'userswp' ),
111 'type' => 'title',
112 'desc' => $desc,
113 'id' => 'redirects_options',
114 ),
115 );
116 if(isset($wp_roles->roles) && !empty($wp_roles->roles)){
117 foreach ($wp_roles->roles as $key => $value){
118 $role_label = $value['name'];
119 $settings_array[] = array(
120 'title' => $role_label,
121 'type' => 'title',
122 'id' => 'role_name_'.$key,
123 );
124 $settings_array[] = array(
125 'id' => 'login_redirect_to_'.$key,
126 'name' => __( 'Login Redirect Page', 'userswp' ),
127 'desc' => __( 'Set the page to redirect the user to after logging in. If default redirect has been set then WordPress default will be used.', 'userswp' ),
128 'type' => 'select',
129 'options' => $pages_options,
130 'default' => '-1',
131 'desc_tip' => true,
132 );
133
134 $settings_array[] = array(
135 'id' => 'login_redirect_custom_url_'.$key,
136 'name' => __( 'Redirect Custom URL', 'userswp' ),
137 'desc' => __( 'Set the custom url to redirect the user to after logging in.', 'userswp' ),
138 'type' => 'text',
139 'default' => '',
140 'desc_tip' => true,
141 'class' => 'uwp-login-redirect-custom-url',
142 );
143
144 $settings_array[] = array(
145 'id' => 'logout_redirect_to_'.$key,
146 'name' => __( 'Logout Redirect Page', 'userswp' ),
147 'desc' => __( 'Set the page to redirect the user to after logging out. If no page has been set WordPress default will be used.', 'userswp' ),
148 'type' => 'single_select_page',
149 'desc_tip' => true,
150 );
151
152 $settings_array[] = array(
153 'id' => 'hide_admin_bar_'.$key,
154 'name' => __( 'Hide Admin Bar', 'userswp' ),
155 'desc' => __('Hide admin bar from frontend for this user role.','userswp' ),
156 'type' => 'checkbox',
157 'default' => '0',
158 );
159
160 $settings_array[] = array( 'type' => 'sectionend', 'id' => 'role_name_'.$key );
161 }
162 }
163
164 $settings_array[] = array( 'type' => 'sectionend', 'id' => 'redirects_options' );
165
166 $settings = apply_filters( 'uwp_redirects_options', $settings_array);
167
168 return apply_filters( 'uwp_get_settings_' . $this->id, $settings );
169 }
170 }
171
172 endif;
173
174 return new UsersWP_Settings_Redirects();