Skip to content

Instantly share code, notes, and snippets.

@igorbenic
igorbenic / block-atts.js
Last active June 16, 2022 00:44
How to create a Gutenberg Block for Displaying a Post | https://www.ibenic.com/create-gutenberg-block-displaying-post/
registerBlockType( 'cgb/block-guten-load-post', {
// ...
keywords: [
__( 'my-block — CGB Block' ),
__( 'CGB Example' ),
__( 'create-guten-block' ),
],
attributes: {
content: {
// ==UserScript==
// @name Aliexpress
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://trade.aliexpress.ru/orderList.htm*
// @match https://trade.aliexpress.com/orderList.htm*
// @match https://trade.aliexpress.ru/order_list.htm*
// @match https://trade.aliexpress.com/order_list.htm*
@imath
imath / bp-custom.php
Last active February 3, 2020 17:05
Edit BuddyPress primary nav so that profile primary item is before the activity primary item
<?php
/**
* BuddyPress 2.6.0 introduced a new nav API
* with a Backcompat mechanism. But accessing/editing
* deprecated globals can lead to such problems...
*
* It's too bad Theme designers forget to test betas :)
*/
function strothi_profile_primary_nav_first() {
@danielbachhuber
danielbachhuber / collection-filter.js
Last active June 17, 2024 17:40
Add a custom taxonomy dropdown filter to the WordPress Media Library
(function(){
/**
* Create a new MediaLibraryTaxonomyFilter we later will instantiate
*/
var MediaLibraryTaxonomyFilter = wp.media.view.AttachmentFilters.extend({
id: 'media-attachment-taxonomy-filter',
createFilters: function() {
var filters = {};
// Formats the 'terms' we've included via wp_localize_script()
@shanebp
shanebp / bp-profile-tab-and-subnav.php
Last active June 28, 2023 18:11
BuddyPress add profile tab and subnav
function add_animal_tabs() {
global $bp;
bp_core_new_nav_item( array(
'name' => 'Animals',
'slug' => 'animals',
'parent_url' => $bp->displayed_user->domain,
'parent_slug' => $bp->profile->slug,
'screen_function' => 'animals_screen',
'position' => 200,
@bradp
bradp / gist:8b379e71daa4b6a61d14
Last active August 14, 2023 08:40
Useful SQL Queries
#Get the size of each table, ordered by largest to smallest
SELECT table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "YOU+TABLE+NAME+HERE"
ORDER BY (data_length + index_length) DESC;
#Get the size of the entire DB
SELECT table_schema "DB Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
@galalaly
galalaly / import-variation.php
Created January 13, 2015 23:00
Create WooCommerce variations with PHP
<?php
// In a class constructor
$this->size_tax = wc_attribute_taxonomy_name( 'Size' );
$this->color_tax = wc_attribute_taxonomy_name( 'Color' );
// Insert the main product first
// It will be used as a parent for other variations (think of it as a container)
$product_id = wp_insert_post( array(
@renventura
renventura / gf-create-edd-coupons.php
Created October 4, 2014 03:36
Create randomly generated discount codes for Easy Digital Downloads on Gravity Forms submission
<?php //* Mind this opening php tag and header information below
/*
Plugin Name: Create EDD Discounts with Gravity Forms
Plugin URI: http://engagewp.com/create-random-discount-codes-edd-gravity-forms
Description: Allows discount codes for Easy Digital Downloads to be randomly generated on Gravity Forms submissions. Code credit to David Smith of GravityWiz.com. Modified and put into plugin format by Ren Ventura.
Author: David Smith / Ren Ventura
Version: 1.0
*/
@tjFogarty
tjFogarty / class.vimeothumbnail.php
Last active January 26, 2018 03:12
Get Vimeo thumbnail from video URL
<?php
/**
* Vimeo class to fetch thumbnails
* @example
* $video = new VimeoThumbnail(array(
* 'video_url' => $url
* ));
* echo $video->thumbnail;
*/
@BFTrick
BFTrick / woocommerce-remove-virtual-billing-fields.php
Last active February 19, 2024 17:23
Remove the billing address fields for free virtual orders in WooCommerce
<?php
/**
* Plugin Name: WooCommerce Remove Billing Fields for Free Virtual Products
* Plugin URI: https://gist.github.com/BFTrick/7873168
* Description: Remove the billing address fields for free virtual orders
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 2.0
*
* This program is free software: you can redistribute it and/or modify