Skip to content

Instantly share code, notes, and snippets.

@loulou2u
loulou2u / private.application.custom_fields.php
Last active August 29, 2015 14:08
This Alex-made™ code demonstrates how to use five handlers to get and set a custom field on an existing LiveWhale datatype.
<?php
/*
This is a sample application designed to demonstrate how to add an additional custom field to a backend editor.
The example provided adds a "Dress Code" field to the existing event editor in LiveWhale. To add a custom field to the news editor, for example, follow the same example but change all references from events to news below.
*/
@loulou2u
loulou2u / gist:edb290bd1280fd6bee31
Last active August 29, 2015 14:16
shorten summary with dotdotdot
<script type="text/javascript" language="javascript">
$(document).ready(function() {
//indicate the class or id to apply the dotdotdot function
$(".events_summary").dotdotdot({
//configuration goes here
ellipsis: '... ',
wrap: 'word'
});
});
</script>
<style type="text/css">
/* Use the height attribute on the targetting class or id,
to determine where to shorten the content */
.events_summary{height: 100px;}
</style>
@loulou2u
loulou2u / private.application.custom_events.php
Last active August 29, 2015 14:18
private.application.custom_events.php
<?php
$_LW->REGISTERED_APPS['custom_events']=array(
'title'=>'Custom Events',
'handlers'=>array('onOutput')
);
class LiveWhaleApplicationCustomEvents{
public function onOutput($buffer){
@loulou2u
loulou2u / private.application.mytab.php
Last active August 29, 2015 14:19
Adding a LiveWhale Tab
public function onTabs($tabs) { // configures tabs
global $_LW;
if (@$_SESSION['livewhale']['manage']['grouptitle']!='Public'){
$tabs['mytab']=array('MyTab','https://link-to-your-application.edu',0,0,0); // add tab
}
return $tabs;
}
@loulou2u
loulou2u / public.application.protect_files.php
Last active August 29, 2015 14:21
Restrict Access to Files
//The custom app below redirects files tagged as "private" to a .htaccess protected directory
<?php
$_LW->REGISTERED_APPS['protect_files']=array(
'title'=>'Protect Files',
'handlers'=>array('onLoad')
);
class LiveWhaleApplicationProtectFiles {
@loulou2u
loulou2u / .htaccess
Created May 15, 2015 17:11
.htaccess file to determine SECURED URI
SetEnvIfNoCase Request_URI "^/authenticated-directory/*" SECURED
# enforce auth if SECURED=1
AuthType Basic
AuthName "Login Required"
AuthUserFile /path/to/.htpasswd
Require valid-user
Order allow,deny
Allow from all
Deny from env=SECURED
@loulou2u
loulou2u / public.application.resize_images.php
Last active August 29, 2015 14:21
Resizing RSS images
<?php
$_LW->REGISTERED_APPS['resize_images'] = array( // configure this application module
'title' => 'Resize Images',
'handlers' => array('onLoad')
);
class LiveWhaleApplicationResizeImages {
public function onLoad() { // on frontend request
@loulou2u
loulou2u / gist:c9363ba8ad8d83f9e484
Last active August 29, 2015 14:22
Code generated by Advanced Custom Fields plugin at add custom fields to page/post editors
// Calendar (3 events): Show three LiveWhale Calendar events in a horizontal row
// Below is the resulting code, which you can roll into the master functions.php if you want it to apply to all themes in a multisite site.
register_field_group(array (
'id' => 'acf_calendar-3-events',
'title' => 'Calendar (3 events)',
'fields' => array (
array (
'key' => 'field_53d14e3d55dba',
'label' => 'Show events?',
<?php
$_LW->REGISTERED_APPS['public_notifier']=array(
'title'=>'PublicNotifier',
'handlers' => array('onAfterPublicSubmission')
);
class LiveWhaleApplicationPublicNotifier {
// These two arrays are for including the users and/or groups that