{"id":6956040,"date":"2016-01-18T12:19:39","date_gmt":"2016-01-18T12:19:39","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/handle-html-encoding-in-links-with-existing-parameters\/"},"modified":"2016-08-31T00:33:37","modified_gmt":"2016-08-31T00:33:37","slug":"handle-html-encoding-in-links-with-existing-parameters","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/handle-html-encoding-in-links-with-existing-parameters\/","title":{"rendered":"handle HTML encoding in links with existing parameters"},"content":{"rendered":"<p>hi,<br \/>\nusing sublanguage with woocommerce products the &#8220;sort products&#8221; feature is broken.<\/p>\n<p>i&#8217;ve made a little change in the function table_views to handle HTML-encoding in links with pre-existing parameters:<\/p>\n<pre><code>&lt;br \/&gt;\n\tpublic function table_views($views) {&lt;br \/&gt;\n\t\tglobal $sublanguage_admin;&lt;\/p&gt;\n&lt;p&gt;\t\t$new_views = array();&lt;br \/&gt;\n\t\t$new_views[] = $this-&gt;print_table_view_language_switch($sublanguage_admin-&gt;language_query_var);&lt;\/p&gt;\n&lt;p&gt;\t\tforeach ($views as $view) {&lt;\/p&gt;\n&lt;p&gt;\t\t\tif (preg_match(&#039;\/href=[\\&#039;|&quot;]([^\\&#039;&quot;]*)\/&#039;, $view, $matches)) {&lt;br \/&gt;\n\t\t\t\t$match_decoded = html_entity_decode($matches[1]); \/\/handle HTML encoding in links with existing parameters (IE in WooCommerce &quot;Sort Products&quot; link)&lt;br \/&gt;\n\t\t\t\t$new_views[] = str_replace($matches[1], add_query_arg(array($sublanguage_admin-&gt;language_query_var =&gt; $sublanguage_admin-&gt;current_language-&gt;post_name), $match_decoded), $view);&lt;\/p&gt;\n&lt;p&gt;\t\t\t} else {&lt;\/p&gt;\n&lt;p&gt;\t\t\t\t$new_views[] = $view;&lt;\/p&gt;\n&lt;p&gt;\t\t\t}&lt;\/p&gt;\n&lt;p&gt;\t\t}&lt;\/p&gt;\n&lt;p&gt;\t\treturn $new_views;&lt;br \/&gt;\n\t}&lt;br \/&gt;<\/code><\/pre>\n<p>https:\/\/wordpress.org\/plugins\/sublanguage\/<\/p>\n","protected":false},"template":"","class_list":["post-6956040","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6956040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6956040\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=6956040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}