Skip to content

Instantly share code, notes, and snippets.

View anointed's full-sized avatar

shawn gaffney anointed

View GitHub Profile
@anointed
anointed / admin-redirect.php
Created September 28, 2012 06:17
Admin wildcard redirect
<?php
<?php
/*
Plugin Name: Average CMS Wildcard Admin Redirect
Plugin URI: https://github.com/cramerdev/acms-wildcard-admin-redirect
Description: Redirects the admin pages for a mapped domain to the non-mapped version of the domain. This is required because when FORCE_SSL_ADMIN is enabled, by default the redirect will go the the https version of the URL you're on. If you're using domain mapping, that domain might not have a valid SSL certificate. This plugin redirects to the original, non-mapped domain instead. This plugin MUST be loaded AFTER the wordpress-mu-domain-mapping plugin. One way to do this is to rename this file prefixed with a z_ or something.
Version: 0.0.2
Author: Nathan L Smith
*/
@anointed
anointed / wildcard_admin_redirect.php
Created September 28, 2012 06:15
Redirects the login page for a mapped domain to the non-mapped domain
<?php
function wildcard_admin_redirect($location, $status = 302) {
$url = parse_url($location);
if ($url['scheme'] === 'https' &&
(preg_match("/\/wp-[login|admin|register]/", $url['path']) > 0)) {
$orig = preg_replace("/^https?:\/\//", "", get_original_url($url['host']));
if ($orig && $orig !== $url['host']) {
$location = 'https://'.$orig.$url[path];
}
}
@anointed
anointed / installer.php
Created August 18, 2012 05:03
Automated WordPress installer
#!/usr/bin/php
<?php
$usage = "Automated Wordpress installer\nby Ali Gangji\nUsage: wordpress install_dir -u dbuser -p dbpass -d dbname\nOptions:\n";
$usage .= " -u dbuser Database username\n";
$usage .= " -p dbpass Database password\n";
$usage .= " -d dbname Database name\n";
$usage .= " -h dbhost Database host\n";
$usage .= " --private Hide blog from search engines\n";
$usage .= " --prefix prefix Database prefix\n";
if ($argc < 2) {
@anointed
anointed / grids.html
Created July 29, 2012 18:13
zurb example
<!-- The Basics -->
<div class="container">
<div class="row">
<div class="eight columns">
Eight columns
</div>
<div class="four columns">
Four columns
</div>
@anointed
anointed / tumble-container.php
Created July 25, 2012 20:34
layout main content container
function tumble_layout_main_content_container($args) {
$defaults = array (
'before' => '<div id="' . tumble_get_context() . '" class="' .tumble_get_current_page_layout(). '" >',
'after' => '</div>',
);
$args = wp_parse_args( $args, $defaults );
extract( $args, EXTR_SKIP );
@anointed
anointed / modal-form.php
Created July 23, 2012 07:25
passing value from iframe modal to parent window
<?php
<form action="/wp-admin/media-upload.php?tab=kaltura_upload&amp;kaction=sendtoeditor&amp;firstedit=true&amp;entryIds%5B0%5D=0_715ta6uz" class="kalturaForm" method="post">
<input type="submit" class="button-secondary" name="tumble2_kaltura-video" value="Add Video">
</form>
?>
<?php if (!defined("WP_ADMIN")) die();?>
<?php if ($viewData["uiConfId"]): ?>
<script type="text/javascript">
var playerWidth = "<?php echo $viewData["playerWidth"]; ?>";
var playerHeight = "<?php echo $viewData["playerHeight"]; ?>";
var uiConfId = "<?php echo $viewData["uiConfId"]; ?>";
var entryId = "<?php echo $viewData["entryId"]; ?>";
var addPermission = "<?php echo $viewData["addPermission"]; ?>";
var editPermission = "<?php echo $viewData["editPermission"]; ?>";
@anointed
anointed / kaltura-submit.php
Created July 22, 2012 01:00
kaltura modified thickbox
<?php if (!defined("WP_ADMIN")) die();?>
<?php if ($viewData["uiConfId"]): ?>
<script type="text/javascript">
var playerWidth = "<?php echo $viewData["playerWidth"]; ?>";
var playerHeight = "<?php echo $viewData["playerHeight"]; ?>";
var uiConfId = "<?php echo $viewData["uiConfId"]; ?>";
var entryId = "<?php echo $viewData["entryId"]; ?>";
var addPermission = "<?php echo $viewData["addPermission"]; ?>";
var editPermission = "<?php echo $viewData["editPermission"]; ?>";
@anointed
anointed / media-uploader.js
Created July 21, 2012 05:20
media uploader
$(document).ready(function() {
$('#button-upload').click(function() {
formfield = $('#image-upload').attr('name');
tb_show('', 'media-upload.php&tab=shawn_upload&type=image&TB_iframe=true');
return false;
});
window.send_to_editor = function(html) {
imgurl = $('img',html).attr('src');
$('#image-upload').val(imgurl);
tb_remove();
@anointed
anointed / code-wrap.php
Created July 19, 2012 04:10
metabox code wrapper
<?php
function add_my_class( $begin, $field, $meta ) {
$begin = <<<HTML
<div class="field-wrap-{$field['id']}">
HTML;
$end = '</div>';
$class = 'rwmb-label';
if ( ! empty( $field['class'] ) )