function snapshot_init_proc() { if (!is_multisite()) { $role = get_role('administrator'); if ($role) { $role->add_cap('manage_snapshots_items'); $role->add_cap('manage_snapshots_destinations'); $role->add_cap('manage_snapshots_settings'); $role->add_cap('manage_snapshots_import'); } $this->load_config(); $this->set_backup_folder(); $this->set_log_folders(); if (Snapshot_Helper_Utility::is_pro()) { Snapshot_Model_Destination::load_destinations(); } } else { global $current_site, $current_blog; if ($current_site->blog_id == $current_blog->blog_id) { $this->load_config(); $this->set_backup_folder(); $this->set_log_folders(); if (Snapshot_Helper_Utility::is_pro()) { Snapshot_Model_Destination::load_destinations(); } } } }
public static function render_destination_listing_panel() { if (!Snapshot_Helper_Utility::is_pro()) { self::render_premium_plugin_prompt(); return false; } if (isset($_REQUEST['snapshot-action']) && (sanitize_text_field($_REQUEST['snapshot-action']) == 'add' || sanitize_text_field($_REQUEST['snapshot-action']) == 'edit' || sanitize_text_field($_REQUEST['snapshot-action']) == 'update')) { self::render_destination_edit_panel(); } else { ?> <div id="snapshot-edit-destinations-panel" class="wrap snapshot-wrap"> <h2><?php _ex("All Snapshot Destinations", "Snapshot Destination Page Title", SNAPSHOT_I18N_DOMAIN); ?> </h2> <p><?php _ex("This page show all the destinations available for the Snapshot plugin. A destination is a remote system like Amazon S3, Dropbox or SFTP. Simply select the destination type from the drop down then will in the details. When you add or edit a Snapshot you will be able to assign it a destination. When the snapshot backup runs the archive file will be sent to the destination instead of stored locally.", 'Snapshot page description', SNAPSHOT_I18N_DOMAIN); ?> </p> <?php if (session_id() == "") { @session_start(); } $destinations = array(); foreach (WPMUDEVSnapshot::instance()->config_data['destinations'] as $key => $item) { $type = $item['type']; if (!isset($destinations[$type])) { $destinations[$type] = array(); } $destinations[$type][$key] = $item; } $destinationClasses = WPMUDEVSnapshot::instance()->get_setting('destinationClasses'); if ($destinationClasses && count($destinationClasses)) { ksort($destinationClasses); foreach ($destinationClasses as $classObject) { //echo "classObject<pre>"; print_r($classObject); echo "</pre>"; ?> <h3 style="float:left;"><?php echo $classObject->name_display; ?> <?php if (current_user_can('manage_snapshots_destinations')) { ?> <a class="add-new-h2" style="top:0;" href="<?php echo WPMUDEVSnapshot::instance()->get_setting('SNAPSHOT_MENU_URL'); ?> snapshots_destinations_panel&snapshot-action=add&type=<?php echo $classObject->name_slug; ?> "> Add New</a><?php } ?> </h3> <?php if (isset($classObject->name_logo) && strlen($classObject->name_logo)) { ?> <img style="float: right; height: 40px;" src="<?php echo $classObject->name_logo; ?> " alt="<?php $classObject->name_display; ?> " /><?php } ?> <form id="snapshot-edit-destination-<?php echo $classObject->name_slug; ?> " action="<?php echo WPMUDEVSnapshot::instance()->get_setting('SNAPSHOT_MENU_URL'); ?> snapshots_destinations_panel" method="post"> <input type="hidden" name="snapshot-action" value="delete-bulk"/> <input type="hidden" name="snapshot-destination-type" value="<?php echo $classObject->name_slug; ?> "/> <?php wp_nonce_field('snapshot-delete-destination-bulk-' . $classObject->name_slug, 'snapshot-noonce-field-' . $classObject->name_slug); ?> <?php $edit_url = WPMUDEVSnapshot::instance()->get_setting('SNAPSHOT_MENU_URL') . 'snapshots_destinations_panel&snapshot-action=edit&type=' . $classObject->name_slug . '&'; $delete_url = WPMUDEVSnapshot::instance()->get_setting('SNAPSHOT_MENU_URL') . 'snapshots_destinations_panel&snapshot-action=delete&'; if (isset($destinations[$classObject->name_slug])) { $destination_items = $destinations[$classObject->name_slug]; } else { $destination_items = array(); } $classObject->display_listing_table($destination_items, $edit_url, $delete_url); ?> </form> <?php } } ?> </div> <?php } }
/** * Metabox to show the backup file options * * @since 1.0.2 * * @param string $title - Title to be displayed in header of metabox * @param array $item - The current viewed item * * @return none */ function snapshot_metabox_show_backup_files_options($title, $item) { global $wpdb; if (!isset($item['blog-id'])) { $item['blog-id'] = $wpdb->blogid; } if (!isset($item['files-option'])) { $item['files-option'] = "none"; } if (!isset($item['files-sections'])) { $item['files-sections'] = array(); } ?> <div class="postbox"> <h3 class="hndle"><span><?php echo $title; ?> </span></h3> <div class="inside"> <table class="form-table snapshot-backup-files"> <tr class=""> <td class="left"> <p><?php _e('Select the File backup option for this Snapshot.', SNAPSHOT_I18N_DOMAIN); ?> </p> <ul> <li><input type="radio" class="snapshot-files-option" id="snapshot-files-option-none" value="none" <?php if ($item['files-option'] == "none") { echo ' checked="checked" '; } ?> name="snapshot-files-option"> <label for="snapshot-files-option-none"><?php _e('Do not include files', SNAPSHOT_I18N_DOMAIN); ?> </label></li> <?php $blog_upload_path = Snapshot_Helper_Utility::get_blog_upload_path($item['blog-id']); if (!empty($blog_upload_path)) { ?> <li><input type="radio" class="snapshot-files-option" id="snapshot-files-option-all" value="all" <?php if ($item['files-option'] == "all") { echo ' checked="checked" '; } ?> name="snapshot-files-option"> <label for="snapshot-files-option-all"><?php _e('Include <strong>common</strong> files:', SNAPSHOT_I18N_DOMAIN); ?> <span <?php if (!is_main_site($item['blog-id'])) { echo ' style="display:none" '; } ?> class="snapshot-backup-files-sections-main-only"><?php _e('Themes, Plugins,', SNAPSHOT_I18N_DOMAIN); ?> </span> <?php _e('Media', SNAPSHOT_I18N_DOMAIN); ?> (<span style="font-weight: bold;" class="snapshot-media-upload-path"><?php echo $blog_upload_path; ?> </span>)</label> </li> <?php } ?> <?php if (!isset($item['blog-id']) || is_main_site($item['blog-id'])) { ?> <li class="snapshot-backup-files-sections-main-only"><input type="radio" class="snapshot-files-option" id="snapshot-files-option-selected" value="selected" <?php if ($item['files-option'] == "selected") { echo ' checked="checked" '; } ?> name="snapshot-files-option"> <label for="snapshot-files-option-selected"><?php _e('Include <strong>selected</strong> files:', SNAPSHOT_I18N_DOMAIN); ?> </label> <div id="snapshot-selected-files-container" style="margin-left: 30px; padding-top: 10px; <?php if ($item['files-option'] == "none" || $item['files-option'] == "all") { echo ' display:none; '; } ?> "> <ul id="snapshot-select-files-option"> <?php /* ?> <li><input type="checkbox" class="snapshot-backup-sub-options" <?php if (array_search('home', $item['files-sections']) !== false) { echo ' checked="checked" '; } ?> id="snapshot-files-option-home" value="home" name="snapshot-files-sections[home]"> <label for="snapshot-files-option-home"><?php _e('Home: Files in the home directory. Will automatically exclude .wp-config.php & .htaccess', SNAPSHOT_I18N_DOMAIN); ?></label></li> <?php */ ?> <li><input type="checkbox" class="snapshot-backup-sub-options" <?php if (array_search('themes', $item['files-sections']) !== false) { echo ' checked="checked" '; } ?> id="snapshot-files-option-themes" value="themes" name="snapshot-files-sections[themes]"> <label for="snapshot-files-option-themes"><?php _e('Themes: All active and inactive themes will be included', SNAPSHOT_I18N_DOMAIN); ?> </label> </li> <li><input type="checkbox" class="snapshot-backup-sub-options" <?php if (array_search('plugins', $item['files-sections']) !== false) { echo ' checked="checked" '; } ?> id="snapshot-files-option-plugins" value="plugins" name="snapshot-files-sections[plugins]"> <label for="snapshot-files-option-plugins"><?php _e('Plugins: All active and inactive plugins will be included', SNAPSHOT_I18N_DOMAIN); ?> </label> </li> <?php if (is_multisite()) { ?> <li><input type="checkbox" class="snapshot-backup-sub-options" <?php if (array_search('plugins', $item['files-sections']) !== false) { echo ' checked="checked" '; } ?> id="snapshot-files-option-mu-plugins" value="mu-plugins" name="snapshot-files-sections[mu-plugins]"> <label for="snapshot-files-option-mu-plugins"><?php _e('MU-Plugins: All active and inactive plugins will be included', SNAPSHOT_I18N_DOMAIN); ?> </label></li> <?php } ?> <li><input type="checkbox" class="snapshot-backup-sub-options" <?php if (array_search('media', $item['files-sections']) !== false) { echo ' checked="checked" '; } ?> id="snapshot-files-option-media" value="media" name="snapshot-files-sections[media]"> <label for="snapshot-files-option-media"><?php _e('Media Files:', SNAPSHOT_I18N_DOMAIN); ?> <span style="font-weight: bold;" class="snapshot-media-upload-path"><?php echo Snapshot_Helper_Utility::get_blog_upload_path($item['blog-id']); ?> </span></label> </li> <li><input type="checkbox" class="snapshot-backup-sub-options" <?php if (array_search('config', $item['files-sections']) !== false) { echo ' checked="checked" '; } ?> id="snapshot-files-option-config" value="config" name="snapshot-files-sections[config]"> <label for="snapshot-files-option-config"><?php _e('wp-config.php - Your current wp-config.php file', SNAPSHOT_I18N_DOMAIN); ?> </label> </li> <li><input type="checkbox" class="snapshot-backup-sub-options" <?php if (array_search('htaccess', $item['files-sections']) !== false) { echo ' checked="checked" '; } ?> id="snapshot-files-option-htaccess" value="htaccess" name="snapshot-files-sections[htaccess]"> <label for="snapshot-files-option-htaccess"><?php _e('.htaccess - Your current root .htaccess / web.config file', SNAPSHOT_I18N_DOMAIN); ?> </label> </li> <?php /* ?> <li><input type="checkbox" class="snapshot-backup-sub-options" <?php if (array_search('core', $item['files-sections']) !== false) { echo ' checked="checked" '; } ?> id="snapshot-files-option-core" value="core" name="snapshot-backup-files-sections[core]"> <label for="snapshot-files-option-core"><?php _e('WordPress core files', SNAPSHOT_I18N_DOMAIN); ?></label></li> <?php */ ?> </ul> </div> </li> <?php } ?> </ul> <?php if (!isset($item['destination-sync'])) { $item['destination-sync'] = "archive"; } ?> <?php if (Snapshot_Helper_Utility::is_pro()) { ?> <div id="snapshot-selected-files-sync-container"> <p><?php _e('Dropbox Only - Select Archive or Mirroring option for this Snapshot.', SNAPSHOT_I18N_DOMAIN); ?> </p> <ul> <?php $_is_mirror_disabled = ' disabled="disabled" '; if (isset($item['destination'])) { $destination_key = $item['destination']; if (isset(WPMUDEVSnapshot::instance()->config_data['destinations'][$destination_key])) { $destination = WPMUDEVSnapshot::instance()->config_data['destinations'][$destination_key]; if (isset($destination['type']) && $destination['type'] == "dropbox") { $_is_mirror_disabled = ''; } } } ?> <li><input type="radio" name="snapshot-destination-sync" id="snapshot-destination-sync-archive" value="archive" class="snapshot-destination-sync" <?php if ($item['destination-sync'] == "archive") { echo ' checked="checked" '; } ?> /> <label for="snapshot-destination-sync-archive"><?php _e('<strong>Archive</strong> - (Default) Selecting archive will produce a zip archive. This is standard method for backing up your site. A single zip archive will be created for files and database tables.', SNAPSHOT_I18N_DOMAIN); ?> </li> <li><input type="radio" <?php echo $_is_mirror_disabled; ?> name="snapshot-destination-sync" id="snapshot-destination-sync-mirror" value="mirror" class="snapshot-destination-sync" <?php if ($item['destination-sync'] == "mirror") { echo ' checked="checked" '; } ?> /> <label for="snapshot-destination-sync-mirror"><?php _e('<strong>Mirror/Sync</strong> - <strong>Dropbox ONLY</strong> Selecting mirroring if you want to replicate the file structure of this site to a Dropbox destination. You can include Database tables. If selected they will still be send as a zip archive to the destination root folder. <strong>There is currently no restore with this option</strong>', SNAPSHOT_I18N_DOMAIN); ?> </li> </ul> </div> <?php } else { $message = '<p>Additional options are available for the \'Dropbox\' destination.</p><p>Destinations are available to you in Snapshot Pro from WPMU Dev: <a href="%s">Upgrade Now</a></p>'; $message = sprintf(__($message, SNAPSHOT_I18N_DOMAIN), esc_url('https://premium.wpmudev.org/project/snapshot')); echo $message; } ?> </td> <td class="right"> <label for="snapshot-files-ignore"><?php _e('List files here to exclude from this snapshot. This is handy to exclude very large files like videos. Files should be listed one per line. You can also exclude files for all snapshots by using the Global File Exclusions on the Settings panel.', SNAPSHOT_I18N_DOMAIN); ?> </label><br/> <textarea name="snapshot-files-ignore" id="snapshot-files-ignore" cols="20" rows="5"><?php if (isset($item['files-ignore']) && count($item['files-ignore'])) { echo implode("\n", $item['files-ignore']); } ?> </textarea> <p class="description"><?php _e('The exclude logic uses pattern matching. So instead of entering the complete server pathname for a file or directory you can simply use the filename of parent directory. For example to exclude the theme twentyten you could enter this one of many ways: twentyten, themes/twentyten /wp-content/themes/twentyten, /www-data/wp-content/themes/twentyten. <strong>Regular Expression are not allowed at this time</strong>.', SNAPSHOT_I18N_DOMAIN); ?> </p> </td> </tr> </table> </div> </div> <?php }