X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f..e8f61417994be715a90671aa87f1cd70d8ba132a:/wp-admin/widgets.php diff --git a/wp-admin/widgets.php b/wp-admin/widgets.php index f4de378f..91d611cd 100644 --- a/wp-admin/widgets.php +++ b/wp-admin/widgets.php @@ -1,6 +1,6 @@ ' . __( 'Cheatin’ uh?' ) . '' . + '

' . __( 'You are not allowed to edit theme options on this site.' ) . '

', + 403 + ); +} $widgets_access = get_user_setting( 'widgets_access' ); if ( isset($_GET['widgets-access']) ) { @@ -21,10 +26,6 @@ if ( isset($_GET['widgets-access']) ) { set_user_setting( 'widgets_access', $widgets_access ); } -function wp_widgets_access_body_class($classes) { - return "$classes widgets_access "; -} - if ( 'on' == $widgets_access ) { add_filter( 'admin_body_class', 'wp_widgets_access_body_class' ); } else { @@ -70,12 +71,12 @@ get_current_screen()->add_help_tab( array( get_current_screen()->set_help_sidebar( '

' . __('For more information:') . '

' . - '

' . __('Documentation on Widgets') . '

' . + '

' . __('Documentation on Widgets') . '

' . '

' . __('Support Forums') . '

' ); if ( ! current_theme_supports( 'widgets' ) ) { - wp_die( __( 'The theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please follow these instructions.' ) ); + wp_die( __( 'The theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please follow these instructions.' ) ); } // These are the widgets grouped by sidebar @@ -88,7 +89,7 @@ foreach ( $sidebars_widgets as $sidebar_id => $widgets ) { if ( 'wp_inactive_widgets' == $sidebar_id ) continue; - if ( !isset( $wp_registered_sidebars[ $sidebar_id ] ) ) { + if ( ! is_registered_sidebar( $sidebar_id ) ) { if ( ! empty( $widgets ) ) { // register the inactive_widgets area as sidebar register_sidebar(array( 'name' => __( 'Inactive Sidebar (not used)' ), @@ -151,6 +152,17 @@ if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) { $sidebar = array_diff( $sidebar, array($widget_id) ); $_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1'); + + /** + * Fires immediately after a widget has been marked for deletion. + * + * @since 4.4.0 + * + * @param string $widget_id ID of the widget marked for deletion. + * @param string $sidebar_id ID of the sidebar the widget was deleted from. + * @param string $id_base ID base for the widget. + */ + do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base ); } $_POST['widget-id'] = $sidebar; @@ -182,6 +194,28 @@ if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) { exit; } +// Remove inactive widgets without js +if ( isset( $_POST['removeinactivewidgets'] ) ) { + check_admin_referer( 'remove-inactive-widgets', '_wpnonce_remove_inactive_widgets' ); + + if ( $_POST['removeinactivewidgets'] ) { + foreach ( $sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id ) { + $pieces = explode( '-', $widget_id ); + $multi_number = array_pop( $pieces ); + $id_base = implode( '-', $pieces ); + $widget = get_option( 'widget_' . $id_base ); + unset( $widget[$multi_number] ); + update_option( 'widget_' . $id_base, $widget ); + unset( $sidebars_widgets['wp_inactive_widgets'][$key] ); + } + + wp_set_sidebars_widgets( $sidebars_widgets ); + } + + wp_redirect( admin_url( 'widgets.php?message=0' ) ); + exit; +} + // Output the widget form without js if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) { $widget_id = $_GET['editwidget']; @@ -189,7 +223,7 @@ if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) { if ( isset($_GET['addnew']) ) { // Default to the first sidebar $keys = array_keys( $wp_registered_sidebars ); - $sidebar = array_shift( $keys ); + $sidebar = reset( $keys ); if ( isset($_GET['base']) && isset($_GET['num']) ) { // multi-widget // Copy minimal info from an existing instance of this widget to a new instance @@ -230,9 +264,9 @@ if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) { require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?>
-

+

> -

+

@@ -310,10 +344,27 @@ $errors = array( require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?>
-

+

+%2$s', + esc_url( add_query_arg( + array( + array( 'autofocus' => array( 'panel' => 'widgets' ) ), + 'return' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) + ), + admin_url( 'customize.php' ) + ) ), + __( 'Manage in Customizer' ) + ); + } +?> +

-

+

@@ -332,7 +383,7 @@ do_action( 'widgets_admin_page' ); ?>