Add widget management to the customizer.

This brings in the Widget Customizer plugin: https://wordpress.org/plugins/widget-customizer/.

props westonruter, shaunandrews, michael-arestad, johnregan3, akeda, topher1kenobe, topquarky, bobbravo2, ricardocorreia. And for good measure, props westonruter.
see #27112.

Built from https://develop.svn.wordpress.org/trunk@27419


git-svn-id: http://core.svn.wordpress.org/trunk@27266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-03-05 20:41:14 +00:00
parent d23cd0aa50
commit e853a9cc57
11 changed files with 4444 additions and 2 deletions

View File

@ -58,7 +58,7 @@ $core_actions_post = array(
'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment', 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs', 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
'save-user-color-scheme', 'save-user-color-scheme', 'update-widget',
); );
// Register core Ajax calls. // Register core Ajax calls.

View File

@ -0,0 +1,623 @@
.wp-full-overlay-sidebar {
overflow: visible;
}
/**
* Hide all sidebar sections by default, only show them (via JS) once the
* preview loads and we know whether the sidebars are used in the template.
*/
.control-section[id^="accordion-section-sidebar-widgets-"],
.customize-control-sidebar_widgets label,
.customize-control-sidebar_widgets .hide-if-js {
/* The link in .customize-control-sidebar_widgets .hide-if-js will fail if it ever gets used. */
display:none;
}
.customize-control-widget_form .widget-top {
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.customize-control-widget_form:not(.widget-rendered) .widget-top {
opacity: 0.5;
}
.customize-control-widget_form .widget-control-save {
display: none;
}
.customize-control-widget_form .spinner {
display: inline;
opacity: 0.0;
-webkit-transition: opacity 0.1s;
transition: opacity 0.1s;
}
.customize-control-widget_form.previewer-loading .spinner {
opacity: 1.0;
}
.customize-control-widget_form .widget {
margin-bottom: 0;
}
.customize-control-widget_form:not(.wide-widget-control) {
/**
* Prevent plugins (e.g. Widget Visibility in Jetpack) from forcing widget forms
* to be wide and so overflow the customizer panel
*/
right: auto !important;
max-width: 100%;
}
.customize-control-widget_form.wide-widget-control .widget-inside {
position: fixed;
right: 299px;
top: 25%;
padding: 20px;
border: 1px solid rgb(229, 229, 229);
z-index: -1;
}
.customize-control-widget_form.wide-widget-control.collapsing .widget-inside {
z-index: -2;
}
.customize-control-widget_form.wide-widget-control .widget-top {
-webkit-transition: background-color 0.4s;
transition: background-color 0.4s;
}
.customize-control-widget_form.wide-widget-control.expanding .widget-top,
.customize-control-widget_form.wide-widget-control.expanded:not(.collapsing) .widget-top {
background-color: rgb(227, 227, 227);
}
.widget-inside {
padding: 1px 10px 10px 10px;
border-top: none;
line-height: 16px;
}
.widget-top {
cursor: move;
}
.customize-control-widget_form.expanded a.widget-action:after {
content: "\f142";
}
.customize-control-widget_form.wide-widget-control a.widget-action:after {
content: "\f139";
}
.customize-control-widget_form.wide-widget-control.expanded a.widget-action:after {
content: "\f141";
}
.widget-title-action {
cursor: pointer;
}
.customize-control-widget_form .widget .customize-control-title {
cursor: move;
}
/* @todo What does this do? */
.control-section.accordion-section.widget-customizer-highlighted > .accordion-section-title,
.customize-control-widget_form.widget-customizer-highlighted {
outline: none;
-webkit-box-shadow: 0 0 3px #ce0000;
box-shadow: 0 0 3px #ce0000;
}
#widget-customizer-control-templates {
display: none;
}
/* MP6-compat */
#customize-theme-controls .accordion-section-content .widget {
color: black;
}
/**
* Widget reordering styles
**/
.reorder-toggle {
float: left;
padding: 5px 10px;
margin-left: 10px;
text-decoration: none;
cursor: pointer;
outline: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.reorder-toggle:focus {
outline: 1px dotted;
}
.reorder-done,
.reordering .reorder {
display: none;
}
.reordering .reorder-done {
display: block;
color: #aa0000;
}
#customize-theme-controls .reordering .add-new-widget {
opacity: 0.2;
pointer-events: none;
cursor: not-allowed;
}
#customize-theme-controls .widget-reorder-nav {
display: none;
float: left;
background-color: #fafafa;
}
.widget-reorder-nav span {
position: relative;
overflow: hidden;
float: right;
display: block;
width: 33px; /* was 42px for mobile */
height: 43px;
color: #888;
text-indent: -9999px;
cursor: pointer;
outline: none;
}
.widget-reorder-nav span:before {
display: inline-block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
font: normal normal 20px/43px 'Genericons';
text-align: center;
text-indent: 0;
}
.widget-reorder-nav span:hover,
.widget-reorder-nav span:focus {
color: #444;
background: #eee;
}
.move-widget:before {
content: '\f442';
}
.move-widget-down:before {
content: '\f431';
}
.move-widget-up:before {
content: '\f432';
}
#customize-theme-controls .first-widget .move-widget-up,
#customize-theme-controls .last-widget .move-widget-down {
color: #d5d5d5;
cursor: default;
}
#customize-theme-controls .move-widget-area {
display: none;
background: #fff;
border: 1px solid #dedede;
border-top: none;
cursor: auto;
}
#customize-theme-controls .reordering .move-widget-area.active {
display: block;
}
#customize-theme-controls .move-widget-area .description {
margin: 0;
padding: 15px 20px;
font-weight: 400;
}
#customize-theme-controls .widget-area-select {
margin: 0;
padding: 0;
list-style: none;
}
#customize-theme-controls .widget-area-select li {
position: relative;
margin: 0;
padding: 13px 42px 15px 15px;
color: #555;
border-top: 1px solid #eee;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#customize-theme-controls .widget-area-select li:before {
display: none;
content: '\f418';
position: absolute;
top: 10px;
right: 10px;
font-family: 'Genericons';
font-size: 24px;
line-height: 1;
}
#customize-theme-controls .widget-area-select li:last-child {
border-bottom: 1px solid #eee;
}
#customize-theme-controls .widget-area-select .selected {
color: #fff;
text-shadow: 0 -1px 0 rgba(0,0,0,.4);
border-top: 1px solid #207fa1;
background: #2ea2cc;
}
#customize-theme-controls .widget-area-select .selected:before {
display: block;
}
#customize-theme-controls .widget-area-select .selected:last-child {
border-bottom: 1px solid #207fa1;
}
#customize-theme-controls .move-widget-actions {
text-align: left;
padding: 12px;
}
#customize-theme-controls .widget-area-select + li {
border-top: 1px solid #207fa1;
}
#customize-theme-controls .reordering .widget-title-action {
display: none;
}
#customize-theme-controls .reordering .widget-reorder-nav {
display: block;
}
/**
* Styles for new widget addition panel
*/
.wp-full-overlay-main {
left: auto; /* this overrides a right: 0; which causes the preview to resize, I'd rather have it go off screen at the normal size. */
width: 100%;
}
.add-new-widget {
cursor: pointer;
float: left;
-webkit-transition: all 0.2s;
transition: all 0.2s;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-moz-outline: none;
outline: none;
}
.add-new-widget:before {
content: "\f132";
display: inline-block;
position: relative;
right: -2px;
top: -1px;
font: normal 16px/1 'dashicons';
vertical-align: middle;
-webkit-transition: all 0.2s;
transition: all 0.2s;
-webkit-font-smoothing: antialiased;
}
body.adding-widget .add-new-widget,
body.adding-widget .add-new-widget:hover {
background: #EEE;
border-color: #999;
color: #333;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
}
body.adding-widget .add-new-widget:before {
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
#available-widgets .widget {
position: static;
}
/* override widgets admin page rules in wp-admin/css/wp-admin.css */
#widgets-left #available-widgets .widget {
float: none !important;
width: auto !important;
}
#available-widgets {
position: absolute;
overflow: auto;
top: 0;
bottom: 0;
right: -301px;
width: 300px;
margin: 0;
z-index: 1;
background: #fff;
-webkit-transition: all 0.2s;
transition: all 0.2s;
border-left: 1px solid #dddddd;
}
#available-widgets-filter {
padding: 8px 13px 7px 17px;
border-bottom: 1px solid #e4e4e4;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#available-widgets-filter input {
padding: 5px 10px 2px 10px;
width: 100%;
}
#available-widgets .widget-tpl {
position: relative;
padding: 20px 60px 20px 15px;
border-bottom: 1px solid #e4e4e4;
cursor: pointer;
}
#available-widgets .widget-tpl:hover,
#available-widgets .widget-tpl.selected {
background: #fafafa;
}
#available-widgets .widget-top,
#available-widgets .widget-top:hover {
border: none;
background: transparent;
-webkit-box-shadow: none;
box-shadow: none;
}
#available-widgets .widget-title h4 {
padding: 0 0 5px;
font-size: 14px;
}
#available-widgets .widget .widget-description {
padding: 0;
color: #777;
}
#customize-preview {
-webkit-transition: all 0.2s;
transition: all 0.2s;
}
body.adding-widget #available-widgets {
right: 0;
}
body.adding-widget .wp-full-overlay-main {
right: 300px;
}
body.adding-widget #customize-preview {
opacity: 0.4;
}
/** Widget Icon styling **
* No plurals in naming.
* Ordered from lowest to highest specificity.
**/
#available-widgets .widget-title {
position: relative;
}
#available-widgets .widget-title:before {
content:"\f132";
position: absolute;
top: -3px;
left: 100%;
margin-left: 20px;
width: 20px;
height: 20px;
color: #333;
font: normal 20px/1 'dashicons', 'widgeticons';
text-align: center;
-webkit-border-radius: 2px;
border-radius: 2px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
}
/* smiley */
#available-widgets [class*="easy"] .widget-title:before { content: "\f328"; top: -4px; }
/* star-filled */
#available-widgets [class*="super"] .widget-title:before,
#available-widgets [class*="like"] .widget-title:before { content: "\f155"; top: -4px; }
/* wordpress */
#available-widgets [class*="meta"] .widget-title:before { content: "\f120"; }
/* archive-box */
#available-widgets [class*="archives"] .widget-title:before { content: "\f483"; top: -4px; }
/* category */
#available-widgets [class*="categor"] .widget-title:before { content: "\f318"; top: -4px; }
/* comments */
#available-widgets [class*="comment"] .widget-title:before,
#available-widgets [class*="testimonial"] .widget-title:before,
#available-widgets [class*="chat"] .widget-title:before { content: "\f101"; }
/* post */
#available-widgets [class*="post"] .widget-title:before { content: "\f109"; }
/* admin-page */
#available-widgets [class*="page"] .widget-title:before { content: "\f105"; }
/* text */
#available-widgets [class*="text"] .widget-title:before { content: "\f480"; }
/* links */
#available-widgets [class*="link"] .widget-title:before { content: "\f103"; }
/* search */
#available-widgets [class*="search"] .widget-title:before { content: "\f179"; }
/* menu */
#available-widgets [class*="menu"] .widget-title:before,
#available-widgets [class*="nav"] .widget-title:before { content: "\f333"; }
/* tag-cloud */
#available-widgets [class*="tag"] .widget-title:before { content: "\f481"; }
/* rss */
#available-widgets [class*="rss"] .widget-title:before { content: "\f303"; top: -6px; }
/* calendar */
#available-widgets [class*="event"] .widget-title:before,
#available-widgets [class*="calendar"] .widget-title:before { content: "\f145"; top: -4px;}
/* format-image */
#available-widgets [class*="image"] .widget-title:before,
#available-widgets [class*="photo"] .widget-title:before,
#available-widgets [class*="slide"] .widget-title:before,
#available-widgets [class*="instagram"] .widget-title:before { content: "\f128"; }
/* format-gallery */
#available-widgets [class*="album"] .widget-title:before,
#available-widgets [class*="galler"] .widget-title:before { content: "\f161"; }
/* format-video */
#available-widgets [class*="video"] .widget-title:before,
#available-widgets [class*="tube"] .widget-title:before { content: "\f126"; }
/* format-audio */
#available-widgets [class*="music"] .widget-title:before,
#available-widgets [class*="radio"] .widget-title:before,
#available-widgets [class*="audio"] .widget-title:before { content: "\f127"; }
/* admin-users */
#available-widgets [class*="login"] .widget-title:before,
#available-widgets [class*="user"] .widget-title:before,
#available-widgets [class*="member"] .widget-title:before,
#available-widgets [class*="avatar"] .widget-title:before,
#available-widgets [class*="subscriber"] .widget-title:before,
#available-widgets [class*="profile"] .widget-title:before,
#available-widgets [class*="grofile"] .widget-title:before { content: "\f110"; }
/* cart */
#available-widgets [class*="commerce"] .widget-title:before,
#available-widgets [class*="shop"] .widget-title:before,
#available-widgets [class*="cart"] .widget-title:before { content: "\f174"; top: -4px; }
/* shield */
#available-widgets [class*="secur"] .widget-title:before,
#available-widgets [class*="firewall"] .widget-title:before { content: "\f332"; }
/* chart-bar */
#available-widgets [class*="analytic"] .widget-title:before,
#available-widgets [class*="stat"] .widget-title:before,
#available-widgets [class*="poll"] .widget-title:before { content: "\f185"; }
/* feedback */
#available-widgets [class*="form"] .widget-title:before { content: "\f175"; }
/* email-alt */
#available-widgets [class*="subscribe"] .widget-title:before,
#available-widgets [class*="news"] .widget-title:before,
#available-widgets [class*="contact"] .widget-title:before,
#available-widgets [class*="mail"] .widget-title:before { content: "\f466"; }
/* share */
#available-widgets [class*="share"] .widget-title:before,
#available-widgets [class*="socia"] .widget-title:before { content: "\f237"; }
/* translation */
#available-widgets [class*="lang"] .widget-title:before,
#available-widgets [class*="translat"] .widget-title:before { content: "\f326"; }
/* location-alt */
#available-widgets [class*="locat"] .widget-title:before,
#available-widgets [class*="map"] .widget-title:before { content: "\f231"; }
/* download */
#available-widgets [class*="download"] .widget-title:before { content: "\f316"; }
/* cloud */
#available-widgets [class*="weather"] .widget-title:before { content: "\f176"; top: -4px;}
/* facebook */
#available-widgets [class*="facebook"] .widget-title:before { content: "\f304"; }
/* twitter */
#available-widgets [class*="tweet"] .widget-title:before,
#available-widgets [class*="twitter"] .widget-title:before { content: "\f301"; }
@media screen and (max-height: 700px) and (min-width: 981px) {
.customize-control {
margin-bottom: 0;
}
.widget-top {
-webkit-box-shadow: none;
box-shadow: none;
margin-top: -1px;
}
.widget-top:hover {
position: relative;
z-index: 1;
}
.last-widget {
margin-bottom: 15px;
}
.widget-title h4 {
padding: 13px 15px;
}
.widget-top a.widget-action:after {
padding-top: 9px;
}
.widget-reorder-nav span {
height: 39px;
}
.widget-reorder-nav span:before {
line-height: 39px;
}
#customize-theme-controls .widget-area-select li {
padding: 9px 42px 11px 15px;
}
#customize-theme-controls .widget-area-select li:before {
top: 6px;
}
}

View File

@ -0,0 +1,623 @@
.wp-full-overlay-sidebar {
overflow: visible;
}
/**
* Hide all sidebar sections by default, only show them (via JS) once the
* preview loads and we know whether the sidebars are used in the template.
*/
.control-section[id^="accordion-section-sidebar-widgets-"],
.customize-control-sidebar_widgets label,
.customize-control-sidebar_widgets .hide-if-js {
/* The link in .customize-control-sidebar_widgets .hide-if-js will fail if it ever gets used. */
display:none;
}
.customize-control-widget_form .widget-top {
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.customize-control-widget_form:not(.widget-rendered) .widget-top {
opacity: 0.5;
}
.customize-control-widget_form .widget-control-save {
display: none;
}
.customize-control-widget_form .spinner {
display: inline;
opacity: 0.0;
-webkit-transition: opacity 0.1s;
transition: opacity 0.1s;
}
.customize-control-widget_form.previewer-loading .spinner {
opacity: 1.0;
}
.customize-control-widget_form .widget {
margin-bottom: 0;
}
.customize-control-widget_form:not(.wide-widget-control) {
/**
* Prevent plugins (e.g. Widget Visibility in Jetpack) from forcing widget forms
* to be wide and so overflow the customizer panel
*/
left: auto !important;
max-width: 100%;
}
.customize-control-widget_form.wide-widget-control .widget-inside {
position: fixed;
left: 299px;
top: 25%;
padding: 20px;
border: 1px solid rgb(229, 229, 229);
z-index: -1;
}
.customize-control-widget_form.wide-widget-control.collapsing .widget-inside {
z-index: -2;
}
.customize-control-widget_form.wide-widget-control .widget-top {
-webkit-transition: background-color 0.4s;
transition: background-color 0.4s;
}
.customize-control-widget_form.wide-widget-control.expanding .widget-top,
.customize-control-widget_form.wide-widget-control.expanded:not(.collapsing) .widget-top {
background-color: rgb(227, 227, 227);
}
.widget-inside {
padding: 1px 10px 10px 10px;
border-top: none;
line-height: 16px;
}
.widget-top {
cursor: move;
}
.customize-control-widget_form.expanded a.widget-action:after {
content: "\f142";
}
.customize-control-widget_form.wide-widget-control a.widget-action:after {
content: "\f139";
}
.customize-control-widget_form.wide-widget-control.expanded a.widget-action:after {
content: "\f141";
}
.widget-title-action {
cursor: pointer;
}
.customize-control-widget_form .widget .customize-control-title {
cursor: move;
}
/* @todo What does this do? */
.control-section.accordion-section.widget-customizer-highlighted > .accordion-section-title,
.customize-control-widget_form.widget-customizer-highlighted {
outline: none;
-webkit-box-shadow: 0 0 3px #ce0000;
box-shadow: 0 0 3px #ce0000;
}
#widget-customizer-control-templates {
display: none;
}
/* MP6-compat */
#customize-theme-controls .accordion-section-content .widget {
color: black;
}
/**
* Widget reordering styles
**/
.reorder-toggle {
float: right;
padding: 5px 10px;
margin-right: 10px;
text-decoration: none;
cursor: pointer;
outline: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.reorder-toggle:focus {
outline: 1px dotted;
}
.reorder-done,
.reordering .reorder {
display: none;
}
.reordering .reorder-done {
display: block;
color: #aa0000;
}
#customize-theme-controls .reordering .add-new-widget {
opacity: 0.2;
pointer-events: none;
cursor: not-allowed;
}
#customize-theme-controls .widget-reorder-nav {
display: none;
float: right;
background-color: #fafafa;
}
.widget-reorder-nav span {
position: relative;
overflow: hidden;
float: left;
display: block;
width: 33px; /* was 42px for mobile */
height: 43px;
color: #888;
text-indent: -9999px;
cursor: pointer;
outline: none;
}
.widget-reorder-nav span:before {
display: inline-block;
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
font: normal normal 20px/43px 'Genericons';
text-align: center;
text-indent: 0;
}
.widget-reorder-nav span:hover,
.widget-reorder-nav span:focus {
color: #444;
background: #eee;
}
.move-widget:before {
content: '\f442';
}
.move-widget-down:before {
content: '\f431';
}
.move-widget-up:before {
content: '\f432';
}
#customize-theme-controls .first-widget .move-widget-up,
#customize-theme-controls .last-widget .move-widget-down {
color: #d5d5d5;
cursor: default;
}
#customize-theme-controls .move-widget-area {
display: none;
background: #fff;
border: 1px solid #dedede;
border-top: none;
cursor: auto;
}
#customize-theme-controls .reordering .move-widget-area.active {
display: block;
}
#customize-theme-controls .move-widget-area .description {
margin: 0;
padding: 15px 20px;
font-weight: 400;
}
#customize-theme-controls .widget-area-select {
margin: 0;
padding: 0;
list-style: none;
}
#customize-theme-controls .widget-area-select li {
position: relative;
margin: 0;
padding: 13px 15px 15px 42px;
color: #555;
border-top: 1px solid #eee;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#customize-theme-controls .widget-area-select li:before {
display: none;
content: '\f418';
position: absolute;
top: 10px;
left: 10px;
font-family: 'Genericons';
font-size: 24px;
line-height: 1;
}
#customize-theme-controls .widget-area-select li:last-child {
border-bottom: 1px solid #eee;
}
#customize-theme-controls .widget-area-select .selected {
color: #fff;
text-shadow: 0 -1px 0 rgba(0,0,0,.4);
border-top: 1px solid #207fa1;
background: #2ea2cc;
}
#customize-theme-controls .widget-area-select .selected:before {
display: block;
}
#customize-theme-controls .widget-area-select .selected:last-child {
border-bottom: 1px solid #207fa1;
}
#customize-theme-controls .move-widget-actions {
text-align: right;
padding: 12px;
}
#customize-theme-controls .widget-area-select + li {
border-top: 1px solid #207fa1;
}
#customize-theme-controls .reordering .widget-title-action {
display: none;
}
#customize-theme-controls .reordering .widget-reorder-nav {
display: block;
}
/**
* Styles for new widget addition panel
*/
.wp-full-overlay-main {
right: auto; /* this overrides a right: 0; which causes the preview to resize, I'd rather have it go off screen at the normal size. */
width: 100%;
}
.add-new-widget {
cursor: pointer;
float: right;
-webkit-transition: all 0.2s;
transition: all 0.2s;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-moz-outline: none;
outline: none;
}
.add-new-widget:before {
content: "\f132";
display: inline-block;
position: relative;
left: -2px;
top: -1px;
font: normal 16px/1 'dashicons';
vertical-align: middle;
-webkit-transition: all 0.2s;
transition: all 0.2s;
-webkit-font-smoothing: antialiased;
}
body.adding-widget .add-new-widget,
body.adding-widget .add-new-widget:hover {
background: #EEE;
border-color: #999;
color: #333;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
}
body.adding-widget .add-new-widget:before {
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
#available-widgets .widget {
position: static;
}
/* override widgets admin page rules in wp-admin/css/wp-admin.css */
#widgets-left #available-widgets .widget {
float: none !important;
width: auto !important;
}
#available-widgets {
position: absolute;
overflow: auto;
top: 0;
bottom: 0;
left: -301px;
width: 300px;
margin: 0;
z-index: 1;
background: #fff;
-webkit-transition: all 0.2s;
transition: all 0.2s;
border-right: 1px solid #dddddd;
}
#available-widgets-filter {
padding: 8px 17px 7px 13px;
border-bottom: 1px solid #e4e4e4;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#available-widgets-filter input {
padding: 5px 10px 2px 10px;
width: 100%;
}
#available-widgets .widget-tpl {
position: relative;
padding: 20px 15px 20px 60px;
border-bottom: 1px solid #e4e4e4;
cursor: pointer;
}
#available-widgets .widget-tpl:hover,
#available-widgets .widget-tpl.selected {
background: #fafafa;
}
#available-widgets .widget-top,
#available-widgets .widget-top:hover {
border: none;
background: transparent;
-webkit-box-shadow: none;
box-shadow: none;
}
#available-widgets .widget-title h4 {
padding: 0 0 5px;
font-size: 14px;
}
#available-widgets .widget .widget-description {
padding: 0;
color: #777;
}
#customize-preview {
-webkit-transition: all 0.2s;
transition: all 0.2s;
}
body.adding-widget #available-widgets {
left: 0;
}
body.adding-widget .wp-full-overlay-main {
left: 300px;
}
body.adding-widget #customize-preview {
opacity: 0.4;
}
/** Widget Icon styling **
* No plurals in naming.
* Ordered from lowest to highest specificity.
**/
#available-widgets .widget-title {
position: relative;
}
#available-widgets .widget-title:before {
content:"\f132";
position: absolute;
top: -3px;
right: 100%;
margin-right: 20px;
width: 20px;
height: 20px;
color: #333;
font: normal 20px/1 'dashicons', 'widgeticons';
text-align: center;
-webkit-border-radius: 2px;
border-radius: 2px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
}
/* smiley */
#available-widgets [class*="easy"] .widget-title:before { content: "\f328"; top: -4px; }
/* star-filled */
#available-widgets [class*="super"] .widget-title:before,
#available-widgets [class*="like"] .widget-title:before { content: "\f155"; top: -4px; }
/* wordpress */
#available-widgets [class*="meta"] .widget-title:before { content: "\f120"; }
/* archive-box */
#available-widgets [class*="archives"] .widget-title:before { content: "\f483"; top: -4px; }
/* category */
#available-widgets [class*="categor"] .widget-title:before { content: "\f318"; top: -4px; }
/* comments */
#available-widgets [class*="comment"] .widget-title:before,
#available-widgets [class*="testimonial"] .widget-title:before,
#available-widgets [class*="chat"] .widget-title:before { content: "\f101"; }
/* post */
#available-widgets [class*="post"] .widget-title:before { content: "\f109"; }
/* admin-page */
#available-widgets [class*="page"] .widget-title:before { content: "\f105"; }
/* text */
#available-widgets [class*="text"] .widget-title:before { content: "\f480"; }
/* links */
#available-widgets [class*="link"] .widget-title:before { content: "\f103"; }
/* search */
#available-widgets [class*="search"] .widget-title:before { content: "\f179"; }
/* menu */
#available-widgets [class*="menu"] .widget-title:before,
#available-widgets [class*="nav"] .widget-title:before { content: "\f333"; }
/* tag-cloud */
#available-widgets [class*="tag"] .widget-title:before { content: "\f481"; }
/* rss */
#available-widgets [class*="rss"] .widget-title:before { content: "\f303"; top: -6px; }
/* calendar */
#available-widgets [class*="event"] .widget-title:before,
#available-widgets [class*="calendar"] .widget-title:before { content: "\f145"; top: -4px;}
/* format-image */
#available-widgets [class*="image"] .widget-title:before,
#available-widgets [class*="photo"] .widget-title:before,
#available-widgets [class*="slide"] .widget-title:before,
#available-widgets [class*="instagram"] .widget-title:before { content: "\f128"; }
/* format-gallery */
#available-widgets [class*="album"] .widget-title:before,
#available-widgets [class*="galler"] .widget-title:before { content: "\f161"; }
/* format-video */
#available-widgets [class*="video"] .widget-title:before,
#available-widgets [class*="tube"] .widget-title:before { content: "\f126"; }
/* format-audio */
#available-widgets [class*="music"] .widget-title:before,
#available-widgets [class*="radio"] .widget-title:before,
#available-widgets [class*="audio"] .widget-title:before { content: "\f127"; }
/* admin-users */
#available-widgets [class*="login"] .widget-title:before,
#available-widgets [class*="user"] .widget-title:before,
#available-widgets [class*="member"] .widget-title:before,
#available-widgets [class*="avatar"] .widget-title:before,
#available-widgets [class*="subscriber"] .widget-title:before,
#available-widgets [class*="profile"] .widget-title:before,
#available-widgets [class*="grofile"] .widget-title:before { content: "\f110"; }
/* cart */
#available-widgets [class*="commerce"] .widget-title:before,
#available-widgets [class*="shop"] .widget-title:before,
#available-widgets [class*="cart"] .widget-title:before { content: "\f174"; top: -4px; }
/* shield */
#available-widgets [class*="secur"] .widget-title:before,
#available-widgets [class*="firewall"] .widget-title:before { content: "\f332"; }
/* chart-bar */
#available-widgets [class*="analytic"] .widget-title:before,
#available-widgets [class*="stat"] .widget-title:before,
#available-widgets [class*="poll"] .widget-title:before { content: "\f185"; }
/* feedback */
#available-widgets [class*="form"] .widget-title:before { content: "\f175"; }
/* email-alt */
#available-widgets [class*="subscribe"] .widget-title:before,
#available-widgets [class*="news"] .widget-title:before,
#available-widgets [class*="contact"] .widget-title:before,
#available-widgets [class*="mail"] .widget-title:before { content: "\f466"; }
/* share */
#available-widgets [class*="share"] .widget-title:before,
#available-widgets [class*="socia"] .widget-title:before { content: "\f237"; }
/* translation */
#available-widgets [class*="lang"] .widget-title:before,
#available-widgets [class*="translat"] .widget-title:before { content: "\f326"; }
/* location-alt */
#available-widgets [class*="locat"] .widget-title:before,
#available-widgets [class*="map"] .widget-title:before { content: "\f231"; }
/* download */
#available-widgets [class*="download"] .widget-title:before { content: "\f316"; }
/* cloud */
#available-widgets [class*="weather"] .widget-title:before { content: "\f176"; top: -4px;}
/* facebook */
#available-widgets [class*="facebook"] .widget-title:before { content: "\f304"; }
/* twitter */
#available-widgets [class*="tweet"] .widget-title:before,
#available-widgets [class*="twitter"] .widget-title:before { content: "\f301"; }
@media screen and (max-height: 700px) and (min-width: 981px) {
.customize-control {
margin-bottom: 0;
}
.widget-top {
-webkit-box-shadow: none;
box-shadow: none;
margin-top: -1px;
}
.widget-top:hover {
position: relative;
z-index: 1;
}
.last-widget {
margin-bottom: 15px;
}
.widget-title h4 {
padding: 13px 15px;
}
.widget-top a.widget-action:after {
padding-top: 9px;
}
.widget-reorder-nav span {
height: 39px;
}
.widget-reorder-nav span:before {
line-height: 39px;
}
#customize-theme-controls .widget-area-select li {
padding: 9px 15px 11px 42px;
}
#customize-theme-controls .widget-area-select li:before {
top: 6px;
}
}

View File

@ -1587,6 +1587,13 @@ function wp_ajax_save_widget() {
wp_die(); wp_die();
} }
function wp_ajax_update_widget() {
require( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
$GLOBALS['wp_customize'] = new WP_Customize_Manager;
WP_Customize_Widgets::wp_ajax_update_widget();
}
function wp_ajax_upload_attachment() { function wp_ajax_upload_attachment() {
check_ajax_referer( 'media-form' ); check_ajax_referer( 'media-form' );

File diff suppressed because it is too large Load Diff

1
wp-admin/js/customize-widgets.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -813,4 +813,76 @@ class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
foreach ( $this->default_headers as $choice => $header ) foreach ( $this->default_headers as $choice => $header )
$this->print_header_image( $choice, $header ); $this->print_header_image( $choice, $header );
} }
} }
/**
* Widget Area Customize Control Class
*
*/
class WP_Widget_Area_Customize_Control extends WP_Customize_Control {
public $type = 'sidebar_widgets';
public $sidebar_id;
public function to_json() {
parent::to_json();
$exported_properties = array( 'sidebar_id' );
foreach ( $exported_properties as $key ) {
$this->json[ $key ] = $this->$key;
}
}
public function render_content() {
?>
<span class="button-secondary add-new-widget" tabindex="0">
<?php esc_html_e( 'Add a Widget' ); ?>
</span>
<span class="reorder-toggle" tabindex="0">
<span class="reorder"><?php esc_html_e( 'Reorder' ); ?></span>
<span class="reorder-done"><?php esc_html_e( 'Done' ); ?></span>
</span>
<?php
}
}
/**
* Widget Form Customize Control Class
*/
class WP_Widget_Form_Customize_Control extends WP_Customize_Control {
public $type = 'widget_form';
public $widget_id;
public $widget_id_base;
public $sidebar_id;
public $is_new = false;
public $width;
public $height;
public $is_wide = false;
public $is_live_previewable = false;
public function to_json() {
parent::to_json();
$exported_properties = array( 'widget_id', 'widget_id_base', 'sidebar_id', 'width', 'height', 'is_wide', 'is_live_previewable' );
foreach ( $exported_properties as $key ) {
$this->json[ $key ] = $this->$key;
}
}
public function render_content() {
global $wp_registered_widgets;
require_once ABSPATH . '/wp-admin/includes/widgets.php';
$widget = $wp_registered_widgets[ $this->widget_id ];
if ( ! isset( $widget['params'][0] ) ) {
$widget['params'][0] = array();
}
$args = array(
'widget_id' => $widget['id'],
'widget_name' => $widget['name'],
);
$args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
echo WP_Customize_Widgets::get_widget_control( $args );
}
}

View File

@ -61,6 +61,9 @@ final class WP_Customize_Manager {
require( ABSPATH . WPINC . '/class-wp-customize-setting.php' ); require( ABSPATH . WPINC . '/class-wp-customize-setting.php' );
require( ABSPATH . WPINC . '/class-wp-customize-section.php' ); require( ABSPATH . WPINC . '/class-wp-customize-section.php' );
require( ABSPATH . WPINC . '/class-wp-customize-control.php' ); require( ABSPATH . WPINC . '/class-wp-customize-control.php' );
require( ABSPATH . WPINC . '/class-wp-customize-widgets.php' );
WP_Customize_Widgets::setup(); // This should be integrated.
add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) ); add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) );

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
/*global jQuery, WidgetCustomizerPreview_exports */
/*exported WidgetCustomizerPreview */
var WidgetCustomizerPreview = (function ($) {
'use strict';
var self = {
rendered_sidebars: {}, // @todo Make rendered a property of the Backbone model
rendered_widgets: {}, // @todo Make rendered a property of the Backbone model
registered_sidebars: [], // @todo Make a Backbone collection
registered_widgets: {}, // @todo Make array, Backbone collection
widget_selectors: [],
render_widget_ajax_action: null,
render_widget_nonce_value: null,
render_widget_nonce_post_key: null,
preview: null,
i18n: {},
init: function () {
this.buildWidgetSelectors();
this.highlightControls();
self.preview.bind( 'active', function() {
self.preview.send( 'rendered-sidebars', self.rendered_sidebars ); // @todo Only send array of IDs
self.preview.send( 'rendered-widgets', self.rendered_widgets ); // @todo Only send array of IDs
} );
},
/**
* Calculate the selector for the sidebar's widgets based on the registered sidebar's info
*/
buildWidgetSelectors: function () {
$.each( self.registered_sidebars, function ( i, sidebar ) {
var widget_tpl = [
sidebar.before_widget.replace('%1$s', '').replace('%2$s', ''),
sidebar.before_title,
sidebar.after_title,
sidebar.after_widget
].join('');
var empty_widget = $(widget_tpl);
var widget_selector = empty_widget.prop('tagName');
var widget_classes = empty_widget.prop('className').replace(/^\s+|\s+$/g, '');
if ( widget_classes ) {
widget_selector += '.' + widget_classes.split(/\s+/).join('.');
}
self.widget_selectors.push(widget_selector);
});
},
/**
* Obtain a widget instance if it was added to the provided sidebar
* This addresses a race condition where a widget is moved between sidebars
* We cannot use ID selector because jQuery will only return the first one
* that matches. We have to resort to an [id] attribute selector
*
* @param {String} sidebar_id
* @param {String} widget_id
* @return {jQuery}
*/
getSidebarWidgetElement: function ( sidebar_id, widget_id ) {
return $( '[id=' + widget_id + ']' ).filter( function () {
return $( this ).data( 'widget_customizer_sidebar_id' ) === sidebar_id;
} );
},
/**
*
*/
highlightControls: function() {
var selector = this.widget_selectors.join(',');
$(selector).attr( 'title', self.i18n.widget_tooltip );
$(document).on( 'mouseenter', selector, function () {
var control = parent.WidgetCustomizer.getWidgetFormControlForWidget( $(this).prop('id') );
if ( control ) {
control.highlightSectionAndControl();
}
});
// Open expand the widget control when shift+clicking the widget element
$(document).on( 'click', selector, function ( e ) {
if ( ! e.shiftKey ) {
return;
}
e.preventDefault();
var control = parent.WidgetCustomizer.getWidgetFormControlForWidget( $(this).prop('id') );
if ( control ) {
control.focus();
}
});
}
};
$.extend(self, WidgetCustomizerPreview_exports);
/**
* Capture the instance of the Preview since it is private
*/
var OldPreview = wp.customize.Preview;
wp.customize.Preview = OldPreview.extend( {
initialize: function( params, options ) {
self.preview = this;
OldPreview.prototype.initialize.call( this, params, options );
}
} );
// @todo on customize ready?
$(function () {
self.init();
});
return self;
}( jQuery ));

View File

@ -0,0 +1 @@
var WidgetCustomizerPreview=function(a){"use strict";var b={rendered_sidebars:{},rendered_widgets:{},registered_sidebars:[],registered_widgets:{},widget_selectors:[],render_widget_ajax_action:null,render_widget_nonce_value:null,render_widget_nonce_post_key:null,preview:null,i18n:{},init:function(){this.buildWidgetSelectors(),this.highlightControls(),b.preview.bind("active",function(){b.preview.send("rendered-sidebars",b.rendered_sidebars),b.preview.send("rendered-widgets",b.rendered_widgets)})},buildWidgetSelectors:function(){a.each(b.registered_sidebars,function(c,d){var e=[d.before_widget.replace("%1$s","").replace("%2$s",""),d.before_title,d.after_title,d.after_widget].join(""),f=a(e),g=f.prop("tagName"),h=f.prop("className").replace(/^\s+|\s+$/g,"");h&&(g+="."+h.split(/\s+/).join(".")),b.widget_selectors.push(g)})},getSidebarWidgetElement:function(b,c){return a("[id="+c+"]").filter(function(){return a(this).data("widget_customizer_sidebar_id")===b})},highlightControls:function(){var c=this.widget_selectors.join(",");a(c).attr("title",b.i18n.widget_tooltip),a(document).on("mouseenter",c,function(){var b=parent.WidgetCustomizer.getWidgetFormControlForWidget(a(this).prop("id"));b&&b.highlightSectionAndControl()}),a(document).on("click",c,function(b){if(b.shiftKey){b.preventDefault();var c=parent.WidgetCustomizer.getWidgetFormControlForWidget(a(this).prop("id"));c&&c.focus()}})}};a.extend(b,WidgetCustomizerPreview_exports);var c=wp.customize.Preview;return wp.customize.Preview=c.extend({initialize:function(a,d){b.preview=this,c.prototype.initialize.call(this,a,d)}}),a(function(){b.init()}),b}(jQuery);