Skip Navigation

[Resolved] Shortcodes with parameters upgrade after error php

This support ticket is created 2 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.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

This topic contains 6 replies, has 2 voices.

Last updated by Jamal 2 years, 4 months ago.

Assisted by: Jamal.

Author
Posts
#2236957

I am trying to: I need to move my WordPress landscape to PHP8 (! that's main target, can't stay on v.7.3 ). I have Divi template assigned to Page where couple of Views are listed. They are putted in Divi Text Module. Shortcodes are below. Please provide a clear guidence how to move them with no functionality loss.

<div>{!{wpv-view name='mysht-list-all-orders' email='[wpv-user field="user_email"]' cached='off'}!}</div>
<div>{!{wpv-view name='mysht-list-all-orders-others' email='[wpv-user field="user_email"]' cached='off'}!}</div>

This Views are showing Woocommerce orders (Completed | Processed) in breakdown by Products in one screen. Each View goes to Subsequent Views ( to select products, that are assigned to orders, filtered by BillingMail ( passing by user_email parameter )). OK works perfectly on current landscape, with PHP7.3 under.

OK, other facts to be mentioned:
0. Latest WordPress (8.4.2), DIVI that supports this type of TOOLSET shortcodes ( version 4.10.8 ( updated 09-20-2021, details here - hidden link ; next Divi release breacks shortcodes, that's tested by me in different approaches. Next DIVI version( with Divi Conditional output) will not support Toolset shortcodes written like mentioned above. Key TOOLSET plugins activated: Toolset Types ( Version 3.4.7 ) + Toolset Views ( Version 3.4.2 ) + Toolset WooCommerce Blocks ( Version 2.9.4 ) + Toolset Access ( Version 2.8.10 ). If I upgrade Types to greater version it breaks shortcode on Divi page, so let's assume only current versions are suitable.

1. I disable all others plugins (with Twenty-Twenty theme active), switch php from 7.3 to 8, site is On
2. Than activate DIVI - site is ON
3. I activate Toolset plugins mentioned above - the first mentioned View - <div>{!{wpv-view name='mysht-list-all-orders' email='[wpv-user field="user_email"]'}!}</div> breacks the page.

Ok. Deactivate everything.
1. I disable all others plugins, switch php from 7.3 to 8, site is On
2. Twenty-Twenty theme active - site is ON. Divi is deactivated.
3. I activate Toolset plugins mentioned above - the first mentioned View - <div>{!{wpv-view name='mysht-list-all-orders' email='[wpv-user field="user_email"]'}!}</div> breaks the page again.

Revert everything. Looks like I need to change shortcodes while I in php7.3 , put them in DIVI "code" module, like

 [ wpv-view name ... ] 

with no

 {!{...}!} 

Please provide right syntax for this, all my experiments are not successfull now... Really appreciate on your support, Toolset is best solution, I'му spent many years with it, and before each upgrade (WordPress or PHP) looks like this almost impossible, but now we need to "pass PHP8.0 milestone", again....

P.s. Duplicator package for experiments on your side can be provided.

#2237439

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello and thank you for contacting the Toolset support.

We have an ongoing project to make Toolset plugins compatible with PHP8, but it is not yet complete. I am afraid you can't upgrade PHP version, right now. Check the Important notes of the Toolset requirements https://toolset.com/toolset-requirements/

Regarding the issues with nested shortcodes inside Divi, you can work around them using a content template. Create a content template and put the shortcodes inside of it, with the [ ] brackets or the {!{ }!} brackets syntax. Then include the content template inside Divi:

[wpv-post-body view_template="name or slug of the content template"]
or
{!{wpv-post-body view_template="name or slug of the content template"}!}

This way, the nested shortcodes will be rendered inside Toolset context, and the output will be passed to Divi.

If this does not work for you, I'd like to take the Duplicator copy and check it locally. Your next reply will be private to let you share the download link safely.

Finally, please note that the current integration with Divi is now offered using our Toolset View widget. But, you can't pass the user_email attribute to it. However, you can pass it through custom code. We can discuss this further if none of the above works.

#2239861

Hi Jamal, thanks for reply

the only thing I need to fix (everuthing else is tested and supports php8), is to pass ID into next View - "We can discuss this further if none of the above works - how to pass the "user_email attribute" to it. However, you can pass it through custom code. That's the most interesting point...

Heres is code for 1st View shows all woocommerce orders

...
[wpv-view name="mysht-list-products-belongs-order-completed" ids="[wpv-ordered-product-ids]"]
...

here is code for subsequent view shows all products per order in a loop

in a query filter of subsequent view - "Include only posts with IDs set by the View shortcode attribute "ids"

<li style="margin-top:1.5em;list-style: none;">
            <a href="[wpv-post-url]" target="_blank"><h4>[wpv-post-title] (в новом окне)</h4></a>[et_pb_toggle admin_label="Toggle" title="Просмотр/скачивание из Мой@ШД" open="off" use_border_color="off" border_color="#ffffff" border_style="solid"][wpv-post-body view_template="sht-content-template-for-mysht-product-per-order"][/et_pb_toggle]
          </li>
#2239883

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

I am sorry, but I got lost. I can't say where the last code is being used, a content template, a view, inside or outside of the view, etc.

Would you allow me temporary access to your website to check this further? Please share the URL where we can see the view and any details you think could be relevant. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2239923

Sorry Jamal, can you make next reply for me hidden again, so I can sent you diplicator files...

#2239925

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Of course. The next reply will be private.

#2240847

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

I built the website locally with PHP7, then I upgraded to PHP8 and it broke the site, not only the page with the views. I can't access the admin area too. With Nginx, it gives me a 502 error, and with Apache a 503. This happens also if I renamed the plugins folder(to deactivate all plugins).

So, the issues on my side are caused by the theme or the mu-plugins, but I can't tell.

The views are expecting a shortcode argument to match against a custom field, with a post status filter, and a text search filter. You can replace the shortcode attribute by a custom code that hooks into the views' query filters. Something like:

//Return only posts from the current author when listing posts of type company:
add_filter( 'wpv_filter_query', 'prefix_for_specific_email', 20, 3 );
 
function prefix_for_specific_email( $query_args, $view_settings, $view_id ) {
    if ( in_array( $view_id, array( 123, 456) ) ){
        $query_args['meta_query'] => array(
            array(
                'key'     => '_billing_email',
                'value'   => wpv_do_shortcode('[wpv-user field="user_email"]"]'),
                'compare' => '=',
            ),
        );
    }
    return $query_args;
}

Change the numbers 123 and 456 with the IDs of the views that you want to affect with this query filter.
Read more about the filter here https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

I hope this fixes the issues for you. If it does not, I am afraid, we(at support) won't be able to help you until we raise the Toolset requirements to PHP8.

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