Skip to content

Instantly share code, notes, and snippets.

View spyrosvl's full-sized avatar

Spyros Vlachopoulos spyrosvl

View GitHub Profile
@RadGH
RadGH / rs_upload_from_url.php
Last active October 1, 2024 08:07
Upload a file from a URL to the WordPress media gallery. Supports images, PDFs, and other file types.
<?php
/**
* This function uploads a file from a URL to the media library, designed to be placed in your own theme or plugin.
* Metadata will be generated and images will generate thumbnails automatically.
*
* HOW TO USE:
* 1. Add the function below to your theme or plugin
* 2. Call the function and provide the URL to an image or other file.
* 3. If successful, the attachment ID will be returned.
@tripflex
tripflex / functions.php
Last active July 12, 2024 13:20
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback
@mgibbs189
mgibbs189 / test.php
Created October 14, 2015 09:18
FacetWP - index parent terms and child terms in separate facets
<?php
function fwp_index_categories( $params, $class ) {
if ( 'product_cat' == $params['facet_name'] && 0 < (int) $params['depth'] ) {
return false; // skip this term
}
elseif ( 'product_sub_cat' == $params['facet_name'] && 0 == (int) $params['depth'] ) {
return false; // skip this term
}
return $params;
@pietromalerba
pietromalerba / woocommerce-my-account.php
Last active July 13, 2022 18:34 — forked from SiR-DanieL/functions.php
Add custom fields to Woocommerce My Account
// Add VAT and SSN fields in billing address display
add_filter( 'woocommerce_order_formatted_billing_address', 'custom_add_vat_ssn_formatted_billing_address', 10, 2 );
function custom_add_vat_ssn_formatted_billing_address( $fields, $order ) {
$fields['vat'] = $order->billing_vat;
$fields['ssn'] = $order->billing_ssn;
return $fields;
}
add_filter( 'woocommerce_my_account_my_address_formatted_address', 'custom_my_account_my_address_formatted_address', 10, 3 );
@melissacabral
melissacabral / wp-dimox-breadcrumbs.php
Last active February 17, 2022 09:13
breadcrumbs - place in functions.php and call in your theme with dimox_breadcrumbs() [Source](http://dimox.net/wordpress-breadcrumbs-without-a-plugin/)
<?php
/**
* Dimox Breadcrumbs
* http://dimox.net/wordpress-breadcrumbs-without-a-plugin/
* Since ver 1.0
* Add this to any template file by calling dimox_breadcrumbs()
* Changes: MC added taxonomy support
*/
function dimox_breadcrumbs(){
/* === OPTIONS === */