Skip to content

Instantly share code, notes, and snippets.

View norcross's full-sized avatar
somone said this would be easy. someone LIED.

Norcross norcross

somone said this would be easy. someone LIED.
View GitHub Profile
@norcross
norcross / head_redirect.php
Created April 29, 2012 22:12
PHP redirects
<?php
add_action ('wp_head', 'rkv_new_redirects', 1); // create redirects
function rkv_new_redirects() {
$newurl = 'http://mynewurl.com';
$slug = basename(get_permalink());
$cat = get_query_var('cat');
$cat_s = get_category ($cat);
$c_slug = $cat_s->slug;
// set up
@norcross
norcross / rkv-media-link
Created June 19, 2012 14:28
Change default linking WP media
@norcross
norcross / Image-Waterfall.php
Created July 7, 2012 04:32 — forked from eddiemachado-zz/Image-Waterfall.php
images with fallbacks
// let's go through and get the right image
function dg_thumb_waterfall() {
global $post;
if ( has_post_thumbnail($post->ID) ) {
echo '<div class="thumbnail-wrapper">';
the_post_thumbnail('digi-med-thumb');
echo '</div>';
@norcross
norcross / old-post-search-filter.php
Created July 23, 2012 14:50
filter search result to hide old posts
function rkv_search_filter( $where = '' ) {
// don't touch anything outside of a search query
if(is_admin() || !is_search() )
return $where;
// Hide posts older than 2 years old
if ( is_search() ){
$where .= "AND post_type = 'post' AND post_date >= '" . date('Y-m-d', strtotime('-730 days')) . "'";
return $where;
}
@norcross
norcross / format-content
Created July 26, 2012 20:01
format text from custom call
global $post;
$content = $post->post_content;
echo wpautop($content);
@norcross
norcross / jquery.radioset
Created August 1, 2012 15:38
allow labels to set input for radio and checkbox
// **************************************************************
// set inputs when clicking labels
// **************************************************************
$('div#default_license span.ap_option label[rel="ap_rd"]').each(function() {
$(this).click(function() {
if($(this).hasClass('disabled-label'))
return;
@norcross
norcross / image-url-fix
Created August 10, 2012 03:38
create clean attachment URLs
// clean URLs for attachments
// http://domain.com/?attachment_id=173
// http://domain.com/attachment/173
function rkv_attachment_urls($wp_rewrite){
$new_rules = array();
$new_rules['media/(\d*)$'] = 'index.php?attachment_id=$matches[1]';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
<?php
function amm_change_title($title) {
global $post;
$type = get_post_type( $post->ID );
$slug = basename(get_permalink( $post->ID ));
if( 'page' == $type && 'title-test' == $slug )
$title = esc_attr( 'My Awesome Title' );
@norcross
norcross / shopp-comment-hide.js
Created August 14, 2012 02:10
Hide comments and pingbacks on Shopp
jQuery(document).ready(function($) {
//********************************************************
// expand / collapse for settings page
//********************************************************
$('div.settings_group div.dg_wrap').hide();
// show or hide new license block licenses
$('div.settings_group input.toggle_group').click(function() {
var name = $(this).attr('name');
@norcross
norcross / mc-campain-list.php
Created August 17, 2012 20:23
MailChimp Campaign List
function mc_campaign_content($cid) {
$apikey = 'APIKEY';
$method = 'campaignContent';
$archive = 'true';
$request = new WP_Http;
$url = 'http://<dc>.api.mailchimp.com/1.3/?method='.$method.'&apikey='.$apikey.'&cid='.$cid.'&for_archive='.$archive.'&output=json';
$response = wp_remote_get ( $url );