| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDataAccess\Settings; |
| 4 |
|
| 5 |
use WPDataAccess\Connection\WPDADB; |
| 6 |
use WPDataAccess\Utilities\WPDA_Message_Box; |
| 7 |
use WPDataAccess\WPDA; |
| 8 |
class WPDA_Settings_Plugin extends WPDA_Settings { |
| 9 |
protected function add_content() { |
| 10 |
// Add datetimepicker |
| 11 |
wp_enqueue_style( 'datetimepicker' ); |
| 12 |
wp_enqueue_script( 'datetimepicker' ); |
| 13 |
if ( isset( $_REQUEST['action'] ) ) { |
| 14 |
$action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); |
| 15 |
// input var okay. |
| 16 |
// Security check. |
| 17 |
if ( 'delete_remote_database' === $action ) { |
| 18 |
$wp_nonce = ( isset( $_REQUEST['_wpnoncedelrdb'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnoncedelrdb'] ) ) : '' ); |
| 19 |
// input var okay. |
| 20 |
if ( !wp_verify_nonce( $wp_nonce, 'wpda-delete-remote-database-' . WPDA::get_current_user_login() ) ) { |
| 21 |
wp_die( __( 'ERROR: Not authorized', 'wp-data-access' ) ); |
| 22 |
} |
| 23 |
if ( isset( $_REQUEST['remote_database_name'] ) ) { |
| 24 |
$remote_database_name = sanitize_text_field( wp_unslash( $_REQUEST['remote_database_name'] ) ); |
| 25 |
// input var okay. |
| 26 |
WPDADB::del_remote_database( $remote_database_name ); |
| 27 |
} |
| 28 |
} elseif ( 'update_remote_database' === $action ) { |
| 29 |
$wp_nonce = ( isset( $_REQUEST['_wpnonceupdrdb'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonceupdrdb'] ) ) : '' ); |
| 30 |
// input var okay. |
| 31 |
if ( !wp_verify_nonce( $wp_nonce, 'wpda-update-remote-database-' . WPDA::get_current_user_login() ) ) { |
| 32 |
wp_die( __( 'ERROR: Not authorized', 'wp-data-access' ) ); |
| 33 |
} |
| 34 |
$database_old = ( isset( $_REQUEST['remote_database_old'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_database_old'] ) ) : '' ); |
| 35 |
// input var okay. |
| 36 |
$database = ( isset( $_REQUEST['remote_database'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_database'] ) ) : '' ); |
| 37 |
// input var okay. |
| 38 |
$host = ( isset( $_REQUEST['remote_host'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_host'] ) ) : '' ); |
| 39 |
// input var okay. |
| 40 |
$username = ( isset( $_REQUEST['remote_user'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_user'] ) ) : '' ); |
| 41 |
// input var okay. |
| 42 |
$password = ( isset( $_REQUEST['remote_passwd'] ) ? wp_unslash( $_REQUEST['remote_passwd'] ) : '' ); |
| 43 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 44 |
$port = ( isset( $_REQUEST['remote_port'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_port'] ) ) : '' ); |
| 45 |
// input var okay. |
| 46 |
$schema = ( isset( $_REQUEST['remote_schema'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_schema'] ) ) : '' ); |
| 47 |
// input var okay. |
| 48 |
$enabled = ( isset( $_REQUEST['remote_enabled'] ) ? true : false ); |
| 49 |
// Add ssl |
| 50 |
$remote_ssl = ( isset( $_REQUEST['remote_ssl'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_ssl'] ) ) : 'off' ); |
| 51 |
// input var okay. |
| 52 |
$remote_client_key = ( isset( $_REQUEST['remote_client_key'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_client_key'] ) ) : '' ); |
| 53 |
// input var okay. |
| 54 |
$remote_client_certificate = ( isset( $_REQUEST['remote_client_certificate'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_client_certificate'] ) ) : '' ); |
| 55 |
// input var okay. |
| 56 |
$remote_ca_certificate = ( isset( $_REQUEST['remote_ca_certificate'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_ca_certificate'] ) ) : '' ); |
| 57 |
// input var okay. |
| 58 |
$remote_certificate_path = ( isset( $_REQUEST['remote_certificate_path'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_certificate_path'] ) ) : '' ); |
| 59 |
// input var okay. |
| 60 |
$remote_specified_cipher = ( isset( $_REQUEST['remote_specified_cipher'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['remote_specified_cipher'] ) ) : '' ); |
| 61 |
// input var okay. |
| 62 |
if ( '' === $database_old || '' === $database || '' === $host || '' === $username || '' === $password || '' === $port || '' === $schema || '' === $enabled ) { |
| 63 |
$msg = new WPDA_Message_Box(array( |
| 64 |
'message_text' => sprintf( __( 'Cannot save remote database connection [missing arguments]', 'wp-data-access' ) ), |
| 65 |
'message_type' => 'error', |
| 66 |
'message_is_dismissible' => false, |
| 67 |
)); |
| 68 |
$msg->box(); |
| 69 |
} else { |
| 70 |
WPDADB::upd_remote_database( |
| 71 |
$database, |
| 72 |
$host, |
| 73 |
$username, |
| 74 |
$password, |
| 75 |
$port, |
| 76 |
$schema, |
| 77 |
!$enabled, |
| 78 |
$database_old, |
| 79 |
$remote_ssl, |
| 80 |
$remote_client_key, |
| 81 |
$remote_client_certificate, |
| 82 |
$remote_ca_certificate, |
| 83 |
$remote_certificate_path, |
| 84 |
$remote_specified_cipher |
| 85 |
); |
| 86 |
} |
| 87 |
} else { |
| 88 |
$wp_nonce = ( isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : '' ); |
| 89 |
// input var okay. |
| 90 |
if ( !wp_verify_nonce( $wp_nonce, 'wpda-plugin-settings-' . WPDA::get_current_user_login() ) ) { |
| 91 |
wp_die( __( 'ERROR: Not authorized', 'wp-data-access' ) ); |
| 92 |
} |
| 93 |
if ( 'save' === $action ) { |
| 94 |
WPDA::set_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES, ( isset( $_REQUEST['hide_foreign_notices'] ) ? 'on' : 'off' ) ); |
| 95 |
WPDA::set_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU, ( isset( $_REQUEST['hide_admin_menu'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['hide_admin_menu'] ) ) : 'off' ) ); |
| 96 |
if ( isset( $_REQUEST['panel_cookies'] ) ) { |
| 97 |
WPDA::set_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES, sanitize_text_field( wp_unslash( $_REQUEST['panel_cookies'] ) ) ); |
| 98 |
} |
| 99 |
if ( !isset( $_REQUEST['secret_key'] ) || !isset( $_REQUEST['secret_iv'] ) ) { |
| 100 |
// Leave both values untouched |
| 101 |
} else { |
| 102 |
$secret_key_old = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_KEY ); |
| 103 |
$secret_iv_old = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_IV ); |
| 104 |
$secret_key_new = sanitize_text_field( wp_unslash( $_REQUEST['secret_key'] ) ); |
| 105 |
// input var okay. |
| 106 |
$secret_iv_new = sanitize_text_field( wp_unslash( $_REQUEST['secret_iv'] ) ); |
| 107 |
// input var okay. |
| 108 |
if ( $secret_key_old !== $secret_key_new || $secret_iv_old !== $secret_iv_new ) { |
| 109 |
// Update existing remote databases |
| 110 |
WPDADB::load_remote_databases(); |
| 111 |
// load remote databases with old secret key and iv |
| 112 |
WPDA::set_option( WPDA::OPTION_PLUGIN_SECRET_KEY, $secret_key_new ); |
| 113 |
// update secret key |
| 114 |
WPDA::set_option( WPDA::OPTION_PLUGIN_SECRET_IV, $secret_iv_new ); |
| 115 |
// update secret iv |
| 116 |
WPDADB::save_remote_databases(); |
| 117 |
// save remote databases with new secret key and iv |
| 118 |
} |
| 119 |
} |
| 120 |
if ( isset( $_REQUEST['remote_database_name'] ) && isset( $_REQUEST['remote_database_enabled'] ) ) { |
| 121 |
if ( is_array( $_REQUEST['remote_database_name'] ) && is_array( $_REQUEST['remote_database_enabled'] ) && count( $_REQUEST['remote_database_name'] ) === count( $_REQUEST['remote_database_enabled'] ) ) { |
| 122 |
$i = 0; |
| 123 |
while ( $i < count( $_REQUEST['remote_database_name'] ) ) { |
| 124 |
//phpcs:ignore - 8.1 proof |
| 125 |
$rdb_name = sanitize_text_field( wp_unslash( $_REQUEST['remote_database_name'][$i] ) ); |
| 126 |
$dbs = WPDADB::get_remote_database( $rdb_name, true ); |
| 127 |
if ( !$dbs ) { |
| 128 |
$msg = new WPDA_Message_Box(array( |
| 129 |
'message_text' => __( 'Remote database connection not found', 'wp-data-access' ), |
| 130 |
'message_type' => 'error', |
| 131 |
'message_is_dismissible' => false, |
| 132 |
)); |
| 133 |
$msg->box(); |
| 134 |
} else { |
| 135 |
WPDADB::upd_remote_database( |
| 136 |
$rdb_name, |
| 137 |
$dbs['host'], |
| 138 |
$dbs['username'], |
| 139 |
$dbs['password'], |
| 140 |
$dbs['port'], |
| 141 |
$dbs['database'], |
| 142 |
$_REQUEST['remote_database_enabled'][$i] === 'FALSE', |
| 143 |
false, |
| 144 |
$dbs['ssl'], |
| 145 |
$dbs['ssl_key'], |
| 146 |
$dbs['ssl_cert'], |
| 147 |
$dbs['ssl_ca'], |
| 148 |
$dbs['ssl_path'], |
| 149 |
$dbs['ssl_cipher'] |
| 150 |
); |
| 151 |
} |
| 152 |
$i++; |
| 153 |
} |
| 154 |
WPDADB::save_remote_databases(); |
| 155 |
// save changes |
| 156 |
} |
| 157 |
} |
| 158 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_POST, ( isset( $_REQUEST['wpdataaccess_post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdataaccess_post'] ) ) : 'off' ) ); |
| 159 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_PAGE, ( isset( $_REQUEST['wpdataaccess_page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdataaccess_page'] ) ) : 'off' ) ); |
| 160 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_POST, ( isset( $_REQUEST['wpdadiehard_post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadiehard_post'] ) ) : 'off' ) ); |
| 161 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_PAGE, ( isset( $_REQUEST['wpdadiehard_page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadiehard_page'] ) ) : 'off' ) ); |
| 162 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_POST, ( isset( $_REQUEST['wpdadataforms_post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadataforms_post'] ) ) : 'off' ) ); |
| 163 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_PAGE, ( isset( $_REQUEST['wpdadataforms_page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadataforms_page'] ) ) : 'off' ) ); |
| 164 |
WPDA::set_option( WPDA::OPTION_PLUGIN_DEBUG, ( isset( $_REQUEST['debug'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['debug'] ) ) : 'off' ) ); |
| 165 |
if ( isset( $_REQUEST['date_format'] ) ) { |
| 166 |
WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_FORMAT, sanitize_text_field( wp_unslash( $_REQUEST['date_format'] ) ) ); |
| 167 |
} |
| 168 |
if ( isset( $_REQUEST['date_placeholder'] ) ) { |
| 169 |
WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_PLACEHOLDER, sanitize_text_field( wp_unslash( $_REQUEST['date_placeholder'] ) ) ); |
| 170 |
} |
| 171 |
if ( isset( $_REQUEST['time_format'] ) ) { |
| 172 |
WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_FORMAT, sanitize_text_field( wp_unslash( $_REQUEST['time_format'] ) ) ); |
| 173 |
} |
| 174 |
if ( isset( $_REQUEST['time_placeholder'] ) ) { |
| 175 |
WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_PLACEHOLDER, sanitize_text_field( wp_unslash( $_REQUEST['time_placeholder'] ) ) ); |
| 176 |
} |
| 177 |
if ( isset( $_REQUEST['set_format'] ) ) { |
| 178 |
WPDA::set_option( WPDA::OPTION_PLUGIN_SET_FORMAT, sanitize_text_field( wp_unslash( $_REQUEST['set_format'] ) ) ); |
| 179 |
} |
| 180 |
} elseif ( 'setdefaults' === $action ) { |
| 181 |
// Set all back-end settings back to default. |
| 182 |
WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES ); |
| 183 |
WPDA::set_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU ); |
| 184 |
WPDA::set_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES ); |
| 185 |
// DO NOT RESET SECRET KEY AND IV |
| 186 |
// DO NOT RESET RDBs |
| 187 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_POST ); |
| 188 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_PAGE ); |
| 189 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_POST ); |
| 190 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_PAGE ); |
| 191 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_POST ); |
| 192 |
WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_PAGE ); |
| 193 |
WPDA::set_option( WPDA::OPTION_PLUGIN_DEBUG ); |
| 194 |
WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_FORMAT ); |
| 195 |
WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_PLACEHOLDER ); |
| 196 |
WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_FORMAT ); |
| 197 |
WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_PLACEHOLDER ); |
| 198 |
WPDA::set_option( WPDA::OPTION_PLUGIN_SET_FORMAT ); |
| 199 |
} |
| 200 |
} |
| 201 |
$msg = new WPDA_Message_Box(array( |
| 202 |
'message_text' => __( 'Settings saved', 'wp-data-access' ), |
| 203 |
)); |
| 204 |
$msg->box(); |
| 205 |
} elseif ( isset( $_REQUEST['msg'] ) && 'ok' === $_REQUEST['msg'] ) { |
| 206 |
$msg = new WPDA_Message_Box(array( |
| 207 |
'message_text' => __( 'Settings saved', 'wp-data-access' ), |
| 208 |
)); |
| 209 |
$msg->box(); |
| 210 |
} |
| 211 |
// Get options. |
| 212 |
$hide_foreign_notices = WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES ); |
| 213 |
$hide_admin_menu = WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU ); |
| 214 |
$panel_cookies = WPDA::get_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES ); |
| 215 |
$secret_key = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_KEY ); |
| 216 |
$secret_iv = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_IV ); |
| 217 |
$wpdataaccess_post = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_POST ); |
| 218 |
$wpdataaccess_page = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_PAGE ); |
| 219 |
$wpdadiehard_post = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_POST ); |
| 220 |
$wpdadiehard_page = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_PAGE ); |
| 221 |
$wpdadataforms_post = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_POST ); |
| 222 |
$wpdadataforms_page = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_PAGE ); |
| 223 |
$debug = WPDA::get_option( WPDA::OPTION_PLUGIN_DEBUG ); |
| 224 |
$date_format = WPDA::get_option( WPDA::OPTION_PLUGIN_DATE_FORMAT ); |
| 225 |
$date_placeholder = WPDA::get_option( WPDA::OPTION_PLUGIN_DATE_PLACEHOLDER ); |
| 226 |
$time_format = WPDA::get_option( WPDA::OPTION_PLUGIN_TIME_FORMAT ); |
| 227 |
$time_placeholder = WPDA::get_option( WPDA::OPTION_PLUGIN_TIME_PLACEHOLDER ); |
| 228 |
$set_format = WPDA::get_option( WPDA::OPTION_PLUGIN_SET_FORMAT ); |
| 229 |
$remote_databases = WPDADB::get_remote_databases( true ); |
| 230 |
?> |
| 231 |
<style type="text/css"> |
| 232 |
.settings_line { |
| 233 |
line-height: 2.4; |
| 234 |
} |
| 235 |
|
| 236 |
.settings_label { |
| 237 |
display: inline-block; |
| 238 |
width: 7em; |
| 239 |
font-weight: bold; |
| 240 |
} |
| 241 |
|
| 242 |
.item_width { |
| 243 |
width: 14em; |
| 244 |
} |
| 245 |
|
| 246 |
.item_label { |
| 247 |
width: 14.9em; |
| 248 |
display: inline-block; |
| 249 |
padding-left: 0.3em; |
| 250 |
} |
| 251 |
|
| 252 |
.item_label_text { |
| 253 |
width: 7em; |
| 254 |
display: inline-block; |
| 255 |
} |
| 256 |
|
| 257 |
.item_label_format { |
| 258 |
width: 5em; |
| 259 |
padding: 0.6em; |
| 260 |
border-radius: 4px; |
| 261 |
} |
| 262 |
|
| 263 |
.item_label_align { |
| 264 |
float: right; |
| 265 |
} |
| 266 |
|
| 267 |
#wpda_update_database_popup { |
| 268 |
display: none; |
| 269 |
padding: 10px; |
| 270 |
position: absolute; |
| 271 |
top: 30px; |
| 272 |
left: 10px; |
| 273 |
color: black; |
| 274 |
overflow-y: auto; |
| 275 |
background-color: white; |
| 276 |
border: 1px solid #ccc; |
| 277 |
width: max-content; |
| 278 |
} |
| 279 |
|
| 280 |
#wpda_update_database_popup_header { |
| 281 |
background-color: #ccc; |
| 282 |
height: 30px; |
| 283 |
padding: 10px; |
| 284 |
margin-bottom: 10px; |
| 285 |
} |
| 286 |
</style> |
| 287 |
<script type='text/javascript'> |
| 288 |
jQuery(function () { |
| 289 |
jQuery('.radio_date_format').on('click', function() { |
| 290 |
jQuery('#date_format').val(jQuery(this).val()); |
| 291 |
}); |
| 292 |
|
| 293 |
jQuery('.radio_time_format').on('click', function() { |
| 294 |
jQuery('#time_format').val(jQuery(this).val()); |
| 295 |
}); |
| 296 |
|
| 297 |
jQuery.datetimepicker.setLocale('<?php |
| 298 |
echo esc_attr( substr( get_locale(), 0, 2 ) ); |
| 299 |
?>'); |
| 300 |
jQuery('#test_datetime').attr('autocomplete', 'off'); |
| 301 |
jQuery('#init_datetime').on('click', function() { |
| 302 |
jQuery('#test_datetime').datetimepicker({ |
| 303 |
format: jQuery('#date_format').val() + ' ' + jQuery('#time_format').val(), |
| 304 |
datepicker: true, |
| 305 |
timepicker: true |
| 306 |
}); |
| 307 |
jQuery('#init_datetime').toggle(); |
| 308 |
jQuery('#test_datetime').toggle(); |
| 309 |
jQuery('#test_datetime').val(''); |
| 310 |
jQuery('#test_datetime').attr('placeholder', jQuery('#date_placeholder').val() + ' ' + jQuery('#time_placeholder').val()); |
| 311 |
}); |
| 312 |
jQuery('#test_datetime').on('blur', function() { |
| 313 |
jQuery('#test_datetime').toggle(); |
| 314 |
jQuery('#init_datetime').toggle(); |
| 315 |
}); |
| 316 |
}); |
| 317 |
|
| 318 |
function delete_remote_database(id) { |
| 319 |
remote_database_name = jQuery('#remote_database_name' + id).val(); |
| 320 |
if (confirm("<?php |
| 321 |
echo __( 'Delete remote database connection from plugin repository?', 'wp-data-access' ); |
| 322 |
?>")) { |
| 323 |
jQuery('#delete_remote_database_name').val(remote_database_name); |
| 324 |
jQuery('#wpda_delete_database').submit(); |
| 325 |
} |
| 326 |
} |
| 327 |
|
| 328 |
function update_rdb_setting(id) { |
| 329 |
if (jQuery('#remote_database' + id).is(':checked')) { |
| 330 |
jQuery('#remote_database_enabled' + id).val('TRUE'); |
| 331 |
} else { |
| 332 |
jQuery('#remote_database_enabled' + id).val('FALSE'); |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
function edit_rdb_setting(id) { |
| 337 |
jQuery('#wpda_update_database_popup').show(); |
| 338 |
jQuery('#remote_database_old').val(id); |
| 339 |
jQuery('#remote_database').val(id); |
| 340 |
jQuery('#remote_host').val(remote_databases[id].host); |
| 341 |
jQuery('#remote_user').val(remote_databases[id].username); |
| 342 |
jQuery('#remote_passwd').val(remote_databases[id].password); |
| 343 |
jQuery('#remote_port').val(remote_databases[id].port); |
| 344 |
jQuery('#remote_schema').val(remote_databases[id].database); |
| 345 |
jQuery('#remote_enabled').prop('checked', !remote_databases[id].disabled); |
| 346 |
jQuery('#remote_ssl').prop('checked', remote_databases[id].ssl==="on");//.val(remote_databases[id].ssl); |
| 347 |
jQuery('#remote_client_key').val(remote_databases[id].ssl_key); |
| 348 |
jQuery('#remote_client_certificate').val(remote_databases[id].ssl_cert); |
| 349 |
jQuery('#remote_ca_certificate').val(remote_databases[id].ssl_ca); |
| 350 |
jQuery('#remote_certificate_path').val(remote_databases[id].ssl_path); |
| 351 |
jQuery('#remote_specified_cipher').val(remote_databases[id].ssl_cipher); |
| 352 |
if (remote_databases[id].ssl==="on") { |
| 353 |
jQuery('#remote_database_block_ssl').show(); |
| 354 |
} else { |
| 355 |
jQuery('#remote_database_block_ssl').hide(); |
| 356 |
} |
| 357 |
} |
| 358 |
|
| 359 |
function test_remote_clear(mode = '') { |
| 360 |
jQuery('#' + mode + 'remote_database_block_test_content').html(''); |
| 361 |
jQuery('#' + mode + 'remote_database_block_test').hide(); |
| 362 |
jQuery('#' + mode + 'remote_clear_button').hide(); |
| 363 |
} |
| 364 |
|
| 365 |
function test_remote_connection(mode = '') { |
| 366 |
host = jQuery('#remote_host').val(); |
| 367 |
user = jQuery('#remote_user').val(); |
| 368 |
pass = jQuery('#remote_passwd').val(); |
| 369 |
port = jQuery('#remote_port').val(); |
| 370 |
dbs = jQuery('#remote_schema').val(); |
| 371 |
|
| 372 |
url = '//' + window.location.host + window.location.pathname.replace('options-general','admin') + |
| 373 |
'?action=wpda_check_remote_database_connection'; |
| 374 |
|
| 375 |
jQuery('#remote_test_button').val('Testing...'); |
| 376 |
|
| 377 |
jQuery.ajax({ |
| 378 |
method: 'POST', |
| 379 |
url: url, |
| 380 |
data: { |
| 381 |
host: host, |
| 382 |
user: user, |
| 383 |
passwd: pass, |
| 384 |
port: port, |
| 385 |
schema: dbs |
| 386 |
} |
| 387 |
}).done( |
| 388 |
function (msg) { |
| 389 |
jQuery('#remote_database_block_test_content').html(msg); |
| 390 |
jQuery('#remote_database_block_test').show(); |
| 391 |
} |
| 392 |
).fail( |
| 393 |
function () { |
| 394 |
jQuery('#remote_database_block_test_content').html('Preparing connection...<br/>Establishing connection...<br/><br/><strong>Remote database connection invalid</strong>'); |
| 395 |
jQuery('#remote_database_block_test').show(); |
| 396 |
} |
| 397 |
).always( |
| 398 |
function () { |
| 399 |
jQuery('#remote_test_button').val('Test'); |
| 400 |
jQuery('#remote_clear_button').show(); |
| 401 |
} |
| 402 |
); |
| 403 |
} |
| 404 |
|
| 405 |
jQuery(function () { |
| 406 |
jQuery('#remote_database').keydown(function(e) { |
| 407 |
var field = this; |
| 408 |
setTimeout(function () { |
| 409 |
if (field.value.indexOf('rdb:') !== 0) { |
| 410 |
jQuery(field).val('rdb:'); |
| 411 |
} |
| 412 |
}, 1); |
| 413 |
}); |
| 414 |
}); |
| 415 |
|
| 416 |
var remote_databases = new Object(); |
| 417 |
<?php |
| 418 |
foreach ( $remote_databases as $key => $value ) { |
| 419 |
echo "remote_databases['{$key}'] = " . json_encode( $value ) . ';'; |
| 420 |
// phpcs:ignore WordPress.Security.EscapeOutput |
| 421 |
} |
| 422 |
?> |
| 423 |
</script> |
| 424 |
<div id="wpda_update_database_popup"> |
| 425 |
<div id="wpda_update_database_popup_header"> |
| 426 |
<span style="display:inline-block;margin-top:5px;"> |
| 427 |
<strong> |
| 428 |
<?php |
| 429 |
echo __( 'Edit Remote Database Connection', 'wp-data-access' ); |
| 430 |
?> |
| 431 |
</strong> |
| 432 |
</span> |
| 433 |
<span class="button" style="float:right;height:10px;" |
| 434 |
onclick="jQuery('#wpda_update_database_popup').hide()">x</span><br/> |
| 435 |
</div> |
| 436 |
|
| 437 |
<form id="wpda_update_database" method="post" |
| 438 |
action="?page=<?php |
| 439 |
echo esc_attr( $this->page ); |
| 440 |
?>&tab=plugin"> |
| 441 |
|
| 442 |
<div> |
| 443 |
<label for="remote_database" style="vertical-align:baseline;" |
| 444 |
class="database_item_label">Database name:</label> |
| 445 |
<input type="text" name="remote_database" id="remote_database" value="rdb:"> |
| 446 |
<span>(local WordPress dashboard)</span> |
| 447 |
<div style="height:10px;"></div> |
| 448 |
<label for="remote_host" style="vertical-align:baseline;" class="database_item_label">MySQL host:</label> |
| 449 |
<input type="text" name="remote_host" id="remote_host"> |
| 450 |
<span>(ip address or hostname)</span> |
| 451 |
<br/> |
| 452 |
<label for="remote_user" style="vertical-align:baseline;" class="database_item_label">MySQL username:</label> |
| 453 |
<input type="text" name="remote_user" id="remote_user"> |
| 454 |
<br/> |
| 455 |
<label for="remote_passwd" style="vertical-align:baseline;" class="database_item_label">MySQL password:</label> |
| 456 |
<input type="password" name="remote_passwd" id="remote_passwd" autocomplete="new-password"> |
| 457 |
<i class="fas fa-eye" onclick="wpda_toggle_password('remote_passwd', event)" style="cursor:pointer"></i> |
| 458 |
<br/> |
| 459 |
<label for="remote_port" style="vertical-align:baseline;" class="database_item_label">MySQL port:</label> |
| 460 |
<input type="text" name="remote_port" id="remote_port" value="3306"> |
| 461 |
<br/> |
| 462 |
<label for="remote_schema" style="vertical-align:baseline;" class="database_item_label">MySQL schema:</label> |
| 463 |
<input type="text" name="remote_schema" id="remote_schema"> |
| 464 |
<br/> |
| 465 |
<label for="remote_schema" style="vertical-align:baseline;line-height:30px;" class="database_item_label"> |
| 466 |
Enabled: |
| 467 |
</label> |
| 468 |
<input type="checkbox" name="remote_enabled" id="remote_enabled"> |
| 469 |
|
| 470 |
<br/> |
| 471 |
<label style="line-height:30px;" for="remote_ssl" style="vertical-align:baseline;" class="database_item_label">SSL:</label> |
| 472 |
<input type="checkbox" name="remote_ssl" id="remote_ssl" unchecked onclick="jQuery('#remote_database_block_ssl').toggle()"> |
| 473 |
<div id="remote_database_block_ssl"> |
| 474 |
<label for="remote_client_key" style="vertical-align:baseline;" class="database_item_label">Client key:</label> |
| 475 |
<input type="text" name="remote_client_key" id="remote_client_key"> |
| 476 |
<br/> |
| 477 |
<label for="remote_client_certificate" style="vertical-align:baseline;" class="database_item_label">Client certificate:</label> |
| 478 |
<input type="text" name="remote_client_certificate" id="remote_client_certificate"> |
| 479 |
<br/> |
| 480 |
<label for="remote_ca_certificate" style="vertical-align:baseline;" class="database_item_label">CA certificate:</label> |
| 481 |
<input type="text" name="remote_ca_certificate" id="remote_ca_certificate"> |
| 482 |
<br/> |
| 483 |
<label for="remote_certificate_path" style="vertical-align:baseline;" class="database_item_label">Certificate path:</label> |
| 484 |
<input type="text" name="remote_certificate_path" id="remote_certificate_path"> |
| 485 |
<br/> |
| 486 |
<label for="remote_specified_cipher" style="vertical-align:baseline;" class="database_item_label">Specified Cipher:</label> |
| 487 |
<input type="text" name="remote_specified_cipher" id="remote_specified_cipher"> |
| 488 |
</div> |
| 489 |
|
| 490 |
<div style="height:10px;"></div> |
| 491 |
<label class="database_item_label"></label> |
| 492 |
<input type="button" value="Test" onclick="test_remote_connection(); return false;" |
| 493 |
id="remote_test_button" class="button"> |
| 494 |
<input type="button" value="Clear" onclick="test_remote_clear(); return false;" |
| 495 |
id="remote_clear_button" class="button" style="display:none;"> |
| 496 |
<div style="height:10px;"></div> |
| 497 |
</div> |
| 498 |
<div id="remote_database_block_test" style="display:none;"> |
| 499 |
<div id="remote_database_block_test_content" |
| 500 |
class="remote_database_block_test_content"></div> |
| 501 |
<div style="height:10px;"></div> |
| 502 |
</div> |
| 503 |
<input type="hidden" name="remote_database_old" id="remote_database_old" value="""> |
| 504 |
<input type="hidden" name="action" value="update_remote_database"/> |
| 505 |
<input type="submit" class="button button-secondary" value="<?php |
| 506 |
echo __( 'Save', 'wp-data-access' ); |
| 507 |
?>"> |
| 508 |
<a href="javascript:void(0)" |
| 509 |
onclick="jQuery('#wpda_update_database_popup').hide()" |
| 510 |
class="button button-secondary"> |
| 511 |
<?php |
| 512 |
echo __( 'Cancel', 'wp-data-access' ); |
| 513 |
?> |
| 514 |
</a> |
| 515 |
<?php |
| 516 |
$rdb_wp_nonce_action = 'wpda-update-remote-database-' . WPDA::get_current_user_login(); |
| 517 |
$rdb_wp_nonce = wp_create_nonce( $rdb_wp_nonce_action ); |
| 518 |
?> |
| 519 |
<input type="hidden" name="_wpnonceupdrdb" value="<?php |
| 520 |
echo esc_attr( $rdb_wp_nonce ); |
| 521 |
?>"/> |
| 522 |
</form> |
| 523 |
</div> |
| 524 |
<form id="wpda_delete_database" method="post" style="display:none;" |
| 525 |
action="?page=<?php |
| 526 |
echo esc_attr( $this->page ); |
| 527 |
?>&tab=plugin"> |
| 528 |
<input type="hidden" name="remote_database_name" id="delete_remote_database_name" value=""/> |
| 529 |
<input type="hidden" name="action" value="delete_remote_database"/> |
| 530 |
<?php |
| 531 |
$rdb_wp_nonce_action = 'wpda-delete-remote-database-' . WPDA::get_current_user_login(); |
| 532 |
$rdb_wp_nonce = wp_create_nonce( $rdb_wp_nonce_action ); |
| 533 |
?> |
| 534 |
<input type="hidden" name="_wpnoncedelrdb" value="<?php |
| 535 |
echo esc_attr( $rdb_wp_nonce ); |
| 536 |
?>"/> |
| 537 |
</form> |
| 538 |
<form id="wpda_settings_plugin" method="post" |
| 539 |
action="?page=<?php |
| 540 |
echo esc_attr( $this->page ); |
| 541 |
?>&tab=plugin"> |
| 542 |
<table class="wpda-table-settings" id="wpda_table_plugin"> |
| 543 |
<tr> |
| 544 |
<th><?php |
| 545 |
echo __( 'Plugin menu', 'wp-data-access' ); |
| 546 |
?></th> |
| 547 |
<td> |
| 548 |
<label> |
| 549 |
<input type="checkbox" name="hide_admin_menu" <?php |
| 550 |
echo ( 'on' === $hide_admin_menu ? 'checked="checked"' : '' ); |
| 551 |
?>/> |
| 552 |
<?php |
| 553 |
echo __( 'Hide plugin menu in admin panel', 'wp-data-access' ); |
| 554 |
?> |
| 555 |
</label> |
| 556 |
</td> |
| 557 |
</tr> |
| 558 |
<tr> |
| 559 |
<th><?php |
| 560 |
echo __( 'Notices', 'wp-data-access' ); |
| 561 |
?></th> |
| 562 |
<td> |
| 563 |
<label> |
| 564 |
<input type="checkbox" name="hide_foreign_notices" <?php |
| 565 |
echo ( $hide_foreign_notices === 'on' ? 'checked' : '' ); |
| 566 |
?> /> |
| 567 |
<?php |
| 568 |
echo __( 'Hide notices of other themes and plugins on WP Data Access admin pages', 'wp-data-access' ); |
| 569 |
?> |
| 570 |
</label> |
| 571 |
</td> |
| 572 |
</tr> |
| 573 |
<tr> |
| 574 |
<th><?php |
| 575 |
echo __( 'Panel cookies', 'wp-data-access' ); |
| 576 |
?></th> |
| 577 |
<td> |
| 578 |
<label> |
| 579 |
<input |
| 580 |
type="radio" |
| 581 |
name="panel_cookies" |
| 582 |
value="clear" |
| 583 |
<?php |
| 584 |
echo ( 'clear' === $panel_cookies ? 'checked' : '' ); |
| 585 |
?> |
| 586 |
><?php |
| 587 |
echo __( 'Clear when switching panels', 'wp-data-access' ); |
| 588 |
?> |
| 589 |
</label> |
| 590 |
<br/> |
| 591 |
<label> |
| 592 |
<input |
| 593 |
type="radio" |
| 594 |
name="panel_cookies" |
| 595 |
value="keep" |
| 596 |
<?php |
| 597 |
echo ( 'keep' === $panel_cookies ? 'checked' : '' ); |
| 598 |
?> |
| 599 |
><?php |
| 600 |
echo __( 'Keep when switching panels', 'wp-data-access' ); |
| 601 |
?> |
| 602 |
</label> |
| 603 |
</td> |
| 604 |
</tr> |
| 605 |
<tr> |
| 606 |
<th><?php |
| 607 |
echo __( 'Secret key and IV' ); |
| 608 |
?></th> |
| 609 |
<td> |
| 610 |
<input type="text" name="secret_key" value="<?php |
| 611 |
echo esc_attr( $secret_key ); |
| 612 |
?>"/> |
| 613 |
<br/> |
| 614 |
<input type="text" name="secret_iv" value="<?php |
| 615 |
echo esc_attr( $secret_iv ); |
| 616 |
?>"/> |
| 617 |
<br/><br/> |
| 618 |
<span class="dashicons dashicons-info"></span><?php |
| 619 |
echo __( 'Existing remote database connection settings will be converted', 'wp-data-access' ); |
| 620 |
?> |
| 621 |
</td> |
| 622 |
</tr> |
| 623 |
<tr> |
| 624 |
<th><?php |
| 625 |
echo __( 'Remote database connections' ); |
| 626 |
?></th> |
| 627 |
<td> |
| 628 |
<?php |
| 629 |
$i = 0; |
| 630 |
foreach ( $remote_databases as $remote_database => $remote_database_settings ) { |
| 631 |
$checked = ( isset( $remote_database_settings['disabled'] ) && $remote_database_settings['disabled'] ? '' : 'checked' ); |
| 632 |
$enabled = ( isset( $remote_database_settings['disabled'] ) && $remote_database_settings['disabled'] ? 'FALSE' : 'TRUE' ); |
| 633 |
?> |
| 634 |
<a href="javascript:void(0)" |
| 635 |
onclick="delete_remote_database('<?php |
| 636 |
echo esc_attr( $i ); |
| 637 |
?>')" |
| 638 |
style="text-decoration:none;" |
| 639 |
class="wpda_tooltip" |
| 640 |
title="<?php |
| 641 |
echo __( 'Delete remote database connection from plugin repository', 'wp-data-access' ); |
| 642 |
?>"> |
| 643 |
<span class="dashicons dashicons-trash" style="font-size:18px;"></span> |
| 644 |
</a> |
| 645 |
<label class="wpda_tooltip" title="<?php |
| 646 |
echo __( 'Disable remote database connection', 'wp-data-access' ); |
| 647 |
?>"> |
| 648 |
<input type="checkbox" name="remote_database[]" id="remote_database<?php |
| 649 |
echo esc_attr( $i ); |
| 650 |
?>" onclick="update_rdb_setting('<?php |
| 651 |
echo esc_attr( $i ); |
| 652 |
?>')" <?php |
| 653 |
echo esc_attr( $checked ); |
| 654 |
?>> |
| 655 |
<input type="hidden" name="remote_database_name[]" id="remote_database_name<?php |
| 656 |
echo esc_attr( $i ); |
| 657 |
?>" value="<?php |
| 658 |
echo esc_attr( $remote_database ); |
| 659 |
?>"> |
| 660 |
<input type="hidden" name="remote_database_enabled[]" id="remote_database_enabled<?php |
| 661 |
echo esc_attr( $i ); |
| 662 |
?>" value="<?php |
| 663 |
echo esc_attr( $enabled ); |
| 664 |
?>"> |
| 665 |
<?php |
| 666 |
echo esc_attr( $remote_database ); |
| 667 |
?> |
| 668 |
</label> |
| 669 |
<a href="javascript:void(0)" |
| 670 |
onclick="edit_rdb_setting('<?php |
| 671 |
echo esc_attr( $remote_database ); |
| 672 |
?>')" |
| 673 |
style="text-decoration:none;" |
| 674 |
class="wpda_tooltip" |
| 675 |
title="<?php |
| 676 |
echo __( 'Edit remote database connection', 'wp-data-access' ); |
| 677 |
?>"> |
| 678 |
<span class="dashicons dashicons-edit" style="font-size:18px;"></span> |
| 679 |
</a><br/> |
| 680 |
<?php |
| 681 |
$i++; |
| 682 |
} |
| 683 |
?> |
| 684 |
</td> |
| 685 |
</tr> |
| 686 |
<tr> |
| 687 |
<th><?php |
| 688 |
echo __( 'Shortcode [wpdataaccess]' ); |
| 689 |
?></th> |
| 690 |
<td> |
| 691 |
<label> |
| 692 |
<input type="checkbox" name="wpdataaccess_post" <?php |
| 693 |
echo ( 'on' === $wpdataaccess_post ? 'checked="checked"' : '' ); |
| 694 |
?>/> |
| 695 |
Allow in posts |
| 696 |
</label> |
| 697 |
<br/> |
| 698 |
<label> |
| 699 |
<input type="checkbox" name="wpdataaccess_page" <?php |
| 700 |
echo ( 'on' === $wpdataaccess_page ? 'checked="checked"' : '' ); |
| 701 |
?>/> |
| 702 |
Allow in pages |
| 703 |
</label> |
| 704 |
</td> |
| 705 |
</tr> |
| 706 |
<tr> |
| 707 |
<th><?php |
| 708 |
echo __( 'Shortcode [wpdadiehard]' ); |
| 709 |
?></th> |
| 710 |
<td> |
| 711 |
<label> |
| 712 |
<input type="checkbox" name="wpdadiehard_post" <?php |
| 713 |
echo ( 'on' === $wpdadiehard_post ? 'checked="checked"' : '' ); |
| 714 |
?>/> |
| 715 |
Allow in posts |
| 716 |
</label> |
| 717 |
<br/> |
| 718 |
<label> |
| 719 |
<input type="checkbox" name="wpdadiehard_page" <?php |
| 720 |
echo ( 'on' === $wpdadiehard_page ? 'checked="checked"' : '' ); |
| 721 |
?>/> |
| 722 |
Allow in pages |
| 723 |
</label> |
| 724 |
</td> |
| 725 |
</tr> |
| 726 |
<?php |
| 727 |
?> |
| 728 |
<tr> |
| 729 |
<th><?php |
| 730 |
echo __( 'Debug mode', 'wp-data-access' ); |
| 731 |
?></th> |
| 732 |
<td> |
| 733 |
<label> |
| 734 |
<input |
| 735 |
type="checkbox" |
| 736 |
name="debug" <?php |
| 737 |
echo ( 'on' === $debug ? 'checked' : '' ); |
| 738 |
?> |
| 739 |
><?php |
| 740 |
echo __( 'Enable debug mode', 'wp-data-access' ); |
| 741 |
?> |
| 742 |
</label> |
| 743 |
</td> |
| 744 |
</tr> |
| 745 |
<tr> |
| 746 |
<th><?php |
| 747 |
echo __( 'Date format' ); |
| 748 |
?></th> |
| 749 |
<td> |
| 750 |
<span class="settings_label"><?php |
| 751 |
echo __( 'Output', 'wp-data-access' ); |
| 752 |
?></span> |
| 753 |
<input type="text" value="<?php |
| 754 |
echo esc_attr( get_option( 'date_format' ) ); |
| 755 |
?>" class="item_width" |
| 756 |
readonly/> |
| 757 |
<?php |
| 758 |
echo __( '(WordPress format)', 'wp-data-access' ); |
| 759 |
?> |
| 760 |
<br/> |
| 761 |
<span class="settings_line"> |
| 762 |
<span class="settings_label"><?php |
| 763 |
echo __( 'Input', 'wp-data-access' ); |
| 764 |
?></span> |
| 765 |
<label class="item_label"> |
| 766 |
<input type="radio" name="radio_date_format" class="radio_date_format" |
| 767 |
value="Y-m-d" <?php |
| 768 |
echo ( 'Y-m-d' === $date_format ? 'checked="checked"' : '' ); |
| 769 |
?>/> |
| 770 |
<span class="item_label_text"><?php |
| 771 |
echo esc_attr( ( new \DateTime() )->format( 'Y-m-d' ) ); |
| 772 |
?></span> |
| 773 |
<span class="item_label_align"> |
| 774 |
<input type="text" class="item_label_format" value="Y-m-d" readonly/> |
| 775 |
</span> |
| 776 |
</label> |
| 777 |
</span> |
| 778 |
<?php |
| 779 |
echo __( '(JavaScript format)', 'wp-data-access' ); |
| 780 |
?> |
| 781 |
<br/> |
| 782 |
<span class="settings_line"> |
| 783 |
<span class="settings_label"></span> |
| 784 |
<label class="item_label"> |
| 785 |
<input type="radio" name="radio_date_format" class="radio_date_format" |
| 786 |
value="m/d/Y" <?php |
| 787 |
echo ( 'm/d/Y' === $date_format ? 'checked="checked"' : '' ); |
| 788 |
?>/> |
| 789 |
<span class="item_label_text"><?php |
| 790 |
echo esc_attr( ( new \DateTime() )->format( 'm/d/Y' ) ); |
| 791 |
?></span> |
| 792 |
<span class="item_label_align"> |
| 793 |
<input type="text" class="item_label_format" value="m/d/Y" readonly/> |
| 794 |
</span> |
| 795 |
</label> |
| 796 |
</span> |
| 797 |
<br/> |
| 798 |
<span class="settings_line"> |
| 799 |
<span class="settings_label"></span> |
| 800 |
<label class="item_label"> |
| 801 |
<input type="radio" name="radio_date_format" class="radio_date_format" |
| 802 |
value="d/m/Y" <?php |
| 803 |
echo ( 'd/m/Y' === $date_format ? 'checked="checked"' : '' ); |
| 804 |
?>/> |
| 805 |
<span class="item_label_text"><?php |
| 806 |
echo esc_attr( ( new \DateTime() )->format( 'd/m/Y' ) ); |
| 807 |
?></span> |
| 808 |
<span class="item_label_align"> |
| 809 |
<input type="text" class="item_label_format" value="d/m/Y" readonly/> |
| 810 |
</span> |
| 811 |
</label> |
| 812 |
</span> |
| 813 |
<br/> |
| 814 |
<span class="settings_line"> |
| 815 |
<span class="settings_label"></span> |
| 816 |
<label class="item_label"> |
| 817 |
<input type="radio" name="radio_date_format" name="date_format" |
| 818 |
value="custom" <?php |
| 819 |
echo ( 'Y-m-d' !== $date_format && 'd/m/Y' !== $date_format && 'm/d/Y' !== $date_format ? 'checked="checked"' : '' ); |
| 820 |
?>/> |
| 821 |
<span class="item_label_text"><?php |
| 822 |
echo __( 'Custom:', 'wp-data-access' ); |
| 823 |
?></span> |
| 824 |
<span class="item_label_align"> |
| 825 |
<input class="item_label_format" type="text" name="date_format" id="date_format" |
| 826 |
value="<?php |
| 827 |
echo esc_attr( $date_format ); |
| 828 |
?>" class="item_label_format"/> |
| 829 |
</span> |
| 830 |
</label> |
| 831 |
</span> |
| 832 |
<br/> |
| 833 |
<span class="settings_label"><?php |
| 834 |
echo __( 'Placeholder', 'wp-data-access' ); |
| 835 |
?></span> |
| 836 |
<input type="text" name="date_placeholder" id="date_placeholder" |
| 837 |
value="<?php |
| 838 |
echo esc_attr( $date_placeholder ); |
| 839 |
?>" class="item_width"/> |
| 840 |
<?php |
| 841 |
echo __( '(user info)', 'wp-data-access' ); |
| 842 |
?> |
| 843 |
</td> |
| 844 |
</tr> |
| 845 |
<tr> |
| 846 |
<th><?php |
| 847 |
echo __( 'Time format' ); |
| 848 |
?></th> |
| 849 |
<td> |
| 850 |
<span class="settings_label"><?php |
| 851 |
echo __( 'Output', 'wp-data-access' ); |
| 852 |
?></span> |
| 853 |
<input type="text" value="<?php |
| 854 |
echo esc_attr( get_option( 'time_format' ) ); |
| 855 |
?>" class="item_width" |
| 856 |
readonly/> |
| 857 |
<?php |
| 858 |
echo __( '(WordPress format)', 'wp-data-access' ); |
| 859 |
?> |
| 860 |
<br/> |
| 861 |
<span class="settings_line"> |
| 862 |
<span class="settings_label"><?php |
| 863 |
echo __( 'Input', 'wp-data-access' ); |
| 864 |
?></span> |
| 865 |
<label class="item_label"> |
| 866 |
<input type="radio" name="radio_time_format" class="radio_time_format" |
| 867 |
value="H:i" <?php |
| 868 |
echo ( 'H:i' === $time_format ? 'checked="checked"' : '' ); |
| 869 |
?>/> |
| 870 |
<span class="item_label_text"><?php |
| 871 |
echo esc_attr( ( new \DateTime() )->format( 'H:i' ) ); |
| 872 |
?></span> |
| 873 |
<span class="item_label_align"> |
| 874 |
<input type="text" class="item_label_format" value="H:i" readonly/> |
| 875 |
</span> |
| 876 |
</label> |
| 877 |
</span> |
| 878 |
<?php |
| 879 |
echo __( '(JavaScript format)', 'wp-data-access' ); |
| 880 |
?> |
| 881 |
<br/> |
| 882 |
<span class="settings_line"> |
| 883 |
<span class="settings_label"></span> |
| 884 |
<label class="item_label"> |
| 885 |
<input type="radio" name="radio_time_format" name="time_format" |
| 886 |
value="custom" <?php |
| 887 |
echo ( 'H:i' !== $time_format ? 'checked="checked"' : '' ); |
| 888 |
?>/> |
| 889 |
<span class="item_label_text"><?php |
| 890 |
echo __( 'Custom:', 'wp-data-access' ); |
| 891 |
?></span> |
| 892 |
<span class="item_label_align"> |
| 893 |
<input class="item_label_format" type="text" name="time_format" id="time_format" |
| 894 |
value="<?php |
| 895 |
echo esc_attr( $time_format ); |
| 896 |
?>" class="item_label_format"/> |
| 897 |
</span> |
| 898 |
</label> |
| 899 |
</span> |
| 900 |
<br/> |
| 901 |
<span class="settings_label"><?php |
| 902 |
echo __( 'Placeholder', 'wp-data-access' ); |
| 903 |
?></span> |
| 904 |
<input type="text" name="time_placeholder" id="time_placeholder" |
| 905 |
value="<?php |
| 906 |
echo esc_attr( $time_placeholder ); |
| 907 |
?>" class="item_width"/> |
| 908 |
</td> |
| 909 |
</tr> |
| 910 |
<tr> |
| 911 |
<th><?php |
| 912 |
echo __( 'Date/time test' ); |
| 913 |
?></th> |
| 914 |
<td> |
| 915 |
<input type="button" id="init_datetime" value="Test DateTimePicker" class="button item_width"/> |
| 916 |
<input type="text" class="item_width" id="test_datetime" style="display:none;" /> |
| 917 |
</td> |
| 918 |
</tr> |
| 919 |
<tr> |
| 920 |
<th><?php |
| 921 |
echo __( 'Set format' ); |
| 922 |
?></th> |
| 923 |
<td> |
| 924 |
<span><?php |
| 925 |
echo __( 'Show columns of data type set in list table as' ); |
| 926 |
?></span> |
| 927 |
<select name="set_format"> |
| 928 |
<option value="csv" <?php |
| 929 |
echo ( 'csv' === $set_format ? 'selected' : '' ); |
| 930 |
?>>Comma separated values</option> |
| 931 |
<option value="ul" <?php |
| 932 |
echo ( 'ul' === $set_format ? 'selected' : '' ); |
| 933 |
?>>Unordered list</option> |
| 934 |
<option value="ol" <?php |
| 935 |
echo ( 'ol' === $set_format ? 'selected' : '' ); |
| 936 |
?>>Ordered list</option> |
| 937 |
</select> |
| 938 |
</td> |
| 939 |
</tr> |
| 940 |
<tr> |
| 941 |
<th><span class="dashicons dashicons-info" style="float:right;font-size:300%;"></span></th> |
| 942 |
<td> |
| 943 |
<span class="dashicons dashicons-yes"></span> |
| 944 |
<?php |
| 945 |
echo __( 'The plugin uses your WordPress general settings to format your date and time output', 'wp-data-access' ); |
| 946 |
?> |
| 947 |
<br/> |
| 948 |
<span class="dashicons dashicons-yes"></span> |
| 949 |
<a href="<?php |
| 950 |
echo admin_url( 'options-general.php' ); |
| 951 |
// phpcs:ignore WordPress.Security.EscapeOutput |
| 952 |
?>?page=wpdataaccess"> |
| 953 |
<?php |
| 954 |
echo __( 'Output formats can be changed in WordPress general settings', 'wp-data-access' ); |
| 955 |
?> |
| 956 |
</a> |
| 957 |
<br/> |
| 958 |
<span class="dashicons dashicons-yes"></span> |
| 959 |
<?php |
| 960 |
echo __( 'The plugin uses the jQuery DateTimePicker plugin for data entry validation', 'wp-data-access' ); |
| 961 |
?> |
| 962 |
<br/> |
| 963 |
<span class="dashicons dashicons-yes"></span> |
| 964 |
<a href="https://xdsoft.net/jqplugins/datetimepicker/" target="_blank"> |
| 965 |
<?php |
| 966 |
echo __( 'Input formats can be found on the XDSoft DateTimePicker page', 'wp-data-access' ); |
| 967 |
?> |
| 968 |
</a> |
| 969 |
</td> |
| 970 |
</tr> |
| 971 |
</table> |
| 972 |
<div class="wpda-table-settings-button"> |
| 973 |
<input type="hidden" name="action" value="save"/> |
| 974 |
<button type="submit" class="button button-primary"> |
| 975 |
<i class="fas fa-check wpda_icon_on_button"></i> |
| 976 |
<?php |
| 977 |
echo __( 'Save Plugin Settings', 'wp-data-access' ); |
| 978 |
?> |
| 979 |
</button> |
| 980 |
<a href="javascript:void(0)" |
| 981 |
onclick="if (confirm('<?php |
| 982 |
echo __( 'Reset to defaults?', 'wp-data-access' ); |
| 983 |
?>')) { |
| 984 |
jQuery('input[name="action"]').val('setdefaults'); |
| 985 |
jQuery('#wpda_settings_plugin').trigger('submit') |
| 986 |
}" |
| 987 |
class="button"> |
| 988 |
<i class="fas fa-times-circle wpda_icon_on_button"></i> |
| 989 |
<?php |
| 990 |
echo __( 'Reset Plugin Settings To Defaults', 'wp-data-access' ); |
| 991 |
?> |
| 992 |
</a> |
| 993 |
</div> |
| 994 |
<?php |
| 995 |
wp_nonce_field( 'wpda-plugin-settings-' . WPDA::get_current_user_login(), '_wpnonce', false ); |
| 996 |
?> |
| 997 |
</form> |
| 998 |
<?php |
| 999 |
} |
| 1000 |
|
| 1001 |
} |
| 1002 |
|