Skip to content

Instantly share code, notes, and snippets.

View jesperweltz's full-sized avatar

Jesper Weltz jesperweltz

View GitHub Profile
@mikeschinkel
mikeschinkel / redirect-to-www.php
Last active August 8, 2016 06:10
MU-Plugin for WordPress to redirect from non-www to www domain
<?php
function redirect_to_www() {
if ( ! preg_match( '#^www.#', $_SERVER['HTTP_HOST'] ) ) {
$https = 443 === $_SERVER['SERVER_PORT'] ? 's' : '';
header( "Location: http{$https}://www.{$_SERVER['HTTP_HOST']}", true, 301 );
die();
}
}
redirect_to_www();
@mikeschinkel
mikeschinkel / redirect-old-urls.php
Created May 31, 2016 03:26
WordPress plugin to redirect old URLs when a site is refreshed. Uses a JSON file on activate to import into the DB. If Activation fails because of an error in the JSON file just deactivate, edit the file and then reactivate.
<?php
/**
* Plugin Name: Redirect Old URLs
* Description: Supports redirecting from an old site's URL to a new site on same domain.
* Version: 0.1.0
* Author: The WPLib Team
* Author URI: http://github.com/wplib
* Author Email: team@wplib.org
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
@cypres
cypres / gpoint.php
Created February 23, 2011 14:20
PHP class to convert Latitude & Longitude coordinates into UTM & Lambert Conic Conformal Northing/Easting coordinates.
<?php
/**
* PHP class to convert Latitude & Longitude coordinates into UTM & Lambert Conic Conformal Northing/Easting coordinates.
*
* This class encapsulates the methods for representing a geographic point on the earth in three different coordinate systema. Lat/Long, UTM and Lambert Conic Conformal.
*
* Code for datum and UTM conversion was converted from C++ code written by Chuck Gantz (chuck.gantz@globalstar.com) from http://www.gpsy.com/gpsinfo/geotoutm/
* This code was converted into PHP by Brenor Brophy (brenor@sbcglobal.net) and later refactored for PHP 5.3 by Hans Duedal (hd@onlinecity.dk).
*