Skip to content

Instantly share code, notes, and snippets.

View grayayer's full-sized avatar

Gray Ayer grayayer

View GitHub Profile
@grayayer
grayayer / ce-redirect.php
Created September 29, 2016 17:31 — forked from jg314/ce-redirect.php
Events Calendar Community Events: Redirect users to a new page after submission
<?php
/*
* Send visitors who submit events to a different page after submission.
*
* This actually does the redirect. If an event was submitted, and we're about
* to reload the submission page (with a message instead of a form), this will
* redirect the user.
*
* @param WP $wp
* @return void
@grayayer
grayayer / restrict.php
Last active October 5, 2016 17:55 — forked from mikeyarce/restrict.php
WooCommerce Memberships restriction on a page through using a template. This is how we can easily do it for pages that aren't generated through a post, like the Events Calendar archive
<?php
$user_id = get_current_user_id();
if ( wc_memberships_is_user_active_member( $user_id, 'gold' ) ) {
get_template_part( 'template', 'gold' );
} else {
echo "You are not allowed to view this content";
}
?>
@grayayer
grayayer / functions.php
Last active October 7, 2016 21:18 — forked from BFTrick/functions.php
Change WooCommerce Email Styles
<?php
add_filter( 'woocommerce_email_styles', 'patricks_woocommerce_email_styles' );
function patricks_woocommerce_email_styles( $css ) {
$css .= "#template_header { background-color: #231f20; }";
return $css;
}
@grayayer
grayayer / The7ChildThemeFunctions.php
Created October 26, 2016 01:12 — forked from thecodepoetry/functions.php
To change default pre selected sidebar position in The7 and Armada
function dt_change_default_sidebar() {
global $DT_META_BOXES;
if ( $DT_META_BOXES ) {
if ( isset($DT_META_BOXES[ 'dt_page_box-sidebar' ]) ) {
$DT_META_BOXES[ 'dt_page_box-sidebar' ]['fields'][0]['std'] = 'left'; // use disabled to disable sidebar
}
@grayayer
grayayer / functions.php
Created April 20, 2017 22:29 — forked from temperatio/functions.php
Woocommerce: Remove related products
/**
* Remove related products
*/
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
@grayayer
grayayer / add-product-to-cart.php
Created March 3, 2018 00:35 — forked from sc0ttkclark/add-product-to-cart.php
WooCommerce Automatically add product to cart on site visit
<?php
/*
* This code goes into theme functions.php or a custom plugin
*/
/**
* Add product to cart on page load
*/
function add_product_to_cart() {
Search for : (.*(\n|$)){2}
alt+R - to toggle regular expression search
alt+ENTER - to select all results