Progressive WordPress (PWA) Shortcode

Below, you’ll find a detailed guide on how to add the Progressive WordPress (PWA) Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Progressive WordPress (PWA) Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Progressive WordPress (PWA) Plugin and the shortcodes it provides:

Plugin Icon
Progressive WordPress (PWA)

"Progressive WordPress (PWA) is a powerful plugin that converts your WordPress website into a progressive web app, enhancing user experience and site performance."

★★★★☆ (31) Active Installs: 2000+ Tested with: 5.7.0 PHP Version: 5.6
Included Shortcodes:
  • [pwp_notification_button]

Progressive WordPress (PWA) [pwp_notification_button] Shortcode

The Progressive-WP plugin shortcode ‘pwp_notification_button’ is designed to generate a notification button. This shortcode uses attributes such as ‘size’ and ‘class’ to customize the button’s appearance. It returns the notification button with these attributes, facilitating user interaction.

Shortcode: [pwp_notification_button]

Parameters

Here is a list of all possible pwp_notification_button shortcode parameters and attributes:

  • size – Defines the font size of the notification button
  • class – Assigns a specific CSS class to the notification button

Examples and Usage

Basic example – Display a notification button with default parameters

[pwp_notification_button /]

Advanced examples

Display a notification button with a specific class

[pwp_notification_button class="my-custom-class" /]

Display a notification button with a specific font size

[pwp_notification_button size="2rem" /]

Display a notification button with a specific class and font size

[pwp_notification_button class="my-custom-class" size="2rem" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [pwp_notification_button] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'pwp_notification_button', [ $this, 'shortcode_template' ] );

Shortcode PHP function:

function shortcode_template( $atts, $content = '' ) {

		$atts = shortcode_atts( [
			'size'  => '1rem',
			'class' => '',
		], $atts );

		$attributes = [
			'class' => $atts['class'],
			'style' => "font-size: {$atts['size']};",
		];

		return pwp_get_notification_button( $attributes );
	}

Code file location:

progressive-wp/progressive-wp/Classes/class-push.php

Conclusion

Now that you’ve learned how to embed the Progressive WordPress (PWA) Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *