PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.74
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.74
1.2.74 1.2.73 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 All 174 releases
← All changes | public/class-public.php +81 -152 1.0.211.2.74 View file →
@@ -1,6 +1,5 @@
1 1 <?php
2 -
3 2 /**
4 3 * The public-facing functionality of the plugin.
5 4 *
6 5 * @link http://wpgeodirectory.com
@@ -21,176 +20,106 @@
21 20 * @author GeoDirectory Team <info@wpgeodirectory.com>
22 21 */
23 22 class UsersWP_Public {
24 23
25 -
26 - /**
27 - * Register the stylesheets for the public-facing side of the site.
28 - *
29 - * @since 1.0.0
30 - */
31 - public function enqueue_styles() {
24 + /**
25 + * Register the stylesheets for the public-facing side of the site.
26 + *
27 + * @since 1.0.0
28 + */
29 + public function enqueue_styles() {
30 + // Scripts if user on own profile page.
31 + if ( is_uwp_current_user_profile_page() ) {
32 + // Include only profile pages
33 + wp_enqueue_style( 'jcrop' );
32 34
33 - /**
34 - * An instance of this class should be passed to the run() function
35 - * defined in UsersWP_Loader as all of the hooks are defined
36 - * in that particular class.
37 - *
38 - * The UsersWP_Loader will then create the relationship
39 - * between the defined hooks and the functions defined in this
40 - * class.
41 - */
42 - if (is_uwp_page()) {
43 - // include only in uwp pages
44 - wp_register_style('jquery-ui', plugin_dir_url(dirname(__FILE__)) . 'public/assets/css/jquery-ui.css');
45 - wp_enqueue_style( 'jquery-ui' );
46 - }
35 + if ( is_user_logged_in() ) {
36 + wp_enqueue_media();
37 + }
38 + }
47 39
48 - if (is_uwp_current_user_profile_page()) {
49 - // include only profile pages
50 - wp_enqueue_style( 'jcrop' );
40 + wp_register_style( 'jquery-ui', USERSWP_PLUGIN_URL . 'assets/css/jquery-ui.css' );
51 41
52 - if (is_user_logged_in()) {
53 - wp_enqueue_media();
54 - }
55 - }
42 + // maybe add bootstrap
43 + if ( empty( uwp_get_option("design_style", "bootstrap" ) ) ) {
44 + wp_enqueue_style( USERSWP_NAME, USERSWP_PLUGIN_URL . 'assets/css/users-wp.css', array(), USERSWP_VERSION, 'all' );
45 + wp_register_style( 'uwp-authorbox', USERSWP_PLUGIN_URL . 'assets/css/authorbox.css', array(), USERSWP_VERSION, 'all' );
46 + } else {
47 + //@todo this is not actually being used yet, enable when if it is.
48 + //wp_enqueue_style( "uwp", USERSWP_PLUGIN_URL . 'assets/css/bootstrap/uwp.css', array(), USERSWP_VERSION, 'all' );
49 + }
50 + }
56 51
57 - $enable_timepicker_in_register = false;
58 - $enable_timepicker_in_account = false;
52 + /**
53 + * Register the JavaScript for the public-facing side of the site.
54 + *
55 + * @since 1.0.0
56 + */
57 + public function enqueue_scripts() {
58 + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
59 + $in_footer = apply_filters( 'uwp_enqueue_scripts_in_footer', false );
59 60
60 - $enable_chosen_in_register = false;
61 - $enable_chosen_in_account = false;
61 + // Core UWP JS
62 + wp_enqueue_script( USERSWP_NAME, USERSWP_PLUGIN_URL . 'assets/js/users-wp' . $suffix . '.js', array( 'jquery' ), USERSWP_VERSION, $in_footer );
62 63
63 - if (is_uwp_register_page() || is_uwp_account_page()) {
64 - if (is_uwp_register_page()) {
65 - $fields = get_register_form_fields();
66 - } else {
67 - // account page
68 - $fields = get_account_form_fields();
69 - }
70 - if (!empty($fields)) {
71 - foreach ($fields as $field) {
72 - if ($field->field_type == 'time') {
73 - $enable_timepicker_in_register = true;
74 - }
64 + // localize
65 + $uwp_localize_data = uwp_get_localize_data();
66 + wp_localize_script( USERSWP_NAME, 'uwp_localize_data', $uwp_localize_data );
75 67
76 - if ($field->field_type == 'multiselect') {
77 - $enable_chosen_in_register = true;
78 - }
79 - }
80 - }
81 - }
82 -
68 + wp_register_script( "uwp_timepicker", USERSWP_PLUGIN_URL . 'assets/js/jquery.ui.timepicker.min.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-core' ), USERSWP_VERSION, true );
83 69
84 - if ($enable_timepicker_in_register || $enable_timepicker_in_account) {
85 - // time fields available only in register and account pages
86 - wp_enqueue_style( "uwp_timepicker_css", plugin_dir_url( __FILE__ ) . 'assets/css/jquery.ui.timepicker.css', array(), null, 'all' );
87 - }
70 + $enable_timepicker_fields = false;
71 + $enable_country_fields = false;
72 + $fields = $this->get_all_form_fields();
88 73
74 + if ( ! empty( $fields ) ) {
75 + foreach ( $fields as $field ) {
76 + if ( isset( $field->field_type ) && ( $field->field_type == 'time' || $field->field_type == 'datepicker' ) ) {
77 + $enable_timepicker_fields = true;
78 + }
89 79
90 - if ($enable_chosen_in_register || $enable_chosen_in_account) {
91 - // chosen fields (multiselect) available only in register and account pages
92 - wp_enqueue_style( "uwp_chosen_css", plugin_dir_url( __FILE__ ) . 'assets/css/chosen.css', array(), null, 'all' );
93 - }
80 + if ( isset($field->field_type_key ) && ( $field->field_type_key == 'uwp_country' || $field->field_type_key == 'country' ) ) {
81 + $enable_country_fields = true;
82 + }
83 + }
84 + }
94 85
95 - wp_enqueue_style( USERSWP_NAME, plugin_dir_url( __FILE__ ) . 'assets/css/users-wp.css', array(), null, 'all' );
96 - //widget styles for all pages
97 - wp_enqueue_style( "uwp_widget_css", plugin_dir_url( __FILE__ ) . 'assets/css/widgets.css', array(), null, 'all' );
86 + if ( $enable_timepicker_fields ) {
87 + wp_enqueue_style( 'jquery-ui' );
88 + wp_enqueue_script( "uwp_timepicker" );
89 + }
98 90
91 + if ( $enable_country_fields ) {
92 + //@todo lets find a better solution for this and put it in AUI, maybe SVG files?
93 + wp_enqueue_style( "uwp-country-select", USERSWP_PLUGIN_URL . 'assets/css/countryselect.css', array(), USERSWP_VERSION, 'all' );
94 + wp_enqueue_script( "country-select", USERSWP_PLUGIN_URL . 'assets/js/countrySelect' . $suffix . '.js', array( 'jquery' ), USERSWP_VERSION, $in_footer );
95 + $country_data = uwp_get_country_data();
96 + wp_localize_script( 'country-select', 'uwp_country_data', $country_data );
97 + }
99 98 }
100 99
101 - /**
102 - * Register the JavaScript for the public-facing side of the site.
103 - *
104 - * @since 1.0.0
105 - */
106 - public function enqueue_scripts() {
100 + function get_all_form_fields( $htmlvar_name = '' ) {
101 + global $wpdb;
107 102
108 - /**
109 - * An instance of this class should be passed to the run() function
110 - * defined in UsersWP_Loader as all of the hooks are defined
111 - * in that particular class.
112 - *
113 - * The UsersWP_Loader will then create the relationship
114 - * between the defined hooks and the functions defined in this
115 - * class.
116 - */
117 - if (is_uwp_page()) {
118 - // include only in uwp pages
119 - wp_enqueue_script( 'jquery-ui-core', array( 'jquery' ) );
120 - }
103 + $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
104 + $register_forms = uwp_get_option( 'multiple_registration_forms' );
105 + $custom_fields = array();
121 106
122 - if (is_uwp_current_user_profile_page()) {
123 - // include only profile pages
124 - wp_enqueue_script( 'jcrop', array( 'jquery' ) );
125 - }
126 -
127 - $enable_timepicker_in_register = false;
128 - $enable_timepicker_in_account = false;
107 + if ( ! empty( $register_forms ) && is_array( $register_forms ) ) {
108 + $form_ids = array();
129 109
130 - $enable_datepicker_in_register = false;
131 - $enable_datepicker_in_account = false;
110 + foreach ( $register_forms as $key => $register_form ) {
111 + $form_ids[] = (int) $register_form['id'];
112 + }
132 113
133 - $enable_chosen_in_register = false;
134 - $enable_chosen_in_account = false;
135 -
136 - if (is_uwp_register_page() || is_uwp_account_page()) {
137 - if (is_uwp_register_page()) {
138 - $fields = get_register_form_fields();
139 - } else {
140 - // account page
141 - $fields = get_account_form_fields();
142 - }
143 -
144 - if (!empty($fields)) {
145 - foreach ($fields as $field) {
146 - if ($field->field_type == 'time') {
147 - $enable_timepicker_in_register = true;
148 - }
114 + if ( ! empty( $form_ids ) && count( $form_ids ) > 0 ) {
115 + $form_ids_placeholder = array_fill( 0, count( $form_ids ), '%d' );
116 + $form_ids_placeholder = implode( ', ', $form_ids_placeholder );
117 + $query = $wpdb->prepare( "SELECT id,field_type,field_type_key FROM " . $table_name . " WHERE form_type = 'account' AND form_id IN (" . $form_ids_placeholder . ") AND (field_type = 'time' OR field_type = 'datepicker' OR field_type_key = 'uwp_country' OR field_type_key = 'country') ORDER BY sort_order ASC", $form_ids );
118 + $custom_fields = $wpdb->get_results( $query );
119 + }
120 + }
149 121
150 - if ($field->field_type == 'datepicker') {
151 - $enable_datepicker_in_register = true;
152 - }
153 -
154 - if ($field->field_type == 'multiselect') {
155 - $enable_chosen_in_register = true;
156 - }
157 - }
158 - }
159 - }
160 -
161 - if ($enable_timepicker_in_register || $enable_timepicker_in_account) {
162 - // time fields available only in register and account pages
163 - wp_enqueue_script( "uwp_timepicker", plugin_dir_url( __FILE__ ) . 'assets/js/jquery.ui.timepicker.min.js', array( 'jquery', 'jquery-ui-datepicker', 'jquery-ui-core' ), null, false );
164 - }
165 -
166 -
167 - if ($enable_datepicker_in_register || $enable_datepicker_in_account) {
168 - // date fields available only in register and account pages
169 - wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) );
170 - }
171 -
172 - if (is_uwp_profile_page() ) {
173 - wp_enqueue_script( 'jquery-ui-progressbar', array( 'jquery' ) );
174 - }
175 -
176 - if ($enable_chosen_in_register || $enable_chosen_in_account) {
177 - // chosen fields (multiselect) available only in register and account pages
178 - wp_dequeue_script('chosen');
179 - wp_enqueue_script( "uwp_chosen", plugin_dir_url( __FILE__ ) . 'assets/js/chosen.jquery.js', array( 'jquery' ), null, false );
180 - }
181 -
182 - // include only in uwp pages
183 - wp_enqueue_script( USERSWP_NAME, plugin_dir_url( __FILE__ ) . 'assets/js/users-wp.min.js', array( 'jquery' ), null, false );
184 -
185 - //load CountrySelect
186 - wp_enqueue_script( "country-select", plugin_dir_url(dirname(__FILE__)) . 'public/assets/js/countrySelect.min.js', array( 'jquery' ), null, false );
187 -
188 - $country_data = uwp_get_country_data();
189 - wp_localize_script(USERSWP_NAME, 'uwp_country_data', $country_data);
190 -
191 - $uwp_localize_data = uwp_get_localize_data();
192 - wp_localize_script(USERSWP_NAME, 'uwp_localize_data', $uwp_localize_data);
193 -
194 - }
122 + return $custom_fields;
123 + }
195 124
196 125 }