WordPress / wordcamp.org

WordCamps are casual, locally-organized conferences covering everything related to WordPress.
https://wordcamp.org
132 stars 74 forks source link

PWA: Override `short_name` in manifest with more descriptive name #196

Open ryelle opened 5 years ago

ryelle commented 5 years ago

The short_name is generated by the PWA plugin as the first 12 characters of the site name. So for WordCamps, it's almost always going to be "WordCamp". This is used in a few different places- on the install prompt, for the app name, on the "App Info" screen, etc.

We can override the manifest with the web_app_manifest filter, so let's add our own short_name - maybe we can get the WC Hashtag from the WordCamp post type?

iandunn commented 5 years ago

first 12 characters ... maybe we can get the WC Hashtag from the WordCamp post type?

Ah, that's a good idea!

Maybe we could try WC {Name} first, and if that is > 12 then we fall back to the hashtag? That may be more trouble than it's worth, though.

Related: https://github.com/xwp/pwa-wp/issues/200#issuecomment-515788791

ryelle commented 5 years ago

Where does Name come from?

iandunn commented 5 years ago

There's a get_wordcamp_name() helper that should provide it, although we'd have to regex out the "WordCamp" and "YYYY" part.

It'd probably be simpler to do something like this:

$wordcamp = get_wordcamp_post();
// fall back to get_bloginfo( 'name' ) if ^ fails
$title = sprintf( 'WC %s', trim( str_replace( 'WordCamp', '', $wordcamp->post_title ) ) );

That might break down with some outliers, like WordCamp for Publishers: Columbus and WordCamp Seattle: Experienced Edition, though.

🤔

westonruter commented 5 years ago

Note that PWA plugin v0.3.0 no longer auto-generates the short_name: https://github.com/xwp/pwa-wp/pull/201

So it has to be supplied by the site now via the web_app_manifest filter.

What do you think of the PWA plugin adding a short name to be added alongside the Site Title in the general options screen? Like this:

image

I've opened an issue to discuss this: https://github.com/xwp/pwa-wp/issues/210

westonruter commented 5 years ago

Aside: The lack of a short_name is apparently making the WCEU site not able to prompt to Add to Homescreen:

image (2)

Supplying WCEU 2019 via the web_app_manifest filter will fix that in the short term:

add_filter( 'web_app_manifest', function( $manifest ) {
    $manifest['short_name'] = 'WCEU 2019';
    return $manifest;
} );