File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public function __construct() {
3838 public function sf_add_custom_rewrite_rule () {
3939 // regex match either the base endpoint or the localized endpoints.
4040 $ regex = sprintf (
41- '^%s(?:-( [a-z]{2,3}))?/?$ ' ,
41+ '^%s(( ?:-[a-z]{2,3}){1,2} )?/?$ ' ,
4242 ShoppingFeedHelper::get_public_feed_endpoint ()
4343 );
4444 $ query = sprintf (
@@ -72,9 +72,16 @@ public function sf_add_custom_query_vars( $vars ) {
7272 */
7373 public function sf_parse_request () {
7474 global $ wp ;
75- if ( isset ( $ wp ->query_vars [ self ::FEED_QUERY_VAR ] ) ) {
76- $ lang = ! empty ( $ wp ->query_vars [ self ::FEED_LANG_QUERY_VAR ] ) ? $ wp ->query_vars [ self ::FEED_LANG_QUERY_VAR ] : null ;
77- ShoppingFeedHelper::get_feedbuilder_manager ()->render_feed ( $ lang );
75+ if ( ! isset ( $ wp ->query_vars [ self ::FEED_QUERY_VAR ] ) ) {
76+ return ;
7877 }
78+
79+ $ lang = ! empty ( $ wp ->query_vars [ self ::FEED_LANG_QUERY_VAR ] ) ? $ wp ->query_vars [ self ::FEED_LANG_QUERY_VAR ] : null ;
80+
81+ // Remove first hyphen (-) if needed
82+ if ( ! empty ( $ lang ) && str_starts_with ( $ lang , '- ' ) ) {
83+ $ lang = ltrim ( $ lang , '- ' );
84+ }
85+ ShoppingFeedHelper::get_feedbuilder_manager ()->render_feed ( $ lang );
7986 }
8087}
You can’t perform that action at this time.
0 commit comments