WordPress plugin intelligence profile

Commentcode API

A shortcode API alternative.

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 4.7
Current version1.0.0
WordPress coverageTested up to WordPress 4.7
Minimum stackWP 3.4 · PHP —
Directory statusactive
Last directory update21 Dec 20169y ago
Active installationsNewAdoption metric — not a quality score
WordPress.org ratingNo WordPress.org ratings yet
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records Commentcode API version 1.0.0 as active, updated 9y ago and tested up to WordPress 4.7.

Overview

About this plugin

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 --->

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.

" --->

will be

', )

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' );

---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 )

)

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • html comments
  • api
  • commentcode
  • shortcode
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 4.7

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 4.7.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to4.7
Minimum requirementsWordPress 3.4 · PHP not listed
Update activity21 Dec 20169y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.