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 / 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 / WooUpgradeTestSuiteCest.php
Last active March 7, 2019 14:22
Run various acceptance tests for WooCommerce
<?php
/**
* WooCommerce Upgrade Test Suite
*
* A set of acceptance tests for a standard WooCommerce store.
*
* https://gist.github.com/norcross/4d45f1902bfb2f1f4cf79997a47d9d03
*/
// It'll error out sometimes without this ¯\_(ツ)_/¯ .
@norcross
norcross / csv-export-example.php
Created August 9, 2015 20:14
a basic CSV export example
<?php
/**
* Devin CSV Export
*
* Contains our export processing
*/
/*
Copyright 2015 Reaktiv Studios
This program is free software; you can redistribute it and/or modify
@norcross
norcross / admin-bar-kill.php
Created January 17, 2013 22:44
remove admin bar globally on front and back end
<?php
add_action ( 'init', 'rkv_adminbar_front_kill' );
add_action ( 'admin_init', 'rkv_adminbar_back_kill' );
function rkv_adminbar_front_kill() {
show_admin_bar( false );
wp_dequeue_script('admin-bar');
wp_dequeue_style('admin-bar');
@norcross
norcross / emailbot_ssc.php
Created October 1, 2012 15:37
Obfuscate email shortcode
/*
Usage (on the HTML tab, not the visual editor)
[email address="you@emailcompany.com"]
*/
function emailbot_ssc($attr) {
extract( shortcode_atts( array(
'address' => '',
), $attr ) );
@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;
@norcross
norcross / content-create.php
Last active February 20, 2018 16:50
Functionality pieces for the NextDraft build
<?php
/**
* AJAX call for parsing HTML
*
*/
public function parse_html() {
// get content from textarea
$text = $_POST['content'];
@norcross
norcross / cpt-rss.php
Created December 17, 2012 12:21
add custom post type to RSS
function cpt_feed_request($qv) {
if (isset($qv['feed']))
$qv['post_type'] = get_post_types();
return $qv;
}
add_filter('request', 'cpt_feed_request');
@norcross
norcross / force-image-https.php
Created January 21, 2015 02:08
filter content to rewrite image src to https
<?php
add_filter( 'the_content', 'rkv_force_https_images', 10 );
/**
* check image URLs and force https on them
*
* @param [type] $content [description]
*/
function rkv_force_https_images( $content ) {
return str_replace( 'src="http://css-tricks.com', 'src="https://css-tricks.com', $content );
@norcross
norcross / image-link-default.php
Created October 2, 2012 00:52
set default image link