Automattic / Automattic/jetpack
Shortlinks: page_on_front not handled correctly.
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
### Impacted plugin
Jetpack
### Steps to Reproduce
1. Enable Jetpack Shortlinks
2. Set a page to display on front
3. Visit Frontpage
4. View Shortlink
### A clear and concise description of what you expected to happen.
I expected a shortlink that was short and linked to the blog front page.
~I expected a shortlink that was shorter than the domain, but it's longer.~ It's shorter by a single character... but looks longer due to the uppercase characters..
### What actually happened
1. The shortlink is almost as long as the homepage
2. The shortlink links to the page ID rather than to the homepage.
### Other information
For example:
- Site: https://wordpress.org/
- Shortlink: https://wp.me/P1OHUb-7n
```
$ curl -isL https://wp.me/P1OHUb-7n | grep ^location
location: https://wordpress.org/?page_id=457
location: https://wordpress.org/
```
This is caused by `$context` being set to `post` because a page_on_front is a singular page. It should have been set to `blog` I guess.
https://github.com/Automattic/jetpack/blob/39fc94c7215da7e837e119cf6b0010e0daa49356/projects/plugins/jetpack/modules/shortlinks.php#L59-L68
### Operating System
Other
### OS Version
_No response_
### Browser
Other / Not applicable
### Browser Version(s)
_No response_
Contributor guide
Research direction
Start in projects/plugins/jetpack/modules/shortlinks.php around lines 59-68 and trace how the context is chosen for a page configured as the front page. Reproduce the Jetpack Shortlinks case with a page set to display on front, then verify the generated shortlink targets the blog front page rather than the page ID and remains appropriately short.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100