Skip to content

Instantly share code, notes, and snippets.

View NorbertFeria's full-sized avatar

Norbert Feria NorbertFeria

View GitHub Profile
@NorbertFeria
NorbertFeria / dump.sh
Created August 24, 2024 09:57
dump sql file and place it on a tar.gz file
#!/bin/bash
# Notes
echo "NOTES:"
echo "This script will perform a MySQL dump of your database and compress the file."
echo "PRESS ANY KEY TO CONTINUE"
read -n 1 -s -r -p
# Default values
DEFAULT_DBNAME="mydatabase"
@NorbertFeria
NorbertFeria / restore.sh
Created August 24, 2024 08:29
Restore the backup files to a destination folder
#!/bin/bash
# Default values
DEFAULT_COMPRESSED_FILE="/backups/file.tar.gz"
DEFAULT_DEST_DIR="/public_html"
# Prompt for the compressed file
read -p "Enter the path to the compressed file [${DEFAULT_COMPRESSED_FILE}]: " COMPRESSED_FILE
COMPRESSED_FILE=${COMPRESSED_FILE:-$DEFAULT_COMPRESSED_FILE}
@NorbertFeria
NorbertFeria / backup.sh
Created August 24, 2024 08:23
shellscript to backup an entire folder.
#!/bin/bash
# Default directories
DEFAULT_BACKUP_DIR="./backups"
DEFAULT_DIR_TO_COMPRESS="./public_html"
# Prompt for the directory to compress and backup
read -p "Enter the directory to compress [${DEFAULT_DIR_TO_COMPRESS}]: " DIR_TO_COMPRESS
DIR_TO_COMPRESS=${DIR_TO_COMPRESS:-$DEFAULT_DIR_TO_COMPRESS}
@NorbertFeria
NorbertFeria / install-wp.sh
Created August 22, 2024 06:00
Quickly install wordpress from the command line using WP-CLI
#!/bin/bash
echo "Usage: $0 <foldername> <dbname> <dbuser> <dbpass> <url> <title> <adminuser> <adminpass> <adminemail>"
echo "Or you can enter the details when prompted."
# Check if WP-CLI is installed
if ! which wp > /dev/null; then
echo "WP-CLI is not installed. Please install WP-CLI before running this script."
exit 1
fi
@NorbertFeria
NorbertFeria / breadcrumbs.php
Created August 21, 2024 15:54
Bootstrap 5 Breadcrumb for WordPress USAGE: <?php the_breadcrumbs(); ?> OR <?php echo get_the_breadcrumbs(); ?> Or through shortcode [the_breadcrumbs]
<?php
/**
* Retrieves the post title.
*
* @return string
*/
function get_the_breadcrumbs(){
@NorbertFeria
NorbertFeria / functions.php
Created October 6, 2023 20:46
Add admin email to BCC of RSVP ticket emails
<?php
/**
* Add admin email to BCC of RSVP ticket emails
*
* Tested on
* Wordpress Version 6.3.1
* Events tickets Version 5.6.5.1
* Events tickets Plus Version 5.7.5
*
* Reference: https://developer.wordpress.org/reference/functions/wp_mail/#using-headers-to-set-from-cc-and-bcc-parameters
@NorbertFeria
NorbertFeria / wp-cli.md
Created June 8, 2023 14:12
WP-CLI Installation and usage

WP-CLI Installation and usage

Wordpress is very easy to install and aside from the very quick manual installation method there are several other ways e.g. One-click installers provided by hosting companies and the installers from cpanel. My preferred way of installing wordpress If I have digitalocean, AWS, Google cloud or similar servers is through the WP-CLI.

WP-CLI is a command-line interface tool for WordPress that supports all WordPress versions and enables automation, quicker and more effective jobs, reproducibility, scripting, and other features. Anyone who frequently works with WordPress should understand know how to utilize this useful tool because it can save a lot of time.

Installing WP-CLI

Requirements for installing WP-CLI.