/** * Hook in an change the plugin description when BackUpWordPress is activated * * @param array $plugins * @return array $plugins */ function hmbkp_plugin_row($plugins) { $menu = is_multisite() ? 'Settings' : 'Tools'; if (isset($plugins[HMBKP_PLUGIN_SLUG . '/backupwordpress.php'])) { $plugins[HMBKP_PLUGIN_SLUG . '/backupwordpress.php']['Description'] = str_replace('Once activated you\'ll find me under <strong>' . $menu . ' → Backups</strong>', 'Find me under <strong><a href="' . esc_url(hmbkp_get_settings_url()) . '">' . $menu . ' → Backups</a></strong>', $plugins[HMBKP_PLUGIN_SLUG . '/backupwordpress.php']['Description']); } return $plugins; }
_e('Excludes', 'hmbkp'); ?> </a> | <?php } ?> <?php foreach (HMBKP_Services::get_services($schedule) as $service) { if (!$service->has_form()) { continue; } ?> <a href="<?php echo esc_url(add_query_arg(array('action' => 'hmbkp_edit_schedule', 'hmbkp_panel' => 'hmbkp_edit_schedule_settings_' . $service->get_slug(), 'hmbkp_schedule_id' => $schedule->get_id()), hmbkp_get_settings_url())); ?> "><?php echo esc_html($service->name); ?> </a> | <?php } ?> <a class="delete-action" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'hmbkp_request_delete_schedule', 'hmbkp_schedule_id' => $schedule->get_id()), admin_url('admin-post.php')), 'hmbkp_delete_schedule', 'hmbkp_delete_schedule_nonce')); ?> "><?php _e('Delete', 'hmbkp');
/** * * @param null $pathname */ function hmbkp_recalculate_directory_filesize() { if (!isset($_GET['hmbkp_recalculate_directory_filesize']) || !check_admin_referer('hmbkp-recalculate_directory_filesize')) { return; } $schedule = new HMBKP_Scheduled_Backup(sanitize_text_field($_GET['hmbkp_schedule_id'])); $directory = sanitize_text_field($_GET['hmbkp_recalculate_directory_filesize']); // Delete the cached directory size delete_transient('hmbkp_directory_filesizes'); $url = add_query_arg(array('action' => 'hmbkp_edit_schedule', 'hmbkp_panel' => 'hmbkp_edit_schedule_excludes'), hmbkp_get_settings_url()); if (isset($_GET['hmbkp_directory_browse'])) { $url = add_query_arg('hmbkp_directory_browse', sanitize_text_field($_GET['hmbkp_directory_browse']), $url); } wp_safe_redirect($url, '303'); die; }
/** * Display the row of actions for a schedule * * @access public * @param HMBKP_Scheduled_Backup $schedule * @return void */ function hmbkp_schedule_status(HMBKP_Scheduled_Backup $schedule, $echo = true) { ob_start(); ?> <span class="hmbkp-status"<?php if ($schedule->get_status()) { ?> title="<?php printf(__('Started %s ago', 'hmbkp'), human_time_diff($schedule->get_schedule_running_start_time())); ?> "<?php } ?> > <?php echo $schedule->get_status() ? wp_kses_data($schedule->get_status()) : __('Starting Backup', 'hmbkp'); ?> <a href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'hmbkp_request_cancel_backup', 'hmbkp_schedule_id' => $schedule->get_id()), hmbkp_get_settings_url()), 'hmbkp_request_cancel_backup', 'hmbkp_request_cancel_backup_nonce')); ?> "><?php _e('cancel', 'hmbkp'); ?> </a> </span> <?php $output = ob_get_clean(); if (!$echo) { return $output; } echo $output; }
?> </td> </tr> <?php } ?> </tbody> </table> <?php } ?> <p class="submit"> <a href="<?php echo esc_url(hmbkp_get_settings_url()); ?> " class="button-primary"><?php _e('Done', 'backupwordpress'); ?> </a> </p> </div>
/** * * @param null $pathname */ function hmbkp_recalculate_directory_filesize($pathname = null) { if (!$pathname && (!isset($_GET['hmbkp_recalculate_directory_filesize']) || !check_admin_referer('hmbkp-recalculate_directory_filesize'))) { return; } $schedule = new HMBKP_Scheduled_Backup(sanitize_text_field($_GET['hmbkp_schedule_id'])); if (!$pathname) { $directory = sanitize_text_field($_GET['hmbkp_recalculate_directory_filesize']); } else { $directory = $pathname; } // Delete the cached directory size // TODO should use $schedule->get_transient_key delete_transient($schedule->get_transient_key($directory)); $handle = opendir($directory); while ($file_handle = readdir($handle)) { // Ignore current dir and containing dir if ($file_handle === '.' || $file_handle === '..') { continue; } $file = HM_Backup::conform_dir(trailingslashit($directory) . $file_handle); // Delete all sub directories if (is_dir($file)) { delete_transient($schedule->get_transient_key($file)); hmbkp_recalculate_directory_filesize($file); } } closedir($handle); $parent_directory = dirname($directory); // Delete the cached filesize of all parents as well while ($schedule->get_root() !== $parent_directory) { delete_transient($schedule->get_transient_key($parent_directory)); $parent_directory = dirname($parent_directory); } if (!$pathname) { $url = add_query_arg(array('action' => 'hmbkp_edit_schedule', 'hmbkp_panel' => 'hmbkp_edit_schedule_excludes'), hmbkp_get_settings_url()); if (isset($_GET['hmbkp_directory_browse'])) { $url = add_query_arg('hmbkp_directory_browse', sanitize_text_field($_GET['hmbkp_directory_browse']), $url); } wp_safe_redirect($url, '303'); die; } }