Skip to content

Instantly share code, notes, and snippets.

View geilt's full-sized avatar

Alexander Conroy geilt

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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();