Skip to content

Instantly share code, notes, and snippets.

@carlodaniele
carlodaniele / media-hacks.php
Last active March 28, 2024 20:19
An example WP plugin which adds functionalities to the WordPress Media Library
<?php
/**
* @package Media_hacks
* @version 1.0
*/
/*
Plugin Name: Media hacks
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
@mikaelz
mikaelz / delete-all-woocommerce-products.php
Last active September 4, 2024 13:39
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
@qutek
qutek / woocommerce-ajax.php
Last active May 27, 2024 16:04
[Wordpress] [Woocommerce] WooCommerce Ajax Handlers
<?php
/**
* WooCommerce Ajax Handlers
*
* Handles AJAX requests via wp_ajax hook (both admin and front-end events)
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/** Frontend AJAX events **************************************************/
@JosefJezek
JosefJezek / wp-plugin-periods-in-title.php
Created July 17, 2014 08:30
Wordpress Periods / Dots in Title / Slug / URL
<?php
/*
Plugin Name: Periods in Title
Version: 1.0
Description: Allows periods to appear in post/category URIs
Author: Mark Jaquith
Plugin URI: http://txfx.net/code/wordpress/periods-in-titles/
Author URI: http://txfx.net/
*/
@ChromeOrange
ChromeOrange / functions.php
Created August 31, 2012 12:20
Change Single Product Tab Titles and Headings
<?php
/**
* Tab Title filters do not work with WooCommerce 1.6.5.1 or lower
* Please download this zip file http://cl.ly/2Y3S3D3M3C23 , extract the 3 files and copy them to :
* wp-content/themes/YOUR_THEME/woocommerce/single-product/tabs/
**/
add_filter ( 'woocommerce_product_description_tab_title', 'custom_product_description_tab_title' ) ;
function custom_product_description_tab_title() {
@bueltge
bueltge / post-process.php
Created June 24, 2011 21:08
WordPress Custom Post Type: Insert post via Frontend
<?php
/**
* post-process.php
* make sure to include post-process.php in your functions.php. Use this in functions.php:
*
* get_template_part('post-process');
*
*/
function do_insert() {
if( 'POST' == $_SERVER['REQUEST_METHOD']