Skip to content

Instantly share code, notes, and snippets.

View geilt's full-sized avatar

Alexander Conroy geilt

View GitHub Profile
@geilt
geilt / clone.js
Last active December 12, 2015 07:28
Allows you to clone an element with select data.
/**
* Clone Elements by Alexander Conroy
* Copyright 2012 Esotech Inc.
* MIT License
* http://opensource.org/licenses/MIT
*/
$(document).on('click', '.clone', function() {
// This should be a generic class you give to the element you want to clone. The clone button should be inside the element.
var clone = $(this).closest('.skeleton')
var newClone = clone.clone();
@geilt
geilt / excerpt.php
Last active December 12, 2015 08:59
Better Excerpt functionality for Wordpress. Just paste functions.php in Wordpress to use.
/**
* Excerpt by Alexander Conroy
* Copyright 2012 Esotech Inc.
* MIT License
* http://opensource.org/licenses/MIT
*/
<?php
if(!function_exists( 'excerpt' ) ):
function excerpt( $size = '165', $content = NULL, $echo = TRUE, $ellipsis = TRUE, $wrap = TRUE ) {
if(!$content):
@geilt
geilt / meta.php
Last active December 12, 2015 12:38
Simpul Meta - For Adding Meta Fields to Wordpress Post Types
<?php
/**
* SimpulMeta by Alexander Conroy
* Copyright 2012 Esotech Inc.
* MIT License
* http://opensource.org/licenses/MIT
*
* args = array()
* Valid Values:
* post_type - Which post type to attach meta to.
@geilt
geilt / thumb.php
Last active June 13, 2016 21:20
Better Thumbnails for Wordpress using Timthumb.
<?php
/**
* Thumb by Alexander Conroy
* Copyright 2012 Esotech Inc.
* MIT License
* http://opensource.org/licenses/MIT
*/
$thumb = get_template_directory_uri() . "/includes/timthumb.php?";
if(!function_exists( 'thumb' ) ):
function thumb( $args = array(), $echo = true) {
@geilt
geilt / register_scripts.php
Created March 27, 2013 19:33
Register Scripts and Styles for Wordpress. Put this in functions.php
<?php
add_action('wp_enqueue_scripts', 'register_my_scripts');
if(!function_exists('register_my_scripts')):
function register_my_scripts() {
//wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
wp_enqueue_script('scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery') );
//wp_enqueue_style( $handle, $src, $deps, $ver, $media );
wp_enqueue_style( 'style', get_template_directory_uri() . '/style.css', false, false, 'screen' );
}
@geilt
geilt / simpul.meta.upload.js
Created April 16, 2013 21:11
Theme Options for Multiple Slider images. Customize as needed!
var original_send_to_editor = "";
var modified_send_to_editor = "";
var formfield = '';
var hrefurl = '';
jQuery(document).ready( function() {
original_send_to_editor = window.send_to_editor;
modified_send_to_editor = function(html) {
@geilt
geilt / insert_attachment.php
Created April 24, 2013 15:37
This allows you to take something from the $_FILES array on user input and insert it into a post. as featured or non featured image.
<?php
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
$attach_id = media_handle_upload( $file_handler, $post_id );
@geilt
geilt / isBot.php
Last active December 16, 2015 15:29
Checks for proxies as well as the most common bots for pinterest google and twitter when using the share features.
<?php
function isBot(){
if(!empty($_SERVER['VIA'])):
return true;
endif;
if(!empty($_SERVER['REMOTE_PORT']) && in_array($_SERVER['REMOTE_PORT'], array(8080,80,6588,8000,3128,553,554))):
return true;
endif;
//if(!empty($_SERVER['REMOTE_ADDR']) && fsockopen($_SERVER['REMOTE_ADDR'], 80, $errno, $errstr, 30)): // this Causes Lag...
// return false;
@geilt
geilt / add_do_action.php
Created April 24, 2013 23:12
Add Action and Do Action for any system using Globals. Inspired by Wordpress but custom Coded.
<?php
// Queue: Queues a function or object method to be run during do_action
function add_action($action, $function, $priority = 10, $args = array()){
$GLOBALS['actions'][$action][$priority][] = array('function' => $function, 'args' => $args);
}
// Hook: Runs a function or a object method based on add_action
function do_action($action){
$done = '';
if(!empty($GLOBALS['actions'][$action])):
foreach($GLOBALS['actions'][$action] as $priorities):
@geilt
geilt / news_meta.php
Created May 7, 2013 17:42
Wordpress News Meta
<?php
/*
* Title: News Meta Function
* Author: Alexander Conroy
* Version: 1.0.1
* Website: http://www.esotech.org
* Purpose: Tags Tags for Current Post and puts it in the header meta comma separated maximum 10 tags.
* License: GPLv3+
*/