WordPress / Documentation-Issue-Tracker

Issue Tracker for the WordPress Documentation team.
https://make.wordpress.org/docs/
Other
78 stars 37 forks source link

[HelpHub] Shortcode block screenshots #791

Open zzap opened 1 year ago

zzap commented 1 year ago

Issue Description

Screenshots for shortcode block suggest that <iframe> markup can be used inside the block. This is not correct and screenshots should show the example of adding shortcode.

URL of the Page with the Issue

https://wordpress.org/documentation/article/shortcode-block/

Section of Page with the issue

Why is this a problem?

Because it's misleading.

Suggested Fix

Change screenshots to show the actual shortcode being used inside shortcode block.

github-actions[bot] commented 1 year ago

Heads up @femkreations @atachibana - the "user documentation" label was applied to this issue.

zzap commented 1 year ago

Heads up @WordPress/docs-issues-coordinators, we have a new issue open. Time to use 'em labels.

xbor17 commented 1 year ago

Attaching the new required screenshots using a default WordPress supported shortcode: [caption]...[/caption] wp-block-1 wp-block-2 wp-block-3 wp-block-4 wp-block-5

TonyGravagno commented 9 months ago

I came here when I just saw the Shortcode Block page was completely wrong. 😀

In addition to, perhaps before the proposed sample, it might be helpful to start with an extremely easy example, since this feature has always been advertised as an extremely easy way to do what it does.


In the Shortcode Block, use this syntax : [say_hello] (Yes, brackets are required)

// functions.php
function hola( $atts ) { return '<p>Ciao!</p>'; }`
add_shortcode( 'say_hello','hola' );

That's all there is to it. Use $atts or ignore it. Return any output. Use proper HTML if the target is the browser.
The function can also return "<script>// code </script>" or generated CSS.


I'll volunteer this text if it seems helpful :


While the Shortcode Block provides more control, the shortcode can be used anywhere, without the block, simply by using the "[name]" syntax. For example, "Text before [shortcode] and afterward." Shortcodes can be used anywhere, including posts or pages, templates or template parts, patterns, menus, image captions. or dashboard widgets. Multiple shortcodes can be used on a page: "This is [s1] and this is [s2]."
Can be used in a Custom HTML Block : <p>[my_shortcode x="1" y="2"]</p>

It is possible for shortcodes to be nested, though this is not consistently supported and therefore not recommended. For example: "[greet [username]]." To return "Good Morning, Admin." or "Good Evening, Member." This may not work by default but has been supported to some extent by plugins and at least one Make project. Research if desired, but consider alternative approaches.

The shortcode is an extremely powerful feature that allows content to execute code. This should not be used without serious consideration. Shortcodes are not inherently safe because they are in a plugin or theme.
Site developers should be aware that over the history of WordPress it has been possible for shortcodes to be added by vistors, even when not logged-in, to invoke functionality in the site. Caution is recommended. Test sites with each upgrade. Be aware of related open tickets and warnings. Be prepared to reverse an update of plugins, themes, and even core WordPress if there are issues with shortcodes.


If anyone looking at this ticket wonders why I've included the above warning:
https://core.trac.wordpress.org/ticket/58333 Fixed significant v6.2 issue
https://core.trac.wordpress.org/ticket/58366 Open for 6 months, as of 23/11/07 this is a v6.5 Milestone
I hit a similar issue in v6.3 today. That's what led me to lookup shortcode issues. That's how I got here today.