1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* repro_user_profile_fields function. |
7
|
|
|
* |
8
|
|
|
* @access public |
9
|
|
|
* @param mixed $user User. |
10
|
|
|
* @return void |
11
|
|
|
*/ |
12
|
|
|
function repro_user_profile_fields( $user ) { |
13
|
|
|
|
14
|
|
|
?> |
15
|
|
|
|
16
|
|
|
<h3>Real Estate Portal Profiles</h3> |
17
|
|
|
|
18
|
|
|
<table class="form-table"> |
19
|
|
|
|
20
|
|
|
<tr> |
21
|
|
|
<th><label for="zillow-username">Zillow Username:</label></th> |
22
|
|
|
|
23
|
|
|
<td> |
24
|
|
|
<input type="text" name="zillow_username" id="zillow-username" value="<?php echo esc_attr( get_the_author_meta( 'zillow_username', $user->ID ) ); ?>" class="regular-text" /><br /> |
25
|
|
|
<span class="description">Please provide your Zillow Username.</span> |
26
|
|
|
</td> |
27
|
|
|
</tr> |
28
|
|
|
|
29
|
|
|
<tr> |
30
|
|
|
<th><label for="trulia-username">Trulia Username:</label></th> |
31
|
|
|
|
32
|
|
|
<td> |
33
|
|
|
<input type="text" name="trulia_username" id="trulia-username" value="<?php echo esc_attr( get_the_author_meta( 'trulia_username', $user->ID ) ); ?>" class="regular-text" /><br /> |
34
|
|
|
<span class="description">Please provide your Trulia Username.</span> |
35
|
|
|
</td> |
36
|
|
|
</tr> |
37
|
|
|
|
38
|
|
|
<tr> |
39
|
|
|
<th><label for="homescom-user-id">Homes.com User ID:</label></th> |
40
|
|
|
|
41
|
|
|
<td> |
42
|
|
|
<input type="text" name="homescom_user_id" id="homescom-user-id" value="<?php echo esc_attr( get_the_author_meta( 'homescom_user_id', $user->ID ) ); ?>" class="regular-text" /><br /> |
43
|
|
|
<span class="description">Please provide your Homes.com User ID.</span> |
44
|
|
|
</td> |
45
|
|
|
</tr> |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
<tr> |
49
|
|
|
<th><label for="realtorcom-url">Realtor.com Profile Url:</label></th> |
50
|
|
|
|
51
|
|
|
<td> |
52
|
|
|
<input type="text" name="realtorcom_url" id="realtorcom-url" value="<?php echo esc_attr( get_the_author_meta( 'realtorcom_url', $user->ID ) ); ?>" class="regular-text" /><br /> |
53
|
|
|
<span class="description">Please provide your Realtor.com URL.</span> |
54
|
|
|
</td> |
55
|
|
|
</tr> |
56
|
|
|
|
57
|
|
|
</table> |
58
|
|
|
|
59
|
|
|
<?php |
60
|
|
|
|
61
|
|
|
} // End repro_user_profile_fields. |
62
|
|
|
add_action( 'show_user_profile', 'repro_user_profile_fields' ); |
63
|
|
|
add_action( 'edit_user_profile', 'repro_user_profile_fields' ); |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* repro_user_save_profile_fields function. |
67
|
|
|
* |
68
|
|
|
* @access public |
69
|
|
|
* @param mixed $user_id User ID. |
70
|
|
|
* @return void |
71
|
|
|
*/ |
72
|
|
|
function repro_user_save_profile_fields( $user_id ) { |
|
|
|
|
73
|
|
|
|
74
|
|
|
if ( ! current_user_can( 'edit_user', $user_id ) ) { |
75
|
|
|
return false; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
update_user_meta( $user_id, 'zillow_username', $_POST['zillow_username'] ); |
79
|
|
|
update_user_meta( $user_id, 'trulia_username', $_POST['trulia_username'] ); |
80
|
|
|
update_user_meta( $user_id, 'homescom_user_id', $_POST['homescom_user_id'] ); |
81
|
|
|
update_user_meta( $user_id, 'realtorcom_url', $_POST['realtorcom_url'] ); |
82
|
|
|
|
83
|
|
|
} // End repro_user_save_profile_fields. |
84
|
|
|
add_action( 'personal_options_update', 'repro_user_save_profile_fields' ); |
85
|
|
|
add_action( 'edit_user_profile_update', 'repro_user_save_profile_fields' ); |
86
|
|
|
|
87
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.