BackWPup. * Version: 2.0.0 * Author: Armando Lüscher * Author URI: https://noplanman.ch * Text Domain: advanced-backwpup-s3-destinations * Network: true * Requires at least: 6.0 * Requires PHP: 8.0 * License: GPLv2 or later * License URI: https://www.gnu.org/licenses/gpl-2.0.html */ /** * Copyright 2023 Armando Lüscher (email: armando@noplanman.ch) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ namespace NPM\AdvancedBackWPupS3Destinations; // Exit if accessed directly. defined( 'ABSPATH' ) || exit; /** * Make sure BackWPup is installed and activated. */ add_action( 'admin_init', static function () { if ( current_user_can( 'activate_plugins' ) && ! is_plugin_active( 'backwpup/backwpup.php' ) && ! is_plugin_active( 'backwpup-pro/backwpup.php' ) ) { deactivate_plugins( plugin_basename( __FILE__ ) ); add_action( 'admin_notices', 'NPM\AdvancedBackWPupS3Destinations\admin_notice_missing_plugin' ); add_action( 'network_admin_notices', 'NPM\AdvancedBackWPupS3Destinations\admin_notice_missing_plugin' ); } } ); /** * Admin notice to alert about missing BackWPup plugin. */ function admin_notice_missing_plugin(): void { ?>

' . __( 'Settings', 'advanced-backwpup-s3-destinations' ) . ''; return $links; } ); /** * Add a new tab to the "BackWPup -> Settings" page. */ add_filter( 'backwpup_page_settings_tab', static function ( array $tabs ): array { $tabs['s3-destinations'] = esc_html__( 'S3 Destinations', 'advanced-backwpup-s3-destinations' ); return $tabs; } ); /** * Output the form on the settings page. */ add_action( 'backwpup_page_settings_tab_content', static function (): void { // Fetch saved destinations. $s3_destinations = get_s3_destinations(); // Always set an extra one to allow expansion. $s3_destinations['new-s3-destination'] = $default = [ 'label' => __( 'New S3 destination', 'advanced-backwpup-s3-destinations' ), 'endpoint' => '', 'region' => '', 'multipart' => false, 'only_path_style_bucket' => false, 'version' => '', 'signature' => '', ]; ?>

$s3_destination ): $name = "s3_destinations[{$id}]"; // Fill in defaults for missing fields. $s3_destination += $default; ?>