Esempio n. 1
0
 function __construct($plugin_file_path)
 {
     parent::__construct($plugin_file_path);
 }
Esempio n. 2
0
 function __construct($plugin_file_path)
 {
     parent::__construct($plugin_file_path);
     $this->plugin_slug = 'migrations';
     $this->plugin_version = $GLOBALS['mdb_meta']['migrations']['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(), '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('mdb_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('mdb_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('mdb_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_mdb_verify_connection_to_remote_site', array($this, 'ajax_verify_connection_to_remote_site'));
     add_action('wp_ajax_mdb_reset_api_key', array($this, 'ajax_reset_api_key'));
     add_action('wp_ajax_mdb_delete_migration_profile', array($this, 'ajax_delete_migration_profile'));
     add_action('wp_ajax_mdb_save_setting', array($this, 'ajax_save_setting'));
     add_action('wp_ajax_mdb_save_profile', array($this, 'ajax_save_profile'));
     add_action('wp_ajax_mdb_initiate_migration', array($this, 'ajax_initiate_migration'));
     add_action('wp_ajax_mdb_migrate_table', array($this, 'ajax_migrate_table'));
     add_action('wp_ajax_mdb_finalize_migration', array($this, 'ajax_finalize_migration'));
     add_action('wp_ajax_mdb_clear_log', array($this, 'ajax_clear_log'));
     add_action('wp_ajax_mdb_get_log', array($this, 'ajax_get_log'));
     add_action('wp_ajax_mdb_fire_migration_complete', array($this, 'fire_migration_complete'));
     add_action('wp_ajax_mdb_update_max_request_size', array($this, 'ajax_update_max_request_size'));
     add_action('wp_ajax_mdb_plugin_compatibility', array($this, 'ajax_plugin_compatibility'));
     add_action('wp_ajax_mdb_blacklist_plugins', array($this, 'ajax_blacklist_plugins'));
     add_action('wp_ajax_mdb_cancel_migration', array($this, 'ajax_cancel_migration'));
     // external AJAX handlers
     add_action('wp_ajax_nopriv_mdb_verify_connection_to_remote_site', array($this, 'respond_to_verify_connection_to_remote_site'));
     add_action('wp_ajax_nopriv_mdb_remote_initiate_migration', array($this, 'respond_to_remote_initiate_migration'));
     add_action('wp_ajax_nopriv_mdb_process_chunk', array($this, 'ajax_process_chunk'));
     add_action('wp_ajax_nopriv_mdb_process_pull_request', array($this, 'respond_to_process_pull_request'));
     add_action('wp_ajax_nopriv_mdb_fire_migration_complete', array($this, 'fire_migration_complete'));
     add_action('wp_ajax_nopriv_mdb_backup_remote_table', array($this, 'respond_to_backup_remote_table'));
     add_action('wp_ajax_nopriv_mdb_remote_finalize_migration', array($this, 'respond_to_remote_finalize_migration'));
     add_action('wp_ajax_nopriv_mdb_process_push_migration_cancellation', array($this, 'respond_to_process_push_migration_cancellation'));
     // 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('mdb_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=migrations';
     } else {
         add_action('admin_menu', array($this, 'admin_menu'));
         $this->plugin_base = 'tools.php?page=migrations';
     }
 }