Hurrytimer Shortcode

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

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

Plugin Icon
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce

"HurryTimer is a versatile WordPress & WooCommerce plugin that creates a sense of urgency and scarcity with a customizable countdown timer. Ideal for boosting conversions and sales."

★★★★☆ (131) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [hurrytimer]

Hurrytimer [hurrytimer] Shortcode

The Hurrytimer shortcode is a versatile tool that allows for the creation and management of countdown campaigns. It accepts attributes, fetches the corresponding campaign, and checks if it’s expired. If so, it triggers specific actions. The shortcode also builds a template for the campaign. If the template is not empty, it wraps the template and returns it.

Shortcode: [hurrytimer]

Parameters

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

  • id – Unique identifier for the countdown timer campaign

Examples and Usage

Basic example – A simple usage of the hurrytimer shortcode to display a campaign timer by referencing its ID.

[hurrytimer id=1 /]

Advanced examples

Displaying a campaign timer with customized attributes. The timer will change its appearance based on the provided attributes.

[hurrytimer id=1 color="red" size="large" /]

Using the shortcode to display a campaign timer with a fallback. If the campaign with the specified ID is not found or expired, it will try to load another campaign with a different ID.

[hurrytimer id=1 fallback_id=2 /]

Using the shortcode to display a campaign timer with a specific action to be executed once the timer expires. The action can be a URL redirection, a message display, or any other predefined action in the plugin.

[hurrytimer id=1 action="redirect" action_url="http://example.com" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'hurrytimer', [ $this, 'content' ] );

Shortcode PHP function:

function content( $attrs )
    {

        $attrs = shortcode_atts($this->default_attrs, $attrs, 'hurrytimer');
        $attrs = filter_var_array( $attrs, $this->attrs_filter_def );

        $campaign = hurryt_get_campaign( absint( $attrs[ 'id' ] ) );

        if ( $campaign->is_expired() ) {
            ( new ActionManager( $campaign ) )->run();
        }

        // TODO: Move `build_template` to `TemplateBuilder->build(int $campaign_id)`.
        $template = apply_filters( 'hurryt_campaign_template', $campaign->build_template(), $campaign->get_id() );

        return !empty( $template ) ? $campaign->wrap_template( $template, $attrs ) : '';
    }

Code file location:

hurrytimer/hurrytimer/includes/CampaignShortcode.php

Conclusion

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