Skip to content

Instantly share code, notes, and snippets.

View hiranthi's full-sized avatar

Hiranthi Herlaar hiranthi

View GitHub Profile
<IfModule mod_rewrite.c>
RewriteEngine On
# Het betreft geen request voor `robots.txt`/`bots-forbidden.php`:
RewriteCond %{REQUEST_URI} !(robots.txt|bots-forbidden.php)
# User-Agents van bots die geen toegang (behalve `robots.txt`/`bots-forbidden.php`) mogen hebben:
RewriteCond %{HTTP_USER_AGENT} Amazonbot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} AhrefsBot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Bytespider [NC,OR]
@hiranthi
hiranthi / redis-monitoring
Last active December 8, 2023 10:34
Bash script for custom Redis monitoring. The path in the mentioned cronjob is assuming the contents would be placed in a file called `monitor`, which resides in a folder `redis-monitoring` (within the HOME folder)
#!/bin/bash
#####################################################################################
# #
# Cronjob command: #
# #
# bash /home/DA_USER/redis-monitoring/monitor >/dev/null 2>&1 #
# #
#####################################################################################
@hiranthi
hiranthi / shortcodes.php
Created May 6, 2022 09:20
A few extras / tweaks for the WordPress plugin Glossary by Codeat: https://wordpress.org/plugins/glossary-by-codeat/
<?php
/**
* You can add this code inside your (child) theme's `functions.php`
* or within a PHP-file inside your `mu-plugins` folder
**/
/**
* Adds the shortcode [glossary-total]
*
@hiranthi
hiranthi / .htaccess
Created June 22, 2020 20:44
.htaccess regels om afbeeldingen die niet meer bestaan een 410 Gone status te geven (in plaats van 404 Not Found)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase //
RewriteCond %{REQUEST_URI} ^/wp-content/uploads
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /index.php [L,R=410]
</IfModule>
@hiranthi
hiranthi / cleanup-adsformarket.bash
Last active February 4, 2020 14:40
Veel WordPress websites zijn geïnfecteerd waarbij er verschillende injecties zijn toegevoegd die gerelateerd zijn aan 'adsformarket'. Alle bestanden handmatig nalopen & opschonen, is veel werk. Met deze bash-scripts kan het een stuk makkelijker doorlopen worden.
#!/bin/bash
# WP_PATH definiëren
export WP_PATH=$(pwd)
search_adsformarket="snippet.adsformarket.com"
file_adsformarket="../adsformarket.txt"
touch $file_adsformarket
adsformarketmalfiles=$(find -type f | grep -liR "${search_adsformarket}" $WP_PATH)
@hiranthi
hiranthi / mu-plugin-file.php
Created March 22, 2019 18:55
Pretend another theme is active in the WP dashboard to maintain access to everything when something in your theme messes everything up (or whatevs).
<?php
add_filter( 'template', 'onx_change_theme' );
add_filter( 'option_template', 'onx_change_theme' );
add_filter( 'option_stylesheet', 'onx_change_theme' );
add_filter( 'pre_option_stylesheet', 'onx_change_theme' );
function onx_change_theme( $theme )
{
if ( is_admin() && ( function_exists( 'wp_get_current_user' ) ) )
{
@hiranthi
hiranthi / elementor-redirect.php
Created March 13, 2019 11:03
Redirect Editors & Authors from the 'edit page' page to the Elementor editor. Helps keeping the Elementor-stuff intact :)
<?php
function onx_redirect_edit_page_to_elementor()
{
global $post, $pagenow;
if ( ! isset( $post->ID ) || current_user_can( 'manage_options' ) ) return;
if ( ( ( $pagenow == 'post.php' ) && ( get_post_type() == 'page' ) ) && ( current_user_can( 'editor' ) || current_user_can( 'author' ) ) )
{
@hiranthi
hiranthi / base.txt
Last active May 9, 2021 14:20
WP-CLI stuff :)
# Paths: DirectAdmin
# USER: change to correct username
# DOMAIN: change to the correct domainname
# Core stuff
$ wp core version --path=/home/USER/domains/DOMAIN/public_html/
$ wp core download --skip-content --force --version=latest --path=/home/USER/domains/DOMAIN/public_html/
$ wp core update-db --path=/home/USER/domains/DOMAIN/public_html/ --dry-run
$ wp core verify-checksums --path=/home/USER/domains/DOMAIN/public_html/
@hiranthi
hiranthi / zipcode-2.php
Last active January 17, 2020 00:38
Zipcode validation for Gravity Forms (5 digits, 2 approaches).
<?php
# just add the needed form IDs to the array
$forms = array( '6', '7' );
# looping through the array to add an 'add_filter' for each
foreach ( $forms as $i => $form )
add_filter( "gform_field_validation_{$form}", 'custom_zip_validation', 10, 4 );
# the function
@hiranthi
hiranthi / zipcode-2.php
Created January 23, 2019 19:55
Zipcode validation for Gravity Forms (5 digits, 2 approaches).
<?php
# just add the needed form IDs to the array
$forms = array( '6', '7' );
# looping through the array to add an 'add_filter' for each
foreach ( $forms as $i => $form )
add_filter( "gform_field_validation_{$form}", 'custom_zip_validation', 10, 4 );
# the function