ericek111

Convert phpBB 3.2 post content in DB to BBcodes

Oct 10th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. <?php
  2. if (php_sapi_name() != "cli") die("You can only run this from CLI.");
  3. ini_set('max_execution_time', 60000);
  4. //define('WP_MEMORY_LIMIT', '2048M');
  5. chdir(dirname(__FILE__));
  6. define('WP_USE_THEMES', false);
  7. require('../forum/wp-blog-header.php');
  8.  
  9. ob_end_flush();
  10. global $wpdb;
  11.  
  12. include __DIR__ . '/vendor/autoload.php';
  13. // Use the Forum bundle. It supports BBCodes, emoticons and autolinking
  14. use s9e\TextFormatter\Bundles\Forum as TextFormatter;
  15.  
  16. $query = new WP_Query([
  17.     'numberposts' => -1,
  18.     'posts_per_page'=> -1,
  19.     'post_type' => [ bbp_get_topic_post_type(), bbp_get_reply_post_type() ]
  20. ]);
  21.  
  22. $i = 0;
  23. while ($query->have_posts()) {
  24.     $query->the_post();
  25.     global $post;
  26.     echo $i++ . " / " . $query->found_posts . " =========================== $post->ID : $post->post_title\n";
  27.  
  28.     wp_update_post([
  29.         'ID' => get_the_ID(),
  30.         'post_content' => TextFormatter::unparse($post->post_content)
  31.     ]);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment