Skip to content

Instantly share code, notes, and snippets.

View gerharddt's full-sized avatar

Gerhard gerharddt

View GitHub Profile
<?php
// change the checkout city field to a dropdown field
function nfh_change_city_to_dropdown( $fields ) {
$cities = array(
'',
'Nairobi',
'Nakuru',
'Eldorate',
'Mombasa',
@gerharddt
gerharddt / gist:08e1ee9338d47cee9ca9e2cab3426360
Created September 7, 2020 09:00
WordPress/ACF: Show hidden custom fields
add_filter('acf/settings/remove_wp_meta_box', '__return_false');
@gerharddt
gerharddt / gist:0286c5aef0cb5771c382df6aac0b35ea
Created September 7, 2020 08:59
Wordpress: Require featured image before publish post
//* From http://wpsnipp.com/index.php/functions-php/require-featured-image-can-publish-post/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+wpsnipp+%28wpsnipp+-+wordpress+code+snippets%29
add_action('save_post', 'wpds_check_thumbnail');
add_action('admin_notices', 'wpds_thumbnail_error');
function wpds_check_thumbnail($post_id) {
// change to any custom post type
if(get_post_type($post_id) != 'post')
return;
if ( !has_post_thumbnail( $post_id ) ) {
// set a transient to show the users an admin message
set_transient( "has_post_thumbnail", "no" );
@gerharddt
gerharddt / gist:8ade1bbc76c2521e3e35b87dc5ca7e80
Created September 7, 2020 08:58
PHP: Nice human readable big numbers
function bd_nice_number($n) {
// first strip any formatting;
$n = (0+str_replace(",","",$n));
// is this a number?
if(!is_numeric($n)) return false;
// now filter it;
if($n>1000000000000) return round(($n/1000000000000),1).' trillion';
else if($n>1000000000) return round(($n/1000000000),1).' billion';
// add images to admin post object
function my_post_object_result( $title, $post, $field, $post_id ) {
if ($post->post_type == 'product') {
global $nf;
$title = '<div class="prodi" style="background-image: url(' . $nf->image(wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ), 140, 140) . ');"></div>' . $title;
$title = '<div class="prodc">' . $title . '</div>';
@gerharddt
gerharddt / SassMeister-input.scss
Created January 13, 2015 16:03
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
// and you can now also
.wrapper {
color: #000;