Posts

Showing posts from April, 2025

Block HTtrack or any other web scrapper

 There are several web scrappers tools are available by which your website can be downloaded as static files. The simplest way to block these web scrappers is to add the following blocking bots code in your website .htaccess file. ##Block bad bots RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR] RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR] RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR] RewriteCond %{HTTP_USER_AGENT} ^Custo [OR] RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR] RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR] RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR] RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR] RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR] RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR] RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR] RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR] RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR] RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR] RewriteCond %{HTTP_USER_AGENT} ^GetR...

WordPress change default from name and email id

 When you get any email from your self hosted WordPress website, form name of that email will be WordPress which is quite annoying to you or your clients. You can overwrite this by adding this small piece of code in the functions.php file of your theme. function custom_wp_mail_from_name($email_from_name) { return 'Your Website Name'; // Change this to your desired name } add_filter('wp_mail_from_name', 'custom_wp_mail_from_name'); Also you can change the default from email id of the email generated from WordPress website by adding this another function in the functions.php file of your theme. function custom_wp_mail_from($email) { return 'no-reply@yourdomain.com'; // Change this to your desired email } add_filter('wp_mail_from', 'custom_wp_mail_from');

WordPress custom menu page, fetch data from custom MySQL table and export to CSV

 To create a custom menu page in WordPress, retrieve custom table data from MySQL, and display it with the ability to export to CSV/Excel, you can follow these steps: Create a custom table in your WordPress database to store your data. You can use the $wpdb global variable to interact with custom tables in WordPress. Here’s an example of creating a custom table: <?php global $wpdb; $table_name = $wpdb->prefix . 'custom_data'; $sql = "CREATE TABLE IF NOT EXISTS $table_name ( id INT(11) NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, phone VARCHAR(20) NOT NULL, PRIMARY KEY (id) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); ?> Add the following code to your theme’s functions.php file or create a custom plugin file to define the custom menu page: <?php // Add menu page function custom_menu_page() { add_menu_page( 'Cu...