Skip Navigation

[Resolved] Comment View Code With Comment Tag

This support ticket is created 6 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by chuckH 6 years, 4 months ago.

Assisted by: Beda.

Author
Posts
#918477

Hi. Besides standard HTML comments (i.e. <!-- this is a comment -->), Is there a way to comment view code?

For example...
SINGLE LINE [wpv-comment "this is a comment" ]
MULTIPLE LINES [comment] ... [/comment]

Thank you!

#918712

No, there is no such ShortCode in the Toolset Plugins.

The only way, currently, is to use native HTML comments syntax.
However, it would be possible to register such a ShortCode yourself in a Custom Plugin, or in your Theme's functions.php File.

You'd follow this WordPress Codex:
https://codex.wordpress.org/Shortcode_API

You could simply let the ShortCode return your HTML comments, or even create an enclosing ShortCode, where you can wrap inserted contents with your custom HTML (such as you depict it in your comment above).

An example, you can add such 2 functions to your site:

function html_comment_start_func( $atts ){
	return "<!--";
}
add_shortcode( 'html-comment-start', 'html_comment_start_func' );

function html_comment_end_func( $atts ){
	return "-->";
}
add_shortcode( 'html-comment-end', 'html_comment_end_func' );

Later, apply those ShortCodes like this:

This is the shown content 
          [html-comment-start]This is the hidden content[html-comment-end]

It will result in this HTML:

 This is the shown content 
<!--This is the hidden content-->

Or, you can create an enclosing ShortCode:

function html_comment_func( $atts, $content = null ) {
	return '<!--' . $content . '-->';
}
add_shortcode( 'html-comment', 'html_comment_func' );

And then use that like:

 [html-comment]This is the hidden content[/html-comment]

I hope that helps.

I don't think we will implement that in the GUI as the request is not yet very popular (it's the first time we receive it until now), and it is relatively trivial to create a own ShortCode.

However, if you wish I can let the Developers consider a new feature that would allow this with the GUI.

#919013

Hi. Thank you for taking the time to review and reply to my query/suggestion.

I was hoping for a built-in Toolset shortcode to wrap comments in so that they do not show up in HTML source code.

<!-- This is good, but viewable in HTML source code -->

I was after something like this (i.e. not viewable in HTML source code):

<?php /* PHP comments not visible in HTML source code */ ?>

{% comment %} Django comments not visible in HTML source code {% endcomment %}

It's a helpful, but not essential feature. Maybe something for a later release version.

Keep up the good work.