Advertisement
Guest User

Untitled

a guest
Feb 15th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. Assumptions:
  2. 1. If users can favorite images, this implies that every image has an identifier. So at minimum, the desired action requires the Image-Id and the User-Id. We assume you already have the UserId because they are logged in.
  3.  
  4. 2. As for image ID, we assume this is the media ID generated in the backend by WP, and that the unique generated buttons have this ID stored in the markup some where. I'm assuming this is what you mean by saying:
  5. "The Divi theme uses the .et_pb_image and the .et_pb_gallery_image selectors for most of the images within the website, so I am trying to add these as post types to the post types used by the Favorites plugin but I am unsure of how or where exactly to do so."
  6.  
  7. *** If you don't have the IDs of the images/media, I'm going to guess that you have to figure that out first before proceeding.
  8.  
  9. 3. Let's assume the the favorite button click triggers an AJAX POST request.
  10.  
  11. Solution:
  12. 1. On the client side code, you'll need to find the bit of javascript that gets triggered when the user clicks the favorite button, which triggers the POST request.
  13. 2. Using chrome network tab (or any other request inspector), you need to find the corresponding POST request and analyze what is sent to the server. POST is just a string so likely it's a JSON object.
  14. 3. You need to write a bit of javascript to actually append the image ID to the POST request. Easier to do this in JQUERY probably. I would give you a bit of code but it really depends on what is really there already.
  15. 4. Once you confirm the Image-ID is part of the request, you need to check the PHP code to find the object which represents the POST values raw. This should just be a key-value object.
  16. 5. You need to get the Image-ID string value from that object and save it in your database some where.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement