Skip to content

Instantly share code, notes, and snippets.

View smeric's full-sized avatar

Sébastien Méric smeric

View GitHub Profile
@smeric
smeric / Wordpress RSS 2.0 image enclosure .php
Last active October 14, 2015 14:48 — forked from supermethod/Wordpress RSS 2.0 image enclosure
How to add post image(s) as enclosure(s) to a wordpress RSS feed item - add to functions.php
<?php
/**
* Add post type images to feed items
*/
add_action('rss2_item', 'add_images_in_feed' );
function add_images_in_feed() {
global $post;
// Thumbnail...
$thumbnail_ID = get_post_thumbnail_id( $post->ID );
@smeric
smeric / attachment.php
Last active August 29, 2015 14:10
WordPress plugin used to allow attachment download with one click.
<?php
/**
* Force attachments download :
*
* In order for this to work, when you insert the file into your post through the media uploader,
* you have to select Post URL rather than File URL in the Link URL field before inserting into your post.
* A link to a filename will follow the browser's preferences, but by linking to the WP post link,
* you can control its behaviour.)
*
* @link https://gist.github.com/smeric/cb4520e848aaa0be703c
@smeric
smeric / gist:0c425adf9e9439e3c076
Last active August 29, 2015 14:09
Redirect WooCommerce customer to profile page after a successful login through wp-login.php
<?php
/**
* Redirect WooCommerce customer to profile page after a successful login through wp-login.php or
* redirect any unauthorised user trying to access any wp-admin files.
*
* @author Sébastien Méric <sebastien.meric@gmail.com>
* @param string $redirect_to URL to redirect to.
* @return string
*/
add_action( 'init', 'woocommerce_custom_redirect_customer_to_account_page' );
@smeric
smeric / woocommerce-custom-taxonomy-product-item.php
Last active August 29, 2015 14:08
Register "item" custom taxonomy for woocommerce products
<?php
/**
* Woocommerce "item" taxonomy
*
* This plugin is a template to add a custom taxonomy to products in woocommerce.
* One should search/replace every "Item" occurence with the taxonomy name.
*
* @link https://gist.github.com/smeric/523c54a16f2ed1870a60
* @since 1.0.0
* @package woocommerce_custom_taxonomy_product_item