Skip to content

Instantly share code, notes, and snippets.

👨‍💻
Learning Node.js deeply

Niels Lange nielslange

View GitHub Profile
View style.css
/* Hide actionbar | NL-12062516-hc */
div#actionbar,
.site-info {
display: none;
}
@nielslange
nielslange / .bash
Created Apr 6, 2019
Regenerate images using WP-CLI
View .bash
wp media regenerate --yes
@nielslange
nielslange / .bash
Created Apr 6, 2019
Regenerate images using WP-CLI
View .bash
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
Created Apr 6, 2019
Overwrite default image sizes.
View functions.php
<?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 Apr 5, 2019
Check if a string only contains letters and numbers
View index.php
<?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 Apr 5, 2019
Check if a string only contains numbers
View index.php
<?php
if ( ctype_digit( $input ) ) {
echo $input . ' only contains numbers.' );
} else {
echo $input . ' does not only contains numbers.' );
}
@nielslange
nielslange / index.php
Last active Apr 5, 2019
Check if a string only contains letters
View index.php
<?php
if ( ctype_alpha( $input ) ) {
echo $input . ' only contains letters.';
} else {
echo $input . ' does not only contains letters.';
}
@nielslange
nielslange / functions.php
Last active Jan 13, 2019
List root and sub categories including their published posts
View functions.php
<?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 Dec 31, 2018
Add HTML comment signature
View function.php
add_action( 'wp_head', 'add_signature' );
function add_signature() {
?>
<!--
_____ _ _ _
| __ \ | | | | | |
| |__) _ __ __ _ _ __ ___ __ _| |_| |__ ___ ___| |__
| ___| '__/ _` | '_ ` _ \ / _` | __| '_ \ / _ / __| '_ \
| | | | | (_| | | | | | | (_| | |_| | | | __\__ | | | |
@nielslange
nielslange / index.html
Last active Mar 28, 2019
Increase and descrease value via button click
View index.html
<input type="number" id="number" value="0" />
<button type="button" onclick="increaseValue()">+</button>
<button type="button" onclick="decreaseValue()">-</button>
<button type="button" onclick="resetValue()">Reset</button>
You can’t perform that action at this time.