WordPress / wporg-main-2022

A block-based child theme for WordPress.org, plus local environment
71 stars 26 forks source link

Create a shortcode for `WP_MARKET_SHARE` #10

Closed ryelle closed 2 years ago

ryelle commented 2 years ago

This is a single defined constant that provides the current WP market share (ex, 43%). In wporg-main, this is used to build strings, so that they don't need to be re-translated every time the percentage changes. It also keeps the value defined in one place, so we don't end up with 40% in one place, and 43% in another.

printf(
    /* translators: WordPress market share: 39 - Note: The following percent sign is '%%' for escaping purposes; */
    esc_html__( 'Use the software that powers over %s%% of the web.', 'wporg' ),
    esc_html( number_format_i18n( WP_MARKET_SHARE ) )
);

How should we handle this for content entered in the block editor?

ryelle commented 2 years ago

There are also a few other places in the current front-page.php where we use dynamic counts.

These probably aren't as important - the copy might change, and even if not, these can probably stay static for a while. The meetup count was last updated 3 years ago, the only time since it was added.

tellyworth commented 2 years ago

Could we do this with a few super-simple server side blocks? That basically just run your code snippet, or similar to it.

dd32 commented 2 years ago

IMHO; for the initial release I would just use an inline shortcode.

It looks like "tokens" will be shortcodes-v2 which would likely be the proper solution in future. https://github.com/WordPress/gutenberg/pull/42015

ryelle commented 2 years ago

IMHO; for the initial release I would just use an inline shortcode.

I agree. If we want to make it easier for editors we could add a toolbar button/dropdown like #16 to insert these, but spending too much time here doesn't make much sense if a core solution is on the way.

ryelle commented 2 years ago

Renamed & moved this to "to do" since it sounds like we have a path forward.