Skip to content

Instantly share code, notes, and snippets.

@codex73
codex73 / redirect.php
Created February 8, 2017 16:25 — forked from gopeter/redirect.php
A simple snippet to remove trailing numbers at the end of wordpress urls. For example: redirect http://example.com/foobar/2024/ to http://example.com/foobar/. Don't use it if your permalink structure ends with "%post_id%"! This will return an infinite redirect-loop!
<?php
// get the url
$url = 'http://' . $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI];
// check if there are any slashes inside the url string
if (strpos($url, '/')) {
// split the string in pieces
// use "/" as separator
@codex73
codex73 / basic-usage.php
Created September 9, 2016 17:28 — forked from joshuadavidnelson/basic-usage.php
Create custom theme features with theme feature support
<?php
/**
* Basic Theme Support usage. Add this to your functions.php file
*/
add_theme_support( 'custom-footer-text' );
/**
* Elsewhere in your theme...
*/
if( current_theme_supports( 'custom-footer-text' ) ) {
@codex73
codex73 / gist:26f59f9350d3c237e8e6786d816d3615
Created September 3, 2016 02:30 — forked from gyrus/gist:3332597
Override a WordPress 404 with a specific template
<?php
/**
* Override a 404
*
* @param string $template If passed, this template will be included and
* the request will be terminated if the inclusion
* was successful
* @param string $type If not a 404, what type of request should this be
* flagged as? Must correspond to one of the
@codex73
codex73 / gist:1eeb20bb744b2b52e955436b82b21247
Created April 20, 2016 01:54 — forked from vxnick/gist:380904
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
@codex73
codex73 / widget.js
Created February 10, 2016 22:47 — forked from lukencode/widget.js
Starter template for creating jsonp embeddable widgets.
(function () {
var scriptName = "embed.js"; //name of this script, used to get reference to own tag
var jQuery; //noconflict reference to jquery
var jqueryPath = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js";
var jqueryVersion = "1.8.3";
var scriptTag; //reference to the html script tag
/******** Get reference to self (scriptTag) *********/
var allScripts = document.getElementsByTagName('script');
@codex73
codex73 / .htaccess
Created November 9, 2015 16:57 — 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/
@codex73
codex73 / gist:ad84929efb44ab7f10ae
Created October 22, 2015 15:45 — forked from seanmcn/gist:62a021a765ad4f8e593b
The Perfect Web Server - Nginx, Ajenti, Ubuntu
#Insall Ajenti
apt-get update
wget http://repo.ajenti.org/debian/key -O- | apt-key add -
echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list
apt-get update
apt-get install ajenti
service ajenti restart
# Uninstall Apache2
sudo apt-get autoremove && sudo apt-get remove apache2*
@codex73
codex73 / gist:0ce3ad084238d137041f
Created October 21, 2015 14:23 — forked from phpfunk/gist:2636217
Viddler - Get thumbnails example
<?
include '/path/to/viddler/api/';
$v = new Viddler_V2('API_KEY');
$auth = $v->viddler_users_auth(array(
'user' => 'YOUR USERNAME',
'password' => 'YOUR PASSWORD'
));
if (! isset($auth['auth']['sessionid'])) {
<?php
// Multi Dimensional Array Search
private function searchForId($id, $array)
{
$value = '';
foreach ($array as $key => $val)
{
if ($val['hotel_PPID'] == $id)
{
#!/bin/bash
if [ $1 == '' ]; then
v_valid=false;
#obtain the desired site name
while ! $v_valid; do
read -p "site name:" site_name