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