Skip to content

Instantly share code, notes, and snippets.

View mrazzari's full-sized avatar

Manuel Razzari mrazzari

View GitHub Profile
@mrazzari
mrazzari / wpupdate.sh
Last active March 27, 2019 14:36
Update WP and plugins via wp-cli, then create individual commits
#!/usr/bin/env bash
#
# @author: Pablo Sammartino
# http://www.cvam.com.ar
# Created: 2017-05-22
# Last Update: 2019-03-25
#
DATE=`date +%d-%m-%Y`
CURRENT_DIRECTORY=$PWD
@mrazzari
mrazzari / index.html
Last active May 7, 2016 13:14
Bulletproof static redirect
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Loading&hellip;</title>
<meta http-equiv="Refresh" content="0; url=http://www.example.com/">
<!-- JS is our first option. Faster than the meta refresh.
But if none of these automated options work, wait 2 seconds
to show a "click here" message, using CSS animations.
@mrazzari
mrazzari / multisite_delete_revisions.php
Last active November 9, 2024 00:45
WP - Multisite delete revisions
<pre><?php
// WordPress Multisite - Delete all revisions from all posts in a netword.
// Quick hack by @mrazzari, 2014.
// For context see this thread started by Kitchin at the forums:
// http://wordpress.org/support/topic/deleting-post-revisions-do-not-use-the-abc-join-code-you-see-everywhere
// HOWTO
// This snippet is meant to be called as a standalone script.
// Like http://example.com/tmp/multisite_delete_revisions.php
@mrazzari
mrazzari / plugin.php
Last active March 23, 2019 00:45
WP - Prevent plugin updates
<?php
// Block the admin from updating this plugin, as we've modified it.
add_filter('site_transient_update_plugins', 'remove_update_xyz');
function remove_update_xyz($value) {
$plugin = plugin_basename(__FILE__);
if (!isset($value->response[ $plugin ])){ return $value; }
add_action( "in_plugin_update_message-$plugin", "in_plugin_update_message_xyz");
unset($value->response[ $plugin ]->package); // Remove ->package to fully remove the update notice.
return $value;
@mrazzari
mrazzari / IDN not ready for prime time.markdown
Last active December 19, 2015 11:49
My experience setting up a WP site using an Internationalized domain name. TL;DR: it can work, but requiring extra developer effort, and being noticeably unreliable. OK for blogs / early adopters.
@mrazzari
mrazzari / backup.php
Last active December 10, 2015 23:59
A script to backup a WP database and user uploads into Rackspace Cloud Files, from a cron file.
<?php
$options = my_getopt("p:c:u:k:b:w:d:r", array(
"prefix:",
"container:",
"user:",
"key:",
"backupdir:",
"wpdir:",
"dateformat:",
@mrazzari
mrazzari / readme.md
Last active October 29, 2022 00:06
WP-Migrate: standalone WP database dump into a new DB.

WP-MIGRATE

Migrates a standalone WP database dump into a new DB.

This script will take a mysqldump sql file, and:

  1. Replace the old blog's URL with the new one
  2. Replace an old WP table_prefix with a new one
  3. Take care of string lengths within serialized data

It will finally import the MySQL dump into the new DB, using wp-config's settings.

@mrazzari
mrazzari / html5shiv-printshiv.js
Created June 1, 2012 20:53
Workaround for html5shiv's issue 58
(function(j,c){function q(a,b){var e=a.createElement("p"),f=a.getElementsByTagName("head")[0]||a.documentElement;e.innerHTML="x<style>"+b+"</style>";return f.insertBefore(e.lastChild,f.firstChild)}function m(){var a=d.elements;return"string"==typeof a?a.split(" "):a}function n(a){var b=r[a[s]];b||(b={},o++,a[s]=o,r[o]=b);return b}function t(a,b,e){b||(b=c);if(k)return b.createElement(a);e=e||n(b);b=e.cache[a]?e.cache[a].cloneNode():x.test(a)?(e.cache[a]=e.createElem(a)).cloneNode():e.createElem(a);
return b.canHaveChildren&&!y.test(a)?e.frag.appendChild(b):b}function z(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();a.createElement=function(a){return!d.shivMethods?b.createElem(a):t(a)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(d,b.frag)}function u(a){a||
(a=
@mrazzari
mrazzari / blank_page.htm
Created May 30, 2012 18:51
Testcase for html5shiv's blank page issue #58
<!DOCTYPE html>
<html>
<head>
<!--[if lt IE 9]>
<script src="html5.js"></script>
<![endif]-->
<link rel="stylesheet" href="blank_page_files/style.css" />
</head>
@mrazzari
mrazzari / migrate.php
Created May 29, 2012 23:13
Migrate a standalone WP database dump into a WP MultiSite install
<?php
if (count($argv) < 7){?>
WP-TO-MS-Import
Migrates a standalone WordPress database dump into a WP MultiSite install.
Author: @mrazzari, with thanks to @camilokawerin.
Author URL: http://ConVistaAlMar.com.ar
You found this at: https://gist.github.com/2831366