Skip to content

Instantly share code, notes, and snippets.

View bjornpatje's full-sized avatar

Bjorn bjornpatje

  • Rubberplants | Digital Agency
  • Breda, Netherlands
View GitHub Profile
@bjornpatje
bjornpatje / WCAdminLastOrderNote.php
Last active July 19, 2022 13:19
Add note to Admin mail with latest customer order ID
<?php
add_action( 'woocommerce_email_order_details', 'las_order_email_order_details', 10, 4 );
function las_order_email_order_details( $order, $sent_to_admin, $plain_text, $email ) {
if($sent_to_admin){
$order_statuses = array('wc-on-hold', 'wc-processing', 'wc-completed');
$customer_user_id = get_current_user_id();
$customer_orders = wc_get_orders( array(
'meta_key' => '_customer_user',
'meta_value' => $customer_user_id,
'post_status' => $order_statuses,
@bjornpatje
bjornpatje / script.js
Last active June 10, 2021 09:22
Typewriter Effect
<script type="text/javascript">
var TxtRotate = function(el, toRotate, period) {
this.toRotate = toRotate;
this.el = el;
this.loopNum = 0;
this.period = parseInt(period, 10) || 2000;
this.txt = '';
this.tick();
this.isDeleting = false;
};
@bjornpatje
bjornpatje / horizontal-scroll-script.html
Created July 19, 2022 13:13
Horizontal Scroll with GSAP
<!-- HORIZONTAL SCROLL -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/ScrollTrigger.min.js"></script>
<script type="text/javascript">
if(jQuery('.page-id-735')){
gsap.registerPlugin(ScrollTrigger);
var allSections = jQuery('.horizontal-section');
allSections.wrapAll('<div class="horizontal-container"/>');
@bjornpatje
bjornpatje / day-nite-switch-script.html
Created July 19, 2022 13:15
Change content depending on time
<script>
var ochtend = jQuery(".hero-ochtend");
var middag = jQuery(".hero-middag");
var avond = jQuery(".hero-avond");
var d = new Date();
var n = d.getHours();
if (n > 0 && n < 12){
jQuery(ochtend).show();
jQuery(middag).hide();
jQuery(avond).hide();
@bjornpatje
bjornpatje / whitespace-fix-function.php
Created July 19, 2022 13:17
Whitespace fix WordPress
<?php
function ___wejns_wp_whitespace_fix($input) {
$allowed = false;
$found = false;
foreach (headers_list() as $header) {
if (preg_match("/^content-type:\\s+(text\\/|application\\/((xhtml|atom|rss)\\+xml|xml))/i", $header)) {
$allowed = true;
}
if (preg_match("/^content-type:\\s+/i", $header)) {
$found = true;
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
<script type="text/javascript">
jQuery(document).ready(function() {
// The button
jQuery('<span class="toggle">More</span>').appendTo('#shop-sidebar .product-categories, #shop-sidebar .woocommerce-widget-layered-nav-list');
// Hide categories when more than 5
jQuery("#shop-sidebar .product-categories li").slice(5).hide();
// Hide attribute filter options when more than 5
@bjornpatje
bjornpatje / change-image-hover.css
Created July 28, 2022 13:37
Change image on hover Flatsome
.changeable .bg-loaded{
transition: all 0.2s ease-in-out;
transition-delay: 150ms;
}
<?php
// Add attribute images on shop page with products
function display_attribute_images() {
global $product;
$attributes = $product->get_attributes();
echo '<div class="attribute-image-wrapper" style="display:flex;flex-direction:row;justify-content:center;">';
foreach ( $attributes as $attribute ) {
$name = $attribute['name'];