Setup.php
575 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Transferito\Models\Settings; |
| 4 | |
| 5 | use Transferito\Controllers\Transfer as TransferController; |
| 6 | use Transferito\Models\Core\Api as TransferitoAPI; |
| 7 | use Transferito\Models\Core\Config; |
| 8 | |
| 9 | if (!defined('ABSPATH')) exit; |
| 10 | |
| 11 | class Setup { |
| 12 | |
| 13 | /** |
| 14 | * Holds the values to be used in the fields callbacks |
| 15 | */ |
| 16 | private $options; |
| 17 | private $emptyApiKeys; |
| 18 | private $api; |
| 19 | private $transfer; |
| 20 | |
| 21 | public function __construct() |
| 22 | { |
| 23 | if (current_user_can('activate_plugins')) { |
| 24 | add_action( 'admin_menu', array($this, "createMenuPage")); |
| 25 | add_action( 'admin_init', array($this, "createOptions")); |
| 26 | add_action( 'admin_enqueue_scripts', array($this, "loadTransferitoAssets")); |
| 27 | add_action( 'admin_notices', array($this, "userNotification") ); |
| 28 | add_action( 'plugin_action_links_transferito/transferito.php', array($this, "actionLinks" )); |
| 29 | add_action( 'admin_post_transferito_add_connected_site', array($this, "addConnectedSites" ) ); |
| 30 | |
| 31 | add_filter( 'wp_script_attributes', array($this, "modifyAttributes" ), 10, 3 ); |
| 32 | add_filter( 'plugin_row_meta', array($this, "upgradePluginMetaLink"), 100, 4 ); |
| 33 | |
| 34 | $this->api = new TransferitoAPI(); |
| 35 | $this->transfer = new TransferController(); |
| 36 | $this->options = get_option('transferito_settings_option'); |
| 37 | $publicKey = isset($this->options['public_transferito_key']) ? $this->options['public_transferito_key'] : ''; |
| 38 | $secretKey = isset($this->options['secret_transferito_key']) ? $this->options['secret_transferito_key'] : ''; |
| 39 | $this->emptyApiKeys = filter_var(!($publicKey && $secretKey), FILTER_VALIDATE_BOOLEAN); |
| 40 | |
| 41 | set_transient('transferito_empty_keys', $this->emptyApiKeys); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | public function addConnectedSites() |
| 46 | { |
| 47 | check_ajax_referer('add_connected_site_nonce', 'connected_site_nonce'); |
| 48 | |
| 49 | /** |
| 50 | * Get the request fields |
| 51 | * Once the nonce has been verified |
| 52 | */ |
| 53 | $url = isset($_POST['connected_site_url']) ? wp_kses(wp_unslash($_POST['connected_site_url']), []) : ''; |
| 54 | $filename = isset($_POST['connected_site_filename']) ? wp_kses(wp_unslash($_POST['connected_site_filename']), []) : ''; |
| 55 | $token = isset($_POST['connected_site_token']) ? wp_kses(wp_unslash($_POST['connected_site_token']), []) : ''; |
| 56 | |
| 57 | /** |
| 58 | * Check or Create Validation Details |
| 59 | */ |
| 60 | $destinationServerValidationCheck = $this->transfer->addCheckServerValidation($url, $filename, $token); |
| 61 | |
| 62 | /** |
| 63 | * Set the Status based on the Connection Check |
| 64 | */ |
| 65 | $status = $destinationServerValidationCheck ? 'completed' : 'failed'; |
| 66 | |
| 67 | /** |
| 68 | * Nonce |
| 69 | */ |
| 70 | $nonce = wp_create_nonce('connected_site_redirect'); |
| 71 | |
| 72 | /** |
| 73 | * Redirect to the correct page based on check result |
| 74 | */ |
| 75 | wp_redirect(admin_url('admin.php?page=transferito-connected-sites&status=' . $status . '&_wpnonce=' . $nonce)); |
| 76 | exit; |
| 77 | } |
| 78 | |
| 79 | public function actionLinks($links) |
| 80 | { |
| 81 | $links = array_merge( |
| 82 | array( |
| 83 | '<a href="' . esc_url( admin_url( '/admin.php?page=transferito-main' ) ) . '">' . __( 'Start Migration', 'transferito' ) . '</a>', |
| 84 | ), |
| 85 | $links |
| 86 | ); |
| 87 | |
| 88 | return $links; |
| 89 | } |
| 90 | |
| 91 | public function upgradePluginMetaLink($plugin_meta, $plugin_file, $plugin_data, $status) |
| 92 | { |
| 93 | if ( false !== strpos($plugin_file, 'transferito.php') ) { |
| 94 | $pro_slug = plugin_basename( __FILE__ ); |
| 95 | $installed_plugins = get_plugins(); |
| 96 | $is_pro_installed = array_key_exists( $pro_slug, $installed_plugins ) || in_array( $pro_slug, $installed_plugins, true ); |
| 97 | |
| 98 | $plugin_meta[] = sprintf( |
| 99 | '<a style="color: #B30507; font-weight: bold;" href="https://transferito.com/pricing/" rel="noopener noreferrer" title="Go Pro" target="_blank">%1$s <span class="dashicons dashicons-external"></span></a>', |
| 100 | __('Upgrade to Premium', 'transferito') |
| 101 | ); |
| 102 | } |
| 103 | return $plugin_meta; |
| 104 | } |
| 105 | |
| 106 | public function userNotification() |
| 107 | { |
| 108 | $showMessage = get_transient( 'transferito_settings_update_counter' ); |
| 109 | |
| 110 | if ($showMessage) { |
| 111 | ?> |
| 112 | <div class="notice notice-success is-dismissible"> |
| 113 | <p>Your settings have been updated!</p> |
| 114 | </div> |
| 115 | <?php |
| 116 | } |
| 117 | |
| 118 | delete_transient('transferito_settings_update_counter'); |
| 119 | } |
| 120 | |
| 121 | public function createMenuPage() |
| 122 | { |
| 123 | add_menu_page( |
| 124 | __( 'Transferito1', 'transferito' ), |
| 125 | 'Transferito', |
| 126 | 'manage_options', |
| 127 | 'transferito-main', |
| 128 | '', |
| 129 | 'none', |
| 130 | 26 |
| 131 | ); |
| 132 | |
| 133 | add_submenu_page( |
| 134 | 'transferito-main', |
| 135 | 'Start Migration', |
| 136 | 'Start Migration', |
| 137 | 'manage_options', |
| 138 | 'transferito-main', |
| 139 | array($this, 'createTransferHTML') |
| 140 | ); |
| 141 | |
| 142 | add_submenu_page( |
| 143 | 'transferito-main', |
| 144 | 'Settings', |
| 145 | 'Settings', |
| 146 | 'manage_options', |
| 147 | 'transferito-settings', |
| 148 | array($this, 'settingsHTML') |
| 149 | ); |
| 150 | |
| 151 | add_submenu_page( |
| 152 | '', |
| 153 | 'Connected Sites', |
| 154 | 'Connected Sites', |
| 155 | 'manage_options', |
| 156 | 'transferito-connected-sites', |
| 157 | array($this, 'sitesHTML') |
| 158 | ); |
| 159 | } |
| 160 | |
| 161 | public function createOptions() |
| 162 | { |
| 163 | register_setting( |
| 164 | 'transferito_settings_group', // Option group |
| 165 | 'transferito_settings_option', // Option name |
| 166 | array( $this, 'sanitize' ) // Sanitize |
| 167 | ); |
| 168 | |
| 169 | add_settings_section( |
| 170 | 'transferito_settings_section', // ID |
| 171 | '', // Title |
| 172 | array( $this, 'settingSection' ), // Callback |
| 173 | 'transferito-settings' // Page |
| 174 | ); |
| 175 | |
| 176 | /** |
| 177 | * API Keys fields |
| 178 | */ |
| 179 | add_settings_field( |
| 180 | 'public_transferito_key', // ID |
| 181 | 'Public Key', // Title |
| 182 | array( $this, 'publicKeyField' ), // Callback |
| 183 | 'transferito-settings', // Page |
| 184 | 'transferito_settings_section' |
| 185 | ); |
| 186 | |
| 187 | add_settings_field( |
| 188 | 'secret_transferito_key', // ID |
| 189 | 'Secret Key', // Title |
| 190 | array( $this, 'secretKeyField' ), // Callback |
| 191 | 'transferito-settings', // Page |
| 192 | 'transferito_settings_section' |
| 193 | ); |
| 194 | |
| 195 | add_settings_field( |
| 196 | 'transferito_chunk_size', // ID |
| 197 | 'Set download chunk size', // Title |
| 198 | array( $this, 'chunkSizeField' ), // Callback |
| 199 | 'transferito-settings', // Page |
| 200 | 'transferito_settings_section' |
| 201 | ); |
| 202 | |
| 203 | add_settings_field( |
| 204 | 'transferito_upload_chunk_size', // ID |
| 205 | 'Set upload chunk size', // Title |
| 206 | array( $this, 'uploadChunkSizeField' ), // Callback |
| 207 | 'transferito-settings', // Page |
| 208 | 'transferito_settings_section' |
| 209 | ); |
| 210 | |
| 211 | add_settings_field( |
| 212 | 'transferito_force_upload', // ID |
| 213 | 'Always upload to our secure servers', // Title |
| 214 | array( $this, 'forceUploadField' ), // Callback |
| 215 | 'transferito-settings', // Page |
| 216 | 'transferito_settings_section' |
| 217 | ); |
| 218 | |
| 219 | add_settings_field( |
| 220 | 'transferito_force_tar_backup', // ID |
| 221 | 'Use TAR as default compression format', // Title |
| 222 | array( $this, 'forceTarArchive' ), // Callback |
| 223 | 'transferito-settings', // Page |
| 224 | 'transferito_settings_section' |
| 225 | ); |
| 226 | |
| 227 | add_settings_field( |
| 228 | 'transferito_include_htaccess', // ID |
| 229 | 'Include htaccess file', // Title |
| 230 | array( $this, 'includeHtaccess' ), // Callback |
| 231 | 'transferito-settings', // Page |
| 232 | 'transferito_settings_section' |
| 233 | ); |
| 234 | |
| 235 | add_settings_field( |
| 236 | 'transferito_use_default_collation', // ID |
| 237 | 'Use default database configuration', // Title |
| 238 | array( $this, 'useDefaultCollation' ), // Callback |
| 239 | 'transferito-settings', // Page |
| 240 | 'transferito_settings_section' |
| 241 | ); |
| 242 | |
| 243 | add_settings_field( |
| 244 | 'transferito_bypass_exec_archive_creation', // ID |
| 245 | 'Create backup file without using exec', // Title |
| 246 | array( $this, 'bypassExecArchiveCreation' ), // Callback |
| 247 | 'transferito-settings', // Page |
| 248 | 'transferito_settings_section' |
| 249 | ); |
| 250 | |
| 251 | add_settings_field( |
| 252 | 'transferito_disable_wordpress_cache', // ID |
| 253 | 'Disable WordPress object cache', // Title |
| 254 | array( $this, 'disableWordPressObjectCache' ), // Callback |
| 255 | 'transferito-settings', // Page |
| 256 | 'transferito_settings_section' |
| 257 | ); |
| 258 | |
| 259 | add_settings_field( |
| 260 | 'transferito_malcare_waf_plugin_fix', // ID |
| 261 | 'Disable Malcare WAF plugin', // Title |
| 262 | array( $this, 'malcareWAFPluginFix' ), // Callback |
| 263 | 'transferito-settings', // Page |
| 264 | 'transferito_settings_section' |
| 265 | ); |
| 266 | |
| 267 | add_settings_field( |
| 268 | 'transferito_delete_verification_file', // ID |
| 269 | 'Delete Verification File After Completed Migration', // Title |
| 270 | array( $this, 'deleteVerificationFile' ), // Callback |
| 271 | 'transferito-settings', // Page |
| 272 | 'transferito_settings_section' |
| 273 | ); |
| 274 | |
| 275 | add_settings_field( |
| 276 | 'transferito_hide_welcome_screen', // ID |
| 277 | 'Hide Welcome Screen', // Title |
| 278 | array( $this, 'hideWelcomeScreen' ), // Callback |
| 279 | 'transferito-settings', // Page |
| 280 | 'transferito_settings_section' |
| 281 | ); |
| 282 | |
| 283 | add_settings_field( |
| 284 | 'transferito_enable_debug_tracking', // ID |
| 285 | 'Enable Debug Tracking', // Title |
| 286 | array( $this, 'enableDebugTracking' ), // Callback |
| 287 | 'transferito-settings', // Page |
| 288 | 'transferito_settings_section' |
| 289 | ); |
| 290 | } |
| 291 | |
| 292 | public function modifyAttributes($attribute) |
| 293 | { |
| 294 | if ($attribute['id'] === 'transferito_sentry-js-js') { |
| 295 | $attribute['integrity'] = "sha384-8WK0y5yz2y0ti+wMW84WAgeQI72MHZIGHN3B30ljAcDfexPZRbv3eQ+eqzPKDDqE"; |
| 296 | $attribute['crossorigin'] = "anonymous"; |
| 297 | } |
| 298 | return $attribute; |
| 299 | } |
| 300 | |
| 301 | public function loadTransferitoAssets($hook) |
| 302 | { |
| 303 | $dashIconFont = plugins_url( '../Views/Assets/css/transferito-font.css', dirname(__FILE__)); |
| 304 | |
| 305 | /** |
| 306 | * To load the icon on every admin page |
| 307 | */ |
| 308 | wp_register_style('transferito_font_css', $dashIconFont, false, TRANSFERITO_VERSION); |
| 309 | wp_enqueue_style( 'transferito_font_css' ); |
| 310 | |
| 311 | wp_enqueue_style( |
| 312 | 'transferito-google-fonts', |
| 313 | 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600;700&family=Montserrat:wght@400;500;600;700&display=swap', |
| 314 | false, |
| 315 | TRANSFERITO_VERSION |
| 316 | ); |
| 317 | |
| 318 | /** |
| 319 | * Display on all pages |
| 320 | */ |
| 321 | if ($hook === 'transferito_page_transferito-settings' || $hook === 'toplevel_page_transferito-main' || $hook === "admin_page_transferito-connected-sites" ) { |
| 322 | /** |
| 323 | * New Styles |
| 324 | */ |
| 325 | $updatedStyles = plugins_url( '../Views/Assets/css/transferito-styles.min.css', dirname(__FILE__)); |
| 326 | |
| 327 | wp_register_style('transferito_updated_css', $updatedStyles, false, TRANSFERITO_VERSION); |
| 328 | wp_enqueue_style( 'transferito_updated_css' ); |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Only display on the create migration page |
| 333 | */ |
| 334 | if ($hook === 'toplevel_page_transferito-main') { |
| 335 | |
| 336 | /** |
| 337 | * Check to see if the tracking has been opted in |
| 338 | */ |
| 339 | $trackingEnabled = isset($this->options['transferito_enable_debug_tracking']) |
| 340 | ? $this->options['transferito_enable_debug_tracking'] |
| 341 | : false; |
| 342 | |
| 343 | $script = plugins_url( '../Views/Assets/js/transferito.js', dirname(__FILE__)); |
| 344 | $sentryScript = 'https://browser.sentry-cdn.com/7.40.0/bundle.replay.min.js'; |
| 345 | $sentryImplementationScript = plugins_url( '../Views/Assets/js/transferito-sentry.js', dirname(__FILE__)); |
| 346 | |
| 347 | wp_register_script('transferito_js', $script, array ('jquery'), TRANSFERITO_VERSION, false); |
| 348 | wp_register_script('transferito_sentry-js', $sentryScript, null, TRANSFERITO_VERSION, false); |
| 349 | wp_register_script('transferito_sentry-implement-js', $sentryImplementationScript, array('transferito_sentry-js'), TRANSFERITO_VERSION, false); |
| 350 | |
| 351 | if ($trackingEnabled) { |
| 352 | wp_enqueue_script( 'transferito_sentry-js' ); |
| 353 | wp_enqueue_script( 'transferito_sentry-implement-js' ); |
| 354 | } |
| 355 | |
| 356 | wp_enqueue_script( 'transferito_js' ); |
| 357 | |
| 358 | wp_localize_script('transferito_js', 'transferitoData', [ 'baseUrl' => Config::getBaseApiUrl() ]); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | public function sanitize( $input ) |
| 363 | { |
| 364 | $new_input = array(); |
| 365 | |
| 366 | if( isset( $input['public_transferito_key'] ) ) { |
| 367 | $new_input['public_transferito_key'] = sanitize_text_field( $input['public_transferito_key'] ); |
| 368 | } |
| 369 | |
| 370 | if( isset( $input['secret_transferito_key'] ) ) { |
| 371 | $new_input['secret_transferito_key'] = sanitize_text_field( $input['secret_transferito_key'] ); |
| 372 | } |
| 373 | |
| 374 | if( isset( $input['transferito_chunk_size'] ) ) { |
| 375 | $new_input['transferito_chunk_size'] = sanitize_text_field( $input['transferito_chunk_size'] ); |
| 376 | } |
| 377 | |
| 378 | if( isset( $input['transferito_upload_chunk_size'] ) ) { |
| 379 | $new_input['transferito_upload_chunk_size'] = sanitize_text_field( $input['transferito_upload_chunk_size'] ); |
| 380 | } |
| 381 | |
| 382 | $new_input['transferito_force_upload'] = isset($input['transferito_force_upload']) && $input['transferito_force_upload'] == 'on' ? true : false; |
| 383 | $new_input['transferito_include_htaccess'] = isset($input['transferito_include_htaccess']) && $input['transferito_include_htaccess'] == 'on' ? true : false; |
| 384 | $new_input['transferito_force_tar_backup'] = isset($input['transferito_force_tar_backup']) && $input['transferito_force_tar_backup'] == 'on' ? true : false; |
| 385 | $new_input['transferito_use_default_collation'] = isset($input['transferito_use_default_collation']) && $input['transferito_use_default_collation'] == 'on' ? true : false; |
| 386 | $new_input['transferito_bypass_exec_archive_creation'] = isset($input['transferito_bypass_exec_archive_creation']) && $input['transferito_bypass_exec_archive_creation'] == 'on' ? true : false; |
| 387 | $new_input['transferito_disable_wordpress_cache'] = isset($input['transferito_disable_wordpress_cache']) && $input['transferito_disable_wordpress_cache'] == 'on' ? true : false; |
| 388 | $new_input['transferito_malcare_waf_plugin_fix'] = isset($input['transferito_malcare_waf_plugin_fix']) && $input['transferito_malcare_waf_plugin_fix'] == 'on' ? true : false; |
| 389 | $new_input['transferito_delete_verification_file'] = isset($input['transferito_delete_verification_file']) && $input['transferito_delete_verification_file'] == 'on' ? true : false; |
| 390 | $new_input['transferito_enable_debug_tracking'] = isset($input['transferito_enable_debug_tracking']) && $input['transferito_enable_debug_tracking'] == 'on' ? true : false; |
| 391 | |
| 392 | /** |
| 393 | * Do not save to the settings options |
| 394 | */ |
| 395 | $hideWelcomeScreen = isset($input['transferito_hide_welcome_screen']) && $input['transferito_hide_welcome_screen'] == 'on' ? true : false; |
| 396 | |
| 397 | set_transient('transferito_hide_welcome_screen', $hideWelcomeScreen); |
| 398 | set_transient( 'transferito_settings_update_counter', 1 ); |
| 399 | |
| 400 | return $new_input; |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Print the Section text |
| 405 | */ |
| 406 | public function settingSection() |
| 407 | { |
| 408 | print ''; |
| 409 | } |
| 410 | |
| 411 | /** |
| 412 | * Get the settings option array and print one of its values |
| 413 | */ |
| 414 | public function publicKeyField() |
| 415 | { |
| 416 | printf( |
| 417 | '<input type="text" class="transferito-input__text-box transferito-form-element transferito-input__text-box--full-width transferito-input__text-box--thin" id="public_transferito_key" name="transferito_settings_option[public_transferito_key]" value="%s" />', |
| 418 | isset( $this->options['public_transferito_key'] ) ? esc_attr( $this->options['public_transferito_key']) : '' |
| 419 | ); |
| 420 | } |
| 421 | |
| 422 | public function secretKeyField() |
| 423 | { |
| 424 | printf( |
| 425 | '<input type="text" class="transferito-input__text-box transferito-form-element transferito-input__text-box--full-width transferito-input__text-box--thin" id="secret_transferito_key" name="transferito_settings_option[secret_transferito_key]" value="%s" />', |
| 426 | isset( $this->options['secret_transferito_key'] ) ? esc_attr( $this->options['secret_transferito_key']) : '' |
| 427 | ); |
| 428 | } |
| 429 | |
| 430 | public function chunkSizeField() |
| 431 | { |
| 432 | $chunkSize = isset( $this->options['transferito_chunk_size'] ) ? esc_attr( $this->options['transferito_chunk_size']) : ''; |
| 433 | |
| 434 | $html = '<select id="transferito_chunk_size" class="transferito-form-element transferito-input__dropdown transferito-input__dropdown--full-width transferito-input__dropdown--large" name="transferito_settings_option[transferito_chunk_size]">'; |
| 435 | $html .= $chunkSize == "" ? '<option selected disabled>Use default Download Chunk Size</option>' : '<option disabled>Use default Download Chunk Size</option>'; |
| 436 | $html .= $chunkSize == "1" ? '<option selected>1</option>' : '<option>1</option>'; |
| 437 | $html .= $chunkSize == "5" ? '<option selected>5</option>' : '<option>5</option>'; |
| 438 | $html .= $chunkSize == "10" ? '<option selected>10</option>' : '<option>10</option>'; |
| 439 | $html .= $chunkSize == "25" ? '<option selected>25</option>' : '<option>25</option>'; |
| 440 | $html .= $chunkSize == "50" ? '<option selected>50</option>' : '<option>50</option>'; |
| 441 | $html .= $chunkSize == "100" ? '<option selected>100</option>' : '<option>100</option>'; |
| 442 | $html .= $chunkSize == "250" ? '<option selected>250</option>' : '<option>250</option>'; |
| 443 | $html .= '</select>'; |
| 444 | |
| 445 | echo wp_kses($html, [ |
| 446 | 'select' => [ |
| 447 | 'id' => [], |
| 448 | 'class' => [], |
| 449 | 'name' => [] |
| 450 | ], |
| 451 | 'option' => [ |
| 452 | 'selected' => [], |
| 453 | 'disabled' => [], |
| 454 | ] |
| 455 | ]); |
| 456 | } |
| 457 | |
| 458 | public function uploadChunkSizeField() |
| 459 | { |
| 460 | $chunkSize = isset( $this->options['transferito_upload_chunk_size'] ) ? esc_attr( $this->options['transferito_upload_chunk_size']) : ''; |
| 461 | |
| 462 | $html = '<select id="transferito_upload_chunk_size" class="transferito-form-element transferito-input__dropdown transferito-input__dropdown--full-width transferito-input__dropdown--large" name="transferito_settings_option[transferito_upload_chunk_size]">'; |
| 463 | $html .= $chunkSize == "" ? '<option selected disabled>Use default Upload Chunk Size</option>' : '<option disabled>Use default Upload Chunk Size</option>'; |
| 464 | $html .= $chunkSize == "1" ? '<option selected>1</option>' : '<option>1</option>'; |
| 465 | $html .= $chunkSize == "5" ? '<option selected>5</option>' : '<option>5</option>'; |
| 466 | $html .= $chunkSize == "10" ? '<option selected>10</option>' : '<option>10</option>'; |
| 467 | $html .= $chunkSize == "25" ? '<option selected>25</option>' : '<option>25</option>'; |
| 468 | $html .= $chunkSize == "50" ? '<option selected>50</option>' : '<option>50</option>'; |
| 469 | $html .= $chunkSize == "100" ? '<option selected>100</option>' : '<option>100</option>'; |
| 470 | $html .= '</select>'; |
| 471 | |
| 472 | echo wp_kses($html, [ |
| 473 | 'select' => [ |
| 474 | 'id' => [], |
| 475 | 'class' => [], |
| 476 | 'name' => [] |
| 477 | ], |
| 478 | 'option' => [ |
| 479 | 'selected' => [], |
| 480 | 'disabled' => [], |
| 481 | ] |
| 482 | ]); |
| 483 | } |
| 484 | |
| 485 | public function forceUploadField() |
| 486 | { |
| 487 | $checked = isset($this->options['transferito_force_upload']) && $this->options['transferito_force_upload'] ? 'checked' : ''; |
| 488 | echo '<input type="checkbox" id="transferito_force_upload" name="transferito_settings_option[transferito_force_upload]"' . esc_html($checked) . '/>'; |
| 489 | } |
| 490 | |
| 491 | public function includeHtaccess() |
| 492 | { |
| 493 | $checked = isset($this->options['transferito_include_htaccess']) && $this->options['transferito_include_htaccess'] ? 'checked' : ''; |
| 494 | echo '<input type="checkbox" id="transferito_include_htaccess" name="transferito_settings_option[transferito_include_htaccess]"' . esc_html($checked) . '/>'; |
| 495 | } |
| 496 | |
| 497 | public function forceTarArchive() |
| 498 | { |
| 499 | $checked = isset($this->options['transferito_force_tar_backup']) && $this->options['transferito_force_tar_backup'] ? 'checked' : ''; |
| 500 | echo '<input type="checkbox" id="transferito_force_tar_backup" name="transferito_settings_option[transferito_force_tar_backup]"' . esc_html($checked) . '/>'; |
| 501 | } |
| 502 | |
| 503 | public function useDefaultCollation() |
| 504 | { |
| 505 | $checked = isset($this->options['transferito_use_default_collation']) && $this->options['transferito_use_default_collation'] ? 'checked' : ''; |
| 506 | echo '<input type="checkbox" id="transferito_use_default_collation" name="transferito_settings_option[transferito_use_default_collation]"' . esc_html($checked) . '/>'; |
| 507 | } |
| 508 | |
| 509 | public function bypassExecArchiveCreation() |
| 510 | { |
| 511 | $checked = isset($this->options['transferito_bypass_exec_archive_creation']) && $this->options['transferito_bypass_exec_archive_creation'] ? 'checked' : ''; |
| 512 | echo '<input type="checkbox" id="transferito_bypass_exec_archive_creation" name="transferito_settings_option[transferito_bypass_exec_archive_creation]"' . esc_html($checked) . '/>'; |
| 513 | } |
| 514 | |
| 515 | public function disableWordPressObjectCache() |
| 516 | { |
| 517 | $checked = isset($this->options['transferito_disable_wordpress_cache']) && $this->options['transferito_disable_wordpress_cache'] ? 'checked' : ''; |
| 518 | echo '<input type="checkbox" id="transferito_disable_wordpress_cache" name="transferito_settings_option[transferito_disable_wordpress_cache]"' . esc_html($checked) . '/>'; |
| 519 | } |
| 520 | |
| 521 | public function malcareWAFPluginFix() |
| 522 | { |
| 523 | $checked = isset($this->options['transferito_malcare_waf_plugin_fix']) && $this->options['transferito_malcare_waf_plugin_fix'] ? 'checked' : ''; |
| 524 | echo '<input type="checkbox" id="transferito_malcare_waf_plugin_fix" name="transferito_settings_option[transferito_malcare_waf_plugin_fix]"' . esc_html($checked) . '/>'; |
| 525 | } |
| 526 | |
| 527 | public function deleteVerificationFile() |
| 528 | { |
| 529 | $checked = isset($this->options['transferito_delete_verification_file']) && $this->options['transferito_delete_verification_file'] ? 'checked' : ''; |
| 530 | echo '<input type="checkbox" id="transferito_delete_verification_file" name="transferito_settings_option[transferito_delete_verification_file]"' . esc_html($checked) . '/>'; |
| 531 | } |
| 532 | |
| 533 | public function hideWelcomeScreen() |
| 534 | { |
| 535 | $welcomeScreenHidden = get_transient('transferito_hide_welcome_screen'); |
| 536 | |
| 537 | $checked = $welcomeScreenHidden ? 'checked' : ''; |
| 538 | echo '<input type="checkbox" id="transferito_hide_welcome_screen" name="transferito_settings_option[transferito_hide_welcome_screen]"' . esc_html($checked) . '/>'; |
| 539 | } |
| 540 | |
| 541 | public function enableDebugTracking() |
| 542 | { |
| 543 | $checked = isset($this->options['transferito_enable_debug_tracking']) && $this->options['transferito_enable_debug_tracking'] ? 'checked' : ''; |
| 544 | echo '<input type="checkbox" id="transferito_enable_debug_tracking" name="transferito_settings_option[transferito_enable_debug_tracking]"' . esc_html($checked) . '/>'; |
| 545 | } |
| 546 | |
| 547 | public function settingsHTML() |
| 548 | { |
| 549 | $publicKey = isset($this->options['public_transferito_key']) ? $this->options['public_transferito_key'] : ''; |
| 550 | $secretKey = isset($this->options['secret_transferito_key']) ? $this->options['secret_transferito_key'] : ''; |
| 551 | $hasAPIKeys = $this->emptyApiKeys; |
| 552 | |
| 553 | include TRANSFERITO_PATH . "src" . DIRECTORY_SEPARATOR . "Views" . DIRECTORY_SEPARATOR . 'settings.php'; |
| 554 | } |
| 555 | |
| 556 | public function sitesHTML() |
| 557 | { |
| 558 | include TRANSFERITO_PATH . "src" . DIRECTORY_SEPARATOR . "Views" . DIRECTORY_SEPARATOR . 'connected-sites.php'; |
| 559 | } |
| 560 | |
| 561 | public function createTransferHTML() |
| 562 | { |
| 563 | /** |
| 564 | * Get logged in user's information |
| 565 | */ |
| 566 | $userData = wp_get_current_user(); |
| 567 | $name = (isset($userData->user_firstname) && $userData->user_firstname !== '') |
| 568 | ? $userData->user_firstname |
| 569 | : $userData->display_name; |
| 570 | $userWithoutAPIKeys = $this->emptyApiKeys; |
| 571 | include TRANSFERITO_PATH . "src" . DIRECTORY_SEPARATOR . "Views" . DIRECTORY_SEPARATOR . 'create-transfer.php'; |
| 572 | } |
| 573 | |
| 574 | } |
| 575 |