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 July 16, 2024 01:30
Git CLI Cheatsheet
@plentz
plentz / nginx.conf
Last active July 27, 2024 16:11
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
@Adirael
Adirael / fix-wordpress-permissions.sh
Created August 17, 2012 23:16
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory