Skip to content

Instantly share code, notes, and snippets.

View donaldallen's full-sized avatar

Donald Allen donaldallen

View GitHub Profile
// 1. Click Insert link.
// 2. Choose existing content.
// 3. Select said content and click "Add Link".
// Current resulting code
<a title="Some title" href="http://172.24.1.7/mysite/some-title/">Link</a>
// Proposed resulting code
<a title="Some title" href="[site_url]/some-title/">Link</a>
<?php
$ical = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:" . md5(uniqid(mt_rand(), true)) . "@domain.com
DTSTAMP:" . gmdate('Ymd')."T". gmdate('His') . "Z
DTSTART:" . $start_date->format('Ymd') . "T" . $start_date->format('Hi') . "00Z
DTEND:" . $end_date->format('Ymd') . "T" . $end_date->format('Hi') . "00Z
{{ files:listing folder="6" limit="100" order-by="date_added" direction="desc" }}
<a href="{{ url:site }}files/large/{{ filename }}" class="fancybox" data-fancybox-group="gallery">
<img src="{{ url:site }}files/thumb/{{ id }}/200/200" width="200" height="200" class="img-polaroid">
</a>
{{ /files:listing }}
<nav id="primary">
<ul>
<li {{ (Request::is('/') ? 'class="active"' : '') }}>{{ HTML::link(URL::to(''), 'Home') }}</li>
<li {{ (Request::is('/') ? 'class="active"' : '') }}>{{ HTML::link(URL::to(''), 'The Trade') }}</li>
</ul>
</nav>
// Being sent from a form via AJAX that gets URI encoded
list[1]=root&list[68]=root&list[67]=root
// Data from $this->input->data
list%5B1%5D%3Droot%26list%5B68%5D%3Droot%26list%5B67
<?php
$parts = parse_url($this->input->post('data'));
$query = array();
parse_str($parts['path'], $query);
@donaldallen
donaldallen / gist:6140230
Created August 2, 2013 14:21
Admin Table library for WP-MVC
<?php
require_once dirname(__FILE__).'/app/libraries/admin_table.php';
$wp_events_registrants_table = new Admin_Table($args = wp_parse_args($args, array(
'plural' => 'wp_list_events',
'singular' => 'wp_list_event',
'ajax' => false,
)));
public function display_content()
{
ob_start();
include_once(plugin_dir_path(__FILE__) . 'views/public.php');
$output_string = ob_get_contents();
ob_end_clean();
return $output_string;
}
(array) Array
(
[key] => field_5203ab0ca23ee
[label] => Question
[name] => question
[type] => repeater
[order_no] => 0
[instructions] =>
[required] => 1
[id] => acf-field-question
@donaldallen
donaldallen / gist:6253869
Last active December 21, 2015 04:59
WordPress: Admin notices
add_action('admin_notices', function() {
$action = (isset($_REQUEST['action']) ? $_REQUEST['action'] : null);
if ($action && $_REQUEST['page'] == 'mvc_events') {
$notice = '<div class="updated"><p>';
if ($action == 'delete') {
$notice .= 'Successfully deleted.';
} elseif ($action == 'cancel') {
$notice .= 'Successfully cancelled.';
<ol class="breadcrumb">
{{ template:breadcrumbs }}
{{ if uri }}
<li>{{ url:anchor segments=uri title=name }}</li>
{{ else }}
<li class="active">{{ name }}</li>
{{ endif }}
{{ /template:breadcrumbs }}
</ol>