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 / scroll-down-page-on-page-load.js
Last active July 29, 2022 07:52
Scroll down page on page load
/* jQuery */
$( document ).ready(function() {
window.scroll(0,400);
});
@mikeott
mikeott / add-custom-radio-buttons-to-woo-checkout.php
Last active April 1, 2024 13:42
Add custom radio buttons to Woo checkout
<?php
/*
Add custom delivery radio buttons to checkout.
Requires WooCommerce v3+
Add your radio buttons.
Remove the 'required' attribute if these are to be optional.
*/
add_action( 'woocommerce_review_order_before_payment', 'display_extra_fields_after_billing_address' , 10, 1 );
function display_extra_fields_after_billing_address () { ?>
@mikeott
mikeott / wordpres-custom-css.php
Last active July 29, 2022 07:57
WordPress: include custom CSS file if page slug matches CSS file name.
/* Check if css file of slug name exists and if it does, include stylesheet for that slug */
function check_for_css() {
global $post;
$post_slug = $post->post_name;
$filename = get_template_directory() . '/css/' . $post_slug . '.css';
if (file_exists($filename)) {
echo '<link rel="stylesheet" id="' . $post_slug . '-css" href="' . get_template_directory_uri() . '/css/' . $post_slug . '.css" type="text/css" media="all" />';
}
@mikeott
mikeott / wordpress-plugin-css-cache-buster.php
Last active March 14, 2019 03:43
WordPress plugin CSS cache buster (based on plugin version number)
/*
Add custom stylesheet into plugin admin.
This method appends the plugin version number to the stylesheet for easy CSS cache busting.
If your plugin is at version 1.0 the styesheet URL will look like this:
https://example.com/wp-content/plugins/your-plugin/css/your-plugin-style.css?ver=1.0
Any time you update your plugin version number, the query string value will match it.
*/
function your_plugin_style() {
@mikeott
mikeott / fix-double-lines-issue.txt
Last active July 29, 2022 08:01
Fix double lines issue using a regular expression
Using a regx search, search your file for...
[\r\n]{2,}
...and replace with ...
\n