PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.5
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.5
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 / edit-profile / edit-profile.php

edit-profile.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.5, at assets/misc/divi/includes/modules/edit-profile/edit-profile.php

144 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WPPB_EditProfile extends ET_Builder_Module {
4
5 public $slug = 'wppb_edit_profile';
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 Edit Profile', '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 $args = array(
34 'post_type' => 'page',
35 'posts_per_page' => -1
36 );
37
38 if( function_exists( 'wc_get_page_id' ) )
39 $args['exclude'] = wc_get_page_id( 'shop' );
40
41 $all_pages = get_posts( $args );
42 $pages ['default'] = 'None';
43
44 if( !empty( $all_pages ) ){
45 foreach ( $all_pages as $page ){
46 $pages [ esc_url( get_page_link( $page->ID ) ) ] = esc_html( $page->post_title );
47 }
48 }
49
50 $wppb_module_settings = get_option( 'wppb_module_settings', 'not_found' );
51
52 $edit_profile_forms ['default'] = esc_html__( 'Default' , 'profile-builder' );
53
54 if ( !( ( $wppb_module_settings !== 'not_found' && (
55 !isset( $wppb_module_settings['wppb_multipleRegistrationForms'] ) ||
56 $wppb_module_settings['wppb_multipleRegistrationForms'] !== 'show'
57 ) ) ||
58 $wppb_module_settings === 'not_found' ) ){
59 $args = array(
60 'post_type' => 'wppb-epf-cpt',
61 'posts_per_page' => -1
62 );
63
64 $the_query = new WP_Query( $args );
65
66 if ( $the_query->have_posts() ) {
67 foreach ( $the_query->posts as $post ) {
68 $edit_profile_forms [esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $post->post_title ) )] = esc_html( $post->post_title );
69 }
70 wp_reset_postdata();
71 }
72 }
73
74 $fields = array(
75 'form_name' => array(
76 'label' => esc_html__( 'Form', 'profile-builder' ),
77 'type' => 'select',
78 'options' => $edit_profile_forms,
79 'default' => 'default',
80 'option_category' => 'basic_option',
81 'description' => esc_html__( 'Select the desired Edit Profile form.', 'profile-builder' ),
82 'toggle_slug' => 'main_content',
83 ),
84 'redirect_url' => array(
85 'label' => esc_html__( 'Redirect After Edit Profile', 'profile-builder' ),
86 'type' => 'select',
87 'options' => $pages,
88 'default' => 'default',
89 'option_category' => 'basic_option',
90 'description' => esc_html__( 'Select a page for an After Edit Profile Redirect.', 'profile-builder' ),
91 'toggle_slug' => 'main_content',
92 'show_if' => array(
93 'form_name' => 'default',
94 ),
95 ),
96 );
97
98 if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ) {
99 $fields['toggle_ajax_validation'] = array(
100 'label' => esc_html__( 'AJAX Validation', 'profile-builder' ),
101 'type' => 'yes_no_button',
102 'options' => array(
103 'on' => esc_html__( 'Yes', 'profile-builder'),
104 'off' => esc_html__( 'No', 'profile-builder'),
105 ),
106 'option_category' => 'basic_option',
107 'description' => esc_html__( 'Use AJAX to Validate the Edit Profile Form without reloading the page.', 'profile-builder' ),
108 'toggle_slug' => 'main_content',
109 'show_if' => array(
110 'form_name' => 'default',
111 ),
112 );
113 }
114
115 return $fields;
116 }
117
118 public function render( $attrs, $content, $render_slug ) {
119
120 if ( !is_array( $attrs ) ) {
121 return;
122 }
123
124 include_once(WPPB_PLUGIN_DIR . '/front-end/edit-profile.php');
125 include_once(WPPB_PLUGIN_DIR . '/front-end/class-formbuilder.php');
126
127 $form_name = 'unspecified';
128 if ( is_array( $attrs ) && array_key_exists( 'form_name', $attrs ) ) {
129 $form_name = sanitize_text_field($attrs['form_name']);
130 if ( $form_name === 'default' ) {
131 $form_name = 'unspecified';
132 }
133 }
134 $atts = [
135 'form_name' => $form_name,
136 'redirect_url' => is_array( $attrs ) && array_key_exists( 'redirect_url', $attrs ) && $attrs['redirect_url'] !== '' ? pb_divi_parse_url( $attrs['redirect_url'] ) : '',
137 'ajax' => ( $form_name === 'unspecified' && is_array( $attrs ) && array_key_exists( 'toggle_ajax_validation', $attrs ) && $attrs['toggle_ajax_validation'] === 'on' ) ? 'true' : false,
138 ];
139 return '<div class="wppb-divi-front-end-container">' . wppb_front_end_profile_info( $atts ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
140 }
141 }
142
143 new WPPB_EditProfile;
144