Skip to content

Instantly share code, notes, and snippets.

View niladam's full-sized avatar

Madalin Tache niladam

View GitHub Profile
@niladam
niladam / disable_wp_mail_by_subject.php
Created March 14, 2017 12:11
Disable WordPress email based on subject or any other variable
<?php
add_filter('phpmailer_init', 'stopCartNotifications');
function stopCartNotifications( $phpmailer ) {
// Let's extract object variables so we can use them.
$variabile = get_object_vars($phpmailer);
// I' blocking based on subject so, i'm selecting Subject from the object below in phpmailer_object_data.php
$subiect_email = $variabile['Subject'];
// I'm searching for Contact from the blog... (Calculated Form Fields)
if ( !empty($subiect_email) && $subiect_email == 'Contact from the blog...')
// Well, the subject matches, let's clear the email.
@niladam
niladam / duplicate_files_by_md5.txt
Last active March 14, 2017 16:06
Duplicate files
0000e0dcce4a7a6c6589c17cd87f5b9c ./Headline-37399-1-600x389.jpg
0000e0dcce4a7a6c6589c17cd87f5b9c ./Headline-37399-600x389.jpg
000199a0fed1807f39809ae3b954ffd3 ./32912H-1-450x253.jpg
000199a0fed1807f39809ae3b954ffd3 ./32912H-450x253.jpg
0010b2446be707b2cfa76fc2fd9e0245 ./Headline-30939-1.jpg
0010b2446be707b2cfa76fc2fd9e0245 ./Headline-30939.jpg
00156f723e600cf2eb6070e9cff60257 ./Headline-37356-1-180x180.jpg
00156f723e600cf2eb6070e9cff60257 ./Headline-37356-180x180.jpg
001eef2c022dfde390d33a10792cfbae ./230832-1-600x520.jpg
001eef2c022dfde390d33a10792cfbae ./230832-600x520.jpg
@niladam
niladam / style.css.php
Created May 2, 2017 21:54 — forked from JoeHana/style.css.php
On-the-fly CSS Compression
<?php
/**
* On-the-fly CSS Compression
* Copyright (c) 2009 and onwards, Manas Tungare.
* Creative Commons Attribution, Share-Alike.
*
* In order to minimize the number and size of HTTP requests for CSS content,
* this script combines multiple CSS files into a single file and compresses
* it on-the-fly.
@niladam
niladam / addtogcal.php
Created May 10, 2017 22:42 — forked from petertwise/addtogcal.php
Function to create Add to Google Calendar link
<?php
function squarecandy_add_to_gcal(
$name,
$startdate,
$enddate = false,
$description = false,
$location = false,
$allday = false,
$linktext = 'Add to gCal',
$classes = array('gcal-button, button')
@niladam
niladam / index.php
Created May 18, 2017 10:38 — forked from SGudbrandsson/index.php
Create a WordPress staging area from your live wordpress setup with a Click-of-a-button [TM] ..
<?php
/**
*
* This script will copy your wordpress from public_html (or wherever)
* and place it in a staging folder.
* It will then clone the database, reconfigure the config file
* and replace URL's from the original URL to your staging URL.
* It will then make sure to NOT allow search engines to index the page.
*
* Use this script to clone your main wp in order to test maintenance work
@niladam
niladam / deregister-dashicons.php
Created May 21, 2017 20:39 — forked from perezdans/deregister-dashicons.php
Hacer deregister de los estilos CSS de los dashicons para todos los visitantes salvo cuando se muestre la barra de admin para mejorar Google Page Speed Insights
<?php
// Deregister los dashicons si no se muestra la barra de admin
add_action( 'wp_print_styles', function() {
if (!is_admin_bar_showing()) wp_deregister_style( 'dashicons' );
}, 100);
@niladam
niladam / slugify.sh
Created June 24, 2017 20:05 — forked from ronanguilloux/slugify.sh
batch in bash to replace accents in filenames
#! /bin/bash
#
# slugify.sh by Ronan
#
# Distributed under terms of the MIT license.
#
cd photos
for file in *.png; do
filename=${file%.*}
@niladam
niladam / .htaccess
Created July 17, 2017 15:56 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@niladam
niladam / time-since.php
Created October 7, 2017 08:01 — forked from ThatGuySam/time-since.php
Time since Shortcode for Wordpress
<?php
// ex:
// With [time since="1997"] years experience
// outputs: With 20 years of experience
class SCCTimeShortcode {
static $add_script;
static function init() {
@niladam
niladam / dnsmasq.dev.md
Created October 10, 2017 19:58
DNSmasq for *.dev domains mapping

After installing dnsmasq, create a "zone file" for *.dev. Create a file /etc/dnsmasq.d/dev and add the following:

address=/dev/127.0.0.1