Skip to content

Instantly share code, notes, and snippets.

View alexmustin's full-sized avatar

Alex Mustin alexmustin

View GitHub Profile
@alexmustin
alexmustin / functions.php
Last active January 15, 2018 20:43
WooCommerce Box Office - Enable Tickets options on Subscription and Deposit product types
<?php
/*
* This code will enable the 'Tickets' checkbox and options on Subscription and Deposit products.
* Add this to your theme's functions.php file.
*/
//* Remove Filter from BOX OFFICE plugin
add_action( 'admin_init', 'remove_boxoffice_filter' );
function remove_boxoffice_filter(){
@alexmustin
alexmustin / functions.php
Last active January 15, 2018 20:45
Social Proof Slider - Show all testimonials in a UL list
<?php
/*
* This code will create a new 'list-testimonials' shortcode, which will show all testimonials in a UL list.
* Add this to your theme's functions.php file.
*/
// Add Shortcode
add_shortcode( 'list-testimonials', 'spslider_list_testimonials' );
@alexmustin
alexmustin / functions.php
Last active August 29, 2022 04:39
Add Genesis Widget to the End of the_content()
<?php
//* New Widget
genesis_register_sidebar( array(
'id' => 'after-blog-content',
'name' => __( 'After Blog Content', 'hello-pro' ),
'description' => __( 'Description of the widget goes here', 'hello-pro' ),
) );
//* Add widget after the_content()
@alexmustin
alexmustin / functions.php
Last active February 3, 2018 03:34
WooCommerce - Create new Admin Product Data Tab
<?php
/* CREATE THE NEW CUSTOM TAB
---------------------------------------------------- */
// First Register the Tab by hooking into the 'woocommerce_product_data_tabs' filter
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' );
function add_my_custom_product_data_tab( $product_data_tabs ) {
$product_data_tabs['my-custom-tab'] = array(
'label' => __( 'My Custom Tab', 'woocommerce' ),
'target' => 'my_custom_product_data',
@alexmustin
alexmustin / form-content.html
Created February 4, 2018 21:31
WordPress AJAX Live Search of Post Title
<!-- // The HTML (could be part of page content) // -->
<input type="text" name="keyword" id="keyword" onkeyup="fetch()"></input>
<div id="datafetch">Search results will appear here</div>
@alexmustin
alexmustin / sticky-nav.js
Created February 28, 2018 20:02
Sticky Navigation - jQuery script
jQuery(document).ready(function($) {
// Optimization: Store the references outside the event handler:
var $window = $(window);
// maximum height of site-header element (before sticky)
var maxHeaderHeight = $('body.sticky-header .site-header:not(.sticky)').outerHeight();
/* De-Bouncer script: pause resize calculations until last resize event is finished */
/* http://www.hnldesign.nl/work/code/debouncing-events-with-jquery/ */
@alexmustin
alexmustin / functions.php
Last active March 23, 2018 21:09
WooCommerce - is Product in Cart
<?php
function is_product_in_cart( $prodID ) {
$cartID = WC()->cart->generate_cart_id( $prodID );
$in_cart = WC()->cart->find_product_in_cart( $cartID );
if ( $in_cart ) {
return true;
}
return false;
}
@alexmustin
alexmustin / theme-setup.php
Last active April 18, 2018 18:52
CoachingPro theme setup modification -- disable first image as Featured Image
<?php
// Copy/Paste this code to overwrite the current code, starting at Line 220 of /coaching-pro/lib/theme-setup.php
add_action( 'genesis_entry_header', 'coaching_pro_show_featured_post_image', 1 );
function coaching_pro_show_featured_post_image() {
// only show on single posts and pages
if ( ! is_single() && ! is_page() || ! has_post_thumbnail() ) {
return;
}
@alexmustin
alexmustin / functions.php
Last active May 4, 2018 17:14
WooCommerce - allow editing of Orders regardless of Status
<?php
// WooCommerce -- allow editing of Orders regardless of Status
add_filter ( 'wc_order_is_editable', 'force_order_statuses_to_editable' );
function force_order_statuses_to_editable () {
return TRUE;
}
?>
@alexmustin
alexmustin / functions.php
Last active July 23, 2018 19:11
WooCommerce - Add custom field to Checkout page
<?php
/* ADD 'WEBSITE' REQUIRED FIELD TO CHECKOUT PAGE
----------------------------------------------------------------------------- */
//* Check if a specific product ID is in the cart
function hm_product_is_in_cart( $ids ) {
// Products currently in the cart
$cart_ids = array();
// Find each product in the cart and add it to the $cart_ids array
foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {