Hi All,
This is my first time asking for help here so please bear with me. I am currently stuck trying to add some custom functionality to an up to date WP install, running the Divi Theme, and trying to customize the results of the “Favorites” plugin. I’m working locally off of MAMP, using a simple child theme, and overwriting a specific Divi gallery class in order to add a favorites button to each image within a gallery.
I had some help with the logic of this solution, and now find myself over my head again. My goal is to allow users to favorite images within the galleries (and ultimately for that data to be accessible to the user); the plugin I’m using functions properly with it’s specified “posttypes”, however in order to gain functionality with the Galleries, I needed to overwrite the “Gallery.php” module within my child-theme. I have added this line:
$output .= get_favorites_button( $id );
This has been placed within the render function of the class. The buttons are indeed being output for each image in the gallery, however they do not all function, only the 1st and 4th in the first row of the gallery, but after that only 1 or 2 random buttons function (without any pattern I can see) on any gallery I make. Within the plugin settings I have to enable Favorites for “Pages” on the “Display & Post Types” tab. I suspect my logic is flawed with the “$id” variable that I am using, and that I should be using a different attribute/property of the images to get a unique button for each image but I am not sure.
The console in Chrome/Canary gives this message for the buttons that work:
-
{status: “success”, favorite_data: {…}, favorites: Array(1)}
-
favorite_data: {id: 3, siteid: 1, status: “active”, groupid: 1, save_type: “cookie”}
And this message for the buttons that don’t:
-
{status: “error”, message: “Invalid post.”}
-
message: “Invalid post.”
-
status: “error”
I’m also not sure on how to ask this question and provide you guys with the information needed to answer it. The Gallery.php function that I am overwriting is around 625 lines long, and that seems long to post here, especially since the only piece of code I am adding to it is the piece above that is posted at line 594. I recognize that it’s probably near impossible to answer this without seeing more code or examples, so please ask away and I will try to accommodate; since the development is being done locally with MAMP I am not sure how I can show it to everyone here, but I am willing to do whatever is asked as far as providing any information to help shed some light on a solution for this.
Thanks for reading and any help that can be offered will be most appreciated!