Order of hook&filter execution
-
Hello Chouby,
I hope everything is well on your side.
Following with my series of questions about Polylang-Rewrite interactions and recent exchanges about getting the laguage from the path.
Ref: https://ww.wp.xz.cn/support/topic/getting-language-from-path?replies=4#post-7149454Still trying to get the permalink to define the language from $_GET[‘lang’].
I cannot wrap my mind over it, it seems.I have find out we may use add_filter(‘post_link’, ..).
Could you please tell me if the pll_language_defined hook is execute before or after the add_filter(‘post_link’, ..)?In the best of your knowledge, once Polylang modify the permalink, is the new permalink passed through the rewrite rules again?
example:
$regex = 'dl/.*/?'; rewrite = 'index.php?pagename=dl'; add_rewrite_rule( $regex, $rewrite, 'top' ); $regex = '(en|fr)/dl/.*/?'; rewrite = 'index.php?pagename=dl&lang=$matches[1]'; add_rewrite_rule( $regex, $rewrite, 'top' );Considering the following (over simplified) function will add the language to the permalink:
function dl_language() { global $polylang; $reqLangSlug = $_GET['lang']; $polylang->curlang = $polylang->model->get_language($reqLangSlug); } add_action('pll_language_defined', 'dl_language');http://www.next.ca/dl/aa/aa/00/ri/00/?lang=fr
would be caught by Polylang and added the language slug, generating
http://www.next.ca/fr/dl/aa/aa/00/ri/00/?lang=frWill this new permalink be reinterpreted by the rewrite rules (caught by the second rule) and be understood as index.php?pagename=dl&lang=fr ?
The topic ‘Order of hook&filter execution’ is closed to new replies.