Ticket #4814: 4814.diff
File 4814.diff, 10.9 KB (added by , 5 years ago) |
---|
-
wordpress.org/public_html/wp-content/plugins/theme-directory/query-modifications.php
diff --git wordpress.org/public_html/wp-content/plugins/theme-directory/query-modifications.php wordpress.org/public_html/wp-content/plugins/theme-directory/query-modifications.php index 60b6e9f07..32b81e241 100644
function wporg_themes_pre_get_posts( $query ) { 18 18 } 19 19 20 20 // Default to the ~featured~ popular view 21 if ( empty( $query->query ) ) {21 if ( empty( $query->query_vars['browse'] ) ) { 22 22 $query->query_vars['browse'] = 'popular'; 23 23 } 24 24 … … function wporg_themes_pre_get_posts( $query ) { 38 38 $query->query_vars['post_status'] = 'publish'; 39 39 } 40 40 41 // We always want there to be a paged variable to match the front end 42 if( empty( $query->query_vars['paged'] ) ) { 43 $query->query_vars['paged'] = 1; 44 } 45 41 46 switch ( $query->query_vars['browse'] ) { 42 47 case 'new': 43 48 $query->query_vars['orderby'] = 'post_date'; -
wordpress.org/public_html/wp-content/themes/pub/wporg-themes/css/components/_main.scss
diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-themes/css/components/_main.scss wordpress.org/public_html/wp-content/themes/pub/wporg-themes/css/components/_main.scss index 2541bb05b..3e485c603 100644
body.author .theme-browser .theme .theme-author { 586 586 margin: 100px 0 150px; 587 587 } 588 588 589 .viewing-paged-alert { 590 display: none; 591 display: flex; 592 align-items: center; 593 justify-content: space-between; 594 padding: 16px; 595 margin: 0 0 20px 0; 596 background: #fef8e7; 597 border: 1px solid #f0b849; 598 599 p { 600 margin: 0; 601 font-size: 14px; 602 } 603 } 604 605 .viewing-paged-alert.is-hidden { 606 display: none; 607 } 589 608 590 609 /* Ratings */ 591 610 .rating { -
wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php
diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php index d76673d4e..c0f06ec88 100644
function wporg_themes_canonical_redirects() { 50 50 } 51 51 52 52 // We don't support pagination on the directory at present. 53 if ( get_query_var( 'paged' ) ) {54 $url = remove_query_arg( 'paged' );55 $url = preg_replace( '!page/\d+!i', '', $url );53 // if ( get_query_var( 'paged' ) ) { 54 // $url = remove_query_arg( 'paged' ); 55 // $url = preg_replace( '!page/\d+!i', '', $url ); 56 56 57 // Remove any double slashes58 $url = preg_replace( '!/{2,}!', '/', $url );57 // // Remove any double slashes 58 // $url = preg_replace( '!/{2,}!', '/', $url ); 59 59 60 wp_safe_redirect( $url ); // Not 301, as paginated requests will one day be supported hopefully.61 die();62 }60 // wp_safe_redirect( $url ); // Not 301, as paginated requests will one day be supported hopefully. 61 // die(); 62 // } 63 63 64 64 // Uppercase characters in URLs tend to lead to broken JS pages. 65 65 // Redirect all paths to the lower-case variant, excluding searches.. -
wordpress.org/public_html/wp-content/themes/pub/wporg-themes/index.php
diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-themes/index.php wordpress.org/public_html/wp-content/themes/pub/wporg-themes/index.php index 55c70de32..123aa8f91 100644
get_header(); 60 60 </div> 61 61 </div><!-- .wp-filter --> 62 62 63 <div id="viewing-paged-alert" class="viewing-paged-alert is-hidden"> 64 <p><?php _e( 'You are currently viewing a subset.', 'wporg-themes' ); ?></p> 65 <button class="button button-primary" id="view-page-list-clear-btn"> 66 <?php _e( 'View All', 'wporg-themes' ); ?> 67 </button> 68 </div> 69 63 70 <div class="theme-browser content-filterable"> 64 71 <div class="themes"> 65 72 <?php -
wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js
diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js index c21ec0631..9f73d279b 100644
window.wp = window.wp || {}; 242 242 return collection; 243 243 }, 244 244 245 // Binds event that removes paging and reload the page 246 bindFilteredAlertBtn: function( isPagedView ) { 247 if( ! isPagedView ) { 248 return; 249 } 250 251 $( '#view-page-list-clear-btn' ).click( function() { 252 var urlSplitAtPage = Backbone.history.getFragment().split( 'page/' ); 253 var navigateTo = urlSplitAtPage && urlSplitAtPage[0]; 254 255 // If anything goes wrong, go back to root. 256 if( ! navigateTo || ! navigateTo.length ) { 257 navigateTo = themes.router.baseUrl( '/' ); 258 } 259 260 //If urlSplitAtPage is undefined, it will restart at the root 261 themes.router.navigate( navigateTo ); 262 window.location.reload(); 263 } ); 264 }, 265 266 // Show/hides message that alerts user they are on a page 267 showFilteredAlert: function( isPagedView ) { 268 $( '#viewing-paged-alert' ).toggleClass( 'is-hidden', ! isPagedView ); 269 270 this.bindFilteredAlertBtn( isPagedView ); 271 }, 272 273 // Always reset the themes array when we move contexts 274 resetOnNextQuery: function() { 275 this.currentQuery.page = 1; 276 }, 277 278 shouldResetThemes: function() { 279 return this.currentQuery.page === 1; 280 }, 281 245 282 // Handles requests for more themes 246 283 // and caches results 247 284 // … … window.wp = window.wp || {}; 275 312 } 276 313 277 314 // Otherwise, send a new API call and add it to the cache. 278 if ( ! query && ! isPaginated) {279 query = this.apiCall( request ).done( function( data ) {315 if ( ! query ) { 316 query = this.apiCall( request, isPaginated ).done( function( data ) { 280 317 281 318 // Update the collection with the queried data. 282 319 if ( data.themes ) { 320 321 if( ! self.length || self.shouldResetThemes() ) { 283 322 self.reset( data.themes ); 323 self.trigger( 'themes:update' ); 324 } else { 325 self.add( data.themes ); 326 } 327 284 328 count = data.info.results; 329 330 // Because we store the request, we should create a new instance 331 var newReq = JSON.parse(JSON.stringify(request)); 332 285 333 // Store the results and the query request 286 queries.push( { themes: data.themes, request: request, total: count } );334 queries.push( { themes: data.themes, request: newReq, total: count } ); 287 335 } 288 336 289 337 // Trigger a collection refresh event 290 338 // and a `query:success` event with a `count` argument. 291 self.trigger( 'themes:update' );292 339 self.trigger( 'query:success', count ); 293 340 294 341 if ( data.themes && data.themes.length === 0 ) { 295 342 self.trigger( 'query:empty' ); 296 }297 298 }).fail( function() {299 self.trigger( 'query:fail' );300 });301 343 } else { 302 // If it's a paginated request we need to fetch more themes... 303 if ( isPaginated ) { 304 return this.apiCall( request, isPaginated ).done( function( data ) { 305 // Add the new themes to the current collection 306 // @todo update counter 307 self.add( data.themes ); 308 self.trigger( 'query:success', data.info.results ); 344 $( 'body' ).removeClass( 'no-results' ); 345 } 309 346 310 347 // We are done loading themes for now. 311 348 self.loadingThemes = false; … … window.wp = window.wp || {}; 313 350 }).fail( function() { 314 351 self.trigger( 'query:fail' ); 315 352 }); 316 }353 } else { 317 354 318 355 if ( query.themes.length === 0 ) { 319 self.trigger( 'query:empty' );356 this.trigger( 'query:empty' ); 320 357 } else { 321 358 $( 'body' ).removeClass( 'no-results' ); 322 359 } 323 360 361 // We are done loading themes for now. 362 this.loadingThemes = false; 363 324 364 // Only trigger an update event since we already have the themes 325 365 // on our cached object 326 366 if ( _.isNumber( query.total ) ) { 327 367 this.count = query.total; 328 368 } 329 369 if( this.shouldResetThemes() ) { 330 370 this.reset( query.themes ); 371 } else { 372 this.add( query.themes ); 373 } 374 331 375 if ( ! query.total ) { 332 376 this.count = this.length; 333 377 } … … window.wp = window.wp || {}; 1305 1349 $( '.filter-links li > a.current' ).removeClass( 'current' ); 1306 1350 $( 'body' ).removeClass( 'show-filters filters-applied' ); 1307 1351 1352 // Paging no longer exists, hide message 1353 this.collection.showFilteredAlert( false ); 1354 1308 1355 // Set route 1309 1356 if ( value ) { 1310 1357 themes.utils.title( value, 'search' ); … … window.wp = window.wp || {}; 1424 1471 user: themes.data.settings.favorites.user 1425 1472 } ); 1426 1473 } else { 1427 this.collection.query( { browse: section } ); 1474 this.collection.query( { 1475 browse: section, 1476 page: this.view.collection.currentQuery.page 1477 } ); 1428 1478 } 1429 1479 }, 1430 1480 … … window.wp = window.wp || {}; 1433 1483 var $el = $( event.target ), 1434 1484 sort = $el.data( 'sort' ); 1435 1485 1486 // We need to set this to tell the apiCall that we should clear the themes array 1487 this.view.collection.resetOnNextQuery(); 1488 1489 // We automatically remove the paging on sort, so hide the alert 1490 this.view.collection.showFilteredAlert( false ); 1491 1436 1492 event.preventDefault(); 1437 1493 1438 1494 $( 'body' ).removeClass( 'filters-applied show-filters' ); … … window.wp = window.wp || {}; 1546 1602 themes.router.navigate( themes.router.baseUrl( 'tags/' + tags.join( '+' ) ) ); 1547 1603 themes.utils.title( names[0], 'tags' ); 1548 1604 1605 // Paging is gone. 1606 this.collection.showFilteredAlert( false ); 1607 1549 1608 // Get the themes by sending Ajax POST request to api.wordpress.org/themes 1550 1609 // or searching the local cache 1551 1610 this.collection.query( request ); … … window.wp = window.wp || {}; 1629 1688 'search/:query(/page/:page)(/)' : 'search', 1630 1689 'author/:author(/page/:page)(/)' : 'author', 1631 1690 ':slug(/)' : 'preview', 1691 'page/:page(/)' : 'rootWithPaging', 1632 1692 '' : 'sort' 1633 1693 }, 1634 1694 … … window.wp = window.wp || {}; 1701 1761 self.view.view.expand( slug ); 1702 1762 }); 1703 1763 1704 // Handles sorting / browsing routes 1705 // Also handles the root URL triggering a sort request 1706 // for `featured`, the default view 1707 themes.router.on( 'route:sort', function( sort, page ) { 1764 function onLoadSort( sort, page ) { 1708 1765 if ( page ) { 1709 themes.router.navigate( 'browse/' + sort + '/', { replace: true } ); 1766 self.view.collection.currentQuery.page = +page; 1767 self.view.collection.showFilteredAlert( true ); 1710 1768 } 1711 1769 1712 1770 self.view.collection.queries.push( themes.data.query ); … … window.wp = window.wp || {}; 1716 1774 } 1717 1775 self.view.sort( sort ); 1718 1776 self.view.trigger( 'theme:close' ); 1777 } 1778 1779 // Handles sorting / browsing routes 1780 // Also handles the root URL triggering a sort request 1781 // for `featured`, the default view 1782 themes.router.on( 'route:sort', onLoadSort ); 1783 1784 themes.router.on( 'route:rootWithPaging', function( page ) { 1785 onLoadSort.call( this, undefined, page ); 1719 1786 }); 1720 1787 1721 1788 // The `search` route event. The router populates the input field.