← All changes
|
WPDataAccess/Settings/WPDA_Settings_Plugin.php
+286
-693
5.5.34
→
5.5.85
View file →
| @@ -1,249 +1,227 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace WPDataAccess\Settings; | |
| 3 | +namespace WPDataAccess\Settings { | |
| 4 | 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; | |
| 5 | + use WPDataAccess\Connection\WPDADB; | |
| 6 | + use WPDataAccess\Utilities\WPDA_Message_Box; | |
| 7 | + use WPDataAccess\WPDA; | |
| 8 | + | |
| 9 | + class WPDA_Settings_Plugin extends WPDA_Settings { | |
| 10 | + | |
| 11 | + protected function add_content() { | |
| 12 | + if ( isset( $_REQUEST['action'] ) ) { | |
| 13 | + $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // input var okay. | |
| 14 | + | |
| 15 | + // Security check. | |
| 16 | + if ( 'delete_remote_database' === $action ) { | |
| 17 | + $wp_nonce = isset( $_REQUEST['_wpnoncedelrdb'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnoncedelrdb'] ) ) : ''; // input var okay. | |
| 18 | + if ( ! wp_verify_nonce( $wp_nonce, 'wpda-delete-remote-database-' . WPDA::get_current_user_login() ) ) { | |
| 19 | + wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) ); | |
| 20 | + } | |
| 21 | + | |
| 22 | + if ( isset( $_REQUEST['remote_database_name'] ) ) { | |
| 23 | + $remote_database_name = sanitize_text_field( wp_unslash( $_REQUEST['remote_database_name'] ) ); // input var okay. | |
| 24 | + WPDADB::del_remote_database( $remote_database_name ); | |
| 25 | + } | |
| 26 | + } elseif ( 'update_remote_database' === $action ) { | |
| 27 | + $wp_nonce = isset( $_REQUEST['_wpnonceupdrdb'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonceupdrdb'] ) ) : ''; // input var okay. | |
| 28 | + if ( ! wp_verify_nonce( $wp_nonce, 'wpda-update-remote-database-' . WPDA::get_current_user_login() ) ) { | |
| 29 | + wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) ); | |
| 30 | + } | |
| 31 | + | |
| 32 | + $database_old = isset( $_REQUEST['remote_database_old'] ) ? | |
| 33 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_database_old'] ) ) : ''; // input var okay. | |
| 34 | + $database = isset( $_REQUEST['remote_database'] ) ? | |
| 35 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_database'] ) ) : ''; // input var okay. | |
| 36 | + $host = isset( $_REQUEST['remote_host'] ) ? | |
| 37 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_host'] ) ) : ''; // input var okay. | |
| 38 | + $username = isset( $_REQUEST['remote_user'] ) ? | |
| 39 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_user'] ) ) : ''; // input var okay. | |
| 40 | + $password = isset( $_REQUEST['remote_passwd'] ) ? // Cannot use sanitize_text_field on password field! | |
| 41 | + wp_unslash( $_REQUEST['remote_passwd'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 42 | + $port = isset( $_REQUEST['remote_port'] ) ? | |
| 43 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_port'] ) ) : ''; // input var okay. | |
| 44 | + $schema = isset( $_REQUEST['remote_schema'] ) ? | |
| 45 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_schema'] ) ) : ''; // input var okay. | |
| 46 | + $enabled = isset( $_REQUEST['remote_enabled'] ) ? true : false; | |
| 47 | + | |
| 48 | + // Add ssl | |
| 49 | + $remote_ssl = isset( $_REQUEST['remote_ssl'] ) ? | |
| 50 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_ssl'] ) ) : 'off'; // input var okay. | |
| 51 | + $remote_client_key = isset( $_REQUEST['remote_client_key'] ) ? | |
| 52 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_client_key'] ) ) : ''; // input var okay. | |
| 53 | + $remote_client_certificate = isset( $_REQUEST['remote_client_certificate'] ) ? | |
| 54 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_client_certificate'] ) ) : ''; // input var okay. | |
| 55 | + $remote_ca_certificate = isset( $_REQUEST['remote_ca_certificate'] ) ? | |
| 56 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_ca_certificate'] ) ) : ''; // input var okay. | |
| 57 | + $remote_certificate_path = isset( $_REQUEST['remote_certificate_path'] ) ? | |
| 58 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_certificate_path'] ) ) : ''; // input var okay. | |
| 59 | + $remote_specified_cipher = isset( $_REQUEST['remote_specified_cipher'] ) ? | |
| 60 | + sanitize_text_field( wp_unslash( $_REQUEST['remote_specified_cipher'] ) ) : ''; // input var okay. | |
| 61 | + | |
| 62 | + if ( '' === $database_old || '' === $database || '' === $host || '' === $username || '' === $password || '' === $port || '' === $schema || '' === $enabled ) { | |
| 63 | + $msg = new WPDA_Message_Box( | |
| 64 | + array( | |
| 65 | + 'message_text' => __( 'Cannot save remote database connection [missing arguments]', 'wp-data-access' ), | |
| 66 | + 'message_type' => 'error', | |
| 67 | + 'message_is_dismissible' => false, | |
| 68 | + ) | |
| 69 | + ); | |
| 70 | + $msg->box(); | |
| 71 | + } else { | |
| 72 | + WPDADB::upd_remote_database( | |
| 73 | + $database, | |
| 74 | + $host, | |
| 75 | + $username, | |
| 76 | + $password, | |
| 77 | + $port, | |
| 78 | + $schema, | |
| 79 | + ! $enabled, | |
| 80 | + $database_old, | |
| 81 | + $remote_ssl, | |
| 82 | + $remote_client_key, | |
| 83 | + $remote_client_certificate, | |
| 84 | + $remote_ca_certificate, | |
| 85 | + $remote_certificate_path, | |
| 86 | + $remote_specified_cipher | |
| 87 | + ); | |
| 88 | + } | |
| 89 | + } else { | |
| 90 | + $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay. | |
| 91 | + if ( ! wp_verify_nonce( $wp_nonce, 'wpda-plugin-settings-' . WPDA::get_current_user_login() ) ) { | |
| 92 | + wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) ); | |
| 93 | + } | |
| 94 | + | |
| 95 | + if ( 'save' === $action ) { | |
| 96 | + WPDA::set_option( | |
| 97 | + WPDA::OPTION_PLUGIN_HIDE_NOTICES, | |
| 98 | + isset( $_REQUEST['hide_foreign_notices'] ) ? 'on' : 'off' // input var okay. | |
| 99 | + ); | |
| 100 | + | |
| 101 | + WPDA::set_option( | |
| 102 | + WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU, | |
| 103 | + isset( $_REQUEST['hide_admin_menu'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['hide_admin_menu'] ) ) : 'off' // input var okay. | |
| 104 | + ); | |
| 105 | + | |
| 106 | + if ( isset( $_REQUEST['panel_cookies'] ) ) { | |
| 107 | + WPDA::set_option( | |
| 108 | + WPDA::OPTION_PLUGIN_PANEL_COOKIES, | |
| 109 | + sanitize_text_field( wp_unslash( $_REQUEST['panel_cookies'] ) ) // input var okay. | |
| 110 | + ); | |
| 111 | + } | |
| 112 | + | |
| 113 | + if ( ! isset( $_REQUEST['secret_key'] ) || ! isset( $_REQUEST['secret_iv'] ) ) { | |
| 114 | + // Leave both values untouched | |
| 115 | + } else { | |
| 116 | + $secret_key_old = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_KEY ); | |
| 117 | + $secret_iv_old = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_IV ); | |
| 118 | + | |
| 119 | + $secret_key_new = sanitize_text_field( wp_unslash( $_REQUEST['secret_key'] ) ); // input var okay. | |
| 120 | + $secret_iv_new = sanitize_text_field( wp_unslash( $_REQUEST['secret_iv'] ) ); // input var okay. | |
| 121 | + | |
| 122 | + if ( $secret_key_old !== $secret_key_new || $secret_iv_old !== $secret_iv_new ) { | |
| 123 | + // Update existing remote databases | |
| 124 | + WPDADB::load_remote_databases(); // load remote databases with old secret key and iv | |
| 125 | + WPDA::set_option( WPDA::OPTION_PLUGIN_SECRET_KEY, $secret_key_new ); // update secret key | |
| 126 | + WPDA::set_option( WPDA::OPTION_PLUGIN_SECRET_IV, $secret_iv_new ); // update secret iv | |
| 127 | + WPDADB::save_remote_databases(); // save remote databases with new secret key and iv | |
| 128 | + } | |
| 129 | + } | |
| 130 | + | |
| 131 | + if ( isset( $_REQUEST['remote_database_name'] ) && isset( $_REQUEST['remote_database_enabled'] ) ) { | |
| 132 | + if ( is_array( $_REQUEST['remote_database_name'] ) && | |
| 133 | + is_array( $_REQUEST['remote_database_enabled'] ) && | |
| 134 | + count( $_REQUEST['remote_database_name'] ) === count( $_REQUEST['remote_database_enabled'] ) // phpcs:ignore -- 8.1 proof | |
| 135 | + ) { | |
| 136 | + $i = 0; | |
| 137 | + while ( $i < count( $_REQUEST['remote_database_name'] ) ) { // phpcs:ignore -- 8.1 proof | |
| 138 | + $rdb_name = sanitize_text_field( wp_unslash( $_REQUEST['remote_database_name'][ $i ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 139 | + $dbs = WPDADB::get_remote_database( $rdb_name, true ); | |
| 140 | + if ( ! $dbs ) { | |
| 141 | + $msg = new WPDA_Message_Box( | |
| 142 | + array( | |
| 143 | + 'message_text' => __( 'Remote database connection not found', 'wp-data-access' ), | |
| 144 | + 'message_type' => 'error', | |
| 145 | + 'message_is_dismissible' => false, | |
| 146 | + ) | |
| 147 | + ); | |
| 148 | + $msg->box(); | |
| 149 | + } else { | |
| 150 | + WPDADB::upd_remote_database( | |
| 151 | + $rdb_name, | |
| 152 | + $dbs['host'], | |
| 153 | + $dbs['username'], | |
| 154 | + $dbs['password'], | |
| 155 | + $dbs['port'], | |
| 156 | + $dbs['database'], | |
| 157 | + $_REQUEST['remote_database_enabled'][ $i ] === 'FALSE', // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 158 | + false, | |
| 159 | + $dbs['ssl'], | |
| 160 | + $dbs['ssl_key'], | |
| 161 | + $dbs['ssl_cert'], | |
| 162 | + $dbs['ssl_ca'], | |
| 163 | + $dbs['ssl_path'], | |
| 164 | + $dbs['ssl_cipher'] | |
| 165 | + ); | |
| 166 | + } | |
| 167 | + $i++; | |
| 168 | + } | |
| 169 | + WPDADB::save_remote_databases(); // save changes | |
| 170 | + } | |
| 171 | + } | |
| 172 | + | |
| 173 | + WPDA::set_option( | |
| 174 | + WPDA::OPTION_PLUGIN_DEBUG, | |
| 175 | + isset( $_REQUEST['debug'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['debug'] ) ) : 'off' // input var okay. | |
| 176 | + ); | |
| 177 | + } elseif ( 'setdefaults' === $action ) { | |
| 178 | + // Set all back-end settings back to default. | |
| 179 | + WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES ); | |
| 180 | + | |
| 181 | + WPDA::set_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU ); | |
| 182 | + | |
| 183 | + WPDA::set_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES ); | |
| 184 | + | |
| 185 | + // DO NOT RESET SECRET KEY AND IV | |
| 186 | + | |
| 187 | + // DO NOT RESET RDBs | |
| 188 | + | |
| 189 | + WPDA::set_option( WPDA::OPTION_PLUGIN_DEBUG ); | |
| 190 | + } | |
| 234 | 191 | } |
| 235 | 192 | |
| 236 | - .settings_label { | |
| 237 | - display: inline-block; | |
| 238 | - width: 7em; | |
| 239 | - font-weight: bold; | |
| 240 | - } | |
| 193 | + $msg = new WPDA_Message_Box( | |
| 194 | + array( | |
| 195 | + 'message_text' => __( 'Settings saved', 'wp-data-access' ), | |
| 196 | + ) | |
| 197 | + ); | |
| 198 | + $msg->box(); | |
| 199 | + } elseif ( isset( $_REQUEST['msg'] ) && 'ok' === $_REQUEST['msg'] ) { | |
| 200 | + $msg = new WPDA_Message_Box( | |
| 201 | + array( | |
| 202 | + 'message_text' => __( 'Settings saved', 'wp-data-access' ), | |
| 203 | + ) | |
| 204 | + ); | |
| 205 | + $msg->box(); | |
| 206 | + } | |
| 241 | 207 | |
| 242 | - .item_width { | |
| 243 | - width: 14em; | |
| 244 | - } | |
| 208 | + // Get options. | |
| 209 | + $hide_foreign_notices = WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_NOTICES ); | |
| 245 | 210 | |
| 211 | + $hide_admin_menu = WPDA::get_option( WPDA::OPTION_PLUGIN_HIDE_ADMIN_MENU ); | |
| 212 | + | |
| 213 | + $panel_cookies = WPDA::get_option( WPDA::OPTION_PLUGIN_PANEL_COOKIES ); | |
| 214 | + | |
| 215 | + $secret_key = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_KEY ); | |
| 216 | + $secret_iv = WPDA::get_option( WPDA::OPTION_PLUGIN_SECRET_IV ); | |
| 217 | + | |
| 218 | + $debug = WPDA::get_option( WPDA::OPTION_PLUGIN_DEBUG ); | |
| 219 | + | |
| 220 | + $remote_databases = WPDADB::get_remote_databases( true ); | |
| 221 | + ?> | |
| 222 | + | |
| 223 | + <style> | |
| 246 | 224 | .item_label { |
| 247 | 225 | width: 14.9em; |
| 248 | 226 | display: inline-block; |
| 249 | 227 | padding-left: 0.3em; |
| @@ -283,44 +261,13 @@ | ||
| 283 | 261 | padding: 10px; |
| 284 | 262 | margin-bottom: 10px; |
| 285 | 263 | } |
| 286 | 264 | </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 | 265 | |
| 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 | - | |
| 266 | + <script> | |
| 318 | 267 | function delete_remote_database(id) { |
| 319 | 268 | 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 | - ?>")) { | |
| 269 | + if (confirm("<?php esc_html_e( 'Delete remote database connection from plugin repository?', 'wp-data-access' ); ?>")) { | |
| 323 | 270 | jQuery('#delete_remote_database_name').val(remote_database_name); |
| 324 | 271 | jQuery('#wpda_delete_database').submit(); |
| 325 | 272 | } |
| 326 | 273 | } |
| @@ -413,22 +360,20 @@ | ||
| 413 | 360 | }); |
| 414 | 361 | }); |
| 415 | 362 | |
| 416 | 363 | 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 | - ?> | |
| 364 | + <?php | |
| 365 | + foreach ( $remote_databases as $key => $value ) { | |
| 366 | + echo "remote_databases['$key'] = " . json_encode( $value ) . ';'; // phpcs:ignore WordPress.Security.EscapeOutput | |
| 367 | + } | |
| 368 | + ?> | |
| 423 | 369 | </script> |
| 370 | + | |
| 424 | 371 | <div id="wpda_update_database_popup"> |
| 425 | 372 | <div id="wpda_update_database_popup_header"> |
| 426 | 373 | <span style="display:inline-block;margin-top:5px;"> |
| 427 | 374 | <strong> |
| 428 | - <?php | |
| 429 | - echo __( 'Edit Remote Database Connection', 'wp-data-access' ); | |
| 430 | - ?> | |
| 375 | + <?php esc_html_e( 'Edit Remote Database Connection', 'wp-data-access' ); ?> | |
| 431 | 376 | </strong> |
| 432 | 377 | </span> |
| 433 | 378 | <span class="button" style="float:right;height:10px;" |
| 434 | 379 | onclick="jQuery('#wpda_update_database_popup').hide()">x</span><br/> |
| @@ -434,11 +379,9 @@ | ||
| 434 | 379 | onclick="jQuery('#wpda_update_database_popup').hide()">x</span><br/> |
| 435 | 380 | </div> |
| 436 | 381 | |
| 437 | 382 | <form id="wpda_update_database" method="post" |
| 438 | - action="?page=<?php | |
| 439 | - echo esc_attr( $this->page ); | |
| 440 | - ?>&tab=plugin"> | |
| 383 | + action="?page=<?php echo esc_attr( $this->page ); ?>&tab=plugin"> | |
| 441 | 384 | |
| 442 | 385 | <div> |
| 443 | 386 | <label for="remote_database" style="vertical-align:baseline;" |
| 444 | 387 | class="database_item_label">Database name:</label> |
| @@ -501,80 +444,54 @@ | ||
| 501 | 444 | <div style="height:10px;"></div> |
| 502 | 445 | </div> |
| 503 | 446 | <input type="hidden" name="remote_database_old" id="remote_database_old" value="""> |
| 504 | 447 | <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 | - ?>"> | |
| 448 | + <input type="submit" class="button button-secondary" value="<?php esc_html_e( 'Save', 'wp-data-access' ); ?>"> | |
| 508 | 449 | <a href="javascript:void(0)" |
| 509 | 450 | onclick="jQuery('#wpda_update_database_popup').hide()" |
| 510 | 451 | class="button button-secondary"> |
| 511 | - <?php | |
| 512 | - echo __( 'Cancel', 'wp-data-access' ); | |
| 513 | - ?> | |
| 452 | + <?php esc_html_e( 'Cancel', 'wp-data-access' ); ?> | |
| 514 | 453 | </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 | - ?>"/> | |
| 454 | + <?php | |
| 455 | + $rdb_wp_nonce_action = 'wpda-update-remote-database-' . WPDA::get_current_user_login(); | |
| 456 | + $rdb_wp_nonce = wp_create_nonce( $rdb_wp_nonce_action ); | |
| 457 | + ?> | |
| 458 | + <input type="hidden" name="_wpnonceupdrdb" value="<?php echo esc_attr( $rdb_wp_nonce ); ?>"/> | |
| 522 | 459 | </form> |
| 523 | 460 | </div> |
| 524 | 461 | <form id="wpda_delete_database" method="post" style="display:none;" |
| 525 | - action="?page=<?php | |
| 526 | - echo esc_attr( $this->page ); | |
| 527 | - ?>&tab=plugin"> | |
| 462 | + action="?page=<?php echo esc_attr( $this->page ); ?>&tab=plugin"> | |
| 528 | 463 | <input type="hidden" name="remote_database_name" id="delete_remote_database_name" value=""/> |
| 529 | 464 | <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 | - ?>"/> | |
| 465 | + <?php | |
| 466 | + $rdb_wp_nonce_action = 'wpda-delete-remote-database-' . WPDA::get_current_user_login(); | |
| 467 | + $rdb_wp_nonce = wp_create_nonce( $rdb_wp_nonce_action ); | |
| 468 | + ?> | |
| 469 | + <input type="hidden" name="_wpnoncedelrdb" value="<?php echo esc_attr( $rdb_wp_nonce ); ?>"/> | |
| 537 | 470 | </form> |
| 538 | 471 | <form id="wpda_settings_plugin" method="post" |
| 539 | - action="?page=<?php | |
| 540 | - echo esc_attr( $this->page ); | |
| 541 | - ?>&tab=plugin"> | |
| 472 | + action="?page=<?php echo esc_attr( $this->page ); ?>&tab=plugin"> | |
| 542 | 473 | <table class="wpda-table-settings" id="wpda_table_plugin"> |
| 543 | 474 | <tr> |
| 544 | - <th><?php | |
| 545 | - echo __( 'Plugin menu', 'wp-data-access' ); | |
| 546 | - ?></th> | |
| 475 | + <th><?php esc_html_e( 'Plugin menu', 'wp-data-access' ); ?></th> | |
| 547 | 476 | <td> |
| 548 | 477 | <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 | - ?> | |
| 478 | + <input type="checkbox" name="hide_admin_menu" <?php echo 'on' === $hide_admin_menu ? 'checked="checked"' : ''; ?>/> | |
| 479 | + <?php esc_html_e( 'Hide plugin menu in admin panel', 'wp-data-access' ); ?> | |
| 555 | 480 | </label> |
| 556 | 481 | </td> |
| 557 | 482 | </tr> |
| 558 | 483 | <tr> |
| 559 | - <th><?php | |
| 560 | - echo __( 'Notices', 'wp-data-access' ); | |
| 561 | - ?></th> | |
| 484 | + <th><?php esc_html_e( 'Notices', 'wp-data-access' ); ?></th> | |
| 562 | 485 | <td> |
| 563 | 486 | <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 | - ?> | |
| 487 | + <input type="checkbox" name="hide_foreign_notices" <?php echo $hide_foreign_notices === 'on' ? 'checked' : ''; ?> /> | |
| 488 | + <?php esc_html_e( 'Hide notices of other themes and plugins on WP Data Access admin pages', 'wp-data-access' ); ?> | |
| 570 | 489 | </label> |
| 571 | 490 | </td> |
| 572 | 491 | </tr> |
| 573 | 492 | <tr> |
| 574 | - <th><?php | |
| 575 | - echo __( 'Panel cookies', 'wp-data-access' ); | |
| 576 | - ?></th> | |
| 493 | + <th><?php esc_html_e( 'Panel cookies', 'wp-data-access' ); ?></th> | |
| 577 | 494 | <td> |
| 578 | 495 | <label> |
| 579 | 496 | <input |
| 580 | 497 | type="radio" |
| @@ -579,14 +496,10 @@ | ||
| 579 | 496 | <input |
| 580 | 497 | type="radio" |
| 581 | 498 | name="panel_cookies" |
| 582 | 499 | value="clear" |
| 583 | - <?php | |
| 584 | - echo ( 'clear' === $panel_cookies ? 'checked' : '' ); | |
| 585 | - ?> | |
| 586 | - ><?php | |
| 587 | - echo __( 'Clear when switching panels', 'wp-data-access' ); | |
| 588 | - ?> | |
| 500 | + <?php echo 'clear' === $panel_cookies ? 'checked' : ''; ?> | |
| 501 | + ><?php esc_html_e( 'Clear when switching panels', 'wp-data-access' ); ?> | |
| 589 | 502 | </label> |
| 590 | 503 | <br/> |
| 591 | 504 | <label> |
| 592 | 505 | <input |
| @@ -592,410 +505,90 @@ | ||
| 592 | 505 | <input |
| 593 | 506 | type="radio" |
| 594 | 507 | name="panel_cookies" |
| 595 | 508 | value="keep" |
| 596 | - <?php | |
| 597 | - echo ( 'keep' === $panel_cookies ? 'checked' : '' ); | |
| 598 | - ?> | |
| 599 | - ><?php | |
| 600 | - echo __( 'Keep when switching panels', 'wp-data-access' ); | |
| 601 | - ?> | |
| 509 | + <?php echo 'keep' === $panel_cookies ? 'checked' : ''; ?> | |
| 510 | + ><?php esc_html_e( 'Keep when switching panels', 'wp-data-access' ); ?> | |
| 602 | 511 | </label> |
| 603 | 512 | </td> |
| 604 | 513 | </tr> |
| 605 | 514 | <tr> |
| 606 | - <th><?php | |
| 607 | - echo __( 'Secret key and IV' ); | |
| 608 | - ?></th> | |
| 515 | + <th><?php esc_html_e( 'Secret key and IV', 'wp-data-access' ); ?></th> | |
| 609 | 516 | <td> |
| 610 | - <input type="text" name="secret_key" value="<?php | |
| 611 | - echo esc_attr( $secret_key ); | |
| 612 | - ?>"/> | |
| 517 | + <input type="text" name="secret_key" value="<?php echo esc_attr( $secret_key ); ?>"/> | |
| 613 | 518 | <br/> |
| 614 | - <input type="text" name="secret_iv" value="<?php | |
| 615 | - echo esc_attr( $secret_iv ); | |
| 616 | - ?>"/> | |
| 519 | + <input type="text" name="secret_iv" value="<?php echo esc_attr( $secret_iv ); ?>"/> | |
| 617 | 520 | <br/><br/> |
| 618 | - <span class="dashicons dashicons-info"></span><?php | |
| 619 | - echo __( 'Existing remote database connection settings will be converted', 'wp-data-access' ); | |
| 620 | - ?> | |
| 521 | + <span class="dashicons dashicons-info"></span><?php esc_html_e( 'Existing remote database connection settings will be converted', 'wp-data-access' ); ?> | |
| 621 | 522 | </td> |
| 622 | 523 | </tr> |
| 623 | 524 | <tr> |
| 624 | - <th><?php | |
| 625 | - echo __( 'Remote database connections' ); | |
| 626 | - ?></th> | |
| 525 | + <th><?php esc_html_e( 'Remote database connections', 'wp-data-access' ); ?></th> | |
| 627 | 526 | <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 | - ?> | |
| 527 | + <?php | |
| 528 | + $i = 0; | |
| 529 | + foreach ( $remote_databases as $remote_database => $remote_database_settings ) { | |
| 530 | + $checked = isset( $remote_database_settings['disabled'] ) && $remote_database_settings['disabled'] ? '' : 'checked'; | |
| 531 | + $enabled = isset( $remote_database_settings['disabled'] ) && $remote_database_settings['disabled'] ? 'FALSE' : 'TRUE'; | |
| 532 | + ?> | |
| 634 | 533 | <a href="javascript:void(0)" |
| 635 | - onclick="delete_remote_database('<?php | |
| 636 | - echo esc_attr( $i ); | |
| 637 | - ?>')" | |
| 534 | + onclick="delete_remote_database('<?php echo esc_attr( $i ); ?>')" | |
| 638 | 535 | style="text-decoration:none;" |
| 639 | 536 | class="wpda_tooltip" |
| 640 | - title="<?php | |
| 641 | - echo __( 'Delete remote database connection from plugin repository', 'wp-data-access' ); | |
| 642 | - ?>"> | |
| 537 | + title="<?php esc_html_e( 'Delete remote database connection from plugin repository', 'wp-data-access' ); ?>"> | |
| 643 | 538 | <span class="dashicons dashicons-trash" style="font-size:18px;"></span> |
| 644 | 539 | </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 | - ?> | |
| 540 | + <label class="wpda_tooltip" title="<?php esc_html_e( 'Disable remote database connection', 'wp-data-access' ); ?>"> | |
| 541 | + <input type="checkbox" name="remote_database[]" id="remote_database<?php echo esc_attr( $i ); ?>" onclick="update_rdb_setting('<?php echo esc_attr( $i ); ?>')" <?php echo esc_attr( $checked ); ?>> | |
| 542 | + <input type="hidden" name="remote_database_name[]" id="remote_database_name<?php echo esc_attr( $i ); ?>" value="<?php echo esc_attr( $remote_database ); ?>"> | |
| 543 | + <input type="hidden" name="remote_database_enabled[]" id="remote_database_enabled<?php echo esc_attr( $i ); ?>" value="<?php echo esc_attr( $enabled ); ?>"> | |
| 544 | + <?php echo esc_attr( $remote_database ); ?> | |
| 668 | 545 | </label> |
| 669 | 546 | <a href="javascript:void(0)" |
| 670 | - onclick="edit_rdb_setting('<?php | |
| 671 | - echo esc_attr( $remote_database ); | |
| 672 | - ?>')" | |
| 547 | + onclick="edit_rdb_setting('<?php echo esc_attr( $remote_database ); ?>')" | |
| 673 | 548 | style="text-decoration:none;" |
| 674 | 549 | class="wpda_tooltip" |
| 675 | - title="<?php | |
| 676 | - echo __( 'Edit remote database connection', 'wp-data-access' ); | |
| 677 | - ?>"> | |
| 550 | + title="<?php esc_html_e( 'Edit remote database connection', 'wp-data-access' ); ?>"> | |
| 678 | 551 | <span class="dashicons dashicons-edit" style="font-size:18px;"></span> |
| 679 | 552 | </a><br/> |
| 680 | - <?php | |
| 681 | - $i++; | |
| 682 | - } | |
| 683 | - ?> | |
| 553 | + <?php | |
| 554 | + $i++; | |
| 555 | + } | |
| 556 | + ?> | |
| 684 | 557 | </td> |
| 685 | 558 | </tr> |
| 686 | 559 | <tr> |
| 687 | - <th><?php | |
| 688 | - echo __( 'Shortcode [wpdataaccess]' ); | |
| 689 | - ?></th> | |
| 560 | + <th><?php esc_html_e( 'Debug mode', 'wp-data-access' ); ?></th> | |
| 690 | 561 | <td> |
| 691 | 562 | <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 | 563 | <input |
| 735 | 564 | type="checkbox" |
| 736 | - name="debug" <?php | |
| 737 | - echo ( 'on' === $debug ? 'checked' : '' ); | |
| 738 | - ?> | |
| 739 | - ><?php | |
| 740 | - echo __( 'Enable debug mode', 'wp-data-access' ); | |
| 741 | - ?> | |
| 565 | + name="debug" <?php echo 'on' === $debug ? 'checked' : ''; ?> | |
| 566 | + ><?php esc_html_e( 'Enable debug mode', 'wp-data-access' ); ?> | |
| 742 | 567 | </label> |
| 743 | 568 | </td> |
| 744 | 569 | </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 | 570 | </table> |
| 972 | 571 | <div class="wpda-table-settings-button"> |
| 973 | 572 | <input type="hidden" name="action" value="save"/> |
| 974 | 573 | <button type="submit" class="button button-primary"> |
| 975 | 574 | <i class="fas fa-check wpda_icon_on_button"></i> |
| 976 | - <?php | |
| 977 | - echo __( 'Save Plugin Settings', 'wp-data-access' ); | |
| 978 | - ?> | |
| 575 | + <?php esc_html_e( 'Save Plugin Settings', 'wp-data-access' ); ?> | |
| 979 | 576 | </button> |
| 980 | 577 | <a href="javascript:void(0)" |
| 981 | - onclick="if (confirm('<?php | |
| 982 | - echo __( 'Reset to defaults?', 'wp-data-access' ); | |
| 983 | - ?>')) { | |
| 578 | + onclick="if (confirm('<?php esc_html_e( 'Reset to defaults?', 'wp-data-access' ); ?>')) { | |
| 984 | 579 | jQuery('input[name="action"]').val('setdefaults'); |
| 985 | 580 | jQuery('#wpda_settings_plugin').trigger('submit') |
| 986 | 581 | }" |
| 987 | 582 | class="button"> |
| 988 | 583 | <i class="fas fa-times-circle wpda_icon_on_button"></i> |
| 989 | - <?php | |
| 990 | - echo __( 'Reset Plugin Settings To Defaults', 'wp-data-access' ); | |
| 991 | - ?> | |
| 584 | + <?php esc_html_e( 'Reset Plugin Settings To Defaults', 'wp-data-access' ); ?> | |
| 992 | 585 | </a> |
| 993 | 586 | </div> |
| 994 | - <?php | |
| 995 | - wp_nonce_field( 'wpda-plugin-settings-' . WPDA::get_current_user_login(), '_wpnonce', false ); | |
| 996 | - ?> | |
| 587 | + <?php wp_nonce_field( 'wpda-plugin-settings-' . WPDA::get_current_user_login(), '_wpnonce', false ); ?> | |
| 997 | 588 | </form> |
| 998 | - <?php | |
| 999 | - } | |
| 589 | + <?php | |
| 590 | + } | |
| 591 | + | |
| 592 | + } | |
| 1000 | 593 | |
| 1001 | 594 | } |