Skip to content

Instantly share code, notes, and snippets.

View mikeott's full-sized avatar
😀
Greetings programs. See you on the grid.

Michael Ott mikeott

😀
Greetings programs. See you on the grid.
View GitHub Profile
@mikeott
mikeott / verify-recaptcha.html
Last active August 25, 2022 06:14
Verify Recaptcha
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
<form>
<div id="re-captcha"></div>
<input type="submit" value="Submit" id="contactFormSubmit" value="Submit" disabled />
</form>
<script>
var actCallback = function (response) {
$('#contactFormSubmit').prop('disabled', false);
@mikeott
mikeott / acf-return-a-specific-repeater-field-row-value
Last active August 16, 2022 01:11
ACF return a specific repeater field row value
$cast_members = get_field( 'cast_members'); /* The repeater field */
$row = $row[2]; /* The repeater field row number to target (start counting at 0) */
$character = $row['character']; /* The field to get */
echo $character; /* Echo the field */
@mikeott
mikeott / css-clip-image.css
Last active August 16, 2022 01:15
CSS clip image
/* Note: Clip is deprecated and will be replaced by the clip-path in the future. */
#my-div img {
position: absolute;
clip: rect( 0px, 300px, 177px, 0px );
}
@mikeott
mikeott / strip-new-lines-from-string.liquid
Created June 24, 2022 04:50
Shopigy - strip new liness from string
{{ string_with_newlines | strip_newlines }}
@mikeott
mikeott / shopify-add-hero-image-to-page.liquid
Last active June 20, 2022 02:20
Add hero image to shopify page
// Save this to the 'sections' directory...
{% if section.settings.hero_image %}
<img src="{{ section.settings.hero_image | img_url:'master' }}" alt="{{ section.settings.hero_image.alt | escape }}" />
{% endif %}
{% schema %} {
"name": "Hero Image",
"settings": [
{
@mikeott
mikeott / wordpress-nonce-anchor.php
Last active July 29, 2022 07:06
WordPress nonce anchor
<?php
/*
Only allow access to a URL if nonce passed.
Nonce docs: https://codex.wordpress.org/WordPress_Nonces
*/
/* The URL you want to protect */
$the_url = plugins_url() . '/my-plugin/top-secret.php';
?>
@mikeott
mikeott / leaflet-multiple-map-marker-images.php
Created May 11, 2022 07:59
Leaflet map multiple map marker images
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet.fullscreen@1.4.5/Control.FullScreen.js"></script>
<style>.leaflet-control-zoom-fullscreen { background-image: url('<?php echo get_template_directory_uri();?>/images/maps/icon-fullscreen.png');}</style>
<div id='map'></div>
<script type="text/javascript">
$( document ).ready(function() {
var map = new L.Map('map', {
center: [-31.898472745592997, 115.81094863686857],
@mikeott
mikeott / enqueue-jquery.php
Last active May 11, 2022 03:21
Enqueue jQuery
/*
Enqueue jQuery
Uses the WordPress built-on jQuery
*/
function my_jquery_method() {
wp_enqueue_script( 'jquery');
}
add_action( 'wp_enqueue_scripts', 'my_jquery_method' );
@mikeott
mikeott / if-scroll-past-pixels.js
Created May 4, 2022 02:27
If scrolled past number of pixels
$(window).scroll(function() {
if ($(document).scrollTop() > 100) {
$('.header').addClass('scrolled');
}
else {
$('.header').removeClass('scrolled');
}
});
@mikeott
mikeott / woocommerce-list-products-by-tags.php
Last active April 22, 2022 00:45 — forked from corsonr/gist:5933479
List WooCommerce products by tags
<?php
/**
* Plugin Name: WooCommerce - List Products by Tags
* Plugin URI: http://www.remicorson.com/list-woocommerce-products-by-tags/
* Description: List WooCommerce products by tags using a shortcode, ex: [woo_products_by_tags tags="shoes,socks"]
* Version: 1.0
* Author: Remi Corson
* Author URI: http://remicorson.com
* Requires at least: 3.5
* Tested up to: 3.5