Prismatic Shortcode

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

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

Plugin Icon
Prismatic

"Prismatic is a WordPress plugin that provides a simple yet powerful solution for highlighting syntax in your posts. It's user-friendly and highly customizable, making your content more engaging and easier to read."

★★★★☆ (42) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: 5.6.20
Included Shortcodes:
  • [prismatic_code]

Prismatic [prismatic_code] Shortcode

The Prismatic plugin shortcode is a powerful tool that enables the display of code snippets in WordPress. The shortcode takes a ‘class’ attribute, allowing custom styling. It encodes the content to ensure safe display, then decodes it within HTML ‘code’ tags. This ensures the code snippet is displayed correctly and securely.

Shortcode: [prismatic_code]

Parameters

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

  • class – specifies a unique CSS class for the code block
  • content – the content that is to be encoded and decoded

Examples and Usage

Basic example – The prismatic_code shortcode is used to encode and decode the content passed within it. It also allows you to add a class to the output.

[prismatic_code]Your content here[/prismatic_code]

Advanced examples

Adding a class to the prismatic_code shortcode. The output will be wrapped in a <code> tag with the specified class.

[prismatic_code class="highlight"]Your content here[/prismatic_code]

Using the prismatic_code shortcode to encode and decode multiple lines of content. This can be particularly useful when you need to display code snippets on your WordPress site.

[prismatic_code class="multiline"]
Line 1
Line 2
Line 3
[/prismatic_code]

Combining the prismatic_code shortcode with other shortcodes. In this example, the prismatic_code shortcode is used to encode and decode the output of another shortcode.

[prismatic_code class="nested"] [another_shortcode param="value"] [/prismatic_code]

PHP Function Code

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

Shortcode line:

add_shortcode('prismatic_code', 'prismatic_code_shortcode');

Shortcode PHP function:

function prismatic_code_shortcode($attr, $content = null) {
	
	extract(shortcode_atts(array('class' => '',
		
	), $attr));
	
	$class = $class ? ' class="'. sanitize_html_class($class) .'"' : '';
	
	$encode = prismatic_encode($content);
	$decode = prismatic_decode($encode);
	
	return '<code'. $class .'>'. wp_kses_post($decode) .'</code>';
	
}

Code file location:

prismatic/prismatic/prismatic.php

Conclusion

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