wp/wp-admin/network/themes.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Multisite themes administration panel.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Multisite
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
/** Load WordPress Administration Bootstrap */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
require_once( dirname( __FILE__ ) . '/admin.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
if ( ! is_multisite() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	wp_die( __( 'Multisite support is not enabled.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
if ( !current_user_can('manage_network_themes') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
	wp_die( __( 'You do not have sufficient permissions to manage network themes.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
$pagenum = $wp_list_table->get_pagenum();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
$action = $wp_list_table->current_action();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
$temp_args = array( 'enabled', 'disabled', 'deleted', 'error' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
$referer = remove_query_arg( $temp_args, wp_get_referer() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
if ( $action ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	$allowed_themes = get_site_option( 'allowedthemes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
	switch ( $action ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
		case 'enable':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
			check_admin_referer('enable-theme_' . $_GET['theme']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
			$allowed_themes[ $_GET['theme'] ] = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
			update_site_option( 'allowedthemes', $allowed_themes );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
			if ( false === strpos( $referer, '/network/themes.php' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
				wp_redirect( network_admin_url( 'themes.php?enabled=1' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
				wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
			exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
		case 'disable':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
			check_admin_referer('disable-theme_' . $_GET['theme']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
			unset( $allowed_themes[ $_GET['theme'] ] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
			update_site_option( 'allowedthemes', $allowed_themes );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
			wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
			exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
		case 'enable-selected':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
			check_admin_referer('bulk-themes');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
			$themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
			if ( empty($themes) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
				wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
				exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
			foreach( (array) $themes as $theme )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
				$allowed_themes[ $theme ] = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
			update_site_option( 'allowedthemes', $allowed_themes );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
			wp_safe_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
			exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
		case 'disable-selected':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
			check_admin_referer('bulk-themes');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
			$themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
			if ( empty($themes) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
				wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
				exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
			foreach( (array) $themes as $theme )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
				unset( $allowed_themes[ $theme ] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
			update_site_option( 'allowedthemes', $allowed_themes );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
			wp_safe_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
			exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
		case 'update-selected' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
			check_admin_referer( 'bulk-themes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
			if ( isset( $_GET['themes'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
				$themes = explode( ',', $_GET['themes'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
			elseif ( isset( $_POST['checked'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
				$themes = (array) $_POST['checked'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
				$themes = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
			$title = __( 'Update Themes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
			$parent_file = 'themes.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
			require_once(ABSPATH . 'wp-admin/admin-header.php');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
			echo '<div class="wrap">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
			echo '<h2>' . esc_html( $title ) . '</h2>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
			$url = self_admin_url('update.php?action=update-selected-themes&amp;themes=' . urlencode( join(',', $themes) ));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
			$url = wp_nonce_url($url, 'bulk-update-themes');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
			echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
			echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
			require_once(ABSPATH . 'wp-admin/admin-footer.php');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
			exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
		case 'delete-selected':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    99
			if ( ! current_user_can( 'delete_themes' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
				wp_die( __('You do not have sufficient permissions to delete themes for this site.') );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   101
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   102
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
			check_admin_referer( 'bulk-themes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
			$themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
			if ( empty( $themes ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
				wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
				exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   112
			$themes = array_diff( $themes, array( get_option( 'stylesheet' ), get_option( 'template' ) ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
			if ( empty( $themes ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
				wp_safe_redirect( add_query_arg( 'error', 'main', $referer ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
				exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   119
			$files_to_delete = $theme_info = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   120
			$theme_translations = wp_get_installed_translations( 'themes' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   121
			foreach ( $themes as $key => $theme ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   122
				$theme_info[ $theme ] = wp_get_theme( $theme );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   123
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   124
				// Locate all the files in that folder.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   125
				$files = list_files( $theme_info[ $theme ]->get_stylesheet_directory() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   126
				if ( $files ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   127
					$files_to_delete = array_merge( $files_to_delete, $files );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   128
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   129
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   130
				// Add translation files.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   131
				$theme_slug = $theme_info[ $theme ]->get_stylesheet();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   132
				if ( ! empty( $theme_translations[ $theme_slug ] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   133
					$translations = $theme_translations[ $theme_slug ];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   134
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   135
					foreach ( $translations as $translation => $data ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   136
						$files_to_delete[] = $theme_slug . '-' . $translation . '.po';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   137
						$files_to_delete[] = $theme_slug . '-' . $translation . '.mo';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   138
					}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   139
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   140
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   141
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
			include(ABSPATH . 'wp-admin/update.php');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
			$parent_file = 'themes.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
			if ( ! isset( $_REQUEST['verify-delete'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
				wp_enqueue_script( 'jquery' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
				require_once( ABSPATH . 'wp-admin/admin-header.php' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   149
				$themes_to_delete = count( $themes );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
				?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
			<div class="wrap">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   152
				<?php if ( 1 == $themes_to_delete ) : ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   153
					<h2><?php _e( 'Delete Theme' ); ?></h2>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   154
					<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This theme may be active on other sites in the network.' ); ?></p></div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   155
					<p><?php _e( 'You are about to remove the following theme:' ); ?></p>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   156
				<?php else : ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   157
					<h2><?php _e( 'Delete Themes' ); ?></h2>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   158
					<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These themes may be active on other sites in the network.' ); ?></p></div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   159
					<p><?php _e( 'You are about to remove the following themes:' ); ?></p>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   160
				<?php endif; ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
					<ul class="ul-disc">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   162
					<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   163
						foreach ( $theme_info as $theme ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   164
							/* translators: 1: theme name, 2: theme author */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   165
							echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), $theme->display('Name'), $theme->display('Author') ), '</li>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   166
						}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   167
					?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
					</ul>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   169
				<?php if ( 1 == $themes_to_delete ) : ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   170
					<p><?php _e( 'Are you sure you wish to delete this theme?' ); ?></p>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   171
				<?php else : ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   172
					<p><?php _e( 'Are you sure you wish to delete these themes?' ); ?></p>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   173
				<?php endif; ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
				<form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
					<input type="hidden" name="verify-delete" value="1" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
					<input type="hidden" name="action" value="delete-selected" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
					<?php
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   178
						foreach ( (array) $themes as $theme ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
							echo '<input type="hidden" name="checked[]" value="' . esc_attr($theme) . '" />';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   180
						}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   181
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   182
						wp_nonce_field( 'bulk-themes' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   183
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   184
						if ( 1 == $themes_to_delete ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   185
							submit_button( __( 'Yes, Delete this theme' ), 'button', 'submit', false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   186
						} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   187
							submit_button( __( 'Yes, Delete these themes' ), 'button', 'submit', false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   188
						}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
					?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
				</form>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   191
				<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   192
				$referer = wp_get_referer();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   193
				?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   194
				<form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
					<?php submit_button( __( 'No, Return me to the theme list' ), 'button', 'submit', false ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
				</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
				<p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
				<div id="files-list" style="display:none;">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
					<ul class="code">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
					<?php
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   202
						foreach ( (array) $files_to_delete as $file ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   203
							echo '<li>' . esc_html( str_replace( WP_CONTENT_DIR . '/themes', '', $file ) ) . '</li>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   204
						}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
					?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
					</ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
				</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
			</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
				<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
				require_once(ABSPATH . 'wp-admin/admin-footer.php');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
				exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
			} // Endif verify-delete
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
			foreach ( $themes as $theme ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
				$delete_result = delete_theme( $theme, esc_url( add_query_arg( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
					'verify-delete' => 1,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
					'action' => 'delete-selected',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
					'checked' => $_REQUEST['checked'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
					'_wpnonce' => $_REQUEST['_wpnonce']
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
				), network_admin_url( 'themes.php' ) ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
			}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   222
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
			$paged = ( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
			wp_redirect( add_query_arg( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
				'deleted' => count( $themes ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
				'paged' => $paged,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
				's' => $s
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
			), network_admin_url( 'themes.php' ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
			exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
$wp_list_table->prepare_items();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
add_thickbox();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   237
add_screen_option( 'per_page' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
get_current_screen()->add_help_tab( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
	'id'      => 'overview',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
	'title'   => __('Overview'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
	'content' =>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
		'<p>' . __('This screen enables and disables the inclusion of themes available to choose in the Appearance menu for each site. It does not activate or deactivate which theme a site is currently using.') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
		'<p>' . __('If the network admin disables a theme that is in use, it can still remain selected on that site. If another theme is chosen, the disabled theme will not appear in the site&#8217;s Appearance > Themes screen.') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
		'<p>' . __('Themes can be enabled on a site by site basis by the network admin on the Edit Site screen (which has a Themes tab); get there via the Edit action link on the All Sites screen. Only network admins are able to install or edit themes.') . '</p>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
get_current_screen()->set_help_sidebar(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
	'<p><strong>' . __('For more information:') . '</strong></p>' .
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   250
	'<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen" target="_blank">Documentation on Network Themes</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   251
	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
$title = __('Themes');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
$parent_file = 'themes.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   257
wp_enqueue_script( 'theme-preview' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
require_once(ABSPATH . 'wp-admin/admin-header.php');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
<div class="wrap">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
<h2><?php echo esc_html( $title ); if ( current_user_can('install_themes') ) { ?> <a href="theme-install.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
if ( $s )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
</h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
if ( isset( $_GET['enabled'] ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   271
	$enabled = absint( $_GET['enabled'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   272
	if ( 1 == $enabled ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   273
		$message = __( 'Theme enabled.' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   274
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   275
		$message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   276
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   277
	echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
} elseif ( isset( $_GET['disabled'] ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   279
	$disabled = absint( $_GET['disabled'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   280
	if ( 1 == $disabled ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   281
		$message = __( 'Theme disabled.' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   282
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   283
		$message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   284
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   285
	echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
} elseif ( isset( $_GET['deleted'] ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   287
	$deleted = absint( $_GET['deleted'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   288
	if ( 1 == $deleted ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   289
		$message = __( 'Theme deleted.' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   290
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   291
		$message = _n( '%s theme deleted.', '%s themes deleted.', $deleted );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   292
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   293
	echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   295
	echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
} elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   297
	echo '<div class="error notice is-dismissible"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   302
<form method="get">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
$wp_list_table->views();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
if ( 'broken' == $status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
	echo '<p class="clear">' . __('The following themes are installed but incomplete. Themes must have a stylesheet and a template.') . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   313
<form method="post">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
<input type="hidden" name="theme_status" value="<?php echo esc_attr($status) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
<input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
<?php $wp_list_table->display(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
include(ABSPATH . 'wp-admin/admin-footer.php');