| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
?> |
| 6 |
<form method="post" name="cleanup_options" action="options.php"> |
| 7 |
<?php |
| 8 |
settings_fields( $this->plugin_name . '_admin_options' ); |
| 9 |
do_settings_sections( $this->plugin_name . '_admin_options' ); |
| 10 |
$options = get_option( $this->plugin_name . '_admin_options' ); |
| 11 |
|
| 12 |
global $mlsimport; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
$settings_list = array( |
| 20 |
|
| 21 |
'mlsimport_username' => array( |
| 22 |
'name' => esc_html__( 'MLSImport.com Username (not your email)', 'mlsimport' ), |
| 23 |
'details' => 'to be added', |
| 24 |
), |
| 25 |
'mlsimport_password' => array( |
| 26 |
'name' => esc_html__( 'MLSImport.com Password', 'mlsimport'), |
| 27 |
'details' => 'to be added', |
| 28 |
), |
| 29 |
|
| 30 |
|
| 31 |
'mlsimport_mls_name' => array( |
| 32 |
'type' => 'select', |
| 33 |
'name' => esc_html__( 'Your MLS', 'mlsimport'), |
| 34 |
'details' => 'to be added', |
| 35 |
), |
| 36 |
|
| 37 |
'mlsimport_mls_token' => array( |
| 38 |
'name' => esc_html__( 'Your API Server token - provided by your MLS','mlsimport'), |
| 39 |
'details' => 'to be added', |
| 40 |
), |
| 41 |
'mlsimport_tresle_client_id' => array( |
| 42 |
'name' => esc_html__( 'Your Trestle Client ID - provided by your MLS', 'mlsimport'), |
| 43 |
'details' => 'to be added', |
| 44 |
), |
| 45 |
|
| 46 |
'mlsimport_tresle_client_secret' => array( |
| 47 |
'name' => esc_html__( 'Your Trestle Client Secret - provided by your MLS', 'mlsimport' ), |
| 48 |
'details' => 'to be added', |
| 49 |
), |
| 50 |
|
| 51 |
'mlsimport_connectmls_username' => array( |
| 52 |
'name' => esc_html__( 'Your ConnectMLS Username - provided by your MLS', 'mlsimport' ), |
| 53 |
'details' => 'to be added', |
| 54 |
), |
| 55 |
|
| 56 |
'mlsimport_connectmls_password' => array( |
| 57 |
'name' => esc_html__( 'Your ConnectMLS Password - provided by your MLS', 'mlsimport' ), |
| 58 |
'details' => 'to be added', |
| 59 |
), |
| 60 |
|
| 61 |
'mlsimport_rapattoni_client_id' => array( |
| 62 |
'name' => esc_html__( 'MLSImport Rapattoni Client id', 'mlsimport' ), |
| 63 |
'details' => 'to be added', |
| 64 |
), |
| 65 |
|
| 66 |
'mlsimport_rapattoni_client_secret' => array( |
| 67 |
'name' => esc_html__( 'MLSImport Rapattoni Client Secret', 'mlsimport' ), |
| 68 |
'details' => 'to be added', |
| 69 |
), |
| 70 |
|
| 71 |
'mlsimport_rapattoni_username' => array( |
| 72 |
'name' => esc_html__( 'MLSImport Rapattoni Username', 'mlsimport' ), |
| 73 |
'details' => 'to be added', |
| 74 |
), |
| 75 |
|
| 76 |
'mlsimport_rapattoni_password' => array( |
| 77 |
'name' => esc_html__( 'MLSImport Rapattoni Client Password','mlsimport' ), |
| 78 |
'details' => 'to be added', |
| 79 |
), |
| 80 |
|
| 81 |
|
| 82 |
'mlsimport_paragon_client_id' => array( |
| 83 |
'name' => esc_html__( 'MLSImport Paragon Client id', 'mlsimport' ), |
| 84 |
'details' => 'to be added', |
| 85 |
), |
| 86 |
|
| 87 |
'mlsimport_paragon_client_secret' => array( |
| 88 |
'name' => esc_html__( 'MLSImport Paragon Client Secret', 'mlsimport' ), |
| 89 |
'details' => 'to be added', |
| 90 |
), |
| 91 |
|
| 92 |
'mlsimport_realtorca_client_id' => array( |
| 93 |
'name' => esc_html__( 'MLSImport Realtor.ca Client id', 'mlsimport' ), |
| 94 |
'details' => 'to be added', |
| 95 |
), |
| 96 |
|
| 97 |
'mlsimport_realtorca_client_secret' => array( |
| 98 |
'name' => esc_html__( 'MLSImport Realtor.ca Client Secret', 'mlsimport' ), |
| 99 |
'details' => 'to be added', |
| 100 |
), |
| 101 |
|
| 102 |
'mlsimport_brightmls_client_id' => array( |
| 103 |
'name' => esc_html__( 'Your BrightMLS Client ID - provided by your MLS', 'mlsimport' ), |
| 104 |
'details' => 'to be added', |
| 105 |
), |
| 106 |
|
| 107 |
'mlsimport_brightmls_client_secret' => array( |
| 108 |
'name' => esc_html__( 'Your BrightMLS Client Secret - provided by your MLS', 'mlsimport' ), |
| 109 |
'details' => 'to be added', |
| 110 |
), |
| 111 |
|
| 112 |
'mlsimport_theme_used' => array( |
| 113 |
'type' => 'select', |
| 114 |
'name' => esc_html__( 'Your Wordpress Theme', 'mlsimport'), |
| 115 |
'details' => 'to be added', |
| 116 |
), |
| 117 |
|
| 118 |
); |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
?> |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
<?php |
| 129 |
$token = $mlsimport->admin->mlsimport_saas_get_mls_api_token_from_transient(); |
| 130 |
|
| 131 |
$is_mls_connected = get_option( 'mlsimport_connection_test', '' ); |
| 132 |
$mlsimport->admin->mlsimport_saas_setting_up(); |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
if ( 'yes' !== $is_mls_connected ) { |
| 137 |
$mlsimport->admin->mlsimport_saas_check_mls_connection(); |
| 138 |
$is_mls_connected = get_option( 'mlsimport_connection_test', '' ); |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
if ( trim( $token ) === '' ) { |
| 147 |
mlsimport_show_signup(); |
| 148 |
?> |
| 149 |
<div class="mlsimport_warning"> |
| 150 |
<?php esc_html_e( 'You are not connected to MlsImport - Please check your Username and Password.', 'mlsimport' );?> |
| 151 |
</div> |
| 152 |
<?php |
| 153 |
} else { ?> |
| 154 |
<div class="mlsimport_warning mlsimport_validated"> |
| 155 |
<?php esc_html_e( 'You are connected to your MlsImport account!', 'mlsimport' );?> |
| 156 |
</div> |
| 157 |
<?php |
| 158 |
} |
| 159 |
|
| 160 |
if ( 'yes' === $is_mls_connected ) { ?> |
| 161 |
<div class="mlsimport_warning mlsimport_validated"> |
| 162 |
<?php esc_html_e( 'You are connected to your MLS.', 'mlsimport' );?> |
| 163 |
</div> |
| 164 |
<?php |
| 165 |
} else { ?> |
| 166 |
<div class="mlsimport_warning"> |
| 167 |
<?php esc_html_e( 'The connection to your MLS was NOT succesful. Please check the authentication token is correct and check your MLS Data Access Application is approved. ', 'mlsimport' );?> |
| 168 |
</div> |
| 169 |
<?php |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
// Add before username fieldset |
| 174 |
/* |
| 175 |
global $mlsimport; |
| 176 |
$current_token = $mlsimport->admin->mlsimport_saas_get_mls_api_token_from_transient(); |
| 177 |
$token_expiry = get_option('mlsimport_token_expiry', 0); |
| 178 |
|
| 179 |
|
| 180 |
$expiry_date = date('Y-m-d H:i:s', $token_expiry); |
| 181 |
$is_expired = time() >= $token_expiry; |
| 182 |
$status_color = $is_expired ? '#dc3545' : '#28a745'; |
| 183 |
$status_text = $is_expired ? 'EXPIRED' : 'VALID'; |
| 184 |
|
| 185 |
echo '<div style="background: #f9f9f9; padding: 15px; margin-bottom: 20px; border-radius: 5px;">'; |
| 186 |
echo '<h4>Current Token Status</h4>'; |
| 187 |
echo '<p><strong>Token:</strong> ' . esc_html(substr($current_token, 0, 20)) . '...</p>'; |
| 188 |
echo '<p><strong>Status:</strong> <span style="color: ' . $status_color . '; font-weight: bold;">' . $status_text . '</span></p>'; |
| 189 |
echo '<p><strong>Expires:</strong> ' . esc_html($expiry_date) . '</p>'; |
| 190 |
echo '</div>'; |
| 191 |
*/ |
| 192 |
|
| 193 |
|
| 194 |
foreach ( $settings_list as $key => $setting ) { |
| 195 |
$value = ( isset( $options[ $key ] ) && ! empty( $options[ $key ] ) ) ? esc_attr( $options[ $key ] ) : ''; |
| 196 |
?> |
| 197 |
<fieldset class="mlsimport-fieldset <?php echo 'fieldset_' . esc_attr( $key ); ?>"> |
| 198 |
<label class="mlsimport-label" for="<?php echo esc_attr($this->plugin_name ). '_admin_options'; ?>-<?php echo esc_attr($key); ?>" > |
| 199 |
<?php echo esc_html( $setting['name'] ); ?> |
| 200 |
</label> |
| 201 |
|
| 202 |
|
| 203 |
<?php |
| 204 |
if ( 'mlsimport_mls_name' === $key && isset( $setting['type'] ) and 'select' === $setting['type'] ) { |
| 205 |
$mls_import_list = mlsimport_saas_request_list(); |
| 206 |
|
| 207 |
?> |
| 208 |
|
| 209 |
<div class="mls_explanations"> |
| 210 |
If your MLS is not on the list yet, requires manual activation, or if your credentials are not connecting, please <a href="https://mlsimport.com/contact-us/" target="_blank">contact us</a> for support. |
| 211 |
</div> |
| 212 |
|
| 213 |
<input type="text" class="mlsimport-input mlsimport-2025-input" id="mlsimport_mls_name_front" name="mlsimport_admin_options[mlsimport_mls_name_front]" placeholder="search your MLS" value="<?php |
| 214 |
if ( ! empty( $options['mlsimport_mls_name_front'] ) ) { |
| 215 |
echo esc_html($options['mlsimport_mls_name_front']); |
| 216 |
} |
| 217 |
?>"> |
| 218 |
|
| 219 |
|
| 220 |
<input type="hidden" id="mlsimport_mls_name" name="mlsimport_admin_options[mlsimport_mls_name]" value="<?php |
| 221 |
if ( ! empty( $value ) ) { |
| 222 |
echo esc_html($value); |
| 223 |
} |
| 224 |
?>"> |
| 225 |
|
| 226 |
|
| 227 |
<?php |
| 228 |
} elseif ( 'mlsimport_theme_used' === $key && isset( $setting['type'] ) and 'select' === $setting['type'] ) { |
| 229 |
$permited_tags = mlsimport_allowed_html_tags_content(); |
| 230 |
$list = mlsiport_mls_select_list( $key, $value, MLSIMPORT_THEME); |
| 231 |
print wp_kses( $list ,$permited_tags ); |
| 232 |
} else { |
| 233 |
?> |
| 234 |
|
| 235 |
<input |
| 236 |
<?php |
| 237 |
if ( in_array( $key, array( 'mlsimport_password', 'mlsimport_connectmls_password' ), true ) ) { ?> |
| 238 |
type="password" |
| 239 |
<?php |
| 240 |
} else { ?> |
| 241 |
type="text" |
| 242 |
<?php |
| 243 |
} |
| 244 |
?> |
| 245 |
|
| 246 |
class="mlsimport-input mlsimport-2025-input " autocomplete="off" |
| 247 |
id="<?php echo esc_attr( $this->plugin_name . '_admin_options' ); ?>-<?php echo esc_attr( $key ); ?>" |
| 248 |
name="<?php echo esc_attr( $this->plugin_name . '_admin_options' ); ?>[<?php echo esc_attr( $key ); ?>]" |
| 249 |
value="<?php |
| 250 |
if ( ! empty( $value ) ) { |
| 251 |
echo trim( esc_html( ( $value ) ) ); |
| 252 |
} else { |
| 253 |
echo ''; |
| 254 |
} |
| 255 |
?>"/> |
| 256 |
<?php } ?> |
| 257 |
</fieldset> |
| 258 |
<?php } ?> |
| 259 |
|
| 260 |
|
| 261 |
<input type="hidden" name="<?php echo esc_attr($this->plugin_name) . '_admin_options'; ?>[force_rand]" value="<?php echo esc_attr( wp_rand() ); ?>"> |
| 262 |
|
| 263 |
<?php |
| 264 |
$attributes = array( 'data-style' => 'mlsimport_but' ); |
| 265 |
submit_button( __( 'Save Changes', 'mlsimport' ), 'mlsimport_button save_data', 'submit', true, $attributes ); |
| 266 |
?> |
| 267 |
</form> |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
<?php |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
?> |