This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /* This function attaches the image to the post in the database, add it to functions.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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function adaptiveResize() { | |
var $w, $target; | |
$target = $('img'); | |
$target.each(function() { | |
$w = $(this).parent().width(); | |
$target.css('max-height', $w ); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: Add TypeKit scripts to header | |
*/ | |
function my_theme_custom_head() { ?> | |
<script type="text/javascript"> | |
/* Your custom scripts go here */ | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* jQuery imagesLoaded plugin v2.0.1 | |
* http://github.com/desandro/imagesloaded | |
* | |
* MIT License. by Paul Irish et al. | |
*/ | |
(function(a,b){var c="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";a.fn.imagesLoaded=function(k){var h=this,m=a.isFunction(a.Deferred)?a.Deferred():0,l=a.isFunction(m.notify),e=h.find("img").add(h.filter("img")),f=[],j=[],g=[];function i(){var n=a(j),o=a(g);if(m){if(g.length){m.reject(e,n,o)}else{m.resolve(e)}}if(a.isFunction(k)){k.call(h,e,n,o) | |
}}function d(n,o){if(n.src===c||a.inArray(n,f)!==-1){return}f.push(n);if(o){g.push(n)}else{j.push(n)}a.data(n,"imagesLoaded",{isBroken:o,src:n.src});if(l){m.notifyWith(a(n),[o,e,a(j),a(g)])}if(e.length===f.length){setTimeout(i);e.unbind(".imagesLoaded")}}if(!e.length){i()}else{e.bind("load.imagesLoaded error.imagesLoaded",function(n){d(n.target,n.type==="error")}).each(function(n,p){var q=p.src;var o=a.data(p,"imagesLoaded");if(o&&o.src===q){d(p,o.isBroken);return}if(p.complete&&p.naturalWidth!==b){d(p,p.naturalWidt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The Header for the template. | |
* | |
* @package WordPress | |
*/ | |
$pp_theme_version = '1.0'; | |
?><!DOCTYPE html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $args = array( | |
'numberposts' => -1, | |
'offset' => 0, | |
'orderby' => 'post_date', | |
'order' => 'DESC', | |
'post_type' => 'custom_post_type_here', | |
'post_status' => 'publish', | |
'meta_query' => array( | |
array( | |
'key' => 'custom_field_key_name', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
function addCharLimit(){ | |
$('textarea').each(function(){ | |
maxlength = $(this).attr("maxlength"); | |
if ( maxlength !== undefined ) { | |
charContainer = $(this).parent().find('p.charleft').val(); | |
if ( charContainer === undefined ) { | |
$(this).parent().append("<p class='charleft description'>"); | |
} | |
charleft = maxlength - $(this).val().length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- begin pagination --> | |
<?php if( $engine->maxNumPages > 1 ) : | |
echo '<nav class="pagination"><ul>'; | |
$max = intval( $engine->maxNumPages ); | |
/**ID of your custom search results page here**/ | |
$permalink = get_permalink(479); | |
$prevPage = $swppg > 1 ? $swppg - 1 : false; | |
$nextPage = $swppg < $engine->maxNumPages ? $swppg + 1 : false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's say you run a WooCommerce subscription website, and you'd like to automatically add | |
a downloadable product to a subscriber's account when they activate their subscription. | |
Here's one way to do it: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mbn_get_stores_by_location( $zip, $radius ) { | |
global $wpdb; | |
$radius = intval( $radius ); | |
// we first need to get the source coordinates | |
$sql = "SELECT `latitude`, `longitude` FROM `wp_zip_codes` WHERE `zipcode` = '%s'"; | |
$coords = $wpdb->get_row( $wpdb->prepare( $sql, $zip ) ); | |