Advertisement
herculesnetwork

Untitled

Apr 1st, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. PASTEBINnew pastetrends API tools faq
  2. search...
  3.  
  4.  
  5. herculesnetwork
  6.  
  7. 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
  8.  
  9. But this has to be applied in the post_content after it creates the post
  10.  
  11. `
  12. $post = array(
  13. 'post_author' => '1',
  14. 'post_status' => $_POST['status'],
  15. 'post_type' => $cpt,
  16. 'post_title' => (string) $feed_item->title,
  17. 'post_content' => (string) $feed_item->desc
  18. );
  19. $post_id = wp_insert_post( $post );
  20. update_post_meta($post_id, 'sponsor', (string)$_POST['source']);
  21. update_post_meta($post_id, 'videoID', (string)$feed_item->id);
  22.  
  23. // hercules arrays:
  24. $myembeddirty = array('ID:','&lt;','&quot;','&amp;','&gt;'
  25. );
  26. $myembedcleaner = array('','<','"','&','>'
  27. );
  28. /*
  29. From now on, clearly I do not know what I'm doing srsr
  30. I do not know how to call by post_content above, would it be with $ post_content?
  31. I suffer with this case, because cron has a minimum of one hour, and I already used grep
  32. From linux to see if I can find the code to slow this time I can not!
  33. So every new try I have to wait an hour to see if it works!
  34. */
  35. // $post = get_post( $post_ID );
  36. // $post->post_content;
  37. /*
  38. THE SOLUTION:
  39. //$mynewdesc = $post->post_content;
  40. //$mynewdesc = str_replace($myembeddirty, $myembedcleaner, $mynewdesc); //this solve the PROBLEM do embed breaked from htmlentities, but I don't know apply in $post_content
  41. */
  42. $prev = get_post( $post_id );
  43. $prev->post_content = $post->post_content;
  44. $prev->post_content = str_replace($myembeddirty, $myembedcleaner, $prev->post_content);
  45. wp_insert_post( $prev );
  46.  
  47. // $post = array(
  48. // 'post_content' => $post->post_content,
  49. // );
  50. // wp_insert_post($post_id);
  51. `
  52. RAW Paste Data
  53.  
  54. 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
  55.  
  56. But this has to be applied in the post_content after it creates the post
  57.  
  58. `
  59. $post = array(
  60. 'post_author' => '1',
  61. 'post_status' => $_POST['status'],
  62. 'post_type' => $cpt,
  63. 'post_title' => (string) $feed_item->title,
  64. 'post_content' => (string) $feed_item->desc
  65. );
  66. $post_id = wp_insert_post( $post );
  67. update_post_meta($post_id, 'sponsor', (string)$_POST['source']);
  68. update_post_meta($post_id, 'videoID', (string)$feed_item->id);
  69.  
  70. // hercules arrays:
  71. $myembeddirty = array('ID:','&lt;','&quot;','&amp;','&gt;'
  72. );
  73. $myembedcleaner = array('','<','"','&','>'
  74. );
  75. /*
  76. From now on, clearly I do not know what I'm doing srsr
  77. I do not know how to call by post_content above, would it be with $ post_content?
  78. I suffer with this case, because cron has a minimum of one hour, and I already used grep
  79. From linux to see if I can find the code to slow this time I can not!
  80. So every new try I have to wait an hour to see if it works!
  81. */
  82. $post = get_post( $post_ID );
  83. $post->post_content;
  84. /*
  85. THE SOLUTION:
  86. //$mynewdesc = $post->post_content;
  87. //$mynewdesc = str_replace($myembeddirty, $myembedcleaner, $mynewdesc); //this solve the PROBLEM do embed breaked from htmlentities, but I don't know apply in $post_content
  88. */
  89. $post->post_content = str_replace($myembeddirty, $myembedcleaner, $post->post_content);
  90. $post = array(
  91. 'post_content' => $post->post_content,
  92. );
  93. wp_insert_post($post_id);
  94. `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement