#3870 closed enhancement (fixed)
Update total plugin counter in WP.org
Reported by: | vaishalipanchal | Owned by: | dd32 |
---|---|---|---|
Milestone: | Priority: | normal | |
Component: | General | Keywords: | has-patch dev-feedback |
Cc: |
Description
On https://wordpress.org/ we needs to update total plugins counter as per https://wordpress.org/plugins/ page. Also if possible needs to set update plugins counter dynamically by coding so anyone can check it from main page no need to check plugin page.
Attachments (2)
Change History (13)
#4
@
6 years ago
wp_count_posts('plugin') won't work either. The plugin directory is not in the main instance, it is in a separate instance on the multisite system.
#5
@
6 years ago
@Otto42 yes i have used $plugin_count = wp_count_posts( 'plugin' )->publish;
to get total plugin count as per https://wordpress.org/plugins/ page coding. Which function i have to used to get total plugin counter in main WP.org site?
#6
@
6 years ago
@vaishalipanchal It'll probably need code such as:
$number = 50000; if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) { switch_to_blog( WPORG_PLUGIN_DIRECTORY_BLOGID ) $number = count posts.. restore_current_blog() }
#7
@
6 years ago
- Priority changed from low to normal
@dd32 i can't test above code in my WordPress Meta folder. can you please suggest me code or add here working patch for plugin counter so ticket goes to close once plugin counter dynamic for Main WP.org website.
#9
@
6 years ago
I'm going to fix this by using a constant which will need updating rather than automatically pulling it from the plugin directory.
The reason is simple - wordpress.org/
doesn't actually run the wporg-main
theme and instead is hard-coded. As we already have another hard-coded number here (WP_MARKET_SHARE
) introducing another constant here seems fine. It only needs updating every 5-10k plugins which probably coincides with the market share changes anyway.
That patch updates the number, but breaks the existing translations. If the number is going to be dynamic, then the translation needs to be static and have the number sprintf'd into it. Also it would need to be run through number_format_i18n and so forth as well.