| 1 |
<?php |
| 2 |
if ( ! function_exists( 'is_plugin_active' ) ) { |
| 3 |
require_once ABSPATH . '/wp-admin/includes/plugin.php'; |
| 4 |
} |
| 5 |
|
| 6 |
// Handle form submission securely |
| 7 |
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) { |
| 8 |
// Check nonce and user capability |
| 9 |
if ( |
| 10 |
! isset( $_POST['avcp_settings_nonce'] ) || |
| 11 |
! wp_verify_nonce( $_POST['avcp_settings_nonce'], 'avcp_save_settings' ) || |
| 12 |
! current_user_can( 'manage_options' ) |
| 13 |
) { |
| 14 |
echo '<div class="notice notice-error"><p>' . esc_html__( 'Errore di sicurezza: riprova.', 'avcp' ) . '</p></div>'; |
| 15 |
return; |
| 16 |
} |
| 17 |
|
| 18 |
// Sanitize and save options |
| 19 |
update_option( 'avcp_denominazione_ente', sanitize_text_field( filter_input( INPUT_POST, 'avcp_denominazione_ente_n', FILTER_SANITIZE_STRING ) ) ); |
| 20 |
update_option( 'avcp_codicefiscale_ente', sanitize_text_field( filter_input( INPUT_POST, 'avcp_codicefiscale_ente_n', FILTER_SANITIZE_STRING ) ) ); |
| 21 |
update_option( 'avcp_dataset_capability', sanitize_text_field( filter_input( INPUT_POST, 'avcp_dataset_capability_n', FILTER_SANITIZE_STRING ) ) ); |
| 22 |
|
| 23 |
update_option( 'avcp_autopublish', isset( $_POST['avcp_autopublish_n'] ) ? '1' : '0' ); |
| 24 |
update_option( 'avcp_dis_archivioditte', isset( $_POST['avcp_dis_archivioditte_n'] ) ? '0' : '1' ); |
| 25 |
update_option( 'avcp_dis_archivioanni', isset( $_POST['avcp_dis_archivioanni_n'] ) ? '0' : '1' ); |
| 26 |
update_option( 'avcp_dis_styledbackend', isset( $_POST['avcp_dis_styledbackend_n'] ) ? '0' : '1' ); |
| 27 |
update_option( 'avcp_centricosto', isset( $_POST['avcp_centricosto_n'] ) ? '0' : '1' ); |
| 28 |
update_option( 'avcp_abilita_ruoli', isset( $_POST['avcp_abilita_ruoli_n'] ) ? '1' : '0' ); |
| 29 |
update_option( 'wpgov_show_love', isset( $_POST['wpgov_show_love_n'] ) ? '1' : '0' ); |
| 30 |
|
| 31 |
echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'Impostazioni aggiornate.', 'avcp' ) . '</p></div>'; |
| 32 |
} |
| 33 |
|
| 34 |
// Get current values |
| 35 |
$denominazione_ente = get_option( 'avcp_denominazione_ente', '' ); |
| 36 |
$codicefiscale_ente = get_option( 'avcp_codicefiscale_ente', '' ); |
| 37 |
$dataset_capability = get_option( 'avcp_dataset_capability', 'manage_options' ); |
| 38 |
$autopublish = get_option( 'avcp_autopublish', '0' ); |
| 39 |
$centricosto = get_option( 'avcp_centricosto', '1' ); |
| 40 |
$dis_archivioditte = get_option( 'avcp_dis_archivioditte', '1' ); |
| 41 |
$dis_archivioanni = get_option( 'avcp_dis_archivioanni', '1' ); |
| 42 |
$abilita_ruoli = get_option( 'avcp_abilita_ruoli', '0' ); |
| 43 |
$wpgov_show_love = get_option( 'wpgov_show_love', '0' ); |
| 44 |
|
| 45 |
?> |
| 46 |
|
| 47 |
<div class="wrap"> |
| 48 |
<h1><?php esc_html_e( 'ANAC XML Bandi di Gara', 'avcp' ); ?></h1> |
| 49 |
<div class="card" style="margin-bottom: 20px;"> |
| 50 |
<p> |
| 51 |
<?php |
| 52 |
printf( |
| 53 |
/* translators: 1: Marco Milesi link, 2: WPGov.it link */ |
| 54 |
esc_html__( 'Software sviluppato da %1$s nell\'ambito del progetto %2$s', 'avcp' ), |
| 55 |
'<a href="' . esc_url( 'https://www.marcomilesi.com' ) . '" target="_blank" rel="noopener">Marco Milesi</a>', |
| 56 |
'<a href="' . esc_url( 'https://www.wpgov.it' ) . '" target="_blank" rel="noopener">WPGov.it</a>' |
| 57 |
); |
| 58 |
?> |
| 59 |
</p> |
| 60 |
<p> |
| 61 |
<strong><?php esc_html_e( 'Risorse utili:', 'avcp' ); ?></strong><br> |
| 62 |
📖 <a href="<?php echo esc_url( 'https://github.com/WPGov/avcp/wiki' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Documentazione e Wiki', 'avcp' ); ?></a><br> |
| 63 |
💻 <a href="<?php echo esc_url( 'https://github.com/WPGov/avcp' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Repository GitHub', 'avcp' ); ?></a> |
| 64 |
</p> |
| 65 |
</div> |
| 66 |
|
| 67 |
<form method="post" action=""> |
| 68 |
<?php wp_nonce_field( 'avcp_save_settings', 'avcp_settings_nonce' ); ?> |
| 69 |
|
| 70 |
<h2 class="title"><?php esc_html_e( 'Impostazioni Ente', 'avcp' ); ?></h2> |
| 71 |
<table class="form-table"> |
| 72 |
<tr> |
| 73 |
<th scope="row"><label for="avcp_denominazione_ente_n"><?php esc_html_e( 'Denominazione Ente', 'avcp' ); ?></label></th> |
| 74 |
<td> |
| 75 |
<input type="text" id="avcp_denominazione_ente_n" name="avcp_denominazione_ente_n" value="<?php echo esc_attr( $denominazione_ente ); ?>" class="regular-text" maxlength="250" /> |
| 76 |
<p class="description"><?php esc_html_e( "Inserire la denominazione dell'Ente (max 250 caratteri)", 'avcp' ); ?></p> |
| 77 |
</td> |
| 78 |
</tr> |
| 79 |
<tr> |
| 80 |
<th scope="row"><label for="avcp_codicefiscale_ente_n"><?php esc_html_e( 'Codice Fiscale Ente', 'avcp' ); ?></label></th> |
| 81 |
<td> |
| 82 |
<input type="text" id="avcp_codicefiscale_ente_n" name="avcp_codicefiscale_ente_n" value="<?php echo esc_attr( $codicefiscale_ente ); ?>" class="regular-text" maxlength="16" /> |
| 83 |
<p class="description"><?php esc_html_e( "Inserire il codice fiscale/partita IVA dell'ente (max 16 caratteri)", 'avcp' ); ?></p> |
| 84 |
</td> |
| 85 |
</tr> |
| 86 |
<tr> |
| 87 |
<th scope="row"><label for="avcp_autopublish_n"><?php esc_html_e( '.XML Automatico', 'avcp' ); ?></label></th> |
| 88 |
<td> |
| 89 |
<input type="checkbox" id="avcp_autopublish_n" name="avcp_autopublish_n" <?php checked( $autopublish, '1' ); ?> /> |
| 90 |
<span class="description"><?php esc_html_e( "Spunta questa casella se vuoi generare e aggiungere automaticamente le gare al file .xml (in base all'anno di riferimento impostato).", 'avcp' ); ?><br/> |
| 91 |
<small><?php esc_html_e( "Attenzione! Con questa funzione ad ogni nuova pubblicazione viene ricreato solo il file .xml relativo all'anno di riferimento della gara. Per creare i file .xml relativi ad ogni anno di riferimento è comunque necessario cliccare sul pulsante di questa pagina, in alto.", 'avcp' ); ?></small></span> |
| 92 |
</td> |
| 93 |
</tr> |
| 94 |
<tr> |
| 95 |
<th scope="row"><label for="avcp_centricosto_n"><?php esc_html_e( 'Abilita Centri di Costo', 'avcp' ); ?></label></th> |
| 96 |
<td> |
| 97 |
<input type="checkbox" id="avcp_centricosto_n" name="avcp_centricosto_n" <?php checked( $centricosto, '0' ); ?> /> |
| 98 |
<span class="description"><?php esc_html_e( "La funzionalità Centri di Costo è abilitata di default e il campo relativo sarà scritto nel file XML. Se l'ente non li prevede, puoi disabilitarne la scrittura nel file xml. Saranno comunque utilizzabili nel sito come tassonomia.", 'avcp' ); ?></span> |
| 99 |
</td> |
| 100 |
</tr> |
| 101 |
</table> |
| 102 |
|
| 103 |
<h2 class="title"><?php esc_html_e( 'Visualizzazioni Archivio', 'avcp' ); ?></h2> |
| 104 |
<table class="form-table"> |
| 105 |
<tr> |
| 106 |
<th scope="row"><label for="avcp_dis_archivioditte_n"><?php esc_html_e( 'Archivio Ditte', 'avcp' ); ?></label></th> |
| 107 |
<td> |
| 108 |
<input type="checkbox" id="avcp_dis_archivioditte_n" name="avcp_dis_archivioditte_n" <?php checked( $dis_archivioditte, '0' ); ?> /> |
| 109 |
<span class="description"><?php esc_html_e( "Abilita i link con la visualizzazione archivio delle ditte con i bandi a cui la ditta ha partecipato", 'avcp' ); ?></span> |
| 110 |
</td> |
| 111 |
</tr> |
| 112 |
<tr> |
| 113 |
<th scope="row"><label for="avcp_dis_archivioanni_n"><?php esc_html_e( 'Archivio Annuale', 'avcp' ); ?></label></th> |
| 114 |
<td> |
| 115 |
<input type="checkbox" id="avcp_dis_archivioanni_n" name="avcp_dis_archivioanni_n" <?php checked( $dis_archivioanni, '0' ); ?> /> |
| 116 |
<span class="description"><?php esc_html_e( "Abilita i link con la visualizzazione archivio su base annuale dei bandi", 'avcp' ); ?></span> |
| 117 |
</td> |
| 118 |
</tr> |
| 119 |
<tr> |
| 120 |
<th scope="row"><label for="wpgov_show_love_n"><?php esc_html_e( 'Mostra Logo WPGov', 'avcp' ); ?></label></th> |
| 121 |
<td> |
| 122 |
<input type="checkbox" id="wpgov_show_love_n" name="wpgov_show_love_n" <?php checked( $wpgov_show_love, '1' ); ?> /> |
| 123 |
<span class="description"><?php esc_html_e( "Mostra il logo WPGov nelle pagine dei bandi per supportare il progetto", 'avcp' ); ?></span> |
| 124 |
</td> |
| 125 |
</tr> |
| 126 |
</table> |
| 127 |
|
| 128 |
<h2 class="title"><?php esc_html_e( 'Ruoli & Permessi', 'avcp' ); ?></h2> |
| 129 |
<p><?php esc_html_e( 'Queste impostazioni sono riservate a utenti avanzati.', 'avcp' ); ?></p> |
| 130 |
<table class="form-table"> |
| 131 |
<tr> |
| 132 |
<th scope="row"><label for="avcp_abilita_ruoli_n"><?php esc_html_e( 'Mappa Meta-Capacità', 'avcp' ); ?></label></th> |
| 133 |
<td> |
| 134 |
<input type="checkbox" id="avcp_abilita_ruoli_n" name="avcp_abilita_ruoli_n" <?php checked( $abilita_ruoli, '1' ); ?> /> |
| 135 |
<span class="description"> |
| 136 |
<?php esc_html_e( 'Le voci del plugin ereditano i permessi degli articoli.', 'avcp' ); ?><br> |
| 137 |
<?php |
| 138 |
printf( |
| 139 |
/* translators: %s: tutorial link */ |
| 140 |
esc_html__( 'Se vuoi avere un maggior controllo abilita questa opzione e segui %s', 'avcp' ), |
| 141 |
'<a href="' . esc_url( 'http://supporto.marcomilesi.ml/?p=571' ) . '" target="_blank" rel="noopener">' . esc_html__( 'questo tutorial', 'avcp' ) . '</a>' |
| 142 |
); |
| 143 |
?> |
| 144 |
</span> |
| 145 |
</td> |
| 146 |
</tr> |
| 147 |
<tr> |
| 148 |
<th scope="row"><label for="avcp_dataset_capability_n"><?php esc_html_e( 'Meta-Capacità per Dataset', 'avcp' ); ?></label></th> |
| 149 |
<td> |
| 150 |
<input type="text" id="avcp_dataset_capability_n" name="avcp_dataset_capability_n" value="<?php echo esc_attr( $dataset_capability ); ?>" class="regular-text" /> |
| 151 |
<span class="description"><?php esc_html_e( 'Inserire la capacità richiesta per la visualizzazione del menù "Dataset XML" (default "manage_options")', 'avcp' ); ?></span> |
| 152 |
</td> |
| 153 |
</tr> |
| 154 |
</table> |
| 155 |
|
| 156 |
<p class="submit"> |
| 157 |
<input type="submit" class="button button-primary" name="Submit" value="<?php esc_attr_e( 'Aggiorna Impostazioni', 'avcp' ); ?>" /> |
| 158 |
</p> |
| 159 |
</form> |
| 160 |
</div> |
| 161 |
|