Advertisement
herculesnetwork

This our solution ;-)

Apr 1st, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. I got a solution on a page of my index.php in a testing domain, where I just create index.php files and testo my codes, I wrote a solution that the entire embed destroyed by strange symbols, is fixed by symbols written correctly, <> "& Not those strange codes" srsrsrs
  2.  
  3.   But this has to be applied in the post_content after it creates the post
  4.  
  5. `
  6. $post = array(
  7. 'post_author' => '1',
  8. 'post_status' => $_POST['status'],
  9. 'post_type' => $cpt,
  10. 'post_title' => (string) $feed_item->title,
  11. 'post_content' => (string) $feed_item->desc
  12. );
  13. $post_id = wp_insert_post( $post );
  14. update_post_meta($post_id, 'sponsor', (string)$_POST['source']);
  15. update_post_meta($post_id, 'videoID', (string)$feed_item->id);
  16.  
  17. // hercules arrays:
  18. $myembeddirty = array('ID:','&lt;','&quot;','&amp;','&gt;'
  19. );
  20. $myembedcleaner = array('','<','"','&','>'
  21. );
  22. /*
  23. From now on, clearly I do not know what I'm doing srsr
  24. I do not know how to call by post_content above, would it be with $ post_content?
  25. I suffer with this case, because cron has a minimum of one hour, and I already used grep
  26. From linux to see if I can find the code to slow this time I can not!
  27. So every new try I have to wait an hour to see if it works!
  28. */
  29. $post = get_post( $post_ID );
  30. $post->post_content;
  31. /*
  32. THE SOLUTION:
  33. //$mynewdesc = $post->post_content;
  34. //$mynewdesc = str_replace($myembeddirty, $myembedcleaner, $mynewdesc); //this solve the PROBLEM do embed breaked from htmlentities, but I don't know apply in $post_content
  35. */
  36. $post->post_content = str_replace($myembeddirty, $myembedcleaner, $post->post_content);
  37. $post = array(
  38. 'post_content' => $post->post_content,
  39. );
  40. wp_insert_post($post_id);
  41. `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement