I have slowly developing a WordPress theme which will be compatible with bbPress. During my time developing it I wanted to create and delete some bbPress data for testing purposes.
Here is the code for the plugin, or if you wish see below to download the zip file containing the plugin. When you install the plugin and activate it will create the data, then deactivate the plugin and delete it if you don’t need any further test data.
epicwebs-bbpress-create-test-data.zip
Be careful running this plugin, it does a lot of writes to the database and uses all of the tools inside the bbPress tools area which can be heavy load on your server. This is recommended only for test servers or local development, do not use on a live website.
<?php /* Plugin Name: EpicWebs bbPress Test Data Plugin URI: https://epicwebs.co.uk/ Description: Creates test data for testing a bbPress theme. Author: Lynq Version: 1.0.1 License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ $file = ABSPATH . 'wp-content/plugins/epicwebs-bbpress-create-test-data/epicwebs-bbpress-create-test-data.php'; register_activation_hook( $file, 'epicwebs_create_bbpress_forum_data' ); function epicwebs_create_bbpress_forum_data() { // Forum 1 $forum_data = array( 'post_parent' => 0, // forum ID 'post_content' => 'Nullam est felis, tempor luctus consequat a, aliquam ut dolor. Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Test Forum: Loads of Topics for topic Pagination', ); if(function_exists('bbp_insert_forum')) { $forum_id = bbp_insert_forum( $forum_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $forum_data = array( 'post_parent' => 0, // forum ID 'post_content' => 'Nullam est felis, tempor luctus consequat a, aliquam ut dolor. Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Test Forum: Forum with one topic with loads of replies for reply pagination', ); if(function_exists('bbp_insert_forum')) { $forum_id = bbp_insert_forum( $forum_data ); } $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Test topic with loads of replies', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } $topic_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $topic_data ); } $topic_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $topic_data ); } $topic_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $topic_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } $reply_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $reply_data ); } // Forum 3 $forum_data = array( 'post_parent' => 0, // forum ID 'post_content' => 'Nullam est felis, tempor luctus consequat a, aliquam ut dolor. Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Test Forum: Forum with nested forums.', ); if(function_exists('bbp_insert_forum')) { $forum_id = bbp_insert_forum( $forum_data ); } // Forum 3 Topic 1 $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } // Forum 3 Topic 1 Reply 1 $topic_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $topic_data ); } // Forum 3 Topic 1 Reply 2 $topic_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $topic_data ); } // Forum 3a $forum_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Nullam est felis, tempor luctus consequat a, aliquam ut dolor. Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Test Forum 2: Forum with nested forums', ); if(function_exists('bbp_insert_forum')) { $forum_id = bbp_insert_forum( $forum_data ); } // Forum 3a Topic 1 $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } // Forum 3a Topic 1 Reply 1 $topic_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $topic_data ); } // Forum 3ab $forum_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Nullam est felis, tempor luctus consequat a, aliquam ut dolor. Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Test Forum 2: Forum with nested forums', ); if(function_exists('bbp_insert_forum')) { $forum_id = bbp_insert_forum( $forum_data ); } // Forum 3a Topic 1 $topic_data = array( 'post_parent' => $forum_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_topic')) { $topic_id = bbp_insert_topic( $topic_data ); } // Forum 3a Topic 1 Reply 1 $topic_data = array( 'post_parent' => $topic_id, // forum ID 'post_content' => 'Proin euismod aliquam ante accumsan cursus. Morbi ornare eros magna, eget sollicitudin turpis fringilla quis. Proin vitae vehicula felis. Fusce non lacus consequat, faucibus nisl sed, consequat dolor.', 'post_title' => 'Gravida facilisis eleifend', ); if(function_exists('bbp_insert_reply')) { $reply_id = bbp_insert_reply( $topic_data ); } if(function_exists('bbp_admin_repair_topic_meta')) { bbp_admin_repair_topic_meta(); } if(function_exists('bbp_admin_repair_forum_meta')) { bbp_admin_repair_forum_meta(); } if(function_exists('bbp_admin_repair_forum_visibility')) { bbp_admin_repair_forum_visibility(); } if(function_exists('bbp_admin_repair_freshness')) { bbp_admin_repair_freshness(); } if(function_exists('bbp_admin_repair_sticky')) { bbp_admin_repair_sticky(); } if(function_exists('bbp_admin_repair_forum_topic_count')) { bbp_admin_repair_forum_topic_count(); } if(function_exists('bbp_admin_repair_forum_reply_count')) { bbp_admin_repair_forum_reply_count(); } if(function_exists('bbp_admin_repair_topic_reply_count')) { bbp_admin_repair_topic_reply_count(); } if(function_exists('bbp_admin_repair_topic_voice_count')) { bbp_admin_repair_topic_voice_count(); } if(function_exists('bbp_admin_repair_topic_hidden_reply_count')) { bbp_admin_repair_topic_hidden_reply_count(); } if(function_exists('bbp_admin_repair_user_topic_count')) { bbp_admin_repair_user_topic_count(); } if(function_exists('bbp_admin_repair_user_reply_count')) { bbp_admin_repair_user_reply_count(); } if(function_exists('bbp_admin_repair_user_roles')) { bbp_admin_repair_user_roles(); } }
I hope it is useful, let me know in the comments below!
Comments