2010-07-30 22:34:54 +02:00
< ? php
/**
* Multisite themes administration panel .
*
* @ package WordPress
* @ subpackage Multisite
2010-10-31 10:37:15 +01:00
* @ since 3.1 . 0
2010-07-30 22:34:54 +02:00
*/
2010-11-10 15:27:15 +01:00
/** Load WordPress Administration Bootstrap */
2020-02-06 07:33:11 +01:00
require_once __DIR__ . '/admin.php' ;
2010-07-30 22:34:54 +02:00
2017-12-01 00:11:00 +01:00
if ( ! current_user_can ( 'manage_network_themes' ) ) {
2016-06-29 17:16:29 +02:00
wp_die ( __ ( 'Sorry, you are not allowed to manage network themes.' ) );
2017-12-01 00:11:00 +01:00
}
2010-12-15 20:24:42 +01:00
2017-12-01 00:11:00 +01:00
$wp_list_table = _get_list_table ( 'WP_MS_Themes_List_Table' );
$pagenum = $wp_list_table -> get_pagenum ();
2010-07-30 22:34:54 +02:00
2010-10-31 10:37:15 +01:00
$action = $wp_list_table -> current_action ();
2017-12-01 00:11:00 +01:00
$s = isset ( $_REQUEST [ 's' ] ) ? $_REQUEST [ 's' ] : '' ;
2010-10-31 10:37:15 +01:00
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
$temp_args = array (
'enabled' ,
'disabled' ,
'deleted' ,
'error' ,
'enabled-auto-update' ,
'disabled-auto-update' ,
);
2010-12-24 18:41:36 +01:00
$_SERVER [ 'REQUEST_URI' ] = remove_query_arg ( $temp_args , $_SERVER [ 'REQUEST_URI' ] );
2017-12-01 00:11:00 +01:00
$referer = remove_query_arg ( $temp_args , wp_get_referer () );
2010-10-31 10:37:15 +01:00
if ( $action ) {
switch ( $action ) {
2010-11-08 22:52:54 +01:00
case 'enable' :
2017-12-01 00:11:00 +01:00
check_admin_referer ( 'enable-theme_' . $_GET [ 'theme' ] );
2016-04-14 05:40:27 +02:00
WP_Theme :: network_enable_theme ( $_GET [ 'theme' ] );
Code Modernization: Replace usage of `strpos()` with `str_contains()`.
`str_contains()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).
WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.
Follow-up to [52039], [52040], [52326], [55703], [55710], [55987].
Props Soean, spacedmonkey, costdev, dingo_d, azaozz, mikeschroder, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes #58206.
Built from https://develop.svn.wordpress.org/trunk@55988
git-svn-id: http://core.svn.wordpress.org/trunk@55500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 16:36:26 +02:00
if ( ! str_contains ( $referer , '/network/themes.php' ) ) {
2012-06-12 17:31:25 +02:00
wp_redirect ( network_admin_url ( 'themes.php?enabled=1' ) );
2017-12-01 00:11:00 +01:00
} else {
2012-06-12 17:31:25 +02:00
wp_safe_redirect ( add_query_arg ( 'enabled' , 1 , $referer ) );
2017-12-01 00:11:00 +01:00
}
2010-12-24 18:41:36 +01:00
exit ;
2010-11-08 22:52:54 +01:00
case 'disable' :
2017-12-01 00:11:00 +01:00
check_admin_referer ( 'disable-theme_' . $_GET [ 'theme' ] );
2016-04-14 05:40:27 +02:00
WP_Theme :: network_disable_theme ( $_GET [ 'theme' ] );
2011-12-10 19:26:48 +01:00
wp_safe_redirect ( add_query_arg ( 'disabled' , '1' , $referer ) );
2010-10-31 10:37:15 +01:00
exit ;
2010-11-08 22:52:54 +01:00
case 'enable-selected' :
2017-12-01 00:11:00 +01:00
check_admin_referer ( 'bulk-themes' );
2010-10-31 10:37:15 +01:00
$themes = isset ( $_POST [ 'checked' ] ) ? ( array ) $_POST [ 'checked' ] : array ();
2017-12-01 00:11:00 +01:00
if ( empty ( $themes ) ) {
2011-12-10 19:26:48 +01:00
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
2010-10-31 10:37:15 +01:00
exit ;
2010-12-24 18:41:36 +01:00
}
2016-04-14 05:40:27 +02:00
WP_Theme :: network_enable_theme ( ( array ) $themes );
2011-12-10 19:26:48 +01:00
wp_safe_redirect ( add_query_arg ( 'enabled' , count ( $themes ), $referer ) );
2010-12-24 18:41:36 +01:00
exit ;
2010-11-08 22:52:54 +01:00
case 'disable-selected' :
2017-12-01 00:11:00 +01:00
check_admin_referer ( 'bulk-themes' );
2010-11-04 21:11:08 +01:00
$themes = isset ( $_POST [ 'checked' ] ) ? ( array ) $_POST [ 'checked' ] : array ();
2017-12-01 00:11:00 +01:00
if ( empty ( $themes ) ) {
2011-12-10 19:26:48 +01:00
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
2010-11-04 21:11:08 +01:00
exit ;
2010-12-24 18:41:36 +01:00
}
2016-04-14 05:40:27 +02:00
WP_Theme :: network_disable_theme ( ( array ) $themes );
2011-12-10 19:26:48 +01:00
wp_safe_redirect ( add_query_arg ( 'disabled' , count ( $themes ), $referer ) );
2010-12-24 18:41:36 +01:00
exit ;
2017-12-01 00:11:00 +01:00
case 'update-selected' :
2011-10-03 16:35:43 +02:00
check_admin_referer ( 'bulk-themes' );
2017-12-01 00:11:00 +01:00
if ( isset ( $_GET [ 'themes' ] ) ) {
2011-10-03 16:35:43 +02:00
$themes = explode ( ',' , $_GET [ 'themes' ] );
2017-12-01 00:11:00 +01:00
} elseif ( isset ( $_POST [ 'checked' ] ) ) {
2011-10-03 16:35:43 +02:00
$themes = ( array ) $_POST [ 'checked' ];
2017-12-01 00:11:00 +01:00
} else {
2011-10-03 16:35:43 +02:00
$themes = array ();
2017-12-01 00:11:00 +01:00
}
2011-10-03 16:35:43 +02:00
2021-07-22 15:53:00 +02:00
// Used in the HTML title tag.
2017-12-01 00:11:00 +01:00
$title = __ ( 'Update Themes' );
2011-10-03 16:35:43 +02:00
$parent_file = 'themes.php' ;
2020-02-06 07:33:11 +01:00
require_once ABSPATH . 'wp-admin/admin-header.php' ;
2011-10-03 16:35:43 +02:00
echo '<div class="wrap">' ;
2015-06-27 17:41:25 +02:00
echo '<h1>' . esc_html ( $title ) . '</h1>' ;
2011-10-03 16:35:43 +02:00
2020-10-18 19:27:06 +02:00
$url = self_admin_url ( 'update.php?action=update-selected-themes&themes=' . urlencode ( implode ( ',' , $themes ) ) );
2017-12-01 00:11:00 +01:00
$url = wp_nonce_url ( $url , 'bulk-update-themes' );
2011-10-03 16:35:43 +02:00
echo " <iframe src=' $url ' style='width: 100%; height:100%; min-height:850px;'></iframe> " ;
echo '</div>' ;
2020-02-06 07:33:11 +01:00
require_once ABSPATH . 'wp-admin/admin-footer.php' ;
2011-10-03 16:35:43 +02:00
exit ;
2010-12-21 17:50:16 +01:00
case 'delete-selected' :
2014-10-08 21:05:20 +02:00
if ( ! current_user_can ( 'delete_themes' ) ) {
2017-12-01 00:11:00 +01:00
wp_die ( __ ( 'Sorry, you are not allowed to delete themes for this site.' ) );
2014-10-08 21:05:20 +02:00
}
2010-12-23 19:53:44 +01:00
check_admin_referer ( 'bulk-themes' );
2010-12-21 17:50:16 +01:00
$themes = isset ( $_REQUEST [ 'checked' ] ) ? ( array ) $_REQUEST [ 'checked' ] : array ();
2010-12-24 18:41:36 +01:00
2010-12-21 17:50:16 +01:00
if ( empty ( $themes ) ) {
2011-12-10 19:26:48 +01:00
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
2010-12-21 17:50:16 +01:00
exit ;
}
2014-10-05 22:37:17 +02:00
$themes = array_diff ( $themes , array ( get_option ( 'stylesheet' ), get_option ( 'template' ) ) );
2011-12-09 00:02:33 +01:00
2010-12-21 17:50:16 +01:00
if ( empty ( $themes ) ) {
2011-12-10 19:26:48 +01:00
wp_safe_redirect ( add_query_arg ( 'error' , 'main' , $referer ) );
2010-12-21 17:50:16 +01:00
exit ;
}
2010-12-23 16:56:32 +01:00
2015-12-17 19:35:26 +01:00
$theme_info = array ();
2014-10-05 22:37:17 +02:00
foreach ( $themes as $key => $theme ) {
$theme_info [ $theme ] = wp_get_theme ( $theme );
}
2020-02-06 07:33:11 +01:00
require ABSPATH . 'wp-admin/update.php' ;
2010-12-21 17:50:16 +01:00
$parent_file = 'themes.php' ;
if ( ! isset ( $_REQUEST [ 'verify-delete' ] ) ) {
wp_enqueue_script ( 'jquery' );
2020-02-06 07:33:11 +01:00
require_once ABSPATH . 'wp-admin/admin-header.php' ;
2015-03-31 20:45:28 +02:00
$themes_to_delete = count ( $themes );
2010-12-21 17:50:16 +01:00
?>
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
< div class = " wrap " >
< ? php if ( 1 === $themes_to_delete ) : ?>
2015-06-27 17:41:25 +02:00
< h1 >< ? php _e ( 'Delete Theme' ); ?> </h1>
Administration: Use `wp_admin_notice()` in `wp-admin/network/`.
Add additional usage of `wp_admin_notice()` in `wp-admin/network/` where previously overlooked.
Follow up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597], [56599], [56600].
Props costdev, joedolson.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56601
git-svn-id: http://core.svn.wordpress.org/trunk@56113 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 21:12:21 +02:00
< ? php
wp_admin_notice (
'<strong>' . __ ( 'Caution:' ) . '</strong> ' . __ ( 'This theme may be active on other sites in the network.' ),
array (
'additional_classes' => array ( 'error' ),
)
);
?>
2015-03-31 20:45:28 +02:00
< p >< ? php _e ( 'You are about to remove the following theme:' ); ?> </p>
< ? php else : ?>
2015-06-27 17:41:25 +02:00
< h1 >< ? php _e ( 'Delete Themes' ); ?> </h1>
Administration: Use `wp_admin_notice()` in `wp-admin/network/`.
Add additional usage of `wp_admin_notice()` in `wp-admin/network/` where previously overlooked.
Follow up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597], [56599], [56600].
Props costdev, joedolson.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56601
git-svn-id: http://core.svn.wordpress.org/trunk@56113 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 21:12:21 +02:00
< ? php
wp_admin_notice (
'<strong>' . __ ( 'Caution:' ) . '</strong> ' . __ ( 'These themes may be active on other sites in the network.' ),
array (
'additional_classes' => array ( 'error' ),
)
);
?>
2015-03-31 20:45:28 +02:00
< p >< ? php _e ( 'You are about to remove the following themes:' ); ?> </p>
< ? php endif ; ?>
2010-12-21 17:50:16 +01:00
< ul class = " ul-disc " >
2014-10-08 21:05:20 +02:00
< ? php
2017-12-01 00:11:00 +01:00
foreach ( $theme_info as $theme ) {
echo '<li>' . sprintf (
2019-09-03 02:41:05 +02:00
/* translators: 1: Theme name, 2: Theme author. */
2017-12-01 00:11:00 +01:00
_x ( '%1$s by %2$s' , 'theme' ),
'<strong>' . $theme -> display ( 'Name' ) . '</strong>' ,
'<em>' . $theme -> display ( 'Author' ) . '</em>'
) . '</li>' ;
}
2014-10-08 21:05:20 +02:00
?>
2010-12-21 17:50:16 +01:00
</ ul >
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
< ? php if ( 1 === $themes_to_delete ) : ?>
2019-07-04 11:56:57 +02:00
< p >< ? php _e ( 'Are you sure you want to delete this theme?' ); ?> </p>
2015-03-31 20:45:28 +02:00
< ? php else : ?>
2019-07-04 11:56:57 +02:00
< p >< ? php _e ( 'Are you sure you want to delete these themes?' ); ?> </p>
2015-03-31 20:45:28 +02:00
< ? php endif ; ?>
2017-12-01 00:11:00 +01:00
< form method = " post " action = " <?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?> " style = " display:inline; " >
2010-12-21 17:50:16 +01:00
< input type = " hidden " name = " verify-delete " value = " 1 " />
< input type = " hidden " name = " action " value = " delete-selected " />
< ? php
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
2017-12-01 00:11:00 +01:00
foreach ( ( array ) $themes as $theme ) {
echo '<input type="hidden" name="checked[]" value="' . esc_attr ( $theme ) . '" />' ;
}
2015-03-31 20:45:28 +02:00
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
wp_nonce_field ( 'bulk-themes' );
2015-03-31 20:45:28 +02:00
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
if ( 1 === $themes_to_delete ) {
2017-12-01 00:11:00 +01:00
submit_button ( __ ( 'Yes, delete this theme' ), '' , 'submit' , false );
} else {
submit_button ( __ ( 'Yes, delete these themes' ), '' , 'submit' , false );
}
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
2010-12-21 17:50:16 +01:00
?>
</ form >
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
< ? php $referer = wp_get_referer (); ?>
2015-03-09 03:11:28 +01:00
< form method = " post " action = " <?php echo $referer ? esc_url( $referer ) : ''; ?> " style = " display:inline; " >
2016-09-28 21:54:28 +02:00
< ? php submit_button ( __ ( 'No, return me to the theme list' ), '' , 'submit' , false ); ?>
2010-12-21 17:50:16 +01:00
</ form >
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
</ div >
2010-12-21 17:50:16 +01:00
< ? php
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
2020-02-06 07:33:11 +01:00
require_once ABSPATH . 'wp-admin/admin-footer.php' ;
2010-12-21 17:50:16 +01:00
exit ;
2020-01-29 01:45:18 +01:00
} // End if verify-delete.
2010-12-23 20:40:32 +01:00
2012-09-29 03:36:14 +02:00
foreach ( $themes as $theme ) {
2017-12-01 00:11:00 +01:00
$delete_result = delete_theme (
2018-08-17 03:51:36 +02:00
$theme ,
esc_url (
2017-12-01 00:11:00 +01:00
add_query_arg (
array (
'verify-delete' => 1 ,
'action' => 'delete-selected' ,
'checked' => $_REQUEST [ 'checked' ],
'_wpnonce' => $_REQUEST [ '_wpnonce' ],
2018-08-17 03:51:36 +02:00
),
network_admin_url ( 'themes.php' )
2017-12-01 00:11:00 +01:00
)
)
);
2012-09-29 03:36:14 +02:00
}
2014-05-06 20:08:14 +02:00
2011-12-09 00:02:33 +01:00
$paged = ( $_REQUEST [ 'paged' ] ) ? $_REQUEST [ 'paged' ] : 1 ;
2017-12-01 00:11:00 +01:00
wp_redirect (
add_query_arg (
array (
'deleted' => count ( $themes ),
'paged' => $paged ,
's' => $s ,
2018-08-17 03:51:36 +02:00
),
network_admin_url ( 'themes.php' )
2017-12-01 00:11:00 +01:00
)
);
2010-12-21 17:50:16 +01:00
exit ;
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
case 'enable-auto-update' :
case 'disable-auto-update' :
case 'enable-auto-update-selected' :
case 'disable-auto-update-selected' :
if ( ! ( current_user_can ( 'update_themes' ) && wp_is_auto_update_enabled_for_type ( 'theme' ) ) ) {
wp_die ( __ ( 'Sorry, you are not allowed to change themes automatic update settings.' ) );
}
if ( 'enable-auto-update' === $action || 'disable-auto-update' === $action ) {
check_admin_referer ( 'updates' );
} else {
if ( empty ( $_POST [ 'checked' ] ) ) {
// Nothing to do.
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
exit ;
}
check_admin_referer ( 'bulk-themes' );
}
$auto_updates = ( array ) get_site_option ( 'auto_update_themes' , array () );
if ( 'enable-auto-update' === $action ) {
$auto_updates [] = $_GET [ 'theme' ];
$auto_updates = array_unique ( $auto_updates );
$referer = add_query_arg ( 'enabled-auto-update' , 1 , $referer );
} elseif ( 'disable-auto-update' === $action ) {
$auto_updates = array_diff ( $auto_updates , array ( $_GET [ 'theme' ] ) );
$referer = add_query_arg ( 'disabled-auto-update' , 1 , $referer );
} else {
// Bulk enable/disable.
$themes = ( array ) wp_unslash ( $_POST [ 'checked' ] );
if ( 'enable-auto-update-selected' === $action ) {
$auto_updates = array_merge ( $auto_updates , $themes );
$auto_updates = array_unique ( $auto_updates );
$referer = add_query_arg ( 'enabled-auto-update' , count ( $themes ), $referer );
} else {
$auto_updates = array_diff ( $auto_updates , $themes );
$referer = add_query_arg ( 'disabled-auto-update' , count ( $themes ), $referer );
}
}
$all_items = wp_get_themes ();
// Remove themes that don't exist or have been deleted since the option was last updated.
$auto_updates = array_intersect ( $auto_updates , array_keys ( $all_items ) );
update_site_option ( 'auto_update_themes' , $auto_updates );
wp_safe_redirect ( $referer );
exit ;
2016-09-23 22:33:30 +02:00
default :
$themes = isset ( $_POST [ 'checked' ] ) ? ( array ) $_POST [ 'checked' ] : array ();
if ( empty ( $themes ) ) {
wp_safe_redirect ( add_query_arg ( 'error' , 'none' , $referer ) );
exit ;
}
check_admin_referer ( 'bulk-themes' );
2016-10-26 16:37:29 +02:00
/** This action is documented in wp-admin/network/site-themes.php */
2019-07-05 03:45:56 +02:00
$referer = apply_filters ( 'handle_network_bulk_actions-' . get_current_screen () -> id , $referer , $action , $themes ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
2016-09-23 22:33:30 +02:00
wp_safe_redirect ( $referer );
exit ;
2010-10-31 10:37:15 +01:00
}
2010-07-30 22:34:54 +02:00
}
2010-10-31 10:37:15 +01:00
$wp_list_table -> prepare_items ();
2011-01-13 01:03:38 +01:00
2010-11-01 21:08:25 +01:00
add_thickbox ();
2010-10-31 10:37:15 +01:00
2015-03-10 16:32:27 +01:00
add_screen_option ( 'per_page' );
2011-10-02 08:59:36 +02:00
2017-12-01 00:11:00 +01:00
get_current_screen () -> add_help_tab (
array (
'id' => 'overview' ,
'title' => __ ( 'Overview' ),
'content' =>
'<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>' .
'<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’s Appearance > Themes screen.' ) . '</p>' .
'<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>' ,
)
);
2011-11-02 06:33:53 +01:00
2020-06-16 19:29:07 +02:00
$help_sidebar_autoupdates = '' ;
2020-06-19 23:14:08 +02:00
2020-06-16 19:29:07 +02:00
if ( current_user_can ( 'update_themes' ) && wp_is_auto_update_enabled_for_type ( 'theme' ) ) {
get_current_screen () -> add_help_tab (
array (
'id' => 'plugins-themes-auto-updates' ,
'title' => __ ( 'Auto-updates' ),
'content' =>
'<p>' . __ ( 'Auto-updates can be enabled or disabled for each individual theme. Themes with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '</p>' .
'<p>' . __ ( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>' ,
)
);
2023-02-23 11:38:21 +01:00
$help_sidebar_autoupdates = '<p>' . __ ( '<a href="https://wordpress.org/documentation/article/plugins-themes-auto-updates/">Documentation on Auto-updates</a>' ) . '</p>' ;
2020-06-16 19:29:07 +02:00
}
2011-11-02 22:32:16 +01:00
get_current_screen () -> set_help_sidebar (
2017-12-01 00:11:00 +01:00
'<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' .
'<p>' . __ ( '<a href="https://codex.wordpress.org/Network_Admin_Themes_Screen">Documentation on Network Themes</a>' ) . '</p>' .
2020-06-19 23:14:08 +02:00
$help_sidebar_autoupdates .
2023-02-23 11:38:21 +01:00
'<p>' . __ ( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
2010-11-01 00:23:32 +01:00
);
2017-12-01 00:11:00 +01:00
get_current_screen () -> set_screen_reader_content (
array (
'heading_views' => __ ( 'Filter themes list' ),
'heading_pagination' => __ ( 'Themes list navigation' ),
'heading_list' => __ ( 'Themes list' ),
)
);
2015-10-07 03:28:25 +02:00
2021-07-22 15:53:00 +02:00
// Used in the HTML title tag.
2017-12-01 00:11:00 +01:00
$title = __ ( 'Themes' );
2010-10-31 10:37:15 +01:00
$parent_file = 'themes.php' ;
Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.
Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.
Built from https://develop.svn.wordpress.org/trunk@37714
git-svn-id: http://core.svn.wordpress.org/trunk@37680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-15 18:37:29 +02:00
wp_enqueue_script ( 'updates' );
No-JavaScript and no-Customizer support for the new Themes screen.
JavaScript is rarely disabled, but graceful degradation is still important. For example, syntax errors can occur, usually with major WP updates that overhaul entire experiences and update external libraries combined with themes or plugins doing weird or old things. If this error is due to their current theme, a user needs to be able to access the themes screen to switch away from the theme. A more subtle issue could make things painful to diagnose.
This commit renders the grid in PHP (the template is duplicated, but it lightweight, fairly mundane, and easy to sync). On Backbone render, the grid is then re-rendered from JavaScript so searches can occur. Customize and Live Preview is disabled if JS fails to kick in. If JS is disabled, old-school "Preview" links are displayed.
No-Customizer support: The customizer is only supported when the browser supports postMessage (IE8+), and if the frontend is a different domain, CORS (IE10+). We use the .hide-if-no-customize class for this. Pre-customize "Preview" links should use .hide-if-customize.
The .load-customize class should be used to declare a link that opens the customizer. This enables customize-loader.js to intercept this link and load the customizer on top of the current window, making for a smoother experience.
fixes #25964.
Built from https://develop.svn.wordpress.org/trunk@26726
git-svn-id: http://core.svn.wordpress.org/trunk@26615 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-06 17:11:10 +01:00
wp_enqueue_script ( 'theme-preview' );
2013-07-05 17:15:58 +02:00
2020-02-06 07:33:11 +01:00
require_once ABSPATH . 'wp-admin/admin-header.php' ;
2010-10-31 10:37:15 +01:00
2010-07-30 22:34:54 +02:00
?>
2010-10-31 10:37:15 +01:00
2010-07-30 22:34:54 +02:00
< div class = " wrap " >
2016-12-09 19:57:42 +01:00
< h1 class = " wp-heading-inline " >< ? php echo esc_html ( $title ); ?> </h1>
< ? php if ( current_user_can ( 'install_themes' ) ) : ?>
2023-09-05 21:26:26 +02:00
< a href = " theme-install.php " class = " page-title-action " >< ? php echo esc_html__ ( 'Add New Theme' ); ?> </a>
2016-12-09 19:57:42 +01:00
< ? php endif ; ?>
< ? php
2016-01-14 21:06:25 +01:00
if ( isset ( $_REQUEST [ 's' ] ) && strlen ( $_REQUEST [ 's' ] ) ) {
2020-10-23 19:19:14 +02:00
echo '<span class="subtitle">' ;
printf (
/* translators: %s: Search query. */
__ ( 'Search results for: %s' ),
'<strong>' . esc_html ( $s ) . '</strong>'
);
echo '</span>' ;
2016-01-14 21:06:25 +01:00
}
?>
2016-12-09 19:57:42 +01:00
< hr class = " wp-header-end " >
2010-10-31 10:37:15 +01:00
2010-12-24 18:41:36 +01:00
< ? php
2023-08-17 23:03:19 +02:00
$message = '' ;
$type = 'success' ;
2010-12-24 18:41:36 +01:00
if ( isset ( $_GET [ 'enabled' ] ) ) {
2015-03-31 20:45:28 +02:00
$enabled = absint ( $_GET [ 'enabled' ] );
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
if ( 1 === $enabled ) {
2015-03-31 20:45:28 +02:00
$message = __ ( 'Theme enabled.' );
} else {
2023-08-17 23:03:19 +02:00
$message = sprintf (
/* translators: %s: Number of themes. */
_n ( '%s theme enabled.' , '%s themes enabled.' , $enabled ),
number_format_i18n ( $enabled )
);
2015-03-31 20:45:28 +02:00
}
2010-12-24 18:41:36 +01:00
} elseif ( isset ( $_GET [ 'disabled' ] ) ) {
2015-03-31 20:45:28 +02:00
$disabled = absint ( $_GET [ 'disabled' ] );
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
if ( 1 === $disabled ) {
2015-03-31 20:45:28 +02:00
$message = __ ( 'Theme disabled.' );
} else {
2023-08-17 23:03:19 +02:00
$message = sprintf (
/* translators: %s: Number of themes. */
_n ( '%s theme disabled.' , '%s themes disabled.' , $disabled ),
number_format_i18n ( $disabled )
);
2015-03-31 20:45:28 +02:00
}
2010-12-24 18:41:36 +01:00
} elseif ( isset ( $_GET [ 'deleted' ] ) ) {
2015-03-31 20:45:28 +02:00
$deleted = absint ( $_GET [ 'deleted' ] );
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
if ( 1 === $deleted ) {
2015-03-31 20:45:28 +02:00
$message = __ ( 'Theme deleted.' );
} else {
2023-08-17 23:03:19 +02:00
$message = sprintf (
/* translators: %s: Number of themes. */
_n ( '%s theme deleted.' , '%s themes deleted.' , $deleted ),
number_format_i18n ( $deleted )
);
2015-03-31 20:45:28 +02:00
}
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
} elseif ( isset ( $_GET [ 'enabled-auto-update' ] ) ) {
$enabled = absint ( $_GET [ 'enabled-auto-update' ] );
if ( 1 === $enabled ) {
$message = __ ( 'Theme will be auto-updated.' );
} else {
2023-08-17 23:03:19 +02:00
$message = sprintf (
/* translators: %s: Number of themes. */
_n ( '%s theme will be auto-updated.' , '%s themes will be auto-updated.' , $enabled ),
number_format_i18n ( $enabled )
);
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
}
} elseif ( isset ( $_GET [ 'disabled-auto-update' ] ) ) {
$disabled = absint ( $_GET [ 'disabled-auto-update' ] );
if ( 1 === $disabled ) {
$message = __ ( 'Theme will no longer be auto-updated.' );
} else {
2023-08-17 23:03:19 +02:00
$message = sprintf (
/* translators: %s: Number of themes. */
_n ( '%s theme will no longer be auto-updated.' , '%s themes will no longer be auto-updated.' , $disabled ),
number_format_i18n ( $disabled )
);
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
}
} elseif ( isset ( $_GET [ 'error' ] ) && 'none' === $_GET [ 'error' ] ) {
2023-08-17 23:03:19 +02:00
$message = __ ( 'No theme selected.' );
$type = 'error' ;
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
} elseif ( isset ( $_GET [ 'error' ] ) && 'main' === $_GET [ 'error' ] ) {
2023-08-17 23:03:19 +02:00
$message = __ ( 'You cannot delete a theme while it is active on the main site.' );
$type = 'error' ;
2010-12-24 18:41:36 +01:00
}
2023-08-17 23:03:19 +02:00
if ( '' !== $message ) {
wp_admin_notice (
$message ,
array (
'type' => $type ,
'dismissible' => true ,
'id' => 'message' ,
)
);
}
2010-12-24 18:41:36 +01:00
?>
2015-01-16 05:16:24 +01:00
< form method = " get " >
2010-12-16 21:45:10 +01:00
< ? php $wp_list_table -> search_box ( __ ( 'Search Installed Themes' ), 'theme' ); ?>
2010-10-31 10:37:15 +01:00
</ form >
2012-03-08 08:32:42 +01:00
< ? php
$wp_list_table -> views ();
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin.
Fixes: #50052.
Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon.
Built from https://develop.svn.wordpress.org/trunk@47835
git-svn-id: http://core.svn.wordpress.org/trunk@47611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-20 20:49:09 +02:00
if ( 'broken' === $status ) {
2016-02-23 18:20:27 +01:00
echo '<p class="clear">' . __ ( 'The following themes are installed but incomplete.' ) . '</p>' ;
2017-12-01 00:11:00 +01:00
}
2012-03-08 08:32:42 +01:00
?>
2010-10-31 10:37:15 +01:00
Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.
Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.
Built from https://develop.svn.wordpress.org/trunk@37714
git-svn-id: http://core.svn.wordpress.org/trunk@37680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-15 18:37:29 +02:00
< form id = " bulk-action-form " method = " post " >
2017-12-01 00:11:00 +01:00
< input type = " hidden " name = " theme_status " value = " <?php echo esc_attr( $status ); ?> " />
< input type = " hidden " name = " paged " value = " <?php echo esc_attr( $page ); ?> " />
2010-10-31 10:37:15 +01:00
< ? php $wp_list_table -> display (); ?>
</ form >
2010-07-30 22:34:54 +02:00
</ div >
2010-10-31 10:37:15 +01:00
< ? php
Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.
Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.
Built from https://develop.svn.wordpress.org/trunk@37714
git-svn-id: http://core.svn.wordpress.org/trunk@37680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-15 18:37:29 +02:00
wp_print_request_filesystem_credentials_modal ();
wp_print_admin_notice_templates ();
wp_print_update_row_templates ();
2020-02-06 07:33:11 +01:00
require_once ABSPATH . 'wp-admin/admin-footer.php' ;