Ticket #37974: 37974.9.diff
File 37974.9.diff, 44.3 KB (added by , 8 years ago) |
---|
-
src/wp-admin/css/customize-controls.css
687 687 688 688 /* Style for custom settings */ 689 689 690 #customize-control-front_page_sections { 691 border-top: 1px solid #ddd; 692 margin-top: 8px; 693 padding-top: 16px; 694 } 695 690 696 /** 691 697 * Dropdowns 692 698 */ … … 1205 1211 */ 1206 1212 1207 1213 /* higher specificity than .wp-core-ui .button */ 1214 #customize-theme-controls .add-new-item, 1208 1215 #customize-theme-controls .add-new-widget, 1209 1216 #customize-theme-controls .add-new-menu-item { 1210 1217 cursor: pointer; … … 1219 1226 outline: none; 1220 1227 } 1221 1228 1229 .reordering .add-new-item, 1222 1230 .reordering .add-new-widget, 1223 1231 .reordering .add-new-menu-item { 1224 1232 opacity: 0.2; … … 1226 1234 cursor: not-allowed; /* doesn't work in conjunction with pointer-events */ 1227 1235 } 1228 1236 1237 .add-new-item:before, 1229 1238 .add-new-widget:before, 1230 1239 .add-new-menu-item:before, 1231 1240 #available-menu-items .new-content-item .add-content:before { … … 1282 1291 color: #00a0d2; 1283 1292 } 1284 1293 1294 .wp-reorder-nav { 1295 display: none; 1296 background-color: #fff; 1297 position: absolute; 1298 top: 0; 1299 right: 0; 1300 } 1301 1302 .reordering .wp-reorder-nav, 1303 .wp-reorder-nav.is-active { 1304 display: block; 1305 } 1306 1307 .wp-reorder-nav button, 1285 1308 .widget-reorder-nav span, 1286 1309 .menu-item-reorder-nav button { 1287 1310 position: relative; … … 1296 1319 outline: none; 1297 1320 } 1298 1321 1322 .wp-reorder-nav button, 1299 1323 .menu-item-reorder-nav button { 1300 1324 width: 30px; 1301 1325 height: 40px; … … 1305 1329 box-shadow: none; 1306 1330 } 1307 1331 1332 .wp-reorder-nav button:before, 1308 1333 .widget-reorder-nav span:before, 1309 1334 .menu-item-reorder-nav button:before { 1310 1335 display: inline-block; … … 1320 1345 -moz-osx-font-smoothing: grayscale; 1321 1346 } 1322 1347 1348 .wp-reorder-nav button:hover, 1349 .wp-reorder-nav button:focus, 1323 1350 .widget-reorder-nav span:hover, 1324 1351 .widget-reorder-nav span:focus, 1325 1352 .menu-item-reorder-nav button:hover, … … 1328 1355 background: #eee; 1329 1356 } 1330 1357 1358 .wp-reorder-nav button { 1359 width: 33px; 1360 height: 38px; 1361 } 1362 1363 .wp-reorder-nav button:before { 1364 font: normal 20px/38px dashicons; 1365 } 1366 1367 .move-item-down:before, 1331 1368 .move-widget-down:before, 1332 1369 .menus-move-down:before { 1333 1370 content: "\f347"; 1334 1371 } 1335 1372 1373 .move-item-up:before, 1336 1374 .move-widget-up:before, 1337 1375 .menus-move-up:before { 1338 1376 content: "\f343"; … … 1343 1381 .move-up-disabled .menus-move-up, 1344 1382 .move-down-disabled .menus-move-down, 1345 1383 .move-right-disabled .menus-move-right, 1346 .move-left-disabled .menus-move-left { 1384 .move-left-disabled .menus-move-left, 1385 .wp-item:first-child .move-item-up, 1386 .wp-item:last-child .move-item-down { 1347 1387 color: #d5d5d5; 1348 1388 background-color: #fff; 1349 1389 cursor: default; … … 1351 1391 } 1352 1392 1353 1393 /** 1354 * New widget and Add-menu-itemsmodes and panels1394 * New widget, Add-menu-items, and Drawer modes and panels 1355 1395 */ 1356 1396 1357 1397 .wp-full-overlay-main { … … 1359 1399 width: 100%; 1360 1400 } 1361 1401 1402 .customize-control.is-drawer-open .add-new-item, 1403 .customize-control.is-drawer-open .add-new-item:hover, 1362 1404 body.adding-widget .add-new-widget, 1363 1405 body.adding-widget .add-new-widget:hover, 1364 1406 .adding-menu-items .add-new-menu-item, … … 1372 1414 box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); 1373 1415 } 1374 1416 1417 .customize-control.is-drawer-open .add-new-item:before, 1375 1418 body.adding-widget .add-new-widget:before, 1376 1419 .adding-menu-items .add-new-menu-item:before, 1377 1420 #accordion-section-add_menu .add-new-menu-item.open:before { … … 1380 1423 transform: rotate(45deg); 1381 1424 } 1382 1425 1426 .customize-drawer, 1383 1427 #available-widgets, 1384 1428 #available-menu-items { 1385 1429 position: absolute; … … 1398 1442 border-right: 1px solid #ddd; 1399 1443 } 1400 1444 1445 .customize-drawer .customize-section-title, 1401 1446 #available-widgets .customize-section-title, 1402 1447 #available-menu-items .customize-section-title { 1403 1448 display: none; … … 1425 1470 } 1426 1471 1427 1472 /* search field container */ 1473 .search-group, 1428 1474 #available-widgets-filter, 1429 1475 #available-menu-items-search .accordion-section-title { 1430 1476 padding: 13px 15px; … … 1433 1479 box-sizing: border-box; 1434 1480 } 1435 1481 1482 .search-group { 1483 position: relative; 1484 } 1485 1486 .search-group input, 1436 1487 #available-widgets-filter input, 1437 1488 #available-menu-items-search input { 1438 1489 width: 100%; … … 1441 1492 padding: 6px 30px; 1442 1493 } 1443 1494 1495 .search-group input::-ms-clear, 1444 1496 #available-widgets-filter input::-ms-clear, 1445 1497 #available-menu-items-search input::-ms-clear { 1446 1498 display: none; /* remove the "x" in IE, which conflicts with the "x" icon on button.clear-results */ 1447 1499 } 1448 1500 1501 .search-group .search-icon, 1449 1502 #available-menu-items-search .search-icon, 1450 1503 #available-widgets-filter .search-icon { 1451 1504 display: block; … … 1459 1512 color: #72777c; 1460 1513 } 1461 1514 1515 .search-group .clear-results, 1462 1516 #available-widgets-filter .clear-results, 1463 1517 #available-menu-items-search .clear-results { 1464 1518 position: absolute; … … 1475 1529 outline: 0; 1476 1530 } 1477 1531 1532 .search-group .clear-results, 1478 1533 #available-widgets-filter .clear-results, 1479 1534 #available-menu-items-search .clear-results, 1480 1535 #available-menu-items-search.loading .clear-results.is-visible { … … 1481 1536 display: none; 1482 1537 } 1483 1538 1539 .search-group .clear-results.is-visible, 1484 1540 #available-widgets-filter .clear-results.is-visible, 1485 1541 #available-menu-items-search .clear-results.is-visible { 1486 1542 display: block; 1487 1543 } 1488 1544 1545 .search-group .clear-results:before, 1489 1546 #available-widgets-filter .clear-results:before, 1490 1547 #available-menu-items-search .clear-results:before { 1491 1548 content: "\f335"; … … 1495 1552 -moz-osx-font-smoothing: grayscale; 1496 1553 } 1497 1554 1555 .search-group .clear-results:hover, 1556 .search-group .clear-results:focus, 1498 1557 #available-widgets-filter .clear-results:hover, 1499 1558 #available-widgets-filter .clear-results:focus, 1500 1559 #available-menu-items-search .clear-results:hover, … … 1502 1561 color: #dc3232; 1503 1562 } 1504 1563 1564 .search-group .clear-results:focus, 1505 1565 #available-widgets-filter .clear-results:focus, 1506 1566 #available-menu-items-search .clear-results:focus { 1507 1567 -webkit-box-shadow: … … 1512 1572 0 0 2px 1px rgba(30, 140, 190, .8); 1513 1573 } 1514 1574 1575 .search-group .search-icon:after, 1515 1576 #available-menu-items-search .search-icon:after, 1516 1577 #available-widgets-filter .search-icon:after { 1517 1578 content: "\f179"; … … 1521 1582 -moz-osx-font-smoothing: grayscale; 1522 1583 } 1523 1584 1585 .search-group .spinner { 1586 margin: 0; 1587 position: absolute; 1588 top: 20px; 1589 right: 20px; 1590 } 1591 1592 .search-group.is-searching .clear-results { 1593 display: none; 1594 } 1595 1524 1596 .no-widgets-found-message { 1525 1597 display: none; 1526 1598 margin: 0; … … 1558 1630 position: static; 1559 1631 } 1560 1632 1633 .customize-drawer.is-open { 1634 left: 0; 1635 visibility: visible; 1636 } 1561 1637 1638 body.drawer-is-open .wp-full-overlay-main { 1639 left: 300px; 1640 } 1641 1642 body.drawer-is-open #customize-preview { 1643 opacity: 0.4; 1644 } 1645 1646 .ios .customize-drawer { 1647 -webkit-transition: left 0s; 1648 transition: left 0s; 1649 } 1650 1651 .customize-drawer-notice { 1652 padding: 15px; 1653 } 1654 1655 /* Sortable list items. */ 1656 1657 .wp-items-list { 1658 list-style: none; 1659 margin: 0 0 10px 0; 1660 padding: 0; 1661 position: relative; 1662 } 1663 1664 .wp-item { 1665 background: #fff; 1666 margin: -1px 0 0 0; 1667 padding: 0; 1668 } 1669 1670 .wp-item-header { 1671 border: 1px solid #dfdfdf; 1672 background: #fff; 1673 position: relative; 1674 } 1675 1676 .wp-item-delete { 1677 color: #a00; 1678 height: 38px; 1679 position: absolute; 1680 top: 0; 1681 right: 0; 1682 text-align: center; 1683 vertical-align: middle; 1684 width: 33px; 1685 } 1686 1687 .wp-item-delete:hover { 1688 color: #f00; 1689 } 1690 1691 .wp-item-delete:before { 1692 content: "\f335"; 1693 } 1694 1695 .wp-item-title { 1696 cursor: move; 1697 margin: 0; 1698 padding: 10px 20px; 1699 position: relative; 1700 word-wrap: break-word; 1701 } 1702 1703 /* Corner knockout to account for controls */ 1704 .wp-item-title:before { 1705 content: ""; 1706 float: right; 1707 height: 28px; 1708 width: 79px; 1709 } 1710 1711 .wp-item .wp-reorder-nav { 1712 right: 33px; 1713 } 1714 1715 .wp-item.ui-sortable-helper { 1716 background: #f9f9f9; 1717 border: 1px solid #dfdfdf; 1718 } 1719 1720 .wp-item.ui-sortable-placeholder { 1721 background: transparent; 1722 border: 1px dashed #a0a5aa; 1723 margin-top: 0; 1724 margin-bottom: 1px; 1725 } 1726 1727 .wp-item:hover .wp-item-header { 1728 border-color: #999; 1729 z-index: 1; 1730 } 1731 1732 .wp-item.hide-delete .wp-item-delete { 1733 display: none; 1734 } 1735 1736 .wp-item.hide-delete .wp-reorder-nav { 1737 right: 0; 1738 } 1739 1740 /* Corner knockout to account for controls */ 1741 .wp-item.hide-delete .wp-item-title:before { 1742 width: 46px; 1743 } 1744 1745 /* Search results. */ 1746 1747 .search-results { 1748 padding: 1px 0 15px; 1749 } 1750 1751 .search-results ul { 1752 margin: -1px 0 0; 1753 } 1754 1755 .search-results-item { 1756 background: #fff; 1757 border-color: #ddd; 1758 border-style: solid; 1759 border-width: 1px 0; 1760 clear: both; 1761 cursor: pointer; 1762 line-height: 10px; 1763 margin: -1px 0 0 0; 1764 padding: 10px 15px; 1765 position: relative; 1766 } 1767 1768 .search-results-item-title { 1769 display: block; 1770 font-size: 13px; 1771 font-weight: 600; 1772 line-height: 20px; 1773 padding-left: 20px; 1774 word-wrap: break-word; 1775 } 1776 1777 .search-results-item-type { 1778 color: #666; 1779 float: right; 1780 font-size: 12px; 1781 line-height: 20px; 1782 padding-left: 10px; 1783 text-align: right; 1784 } 1785 1786 .search-results-item-add { 1787 color: #82878c; 1788 height: 38px; 1789 position: absolute; 1790 top: 1px; 1791 left: 1px; 1792 width: 30px; 1793 } 1794 1795 .search-results-item-add:before { 1796 -webkit-border-radius: 50%; 1797 border-radius: 50%; 1798 content: "\f543"; 1799 height: 20px; 1800 position: relative; 1801 top: 0; 1802 left: 2px; 1803 } 1804 1805 .search-results-item:hover { 1806 border-color: #999; 1807 color: #0073aa; 1808 z-index: 1; 1809 } 1810 1811 .search-results-item:hover .search-results-item-add:before { 1812 color: #0073aa; 1813 } 1814 1815 .search-results-item.is-selected .search-results-item-add:before { 1816 content: "\f147"; 1817 } 1818 1819 .search-results-item-add, 1820 .wp-item-delete { 1821 cursor: pointer; 1822 display: inline-block; 1823 font-family: dashicons; 1824 font-size: 20px; 1825 -webkit-font-smoothing: antialiased; 1826 font-style: normal; 1827 font-weight: normal; 1828 line-height: 1; 1829 text-align: center; 1830 text-decoration: inherit; 1831 vertical-align: top; 1832 } 1833 1834 .search-results.hide-type-label .search-results-item-type { 1835 display: none; 1836 } 1837 1838 1562 1839 /* Responsive */ 1563 1840 .customize-controls-preview-toggle { 1564 1841 display: none; … … 1679 1956 margin-top: 6px; 1680 1957 } 1681 1958 1959 body.drawer-is-open .customize-drawer, 1682 1960 body.adding-widget div#available-widgets, 1683 1961 body.adding-menu-items div#available-menu-items { 1684 1962 top: 46px; … … 1687 1965 width: 100%; 1688 1966 } 1689 1967 1968 .customize-drawer .customize-section-title, 1690 1969 #available-widgets .customize-section-title, 1691 1970 #available-menu-items .customize-section-title { 1692 1971 display: block; … … 1693 1972 margin: 0; 1694 1973 } 1695 1974 1975 .customize-drawer .customize-section-back, 1696 1976 #available-widgets .customize-section-back, 1697 1977 #available-menu-items .customize-section-back { 1698 1978 height: 69px; 1699 1979 } 1700 1980 1981 .customize-drawer .customize-section-title h3, 1701 1982 #available-widgets .customize-section-title h3, 1702 1983 #available-menu-items .customize-section-title h3 { 1703 1984 font-size: 20px; … … 1712 1993 text-overflow: ellipsis; 1713 1994 } 1714 1995 1996 .customize-drawer .customize-section-title .customize-action, 1715 1997 #available-widgets .customize-section-title .customize-action, 1716 1998 #available-menu-items .customize-section-title .customize-action { 1717 1999 font-size: 13px; -
src/wp-admin/js/customize-post-collection.js
1 (function( wp, $ ) { 2 3 if ( ! wp || ! wp.customize ) { return; } 4 5 var api = wp.customize; 6 7 api.PostCollection = api.PostCollection || {}; 8 9 api.DrawerModel = Backbone.Model.extend({ 10 defaults: { 11 status: 'closed' 12 }, 13 14 close: function() { 15 this.set( 'status', 'closed' ); 16 }, 17 18 open: function() { 19 this.set( 'status', 'open' ); 20 }, 21 22 toggle: function() { 23 if ( 'open' === this.get( 'status' ) ) { 24 this.close(); 25 } else { 26 this.open(); 27 } 28 } 29 }); 30 31 api.DrawerManager = Backbone.Collection.extend({ 32 model: api.DrawerModel, 33 34 initialize: function() { 35 this.on( 'change:status', this.closeOtherDrawers ); 36 }, 37 38 closeOtherDrawers: function( model ) { 39 if ( 'open' === model.get( 'status' ) ) { 40 _.chain( this.models ).without( model ).invoke( 'close' ); 41 } 42 } 43 }); 44 45 api.DrawerView = wp.Backbone.View.extend({ 46 tagName: 'div', 47 className: 'customize-drawer', 48 49 initialize: function( options ) { 50 this.controller = options.controller; 51 this.listenTo( this.controller, 'change:status', this.updateStatusClass ); 52 }, 53 54 updateStatusClass: function() { 55 if ( 'open' === this.controller.get( 'status' ) ) { 56 this.$el.addClass( 'is-open' ); 57 } else { 58 this.$el.removeClass( 'is-open' ); 59 } 60 } 61 }); 62 63 api.PostCollection.CustomizeSectionTitleView = wp.Backbone.View.extend({ 64 className: 'customize-section-title', 65 template: wp.template( 'customize-section-title' ), 66 67 events: { 68 'click .customize-section-back': 'closeDrawer' 69 }, 70 71 initialize: function( options ) { 72 this.control = options.control; 73 }, 74 75 render: function() { 76 var data = { 77 label: this.control.params.label, 78 l10n: this.control.l10n 79 }; 80 81 this.$el.html( this.template( data ) ); 82 83 return this; 84 }, 85 86 closeDrawer: function( e ) { 87 e.preventDefault(); 88 this.control.drawer.close(); 89 } 90 }); 91 92 api.PostCollection.PostModel = Backbone.Model.extend({ 93 defaults: { 94 title: '', 95 order: 0 96 } 97 }); 98 99 api.PostCollection.PostsCollection = Backbone.Collection.extend({ 100 model: api.PostCollection.PostModel, 101 102 comparator: function( post ) { 103 return parseInt( post.get( 'order' ), 10 ); 104 } 105 }); 106 107 api.PostCollection.ControlView = wp.Backbone.View.extend({ 108 initialize: function( options ) { 109 this.control = options.control; 110 this.setting = options.setting; 111 112 this.listenTo( this.collection, 'add remove reset sort', this.updateSetting ); 113 this.listenTo( this.control.drawer, 'change:status', this.maybeTriggerSearch ); 114 this.listenTo( this.control.drawer, 'change:status', this.updateStatusClass ); 115 }, 116 117 render: function() { 118 this.views.add([ 119 new api.PostCollection.ItemListView({ 120 collection: this.collection, 121 control: this.control, 122 parent: this 123 }), 124 new api.PostCollection.AddNewItemButtonView({ 125 control: this.control 126 }) 127 ]); 128 129 return this; 130 }, 131 132 maybeTriggerSearch: function() { 133 if ( 'open' === this.control.drawer.get( 'status' ) && this.control.results.length < 1 ) { 134 this.control.search(); 135 } 136 }, 137 138 updateSetting: function() { 139 var postIds = this.collection.sort({ silent: true }).pluck( 'id' ).join( ',' ); 140 this.setting.set( postIds ); 141 }, 142 143 updateStatusClass: function() { 144 if ( 'open' === this.control.drawer.get( 'status' ) ) { 145 this.$el.addClass( 'is-drawer-open' ); 146 } else { 147 this.$el.removeClass( 'is-drawer-open' ); 148 } 149 } 150 }); 151 152 api.PostCollection.AddNewItemButtonView = wp.Backbone.View.extend({ 153 className: 'add-new-item button button-secondary alignright', 154 tagName: 'button', 155 156 events: { 157 click: 'toggleDrawer' 158 }, 159 160 initialize: function( options ) { 161 this.control = options.control; 162 }, 163 164 render: function() { 165 this.$el.text( this.control.l10n.addPosts ); 166 return this; 167 }, 168 169 toggleDrawer: function( e ) { 170 e.preventDefault(); 171 this.control.drawer.toggle(); 172 } 173 }); 174 175 api.PostCollection.ItemListView = wp.Backbone.View.extend({ 176 className: 'wp-items-list', 177 tagName: 'ol', 178 179 initialize: function( options ) { 180 var view = this; 181 182 this.control = options.control; 183 184 this.listenTo( this.collection, 'add', this.addItem ); 185 this.listenTo( this.collection, 'add remove', this.updateOrder ); 186 this.listenTo( this.collection, 'reset', this.render ); 187 }, 188 189 render: function() { 190 this.$el.empty(); 191 this.collection.each( this.addItem, this ); 192 this.initializeSortable(); 193 return this; 194 }, 195 196 initializeSortable: function() { 197 this.$el.sortable({ 198 axis: 'y', 199 delay: 150, 200 forceHelperSize: true, 201 forcePlaceholderSize: true, 202 opacity: 0.6, 203 start: function( e, ui ) { 204 ui.placeholder.css( 'visibility', 'visible' ); 205 }, 206 update: _.bind(function() { 207 this.updateOrder(); 208 }, this ) 209 }); 210 }, 211 212 addItem: function( item ) { 213 var itemView = new api.PostCollection.ItemView({ 214 control: this.control, 215 model: item, 216 parent: this 217 }); 218 219 this.$el.append( itemView.render().el ); 220 }, 221 222 moveDown: function( model ) { 223 var index = this.collection.indexOf( model ), 224 $items = this.$el.children(); 225 226 if ( index < this.collection.length - 1 ) { 227 $items.eq( index ).insertAfter( $items.eq( index + 1 ) ); 228 this.updateOrder(); 229 wp.a11y.speak( this.control.l10n.movedDown ); 230 } 231 }, 232 233 moveUp: function( model ) { 234 var index = this.collection.indexOf( model ), 235 $items = this.$el.children(); 236 237 if ( index > 0 ) { 238 $items.eq( index ).insertBefore( $items.eq( index - 1 ) ); 239 this.updateOrder(); 240 wp.a11y.speak( this.control.l10n.movedUp ); 241 } 242 }, 243 244 updateOrder: function() { 245 _.each( this.$el.find( 'li' ), function( item, i ) { 246 var id = $( item ).data( 'post-id' ); 247 this.collection.get( id ).set( 'order', i ); 248 }, this ); 249 250 this.collection.sort(); 251 } 252 }); 253 254 api.PostCollection.ItemView = wp.Backbone.View.extend({ 255 tagName: 'li', 256 className: 'wp-item', 257 template: wp.template( 'wp-item' ), 258 259 events: { 260 'click .js-remove': 'destroy', 261 'click .move-item-up': 'moveUp', 262 'click .move-item-down': 'moveDown' 263 }, 264 265 initialize: function( options ) { 266 this.control = options.control; 267 this.parent = options.parent; 268 this.listenTo( this.model, 'destroy', this.remove ); 269 }, 270 271 render: function() { 272 var isFrontPage = this.model.get( 'id' ) == api( 'page_on_front' )(), 273 canDelete = ! this.control.params.includeFrontPage || ! isFrontPage, 274 data = _.extend( this.model.toJSON(), { 275 l10n: this.control.l10n, 276 includeFrontPage: this.control.params.includeFrontPage, 277 showDeleteButton: canDelete 278 }); 279 280 this.$el.html( this.template( data ) ); 281 this.$el.data( 'post-id', this.model.get( 'id' ) ); 282 283 if ( ! canDelete ) { 284 this.$el.addClass( 'hide-delete' ); 285 } 286 287 return this; 288 }, 289 290 moveDown: function( e ) { 291 e.preventDefault(); 292 this.parent.moveDown( this.model ); 293 }, 294 295 moveUp: function( e ) { 296 e.preventDefault(); 297 this.parent.moveUp( this.model ); 298 }, 299 300 /** 301 * Destroy the view's model. 302 * 303 * Avoid syncing to the server by triggering an event instead of 304 * calling destroy() directly on the model. 305 */ 306 destroy: function() { 307 this.model.trigger( 'destroy', this.model ); 308 }, 309 310 remove: function() { 311 this.$el.remove(); 312 } 313 }); 314 315 api.PostCollection.DrawerNoticeView = wp.Backbone.View.extend({ 316 tagName: 'div', 317 className: 'customize-drawer-notice', 318 319 initialize: function( options ) { 320 this.control = options.control; 321 this.listenTo( this.control.state, 'change:notice', this.render ); 322 }, 323 324 render: function() { 325 var notice = this.control.state.get( 'notice' ); 326 this.$el.toggle( !! notice.length ).text( notice ); 327 return this; 328 } 329 }); 330 331 api.PostCollection.SearchGroupView = wp.Backbone.View.extend({ 332 tagName: 'div', 333 className: 'search-group', 334 template: wp.template( 'search-group' ), 335 336 events: { 337 'click .clear-results' : 'clearResults', 338 'input input': 'search' 339 }, 340 341 initialize: function( options ) { 342 this.control = options.control; 343 this.listenTo( this.collection, 'add remove reset', this.updateClearResultsVisibility ); 344 }, 345 346 render: function() { 347 this.$el.html( this.template({ l10n: this.control.l10n }) ); 348 this.$clearResults = this.$( '.clear-results' ); 349 this.$field = this.$( '.search-group-field' ); 350 this.$spinner = this.$el.append( '<span class="search-group-spinner spinner" />' ).find( '.spinner' ); 351 this.updateClearResultsVisibility(); 352 return this; 353 }, 354 355 clearResults: function() { 356 this.collection.reset(); 357 this.$field.val( '' ).trigger( 'input' ).focus(); 358 }, 359 360 search: function() { 361 var view = this; 362 363 this.$el.addClass( 'is-searching' ); 364 this.$spinner.addClass( 'is-active' ); 365 366 clearTimeout( this.timeout ); 367 this.timeout = setTimeout(function() { 368 view.control.search( view.$field.val() ) 369 .always(function() { 370 view.$el.removeClass( 'is-searching' ); 371 view.$spinner.removeClass( 'is-active' ); 372 }); 373 }, 300 ); 374 }, 375 376 updateClearResultsVisibility: function() { 377 this.$clearResults.toggleClass( 'is-visible', !! this.collection.length && '' !== this.$field.val() ); 378 } 379 }); 380 381 api.PostCollection.SearchResultsView = wp.Backbone.View.extend({ 382 tagName: 'div', 383 className: 'search-results', 384 385 initialize: function( options ) { 386 this.control = options.control; 387 this.listenTo( this.collection, 'reset', this.render ); 388 }, 389 390 render: function() { 391 this.$list = this.$el.html( '<ul />' ).find( 'ul' ); 392 this.$el.toggleClass( 'hide-type-label', 1 === this.control.params.postTypes.length ); 393 394 if ( this.collection.length ) { 395 this.collection.each( this.addItem, this ); 396 } else { 397 this.$el.empty(); 398 } 399 400 return this; 401 }, 402 403 addItem: function( model ) { 404 this.views.add( 'ul', new api.PostCollection.SearchResultView({ 405 control: this.control, 406 model: model 407 })); 408 } 409 }); 410 411 api.PostCollection.SearchResultView = wp.Backbone.View.extend({ 412 tagName: 'li', 413 className: 'search-results-item', 414 template: wp.template( 'search-result' ), 415 416 events: { 417 'click': 'addItem' 418 }, 419 420 initialize: function( options ) { 421 this.control = options.control; 422 this.listenTo( this.control.posts, 'add remove reset', this.updateSelectedClass ); 423 }, 424 425 render: function() { 426 var data = _.extend( this.model.toJSON(), { 427 l10n: this.control.l10n 428 }); 429 430 this.$el.html( this.template( data ) ); 431 this.updateSelectedClass(); 432 433 return this; 434 }, 435 436 addItem: function() { 437 this.control.posts.add( this.model ); 438 }, 439 440 updateSelectedClass: function() { 441 this.$el.toggleClass( 'is-selected', !! this.control.posts.findWhere({ id: this.model.get( 'id' ) }) ); 442 } 443 }); 444 445 api.PostCollection.PostCollectionControl = api.Control.extend({ 446 ready: function() { 447 var controlView, drawerView, 448 control = this, 449 section = api.section( this.section() ); 450 451 this.drawer = new api.DrawerModel(); 452 api.drawerManager.add( this.drawer ); 453 454 this.posts = new api.PostCollection.PostsCollection( this.params.posts ); 455 this.results = new api.PostCollection.PostsCollection(); 456 delete this.params.posts; 457 458 this.l10n = this.params.l10n; 459 delete this.params.l10n; 460 461 this.state = new Backbone.Model({ 462 notice: '' 463 }); 464 465 if ( this.params.includeFrontPage ) { 466 // Add the front page when it changes. 467 api( 'page_on_front', function( setting ) { 468 setting.bind( _.bind( control.onPageOnFrontChange, control ) ); 469 }); 470 } 471 472 controlView = new api.PostCollection.ControlView({ 473 el: this.container, 474 collection: this.posts, 475 control: this, 476 data: this.params, 477 setting: this.setting 478 }); 479 480 controlView.render(); 481 482 drawerView = new api.DrawerView({ 483 controller: this.drawer 484 }); 485 486 drawerView.views.set([ 487 new api.PostCollection.CustomizeSectionTitleView({ 488 control: this 489 }), 490 new api.PostCollection.SearchGroupView({ 491 collection: this.results, 492 control: this 493 }), 494 new api.PostCollection.DrawerNoticeView({ 495 control: this 496 }), 497 new api.PostCollection.SearchResultsView({ 498 collection: this.results, 499 control: this 500 }) 501 ]); 502 503 $( '.wp-full-overlay' ).append( drawerView.render().$el ); 504 505 section.expanded.bind(function( isOpen ) { 506 if ( ! isOpen ) { 507 control.drawer.close(); 508 } 509 }); 510 }, 511 512 onPageOnFrontChange: function( value ) { 513 var id = parseInt( value, 10 ), 514 posts = this.posts.toJSON(), 515 pageOnFrontControl = api.control( 'page_on_front' ); 516 517 if ( id > 1 && ! this.posts.findWhere({ id: id }) ) { 518 posts.unshift({ 519 id: id, 520 title: pageOnFrontControl.container.find( 'option:selected' ).text() 521 }); 522 } 523 524 // Reset the collection to re-render the view. 525 this.posts.reset( posts ); 526 }, 527 528 search: function( query ) { 529 var args = {}, 530 control = this; 531 532 args = { 533 s: query, 534 post_types: this.params.postTypes, 535 not_in: [], 536 wp_customize: 'on', 537 _ajax_nonce: this.params.searchNonce 538 }; 539 540 if ( 'front_page_sections' === this.setting.id ) { 541 //args.not_in.push( api( 'page_on_front' )() ); 542 } 543 544 return wp.ajax.post( 'customize_find_posts', args ) 545 .done(function( response ) { 546 control.results.reset( response ); 547 control.state.set( 'notice', '' ); 548 }) 549 .fail(function( response ) { 550 control.results.reset(); 551 control.state.set( 'notice', response ); 552 }); 553 } 554 }); 555 556 /** 557 * Extends wp.customize.controlConstructor with control constructor for 558 * post_collection. 559 */ 560 $.extend( api.controlConstructor, { 561 post_collection: api.PostCollection.PostCollectionControl 562 }); 563 564 /** 565 * Create a global drawer manager. 566 */ 567 api.drawerManager = new api.DrawerManager(); 568 569 /** 570 * Toggle an HTML class on the body when drawers are opened or closed. 571 */ 572 $( document ).ready(function() { 573 var $body = $( document.body ); 574 575 api.drawerManager.on( 'change:status', function() { 576 if ( api.drawerManager.findWhere({ status: 'open' }) ) { 577 $body.addClass( 'drawer-is-open' ); 578 } else { 579 $body.removeClass( 'drawer-is-open' ); 580 } 581 }); 582 }); 583 584 /** 585 * Toggle the front page sections control when front page settings change. 586 */ 587 api.bind( 'ready', function() { 588 api( 'show_on_front', 'page_on_front', function( showOnFront, pageOnFront ) { 589 var control = api.control( 'front_page_sections' ); 590 591 function toggleFrontPageSectionsControl() { 592 var isVisible = 'page' === showOnFront() && parseInt( pageOnFront() ) > 0; 593 control.container.toggle( isVisible ); 594 }; 595 596 if ( control ) { 597 showOnFront.bind( toggleFrontPageSectionsControl ); 598 pageOnFront.bind( toggleFrontPageSectionsControl ); 599 } 600 }); 601 }); 602 603 })( window.wp, jQuery ); -
src/wp-includes/canonical.php
655 655 exit; 656 656 } 657 657 } 658 659 /** 660 * Redirect front page section permalinks to the fragment on the front page. 661 * 662 * @since 4.7.0 663 */ 664 function wp_redirect_front_page_sections() { 665 $object_id = get_queried_object_id(); 666 667 if ( 668 ! current_theme_supports( 'front-page-sections' ) 669 || is_front_page() 670 || is_home() 671 || ! is_singular() 672 || ! is_front_page_section( $object_id ) 673 ) { 674 return; 675 } 676 677 wp_redirect( get_front_page_section_url( $object_id ) ); 678 exit; 679 } -
src/wp-includes/class-wp-customize-manager.php
227 227 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php' ); 228 228 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php' ); 229 229 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-control.php' ); 230 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-post-collection-control.php' ); 230 231 231 232 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menus-panel.php' ); 232 233 … … 289 290 290 291 add_action( 'wp_ajax_customize_save', array( $this, 'save' ) ); 291 292 add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) ); 293 add_action( 'wp_ajax_customize_find_posts', array( $this, 'ajax_find_posts' ) ); 292 294 293 295 add_action( 'customize_register', array( $this, 'register_controls' ) ); 294 296 add_action( 'customize_register', array( $this, 'register_dynamic_settings' ), 11 ); // allow code to create settings first … … 1970 1972 $this->register_control_type( 'WP_Customize_Cropped_Image_Control' ); 1971 1973 $this->register_control_type( 'WP_Customize_Site_Icon_Control' ); 1972 1974 $this->register_control_type( 'WP_Customize_Theme_Control' ); 1975 $this->register_control_type( 'WP_Customize_Post_Collection_Control' ); 1973 1976 1974 1977 /* Themes */ 1975 1978 … … 2302 2305 'section' => 'static_front_page', 2303 2306 'type' => 'dropdown-pages', 2304 2307 ) ); 2308 2309 if ( current_theme_supports( 'front-page-sections' ) ) { 2310 $this->add_setting( 'front_page_sections', array( 2311 'sanitize_callback' => array( $this, 'sanitize_id_list' ), 2312 ) ); 2313 2314 $this->add_control( new WP_Customize_Post_Collection_Control( $this, 'front_page_sections', array( 2315 'label' => __( 'Front page sections' ), 2316 'description' => '', 2317 'section' => 'static_front_page', 2318 'settings' => 'front_page_sections', 2319 'post_types' => get_theme_support( 'front-page-sections', 'post_types' ), 2320 'include_front_page' => true, 2321 'l10n' => array( 2322 'addPost' => __( 'Add Section' ), 2323 'addPosts' => __( 'Add Sections' ), 2324 'movedUp' => __( 'Section moved up' ), 2325 'movedDown' => __( 'Section moved down' ), 2326 'removePost' => __( 'Remove Section' ), 2327 'searchPosts' => __( 'Search Sections' ), 2328 'searchPostsPlaceholder' => __( 'Search sections…' ), 2329 ), 2330 ) ) ); 2331 } 2305 2332 } 2306 2333 2307 2334 /** … … 2381 2408 public function _render_custom_logo_partial() { 2382 2409 return get_custom_logo(); 2383 2410 } 2411 2412 /** 2413 * Ajax handler for finding posts. 2414 * 2415 * @since 4.7.0 2416 * 2417 * @see wp_ajax_find_posts() 2418 */ 2419 public function ajax_find_posts() { 2420 check_ajax_referer( 'find-posts' ); 2421 2422 $post_types = array(); 2423 2424 if ( ! empty( $_POST['post_types'] ) ) { 2425 $post_type_names = array_map( 'sanitize_text_field', wp_unslash( $_POST['post_types'] ) ); 2426 foreach ( $post_type_names as $post_type ) { 2427 $post_types[ $post_type ] = get_post_type_object( $post_type ); 2428 } 2429 } 2430 2431 if ( empty( $post_types ) ) { 2432 $post_types['post'] = get_post_type_object( 'post' ); 2433 } 2434 2435 $args = array( 2436 'post_type' => array_keys( $post_types ), 2437 'post_status' => 'publish', 2438 'post__not_in' => isset( $_POST['not_in'] ) ? wp_parse_id_list( $_POST['not_in'] ) : array(), 2439 'posts_per_page' => 50, 2440 ); 2441 2442 if ( ! empty( $_POST['s'] ) ) { 2443 $args['s'] = sanitize_text_field( wp_unslash( $_POST['s'] ) ); 2444 } 2445 2446 $posts = get_posts( $args ); 2447 2448 if ( ! $posts ) { 2449 wp_send_json_error( __( 'No results found.' ) ); 2450 } 2451 2452 foreach ( $posts as $post ) { 2453 $data[] = array( 2454 'id' => $post->ID, 2455 'title' => $post->post_title, 2456 'type' => get_post_type_object( $post->post_type )->labels->singular_name, 2457 ); 2458 } 2459 2460 wp_send_json_success( $data ); 2461 } 2462 2463 /** 2464 * Sanitization callback for lists of IDs. 2465 * 2466 * @since 4.7.0 2467 * 2468 * @param string $value Setting value. 2469 * @return string Comma-separated list of IDs. 2470 */ 2471 public function sanitize_id_list( $value ) { 2472 return implode( ',', array_unique( array_filter( wp_parse_id_list( $value ) ) ) ); 2473 } 2384 2474 } -
src/wp-includes/class-wp-query.php
487 487 private $compat_methods = array( 'init_query_flags', 'parse_tax_query' ); 488 488 489 489 /** 490 * Whether we're currently showing a static front page with sections. 491 * 492 * @since 4.7.0 493 * @access private 494 * @var boolean 495 */ 496 private $front_page_with_sections = false; 497 498 /** 490 499 * Resets query flags to false. 491 500 * 492 501 * The query flags are what page info WordPress was able to figure out. … … 521 530 $this->is_robots = false; 522 531 $this->is_posts_page = false; 523 532 $this->is_post_type_archive = false; 533 $this->front_page_with_sections = false; 524 534 } 525 535 526 536 /** … … 974 984 $qv['page'] = $qv['paged']; 975 985 unset($qv['paged']); 976 986 } 987 // Add section pages, if they exist. 988 $front_page_sections = array_filter( wp_parse_id_list( get_theme_mod( 'front_page_sections' ) ) ); 989 if ( $front_page_sections ) { 990 $this->front_page_with_sections = true; 991 if ( ! in_array( $qv['page_id'], $front_page_sections ) ) { 992 array_unshift( $front_page_sections, $qv['page_id'] ); 993 } 994 unset( $qv['page_id'] ); 995 996 $qv['post__in'] = $front_page_sections; 997 $qv['orderby'] = 'post__in'; 998 } 977 999 } 978 1000 } 979 1001 … … 1005 1027 } 1006 1028 } 1007 1029 1008 if ( $qv['page_id']) {1030 if ( ! empty( $qv['page_id'] ) ) { 1009 1031 if ( 'page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts') ) { 1010 1032 $this->is_page = false; 1011 1033 $this->is_home = true; … … 2994 3016 if ( $q['cache_results'] ) 2995 3017 update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']); 2996 3018 2997 $this->post = reset( $this->posts ); 3019 if ( $this->front_page_with_sections ) { 3020 $this->post = reset( $this->posts ); 3021 do { 3022 if ( $this->post && $this->post->ID == get_option( 'page_on_front' ) ) { 3023 reset( $this->posts ); 3024 break; 3025 } 3026 } while ( $this->post = next( $this->posts ) ); 3027 if ( ! $this->post ) { 3028 $this->post = reset( $this->posts ); 3029 } 3030 } else { 3031 $this->post = reset( $this->posts ); 3032 } 2998 3033 } else { 2999 3034 $this->post_count = 0; 3000 3035 $this->posts = array(); -
src/wp-includes/customize/class-wp-customize-post-collection-control.php
1 <?php 2 /** 3 * Customize API: WP_Customize_Post_Collection_Control class 4 * 5 * @package WordPress 6 * @subpackage Customize 7 * @since 4.7.0 8 */ 9 10 /** 11 * Customize Post Collection Control class. 12 * 13 * @since 4.7.0 14 * 15 * @see WP_Customize_Control 16 */ 17 class WP_Customize_Post_Collection_Control extends WP_Customize_Control { 18 /** 19 * Control type. 20 * 21 * @since 4.7.0 22 * @var string 23 */ 24 public $type = 'post_collection'; 25 26 /** 27 * Post types that can be added as sections. 28 * 29 * @since 4.7.0 30 * @var array 31 */ 32 public $post_types = array( 'page', 'post' ); 33 34 /** 35 * Whether to include the front page in the post collection. 36 * 37 * @since 4.7.0 38 * @var bool 39 */ 40 public $include_front_page = false; 41 42 /** 43 * Localization strings. 44 * 45 * @since 4.7.0 46 * @access public 47 * @var array 48 */ 49 public $l10n = array(); 50 51 /** 52 * Constructor. 53 * 54 * @since 4.7.0 55 * 56 * @param WP_Customize_Manager $manager Customizer bootstrap instance. 57 * @param string $id Control ID. 58 * @param array $args Optional. Arguments to override class property defaults. 59 */ 60 public function __construct( $manager, $id, $args = array() ) { 61 parent::__construct( $manager, $id, $args ); 62 63 $this->l10n = wp_parse_args( $this->l10n, array( 64 'addPost' => __( 'Add Post' ), 65 'addPosts' => __( 'Add Posts' ), 66 'clearResults' => __( 'Clear Results' ), 67 'moveUp' => __( 'Move up' ), 68 'moveDown' => __( 'Move down' ), 69 'movedUp' => __( 'Post moved up' ), 70 'movedDown' => __( 'Post moved down' ), 71 'removePost' => __( 'Remove Post' ), 72 'searchPosts' => __( 'Search Posts' ), 73 'searchPostsPlaceholder' => __( 'Search posts…' ), 74 ) ); 75 } 76 77 /** 78 * Enqueue control related scripts/styles. 79 * 80 * @since 4.7.0 81 */ 82 public function enqueue() { 83 wp_enqueue_style( 'customize-post-collection' ); 84 wp_enqueue_script( 'customize-post-collection' ); 85 86 add_action( 'customize_controls_print_footer_scripts', array( 'WP_Customize_Post_Collection_Control', 'print_templates' ) ); 87 } 88 89 /** 90 * Refresh the parameters passed to the JavaScript via JSON. 91 * 92 * @since 4.7.0 93 * @uses WP_Customize_Control::to_json() 94 */ 95 public function to_json() { 96 parent::to_json(); 97 98 $this->json['l10n'] = $this->l10n; 99 $this->json['posts'] = $this->get_posts(); 100 $this->json['postTypes'] = $this->post_types; 101 $this->json['includeFrontPage'] = $this->include_front_page; 102 $this->json['searchNonce'] = wp_create_nonce( 'find-posts' ); 103 } 104 105 /** 106 * Don't render any content for this control from PHP. 107 * 108 * @since 4.7.0 109 * 110 * @see WP_Customize_Post_Collection_Control::content_template() 111 */ 112 public function render_content() {} 113 114 /** 115 * An Underscore (JS) template for this control's content (but not its container). 116 * 117 * @see WP_Customize_Control::print_template() 118 * 119 * @since 4.7.0 120 */ 121 protected function content_template() { 122 ?> 123 <label> 124 <# if ( data.label ) { #> 125 <span class="customize-control-title">{{ data.label }}</span> 126 <# } #> 127 <# if ( data.description ) { #> 128 <span class="description customize-control-description">{{{ data.description }}}</span> 129 <# } #> 130 </label> 131 <?php 132 } 133 134 /** 135 * Print JavaScript templates in the Customizer footer. 136 * 137 * @since 4.7.0 138 */ 139 public static function print_templates() { 140 ?> 141 <script type="text/html" id="tmpl-wp-item"> 142 <div class="wp-item-header"> 143 <h4 class="wp-item-title"><span>{{ data.title }}</span></h4> 144 145 <# if ( data.showDeleteButton ) { #> 146 <button type="button" class="wp-item-delete button-link js-remove"> 147 <span class="screen-reader-text">{{ data.l10n.removePost }}</span> 148 </button> 149 <# } #> 150 151 <div class="wp-reorder-nav is-active"> 152 <button class="move-item-down" tabindex="0">{{ data.l10n.moveDown }}</button> 153 <button class="move-item-up" tabindex="0">{{ data.l10n.moveUp }}</button> 154 </div> 155 </div> 156 </script> 157 158 <script type="text/html" id="tmpl-customize-section-title"> 159 <button type="button" class="customize-section-back" tabindex="-1"> 160 <span class="screen-reader-text"><?php _e( 'Back' ); ?></span> 161 </button> 162 <h3> 163 <span class="customize-action"> 164 <?php 165 /* translators: ▸ is the unicode right-pointing triangle, and %s is the control label in the Customizer */ 166 printf( __( 'Customizing ▸ %s' ), '{{ data.label }}' ); 167 ?> 168 </span> 169 {{ data.l10n.addPosts }} 170 </h3> 171 </script> 172 173 <script type="text/html" id="tmpl-search-group"> 174 <label class="screen-reader-text" for="search-group-field">{{ data.l10n.searchPosts }}</label> 175 <input type="text" id="search-group-field" placeholder="{{{ data.l10n.searchPostsPlaceholder }}}" class="search-group-field"> 176 <div class="search-icon" aria-hidden="true"></div> 177 <button type="button" class="clear-results"><span class="screen-reader-text">{{ data.l10n.clearResults }}</span></button> 178 </script> 179 180 <script type="text/html" id="tmpl-search-result"> 181 <span class="search-results-item-type">{{ data.type }}</span> 182 <span class="search-results-item-title">{{ data.title }}</span> 183 184 <button type="button" class="search-results-item-add button-link"> 185 <span class="screen-reader-text">{{ data.l10n.addPost }}</span> 186 </button> 187 </script> 188 <?php 189 } 190 191 /** 192 * Retrieve posts. 193 * 194 * @since 4.7.0 195 * 196 * @return array 197 */ 198 protected function get_posts() { 199 $data = array(); 200 $value = $this->value(); 201 $post_ids = array_filter( array_map( 'absint', explode( ',', $value ) ) ); 202 203 if ( $this->include_front_page ) { 204 $front_page = get_option( 'page_on_front' ); 205 if ( ! in_array( $front_page, $post_ids ) ) { 206 array_unshift( $post_ids, $front_page ); 207 } 208 } 209 210 if ( ! empty( $post_ids ) ) { 211 $posts = get_posts( array( 212 'post_type' => $this->post_types, 213 'post_status' => 'any', 214 'post__in' => $post_ids, 215 'orderby' => 'post__in', 216 'posts_per_page' => 20, 217 ) ); 218 } 219 220 if ( ! empty( $posts ) ) { 221 $i = 0; 222 foreach ( $posts as $post ) { 223 $data[] = array( 224 'id' => $post->ID, 225 'title' => $post->post_title, 226 'order' => ++$i, 227 ); 228 } 229 } 230 231 return $data; 232 } 233 } -
src/wp-includes/default-filters.php
427 427 428 428 // Canonical 429 429 add_action( 'template_redirect', 'redirect_canonical' ); 430 add_action( 'template_redirect', 'wp_redirect_front_page_sections' ); 430 431 add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 ); 431 432 432 433 // Shortcodes -
src/wp-includes/link-template.php
312 312 function get_page_link( $post = false, $leavename = false, $sample = false ) { 313 313 $post = get_post( $post ); 314 314 315 if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) 315 if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) { 316 316 $link = home_url('/'); 317 else 317 } elseif ( is_front_page_section( $post->ID ) ) { 318 $link = get_front_page_section_url( $post->ID ); 319 } else { 318 320 $link = _get_page_link( $post, $leavename, $sample ); 321 } 319 322 320 323 /** 321 324 * Filters the permalink for a page. … … 4142 4145 */ 4143 4146 return apply_filters( 'parent_theme_file_path', $path, $file ); 4144 4147 } 4148 4149 /** 4150 * Retrieve the URL for a front page section. 4151 * 4152 * @since 4.7.0 4153 * 4154 * @param int|WP_Post $post Post ID or object. 4155 * @return string 4156 */ 4157 function get_front_page_section_url( $post ) { 4158 return home_url( '#post-' . get_post( $post )->ID ); 4159 } -
src/wp-includes/post-template.php
479 479 $classes[] = 'format-standard'; 480 480 } 481 481 482 // Front page sections. 483 if ( is_front_page() && is_front_page_section( $post->ID ) ) { 484 $classes[] = 'front-page-section'; 485 } 486 482 487 $post_password_required = post_password_required( $post->ID ); 483 488 484 489 // Post requires password. … … 1794 1799 echo $rows; 1795 1800 echo "</ul>"; 1796 1801 } 1802 1803 /** 1804 * Whether a post is a front page section. 1805 * 1806 * @since 4.7.0 1807 * 1808 * @param int $post_id Post ID. 1809 * @return bool 1810 */ 1811 function is_front_page_section( $post_id ) { 1812 $section_ids = array_filter( wp_parse_id_list( get_theme_mod( 'front_page_sections' ) ) ); 1813 return in_array( intval( $post_id ), $section_ids, true ); 1814 } -
src/wp-includes/script-loader.php
476 476 $scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu' ), false, 1 ); 477 477 $scripts->add( 'customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 ); 478 478 479 $scripts->add( 'customize-post-collection', "/wp-admin/js/customize-post-collection$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 ); 480 479 481 $scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 ); 480 482 481 483 $scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 ); -
src/wp-includes/theme.php
1730 1730 1731 1731 return false; 1732 1732 } 1733 1734 case 'front-page-sections' : 1735 if ( ! is_array( $args ) ) { 1736 $args = array( 0 => array() ); 1737 } 1738 1739 $args[0] = wp_parse_args( $args[0], array( 1740 'post_types' => array( 'page' ), 1741 ) ); 1742 1743 break; 1733 1744 } 1734 1745 1735 1746 $_wp_theme_features[ $feature ] = $args; … … 1822 1833 case 'custom-logo' : 1823 1834 case 'custom-header' : 1824 1835 case 'custom-background' : 1836 case 'front-page-sections' : 1825 1837 if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) ) 1826 1838 return $_wp_theme_features[ $feature ][0][ $args[0] ]; 1827 1839 return false; … … 2082 2094 return; 2083 2095 } 2084 2096 2085 require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; 2097 require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; 2086 2098 $GLOBALS['wp_customize'] = new WP_Customize_Manager(); 2087 2099 } 2088 2100