Commentcode API

Commentcode API

Wordpress plugin

Install on Wordpress

App Details

Generate Custom Outputs with HTML Comments

Commentcode API lets you generate custom outputs with HTML comment-like codes.

It is similar to the Shortcode API except it takes a form of HTML comments and some few features.

Since it takes a form of HTML comments, even the user disables your plugin, the embedded code will not be visible, on contrary to shortcodes that remain in posts when their plugins are deactivated.

Does not leave a mess in posts

Say, you have been using a plugin that converts a plugin specific shortcode into custom outputs. Later you found something else that is more useful and uninstalled it.

But the shortcodes used by that plugin remained in hundreds of posts and it was too much work to manually delete them so you have to ask somebody to run SQL commands.

That’s a problem. What if the shortcode takes a form of an HTML comment? It won’t leave such a mess.

Syntax

It looks like this.

<!--- tag foo="bar" ---> <!--- tag color="#333" ---><p>Some outputs.</p><!--- /tag ---> 

Notice that tripe dashes are used in the both opening and closing part. So it won’t hardly conflict with generic HTML comments.

Supports Multi-dimensional Array Arguments

The shortcode cannot pass multi-dimensional arguments to the callback function.

The below attributes won’t be parsed.

[my_shortcode foo[1]="one" foo[2]="two"] 

However, commentcode can handle it.

<!---my_shortcode foo[1]="one" foo[2]="two" ---> 

The attributes are interpreted as

array( 'foo' => array( 1 => 'one', 2 => 'two', ) ) 

Preserved Letter Cases

The shortcode does not allow capitalized attribute names.

[my_shortcode CapitalName="I need it to be capitalized"] 

The attribute is interpreted as

array( 'capitalname' => 'I need it to be capitalized', ) 

This is not useful when you need to perform remote API requests which require argument names with capital letters.

However, the commentcode API preserves those argument names.

<!--- my_shortcode CapitalName="Please keep capitalization!" ---> 

will be

array( 'CapitalName' => 'Please keep capitalization!', ) 

Register a Commentcode

Use the add_commentcode() function. It accepts two parameters.
1. (string) the commentcode tag.
2. (callable) a callback function which gets called when the commentcode of the specified tag is processed.

The callback function receives three parameters.
1. (string) The filtered text, usually an empty string.
2. (array) The attributes set in the commentcode.
3. (string) The commentcode tag name.

function get_my_commentcode( $text, $arguments, $tag ) { return "<pre>" . htmlspecialchars( print_r( $arguments, true ) ) . "</pre>"; } add_commentcode( 'my_commentcode', 'get_my_commentcode' ); 

For a test, while running the above code, try inserting <!---my_commentcode Foo="bar" numbers[ 1 ]="one" numbers[ 2 ]="two"---> in a post.

It will produce this output,

Array ( [Foo] => bar [numbers] => Array ( [1] => one [2] => two ) ) 

Pricing

Starting from $0 per month.

Check Out the Instagram Feed Widget

By Common Ninja

Instagram FeedTry For Free!

App Info

Rating

Reviewers

No reviews

Tags

api
shortcode

Developed By

Michael Uno

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Forms

Forms plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Comments

Comments plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Maps

Maps plugins for Wordpress

Security

Security plugins for Wordpress

Translation

Translation plugins for Wordpress

Ads

Ads plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Chat

Chat plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Membership

Membership plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Contact

Contact plugins for Wordpress

Comments

Comments plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

Instagram Feed for Wordpress logo

Instagram Feed

Show Instagram posts in a live feed that keeps content fresh, builds social proof, and helps visitors engage with your brand.

Course Registration Form for Wordpress logo

Course Registration Form

Use a scroll progress bar that visually tracks reading on the page, improves navigation, and keeps visitors aware of their position.

All in One Reviews for Wordpress logo

All in One Reviews

Display and manage customer reviews from multiple platforms in one place to build trust and highlight brand credibility.

Google Play Reviews for Wordpress logo

Google Play Reviews

Show Google Play reviews for your Android app to build trust, strengthen credibility, and help visitors make confident download decisions.

Feature Voting for Wordpress logo

Feature Voting

Use feature voting so users submit ideas, vote on requests, and help you prioritize product updates by real customer demand.

YouTube Feed for Wordpress logo

YouTube Feed

Show YouTube videos in a customizable YouTube feed that keeps content fresh, boosts watch time, and helps visitors explore more of your channel.

Audio Player for Wordpress logo

Audio Player

Add a no-code audio player to your site and boost engagement with music, podcasts, and voice content effortlessly.

Timeline for Wordpress logo

Timeline

Use a timeline widget to display events and milestones in chronological order with images and text so visitors understand your story clearly.

Reviews Trust Box for Wordpress logo

Reviews Trust Box

Display ratings from multiple platforms in a reviews trust box that builds credibility, social proof, and boosts conversions.

Nudge Button for Wordpress logo

Nudge Button

Nudge button with a subtle shaking animation that draws attention to important calls to action, increases interaction, and helps boost conversions.

Sticky Video for Wordpress logo

Sticky Video

Use a sticky video that stays visible while users scroll to keep content in view, increase watch time, and boost engagement.

Petition Form for Wordpress logo

Petition Form

Gather supporter signatures with a petition form that collects entries, saves submissions, sends notifications, and helps you drive meaningful change efficiently.

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms