Skip to content

Commit

Permalink
Merge pull request #185 from grueneschweiz/dev
Browse files Browse the repository at this point in the history
0.35.1
  • Loading branch information
cyrillbolliger authored Feb 7, 2023
2 parents fdf083b + bf3a066 commit aa4bee9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions wordpress/wp-content/themes/les-verts/lib/_loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@

require_once __DIR__ . '/tweaks/inject-svg-sprite.php';
require_once __DIR__ . '/tweaks/responsive-local-video.php';
require_once __DIR__ . '/tweaks/fix-multi-category-urls.php';

if ( defined( 'WPSEO_FILE' ) ) {
require_once __DIR__ . '/tweaks/tweak-yoast-social-media-stuff.php';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* Fix multi-category urls
*
* Links to an archive of multiple categories with an AND conjunction are not
* correctly converted to pretty permalinks (e.g. /?category_name=cat1+cat2 is
* converted to /category/cat1/ instead of /category/cat1+cat2/). We therefore
* disable the pretty permalink conversion for category_name queries if they
* contain an AND conjunction.
*/
add_filter( 'redirect_canonical', function ( $redirect_url, $requested_url ) {
$query = parse_url( $requested_url, PHP_URL_QUERY );
if ( empty( $query ) || strpos( $query, 'category_name=' ) === false ) {
return $redirect_url;
}

parse_str( $query, $query_vars );
if ( empty( $query_vars['category_name'] ) ) {
return $redirect_url;
}

$query_vars['category_name'] = str_replace( ' ', '+', $query_vars['category_name'] );

if ( strpos( $query_vars['category_name'], '+' ) === false ) {
return $redirect_url;
}

return $requested_url;
}, 10, 2 );
2 changes: 1 addition & 1 deletion wordpress/wp-content/themes/les-verts/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Theme Name: Les Verts
* Description: Custom theme for the GREENS of Switzerland. Designed by superhuit.ch, built by gruene.ch on top of superhuit's stack.
* Author: superhuit.ch & gruene.ch
* Version: 0.35.0
* Version: 0.35.1
* Requires PHP: 7.4
* Requires at least: 5.0
* Theme URI: https://github.com/grueneschweiz/2018.gruene.ch/
Expand Down

0 comments on commit aa4bee9

Please sign in to comment.