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 / custom-redirect.php
Created August 21, 2012 19:57
Create redirects based on criteria
function rkv_custom_redirect() {
$source = 'http://domain.com/default.aspx';
$redirect = 'http://domain.com/';
if ($source) {
wp_redirect( esc_url_raw( $redirect ), 301 );
exit();
}
@norcross
norcross / wp-script-calls.php
Created August 23, 2012 16:21
using wp_enqueue_scripts and admin_enqueue_scripts
// front end
function custom_front_scripts() {
wp_enqueue_style( 'front-css', plugins_url('/lib/css/front-css.css', __FILE__), array(), null, 'all' );
wp_enqueue_script( 'front-init', plugins_url('/lib/js/front.init.js', __FILE__) , array('jquery'), null, true );
}
add_action('wp_enqueue_scripts', 'custom_front_scripts' );
// back end
function custom_admin_scripts() {
@norcross
norcross / plugin-support-threads.php
Created August 27, 2012 18:57
Create array of plugin support threads
<?php
function rkv_plugin_list($user) {
$url = 'http://api.wordpress.org/plugins/info/1.0/';
$args = array(
'body' => array (
'action' => 'query_plugins',
'request' => serialize( (object) array(
'author' => $user,
@norcross
norcross / nav-slash.php
Created August 31, 2012 18:30
nav with slashes
$footer_menu_args = array(
'theme_location' => 'footer',
'container_id' => 'footer_nav',
'depth' => 1,
'after' => '<span>/</span>',
);
wp_nav_menu( $footer_menu_args );
@norcross
norcross / body-class-elements.php
Created September 1, 2012 02:49
modifed core and new filter for non-class related body elements
// filter inside theme or plugin
function schema_bodyitems($item) {
$item[] = 'itemtype="http://schema.org/Blog"';
$item[] = 'itemscope=""';
return $item;
}
@norcross
norcross / lightbox-trigger.js
Created September 5, 2012 14:27
fire lightbox on load
// assuming that the input that fires the pop-up has the ID of 'pop_form'. Change as needed.
$('input#pop_form').trigger('click');
@norcross
norcross / liveblog-closed.php
Created September 6, 2012 19:42
listing closed liveblog
add_shortcode( 'liveblog_recap', 'wpcom_liveblog_recap' );
function wpcom_liveblog_recap( $atts, $content = null) {
// get ID if shortcode has declared
extract(shortcode_atts(array(
'id' => ''
), $atts));
// bail if missing ID
if (empty($id))
return $content;
@norcross
norcross / backend-page-query.php
Created September 11, 2012 14:11
Get pages inside CMB class
case 'page_select':
echo '<select name="', $field['id'], '" id="', $field['id'], '">';
$linked_items = get_posts(array(
'post_type' => array ('page',),
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'modified',
'order' => 'DESC'
));
foreach ($linked_items as $linked_item) {
@norcross
norcross / widget-examples.php
Created September 15, 2012 02:09
widget examples
<?php
/*
Plugin Name: Mukulla Custom Widgets
Plugin URI: https://gist.github.com/3726056
Description: A test plugin for showing some example widgets
Version: 0.1
Author: norcross
Author URI: http://andrewnorcross.com
License: GPL2
*/
@norcross
norcross / counter.css
Created September 18, 2012 16:57
Word Count JS
body {
background-color: #FFFFFF;
color: #111;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 20px;
margin: 0;
}
#wrapper {
width: 500px;