Skip to content

Instantly share code, notes, and snippets.

View mikeoberdick's full-sized avatar

Mike Oberdick mikeoberdick

View GitHub Profile
@mikeoberdick
mikeoberdick / simple_form_validation.php
Created August 28, 2024 22:26
Simple form validation where inputs are checked on 'keyup' for value
$("form > input").keyup(function () {
var e = !1;
$("form > input").each(function () {
"" == $(this).val() && (e = !0);
}),
e ? $("#submit").attr("disabled", "disabled") : $("#submit").removeAttr("disabled");
});
@mikeoberdick
mikeoberdick / set_cookie_for_same_session_page_loads.js
Created August 21, 2024 12:31
Remove popup for same session page loads using a cookie
@mikeoberdick
mikeoberdick / remove_popup_for_thirty_days_with_cookie.js
Created August 21, 2024 12:28
Set cookie to remove cookie notification popup for 30 days
@mikeoberdick
mikeoberdick / slick-slider-part-of-next-slide.css
Created August 16, 2024 15:57
Slick slider spacing to show part of the next slide on the right hand side.
.slick-list {
padding: 0 20% 0 0 !important;
}
@mikeoberdick
mikeoberdick / custom_taxonomy_terms_in_loop.php
Last active July 13, 2024 10:18
Show the custom taxonomy terms of a custom post type within the loop.
<?php
the_terms( get_the_ID(), 'event-type', '<ul class="event-types"><li>', '</li><li>', '</li></ul>' );
?>
<?php
//save them to a variable
<?php $terms = wp_get_post_terms(get_the_ID(), 'event-type');
//echo them out
if ( ! empty( $event_terms ) && ! is_wp_error( $event_terms ) ) :
@mikeoberdick
mikeoberdick / gist:26552b9d6fb499cbb4cfa008b09decec
Created May 30, 2024 14:35
Creating symlink using mklink for node_modules folder
mklink /J "C:\Websites\Pixelstrike Creative\Peak Season Workforce\wp-content\themes\psc-starter\node_modules" C:\Websites\node_modules
@mikeoberdick
mikeoberdick / bootstrap-dropdown-menu-offset.js
Created May 5, 2024 15:52
Bootstrap 5 .dropdown-menu data-offset for drop down menus under nav links that use underlines on hover
//ADD DATA OFFSET TO THE MAIN NAV DROPDOWN MENU
$(".dropdown-menu").attr('data-bs-offset', '10,20');
@mikeoberdick
mikeoberdick / no-page-reload-on-same-page-jump-link.js
Created May 5, 2024 15:51
Don't reload page when clicking a jump link from nav menu that references a place on the same page
@mikeoberdick
mikeoberdick / url-based-accordion.js
Created April 5, 2024 10:09
Open up a bootstrap accordion/collapse using attribute from url following # symbol
if (window.location.href.indexOf("requirements") > -1 && window.location.href.indexOf("#") > -1) {
//get the text after the #
var tab = window.location.href.split('#')[1];
//if text is highResidency
if (tab == 'highResidency') {
$('#collapse-content-0').show();
} else {
$('#collapse-content-1').show();
}
}
@mikeoberdick
mikeoberdick / filter_archive_query.php
Created July 6, 2023 12:07
Filter the query on the events archive to only show upcoming events
function show_upcoming_events( $query ) {
if( is_admin() ) {
return $query;
}
if ( ( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'event' ) ) {
$today = date('Y-m-d H:i:s', strtotime("-1 days"));
$meta_query = array(