Clearing Content
Clearing Content
I have been "testing" version 1.5.1 of FlatPress and I am now ready to start the blog. What do I need to delete, edit or change to remove all content that I have been using to "test" my blog. I have looked in the wiki and can't seem to find anything that will guide me through this.
Re: Clearing Content
You have to delete the welcome post, every post created by you to test your blog, the setup folder and setup php file into the main root of your blog.
Re: Clearing Content
With the help of AI, the code listed below will delete all test articles and comments.
Make a copy of the fp-content folder, place this code in the root folder of the application and run it from a browser. You might need to re-index the application if there are remnants left over. Worked for me anyway. Here is the code.
Make a copy of the fp-content folder, place this code in the root folder of the application and run it from a browser. You might need to re-index the application if there are remnants left over. Worked for me anyway. Here is the code.
Code: Select all
<?php
/**
* FlatPress Test Data Wiper
* Place this in your FlatPress root directory.
* DELETE THIS FILE AS SOON AS YOU ARE DONE.
*/
// Simple security check: Uncomment the line below and set a password if running on a live server
// if ($_GET['auth'] !== 'mysecret') die('Unauthorized.');
define('FP_CONTENT_DIR', __DIR__ . '/fp-content');
function delete_folder_contents($dir) {
if (!is_dir($dir)) return;
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($files as $fileinfo) {
$todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink');
$todo($fileinfo->getRealPath());
}
}
echo "<h2>FlatPress Reset Script</h2>";
// 1. Clear Posts
$postsDir = FP_CONTENT_DIR . '/content';
if (is_dir($postsDir)) {
delete_folder_contents($postsDir);
echo "✔️ All articles deleted.<br>";
}
// 2. Clear Comments
$commentsDir = FP_CONTENT_DIR . '/comment';
if (is_dir($commentsDir)) {
delete_folder_contents($commentsDir);
echo "✔️ All comments deleted.<br>";
}
// 3. Clear Cache (Highly recommended so FlatPress notices the changes immediately)
$cacheDir = FP_CONTENT_DIR . '/cache';
if (is_dir($cacheDir)) {
delete_folder_contents($cacheDir);
echo "✔️ Cache cleared.<br>";
}
echo "<br><strong>Done! Your configuration, themes, and plugins are untouched.</strong>";Re: Clearing Content
In the event AI generated code is not allowed, just disregard the post and accept my apology for not checking to see if it is allowed.
Who is online
Users browsing this forum: No registered users and 0 guests