Nested shortcodes

If you are integrating with WordPress or WooCommerce, start here.
blamingas
Posts: 10
Joined: Sat May 23, 2020 7:39 am
Contact:

Nested shortcodes

Postby blamingas » Wed Jan 20, 2021 2:59 pm

(sorry, I've posted this thread into a wrong section. Re-posting it here).
Hello.
I'm using WebRotate's Wordpress plugin and I'm going to use expanded mode of shortcode:
[wr360expand name="view4" browserfs="false" config="url-of-the-viewer-config.xml"]thumbnail or text[/wr360expand]

And instead of adding just a picture for thumbnail, in functions.php of Wordpress theme I created my custom shortcode [spin360_icon] (with pre-adjusted css) which I want to add to "thumbnail or text" of your shortcode. However Wordpress doesn't allow to use shortcode inside of shortcode, it requires to create so called "nested shortcode" which means that I have to include my shortcode [spin360_icon] into the php code of your one. In plugin folder I've found the file class-wr360-shortcodes.php with wr360expand shortcode - what should I change in there to include my [spin360_icon] code so Wordpress would allow me to use it as a thumbnail inside of your shortcode [wr360expand]?
Thanks.

Kind regards,
Oleksiy Kardash

WebSupport
Posts: 1105
Joined: Thu Aug 23, 2012 11:35 am
Location: Pasadena, CA
Contact:

Re: Nested shortcodes

Postby WebSupport » Wed Jan 20, 2021 10:26 pm

Hi Oleksiy,

We're not familiar with nested shortcodes in WordPress unfortunately, but you can modify the content (i.e "thumbnail or text" as per your example) as needed in PHP in class-wr360-shortcodes.php by changing the $content parameter:

Code: Select all

    public function add_expand_shortcode_hanlder($atts, $content)
    {
    ...
        $replace .= $content;
    ...

blamingas
Posts: 10
Joined: Sat May 23, 2020 7:39 am
Contact:

Re: Nested shortcodes

Postby blamingas » Thu Jan 21, 2021 8:14 am

Thank you. After changing $content parameter my custom shortcode is correctly placed in "thumbnail or text" area and desired image is showing up (my custom shortcode returns a div with background image and css parameters). However it doen't work as a link to my 360 expanded viewer. It just shows as a regular non-clickable image, while the original content "thumbnail or text" was a link before my changes.
Could you please suggest me how can I fix it? Thanks
---------
$replace .= $content; // this line I replaced with the next code:

$spin360_icon_shortcode = do_shortcode( '[spin360_icon]' );
$replace .= $spin360_icon_shortcode;

WebSupport
Posts: 1105
Joined: Thu Aug 23, 2012 11:35 am
Location: Pasadena, CA
Contact:

Re: Nested shortcodes

Postby WebSupport » Thu Jan 21, 2021 8:25 am

Hi! We would need to see it in action to advise. Can you possibly share a link to the page with the issue? You may send it to support at webrotate360 dot com or paste here.

blamingas
Posts: 10
Joined: Sat May 23, 2020 7:39 am
Contact:

Re: Nested shortcodes

Postby blamingas » Thu Jan 21, 2021 8:37 am

WebSupport wrote:Hi! We would need to see it in action to advise. Can you possibly share a link to the page with the issue? You may send it to support at webrotate360 dot com or paste here.

Sure, here is the link: https://hochunoshu.com.ua/product/%d1%8 ... %b0%d1%80/
you can see the test icon "360" on the bottom of the page under the product-gallery box.
Thanks

WebSupport
Posts: 1105
Joined: Thu Aug 23, 2012 11:35 am
Location: Pasadena, CA
Contact:

Re: Nested shortcodes

Postby WebSupport » Thu Jan 21, 2021 8:50 am

It doesn't seem like your code is rendering yet. May be it's some sort of page cache you have there?

2021-01-21_8-47-34.png


You can simply add this instead of rendering another shortcode (at least to test this):

$replace .= '<div class="spin360-icon"></div>';

blamingas
Posts: 10
Joined: Sat May 23, 2020 7:39 am
Contact:

Re: Nested shortcodes

Postby blamingas » Thu Jan 21, 2021 9:30 am

Ah yes, that was easier. It works now! Thank you!


Return to “WordPress and WooCommerce Integration”

cron