Skip to content

Instantly share code, notes, and snippets.

View grayayer's full-sized avatar

Gray Ayer grayayer

View GitHub Profile
@grayayer
grayayer / plugin-name.php
Created October 10, 2016 22:59
Disable a plugin's check for updates - useful when you've modified the plugin directly (don't do that though)
add_filter( 'http_request_args', 'dm_prevent_update_check', 10, 2 );
function dm_prevent_update_check( $r, $url ) {
if ( 0 === strpos( $url, 'http://api.wordpress.org/plugins/update-check/' ) ) {
$my_plugin = plugin_basename( __FILE__ );
$plugins = unserialize( $r['body']['plugins'] );
unset( $plugins->plugins[$my_plugin] );
unset( $plugins->active[array_search( $my_plugin, $plugins->active )] );
$r['body']['plugins'] = serialize( $plugins );
}
return $r;
@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 / 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 / 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 / add_helpful_user_classes.php
Last active April 22, 2017 01:23
Appends user role and id to the body classes for for front and backend in wordpress. Place this in a functionality plugin or functions.php file in the theme.
function add_helpful_user_classes() {
if ( is_user_logged_in() ) {
add_filter('body_class','class_to_body');
add_filter('admin_body_class', 'class_to_body_admin');
}
}
add_action('init', 'add_helpful_user_classes');
/// Add user role class to front-end body tag
function class_to_body($classes) {