Posts

Showing posts from March, 2025

PHP script to download file from specific folder

 Below is a simple example of a PHP script that allows you to download file from a specific folder. You can link to this PHP file with the file name as a parameter. Create a file named download.php and add the following code: <?php // Specify the folder where your files are stored $folderPath = '/path/to/your/files/'; // Get the file name from the query parameter if (isset($_GET['file'])) { $fileName = basename($_GET['file']); $filePath = $folderPath . $fileName; // Check if the file exists if (file_exists($filePath)) { // Set headers for download header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header...

WordPress reserved terms you should never use

 While developing WordPress theme or plugin we use different WordPress keywords or terms, additionally while handling forms fields and custom post types we have to consider what names we can use or not. The restricted names are called reserved terms. WordPress itself reserves few keywords or terms which we can not use in our coding. Using these reserved or restricted terms just break the functionality what we intend to get. You should avoid using these reserved terms in the following scenarios: Passing a term through a $_GET or $_POST array. Registering a taxonomy or post type slug Handling query variables WordPress Codex URL: https://codex.wordpress.org/Reserved_Terms