Skip to content

Instantly share code, notes, and snippets.

View mikeoberdick's full-sized avatar

Mike Oberdick mikeoberdick

View GitHub Profile
@mikeoberdick
mikeoberdick / create-a-slug-.php
Created March 7, 2025 22:11
Create a slug using a function to use within a php template
//Create a slug
function createSlug($text) {
// Convert the string to lowercase
$lowercaseText = strtolower($text);
// Replace spaces with hyphens
$slug = preg_replace('/[^a-zA-Z0-9]/', '-', $lowercaseText);
return $slug;
}
@mikeoberdick
mikeoberdick / create_a_slug.php
Created January 10, 2025 21:28
Function to create a slug from a string
//Create a slug
function createSlug($text) {
// Convert the string to lowercase
$lowercaseText = strtolower($text);
// Replace non-number/letters with hyphens
$slug = preg_replace('/[^a-zA-Z0-9]/', '-', $lowercaseText);
return $slug;
}
@mikeoberdick
mikeoberdick / alt_text_to_background_images.php
Created December 17, 2024 00:09
Adding alt text to background images using an aria-label and role = "img"
<div class="outer-wrapper bg-image" style = "background-image: url('<?php echo $sectionOne['image']['url']; ?>');" role = "img" aria-label = "<?php echo $sectionOne['image']['alt']; ?>"></div><!-- .outer-wrapper -->
@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');