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 / wp_is_mobile.php
Last active July 29, 2022 07:39
WordPress: If WordPress is mobile
<?php if ( wp_is_mobile() ) {
// Do something for mobile devices
} else {
// Do something for desktop
}
@mikeott
mikeott / close-yoast-metabox.php
Last active July 11, 2023 14:40
Force the Yoast metabox to be closed by default.
/* Close the Yoast metabox */
function shut_your_mouth_yoast() {
echo '<script>jQuery( document ).ready(function() { jQuery(".yoast.wpseo-metabox").addClass("closed"); });</script>';
}
add_action( 'admin_head', 'shut_your_mouth_yoast' );
jQuery('.my-button').click(function() {
if(jQuery(this).prop('checked')) {
jQuery('.my-checkbox').removeAttr('disabled');
} else {
jQuery('.my-checkbox').attr('disabled', 'disabled');
}
});
@mikeott
mikeott / waypoint.js
Last active March 29, 2022 06:14
Waypoints control
<script>
// Actual waypoint script. Save into waypoint.js
/*!
Waypoints - 4.0.0
Copyright © 2011-2015 Caleb Troughton
Licensed under the MIT license.
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
*/
! function() {
@mikeott
mikeott / text-gradient-fill.html
Last active April 21, 2022 08:22
Text gradient fill
<h1>
<span>This is a test</span>
</h1>
<style>
h1 span {
-webkit-text-fill-color: transparent; /* Chrome Only */
@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
@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 / 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/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 / 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';
?>