Skip to content

Instantly share code, notes, and snippets.

View primedime's full-sized avatar

Roy Jossfolk primedime

View GitHub Profile
@zackkatz
zackkatz / gf-number-field-integers.php
Created June 20, 2019 17:27
Only allow integers (whole numbers, including negative values) in Gravity Forms Number field
<?php
/**
* Force number fields to increment by 1
*/
add_filter( 'gform_field_content', function ( $field_content, $field ) {
if ( 'number' !== $field->type ) {
return $field_content;
}
@rileyelliott
rileyelliott / .env
Created June 11, 2019 15:34
Wordpress DECHO
DEBUG_URL=whatever.test
@pento
pento / php-block.js
Last active February 29, 2024 01:31
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@mikaelz
mikaelz / delete-orphan.sql
Created August 16, 2017 13:59
Delete orphan postmeta and attachment in WordPress database
-- Delete orphan postmeta
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts p ON pm.post_id = p.ID
WHERE p.ID IS NULL
;
-- Delete orphan attachment
DELETE p1
FROM wp_posts p1
@stuartduff
stuartduff / wc-exclude-product-category-from-shop-page.php
Last active May 6, 2022 00:20
This snippet will exclude all products from any categories which you choose from displaying on the WooCommerce Shop page.
function custom_pre_get_posts_query( $q ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'clothing' ), // Don't display products in the clothing category on the shop page.
'operator' => 'NOT IN'
);
@raynov
raynov / nav-menu-exporter-importer.php
Last active August 30, 2017 13:39 — forked from hissy/nav-menu-exporter-importer.php
[WordPress Plugin] Nav Menu Exporter and Importer / Export and Import nav menus. Requires WordPress Importer plugin.
<?php
/*
Plugin Name: Nav Menu Exporter and Importer
Description: Export and Import nav menus. Requires WordPress Importer plugin
Author: hissy, megumi themes
Version: 0.1
Text Domain: nav-menu-exporter-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
add_filter( 'woocommerce_ship_to_different_address_checked', '__return_false' );
@hofmannsven
hofmannsven / README.md
Last active April 19, 2024 13:17
Git CLI Cheatsheet
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………