Skip to content

Instantly share code, notes, and snippets.

View bi0xid's full-sized avatar
🏠
In Seville

Rafa Poveda bi0xid

🏠
In Seville
View GitHub Profile
@mehrshaddarzi
mehrshaddarzi / page-faculty-staff.php
Created November 11, 2017 19:42 — forked from freerangetech/page-faculty-staff.php
Switch to Blog and WP_Query Example
<?php
function smcm_pull_faculty_from_directory() {
//Get the slug of the calling site... array element [3]
$site_slug = explode ("/", get_site_url());
// blog id of the directory
$blog_id = 7;
@corsonr
corsonr / functions.php
Created September 28, 2016 08:33
Display WooCommerce product variations dropdown select on the shop page
<?php
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {
anonymous
anonymous / gist:80fb467852c2c71a5168
Created January 29, 2016 04:43
Add wp_termmeta table to WordPress database
function hm_add_term_meta_table() {
global $wpdb;
if ( ! current_theme_supports( 'term-meta' ) )
return false;
hm_create_term_meta_table();
$wpdb->tables[] = 'termmeta';
$wpdb->termmeta = $wpdb->prefix . 'termmeta';
}
add_action( 'init', 'hm_add_term_meta_table' );
/**

Git Cheat Sheet

Commands

Getting Started

git init

or

@urre
urre / gist:846b89237da760839b3d
Last active January 5, 2021 21:26
Get network wide recent posts from a WordPress Multisite (1 post from every blog except main site), order by date and only show author once (unique authors). Used on http://vertikals.se/
<?php
// Get all blog ids in network except main site (id 1)
$blogs = $wpdb->get_results("
SELECT blog_id
FROM {$wpdb->blogs}
WHERE site_id = '{$wpdb->siteid}'
AND spam = '0'
AND deleted = '0'
AND archived = '0'
@Richzendy
Richzendy / Add CSS class to children menu item on WordPress
Created August 27, 2014 23:59
Add CSS class to children menu item on WordPress
// Add CSS class to children menu item on WordPress
add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );
function add_menu_parent_class( $items ) {
foreach ( $items as $item ) {
if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
$item->classes[] = 'menu-children-item';
}
}
@jartes
jartes / wc-add-button-cart-item.php
Created March 25, 2014 17:58
WooCommerce - Add "update cart" button on all cart items . Props igmoweb
<?php
function fanatic_add_update_cart_item( $product_quantity, $cart_item_key ) {
global $woocommerce;
$cart = $woocommerce->cart->get_cart();
$product = $cart[ $cart_item_key ]['data'];
$product_id = $product->id;
if ( $product->is_sold_individually() === false ) {
$product_quantity .= '<input type="submit" class="update-qty" name="update_cart" value="'.__( 'Update Cart', 'woocommerce' ).'" />';
}
return $product_quantity;
@jartes
jartes / README.md
Last active September 6, 2016 15:24
WooCommerce - Is out of stock category

WooCommerce - Is out of stock category

Overview

This function checks if all products belonging to a product category or custom taxonomy is out of stock.

This function uses Transients API to cache 1 hour the result for avoiding large amount of querys.

Usage

@claudiosanches
claudiosanches / woocommerce-installments-example.php
Last active October 12, 2022 19:03
WooCommerce - Displays the price in 3 installments without interest.
<?php
/**
* Plugin Name: WooCommerce Installments Example
* Plugin URI: http://claudiosmweb.com/
* Description: Added the price with 3 installments without interest.
* Author: claudiosanches
* Author URI: http://www.claudiosmweb.com/
* Version: 1.0
* License: GPLv2 or later
*/
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: