Skip to content

Instantly share code, notes, and snippets.

View nielslange's full-sized avatar
👨‍💻
Moving bits and bytes around the globe

Niels Lange nielslange

👨‍💻
Moving bits and bytes around the globe
View GitHub Profile
@mikejolley
mikejolley / test-plugin.php
Last active November 4, 2024 01:41
WooCommerce Block Checkout Example to listen for payment method change and add a fee server side
<?php
// Reset payment method in session
add_action('woocommerce_checkout_init', function(){
if( ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || !WC() || !WC()->session || is_admin() ) {
return;
}
// Get first payment method and store it
// Since payment method selection is not persistent, on page load always the first one will be selected
@hafizrahman
hafizrahman / add-gutenberg-class.php
Last active April 10, 2019 05:00
WordPress: Add body class (for single post template) or post class (for blog/archive pages) "made-with-gutenberg" for posts/pages created with Gutenberg editor.
// add class to body class on single post template
function themeprefix_body_class_blocks( $classes ) {
if ( is_singular() && has_blocks() ) {
$classes[] = 'made-with-gutenberg';
}
return $classes;
}
add_filter( 'body_class', 'themeprefix_body_class_blocks' );
@ahmadawais
ahmadawais / flywheel-local-xdebug-vscode.md
Last active September 5, 2024 01:57
Debug WordPress with Visual Studio Code | VSCode WordPress Debug Setup | WordPress xDebug Setup for Local by FlyWheel with VSCode | Part of the VSCode Learning Course → https://VSCode.pro

VSCode WordPress Debugging Setup: WordPress Xdebug Setup for Local by FlyWheel with VSCode


Consider supporting my work by purchasing the course this tutorial is a part of i.e. VSCode Power User

🚅 TL;DR

  • Make sure your Local by FlyWheel WordPress install is a custom install
@lirantal
lirantal / terminal-with-powerline.sh
Last active December 2, 2022 09:19
Hyper terminal + Powerline 9k terminal theme for oh-my-zsh
# Use hyper.is or iTerm2 as terminal emulators
# Install ohmyzsh
# https://github.com/robbyrussell/oh-my-zsh
# Copy over configs from ~/.bash_profile
# For example, it may have the nvm setup or any aliases like exa=ls and cat=bat
# ~/.hyper.js configuration:
copyOnSelect: true
@itzikbenh
itzikbenh / home.php
Last active April 5, 2020 09:30
Very simple infinite scroll in WordPress.
//Just a random file for loading your posts to see that the infinite scroll works.
<?php get_header(); ?>
<div class="col-md-6 col-md-offset-3">
<div class="post-container">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="page-header post">
<h1><?php the_title(); ?></h1>
<p><?php the_excerpt(); ?></p>
</div>
<?php
//* Single Portfolio
//* Enlever sidebar classique
remove_action( 'genesis_sidebar', 'genesis_do_sidebar');
add_action( 'genesis_sidebar', 'gn_sidebar');
function gn_sidebar() {
global $post;
//** check ACF
@nielslange
nielslange / .htaccess
Last active March 28, 2019 03:58 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/