Plugin info

Total downloads: 1,037
Active installs: 0
Total reviews: 0
Average rating: 0
Support threads opened: 0
Support threads resolved: 0 (0%)
Available in: 1 language(s)
Contributors: 2
Last updated: 12/21/2016 (3296 days ago)
Added to WordPress: 12/17/2016 (9 years old)
Minimum WordPress version: 3.4
Tested up to WordPress version: 4.7.0
Minimum PHP version: f

Maintenance & Compatibility

Maintenance score

Possibly abandoned • Last updated 3296 days ago

20/100

Is Commentcode API abandoned?

Possibly abandoned (last update 3296 days ago).

Compatibility

Requires WordPress: 3.4
Tested up to: 4.7.0
Requires PHP: f

Similar & Alternatives

Explore plugins with similar tags, and compare key metrics like downloads, ratings, updates, support, and WP/PHP compatibility.

No similar plugins found yet.

Description

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.





Some outputs.

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.


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

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 "
" . htmlspecialchars( print_r( $arguments, true ) ) . "
"; } add_commentcode( 'my_commentcode', 'get_my_commentcode' );

For a test, while running the above code, try inserting in a post.

It will produce this output,

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

)

Installation

  1. Upload commentcode-api.php and other files compressed in the zip folder to the /wp-content/plugins/ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.

Frequently Asked Questions

The commentcode inserted in a post does not get converted. What’s the problem?

Double check you insert it in the View panel of the editor.

Review feed

No reviews available

Screenshots

No screenshots available

Changelog

1.0.0

  • Released.