Edit File by line
/home/barbar84/public_h.../wp-admin/network
File: site-themes.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Edit Site Themes Administration Screen
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Multisite
[5] Fix | Delete
* @since 3.1.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/** Load WordPress Administration Bootstrap */
[9] Fix | Delete
require_once __DIR__ . '/admin.php';
[10] Fix | Delete
[11] Fix | Delete
if ( ! current_user_can( 'manage_sites' ) ) {
[12] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to manage themes for this site.' ) );
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
[16] Fix | Delete
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
[17] Fix | Delete
[18] Fix | Delete
get_current_screen()->set_screen_reader_content(
[19] Fix | Delete
array(
[20] Fix | Delete
'heading_views' => __( 'Filter site themes list' ),
[21] Fix | Delete
'heading_pagination' => __( 'Site themes list navigation' ),
[22] Fix | Delete
'heading_list' => __( 'Site themes list' ),
[23] Fix | Delete
)
[24] Fix | Delete
);
[25] Fix | Delete
[26] Fix | Delete
$wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
[27] Fix | Delete
[28] Fix | Delete
$action = $wp_list_table->current_action();
[29] Fix | Delete
[30] Fix | Delete
$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
[31] Fix | Delete
[32] Fix | Delete
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
[33] Fix | Delete
$temp_args = array( 'enabled', 'disabled', 'error' );
[34] Fix | Delete
$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
[35] Fix | Delete
$referer = remove_query_arg( $temp_args, wp_get_referer() );
[36] Fix | Delete
[37] Fix | Delete
if ( ! empty( $_REQUEST['paged'] ) ) {
[38] Fix | Delete
$referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
$id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
[42] Fix | Delete
[43] Fix | Delete
if ( ! $id ) {
[44] Fix | Delete
wp_die( __( 'Invalid site ID.' ) );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
$wp_list_table->prepare_items();
[48] Fix | Delete
[49] Fix | Delete
$details = get_site( $id );
[50] Fix | Delete
if ( ! $details ) {
[51] Fix | Delete
wp_die( __( 'The requested site does not exist.' ) );
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
if ( ! can_edit_network( $details->site_id ) ) {
[55] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
$is_main_site = is_main_site( $id );
[59] Fix | Delete
[60] Fix | Delete
if ( $action ) {
[61] Fix | Delete
switch_to_blog( $id );
[62] Fix | Delete
$allowed_themes = get_option( 'allowedthemes' );
[63] Fix | Delete
[64] Fix | Delete
switch ( $action ) {
[65] Fix | Delete
case 'enable':
[66] Fix | Delete
check_admin_referer( 'enable-theme_' . $_GET['theme'] );
[67] Fix | Delete
$theme = $_GET['theme'];
[68] Fix | Delete
$action = 'enabled';
[69] Fix | Delete
$n = 1;
[70] Fix | Delete
if ( ! $allowed_themes ) {
[71] Fix | Delete
$allowed_themes = array( $theme => true );
[72] Fix | Delete
} else {
[73] Fix | Delete
$allowed_themes[ $theme ] = true;
[74] Fix | Delete
}
[75] Fix | Delete
break;
[76] Fix | Delete
case 'disable':
[77] Fix | Delete
check_admin_referer( 'disable-theme_' . $_GET['theme'] );
[78] Fix | Delete
$theme = $_GET['theme'];
[79] Fix | Delete
$action = 'disabled';
[80] Fix | Delete
$n = 1;
[81] Fix | Delete
if ( ! $allowed_themes ) {
[82] Fix | Delete
$allowed_themes = array();
[83] Fix | Delete
} else {
[84] Fix | Delete
unset( $allowed_themes[ $theme ] );
[85] Fix | Delete
}
[86] Fix | Delete
break;
[87] Fix | Delete
case 'enable-selected':
[88] Fix | Delete
check_admin_referer( 'bulk-themes' );
[89] Fix | Delete
if ( isset( $_POST['checked'] ) ) {
[90] Fix | Delete
$themes = (array) $_POST['checked'];
[91] Fix | Delete
$action = 'enabled';
[92] Fix | Delete
$n = count( $themes );
[93] Fix | Delete
foreach ( (array) $themes as $theme ) {
[94] Fix | Delete
$allowed_themes[ $theme ] = true;
[95] Fix | Delete
}
[96] Fix | Delete
} else {
[97] Fix | Delete
$action = 'error';
[98] Fix | Delete
$n = 'none';
[99] Fix | Delete
}
[100] Fix | Delete
break;
[101] Fix | Delete
case 'disable-selected':
[102] Fix | Delete
check_admin_referer( 'bulk-themes' );
[103] Fix | Delete
if ( isset( $_POST['checked'] ) ) {
[104] Fix | Delete
$themes = (array) $_POST['checked'];
[105] Fix | Delete
$action = 'disabled';
[106] Fix | Delete
$n = count( $themes );
[107] Fix | Delete
foreach ( (array) $themes as $theme ) {
[108] Fix | Delete
unset( $allowed_themes[ $theme ] );
[109] Fix | Delete
}
[110] Fix | Delete
} else {
[111] Fix | Delete
$action = 'error';
[112] Fix | Delete
$n = 'none';
[113] Fix | Delete
}
[114] Fix | Delete
break;
[115] Fix | Delete
default:
[116] Fix | Delete
if ( isset( $_POST['checked'] ) ) {
[117] Fix | Delete
check_admin_referer( 'bulk-themes' );
[118] Fix | Delete
$themes = (array) $_POST['checked'];
[119] Fix | Delete
$n = count( $themes );
[120] Fix | Delete
$screen = get_current_screen()->id;
[121] Fix | Delete
[122] Fix | Delete
/**
[123] Fix | Delete
* Fires when a custom bulk action should be handled.
[124] Fix | Delete
*
[125] Fix | Delete
* The redirect link should be modified with success or failure feedback
[126] Fix | Delete
* from the action to be used to display feedback to the user.
[127] Fix | Delete
*
[128] Fix | Delete
* The dynamic portion of the hook name, `$screen`, refers to the current screen ID.
[129] Fix | Delete
*
[130] Fix | Delete
* @since 4.7.0
[131] Fix | Delete
*
[132] Fix | Delete
* @param string $redirect_url The redirect URL.
[133] Fix | Delete
* @param string $action The action being taken.
[134] Fix | Delete
* @param array $items The items to take the action on.
[135] Fix | Delete
* @param int $site_id The site ID.
[136] Fix | Delete
*/
[137] Fix | Delete
$referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer, $action, $themes, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
[138] Fix | Delete
} else {
[139] Fix | Delete
$action = 'error';
[140] Fix | Delete
$n = 'none';
[141] Fix | Delete
}
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
update_option( 'allowedthemes', $allowed_themes );
[145] Fix | Delete
restore_current_blog();
[146] Fix | Delete
[147] Fix | Delete
wp_safe_redirect(
[148] Fix | Delete
add_query_arg(
[149] Fix | Delete
array(
[150] Fix | Delete
'id' => $id,
[151] Fix | Delete
$action => $n,
[152] Fix | Delete
),
[153] Fix | Delete
$referer
[154] Fix | Delete
)
[155] Fix | Delete
);
[156] Fix | Delete
exit;
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
if ( isset( $_GET['action'] ) && 'update-site' === $_GET['action'] ) {
[160] Fix | Delete
wp_safe_redirect( $referer );
[161] Fix | Delete
exit;
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
add_thickbox();
[165] Fix | Delete
add_screen_option( 'per_page' );
[166] Fix | Delete
[167] Fix | Delete
/* translators: %s: Site title. */
[168] Fix | Delete
$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
[169] Fix | Delete
[170] Fix | Delete
$parent_file = 'sites.php';
[171] Fix | Delete
$submenu_file = 'sites.php';
[172] Fix | Delete
[173] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php'; ?>
[174] Fix | Delete
[175] Fix | Delete
<div class="wrap">
[176] Fix | Delete
<h1 id="edit-site"><?php echo $title; ?></h1>
[177] Fix | Delete
<p class="edit-site-actions"><a href="<?php echo esc_url( get_home_url( $id, '/' ) ); ?>"><?php _e( 'Visit' ); ?></a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p>
[178] Fix | Delete
<?php
[179] Fix | Delete
[180] Fix | Delete
network_edit_site_nav(
[181] Fix | Delete
array(
[182] Fix | Delete
'blog_id' => $id,
[183] Fix | Delete
'selected' => 'site-themes',
[184] Fix | Delete
)
[185] Fix | Delete
);
[186] Fix | Delete
[187] Fix | Delete
if ( isset( $_GET['enabled'] ) ) {
[188] Fix | Delete
$enabled = absint( $_GET['enabled'] );
[189] Fix | Delete
if ( 1 === $enabled ) {
[190] Fix | Delete
$message = __( 'Theme enabled.' );
[191] Fix | Delete
} else {
[192] Fix | Delete
/* translators: %s: Number of themes. */
[193] Fix | Delete
$message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
[194] Fix | Delete
}
[195] Fix | Delete
echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
[196] Fix | Delete
} elseif ( isset( $_GET['disabled'] ) ) {
[197] Fix | Delete
$disabled = absint( $_GET['disabled'] );
[198] Fix | Delete
if ( 1 === $disabled ) {
[199] Fix | Delete
$message = __( 'Theme disabled.' );
[200] Fix | Delete
} else {
[201] Fix | Delete
/* translators: %s: Number of themes. */
[202] Fix | Delete
$message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
[203] Fix | Delete
}
[204] Fix | Delete
echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
[205] Fix | Delete
} elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) {
[206] Fix | Delete
echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
[207] Fix | Delete
}
[208] Fix | Delete
?>
[209] Fix | Delete
[210] Fix | Delete
<p><?php _e( 'Network enabled themes are not shown on this screen.' ); ?></p>
[211] Fix | Delete
[212] Fix | Delete
<form method="get">
[213] Fix | Delete
<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
[214] Fix | Delete
<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
[215] Fix | Delete
</form>
[216] Fix | Delete
[217] Fix | Delete
<?php $wp_list_table->views(); ?>
[218] Fix | Delete
[219] Fix | Delete
<form method="post" action="site-themes.php?action=update-site">
[220] Fix | Delete
<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
[221] Fix | Delete
[222] Fix | Delete
<?php $wp_list_table->display(); ?>
[223] Fix | Delete
[224] Fix | Delete
</form>
[225] Fix | Delete
[226] Fix | Delete
</div>
[227] Fix | Delete
<?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>
[228] Fix | Delete
[229] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function