Skip to content

Instantly share code, notes, and snippets.

View vijayhardaha's full-sized avatar
💻
Working on WordPress

Vijay Hardaha vijayhardaha

💻
Working on WordPress
View GitHub Profile
@vijayhardaha
vijayhardaha / export-all-wordpress-media-lib-images-list-csv.md
Last active September 24, 2023 18:49
Exporting WordPress Media Library Images: A Custom PHP Solution

Download/Export All WordPress Media Library Images

Managing a WordPress media library with numerous images can be a daunting task. Sometimes, you may need to export all these images for various purposes, such as creating backups or performing bulk image operations. This custom PHP code allows you to export all the images in your WordPress media library to a CSV file for easy access and management.

How to Use the Code

Follow these steps to use the provided custom PHP code to export your WordPress media library images:

  1. Open your theme's functions.php file.
@vijayhardaha
vijayhardaha / essential-wordpress-development-constants.md
Last active September 24, 2023 18:46
Essential WordPress Development Constants

Essential WordPress Development Constants

When working on WordPress development, there are several constants you can define to improve your development workflow and enhance the security and performance of your WordPress site. These constants are particularly useful when debugging, optimizing, or hardening your WordPress installation. In this gist, we'll explore a collection of essential WordPress development constants that can be defined in your wp-config.php file.

WordPress Debugging Constants

Debugging is a crucial part of any development process. WordPress provides a set of constants that help you identify and troubleshoot issues more effectively.

define( 'WP_DEBUG', true );
@vijayhardaha
vijayhardaha / automate-wordpress-installation-in-your-terminal.md
Last active October 13, 2023 08:07
Automate WordPress Installation in Your Terminal

Automate WordPress Installation in Your Terminal

If you're an avid WordPress user, you know that setting up a new WordPress site can be quite a chore, involving multiple manual steps like downloading core files, configuring the database, and installing essential plugins. To streamline this process, you can create a custom function in your shell configuration (zshrc or bashrc) that automates the entire WordPress installation with a single command.

Prerequisites

Before we dive into creating the function, ensure you have the following prerequisites:

@vijayhardaha
vijayhardaha / hide-wp-pages-from-admin-table.md
Last active September 24, 2023 19:12
WordPress: Hide pages from admin pages table using page slugs

Hide Pages from WordPress Admin Pages Table Using Page Slugs

In WordPress, there are times when you want to hide specific pages from the admin pages table in the WordPress dashboard. This code snippet provides a solution to achieve this by excluding selected pages based on their slugs.

How to Use the Code

Follow these steps to use the provided code in your WordPress project:

  1. Open Your Theme's functions.php File: Open the functions.php file of your WordPress theme using a code editor.
@vijayhardaha
vijayhardaha / cloudflare-firewall-rules-generation.md
Last active September 24, 2023 18:41
A Node Script for Generating Cloudflare Firewall Rules: Blocking Bots by Matching User Agents, Hostnames, and IP Addresses.

Generate Cloudflare Firewall Blocking Rules to Block Bots

Cloudflare is a widely used content delivery network (CDN) and security service that allows you to protect your website from various threats, including malicious bots. One way to block bots is by creating firewall rules that match specific user agents, hostnames, and IP addresses. This Node.js script automates the generation of such rules and has been tested on Node.js version 16.

Prerequisites

Before we dive into the script, make sure you have the following prerequisites:

  • Node.js installed on your system.
  • NPM (Node Package Manager) installed.
@vijayhardaha
vijayhardaha / whatsapp-30-seconds-video-splitter.md
Last active September 24, 2023 18:36
Split a video into 30 seconds video for whatsapp video status

Split a Video into 30-Second Clips for WhatsApp Video Status

WhatsApp status updates are a popular way to share short video clips with your contacts. However, WhatsApp has a limitation where video status updates must be 30 seconds or less in duration. To make it easier to create these short video clips, you can use a simple bash script that splits a longer video into multiple 30-second segments.

Prerequisites

Before we dive into the script, ensure you have the following prerequisites:

  • A Linux or macOS system.
  • FFmpeg installed on your system. You can typically install it using your system's package manager.
@vijayhardaha
vijayhardaha / find-large-size-directories-in-cli.md
Created September 24, 2023 18:55
Find Large Size Directories in the Command Line

Find Large Size Directories in the Command Line

When managing your files and directories in the command line, it's often useful to identify large directories that may be consuming a significant amount of storage space. This custom shell function, find-large-dirs(), allows you to search for directories larger than a specified size.

How to Use the Function in Your Shell Configuration Files

You can add the find-large-dirs() function to your shell configuration files (.bashrc, .bash_profile, or .zshrc) to make it available every time you start a new terminal session. Follow these steps to add and use the function in your shell configuration:

  1. Open Visual Studio Code or your preferred code editor.
@vijayhardaha
vijayhardaha / find-large-size-files-in-cli.md
Created September 24, 2023 18:56
Find Large Size Files in the Command Line

Find Large Size Files in the Command Line

When managing your files and directories in the command line, it's important to locate and manage large files that may be consuming significant storage space. This custom shell function, find-large-files(), enables you to search for files larger than a specified size.

How to Use the Function in Your Shell Configuration Files

You can add the find-large-files() function to your shell configuration files (.bashrc, .bash_profile, or .zshrc) to make it available each time you start a new terminal session. Here's how to add and utilize the function in your shell configuration:

  1. Open Visual Studio Code or your preferred code editor.
@vijayhardaha
vijayhardaha / find-all-git-repositories-in-cli.md
Created September 24, 2023 18:59
Find All Git Repositories in a directory using the Command Line

Find All Git Repositories within a directory using the Command Line

When working with multiple Git repositories in various directories, it's helpful to quickly locate them within the command line. This custom shell function, find-git-dirs(), allows you to search for all Git repositories in the current directory and its subdirectories.

How to Use the Function in Your Shell Configuration Files

You can add the find-git-dirs() function to your shell configuration files (.bashrc, .bash_profile, or .zshrc) to make it available each time you start a new terminal session. Here's how to add and utilize the function in your shell configuration:

  1. Open Visual Studio Code or your preferred code editor.
@vijayhardaha
vijayhardaha / get-and-copy-your-public-ip-addresses-in-cli.md
Created September 24, 2023 19:01
Get and Copy Your Public IP Addresses in the Command Line

Get and Copy Your Public IP Addresses in the Command Line

Frequently, you might need to retrieve and use your public IP addresses in various scenarios. These aliases, ip6 and ip4, simplify the process of obtaining your public IPv6 and IPv4 addresses and copying them to your clipboard.

How to Add and Use the Aliases in Your Shell Configuration Files

You can add the ip6 and ip4 aliases to your shell configuration files (.bashrc, .bash_profile, or .zshrc) for convenient access in every terminal session. Follow these steps to add and use the aliases in your shell configuration:

  1. Open Visual Studio Code or your preferred code editor.