Nitropack Shortcode

Below, you’ll find a detailed guide on how to add the Nitropack 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 Nitropack Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Nitropack Plugin and the shortcodes it provides:

Plugin Icon
NitroPack – Cache & Speed Optimization for Core Web Vitals, Defer CSS & JavaScript, Lazy load Images

NitroPack is a powerful plugin designed to optimize your WordPress site's speed and cache. The plugin supports Core Web Vitals, Defer CSS & JavaScript, and Lazy load Images for a smooth, fast-loading website.

★★★★✩ (286) Active Installs: 100000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [gravityform]

Nitropack [gravityform] Shortcode

The Nitropack plugin shortcode ‘gravityform’ is designed to modify Gravity Forms. It adds a loading image while the form loads, enhancing user experience.

Shortcode: [gravityform]

Examples and Usage

Basic example – The following shortcode is used to display a basic gravity form where you only need to specify the form id.

[gravityform id=1 /]

Advanced examples

1. In this example, the shortcode is used to display a gravity form with the form id and title. If the form is not found by id, it will try to load the form by title.

[gravityform id=1 title='Contact Form' /]

2. This example demonstrates the use of the shortcode to display a gravity form with the form id, title, and description. If the form is not found by id, it will try to load the form by title. The description will be displayed below the form.

[gravityform id=1 title='Contact Form' description='This is a contact form.' /]

3. In this advanced example, the shortcode is used to display a gravity form with the form id, title, description, and ajax. The ajax attribute enables the form to submit without refreshing the page.

[gravityform id=1 title='Contact Form' description='This is a contact form.' ajax=true /]

PHP Function Code

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

Shortcode line:

add_shortcode('gravityform', [$this, 'modify_gf_shortcode']);

Shortcode PHP function:

function modify_gf_shortcode($atts, $content = null ) {

		return '<div class="nitropack-gravityforms-shortcode" data-shortcode-attributes="'.esc_attr(json_encode($atts)).'"><img src="'.esc_url(NITROPACK_PLUGIN_DIR_URL . 'view/images/loading.gif').'" alt="loading" /></div>';
	}

Code file location:

nitropack/nitropack/classes/Integration/Plugin/GravityForms.php

Conclusion

Now that you’ve learned how to embed the Nitropack 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 *