function __construct($plugin_file_path) { parent::__construct($plugin_file_path); if (!version_compare(PHP_VERSION, $this->php_version_required, '>=')) { return; } global $wpmdb; $this->wpmdb = $wpmdb; }
function __construct($plugin_file_path) { parent::__construct($plugin_file_path); if (!version_compare(PHP_VERSION, $this->php_version_required, '>=')) { return; } global $wpmdb; $this->wpmdb = $wpmdb; add_filter('wpmdb_cli_finalize_migration_response', array($this, 'finalize_ajax'), 10, 1); }
function __construct($plugin_file_path) { parent::__construct($plugin_file_path); $this->plugin_version = $GLOBALS['wpmdb_meta'][$this->core_slug]['version']; $this->max_insert_string_len = 50000; // 50000 is the default as defined by PhpMyAdmin add_filter('plugin_action_links_' . $this->plugin_basename, array($this, 'plugin_action_links')); add_filter('network_admin_plugin_action_links_' . $this->plugin_basename, array($this, 'plugin_action_links')); // internal AJAX handlers add_action('wp_ajax_wpmdb_delete_migration_profile', array($this, 'ajax_delete_migration_profile')); add_action('wp_ajax_wpmdb_save_profile', array($this, 'ajax_save_profile')); add_action('wp_ajax_wpmdb_initiate_migration', array($this, 'ajax_initiate_migration')); add_action('wp_ajax_wpmdb_migrate_table', array($this, 'ajax_migrate_table')); add_action('wp_ajax_wpmdb_finalize_migration', array($this, 'ajax_finalize_migration')); add_action('wp_ajax_wpmdb_clear_log', array($this, 'ajax_clear_log')); add_action('wp_ajax_wpmdb_get_log', array($this, 'ajax_get_log')); add_action('wp_ajax_wpmdb_fire_migration_complete', array($this, 'fire_migration_complete')); add_action('wp_ajax_wpmdb_plugin_compatibility', array($this, 'ajax_plugin_compatibility')); add_action('wp_ajax_wpmdb_blacklist_plugins', array($this, 'ajax_blacklist_plugins')); add_action('wp_ajax_wpmdb_update_max_request_size', array($this, 'ajax_update_max_request_size')); add_action('wp_ajax_wpmdb_cancel_migration', array($this, 'ajax_cancel_migration')); $absolute_path = rtrim(ABSPATH, '\\/'); $site_url = rtrim(site_url('', 'http'), '\\/'); $home_url = rtrim(home_url('', 'http'), '\\/'); if ($site_url != $home_url) { $difference = str_replace($home_url, '', $site_url); if (strpos($absolute_path, $difference) !== false) { $absolute_path = rtrim(substr($absolute_path, 0, -strlen($difference)), '\\/'); } } $this->absolute_root_file_path = $absolute_path; $this->accepted_fields = array('action', 'save_computer', 'gzip_file', 'connection_info', 'replace_old', 'replace_new', 'table_migrate_option', 'select_tables', 'replace_guids', 'exclude_spam', 'save_migration_profile', 'save_migration_profile_option', 'create_new_profile', 'create_backup', 'remove_backup', 'keep_active_plugins', 'select_post_types', 'backup_option', 'select_backup', 'exclude_transients', 'exclude_post_types', 'exclude_post_revisions', 'compatibility_older_mysql'); $this->default_profile = array('action' => 'savefile', 'save_computer' => '1', 'gzip_file' => '1', 'table_migrate_option' => 'migrate_only_with_prefix', 'replace_guids' => '1', 'default_profile' => true, 'name' => '', 'select_tables' => array(), 'select_post_types' => array(), 'backup_option' => 'backup_only_with_prefix', 'exclude_transients' => '1', 'compatibility_older_mysql' => '1'); $this->checkbox_options = array('save_computer' => '0', 'gzip_file' => '0', 'replace_guids' => '0', 'exclude_spam' => '0', 'keep_active_plugins' => '0', 'create_backup' => '0', 'exclude_post_types' => '0', 'compatibility_older_mysql' => '0'); $this->plugin_tabs = array('<a href="#" class="nav-tab nav-tab-active js-action-link migrate" data-div-name="migrate-tab">' . esc_html(_x('Migrate', 'Configure a migration or export', 'wp-migrate-db')) . '</a>', '<a href="#" class="nav-tab js-action-link settings" data-div-name="settings-tab">' . esc_html(_x('Settings', 'Plugin configuration and preferences', 'wp-migrate-db')) . '</a>', '<a href="#" class="nav-tab js-action-link help" data-div-name="help-tab">' . esc_html(_x('Help', 'Get help or contact support', 'wp-migrate-db')) . '</a>'); // automatically deactivate WPMDB Pro / Free if the other is already active add_action('activated_plugin', array($this, 'deactivate_other_instances')); // display a notice when either WP Migrate DB or WP Migrate DB Pro is automatically deactivated add_action('pre_current_active_plugins', array($this, 'plugin_deactivated_notice')); // check if WP Engine is filtering the buffer and prevent it add_action('plugins_loaded', array($this, 'maybe_disable_wp_engine_filtering')); // this is how many DB rows are processed at a time, allow devs to change this value $this->rows_per_segment = apply_filters('wpmdb_rows_per_segment', $this->rows_per_segment); if (is_multisite()) { add_action('network_admin_menu', array($this, 'network_admin_menu')); /* * The URL find & replace is locked down (delete & reorder disabled) on multisite installations as we require the URL * of the remote site for export migrations. This URL is parsed into it's various components and * used to change values in the 'domain' & 'path' columns in the wp_blogs and wp_site tables. */ $this->lock_url_find_replace_row = true; } else { add_action('admin_menu', array($this, 'admin_menu')); } }
/** * Returns validated and sanitized form data. * * @param array|string $data * * @return array|string */ function parse_migration_form_data($data) { $form_data = parent::parse_migration_form_data($data); $this->accepted_fields = apply_filters('wpmdb_accepted_profile_fields', $this->accepted_fields); $form_data = array_intersect_key($form_data, array_flip($this->accepted_fields)); unset($form_data['replace_old'][0]); unset($form_data['replace_new'][0]); if (!isset($form_data['replace_old'])) { $form_data['replace_old'] = array(); } if (!isset($form_data['replace_new'])) { $form_data['replace_new'] = array(); } if (isset($form_data['exclude_post_revisions'])) { $form_data['exclude_post_types'] = '1'; $form_data['select_post_types'][] = 'revision'; $form_data['select_post_types'] = array_unique($form_data['select_post_types']); unset($form_data['exclude_post_revisions']); } return $form_data; }
function __construct($plugin_file_path) { $this->is_addon = true; parent::__construct($plugin_file_path); }
function __construct($plugin_file_path) { parent::__construct($plugin_file_path); $this->plugin_version = $GLOBALS['wpmdb_meta'][$this->core_slug]['version']; $this->max_insert_string_len = 50000; // 50000 is the default as defined by phphmyadmin $default_settings = array('key' => $this->generate_key(), 'allow_pull' => false, 'allow_push' => false, 'profiles' => array(), 'licence' => '', 'verify_ssl' => false, 'blacklist_plugins' => array()); if (empty($this->settings['max_request'])) { $this->settings['max_request'] = min(1024 * 1024, $this->get_bottleneck('max')); update_option('wpmdb_settings', $this->settings); } // if no settings exist then this is a fresh install, set up some default settings if (empty($this->settings)) { $this->settings = $default_settings; update_option('wpmdb_settings', $this->settings); } else { // When we add a new setting, an existing customer's db won't have this // new setting, so we need to add it. Otherwise, they'll see // array index errors in debug mode $update_settings = false; foreach ($default_settings as $key => $value) { if (!isset($this->settings[$key])) { $this->settings[$key] = $value; $update_settings = true; } } if ($update_settings) { update_option('wpmdb_settings', $this->settings); } } add_filter('plugin_action_links_' . $this->plugin_basename, array($this, 'plugin_action_links')); add_filter('network_admin_plugin_action_links_' . $this->plugin_basename, array($this, 'plugin_action_links')); // internal AJAX handlers add_action('wp_ajax_wpmdb_delete_migration_profile', array($this, 'ajax_delete_migration_profile')); add_action('wp_ajax_wpmdb_save_profile', array($this, 'ajax_save_profile')); add_action('wp_ajax_wpmdb_initiate_migration', array($this, 'ajax_initiate_migration')); add_action('wp_ajax_wpmdb_migrate_table', array($this, 'ajax_migrate_table')); add_action('wp_ajax_wpmdb_finalize_migration', array($this, 'ajax_finalize_migration')); add_action('wp_ajax_wpmdb_clear_log', array($this, 'ajax_clear_log')); add_action('wp_ajax_wpmdb_get_log', array($this, 'ajax_get_log')); add_action('wp_ajax_wpmdb_fire_migration_complete', array($this, 'fire_migration_complete')); add_action('wp_ajax_wpmdb_plugin_compatibility', array($this, 'ajax_plugin_compatibility')); add_action('wp_ajax_wpmdb_blacklist_plugins', array($this, 'ajax_blacklist_plugins')); add_action('wp_ajax_wpmdb_update_max_request_size', array($this, 'ajax_update_max_request_size')); add_action('wp_ajax_wpmdb_cancel_migration', array($this, 'ajax_cancel_migration')); $absolute_path = rtrim(ABSPATH, '\\/'); $site_url = rtrim(site_url('', 'http'), '\\/'); $home_url = rtrim(home_url('', 'http'), '\\/'); if ($site_url != $home_url) { $difference = str_replace($home_url, '', $site_url); if (strpos($absolute_path, $difference) !== false) { $absolute_path = rtrim(substr($absolute_path, 0, -strlen($difference)), '\\/'); } } $this->absolute_root_file_path = $absolute_path; $this->accepted_fields = array('action', 'save_computer', 'gzip_file', 'connection_info', 'replace_old', 'replace_new', 'table_migrate_option', 'select_tables', 'replace_guids', 'exclude_spam', 'save_migration_profile', 'save_migration_profile_option', 'create_new_profile', 'create_backup', 'remove_backup', 'keep_active_plugins', 'select_post_types', 'backup_option', 'select_backup', 'exclude_transients', 'exclude_post_types', 'exclude_post_revisions'); $this->default_profile = array('action' => 'savefile', 'save_computer' => '1', 'gzip_file' => '1', 'table_migrate_option' => 'migrate_only_with_prefix', 'replace_guids' => '1', 'default_profile' => true, 'name' => '', 'select_tables' => array(), 'select_post_types' => array(), 'backup_option' => 'backup_only_with_prefix', 'exclude_transients' => '1'); $this->checkbox_options = array('save_computer' => '0', 'gzip_file' => '0', 'replace_guids' => '0', 'exclude_spam' => '0', 'keep_active_plugins' => '0', 'create_backup' => '0', 'exclude_post_types' => '0'); $this->plugin_tabs = array('<a href="#" class="nav-tab nav-tab-active js-action-link migrate" data-div-name="migrate-tab">' . __('Migrate', 'wp-migrate-db') . '</a>', '<a href="#" class="nav-tab js-action-link settings" data-div-name="settings-tab">' . __('Settings', 'wp-migrate-db') . '</a>', '<a href="#" class="nav-tab js-action-link help" data-div-name="help-tab">' . __('Help', 'wp-migrate-db') . '</a>'); // automatically deactivate WPMDB Pro / Free if the other is already active add_action('activated_plugin', array($this, 'deactivate_other_instances')); // display a notice when either WP Migrate DB or WP Migrate DB Pro is automatically deactivated add_action('pre_current_active_plugins', array($this, 'plugin_deactivated_notice')); // this is how many DB rows are processed at a time, allow devs to change this value $this->rows_per_segment = apply_filters('wpmdb_rows_per_segment', $this->rows_per_segment); if (is_multisite()) { add_action('network_admin_menu', array($this, 'network_admin_menu')); /* * The URL find & replace is locked down (delete & reorder disabled) on multisite installations as we require the URL * of the remote site for export migrations. This URL is parsed into it's various components and * used to change values in the 'domain' & 'path' columns in the wp_blogs and wp_site tables. */ $this->lock_url_find_replace_row = true; } else { add_action('admin_menu', array($this, 'admin_menu')); } }
/** * Return subsite id if subsite selected. * * @param WPMDB_Base $plugin_instance * * @return int Will return 0 if not doing MST migration. * * Will return 0 if not doing MST migration. */ public function selected_subsite(&$plugin_instance = null) { $blog_id = 0; if (empty($plugin_instance)) { $plugin_instance =& $this->wpmdbpro; } $this->state_data = $plugin_instance->set_post_data(); if (!empty($this->state_data['form_data'])) { $this->form_data = $this->parse_migration_form_data($this->state_data['form_data']); $select_subsite = $this->profile_value('mst_select_subsite'); $selected_subsite = $this->profile_value('mst_selected_subsite'); // TODO: Remove backwards compatibility for CLI once Core/MST/CLI dependencies updated. if (empty($select_subsite) && empty($selected_subsite)) { $select_subsite = $this->profile_value('multisite_subsite_export'); $selected_subsite = $this->profile_value('select_subsite'); } // During a migration, this is where the subsite's id will be derived. if (empty($blog_id) && !empty($select_subsite) && !empty($selected_subsite) && is_numeric($selected_subsite)) { $blog_id = $selected_subsite; } } // When loading a saved migration profile, this is where the subsite's id will be derived. global $loaded_profile; if (empty($blog_id) && !empty($loaded_profile['mst_select_subsite']) && !empty($loaded_profile['mst_selected_subsite']) && is_numeric($loaded_profile['mst_selected_subsite'])) { $blog_id = $loaded_profile['mst_selected_subsite']; } // If on multisite we can check that selected blog exists as all scenarios would require it. if (1 < $blog_id && is_multisite() && !$this->subsite_exists($blog_id)) { $blog_id = 0; } return $blog_id; }