function __construct($plugin_file_path) { parent::__construct($plugin_file_path); }
function __construct($plugin_file_path) { parent::__construct($plugin_file_path); $this->plugin_slug = 'wp-migrate-db-pro'; $this->plugin_version = $GLOBALS['wpmdb_meta']['wp-migrate-db-pro']['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 { $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_verify_connection_to_remote_site', array($this, 'ajax_verify_connection_to_remote_site')); add_action('wp_ajax_wpmdb_reset_api_key', array($this, 'ajax_reset_api_key')); add_action('wp_ajax_wpmdb_delete_migration_profile', array($this, 'ajax_delete_migration_profile')); add_action('wp_ajax_wpmdb_save_setting', array($this, 'ajax_save_setting')); 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_activate_licence', array($this, 'ajax_activate_licence')); add_action('wp_ajax_wpmdb_check_licence', array($this, 'ajax_check_licence')); add_action('wp_ajax_wpmdb_fire_migration_complete', array($this, 'fire_migration_complete')); add_action('wp_ajax_wpmdb_update_max_request_size', array($this, 'ajax_update_max_request_size')); 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_cancel_migration', array($this, 'ajax_cancel_migration')); // external AJAX handlers add_action('wp_ajax_nopriv_wpmdb_verify_connection_to_remote_site', array($this, 'respond_to_verify_connection_to_remote_site')); add_action('wp_ajax_nopriv_wpmdb_remote_initiate_migration', array($this, 'respond_to_remote_initiate_migration')); add_action('wp_ajax_nopriv_wpmdb_process_chunk', array($this, 'ajax_process_chunk')); add_action('wp_ajax_nopriv_wpmdb_process_pull_request', array($this, 'respond_to_process_pull_request')); add_action('wp_ajax_nopriv_wpmdb_fire_migration_complete', array($this, 'fire_migration_complete')); add_action('wp_ajax_nopriv_wpmdb_backup_remote_table', array($this, 'respond_to_backup_remote_table')); add_action('wp_ajax_nopriv_wpmdb_remote_finalize_migration', array($this, 'respond_to_remote_finalize_migration')); add_action('wp_ajax_nopriv_wpmdb_process_push_migration_cancellation', array($this, 'respond_to_process_push_migration_cancellation')); // Take over the update check add_filter('site_transient_update_plugins', array($this, 'site_transient_update_plugins')); // Add some custom JS into the WP admin pages add_action('admin_enqueue_scripts', array($this, 'enqueue_plugin_update_script')); // Add some custom CSS into the WP admin pages add_action('admin_head-plugins.php', array($this, 'add_plugin_update_styles')); // Hook into the plugin install process, inject addon download url add_action('plugins_api', array($this, 'inject_addon_install_resource'), 10, 3); // Clear update transients when the user clicks the "Check Again" button from the update screen add_action('current_screen', array($this, 'check_again_clear_transients')); $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'); $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'); if (is_multisite()) { add_action('network_admin_menu', array($this, 'network_admin_menu')); } else { add_action('admin_menu', array($this, 'admin_menu')); } add_filter('admin_body_class', array($this, 'admin_body_class')); // 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')); $this->plugin_base = 'settings.php?page=wp-migrate-db-pro'; } else { add_action('admin_menu', array($this, 'admin_menu')); $this->plugin_base = 'tools.php?page=wp-migrate-db-pro'; } // testing only - if uncommented, will always check for plugin updates //delete_site_transient( 'update_plugins' ); //delete_site_transient( 'wpmdb_upgrade_data' ); //delete_site_transient( 'wpmdb_licence_response' ); }