davidjmurray
Forum Replies Created
-
MT,
I have been watching the replies to your question over the last week and it seems that no-one is game enough to add any comments.
In case there is confusion, all plugins and themes are under the GPL open source license. The exception is that icons, images, etc. within themes may be copyrighted.
Therefore, you have the ability (or opportunity) to manage and support the plugin if you deem that it is not being supported sufficiently for your website/application. This can be done in-house or by your external contractor and should be factored into your normal running site risk assessment, mitigation, and insurance plans.
You do hint in your post that you are not true PHP programmers and this might explain your comment that what this plugin achieves cannot be done with PHP. The plugin is actually written in PHP so all can be done, but the complexity is obviously greater than using the plugin.
So, using the free plugin as a great starting point, I would suggest expanding you knowledge of WordPress and it’s shortcodes and hooks infrastructure so you feel more comfortable in using the plugin and understanding it’s workings and especially it’s limitations.
Which leads into your site testings and loading measurements. I assume that you have discovered by now that shortcodes are an extremely inefficient mechanism for selecting and running code due to the repeated regex search through the text to find the shortcode(s). See https://rocketgeek.com/basics/why-you-should-not-use-do_shortcode/ and others for more information.
So, use this plugin for RAD (Rapid Application Development) and then re-code the important and often used parts into direct PHP using the hooks of add_action and add_filter where appropriate.
On the other hand, I am an avid developer using Divi from Elegant Themes for site theming; which uses shortcodes all the way down…
And it works very well. There is a performance hit but a solid caching mechanism does help (and also a bigger box).
With the recent changes to WordPress with the jQuery upgrades (WP version 5.6 – 5.8?) and with PHP 8 (with changes that are backwards incompatible to 7) this is a fair and very important question to ask all of your plugin and theme provides.
Long story short – you have to plan for it.
Polar,
Thanks for your help.I missed that little tipbit at the bottom of the pass doc page; though I thought that I tried that combination.
Therefore, I’m back to method B (or was it C?).
[set maxevents] [user events_attended] [/set] [ul] [pass vars] [x {MAXEVENTS}] [set xx] [calc] {X} - 1 [/calc] [/set] [-pass vars] [li] [user events_attended_{-XX}_event_date] - [user events_attended_{-XX}_event_name] [/li] [/-pass] [/x] [/pass] [/ul]
and now I no longer depending on my monkey patching to the format.php code.
But I might add a separate shortcode with an offset attribute to my snippets collection as it might come in handy:
[xloop max=5 offset=-1] {X} [/xloop]
Simple and useful I think.
Cheers,
djm- This reply was modified 4 years ago by davidjmurray.
- This reply was modified 4 years ago by davidjmurray.
Thanks polar but I have tried that and the field shortcode does not read from the user info and the user info is not a valid post type so it’s not possible to ‘trick’ it that way.
So I used the Kobayashi Maru solution.
I found a rather useful undocumented shortcode called [x] which is used as:
[x max-loops] [/x]
where max-loops is the number of times to loop.
A variable {X} is available within the tags which displays the loop counter:
[x 5] {X} [/x]
displays:
12345
Also, as the ACF repeater data is stored as individual metadata fields and not an array then my complete solution is:
[set maxevents] [user events_attended] [/set] [ul] [pass vars] [x {MAXEVENTS}] [li] [user events_attended_{X-1}_event_date] - [user events_attended_{X-1}_event_name] [/li] [/x] [/pass] [/ul]
Oh, I had to modify the code in the modules/format.php to get the loop counter to start at zero rather than one:
$rendered = str_replace('{X}', $i, $content); $rendered = str_replace('{X-1}', $i - 1, $rendered);
because the [pass vars] cannot be nested somehow…
Yer, I do that sometimes….