WordPress/wporg-developer

Add redirects to archived Themes Handbook docs

Closed this issue ยท 12 comments

ndiego commented

Following the redesign, a number of docs in the Themes Handbook were archived. We need to add redirects for the following.

Previous URL New URL
https://developer.wordpress.org/themes/advanced-topics/theme-json/ https://developer.wordpress.org/themes/global-settings-and-styles/
https://developer.wordpress.org/themes/advanced-topics/custom-block-styles/ https://developer.wordpress.org/themes/features/block-style-variations/
https://developer.wordpress.org/themes/advanced-topics/block-patterns/ https://developer.wordpress.org/themes/features/block-patterns/
https://developer.wordpress.org/themes/getting-started/who-should-read-this-handbook/ https://developer.wordpress.org/themes/getting-started/who-is-this-handbook-for/
https://developer.wordpress.org/themes/getting-started/theme-development-examples/ https://developer.wordpress.org/themes/getting-started/quick-start-guide/
https://developer.wordpress.org/themes/getting-started/setting-up-a-development-environment/ https://developer.wordpress.org/themes/getting-started/tools-and-setup/
https://developer.wordpress.org/themes/getting-started/wordpress-licensing-the-gpl/ https://wordpress.org/about/license/
https://developer.wordpress.org/themes/block-themes/creating-new-themes-using-the-site-editor/ https://developer.wordpress.org/themes/getting-started/quick-start-guide/
https://developer.wordpress.org/themes/block-themes/templates-and-template-parts/ https://developer.wordpress.org/themes/templates/
https://developer.wordpress.org/themes/block-themes/block-theme-setup/ https://developer.wordpress.org/themes/core-concepts/
https://developer.wordpress.org/themes/block-themes/ https://developer.wordpress.org/themes/getting-started/what-is-a-theme/
pkevan commented

All look fine apart from:

https://developer.wordpress.org/themes/advanced-topics/block-patterns/ which currently redirects to https://developer.wordpress.org/themes/features/block-patterns/

Which is fine, it's just already in place :)

ndiego commented

Which is fine, it's just already in place :)

Great, thanks. Are these redirects in the theme code, or are they managed somewhere else?

pkevan commented

Which is fine, it's just already in place :)

Great, thanks. Are these redirects in the theme code, or are they managed somewhere else?

Not sure - i've been trying to find them without success so far!

I'm not seeing any of those redirects setup yet, but it sounds like you are? ๐Ÿค”

If I'm logged in, I see the original page. If I'm logged out I see the 404 page. Is that different than you see Paul and Nick? I'm checking against production.


Aside: My general approach to finding obscure redirects is to make requests to my sandbox while adding die() statements:

curl -Ik https://{sandbox host}/themes/advanced-topics/block-patterns/ -H 'developer.wordpress.org' --socks5 127.0.0.1:8080

  • die('config') in wp-config.php confirms whether or not it's hitting WP. If not, it's in the nginx config (which you can see on your sandbox)
  • die('core redir') in wp_redirect(). If this is reached, you can die( wp_debug_backtrace_summary( null, 0, true) ) to find the caller. If not, that implies it's using header( 'Location: ...
  • grep for header( 'Location: and header( "Location:, then die( __FILE__ ) in any of the results that seem plausible
pkevan commented

Only one of them is present, listed here: #452 (comment). I was more meaning they weren't there ๐Ÿ˜‚ but I've got stuck trying to find where its set!

pkevan commented
MacBook-Pro-PK:~ pkevan$ curl -IL https://developer.wordpress.org/themes/advanced-topics/block-patterns/
HTTP/2 301 
server: nginx
date: Wed, 20 Dec 2023 16:21:29 GMT
content-type: text/html; charset=UTF-8
x-olaf: โ›„
expires: Wed, 11 Jan 1984 05:00:00 GMT
cache-control: no-cache, must-revalidate, max-age=0
x-redirect-by: WordPress
location: https://developer.wordpress.org/themes/features/block-patterns/
x-frame-options: SAMEORIGIN
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 2

HTTP/2 200 
server: nginx
date: Wed, 20 Dec 2023 16:21:29 GMT
content-type: text/html; charset=UTF-8
vary: Accept-Encoding
x-olaf: โ›„
link: <https://developer.wordpress.org/wp-json/>; rel="https://api.w.org/"
link: <https://developer.wordpress.org/wp-json/wp/v2/theme-handbook/149262>; rel="alternate"; type="application/json"
link: <https://developer.wordpress.org/?p=149262>; rel=shortlink
x-frame-options: SAMEORIGIN
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 2

here is the example using curl - I know it's hitting WP via the x-redirect-by: WordPress header, I just can't find where it's set.

Ah, I see now ๐Ÿ‘๐Ÿป It looks like it's coming from redirect_canonical().

For the rest, I'd personally create mu-plugins/developer-network/redirects.php, and put them there. Then I'd move the existing ones in wporg-redirects.php to that file. It's probably fine to put them in wporg-redirects.php too if you prefer.

pkevan commented

For the rest, I'd personally create mu-plugins/developer-network/redirects.php, and put them there. Then I'd move the existing ones in wporg-redirects.php to that file.

I'll do that. Mainly I was looking for somewhere better to put these, if it didn't already exist, since it's not related to the previous redirects in block-editor but setting something up specifically for this site makes more sense.

pkevan commented

The only one i'm unsure how to handle is below, I'd prefer to lock down redirects to internal i.e. developer.wordpress.org domains only, to avoid potential mis-use.

https://developer.wordpress.org/themes/getting-started/wordpress-licensing-the-gpl/ => https://wordpress.org/about/license/

pkevan commented

Added all but the above in https://dotorg.trac.wordpress.org/changeset/21449, redirects should have a header with:

x-redirect-by: DevNet-redirect