Skip to content

Instantly share code, notes, and snippets.

Simon Kelly simonlk

Block or report user

Report or block simonlk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@simonlk
simonlk / genesis-full-width-footer.php
Created Jan 11, 2017
Full width widgets and site footer on Genesis framework for WordPress
View genesis-full-width-footer.php
View woocommerce-redirect-to-checkout.php
<?php
/**
* Plugin Name: WooCommerce Subscriptions Redirect to Checkout
* Description: Redirect customers to the checkout page when adding a subscription to their cart (rather than the checkout page, which is the default).
* Author: Simon Kelly
* Author URI: http://www.renegade-empire.com
* Version: 1.0
* License: GPL v2
*/
@simonlk
simonlk / .htaccess
Last active Nov 28, 2016
WordPress load uploads from external website.
View .htaccess
# Create .htaccess file within /wp-content/uploads/ and add the below code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} http://dev.example.com # Only perform on dev site
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) http://www.example.com/wp-content/uploads/$1 [L,P]
</IfModule>
View Beaver Builder - author box
// Author profile box
// Thanks Justin Busa and Viktor http://forum.wpbeaverbuilder.com/support/q/author-bio-box/
function my_author_bio($content) {
if ( is_singular('post') ) {
ob_start(); ?>
<div class="fl-author-bio clearfix media well">
<div class="fl-author-bio-thumb media-left">
<img src="<?php echo get_avatar_url( get_the_author_meta('ID'), 96 ); ?>" alt="<?php the_author(); ?>" class="media-object" />
</div>
<div class="fl-author-bio-text media-body">
View wordpress menu shortcode
/*==================================================
Create menu shortcodes - [menu name="menu-name"]
================================================= */
function sk_menu_content_shortcode( $atts, $content = null ) {
extract( shortcode_atts(array( 'name' => null, ), $atts ) );
return wp_nav_menu( array( 'menu' => $name, 'echo' => false ) );
}
add_shortcode( 'menu', 'sk_menu_content_shortcode' );
@simonlk
simonlk / woocommerce-deny-pobox-shipping
Created Jun 22, 2014
WooCommerce - Don't allow shipping to PO Box addresses
View woocommerce-deny-pobox-shipping
add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode');
function deny_pobox_postcode( $posted ) {
global $woocommerce;
// Put postcode, address 1 and address 2 into an array
$check_address = array();
$check_address[] = isset( $posted['shipping_postcode'] ) ? $posted['shipping_postcode'] : $posted['billing_postcode'];
$check_address[] = isset( $posted['shipping_address_1'] ) ? $posted['shipping_address_1'] : $posted['billing_address_1'];
$check_address[] = isset( $posted['shipping_address_2'] ) ? $posted['shipping_address_2'] : $posted['billing_address_2'];
@simonlk
simonlk / soliloquy-link-caption
Created Jun 11, 2014
Add link to Soliloquy caption
View soliloquy-link-caption
@simonlk
simonlk / woocommerce-subs-start-date-edit-debug-off
Created Jun 10, 2014
Modify WooCommerce subscription start date without debug mode
View woocommerce-subs-start-date-edit-debug-off
/* Add _subscription_start_date back to the viewable order meta data */
add_filter( 'woocommerce_hidden_order_itemmeta', 'theme_hide_order_itemmeta' );
function theme_hide_order_itemmeta( $hidden_meta_keys ) {
if ( ! defined( 'WCS_DEBUG' ) || true !== WCS_DEBUG ) {
if(($key = array_search('_subscription_start_date', $hidden_meta_keys)) !== false) {
unset($hidden_meta_keys[$key]);
}
}
return $hidden_meta_keys;
}
@simonlk
simonlk / wp login logout main menu
Created Jun 9, 2014
Add login/logout menu to WordPress main menu
View wp login logout main menu
/* =====================================================
Login/logout menu button
===================================================== */
add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_login_logout_link($items, $args) {
if( $args->theme_location == 'primary-menu' ) {
ob_start();
wp_loginout(get_permalink());
$loginoutlink = ob_get_contents();
ob_end_clean();
@simonlk
simonlk / gist:164e25293343bc502dda
Created Jun 1, 2014
Add/Remove custom fields in WordPress profile
View gist:164e25293343bc502dda
/* =====================================================
Custom profile field
===================================================== */
function modify_contact_methods($profile_fields) {
// Add new fields
$profile_fields['company_name'] = 'Company Name';
// Remove old fields
unset($profile_fields['aim']);
You can’t perform that action at this time.