Skip to content

Instantly share code, notes, and snippets.

View ewistrand's full-sized avatar
🦸‍♂️

Eric Wistrand ewistrand

🦸‍♂️
  • Truly Free
  • Traverse City Michigan
View GitHub Profile
@ewistrand
ewistrand / wp-post-id-column.php
Last active November 19, 2015 13:55
Create admin post and page id column in Wordpress admin
<?php
// Show Page Id In Admin panel
add_filter('manage_posts_columns', 'posts_columns_id', 5);
add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2);
add_filter('manage_pages_columns', 'posts_columns_id', 5);
add_action('manage_pages_custom_column', 'posts_custom_id_columns', 5, 2);
function posts_columns_id($defaults){
$defaults['wps_post_id'] = __('ID');
return $defaults;
@ewistrand
ewistrand / wp-widget-shortcodes.php
Created November 19, 2015 13:58
WP allow shortcodes in sidebar text widgets
<?php
/**
* Allow shortcodes in WP text widgets
*/
add_filter('widget_text', 'do_shortcode');
?>
@ewistrand
ewistrand / wp-extract-shortcode.php
Created November 19, 2015 14:08
WP Extract Shortcode from the_content
<?php
/**
* Use in loop or single, has to access post_content
*/
$pattern = get_shortcode_regex();
preg_match('/'.$pattern.'/s', $post->post_content, $matches);
if (is_array($matches) && $matches[2] == 'smart_track_player') {
$shortcode = $matches[0];
echo do_shortcode($shortcode);
}
@ewistrand
ewistrand / bs3-480-grid.css
Created November 19, 2015 14:40
Bootstrap 3 480px grid
.col-ms-1,
.col-ms-2,
.col-ms-3,
.col-ms-4,
.col-ms-5,
.col-ms-6,
.col-ms-7,
.col-ms-8,
.col-ms-9,
.col-ms-10,
@ewistrand
ewistrand / wp-custom-paginated-loop.php
Created November 19, 2015 14:49
Custom Wordpress loop with pagination
<?php
/**
* Create post loop query
*/
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'post',
'orderby' => 'menu_order',
'order' => 'ASC',
'showposts' => 3,
@ewistrand
ewistrand / grid.scss
Created November 19, 2015 14:52
Simple SASS Grid
/* Grid Variables */
$grid-columns: 12;
$grid-max-width: 1920px;
/* Break Points */
$breakpoint-xs: "screen and (min-width: 320px)";
$breakpoint-ms: "screen and (min-width: 480px)";
$breakpoint-sm: "screen and (min-width: 768px)";
$breakpoint-md: "screen and (min-width: 1024px)";
$breakpoint-lg: "screen and (min-width: 1280px)";
@ewistrand
ewistrand / wp-default-custom-fields.php
Created November 19, 2015 14:57
WP Add default custom fields to posts
<?php
/**
* Add Default Custom Fields To Posts
* Note: This is just an example.
*/
add_action('wp_insert_post', 'set_default_custom_fields');
function set_default_custom_fields($post_id){
// slides can be post or any custom post type
if ( $_GET['post_type'] == 'slides' ) {
add_post_meta($post_id, 'subtitle', '', true);
@ewistrand
ewistrand / woo-disable-payment-require.php
Created November 23, 2015 21:48
Woocommerce disable requirement of payment
<?php
// woocommerce cart disable requirement of payment
add_filter('woocommerce_cart_needs_payment', '__return_false');
?>
@ewistrand
ewistrand / wp-woocommerce-remove-elements.php
Created November 23, 2015 21:51 — forked from dompascal/wp-woocommerce-remove-elements.php
WP - WOOCOMMERCE - Remove Woocommerce Elements
/** woocommerce remove elements **/
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
remove_action( 'woocommerce_before_shop_loop','woocommerce_result_count', 20, 0);
remove_action( 'woocommerce_before_shop_loop','woocommerce_catalog_ordering', 30, 0);
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_after_single_product_summary','woocommerce_output_product_data_tabs', 10, 0);
@ewistrand
ewistrand / all-clients-add-contact.php
Created November 24, 2015 17:00
All Clients Add Contact
<?php
try {
/**
* AllClients Account ID and API Key.
*/
$account_id = esc_html( get_theme_mod( 'all_clients_id' ) );
$api_key = esc_html( get_theme_mod( 'all_clients_token' ) );
//print_r($options);