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 / add-body-class-to-admin.php
Created November 30, 2022 00:52
Add body class to admin
/* Add body class to admin */
add_filter( 'admin_body_class', 'my_body_class' );
function my_body_class( $class ) {
$class .= ' stormbox-plugin ';
return $class;
}
@mikeott
mikeott / shortcode-with-attributes.php
Created November 24, 2022 07:51
Shortcode with attributes
<?php /*
Shortcode CTA button for use in the editor.
Example usage:
[button href="https://www.google.com.au" target="_blank"]Visit Google[/button]
*/
function button( $atts, $content = null ) {
$a = shortcode_atts( array(
'class' => 'button-link external',
'href' => '#',
@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)
});
});
@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 / 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';
?>