• Resolved Halil ESEN

    (@halilesen)


    Hi,
    It’s a feature that’s been around for a long time I guess, but it’s never been asked here. I’m talking about the menu that opens when I long-click or right-click the app on mobile. Here it is: https://web.dev/app-shortcuts/

    But I don’t know how to add the code mentioned on this page to the functions.php file. I’ve tried before, it didn’t work. I don’t understand if I should add the given code as it is.

    Could you help?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Halil ESEN

    (@halilesen)

    Is there anyone who can help?

    I’m also curious about your ideas for the pwabuilder.com site.

    Plugin Author Weston Ruter

    (@westonruter)

    Hey there. This is possible today since all that seems required is modifying the Web App Manifest, and this can be done with the web_app_manifest filter.

    So using the example shortcuts from that Web.dev article, this is how they could be added to your manifest with the PWA plugin:

    add_filter(
    	'web_app_manifest',
    	static function ( $manifest ) {
    		if ( ! isset( $manifest['shortcuts'] ) ) {
    			$manifest['shortcuts'] = array();
    		}
    		$manifest['shortcuts'] = array_merge(
    			$manifest['shortcuts'],
    			array(
    				array(
    					"name"        => "Open Play Later",
    					"short_name"  => "Play Later",
    					"description" => "View the list of podcasts you saved for later",
    					"url"         => "/play-later?utm_source=homescreen",
    					"icons"       => array( array( "src" => "/icons/play-later.png", "sizes" => "192x192" ) )
    				),
    				array(
    					"name"        => "View Subscriptions",
    					"short_name"  => "Subscriptions",
    					"description" => "View the list of podcasts you listen to",
    					"url"         => "/subscriptions?utm_source=homescreen",
    					"icons"       => array( array( "src" => "/icons/subscriptions.png", "sizes" => "192x192" ) )
    				)
    			)
    		);
    
    		return $manifest;
    	}
    );

    Sorry, I don’t have any experience with pwabuilder.com.

    Thread Starter Halil ESEN

    (@halilesen)

    Thanks. It worked. I removed the description as I found it unnecessary.

    The site I mentioned says that besides making PWA analysis, it can prepare PWA for stores and turn it into an application. But I haven’t tested it yet.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add app shortcuts’ is closed to new replies.