PluginProbe
Trinity Backup – Backup, Migrate, Restore, Clone & Schedule Backups / 2.0.10
Trinity Backup – Backup, Migrate, Restore, Clone & Schedule Backups v2.0.10
trunk 2.0.10 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
trinity-backup / trinity-backup.php

trinity-backup.php in Trinity Backup – Backup, Migrate, Restore, Clone & Schedule Backups 2.0.10, at trinity-backup.php

160 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Trinity Backup - Backup, Migrate, Restore, Clone & Schedule Backups
4 * Description: Lightweight backup and migration plugin with chunked processing, streaming archives, and optional AES-256 encryption. Create full site backups, migrate between servers, and restore with ease.
5 * Version: 2.0.10
6 * Author: KingAddons.com
7 * Author URI: https://trinity.kingaddons.com
8 * License: GPLv2 or later
9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
10 * Text Domain: trinity-backup
11 * Requires at least: 6.2
12 * Requires PHP: 8.0
13 */
14
15 declare(strict_types=1);
16
17 if (!defined('ABSPATH')) {
18 exit;
19 }
20
21 if ( ! function_exists( 'trinity_backup_fs' ) ) {
22 // Create a helper function for easy SDK access.
23 function trinity_backup_fs() {
24 global $trinity_backup_fs;
25
26 if ( ! isset( $trinity_backup_fs ) ) {
27 // Include Freemius SDK.
28 require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
29
30 $trinity_backup_fs = fs_dynamic_init( array(
31 'id' => '23373',
32 'slug' => 'trinity-backup',
33 'premium_slug' => 'trinity-backup-pro',
34 'type' => 'plugin',
35 'public_key' => 'pk_19dba60089a3238fd47574daff4c6',
36 'is_premium' => false,
37 'premium_suffix' => 'pro',
38 'has_premium_version' => true,
39 'has_addons' => false,
40 'has_paid_plans' => true,
41 'has_affiliation' => 'selected',
42 'menu' => array(
43 'slug' => 'trinity-backup',
44 'contact' => true,
45 'support' => false,
46 'pricing' => false,
47 'affiliation' => false,
48 ),
49 'is_live' => true,
50 ) );
51 }
52
53 return $trinity_backup_fs;
54 }
55
56 // Init Freemius.
57 trinity_backup_fs();
58 // Signal that SDK was initiated.
59 do_action( 'trinity_backup_fs_loaded' );
60 trinity_backup_fs()->add_filter( 'show_deactivation_subscription_cancellation', '__return_false' );
61 trinity_backup_fs()->add_filter( 'deactivate_on_activation', '__return_false' );
62 }
63
64 /**
65 * Check if the user can use Pro features.
66 *
67 * @return bool
68 */
69 if ( ! function_exists( 'trinity_backup_can_use_pro' ) ) {
70 function trinity_backup_can_use_pro(): bool {
71 if ( ! function_exists( 'trinity_backup_fs' ) ) {
72 return false;
73 }
74
75 $fs = trinity_backup_fs();
76 if ( ! is_object( $fs ) || ! method_exists( $fs, 'can_use_premium_code__premium_only' ) ) {
77 return false;
78 }
79
80 return (bool) $fs->can_use_premium_code__premium_only();
81 }
82 }
83
84 /**
85 * Check if the current license corresponds to the "Unlimited websites" offering.
86 *
87 * Important: In Freemius, the plan slug/name and the pricing option are different concepts.
88 * Your pricing option ID for Unlimited is 51880.
89 *
90 * @return bool
91 */
92 if ( ! function_exists( 'trinity_backup_is_unlimited_pricing' ) ) {
93 function trinity_backup_is_unlimited_pricing(): bool {
94 if ( ! trinity_backup_can_use_pro() ) {
95 return false;
96 }
97
98 $fs = trinity_backup_fs();
99 if ( ! is_object( $fs ) ) {
100 return false;
101 }
102
103 // 1) Prefer checking the active license pricing_id (most reliable for differentiating tiers).
104 if ( method_exists( $fs, '_get_license' ) ) {
105 $license = $fs->_get_license();
106 if ( is_object( $license ) && isset( $license->pricing_id ) ) {
107 $isUnlimited = ( (int) $license->pricing_id === 51880 );
108 /**
109 * Allow overriding unlimited detection if needed.
110 *
111 * @param bool $isUnlimited
112 * @param object $license
113 */
114 return (bool) apply_filters( 'trinity_backup_is_unlimited_pricing', $isUnlimited, $license );
115 }
116 }
117
118 return false;
119 }
120 }
121
122 /**
123 * Check if a specific Pro feature is available by plan.
124 *
125 * Plan 1 ($4.99/yr 5 sites): scheduled, pre_update, encryption, email
126 * Plan 2 ($29/yr unlimited): All Plan 1 + wp_cli, white_label
127 * Plan 3 ($59 lifetime): Same as Plan 2
128 *
129 * @param string $feature Feature slug.
130 * @return bool
131 */
132 if ( ! function_exists( 'trinity_backup_has_feature' ) ) {
133 function trinity_backup_has_feature( string $feature ): bool {
134 if ( ! trinity_backup_can_use_pro() ) {
135 return false;
136 }
137
138 // Plan 1 features — available on any paid plan
139 $plan1 = [ 'scheduled', 'pre_update', 'encryption', 'email' ];
140 if ( in_array( $feature, $plan1, true ) ) {
141 return true;
142 }
143
144 // Plan 2 / Plan 3 features — require Unlimited websites pricing (or equivalent plan)
145 $plan2 = [ 'wp_cli', 'white_label' ];
146 if ( in_array( $feature, $plan2, true ) ) {
147 return trinity_backup_is_unlimited_pricing();
148 }
149
150 return false;
151 }
152 }
153
154 require_once __DIR__ . '/src/Core/Autoloader.php';
155 \TrinityBackup\Core\Autoloader::register();
156
157 register_activation_hook(__FILE__, [\TrinityBackup\Core\StorageSecurity::class, 'install']);
158
159 \TrinityBackup\Core\Plugin::init();
160