PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.2
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.2
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 / upgrade.php

upgrade.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.2, at upgrade.php

236 lines 6.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Upgrade related functions.
4 *
5 * @since 1.0.0
6 * @package UsersWP
7 */
8
9
10 // Exit if accessed directly
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Change account fields to not have uwp_account_ prefix.
17 */
18 function uwp_upgrade_1200() {
19
20 // Change the users item page template content and backup the old content
21 $page_id = uwp_get_page_id( 'user_list_item_page' );
22 $updated = uwp_get_option( "user_list_page_updated" );
23 if ( $page_id && ! $updated ) {
24 $backup_content = get_post_meta( $page_id, 'uwp_1100_content' );
25 if ( ! $backup_content ) {
26 $content = get_post_field( 'post_content', $page_id );
27 if ( $content ) {
28 update_post_meta( $page_id, 'uwp_1100_content', $content );
29 wp_update_post( array( 'ID' => $page_id, 'post_content' => '[uwp_users_item]' ) );
30 uwp_update_option( "user_list_page_updated", "1100" );
31 }
32 }
33 }
34
35 // Convert tabs
36 uwp_upgrade_convert_tabs();
37
38 }
39
40 /**
41 * Convert v1.0 tabs to v1.2.
42 */
43 function uwp_upgrade_convert_tabs() {
44 $old_tabs = uwp_get_option( 'enable_profile_tabs' );
45
46 $updated = uwp_get_option( "user_profile_tabs_updated" );
47 $new_tabs = array();
48 if ( $old_tabs && ! $updated ) {
49
50 foreach ( $old_tabs as $tab ) {
51 $tab_data = array();
52 if ( $tab == 'posts' ) {
53 $tab_data = array(
54 'tab_type' => 'standard',
55 'tab_name' => __( 'Posts', 'userswp' ),
56 'tab_icon' => 'fas fa-info-circle',
57 'tab_key' => 'posts',
58 'tab_content' => ''
59 );
60 } elseif ( $tab == 'more_info' ) {
61 $tab_data = array(
62 'tab_type' => 'standard',
63 'tab_name' => __( 'More Info', 'userswp' ),
64 'tab_icon' => 'fas fa-info-circle',
65 'tab_key' => 'more_info',
66 'tab_content' => ''
67 );
68 } elseif ( $tab == 'comments' ) {
69 $tab_data = array(
70 'tab_type' => 'standard',
71 'tab_name' => __( 'Comments', 'userswp' ),
72 'tab_icon' => 'fas fa-comments',
73 'tab_key' => 'comments',
74 'tab_content' => ''
75 );
76 } elseif ( $tab == 'listings' ) {
77 $tab_data = array(
78 'tab_type' => 'standard',
79 'tab_name' => __( 'Listings', 'userswp' ),
80 'tab_icon' => 'fas fa-globe-americas',
81 'tab_key' => 'listings',
82 'tab_content' => ''
83 );
84 } elseif ( $tab == 'reviews' ) {
85 $tab_data = array(
86 'tab_type' => 'standard',
87 'tab_name' => __( 'Reviews', 'userswp' ),
88 'tab_icon' => 'fas fa-star',
89 'tab_key' => 'reviews',
90 'tab_content' => ''
91 );
92 } elseif ( $tab == 'favorites' ) {
93 $tab_data = array(
94 'tab_type' => 'standard',
95 'tab_name' => __( 'Favorites', 'userswp' ),
96 'tab_icon' => 'fas fa-heart',
97 'tab_key' => 'favorites',
98 'tab_content' => ''
99 );
100 } elseif ( $tab == 'activity' ) {
101 $tab_data = array(
102 'tab_type' => 'shortcode',
103 'tab_name' => __( 'Activity', 'userswp' ),
104 'tab_icon' => 'fas fa-cubes',
105 'tab_key' => 'activity',
106 'tab_content' => '[uwp_activity]'
107 );
108 } elseif ( $tab == 'downloads' ) {
109 $tab_data = array(
110 'tab_type' => 'standard',
111 'tab_name' => __( 'Downloads', 'userswp' ),
112 'tab_icon' => 'fas fa-download',
113 'tab_key' => 'downloads',
114 'tab_content' => '[uwp_edd_downloads]'
115 );
116 } elseif ( $tab == 'purchases' ) {
117 $tab_data = array(
118 'tab_type' => 'standard',
119 'tab_name' => __( 'Purchases', 'userswp' ),
120 'tab_icon' => 'fas fa-receipt',
121 'tab_key' => 'purchases',
122 'tab_content' => '[uwp_edd_purchases]'
123 );
124 } elseif ( $tab == 'followers' ) {
125 $tab_data = array(
126 'tab_type' => 'standard',
127 'tab_name' => __( 'Followers', 'userswp' ),
128 'tab_icon' => 'fas fa-chevron-circle-left',
129 'tab_key' => 'followers',
130 'tab_content' => '[uwp_followers]'
131 );
132 } elseif ( $tab == 'followers' ) {
133 $tab_data = array(
134 'tab_type' => 'standard',
135 'tab_name' => __( 'Following', 'userswp' ),
136 'tab_icon' => 'fas fa-chevron-circle-right',
137 'tab_key' => 'following',
138 'tab_content' => '[uwp_following]'
139 );
140 } elseif ( $tab == 'friends' ) {
141 $tab_data = array(
142 'tab_type' => 'standard',
143 'tab_name' => __( 'Friends', 'userswp' ),
144 'tab_icon' => 'fas fa-chevron-circle-right',
145 'tab_key' => 'friends',
146 'tab_content' => '[uwp_friends]'
147 );
148 } elseif ( $tab == 'mycred' ) {
149 $tab_data = array(
150 'tab_type' => 'standard',
151 'tab_name' => __( 'MyCred', 'userswp' ),
152 'tab_icon' => 'fas fa-star',
153 'tab_key' => 'mycred',
154 'tab_content' => '[uwp_mycred]'
155 );
156 } elseif ( $tab == 'products' ) {
157 $tab_data = array(
158 'tab_type' => 'standard',
159 'tab_name' => __( 'Products', 'userswp' ),
160 'tab_icon' => 'fas fa-info-circle',
161 'tab_key' => 'products',
162 'tab_content' => ''
163 );
164 } elseif ( $tab == 'orders' ) {
165 $tab_data = array(
166 'tab_type' => 'standard',
167 'tab_name' => __( 'Orders', 'userswp' ),
168 'tab_icon' => 'fas fa-info-circle',
169 'tab_key' => 'orders',
170 'tab_content' => ''
171 );
172 } elseif ( $tab == 'jobs' ) {
173 $tab_data = array(
174 'tab_type' => 'standard',
175 'tab_name' => __( 'Jobs', 'userswp' ),
176 'tab_icon' => 'fas fa-briefcase',
177 'tab_key' => 'jobs',
178 'tab_content' => ''
179 );
180 } elseif ( $tab == 'forums' ) {
181 $tab_data = array(
182 'tab_type' => 'standard',
183 'tab_name' => __( 'Topics', 'userswp' ),
184 'tab_icon' => 'fas fa-info-circle',
185 'tab_key' => 'topics',
186 'tab_content' => ''
187 );
188 uwp_profile_add_tabs( $tab_data ); // we are adding two here
189
190 $tab_data = array(
191 'tab_type' => 'standard',
192 'tab_name' => __( 'Replies', 'userswp' ),
193 'tab_icon' => 'fas fa-reply-all',
194 'tab_key' => 'replies',
195 'tab_content' => ''
196 );
197 }
198
199
200 if ( ! empty( $tab_data ) ) {
201 uwp_profile_add_tabs( $tab_data );
202 }
203 }
204
205 // set as updated
206 uwp_update_option( "user_profile_tabs_updated", "1200" );
207 }
208
209 }
210
211 /**
212 * Change country htmlvar name to uwp_country to prevent conflicts with location manager plugin.
213 */
214 function uwp_upgrade_12013() {
215 global $wpdb;
216
217 $default_field = 'country';
218 $replace_field = 'uwp_country';
219 $fields_table = $wpdb->prefix . 'uwp_form_fields';
220
221 $fields_results = $wpdb->get_results($wpdb->prepare("SELECT * FROM `$fields_table` WHERE `htmlvar_name` = '%s'",$default_field));
222 if( !empty($fields_results) && count($fields_results) > 0 ) {
223 $wpdb->update( $fields_table,
224 array( 'htmlvar_name' => $replace_field ),
225 array( 'htmlvar_name' => $default_field )
226 );
227 }
228
229 $uwp_usermeta_table = $wpdb->prefix . 'uwp_usermeta';
230
231 $usermeta_columns = $wpdb->get_col("SHOW COLUMNS FROM `$uwp_usermeta_table` LIKE '$default_field'");
232
233 if( !empty( $usermeta_columns ) && count($usermeta_columns) > 0 ) {
234 $wpdb->query("ALTER TABLE $uwp_usermeta_table CHANGE COLUMN $default_field $replace_field varchar(500) NOT NULL");
235 }
236 }