Skip Navigation

[Resolved] Nested shortcodes not processing correctly

This support ticket is created 8 years, 1 month 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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 24 replies, has 3 voices.

Last updated by Adriano 8 years ago.

Assisted by: Adriano.

Author
Posts
#373170

Ben

I am trying to: Get nested shortcodes to work

I visited this URL: (will share private)

I expected to see: The shortcode processed, but it is not

Instead, I got:

Im trying to pass the attachment image url to my function to to an ID lookup in order to generate a srcset attribute. I did have this working for some time, but it stopped working, I believe with the last update. Here is my code:

In Views:

[wpv-if <!-- conditions for if -->]
              <img src="[types field='featured-slider-image' size='slider-banner' url='true']" srcset="[srcset size="slider-banner"][types field="featured-slider-image" size="slider-banner" url="true"][/srcset]" class="custom-image featured-slider-image" title="[wpv-post-title]" alt="[wpv-post-title]" />
[/wpv-if]

output:
[php]
<img src="hidden link" srcset="[srcset size='slider-banner']hidden link" class="custom-image featured-slider-image" title="post-title" alt="alt text">
[php]

Now I've registered the custom shortcode, and this was working. I've also tried outputting the srcset attribute as well (ie not having it in the view markup, but in the shortcode output), but this is broken too.

Thankfully it's not breaking the page, but it sure is annoying as it had been working very well.

#373412

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

1)
Could you please share debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

2)
Could you please try to resolve your issue by deactivating all third-party plugins as well as the default theme to check for any possible conflicts with any of the plugins or themes?

3)
Could you please share problem URL?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#375335

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Unfortunately, wp-admin access details are not working.

Before you resend it to me:
Could you please try to register your shortcode at:
=> Views -> Settings -> Compatibility -> Third-party shortcode arguments

Please refer to the following image:
=> hidden link

I hope this will help you to fix your issue.

#375379

Ben

Hi sorry for the trouble, I've updated the username and pass in the last post.

You'll find that the shortcode is already registered with Views.

Best

#375735

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I think your issue is related to this:
https://codex.wordpress.org/Shortcode_API#Nested_Shortcodes

Could you please check nested shortcode rules provided by wordpress.

#376006

Ben

Hello Minesh,

I've looked at the Shortcode API, and I'm confident that my code is ok and that Im running do_shorcode() recursively in –– everything seems correct on my end.

I've tried a few more tests, and found that third party shortcodes fail within wpv-if conditions. I greatly simplified my shortcode to simply return, a "I-Ran" / "I-did-not-run" message, and here are the results in my Views code:

[wpv-layout-start]
    [wpv-items-found]
				<!-- wpv-loop-start -->
				<wpv-loop>
                                
                                 <!-- WILL BE PROCESSED -->
                                [srcset2][types field="featured-slider-image" size="slider-banner" url="true"][/srcset2]
                                <!-- RETURNS: "I-Ran" -->

                                [wpv-if field1="wpcf-display-image-without-link" evaluate="($field1 = 0)"]

                                      <!-- WONT BE PROCESSED -->
	              		      [srcset2][types field="featured-slider-image" size="slider-banner" url="true"][/srcset2]
                                      <!-- RETURNS: [srcset2]<em><u>hidden link</u></em> -->

	              	        [/wpv-if]
				</wpv-loop>
				<!-- wpv-loop-end -->
  [/wpv-items-found]
[wpv-layout-end]

It appears that third-party shortcodes are not being processed within wp-if conditions.

Please escalate this to the development team. If there is any question about the shortcode itself I've included the simplified test version here:

function test_srcset($atts, $url = null) {
    if ($url) {
        $url  = esc_url_raw(do_shortcode($url)); // sanitise the url
        return "i-ran-we-found-content-(" . $url . ")";
    } else {
        return "i-ran-we-found-no-content";
    }
}
add_shortcode('srcset2', 'test_srcset');
#376108

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please send me above example URL where you have added your view.

#376231

Ben

Sir,
I shared a link that demonstrates the shortcode opperating outside a Views logic and in a view in the private post above.

Ben

#376475

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Let me give a try once and if I'll not succeed I'll escalate this ticket to our next level support.

#376622

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've escalated your ticket to our next level support. Please be patient, wait for a reply from them and they will get in touch with you as soon as possible.

#376647

Ben

Thank you.
Ben

#376695

Hello,

I’m Adriano, Toolset support lead and I have been escalated to this thread. I’ll give my best to help you to achieve your needs through Toolset components.

I've done several tests and I couldn't reproduce that issue. Then I've figured out that Views isn't updated, please update to Views 1.12.1 and let me know if it solves your issue.

#376712

Ben

Adriano,

Thanks for looking at this. I can reproduce the issue in my local environment which has been updated. But I've now updated the staging sites as well, and the issue is the same.

Best,
Ben

#376714

Ben

Adriano - in your tests are you using the same syntax as my own view "fpslider"? Its using the wp-if syntax.

#376747
Captura de Tela 2016-03-18 às 13.41.48.png

Yes, my code:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
    <wpv-loop>
      	[wpv-conditional if="( $(wpcf-my-single) ne '' )"]
        	[srcset2][types field="my-single"][/types][/srcset2]
      	[/wpv-conditional]
    </wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
	[/wpv-no-items-found]
[wpv-layout-end]

It's printing the attached.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.