Skip to content

Instantly share code, notes, and snippets.

View jeffcdavis's full-sized avatar
👨‍💻

Jeff Davis jeffcdavis

👨‍💻
View GitHub Profile
@jeffcdavis
jeffcdavis / include-wordpress.php
Created March 15, 2013 01:28
Load WordPress database/functions outside of WordPress
<?php
// Include WordPress
define('WP_USE_THEMES', false);
require('/website-root-directory/wp-load.php');
?>
@jeffcdavis
jeffcdavis / backup-mssql.asp
Created March 15, 2013 01:45
If you need to run scheduled backups of a shared hosting MSSQL database. You can easily run a cron job on the following ASP script. May come in handy if you work with MSSQL databases or support older code.
<%
dim thismonth, thisday, thisyear, location, filelename, ver, extention, abolutespath
thismonth= datepart("m", now())
thisday=datepart("d", now())
thisyear=datepart("yyyy",now())
location="\\full-path-to-your-backup-folder\backup\"
filename="dbBackup-" & thismonth & "-" & thisday & "-" & thisyear & "_"
ver=1
@jeffcdavis
jeffcdavis / excerpt.php
Last active August 29, 2015 14:03
Custom WordPress excerpt length and read more link
<?php
function custom_read_more() {
return '&nbsp;<a class="read-more" href="'.get_permalink(get_the_ID()).'">[&#8230;]</a>';
}
function excerpt($limit) {
return wp_trim_words(get_the_excerpt(), $limit, custom_read_more());
}
/*
use excerpt(25) or whatever length you would like
@jeffcdavis
jeffcdavis / hybrid_content_template-filter.php
Last active August 29, 2015 14:03
Filter hook for hybrid_content_template
<?php
add_filter( 'hybrid_content_template', 'my_content_template' );
function my_content_template( $template ) {
if ( is_front_page() ) {
$has_template = locate_template( array( 'content-feature.php', 'content/feature.php' ), false, false );
if ( $has_template )
@jeffcdavis
jeffcdavis / embedded_templates.php
Created September 19, 2014 15:37
Extending the Event Rocket plugin dates
<?php
defined( 'ABSPATH' ) or exit();
/**
* Extremely basic templating engine for embedding templates inline between opening and
* closing shortcodes.
*/
class EventRocketEmbeddedEventTemplateParser
{
@jeffcdavis
jeffcdavis / functions.php
Last active August 29, 2015 14:06
Add new placeholders to Event Rocket plugin
<?php
/*may need additional placeholders for the event rocket plugin, which in turn extends The Events Calendar */
add_filter( 'eventrocket_embedded_event_placeholders', 'my_new_inline_template_tag' );
function my_new_inline_template_tag( $placeholders ) {
$placeholders['{random_number}'] = 'my_inline_template_tag_hander';
return $placeholders;
}
@jeffcdavis
jeffcdavis / functions.php
Created December 3, 2014 16:16
Add meta data to WP-API custom post type without authorization (example here is for Tribe Events Calendar)
<?php
add_filter( 'json_prepare_post', function ($data, $post, $context) {
$data['myextradata'] = array(
'start_date' => get_post_meta( $post['ID'], '_EventStartDate', true ),
'end_date' => get_post_meta( $post['ID'], '_EventEndDate', true ),
);
return $data;
}, 10, 3 );
@jeffcdavis
jeffcdavis / functions.php
Last active August 10, 2016 21:24 — forked from ckpicker/gist:344cd1a5cbcbdf93a0d7
Remove HTML credit from Tribe Events Calendar
function remove_html_credit() {
return '';
}
add_filter( 'tribe_html_credit', 'remove_html_credit' );
if let arrayOfTabBarItems = self.tabBarController!.tabBar.items as! AnyObject as? NSArray,tabBarItem = arrayOfTabBarItems[2] as? UITabBarItem {
tabBarItem.enabled = false
}
if let tabBarController = self.tabBarController {
let indexToRemove = 2
if indexToRemove < tabBarController.viewControllers?.count {
var viewControllers = tabBarController.viewControllers
viewControllers?.removeAtIndex(indexToRemove)
tabBarController.viewControllers = viewControllers
}
}