From 123d7ee968c7442a4af4549c0264b2825db20deb Mon Sep 17 00:00:00 2001 From: azaozz Date: Sat, 11 Apr 2009 14:37:24 +0000 Subject: [PATCH] Widgets page, first run, see #9511 git-svn-id: http://svn.automattic.com/wordpress/trunk@10912 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-ajax.php | 104 ++++++++++ wp-admin/css/colors-classic.css | 37 +--- wp-admin/css/colors-fresh.css | 53 ++--- wp-admin/css/global.css | 1 + wp-admin/css/ie.css | 38 +++- wp-admin/css/widgets-rtl.css | 18 +- wp-admin/css/widgets.css | 211 +++++++++----------- wp-admin/includes/widgets.php | 280 +++++++++----------------- wp-admin/js/widgets.dev.js | 279 +++++++++++++------------- wp-admin/js/widgets.js | 2 +- wp-admin/widgets.php | 334 +++++++++++--------------------- wp-admin/wp-admin.css | 29 +-- wp-includes/default-widgets.php | 13 +- wp-includes/script-loader.php | 21 +- wp-includes/widgets.php | 100 +++++----- 15 files changed, 688 insertions(+), 832 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index ea9d4b00b..cd9eda608 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1268,6 +1268,110 @@ case 'lj-importer' : echo $result->get_error_message(); die; break; +case 'widgets-order' : + check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); + + if ( !current_user_can('switch_themes') ) + die('-1'); + + unset( $_POST['savewidgets'], $_POST['action'] ); + $sidebars_widgets = array('array_version' => 3); + + foreach ( $_POST as $key => $val ) { + if ( preg_match( '/^(wp_inactive_widgets|sidebar-[0-9]+)$/', $key ) ) { + if ( preg_match( '/^[0-9a-z,_-]+$/i', $val ) ) { + $val = explode(',', $val); + + foreach ( $val as $k => $v ) { + $val[$k] = substr($v, strpos($v, '_') + 1); + } + } elseif ( '' == $val ) { + $val = array(); + } else { + die('-1'); + } + + $sidebars_widgets[$key] = $val; + } + } + + wp_set_sidebars_widgets($sidebars_widgets); + + die('1'); + break; +case 'save-widget' : + check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); + + if ( !current_user_can('switch_themes') ) + die('-1'); + + unset( $_POST['savewidgets'], $_POST['action'] ); + + $number = isset($_POST['widget_number']) ? $_POST['widget_number'] : ''; + if ( isset($_POST['id_base']) ) + $id_base = $_POST['id_base']; + else + die('-1'); + + $sidebar_id = (string) $_POST['sidebar']; + $sidebars = wp_get_sidebars_widgets(); + $sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array(); + + // delete + if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) { + $del_id = $_POST['widget-id']; + $widget = isset($wp_registered_widgets[$del_id]) ? $wp_registered_widgets[$del_id] : false; + + if ( !in_array($del_id, $sidebar, true) || !$widget ) + die('-1'); + + $option = str_replace( '-', '_', 'widget_' . $id_base ); + $data = get_option($option); + + if ( isset($widget['params'][0]['number']) ) { + $number = $widget['params'][0]['number']; + if ( is_array($data) && isset($data[$number]) ) { + unset( $data[$number] ); + update_option($option, $data); + } + } else { + if ( $data ) { + $data = array(); + update_option($option, $data); + } + } + + $sidebar = array_diff( $sidebar, array($del_id) ); + $sidebars[$sidebar_id] = $sidebar; + wp_set_sidebars_widgets($sidebars); + + echo "deleted:$del_id"; + die(); + } + + // save + foreach ( (array) $wp_registered_widget_updates as $name => $control ) { + if ( $name == $id_base ) { + if ( !is_callable( $control['callback'] ) ) + continue; + + if ( $number ) { + // don't delete other instances of the same multi-widget + foreach ( $sidebar as $_widget_id ) { + if ( isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) + unset($wp_registered_widgets[$_widget_id]['params'][0]['number']); + } + } + + ob_start(); + call_user_func_array( $control['callback'], $control['params'] ); + ob_end_clean(); + break; + } + } + + die('1'); + break; default : do_action( 'wp_ajax_' . $_POST['action'] ); die('0'); diff --git a/wp-admin/css/colors-classic.css b/wp-admin/css/colors-classic.css index 3bdef8b70..9aef89aa0 100644 --- a/wp-admin/css/colors-classic.css +++ b/wp-admin/css/colors-classic.css @@ -33,7 +33,6 @@ kbd, code { background: #eaeaea; } -div#current-widgets, #postcustomstuff table, #your-profile fieldset, #rightnow, @@ -83,8 +82,7 @@ div.dashboard-widget-notice { background-color: #cfe1ef; } -div.dashboard-widget-submit, -ul.widget-control-list div.widget-control-actions { +div.dashboard-widget-submit { border-top-color: #ccc; } @@ -101,10 +99,6 @@ textarea.disabled { background-color: #ccc; } /* #upload-menu li a.upload-tab-link, */ -li.widget-list-control-item h4.widget-title a:hover, -li.widget-list-control-item h4.widget-title a, -#dragHelper li.widget-list-control-item h4.widget-title a, -#draghelper li.widget-list-control-item h4.widget-title a:visited, .login #backtoblog a:hover, #plugin-information .action-button a, #plugin-information .action-button a:hover, @@ -112,11 +106,6 @@ li.widget-list-control-item h4.widget-title a, color: #fff; } -li.widget-list-control-item div.widget-control { - background-color: #fff; - border-color: #dfdfdf; -} - .metabox-holder .postbox h3, #poststuff .postbox h3, #poststuff .stuffbox h3 { @@ -143,11 +132,6 @@ strong .post-com-count span { background-color: #21759b; } -ul#widget-list li.widget-list-item h4.widget-title { - background-color: #f0f0f0; - color: #000; -} - .sorthelper { background-color: #ccf3fa; } @@ -276,7 +260,7 @@ td.help { border-bottom-color: #dadada; } -.side-info ul, .widget-description { +.side-info ul { color: #666; } @@ -429,7 +413,6 @@ a.page-numbers { } div#available-widgets-filter, -ul#widget-list li.widget-list-item, .commentlist li { border-bottom-color: #ccc; } @@ -531,10 +514,6 @@ div#plugin-information-header { border-color: #666; } -#current-widgets .drop-widget-here { - background-color: #ffc; -} - #dashboard_secondary div.dashboard-widget-content ul li a { background-color: #f9f9f9; } @@ -543,13 +522,6 @@ input.readonly, textarea.readonly { background-color: #ddd; } -#dragHelper h4.widget-title, -li.widget-list-control-item h4, -#dragHelper li.widget-list-control-item h4 { - background-color: #2683ae; - color: #fff; -} - #ed_toolbar input, #ed_reply_toolbar input { background: #fff url("../images/fade-butt.png") repeat-x 0 -2px; @@ -1595,3 +1567,8 @@ input[readonly] { .theme-listing br.line { border-bottom-color: #ccc; } + +div.widgets-holder-wrap { + background-color: #F1F1F1; + border-color: #DDDDDD; +} diff --git a/wp-admin/css/colors-fresh.css b/wp-admin/css/colors-fresh.css index 9de89e8b1..f2e709b33 100644 --- a/wp-admin/css/colors-fresh.css +++ b/wp-admin/css/colors-fresh.css @@ -33,7 +33,6 @@ kbd, code { background: #eaeaea; } -div#current-widgets, #postcustomstuff table, #your-profile fieldset, #rightnow, @@ -83,8 +82,7 @@ div.dashboard-widget-notice { background-color: #cfe1ef; } -div.dashboard-widget-submit, -ul.widget-control-list div.widget-control-actions { +div.dashboard-widget-submit { border-top-color: #ccc; } @@ -101,10 +99,6 @@ textarea.disabled { background-color: #ccc; } /* #upload-menu li a.upload-tab-link, */ -li.widget-list-control-item h4.widget-title a:hover, -li.widget-list-control-item h4.widget-title a, -#dragHelper li.widget-list-control-item h4.widget-title a, -#draghelper li.widget-list-control-item h4.widget-title a:visited, .login #backtoblog a:hover, #plugin-information .action-button a, #plugin-information .action-button a:hover, @@ -112,14 +106,9 @@ li.widget-list-control-item h4.widget-title a, color: #fff; } -li.widget-list-control-item div.widget-control { - background-color: #fff; - border-color: #dfdfdf; -} - -.metabox-holder .postbox h3, -#poststuff .postbox h3, -#poststuff .stuffbox h3 { +.widget .widget-top, +.postbox h3, +.stuffbox h3 { background: #dfdfdf url("../images/gray-grad.png") repeat-x left top; text-shadow: #fff 0 1px 0; } @@ -143,11 +132,6 @@ strong .post-com-count span { background-color: #21759b; } -ul#widget-list li.widget-list-item h4.widget-title { - background-color: #f0f0f0; - color: #000; -} - .sorthelper { background-color: #ccf3fa; } @@ -276,7 +260,7 @@ td.help { border-bottom-color: #dadada; } -.side-info ul, .widget-description { +.side-info ul { color: #666; } @@ -429,7 +413,6 @@ a.page-numbers { } div#available-widgets-filter, -ul#widget-list li.widget-list-item, .commentlist li { border-bottom-color: #ccc; } @@ -531,10 +514,6 @@ div#plugin-information-header { border-color: #666; } -#current-widgets .drop-widget-here { - background-color: #ffc; -} - #dashboard_secondary div.dashboard-widget-content ul li a { background-color: #f9f9f9; } @@ -543,13 +522,6 @@ input.readonly, textarea.readonly { background-color: #ddd; } -#dragHelper h4.widget-title, -li.widget-list-control-item h4, -#dragHelper li.widget-list-control-item h4 { - background-color: #2683ae; - color: #fff; -} - #ed_toolbar input, #ed_reply_toolbar input { background: #fff url("../images/fade-butt.png") repeat-x 0 -2px; @@ -642,8 +614,8 @@ li.widget-list-control-item h4, background-color: #fff; } -.metabox-holder .postbox, -#poststuff .postbox, +.widget, +.postbox, #titlediv, #poststuff .postarea, #poststuff .stuffbox, @@ -654,15 +626,17 @@ li.widget-list-control-item h4, border-color: #dfdfdf; } -.metabox-holder .postbox, -#poststuff .postbox { +.widget, +.postbox { background-color: #FFF; } +.widget .widget-top, .ui-sortable .postbox h3 { color: #464646; } +.widget .widget-top, .ui-sortable .postbox h3:hover { color: #000; } @@ -1595,3 +1569,8 @@ input[readonly] { .theme-listing br.line { border-bottom-color: #ccc; } + +div.widgets-holder-wrap { + background-color: #F1F1F1; + border-color: #DDDDDD; +} diff --git a/wp-admin/css/global.css b/wp-admin/css/global.css index 57b3879c2..bb3179840 100644 --- a/wp-admin/css/global.css +++ b/wp-admin/css/global.css @@ -274,6 +274,7 @@ h3 { h4 { display: block; + font-size: 1em; font-weight: bold; margin: 1.33em 0; } diff --git a/wp-admin/css/ie.css b/wp-admin/css/ie.css index d99e32a9c..3e85af3d1 100644 --- a/wp-admin/css/ie.css +++ b/wp-admin/css/ie.css @@ -188,11 +188,6 @@ input { line-height: 20px; } -#the-comment-list .comment-item, -ul#widget-list li.widget-list-item { - zoom: 100%; -} - #wphead-info { float: right; } @@ -207,7 +202,7 @@ a.button { padding: 4px 6px; } -* html div.widget-liquid-left-holder, +* html div.widget-liquid-left, * html div.widget-liquid-right { display: block; position: relative; @@ -227,6 +222,7 @@ a.button { zoom: 100%; } +#the-comment-list .comment-item, #post-status-info, #wpwrap, #wpcontent, @@ -239,11 +235,13 @@ a.button { #post-body, #editorcontainer, .tablenav, -.widget-control-list, -li.widget-list-control-item, +.widget-liquid-left, +.widget-liquid-right, +#widgets-left, +.widgets-sortables, #dragHelper, -li.widget-list-control-item h4, -.widget-sortable, +.widget .widget-top, +.widget, .widget-control-actions, .tagchecklist, #col-container, @@ -353,3 +351,23 @@ table.ie-fixed { * html .feature-filter .feature-group li { width: 145px; } + +* html .widget-top .widget-title-action a { + background: url("../images/menu-bits.gif") no-repeat scroll 0 -110px; +} + +* html .widget { + border-color: #dfdfdf; +} + +* html div.widget-liquid-left { + width: 99%; +} + +#wp_inactive_widgets { + padding-bottom: 8px; +} + +* html .widgets-sortables { + height: 50px; +} diff --git a/wp-admin/css/widgets-rtl.css b/wp-admin/css/widgets-rtl.css index 8d0fc3aae..b34997222 100644 --- a/wp-admin/css/widgets-rtl.css +++ b/wp-admin/css/widgets-rtl.css @@ -1,14 +1,4 @@ -h4.widget-title span { - float: right; -} -h4.widget-title a { - float: left; - margin-left: 0; - margin-right: 1em; -} -ul#widget-list li.widget-list-item h4.widget-title { - float: right; -} + ul#widget-list li.widget-list-item div.widget-description { margin: 0 200px 0 0; padding: 0 4em 0 0; @@ -19,9 +9,3 @@ ul#widget-list li.widget-list-item div.widget-description { margin-left: 8px; float: right; } -li.widget-list-control-item h4.widget-title a, -#dragHelper li.widget-list-control-item h4.widget-title a, -#draghelper li.widget-list-control-item h4.widget-title a:visited { - right: auto; - left: 1em; -} diff --git a/wp-admin/css/widgets.css b/wp-admin/css/widgets.css index 41db0b33d..de2816dbc 100644 --- a/wp-admin/css/widgets.css +++ b/wp-admin/css/widgets.css @@ -1,25 +1,55 @@ /* 2 column liquid layout */ -div.widget-liquid-left-holder { +div.widget-liquid-left { float: left; clear: left; width: 100%; - margin-right: -310px; + margin-right: -325px; } -div.widget-liquid-left { - margin-right: 320px; +div#widgets-left { + margin-right: 335px; } div.widget-liquid-right { float: right; clear: right; - width: 300px; - position: relative; + width: 320px; } -/* pasitioning etc. */ -form#widgets-filter { - position: relative; +.widgets-sortables li { + width: 300px; + margin: 15px 0 18px; +} + +#widgets-left .widgets-sortables li, +#widgets-left #widget-list li { + float: left; + margin: 0 15px 18px 3px; + width: 300px; +} + +.widget-placeholder { + border-width: 1px; + border-style: dashed; + margin-bottom: 20px; + height: 25px; + width: 298px; +} + +div.widgets-holder-wrap { + padding: 8px 8px 0; + margin: 12px 0; + border-width: 1px; + border-style: solid; + -moz-border-radius: 6px; + -khtml-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; +} + +#widgets-left #available-widgets { + background-color: transparent; + border: 0 none; } div#available-widgets-filter { @@ -31,147 +61,94 @@ ul#widget-list { list-style: none; margin: 0; padding: 0; + min-height: 100px; } -ul#widget-list li.widget-list-item { - padding: .7em 0.9em; - margin: 0; - border-bottom-width: 1px; - border-bottom-style: solid; +.widget .widget-top { + font-size: 12px; + font-weight: bold; line-height: 1; } -h4.widget-title span { - float: left; +.widget-top .widget-title { + margin-right: 30px; + padding: 7px 9px; } -h4.widget-title a { +.widget-top .widget-title-action { float: right; - text-decoration: underline; - border-bottom: none; - margin-left: 1em; } -ul#widget-list li.widget-list-item h4.widget-title { - position: relative; - margin: 0; - padding: .5em 1em; - width: 200px; - float: left; - font-size: 13px; - -moz-border-radius: 3px; - -khtml-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; +.widget-title-action a { + display: block; + width: 24px; + height: 26px; } -#dragHelper h4.widget-title { - padding: .5em 1em; - margin: 0; +.widget-top:hover .widget-title-action a { + background: url("../images/menu-bits.gif") no-repeat scroll 0 -110px; } -ul#widget-list li.widget-list-item div.widget-description { - display: block; - margin: 0 0 0 200px; - padding: 0 0 0 4em; +.widget .widget-inside { + margin: 15px; font-size: 11px; + display: none; } -ul#widget-list li.widget-list-item ul.widget-control-info { +.widget-control, +.widget-description { display: none; } +#available-widgets .widget-description, +.widget-liquid-right .widget-control, +#wp_inactive_widgets .widget-control { + display: block; +} + +.widget .widget-control p { + margin: 0 0 1em; + padding: 0; +} + +.widget-title h4 { + margin: 0; + line-height: 1; +} + +.sidebar-name { + margin: 0 0 12px; + padding: 6px; + cursor: pointer; +} + +.widgets-sortables { + min-height: 50px; +} + +.widget-control-actions { + margin-top: 8px; +} + +.widget-control-actions a { + text-decoration: none; +} + div#sidebar-info { padding: 0 1em; margin-bottom: 1em; font-size: 11px; } -ul.widget-control-list { - list-style: none; - margin: 0; - padding: 0 1em; -} - -div#current-widgets p.submit { - padding: 1em; -} - -li.widget-list-control-item { - margin: 1em 0; - -moz-border-radius: 3px; - -khtml-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; -} - -li.widget-list-control-item h4, -#dragHelper li.widget-list-control-item h4, -li.widget-sortable h4 { - margin: 0; - cursor: move; - font-size: 13px; - padding: 0.4em 0.8em; - position: relative; - -moz-border-radius: 3px; - -khtml-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; -} - -.widget-control-save, -.widget-control-remove { - margin-right: 8px; - float: left; - text-decoration: none; -} - -li.widget-list-control-item h4.widget-title a, -#dragHelper li.widget-list-control-item h4.widget-title a, -#draghelper li.widget-list-control-item h4.widget-title a:visited { - right: 1em; -} - -li.widget-list-control-item h4.widget-title a:hover { +.widget-title a, +.widget-title a:hover { text-decoration: none; border-bottom: none; } -li.widget-list-control-item div.widget-control { - border-width: 0 1px 1px; - border-style: none solid solid; - display: none; - padding: 15px; - font-size: 11px; - position: relative; -} - -li.widget-list-control-item div.widget-control p { - margin: 0 0 1em; - padding: 0; -} - -ul.widget-control-list div.widget-control-actions { - padding: 0.5em 0 0; -} - .widget-control-edit { font-size: 10px; font-weight: normal; } -div#current-widgets { - padding-top: 1em; - border-width: 1px 0 0; - border-style: solid none none; -} -#widget-controls .widefat { - width: 92%; - padding: 3px; -} - -#widget-controls select.widefat { - width: auto; - display: block; -} diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php index 1ddad038f..1c29c55db 100644 --- a/wp-admin/includes/widgets.php +++ b/wp-admin/includes/widgets.php @@ -7,7 +7,7 @@ */ /** - * Display list of widgets, either all or matching search. + * Display list of the available widgets, either all or matching search. * * The search parameter are search terms separated by spaces. * @@ -18,7 +18,8 @@ */ function wp_list_widgets( $show = 'all', $_search = false ) { global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls; - if ( $_search ) { + + if ( $_search ) { // sanitize $search = preg_replace( '/[^\w\s]/', '', $_search ); // array of terms @@ -31,11 +32,11 @@ function wp_list_widgets( $show = 'all', $_search = false ) { $show = 'all'; ?> - -