Title: Commentcode API
Author: miunosoft
Published: <strong>डिसेम्बर 17, 2016</strong>
Last modified: डिसेम्बर 21, 2016

---

प्लगिनहरू खोज्नुहोस्

![](https://ps.w.org/commentcode-api/assets/banner-772x250.jpg?rev=1559034)

यो प्लगिन **वर्डप्रेसका ३ प्रमुख नवीनतम रिलीजहरूसँग परीक्षण गरिएको छैन**। यो अब 
सम्भवतः व्यवस्थित वा समर्थन नभएको हुन सक्छ र वर्डप्रेसका नयाँ संस्करणहरूमा प्रयोग
गर्दा अनुकूलता सम्बन्धी समस्या हुन सक्छ।

![](https://ps.w.org/commentcode-api/assets/icon-256x256.png?rev=1559066)

# Commentcode API

 [miunosoft](https://profiles.wordpress.org/miunosoft/) द्वारा

[डाउनलोड गर्नुहोस्](https://downloads.wordpress.org/plugin/commentcode-api.1.0.0.zip)

 * [विवरण](https://ne.wordpress.org/plugins/commentcode-api/#description)
 * [समीक्षाहरू](https://ne.wordpress.org/plugins/commentcode-api/#reviews)
 *  [स्थापना](https://ne.wordpress.org/plugins/commentcode-api/#installation)
 * [विकास](https://ne.wordpress.org/plugins/commentcode-api/#developers)

 [सहायता](https://wordpress.org/support/plugin/commentcode-api/)

## विवरण

#### 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](https://codex.wordpress.org/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
            )

    )
    ```

## स्थापना

 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.

## प्रश्नोत्तर

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

## समीक्षाहरू

यस प्लगिनको लागि कुनै समीक्षाहरू छैनन्।

## योगदानकर्ता र डेभलपरहरू

“Commentcode API” खुला स्रोत सफ्टवेयर हो। निम्न व्यक्तिहरूले यो प्लगिनमा योगदान 
गरेका छन्।

योगदानकर्ताहरू

 *   [ miunosoft ](https://profiles.wordpress.org/miunosoft/)
 *   [ Michael Uno ](https://profiles.wordpress.org/michael-uno/)

[“Commentcode API” लाई आफ्नो भाषामा अनुवाद गर्नुहोस्](https://translate.wordpress.org/projects/wp-plugins/commentcode-api)

### विकासमा रुचि छ?

[आरएसएस](https://plugins.trac.wordpress.org/log/commentcode-api/?limit=100&mode=stop_on_copy&format=rss)
द्वारा [कोड ब्राउज गर्नुहोस्](https://plugins.trac.wordpress.org/browser/commentcode-api/),
[एसभीएन रिपजिटरी](https://plugins.svn.wordpress.org/commentcode-api/) हेर्नुहोस्,
वा [विकास लग](https://plugins.trac.wordpress.org/log/commentcode-api/) को सदस्यता
लिनुहोस्।

## चेन्जलग

#### 1.0.0

 * Released.

## मेटा

 *  संस्करण **1.0.0**
 *  पछिल्लो अपडेट **10 वर्ष अघि**
 *  सक्रिय स्थापना **१० भन्दा कम**
 *  वर्डप्रेस संस्करण ** 3.4 वा उच्च **
 *  जाँच गरिएको **4.7.0**
 *  भाषा
 * [English (US)](https://wordpress.org/plugins/commentcode-api/)
 * ट्यागहरू
 * [api](https://ne.wordpress.org/plugins/tags/api/)[shortcode](https://ne.wordpress.org/plugins/tags/shortcode/)
 *  [उन्नत दृश्य](https://ne.wordpress.org/plugins/commentcode-api/advanced/)

## रेटिङ्गहरू

अहिलेसम्म कुनै समीक्षा पेस गरिएको छैन।

[तपाईँको समीक्षा](https://wordpress.org/support/plugin/commentcode-api/reviews/#new-post)

[सबै समीक्षाहरू हेर्नुहोस्](https://wordpress.org/support/plugin/commentcode-api/reviews/)

## योगदानकर्ताहरू

 *   [ miunosoft ](https://profiles.wordpress.org/miunosoft/)
 *   [ Michael Uno ](https://profiles.wordpress.org/michael-uno/)

## सहायता

केही भन्नु छ? सहयोग चाहियो?

 [सहायता फोरम हेर्नुहोस्](https://wordpress.org/support/plugin/commentcode-api/)

## दान गर्नुहोस्

के तपाईँ यस प्लगिनको उन्नतिको लागि सहायता गर्न चाहनुहुन्छ?

 [ यो प्लगिनको लागि दान गर्नुहोस् ](http://en.michaeluno.jp/donate)