| 1 |
<?php |
| 2 |
/** |
| 3 |
* Read-only renderer for the Field Configuration settings tab. |
| 4 |
* |
| 5 |
* Metadata gathering owns initialization and persistence. This partial only |
| 6 |
* checks connection state, asks the deep module for an in-memory normalized |
| 7 |
* view, and renders the active fields. There is deliberately no settings form, |
| 8 |
* options.php submission, pagination state, or browser-triggered initial save; |
| 9 |
* the JavaScript controller sends compact commands to the single AJAX seam. |
| 10 |
* |
| 11 |
* @package MLSImport |
| 12 |
* @subpackage MLSImport/admin/partials |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
global $mlsimport; |
| 20 |
|
| 21 |
$metadata_populated = get_option( 'mlsimport_mls_metadata_populated', '' ); |
| 22 |
$token = $mlsimport->admin->mlsimport_saas_get_mls_api_token_from_transient(); |
| 23 |
$is_mls_connected = get_option( 'mlsimport_connection_test', '' ); |
| 24 |
|
| 25 |
// Refresh connection state before deciding whether the configuration can be |
| 26 |
// displayed. These calls preserve the settings page's existing connection flow. |
| 27 |
$mlsimport->admin->mlsimport_saas_setting_up(); |
| 28 |
if ( 'yes' !== $is_mls_connected ) { |
| 29 |
$mlsimport->admin->mlsimport_saas_check_mls_connection(); |
| 30 |
$is_mls_connected = get_option( 'mlsimport_connection_test', '' ); |
| 31 |
} |
| 32 |
|
| 33 |
if ( '' === trim( $token ) ) { |
| 34 |
echo '<div class="mlsimport_warning">' . esc_html__( 'You are not connected to MlsImport - Please check your Username and Password.', 'mlsimport' ) . '</div>'; |
| 35 |
return; |
| 36 |
} |
| 37 |
|
| 38 |
if ( 'yes' !== $is_mls_connected ) { |
| 39 |
echo '<div class="mlsimport_warning">' . esc_html__( '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' ) . '</div>'; |
| 40 |
return; |
| 41 |
} |
| 42 |
|
| 43 |
if ( 'yes' === $metadata_populated ) { |
| 44 |
$metadata = mlsimport_field_configuration_metadata(); |
| 45 |
$theme_schema = mlsimport_hardocde_theme_schema(); |
| 46 |
$configuration = mlsimport_field_configuration()->read( $metadata, $theme_schema, mlsimport_field_configuration_taxonomies() ); |
| 47 |
|
| 48 |
echo '<h3>' . esc_html__( 'Select the extra fields you want to import', 'mlsimport' ) . ':</h3>'; |
| 49 |
echo render_mls_field_selection_interface( |
| 50 |
$metadata, |
| 51 |
$configuration, |
| 52 |
array( |
| 53 |
'search_term' => '', |
| 54 |
'import_filter' => 'all', |
| 55 |
'show_filters' => true, |
| 56 |
'show_stats' => true, |
| 57 |
'enable_drag_drop' => true, |
| 58 |
'plugin_name' => 'mlsimport', |
| 59 |
), |
| 60 |
$theme_schema |
| 61 |
); |
| 62 |
} elseif ( '' !== trim( $token ) ) { |
| 63 |
echo '<div class="mlsimport_warning mlsimport_validated">' . esc_html__( 'We need to gather some information about your MLS. Please Stand By! ', 'mlsimport' ) . '</div>'; |
| 64 |
} else { |
| 65 |
esc_html_e( 'You are not connected to MLS Import', 'mlsimport' ); |
| 66 |
} |
| 67 |
?> |
| 68 |
<input type="hidden" id="mlsimport_saas_get_metadata" value="<?php echo esc_attr( wp_create_nonce( 'mlsimport_saas_get_metadata' ) ); ?>"> |
| 69 |
|