-
-
Notifications
You must be signed in to change notification settings - Fork 73
Demo product #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Demo product #362
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1372,6 +1372,101 @@ public function default_sections(): void { | |
|
|
||
| do_action('wu_settings_site_templates'); | ||
|
|
||
| /* | ||
| * Demo Sites | ||
| * Settings for demo/sandbox site functionality. | ||
| */ | ||
| $this->add_field( | ||
| 'sites', | ||
| 'demo_sites_heading', | ||
| [ | ||
| 'title' => __('Demo Sites', 'ultimate-multisite'), | ||
| 'desc' => __('Configure demo/sandbox site behavior. Demo sites are temporary sites that automatically expire and get deleted after a set period.', 'ultimate-multisite'), | ||
| 'type' => 'header', | ||
| ] | ||
| ); | ||
|
|
||
| $this->add_field( | ||
| 'sites', | ||
| 'demo_duration', | ||
| [ | ||
| 'title' => __('Demo Duration', 'ultimate-multisite'), | ||
| 'desc' => __('How long demo sites should remain active before being automatically deleted. Set to 0 to disable automatic deletion.', 'ultimate-multisite'), | ||
| 'type' => 'number', | ||
| 'default' => 2, | ||
| 'min' => 0, | ||
| 'html_attr' => [ | ||
| 'style' => 'width: 80px;', | ||
| ], | ||
| ] | ||
| ); | ||
|
|
||
| $this->add_field( | ||
| 'sites', | ||
| 'demo_duration_unit', | ||
| [ | ||
| 'title' => __('Demo Duration Unit', 'ultimate-multisite'), | ||
| 'desc' => __('The time unit for demo duration.', 'ultimate-multisite'), | ||
| 'type' => 'select', | ||
| 'default' => 'hour', | ||
| 'options' => [ | ||
| 'hour' => __('Hours', 'ultimate-multisite'), | ||
| 'day' => __('Days', 'ultimate-multisite'), | ||
| 'week' => __('Weeks', 'ultimate-multisite'), | ||
| ], | ||
| ] | ||
| ); | ||
|
|
||
| $this->add_field( | ||
| 'sites', | ||
| 'demo_delete_customer', | ||
| [ | ||
| 'title' => __('Delete Customer After Demo Expires', 'ultimate-multisite'), | ||
| 'desc' => __('When enabled, the customer account will also be deleted when their demo site expires (only if they have no other memberships).', 'ultimate-multisite'), | ||
| 'type' => 'toggle', | ||
| 'default' => 0, | ||
| ] | ||
| ); | ||
|
|
||
| $this->add_field( | ||
| 'sites', | ||
| 'demo_expiring_notification', | ||
| [ | ||
| 'title' => __('Send Expiration Warning Email', 'ultimate-multisite'), | ||
| 'desc' => __('When enabled, customers will receive an email notification before their demo site expires.', 'ultimate-multisite'), | ||
| 'type' => 'toggle', | ||
| 'default' => 1, | ||
| ] | ||
| ); | ||
|
|
||
| $this->add_field( | ||
| 'sites', | ||
| 'demo_expiring_warning_time', | ||
| [ | ||
| 'title' => __('Warning Time Before Expiration', 'ultimate-multisite'), | ||
| 'desc' => __('How long before the demo expires should the warning email be sent. Uses the same time unit as demo duration.', 'ultimate-multisite'), | ||
| 'type' => 'number', | ||
| 'default' => 1, | ||
| 'min' => 1, | ||
| 'html_attr' => [ | ||
| 'style' => 'width: 80px;', | ||
| ], | ||
| ] | ||
| ); | ||
|
Comment on lines
+1431
to
+1455
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align the warning settings with the runtime contract.
🤖 Prompt for AI Agents |
||
|
|
||
| $this->add_field( | ||
| 'sites', | ||
| 'demo_go_live_url', | ||
| [ | ||
| 'title' => __('Go Live URL', 'ultimate-multisite'), | ||
| 'desc' => __('The URL customers are sent to when they click "Go Live" on a keep-until-live demo site. Typically this is your checkout form page URL. Leave empty to use the built-in instant activation (no payment collected).', 'ultimate-multisite'), | ||
| 'type' => 'url', | ||
| 'default' => '', | ||
| ] | ||
| ); | ||
|
|
||
| do_action('wu_settings_demo_sites'); | ||
|
|
||
| /* | ||
| * Payment Gateways | ||
| * This section holds the Payment Gateways settings of the Ultimate Multisite Plugin. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,11 +189,14 @@ function wu_is_plan_type(string $type): bool { | |
| * This filter allows addons to register additional product types | ||
| * that should be recognized as plans in validation and segregation. | ||
| * | ||
| * Demo products are included by default as they function like plans | ||
| * but create sites with automatic expiration. | ||
| * | ||
| * @since 2.3.0 | ||
| * @param array $plan_types Array of product types to treat as plans. | ||
| * @return array | ||
| */ | ||
| $plan_types = apply_filters('wu_plan_product_types', ['plan']); | ||
| $plan_types = apply_filters('wu_plan_product_types', ['plan', 'demo']); | ||
|
Comment on lines
+192
to
+199
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep plan-like helpers consistent with
🤖 Prompt for AI Agents |
||
|
|
||
| return in_array($type, $plan_types, true); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -533,6 +533,32 @@ public function register_all_default_system_emails(): void { | |
| ] | ||
| ); | ||
|
|
||
| /* | ||
| * Demo Site Expiring - Customer | ||
| */ | ||
| $this->register_default_system_email( | ||
| [ | ||
| 'event' => 'demo_site_expiring', | ||
| 'slug' => 'demo_site_expiring_customer', | ||
| 'target' => 'customer', | ||
| 'title' => __('Your demo site is about to expire', 'ultimate-multisite'), | ||
| 'content' => wu_get_template_contents('emails/customer/demo-site-expiring'), | ||
| ] | ||
| ); | ||
|
|
||
| /* | ||
| * Demo Site Expiring - Admin | ||
| */ | ||
| $this->register_default_system_email( | ||
| [ | ||
| 'event' => 'demo_site_expiring', | ||
| 'slug' => 'demo_site_expiring_admin', | ||
| 'target' => 'admin', | ||
| 'title' => __('A demo site is about to expire', 'ultimate-multisite'), | ||
| 'content' => wu_get_template_contents('emails/admin/demo-site-expiring'), | ||
| ] | ||
| ); | ||
|
Comment on lines
+536
to
+560
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C3 "demo_site_expiring_(customer|admin)|create_all_system_emails|create_system_email\(|register_all_default_system_emails|wu_get_default_system_emails" .Repository: Ultimate-Multisite/ultimate-multisite Length of output: 13555 🏁 Script executed: #!/bin/bash
# Search for where migrator is called and upgrade hooks
rg -n "create_all_system_emails|_install_create_emails|activation|upgrade|migrat" inc/installers/ inc/managers/ --type php | grep -E "(do_action|apply_filters|add_action|register|hook|activate|upgrade)" | head -40Repository: Ultimate-Multisite/ultimate-multisite Length of output: 1659 🏁 Script executed: #!/bin/bash
# Look for activation and upgrade hooks
rg -n "register_activation_hook|wp_version|upgrade_needed|plugins_loaded|admin_init" inc/ --type php | head -30Repository: Ultimate-Multisite/ultimate-multisite Length of output: 3055 🏁 Script executed: #!/bin/bash
# Check class-default-content-installer.php for where _install_create_emails is defined and called
grep -n "_install_create_emails\|public function\|add_action\|do_action" inc/installers/class-default-content-installer.php | head -30Repository: Ultimate-Multisite/ultimate-multisite Length of output: 435 🏁 Script executed: #!/bin/bash
# Look for Default_Content_Installer usage
rg -n "Default_Content_Installer|new Default_Content_Installer|->get_instance\(\)" inc/ --type php | head -20Repository: Ultimate-Multisite/ultimate-multisite Length of output: 1052 🏁 Script executed: #!/bin/bash
# Check the main plugin file for activation/upgrade hooks
git ls-files | grep -E "(ultimate-multisite\.php|wp-ultimo\.php|main\.php)" | head -5Repository: Ultimate-Multisite/ultimate-multisite Length of output: 247 🏁 Script executed: #!/bin/bash
# Search for version checks and upgrade logic in main plugin files
rg -n "register_activation_hook|register_deactivation_hook|wp_version|get_option.*version" . --type php --max-count=30Repository: Ultimate-Multisite/ultimate-multisite Length of output: 2290 🏁 Script executed: #!/bin/bash
# Check what on_activation does in class-hooks.php
sed -n '38,150p' inc/class-hooks.phpRepository: Ultimate-Multisite/ultimate-multisite Length of output: 2625 🏁 Script executed: #!/bin/bash
# Search for any automatic email creation or upgrade checks
rg -n "on_activation|_run_migration|create_all_system_emails" inc/class-hooks.php -A 20Repository: Ultimate-Multisite/ultimate-multisite Length of output: 1662 🏁 Script executed: #!/bin/bash
# Search for handlers of wu_activation hook
rg -n "add_action.*wu_activation|do_action.*wu_activation" inc/ --type php -A 5 -B 2Repository: Ultimate-Multisite/ultimate-multisite Length of output: 406 🏁 Script executed: #!/bin/bash
# Search for Migrator instantiation and triggering
rg -n "Migrator|_run_migration|migration" inc/class-wp-ultimo.php -A 3 -B 2 | head -50Repository: Ultimate-Multisite/ultimate-multisite Length of output: 63 🏁 Script executed: #!/bin/bash
# Search for Migrator class instantiation and method calls
rg -n "new Migrator|Migrator::get_instance|->run\(\)|->execute\(\)|_run_migration" . --type php | head -40Repository: Ultimate-Multisite/ultimate-multisite Length of output: 891 🏁 Script executed: #!/bin/bash
# Check if there's any automatic email seeding for upgrades
rg -n "version_compare|old_version|new_version|update_network_option.*version" inc/managers/class-email-manager.php inc/installers/ --type php | head -20Repository: Ultimate-Multisite/ultimate-multisite Length of output: 63 🏁 Script executed: #!/bin/bash
# Look for any upgrade/delta installation logic in core installer
cat inc/installers/class-core-installer.php | head -100Repository: Ultimate-Multisite/ultimate-multisite Length of output: 3222 🏁 Script executed: #!/bin/bash
# Look for email reset/import/sync functionality
rg -n "reset.*email|import.*email|sync.*email|reseed|backfill" inc/admin-pages/class-email-list-admin-page.php -B 2 -A 5Repository: Ultimate-Multisite/ultimate-multisite Length of output: 3577 🏁 Script executed: #!/bin/bash
# Check the email reset/import modal to see if it backfills missing emails
sed -n '346,370p' inc/admin-pages/class-email-list-admin-page.phpRepository: Ultimate-Multisite/ultimate-multisite Length of output: 800 🏁 Script executed: #!/bin/bash
# Search for AJAX handlers for email import/reset
rg -n "handle_reset|handle_import|import_emails|reset_emails" inc/admin-pages/class-email-list-admin-page.php -A 10Repository: Ultimate-Multisite/ultimate-multisite Length of output: 4053 Ensure new system emails auto-seed on upgraded installations, or document the manual import step. New
Without intervention, the 🤖 Prompt for AI Agents |
||
|
|
||
| do_action('wu_system_emails_after_register'); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0currently means “expire immediately”, not “disable”.This field advertises
0as “disable automatic deletion”, butSite::calculate_demo_expiration()multiplies the configured duration and returnsnow + 0, so new demo sites become immediately eligible for cleanup. Either handle0as “no expiration” downstream or remove0from the allowed UI here.🤖 Prompt for AI Agents