Advertisement
Guest User

Untitled

a guest
Apr 28th, 2025
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. function fetch_oeuvre_content() {
  2. // Check nonce for security
  3. check_ajax_referer('ajax_nonce', 'nonce');
  4.  
  5. $oeuvreId = sanitize_text_field($_POST['oeuvre']);
  6. $previousoeuvreId = sanitize_text_field($_POST['poeuvre']);
  7. $nextoeuvreId = sanitize_text_field($_POST['noeuvre']);
  8. $masonryId = sanitize_text_field($_POST['masonry']);
  9.  
  10. $post = get_post($oeuvreId);
  11. if (!empty($post)) {
  12. $post_id = $post->ID;
  13.  
  14. $content = do_shortcode("[jmpeynetoeuvre pid='".$post_id."' previous_id='".$previousoeuvreId."' next_id='".$nextoeuvreId."' masonry_id='".$masonryId."']"); // Get the content and apply content filters
  15.  
  16. // Prepare and send JSON response
  17. wp_send_json(array(
  18. 'content' => $content
  19. ));
  20. } else {
  21. echo 'Definition not found.';
  22. }
  23. wp_die(); // This is required to terminate immediately and return a proper response
  24. }
  25. add_action('wp_ajax_fetch_oeuvre_content', 'fetch_oeuvre_content');
  26. add_action('wp_ajax_nopriv_fetch_oeuvre_content', 'fetch_oeuvre_content');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement