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
@nielslange
nielslange / .htaccess
Created April 25, 2019 12:03
Redirect www to non-www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
@nielslange
nielslange / style.css
Created April 14, 2019 06:53
Hide actionbar
/* Hide actionbar | NL-12062516-hc */
div#actionbar,
.site-info {
display: none;
}
@nielslange
nielslange / .bash
Created April 6, 2019 09:38
Regenerate images using WP-CLI
wp media regenerate --yes
@nielslange
nielslange / .bash
Created April 6, 2019 09:37
Regenerate images using WP-CLI
wp media regenerate --image_size=course_archive_thumbnail --yes
wp media regenerate --image_size=course_single_thumbnail --yes
wp media regenerate --image_size=lesson_archive_thumbnail --yes
wp media regenerate --image_size=lesson_single_thumbnail --yes
wp media regenerate --image_size=portfolio_horizontal --yes
wp media regenerate --image_size=portfolio_slider --yes
wp media regenerate --image_size=portfolio_vertical --yes
wp media regenerate --image_size=shop_catalog --yes
wp media regenerate --image_size=shop_thumbnail --yes
wp media regenerate --image_size=woocommerce_gallery_thumbnail --yes
@nielslange
nielslange / functions.php
Last active September 24, 2019 10:29
Overwrite default image sizes.
<?php
// Overwrite default image sizes.
add_action('init', 'smntcs_remove_image_sizes');
function smntcs_remove_image_sizes() {
add_image_size( 'course_archive_thumbnail', 0 );
add_image_size( 'course_single_thumbnail', 0 );
add_image_size( 'lesson_archive_thumbnail', 0 );
add_image_size( 'lesson_single_thumbnail', 0 );
add_image_size( 'portfolio_horizontal', 0 );
add_image_size( 'portfolio_slider', 0 );
@nielslange
nielslange / index.php
Created April 5, 2019 15:59
Check if a string only contains letters and numbers
<?php
if ( ctype_alnum( $input ) ) {
echo $input . ' only contains letters and numbers.';
} else {
echo $input . ' does not only contains letters and numbers.';
}
@nielslange
nielslange / index.php
Created April 5, 2019 15:58
Check if a string only contains numbers
<?php
if ( ctype_digit( $input ) ) {
echo $input . ' only contains numbers.' );
} else {
echo $input . ' does not only contains numbers.' );
}
@nielslange
nielslange / index.php
Last active April 5, 2019 15:56
Check if a string only contains letters
<?php
if ( ctype_alpha( $input ) ) {
echo $input . ' only contains letters.';
} else {
echo $input . ' does not only contains letters.';
}
@nielslange
nielslange / functions.php
Last active January 13, 2019 10:39
List root and sub categories including their published posts
<?php
$post_type = 'products';
$taxonomy = 'products-category';
// Fetch root categories
$root_cat_args = array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
'parent' => 0,
@nielslange
nielslange / function.php
Last active December 31, 2018 02:52
Add HTML comment signature
add_action( 'wp_head', 'add_signature' );
function add_signature() {
?>
<!--
_____ _ _ _
| __ \ | | | | | |
| |__) _ __ __ _ _ __ ___ __ _| |_| |__ ___ ___| |__
| ___| '__/ _` | '_ ` _ \ / _` | __| '_ \ / _ / __| '_ \
| | | | | (_| | | | | | | (_| | |_| | | | __\__ | | | |