Snippet Shortcodes

Below, you’ll find a detailed guide on how to add the Snippet Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Snippet Shortcodes Plugin shortcodes not to show or not to work correctly.

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

Plugin Icon
Snippet Shortcodes

"Snippet Shortcodes is a handy WordPress plugin that allows users to easily create and manage shortcodes. Use it to enhance your site functionality and streamline content updates."

★★★★☆ (23) Active Installs: 5000+ Tested with: 6.3.2 PHP Version: 7.2
Included Shortcodes:
  • [yeken-license-price]
  • [sv-promo]
  • [sv-promo-free]
  • [sv-promo-premium]
  • [sv-promo-all]
  • [sh_cd_shortcode]

Snippet [yeken-license-price] Shortcode

The Yeken License Price shortcode is a handy tool that retrieves the price of a specific product. It accepts parameters like ‘sku’, ‘type’, and ‘prefix’. It uses these parameters to determine the product’s price based on its SKU and the type of license (yearly or monthly). The ‘prefix’ parameter allows for currency symbols. If the price exists, it returns the price with the prefix; otherwise, it returns an empty string.

Shortcode: [yeken-license-price]

Parameters

Here is a list of all possible yeken-license-price shortcode parameters and attributes:

  • sku – Specifies the product’s unique stock keeping unit.
  • type – Determines the billing period, default is ‘yearly’.
  • prefix – Sets the currency symbol, default is ‘£’.

Examples and Usage

Basic example – The shortcode below is used to display the price of a license with default parameters. It uses the default SKU (sv-premium), type (yearly), and prefix (£).

[yeken-license-price /]

Advanced examples

Here, we’re using the shortcode to display the price of a license with specific parameters. We’ve specified the SKU as ‘sv-basic’, the type as ‘monthly’, and the prefix as ‘$’.

[yeken-license-price sku="sv-basic" type="monthly" prefix="$" /]

In this next example, we’re using the shortcode to display the price of a license with a different set of parameters. We’ve specified the SKU as ‘sv-ultimate’, the type as ‘yearly’, and kept the default prefix (£).

[yeken-license-price sku="sv-ultimate" type="yearly" /]

Finally, in this example, we’re using the shortcode to display the price of a license but we’re only specifying the SKU as ‘sv-premium’ and letting the default parameters for type and prefix apply.

[yeken-license-price sku="sv-premium" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'yeken-license-price', 'yeken_license_shortcode' );

Shortcode PHP function:

function yeken_license_shortcode( $args ) {

            $args = wp_parse_args( $args, [ 'sku' => 'sv-premium', 'type' => 'yearly', 'prefix' => '£' ] );

            $price = yeken_license_price( $args[ 'sku' ], $args[ 'type' ] );

            if ( false === empty( $price ) ) {
                return sprintf( '%s%d', esc_html(  $args[ 'prefix' ] ), $price );
            }

            return '';
        }

Code file location:

shortcode-variables/shortcode-variables/includes/license.php

Snippet [sv-promo] Shortcode

The ‘sv-promo’ shortcode from the Shortcode-Variables plugin generates a list of both premium and free shortcodes. It sorts them into two categories and displays each shortcode’s key and description.

Shortcode: [sv-promo]

Examples and Usage

Basic example – A shortcode is used to display a list of premium shortcodes.

[sv-promo]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sv-promo', 'sh_cd_shortcode_render_text' );

Shortcode PHP function:

function sh_cd_shortcode_render_text() {

	$output = '**Premium Shortcodes**' . PHP_EOL;

	$shortcodes = sh_cd_shortcode_presets_premium_list();

	foreach ( $shortcodes as $key => $data ) {
		$output .= sprintf('- %s - %s' . PHP_EOL , $key, $data['description'] );
	}

	$output .= '**Free Shortcodes**' . PHP_EOL;

	$shortcodes = sh_cd_shortcode_presets_free_list();

	foreach ( $shortcodes as $key => $data ) {
		$output .= sprintf('- %s - %s' . PHP_EOL , $key, $data['description'] );
	}

	return $output;

}

Code file location:

shortcode-variables/shortcode-variables/includes/shortcode.presets.core.php

Snippet [sv-promo-free] Shortcode

The ‘sv-promo-free’ shortcode is a part of the Shortcode-Variables plugin. It triggers the ‘sh_cd_shortcode_render_table_free’ function which returns predefined ‘free’ shortcodes.

Shortcode: [sv-promo-free]

Examples and Usage

Basic example – The following shortcode is used to display a table of free pre-made shortcodes.

[sv-promo-free]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sv-promo-free', 'sh_cd_shortcode_render_table_free');

Shortcode PHP function:

function sh_cd_shortcode_render_table_free() {

	return sh_cd_display_premade_shortcodes( 'free' );

}

Code file location:

shortcode-variables/shortcode-variables/includes/shortcode.presets.core.php

Snippet [sv-promo-premium] Shortcode

The SV-Promo-Premium shortcode is a prebuilt function that displays premium content on your WordPress site. This shortcode works by calling the ‘sh_cd_shortcode_render_table_premium’ function, which returns a table of premium shortcodes. This allows for easy and efficient management of premium content.

Shortcode: [sv-promo-premium]

Examples and Usage

Basic example – A simple usage of the shortcode ‘sv-promo-premium’ to display content related to ‘premium’.

[sv-promo-premium]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sv-promo-premium', 'sh_cd_shortcode_render_table_premium');

Shortcode PHP function:

function sh_cd_shortcode_render_table_premium() {

	return sh_cd_display_premade_shortcodes( 'premium' );

}

Code file location:

shortcode-variables/shortcode-variables/includes/shortcode.presets.core.php

Snippet [sv-promo-all] Shortcode

The ‘sv-promo-all’ shortcode from Shortcode Variables plugin generates a table displaying all pre-made shortcodes. It calls the function ‘sh_cd_shortcode_render_table_all’ which returns the table.

Shortcode: [sv-promo-all]

Examples and Usage

Basic example – Utilizes the ‘sv-promo-all’ shortcode to display all pre-made shortcodes.

[sv-promo-all /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sv-promo-all', 'sh_cd_shortcode_render_table_all');

Shortcode PHP function:

function sh_cd_shortcode_render_table_all() {

	return sh_cd_display_premade_shortcodes();

}

Code file location:

shortcode-variables/shortcode-variables/includes/shortcode.presets.core.php

Snippet [sh_cd_shortcode] Shortcode

The Shortcode-Variables plugin shortcode, ‘sh_cd_shortcode’, is designed to parse arguments and render the desired shortcode. It takes ‘slug’ as an argument.

Shortcode: [sh_cd_shortcode]

Parameters

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

  • slug – The unique name used to identify the shortcode

Examples and Usage

Basic example – The shortcode is used to add a specific code snippet that has been stored in the Shortcode Variables plugin. The ‘slug’ parameter is used to specify the particular code snippet.

[sh_cd slug="example_slug" /]

Advanced examples

The shortcode can be used with multiple ‘slug’ parameters to add several code snippets. The parameters should be separated by spaces. The code snippets will be added in the order that they are specified.

[sh_cd slug="example_slug1" slug="example_slug2" slug="example_slug3" /]

Another advanced usage is to use the shortcode within a PHP code block. This allows for more complex functionality, such as conditionally adding code snippets based on certain conditions. In the following example, the shortcode is used within a ‘if’ statement in a PHP code block.

if ( condition ) {
    echo do_shortcode( '[sh_cd slug="example_slug"]' );
}

PHP Function Code

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

Shortcode line:

add_shortcode( SH_CD_SHORTCODE, 'sh_cd_shortcode' );

Shortcode PHP function:

function sh_cd_shortcode( $args ) {

	$args = wp_parse_args( $args, [ 'slug' => NULL ] );

	return sh_cd_shortcode_render( $args );
}

Code file location:

shortcode-variables/shortcode-variables/includes/shortcode.user.php

Conclusion

Now that you’ve learned how to embed the Snippet Shortcodes Plugin shortcodes, 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 *