Automattic / Automattic/jetpack

Always use Jetpack_Options::get_option( ‘id’ )

Open
#17,647 0 comments 0 reactions 0 assignees View on GitHub
[Type] Janitorial Epic General
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

Until recently, WP.com wouldn't return the correct site id when it called `Jetpack_Options::get_option( ‘id’ )`. Instead we'd have to add lots of this in the code:

```
if ( IS_WPCOM ) { return get_current_blog_id() } else { Jetpack_Options::get_option( 'id' ) }
```

However since #16561, we can use Jetpack_Options::get_option( 'id' ) on WP.com as well as self-hosted Jetpack sites, so we can remove all of these forks in the code. See also p9dueE-1Ee-p2

- [ ] https://github.com/Automattic/jetpack/blob/092d9af6c96384083ae509741be77a8db9346721/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-mailchimp.php#L78
- [ ] https://github.com/Automattic/jetpack/blob/874e9fd02381364cfc7bb4307a055faf930dc5e2/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-search.php#L52
- [ ] https://github.com/Automattic/jetpack/blob/d37c4eca5842ca81a9f0c368fad1b0b83561acef/_inc/lib/class-jetpack-mapbox-helper.php#L88
- [ ] https://github.com/Automattic/jetpack/blob/a1fe6f0b03ea68fb5e0eed1e22d585e2351b2a06/_inc/lib/class-jetpack-instagram-gallery-helper.php#L105
- [ ] https://github.com/Automattic/jetpack/blob/ebec0a8fb35ffac4766cce36646ebf01c5d56063/modules/videopress/class.videopress-gutenberg.php#L133
- [ ] https://github.com/Automattic/jetpack/blob/d37c4eca5842ca81a9f0c368fad1b0b83561acef/modules/tiled-gallery/tiled-gallery/tiled-gallery-layout.php#L91
- [ ] https://github.com/Automattic/jetpack/blob/ea7625a3f46e9e9a100722d23ea33b4c610929b4/_inc/lib/core-api/wpcom-fields/attachment-fields-videopress.php#L66
- [ ] https://github.com/Automattic/jetpack/blob/60f0fa1db582116753d24a49446dc7e70c219f76/modules/memberships/class-jetpack-memberships.php#L344
- [ ] https://github.com/Automattic/jetpack/blob/b7acf5e41bfb344969b409fc61c884a955e785a2/modules/likes.php#L224
- [ ] https://github.com/Automattic/jetpack/blob/ebec0a8fb35ffac4766cce36646ebf01c5d56063/extensions/blocks/mailchimp/mailchimp.php#L55
- [ ] https://github.com/Automattic/jetpack/blob/da783ccfb0173804d37797031bb87d7c9bc1f794/modules/simple-payments/simple-payments.php#L113
- [ ] https://github.com/Automattic/jetpack/blob/9a437395f0d2f8248bea436faacd8445e71de846/_inc/lib/class-jetpack-tweetstorm-helper.php#L1677

Contributor guide

Open the contributing guide

Research direction

Start with the twelve linked PHP files and inspect each conditional that chooses between get_current_blog_id() and Jetpack_Options::get_option('id'). Update the listed call sites so they consistently use the option lookup, then confirm every checklist item has been addressed and the existing behavior remains correct for WP.com and self-hosted Jetpack sites.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.