![]() |
|
Force date of item in RSS feed - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: Themes (https://forum.zenphoto.org/forum-5.html) +--- Thread: Force date of item in RSS feed (/thread-13483.html) |
Force date of item in RSS feed - davidarnoult - 25-11-2020 Hi! I would like to force the tag value as the current date in my custom RSS feed (to trigger every day a random image posting). I have found the getItemGallery() function in class rss_options. If I hack the function in rss.php, it works: //date To modify the function only in my theme and keep the core clean, I have copied the getItemGallery() in my functions.php. But it does not work. What am I missing? I have tried to declare it in the class class rss_options { Thanks for help! Force date of item in RSS feed - acrylian - 26-11-2020 I don't understand why you want to do this but that's not important ;-) It does not work because you use the wrong class and also you did it wrong. You redeclared the 'getItemGallery()
But that also will not exactly do the trick since the old class will be used to setup the feed. You have to also create a child class method Force date of item in RSS feed - davidarnoult - 28-11-2020 Thanks for the great help, appreciated. I will start my own plugin then. I have never developed one, it is a good opportunity ;-) I can see that a demo plugin exists in the release https://www.zenphoto.org/news/demo-plugin/ to kickstart but I can't find it. Do you know where it is today? You wrote: How can I do that specifically in the RSS class? Cheers Force date of item in RSS feed - davidarnoult - 28-11-2020 Btw the objective is to trigger email sending (photo of the day) every day using mailchimp as the pubDate will always be the date of the current day for any random item... Force date of item in RSS feed - acrylian - 28-11-2020 Thanks about the note regarding the demo plugin. It is not included actually but apparenlty there is a bug in our site theme not showing the link: There is no actualy guide to replace a function ( In this case we are speaking of methods as they are part of a class) as this is PHP basics of object inheritance and nothing Zenphoto specific.
Yes, that would be the correct way to remove the filter. It needs to be done right at the beginning of your plugin. Right afterwards you have to register your replacement so it is used. Alternative would be to copy the RSS plugin itself, rename it and modify itself. Of course then you have to see that you get all possible updates later yourself. Force date of item in RSS feed - davidarnoult - 28-11-2020 OK, great! Is the number of $plugin_is_filter in my custom plugin must higher or lower than the one of RSS plugin (to be loaded after the original class) ? I have setup this at the beginning and copy the executeRSS method: Is the integer of zp_register_filter important too? Thanks Force date of item in RSS feed - acrylian - 28-11-2020
The higher he number the more priority, so lower than the original.
That priortiy parameter should not matter in this case as the plugin itself here already sets the priority order. Force date of item in RSS feed - davidarnoult - 30-11-2020 Thanks @acrylian ! It works ;-) I have just have to wait tomorrow if mailchimp will be triggered via RSS to send emails with latest dates of random photo every day. I have found what I was missing: to instantiate my object in my class in executeRSS(): static function executeRSS() { I definitely improved my ZP xp ;-) Force date of item in RSS feed - acrylian - 30-11-2020 Great it worked out. And yes, of course Force date of item in RSS feed - davidarnoult - 05-12-2020 Hi, It wasn't for me ;-), thanks. Now, to be clean, I would like to extend/redefine my 2 customized functions "printRSSLink" and "getRSSLink" in my plugin instead of copy/modified and renamed them in functions.php of my theme. But I cannot succeed to integrate them in my plugin. I have tried to apply same logic: Remove them at the beginning and redefine under my new class but it does not work for these 2. It seems that these 2 functions are not part of the RSS class as it is for getItemGallery. Do you know if it is possible to override these 2 too in same plugin? Force date of item in RSS feed - acrylian - 05-12-2020 These two are procedural functions as a lot in Zenphoto is procedural. You cannot override procedural functions as that leads to fatal errors because of re-declaring. You have to create new unctions with a new name within your plugin and use them instead. |