| 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 Username', 'mlsimport' ), |
| 23 |
'details' => 'to be added', |
| 24 |
), |
| 25 |
'mlsimport_password' => array( |
| 26 |
'name' => esc_html__( 'MLSImport 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_rapattoni_client_id' => array( |
| 52 |
'name' => esc_html__( 'MLSImport Rapattoni Client id', 'mlsimport' ), |
| 53 |
'details' => 'to be added', |
| 54 |
), |
| 55 |
|
| 56 |
'mlsimport_rapattoni_client_secret' => array( |
| 57 |
'name' => esc_html__( 'MLSImport Rapattoni Client Secret', 'mlsimport' ), |
| 58 |
'details' => 'to be added', |
| 59 |
), |
| 60 |
|
| 61 |
'mlsimport_rapattoni_username' => array( |
| 62 |
'name' => esc_html__( 'MLSImport Rapattoni Username', 'mlsimport' ), |
| 63 |
'details' => 'to be added', |
| 64 |
), |
| 65 |
|
| 66 |
'mlsimport_rapattoni_password' => array( |
| 67 |
'name' => esc_html__( 'MLSImport Rapattoni Client Password','mlsimport' ), |
| 68 |
'details' => 'to be added', |
| 69 |
), |
| 70 |
|
| 71 |
|
| 72 |
'mlsimport_paragon_client_id' => array( |
| 73 |
'name' => esc_html__( 'MLSImport Paragon Client id', 'mlsimport' ), |
| 74 |
'details' => 'to be added', |
| 75 |
), |
| 76 |
|
| 77 |
'mlsimport_paragon_client_secret' => array( |
| 78 |
'name' => esc_html__( 'MLSImport Paragon Client Secret', 'mlsimport' ), |
| 79 |
'details' => 'to be added', |
| 80 |
), |
| 81 |
'mlsimport_theme_used' => array( |
| 82 |
'type' => 'select', |
| 83 |
'name' => esc_html__( 'Your Wordpress Theme', 'mlsimport'), |
| 84 |
'details' => 'to be added', |
| 85 |
), |
| 86 |
|
| 87 |
); |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
?> |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
<?php |
| 98 |
$token = $mlsimport->admin->mlsimport_saas_get_mls_api_token_from_transient(); |
| 99 |
|
| 100 |
$is_mls_connected = get_option( 'mlsimport_connection_test', '' ); |
| 101 |
$mlsimport->admin->mlsimport_saas_setting_up(); |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
if ( 'yes' !== $is_mls_connected ) { |
| 106 |
$mlsimport->admin->mlsimport_saas_check_mls_connection(); |
| 107 |
$is_mls_connected = get_option( 'mlsimport_connection_test', '' ); |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
if ( trim( $token ) === '' ) { |
| 116 |
mlsimport_show_signup(); |
| 117 |
?> |
| 118 |
<div class="mlsimport_warning"> |
| 119 |
<?php esc_html_e( 'You are not connected to MlsImport - Please check your Username and Password.', 'mlsimport' );?> |
| 120 |
</div> |
| 121 |
<?php |
| 122 |
} else { ?> |
| 123 |
<div class="mlsimport_warning mlsimport_validated"> |
| 124 |
<?php esc_html_e( 'You are connected to your MlsImport account!', 'mlsimport' );?> |
| 125 |
</div> |
| 126 |
<?php |
| 127 |
} |
| 128 |
|
| 129 |
if ( 'yes' === $is_mls_connected ) { ?> |
| 130 |
<div class="mlsimport_warning mlsimport_validated"> |
| 131 |
<?php esc_html_e( 'The connection to your MLS was successful', 'mlsimport' );?> |
| 132 |
</div> |
| 133 |
<?php |
| 134 |
} else { ?> |
| 135 |
<div class="mlsimport_warning"> |
| 136 |
<?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' );?> |
| 137 |
</div> |
| 138 |
<?php |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
foreach ( $settings_list as $key => $setting ) { |
| 144 |
$value = ( isset( $options[ $key ] ) && ! empty( $options[ $key ] ) ) ? esc_attr( $options[ $key ] ) : ''; |
| 145 |
?> |
| 146 |
<fieldset class="mlsimport-fieldset <?php echo 'fieldset_' . esc_attr( $key ); ?>"> |
| 147 |
<label class="mlsimport-label" for="<?php echo esc_attr($this->plugin_name ). '_admin_options'; ?>-<?php echo esc_attr($key); ?>" > |
| 148 |
<?php echo esc_html( $setting['name'] ); ?> |
| 149 |
</label> |
| 150 |
|
| 151 |
|
| 152 |
<?php |
| 153 |
if ( 'mlsimport_mls_name' === $key && isset( $setting['type'] ) and 'select' === $setting['type'] ) { |
| 154 |
$mls_import_list = mlsimport_saas_request_list(); |
| 155 |
|
| 156 |
?> |
| 157 |
|
| 158 |
<div class="mls_explanations"> |
| 159 |
If your MLS is not on this list yet please <a href="https://mlsimport.com" target="_blank">contact us</a> in order to check it and enable it. |
| 160 |
</div> |
| 161 |
|
| 162 |
<input type="text" id="mlsimport_mls_name_front" name="mlsimport_admin_options[mlsimport_mls_name_front]" placeholder="search your MLS" value="<?php |
| 163 |
if ( ! empty( $options['mlsimport_mls_name_front'] ) ) { |
| 164 |
echo esc_html($options['mlsimport_mls_name_front']); |
| 165 |
} |
| 166 |
?>"> |
| 167 |
|
| 168 |
|
| 169 |
<input type="hidden" id="mlsimport_mls_name" name="mlsimport_admin_options[mlsimport_mls_name]" value="<?php |
| 170 |
if ( ! empty( $value ) ) { |
| 171 |
echo esc_html($value); |
| 172 |
} |
| 173 |
?>"> |
| 174 |
|
| 175 |
|
| 176 |
<?php |
| 177 |
} elseif ( 'mlsimport_theme_used' === $key && isset( $setting['type'] ) and 'select' === $setting['type'] ) { |
| 178 |
$permited_tags = mlsimport_allowed_html_tags_content(); |
| 179 |
$list = mlsiport_mls_select_list( $key, $value, MLSIMPORT_THEME); |
| 180 |
print wp_kses( $list ,$permited_tags ); |
| 181 |
} else { |
| 182 |
?> |
| 183 |
|
| 184 |
<input |
| 185 |
<?php |
| 186 |
if ( 'mlsimport_password' === $key ) { ?> |
| 187 |
type="password" |
| 188 |
<?php |
| 189 |
} else { ?> |
| 190 |
type="text" |
| 191 |
<?php |
| 192 |
} |
| 193 |
?> |
| 194 |
|
| 195 |
class="mlsimport-input xxx" autocomplete="off" |
| 196 |
id="<?php echo esc_attr( $this->plugin_name . '_admin_options' ); ?>-<?php echo esc_attr( $key ); ?>" |
| 197 |
name="<?php echo esc_attr( $this->plugin_name . '_admin_options' ); ?>[<?php echo esc_attr( $key ); ?>]" |
| 198 |
value="<?php |
| 199 |
if ( ! empty( $value ) ) { |
| 200 |
echo trim( esc_html( ( $value ) ) ); |
| 201 |
} else { |
| 202 |
echo ''; |
| 203 |
} |
| 204 |
?>"/> |
| 205 |
<?php } ?> |
| 206 |
</fieldset> |
| 207 |
<?php } ?> |
| 208 |
|
| 209 |
|
| 210 |
<input type="hidden" name="<?php echo esc_attr($this->plugin_name) . '_admin_options'; ?>[force_rand]" value="<?php echo esc_attr( wp_rand() ); ?>"> |
| 211 |
|
| 212 |
<?php |
| 213 |
$attributes = array( 'data-style' => 'mlsimport_but' ); |
| 214 |
submit_button( __( 'Save Changes', 'mlsimport' ), 'mlsimport_button', 'submit', true, $attributes ); |
| 215 |
?> |
| 216 |
</form> |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
<?php |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
/* |
| 231 |
* |
| 232 |
* create dropdown list |
| 233 |
* |
| 234 |
* |
| 235 |
*/ |
| 236 |
function mlsiport_mls_select_list( $key, $value, $data_array ) { |
| 237 |
$select = '<select id="' . esc_attr( $key ) . '" name="mlsimport_admin_options[' . $key . ']">'; |
| 238 |
if ( is_array( $data_array ) ) : |
| 239 |
foreach ( $data_array as $key => $mls_item ) { |
| 240 |
$select .= '<option value="' .esc_attr( $key ). '"'; |
| 241 |
if ( intval( $value ) === intval( $key ) ) { |
| 242 |
$select .= ' selected '; |
| 243 |
} |
| 244 |
$select .= '>' .esc_html( $mls_item ). '</option>'; |
| 245 |
} |
| 246 |
endif; |
| 247 |
$select .= '</select>'; |
| 248 |
return $select; |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
?> |