Skip to content

Instantly share code, notes, and snippets.

@neilgee
neilgee / addinfunctions.php
Last active Feb 22, 2021
Gravity Form Word Count
View addinfunctions.php
<?php
/* Gravity Forms Word Count Script */
function els_load_scripts() {
wp_enqueue_script('gravity-forms-word-count', get_stylesheet_directory_uri() . '/js/jquery.gravity_word_count.js', array('jquery'), '0.1', true);
}
add_action('wp_enqueue_scripts', 'els_load_scripts');
/*Then in the form, for fields that need the word count, add the class ‘els-word-count[300].' Change [300] as needed for the maximum words that can be added to that particular field.*/
/*Source http://www.gravityhelp.com/forums/topic/maximum-word-count#post-149331*/
@neilgee
neilgee / checkbox-metabox.php
Created Jul 16, 2017
WordPress Checkbox Metabox in Post Editor Screen - Added as a Plugin
View checkbox-metabox.php
<?php
/*
Plugin Name: Checkbox Meta
Plugin URI: http://wpbeaches.com/
Description: Checkbox Test
Author: Neil Gee
Version: 1.0.0
Author URI: http://wpbeaches.com
License: GPL-2.0+
@neilgee
neilgee / faq.html
Last active Feb 15, 2021
FAQ Page with Show and Hide Questions and Answers
View faq.html
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function() {
$('.faq_question').click(function() {
if ($(this).parent().is('.open')){
$(this).closest('.faq').find('.faq_answer_container').animate({'height':'0'},500);
$(this).closest('.faq').removeClass('open');
@neilgee
neilgee / scripts-ahoy.php
Last active Feb 14, 2021
SwiperJS and ACF Image Gallery Thumbnail Carousel
View scripts-ahoy.php
<?php // <~ don't add me in
add_action( 'wp_enqueue_scripts', 'ls_scripts_styles', 20 );
/**
* SwiperJS Scripts
*/
function ls_scripts_styles() {
wp_enqueue_style( 'swipercssbundle', get_stylesheet_directory_uri() . '/css/swiper-bundle.min.css' , array(), '6.4.11', 'all' );
wp_enqueue_script( 'swiperjsbundle', get_stylesheet_directory_uri() . '/js/swiper-bundle.min.js', array(), '6.4.11', true );
wp_enqueue_script( 'swiperinit', get_stylesheet_directory_uri() . '/js/swiper-bundle-init.js', array( 'swiperjsbundle' ), '1.0.0', true );
@neilgee
neilgee / acf-js.js
Last active Feb 1, 2021
ACF Google Map - Get Directions Link
View acf-js.js
(function($) {
/*
* new_map
*
* This function will render a Google Map onto the selected jQuery element
*
* @type function
* @date 8/11/2013
* @since 4.3.0
@neilgee
neilgee / markup.php
Last active Jan 31, 2021
WordPress Media Uploader For Multiple Images
View markup.php
<?php
/* One of the upload fields as an example */
?>
<tr>
<th><label for="ols_user_meta_image_1"><?php _e( 'OLS Image 1', 'textdomain' ); ?></label></th>
<td>
<!-- Outputs the image after save -->
<img src="<?php echo esc_url( get_the_author_meta( 'ols_user_meta_image_1', $user->ID ) ); ?>" style="width:150px;"><br />
<!-- Outputs the text field and displays the URL of the image retrieved by the media uploader -->
@neilgee
neilgee / flexbox-woo-products.css
Last active Jan 30, 2021
Flexbox on WooCommerce Products
View flexbox-woo-products.css
/* Flexbox on WooCommerce archive products */
.woocommerce .products ul,
.woocommerce ul.products {
display: flex;
flex-flow: row wrap;
}
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
display: flex;
@neilgee
neilgee / carouse-nav-indicators.php
Last active Jan 19, 2021
Bootstrap carousel ACF Repeaters
View carouse-nav-indicators.php
<?php
// *Repeater
// carousel_repeater
// *Sub-Fields
// carousel_image
// carousel_text
// check if the repeater field has rows of data
if( have_rows('carousel_repeater') ):
@neilgee
neilgee / per-kg.php
Created Sep 17, 2017
WooCommerce add a weight amount after the price such as 'per kg'
View per-kg.php
<?php //<~ don't add me in
add_filter( 'woocommerce_get_price_html', 'wb_change_product_html' );
// Change and return $price_html variable using the $price and weight amount
function wb_change_product_html( $price ) {
$price_html = '<span class="amount">' . $price . ' per kg </span>'; // change weight measurement here
return $price_html;
}
@neilgee
neilgee / filter-wc-orders-by-gateway.php
Created Jan 13, 2021 — forked from bekarice/filter-wc-orders-by-gateway.php
Filters WooCommerce Orders by Payment Gateway Used
View filter-wc-orders-by-gateway.php
<?php
/**
* Plugin Name: Filter WooCommerce Orders by Payment Method
* Plugin URI: http://skyverge.com/
* Description: Filters WooCommerce orders by the payment method used :)
* Author: SkyVerge
* Author URI: http://www.skyverge.com/
* Version: 1.0.0
* Text Domain: wc-filter-orders-by-payment
*