Skip to content

Instantly share code, notes, and snippets.

View amphibian's full-sized avatar

Derek Hogue amphibian

View GitHub Profile
@amphibian
amphibian / gist:5414609
Created April 18, 2013 17:29
Quick example of one way to deal with Localize class methods which will be deprecated in ExpressionEngine 2.6
<?php
// Backwards-compatibility with pre-2.6 Localize class
$format_date_fn = (version_compare(APP_VER, '2.6', '>=')) ? 'format_date' : 'decode_date';
echo $this->EE->localize->{$format_date_fn}('%Y-%m-%d', $this->EE->localize->now);
// 2013-04-18
@amphibian
amphibian / devot-ee-statusboard.php
Last active December 16, 2015 07:58
devot:ee developer sales widget for Panic's StatusBoard iPad app
<?php
/*
devot:ee developer sales widget for Panic's StatusBoard iPad app
http://panic.com/statusboard
Author: Derek Hogue (http://amphibian.info)
Usage: Fill-in your devot:ee API credentials, then upload to your server.
You can use this script to feed either the Graph widget or Table widget.
@amphibian
amphibian / gist:4588185
Last active December 11, 2015 10:38
Addition to pi.delete.php to trigger the delete_entries_loop hook. (For http://devot-ee.com/add-ons/delete-entries-and-comments)
// ~ Line 120
if ($deleted == TRUE)
{
$this->EE->extensions->call('delete_entries_loop', $entry_id, $channel_id);
$return = ($this->EE->TMPL->fetch_param('message_success') ? $this->EE->TMPL->fetch_param('message_success') : $this->message_success);
}
else
{
$return = $this->message_failure;
}
@amphibian
amphibian / gist:2220628
Created March 27, 2012 21:42
MailChimp subscribe REST API
$url = 'http://us1.api.mailchimp.com/1.3/?method=listSubscribe&apikey=YOUR_API_KEY&id=YOUR_LIST_ID&email_address=EMAIL&output=php';
// cURL request with $url
@amphibian
amphibian / ft.distinct_dropdown.php
Created September 22, 2011 20:21
Quickie fieldtype for a dropdown where each value can only be selected in a single entry.
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
/*
Distinct Dropdown fieldtype
- Requires the P&T fieldpack to be installed
- Won't work inside a Matrix row
- Won't work in SafeCracker, as we can't access the current entry_id
(at least I don't think?)
- Idea could be ported to multiselect, checkbox group, and radio fields
*/
@amphibian
amphibian / default_formatting.php
Created May 24, 2011 21:21
Set default formatting options in ExpressionEngine.
<?php
// Note that this has only been tested with the 2.1.5 beta
// Editing starts at line 3926 and goes until line 3963 of /system/expressionengine/controllers/cp/admin_content.php
// Start here:
// build list of formatting options
// (Add whatever additional formatting plugins you like here)
@amphibian
amphibian / gigpress_ticket_col
Created May 17, 2011 13:12
Support aid: add the ticket link as its own column in GigPress
In shows-list.php find this ...
<?php if($gpo['display_country'] == 1) : ?>
<td class="gigpress-country"><?php echo $showdata['country']; ?></td>
<?php endif; ?>
And add this right after:
<td class="gigpress-ticket-col">
<?php echo $showdata['ticket_link']; ?>
@amphibian
amphibian / truncate.js
Created April 20, 2011 14:33
jQuery snippet to truncate unruly links (usually posted in your comments section)
$('#comments a').each(function(){ var str = $(this).text().split(' '); if(str[0].length > 30){ $(this).html($(this).text().substr(0,30) + '[&hellip;]'); } });
@amphibian
amphibian / create_ee_thumbs
Created April 13, 2011 20:46
Creates internal thumbnails for images uploaded outside of ExpressionEngine. Requires EE 2.1.4 or later.
<?php
// Change your upload directory ID here.
$upload_dir_id = 2;
$this->EE =& get_instance();
$this->EE->load->library('filemanager');
$files = $this->EE->filemanager->fetch_files($upload_dir_id);
foreach($files->files[$upload_dir_id] as $data)
{
$dir = array('server_path' => $data['relative_path']);
@amphibian
amphibian / url-match regex
Created November 28, 2009 17:57
John Gruber's URL-matching PCRE regular expression.
\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))