<?php
require_once __DIR__ . '/admin.php';
if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
wp_die(
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
'<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>',
403
);
}
if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) {
if ( 'activate' === $_GET['action'] ) {
check_admin_referer( 'switch-theme_' . $_GET['stylesheet'] );
$theme = wp_get_theme( $_GET['stylesheet'] );
if ( ! $theme->exists() || ! $theme->is_allowed() ) {
wp_die(
'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
'<p>' . __( 'The requested theme does not exist.' ) . '</p>',
403
);
}
switch_theme( $theme->get_stylesheet() );
wp_redirect( admin_url( 'themes.php?activated=true' ) );
exit;
} elseif ( 'resume' === $_GET['action'] ) {
check_admin_referer( 'resume-theme_' . $_GET['stylesheet'] );
$theme = wp_get_theme( $_GET['stylesheet'] );
if ( ! current_user_can( 'resume_theme', $_GET['stylesheet'] ) ) {
wp_die(
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
'<p>' . __( 'Sorry, you are not allowed to resume this theme.' ) . '</p>',
403
);