Skip to content

Instantly share code, notes, and snippets.

View niladam's full-sized avatar

Madalin Tache niladam

View GitHub Profile
@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 / .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 / 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 / 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 / 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 / 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 / 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 / gravity-forms_bootstrap.css
Created March 1, 2017 14:36 — forked from ajithrn/gravity-forms_bootstrap.css
Wordpress: GForm Bootstrap
/* ------------------------------------
Gravity Forms
---------------------------------------*/
.gform_wrapper ul { padding-left: 0; list-style: none }
.gform_wrapper li { margin-bottom: 15px }
.gform_wrapper form { margin-bottom: 0 }
// assets/scripts/customizer.js
(function($) {
// Primary colour
wp.customize('primary_colour', function(value) {
value.bind(function(to) {
$('head').append('<style>.Primary-bg-c{background-color:'+ to +' !important;}</style>');
$('head').append('<style>.Primary-c{color:'+ to +' !important;}</style>');
$('head').append('<style>.Primary-c--hover:hover{color:'+ to +' !important;}</style>');
@niladam
niladam / gist:2277fa462c65eca36b714bc78ea02d34
Created January 27, 2017 13:32
.htaccess redirect wp-content/uploads folder to subdomain
.htaccess
# Re-direct wp-content/uploads to subdomain
RewriteRule wp-content/uploads/(.*) http://uploads.example.com/$1 [R=301,L]
wp-config.php
// Make sure that we put uploads in the right place
update_option(
'upload_url_path',
'http://uploads.aubreypwd.com'
);