| Conditions | 16 |
| Paths | > 20000 |
| Total Lines | 96 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 60 | public static function activate() { |
||
| 61 | |||
| 62 | global $wpdb; |
||
| 63 | |||
| 64 | if (version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) { |
||
| 65 | wp_die('<p>'.sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"), Xcloner_Activator::xcloner_minimum_version, phpversion()).'</p>', __("XCloner Activation Error"), array('response' => 500, |
||
| 66 | 'back_link' => true |
||
| 67 | )); |
||
| 68 | } |
||
| 69 | |||
| 70 | $charset_collate = $wpdb->get_charset_collate(); |
||
| 71 | |||
| 72 | $installed_ver = get_option("xcloner_db_version"); |
||
| 73 | |||
| 74 | $xcloner_db_version = Xcloner_Activator::xcloner_db_version; |
||
| 75 | |||
| 76 | $xcloner_scheduler_table = $wpdb->prefix."xcloner_scheduler"; |
||
| 77 | |||
| 78 | if ($installed_ver != $xcloner_db_version) { |
||
| 79 | $xcloner_schedule_sql = "CREATE TABLE `".$xcloner_scheduler_table."` ( |
||
| 80 | `id` int(11) NOT NULL AUTO_INCREMENT, |
||
| 81 | `name` varchar(255) NOT NULL, |
||
| 82 | `recurrence` varchar(25) NOT NULL, |
||
| 83 | `params` text NOT NULL, |
||
| 84 | `start_at` datetime, |
||
| 85 | `remote_storage` varchar(10) DEFAULT NULL, |
||
| 86 | `hash` varchar(10) DEFAULT NULL, |
||
| 87 | `status` int(1) NOT NULL, |
||
| 88 | `last_backup` varchar(100) DEFAULT NULL, |
||
| 89 | PRIMARY KEY (`id`) |
||
| 90 | ) " . $charset_collate."; |
||
| 91 | "; |
||
| 92 | |||
| 93 | require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
||
| 94 | dbDelta($xcloner_schedule_sql); |
||
| 95 | |||
| 96 | update_option("xcloner_db_version", $xcloner_db_version); |
||
| 97 | } |
||
| 98 | |||
| 99 | if (get_option('xcloner_backup_compression_level') === false) { |
||
| 100 | update_option('xcloner_backup_compression_level', 0); |
||
| 101 | } |
||
| 102 | |||
| 103 | if (get_option('xcloner_enable_log') === false) { |
||
| 104 | update_option('xcloner_enable_log', 1); |
||
| 105 | } |
||
| 106 | |||
| 107 | if (get_option('xcloner_enable_mysql_backup') === false) { |
||
| 108 | update_option('xcloner_enable_mysql_backup', 1); |
||
| 109 | } |
||
| 110 | |||
| 111 | if (get_option('xcloner_system_settings_page') === false) { |
||
| 112 | update_option('xcloner_system_settings_page', 100); |
||
| 113 | } |
||
| 114 | |||
| 115 | if (get_option('xcloner_files_to_process_per_request') === false) { |
||
| 116 | update_option('xcloner_files_to_process_per_request', 250); |
||
| 117 | } |
||
| 118 | |||
| 119 | if (get_option('xcloner_database_records_per_request') === false) { |
||
| 120 | update_option('xcloner_database_records_per_request', 10000); |
||
| 121 | } |
||
| 122 | |||
| 123 | if (get_option('xcloner_exclude_files_larger_than_mb') === false) { |
||
| 124 | update_option('xcloner_exclude_files_larger_than_mb', 0); |
||
| 125 | } |
||
| 126 | |||
| 127 | if (get_option('xcloner_split_backup_limit') === false) { |
||
| 128 | update_option('xcloner_split_backup_limit', 2048); |
||
| 129 | } |
||
| 130 | |||
| 131 | if (get_option('xcloner_size_limit_per_request') === false) { |
||
| 132 | update_option('xcloner_size_limit_per_request', 50); |
||
| 133 | } |
||
| 134 | |||
| 135 | if (get_option('xcloner_cleanup_retention_limit_days') === false) { |
||
| 136 | update_option('xcloner_cleanup_retention_limit_days', 60); |
||
| 137 | } |
||
| 138 | |||
| 139 | if (get_option('xcloner_cleanup_retention_limit_archives') === false) { |
||
| 140 | update_option('xcloner_cleanup_retention_limit_archives', 100); |
||
| 141 | } |
||
| 142 | |||
| 143 | if (get_option('xcloner_directories_to_scan_per_request') === false) { |
||
| 144 | update_option('xcloner_directories_to_scan_per_request', 25); |
||
| 145 | } |
||
| 146 | |||
| 147 | /*if(!get_option('xcloner_diff_backup_recreate_period')) |
||
| 148 | update_option('xcloner_diff_backup_recreate_period', 10); |
||
| 149 | * */ |
||
| 150 | |||
| 151 | if (!get_option('xcloner_regex_exclude')) { |
||
| 152 | update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$"); |
||
| 153 | } |
||
| 154 | |||
| 155 | if (!get_option('xcloner_regex_exclude')) { |
||
| 156 | update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$"); |
||
| 162 |