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 / 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 / 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/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://unpkg.com/[email protected]/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 / 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 / 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 / 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 / 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 / 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 / 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 / additional-user-profile-fields
Created September 24, 2022 23:03
WordPress additional user profile fields
/* Additional user profile fields */
function extra_profile_details( $methods ) {
$methods['new_email'] = __( "New email", "wproject" );
return $methods;
}
add_filter('user_contactmethods','extra_profile_details',10,1);
@mikeott
mikeott / force-16-9-css-attribute.js
Last active November 11, 2022 06:02
Force 16 x 9 CSS attribute
$( document ).ready(function() {
var width = $('iframe').width();
$('iframe').css({
'width': width,
'height': width*(9/16)
});
});