Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ public function register_scripts(): void {
* @return void
*/
public function page_loaded(): void {
/*
* Enforce the "Allow Template Switching" setting on the page itself,
* not only where the Site Actions link is rendered.
*/
if ( ! wu_get_setting('allow_template_switching', true)) {
wp_die(
esc_html__('Template switching is disabled.', 'ultimate-multisite'),
'',
[
'response' => 403,
'back_link' => true,
]
);
}

do_action('wu_template_switching_admin_page', null);

Expand Down
11 changes: 11 additions & 0 deletions inc/ui/class-template-switching-element.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,17 @@ public function switch_template() {
return;
}

/*
* The "Allow Template Switching" setting must be enforced here, not only
* where the Site Actions link is rendered. Otherwise a customer who
* calls the handler directly can overwrite their site while switching
* is disabled network-wide.
*/
if ( ! wu_get_setting('allow_template_switching', true)) {
wp_send_json_error(new \WP_Error('template_switching_disabled', __('Template switching is disabled.', 'ultimate-multisite')));
return;
}

$template_id = (int) wu_request('template_id', '');

// false means MODE_DEFAULT (no restriction) — all templates are allowed.
Expand Down
Loading