{"id":13639260,"date":"2020-11-09T14:24:06","date_gmt":"2020-11-09T14:24:06","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/filter-hook-request\/"},"modified":"2020-11-09T14:40:25","modified_gmt":"2020-11-09T14:40:25","slug":"filter-hook-request","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/filter-hook-request\/","title":{"rendered":"Filter-Hook Request"},"content":{"rendered":"<p>Hi mate,<\/p>\n<p>I am facing an issue regarding different custom post types in different blogs. Here is my stackoverflow question regarding the issue itself: https:\/\/stackoverflow.com\/questions\/64753068\/how-to-correctly-determine-whether-a-post-type-is-active-in-a-given-blog-in-a-wo?noredirect=1#comment114489656_64753068<\/p>\n<p>Now, as it doesn&#8217;t seem to be possible to safely determine whether post-types are active in other blogs, I was wondering if you could add an option for us developers to filter the hreflang output, so we can check whether a tag should be printed or not depending on our own setup. <\/p>\n<p>Specifically, a filter in <code>MslsOutput.php<\/code> in method <code>get_alternate_links<\/code> would we great. Maybe just after <code>$url = $blog-&gt;get_url($options);<\/code> in the foreach loop, something like:<\/p>\n<p><code>$url = apply_filters(&#039;mlsl_output_url&#039;, $url, $blog);<\/code><\/p>\n<p>And &#8211; or maybe event better &#8211; also in the <code>MslsBlog::get_permalink($options)<\/code> method as the blog id is actually set to the respective blog there, just after<\/p>\n<p><code>$url = $options-&gt;get_permalink($this-&gt;get_language());<\/code><br \/>\nalso add a filter so you can return null for the URL if desired<\/p>\n<pre><code>$url = apply_filters(&#039;mlsl_blog_permalink&#039;, $url, $this, $this-&gt;obj-&gt;userblog_id);\n<\/code><\/pre>\n<p>Then we can simply return null if I don&#8217;t want a specific hreflang tag to be printed. At the current point, we only can<\/p>\n<p><code>remove_action(&#039;wp_head&#039;, [&#039;lloc\\Msls\\MslsPlugin&#039;, &#039;print_alternate_links&#039;]);<\/code><\/p>\n<p>But this will avoid any tags from being printed, also the x-default. <\/p>\n<p>If there is another way you would approach this issue feel free to point it out.<\/p>\n<p>Thanks for your support!<br \/>\nMarkus.<\/p>\n","protected":false},"template":"","class_list":["post-13639260","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13639260","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":6,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13639260\/revisions"}],"predecessor-version":[{"id":13639358,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13639260\/revisions\/13639358"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=13639260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}