Problem:
The customer was upgrading their site running Toolset Version 2.3.5 to the latest version while also updating PHP to version 7.x. They needed guidance on the upgrade path and encountered issues displaying custom fields with legacy PHP code after the update. Despite the fields being visible in the Classic Editor, embedding Toolset shortcodes in the editor caused site crashes when running PHP 8.2.
Solution:
Solution:
1- Upgrade Path: It was recommended to deactivate and delete the old version of Toolset, update PHP to version 7.x, install the new Toolset version, and import custom fields if necessary. The customer's data was safely retained in the WordPress database throughout this process.
2- Custom Field Display:
To replicate the legacy PHP logic, it was advised to use Toolset Views with conditional shortcodes, such as:
[wpv-conditional if="( NOT(empty($(wpcf-trail-length))) )"] <h4>Your HTML here</h4> [types field="wpcf-trail-loc"][/types]<br /> [types field="wpcf-trail-land"][/types]<br /> [/wpv-conditional]
If continuing with PHP code, the prefix wpcf- remains unchanged. The get_post_meta() function should be used to retrieve custom fields:
$loc = get_post_meta($post_id, 'wpcf-trail-loc', true);
3- Compatibility Notes: The customer was advised to update the PHP retrieval methods to align with current standards and replace older code constructs. The errors reported were related to the use of the continue statement and outdated plugin code.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/
https://developer.wordpress.org/reference/functions/get_post_meta/
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 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | - |
Zeitzone des Unterstützers: America/Sao_Paulo (GMT-03:00)
Dieses Thema enthält 6 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von vor 7 Monaten, 3 Wochen.
Assistiert von: Mateus Getulio.