Skip to content

Instantly share code, notes, and snippets.

Sébastien Méric smeric

Block or report user

Report or block smeric

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@smeric
smeric / add-roles-to-body.php
Created Feb 19, 2016
Add user roles as classes to body tag in front and backend.
View add-roles-to-body.php
<?php
/**
* Add user roles as classes to body tag in front and backend.
*/
add_filter( 'body_class','add_roles_to_body' );
add_filter( 'admin_body_class', 'add_roles_to_body' );
function add_roles_to_body( $classes ) {
global $current_user;
foreach ( $current_user->roles as $user_role ) {
@smeric
smeric / gform-generate-username.php
Created Feb 12, 2016
Username auto generation for Gravity Form User Registration Add-on
View gform-generate-username.php
<?php
/**
* Username auto generation for Gravity Form User Registration Add-on
*
* see https://www.gravityhelp.com/documentation/article/gform_username/
*/
add_filter( 'gform_username', 'auto_username', 10, 4 );
function auto_username( $username, $feed, $form, $entry ) {
//$username = strtolower( rgar( $entry, '2.3' ) . rgar( $entry, '2.6' ) );
@smeric
smeric / woocommerce-membership-post-excerpt.php
Created Nov 23, 2015
WooCommerce membership custom post excerpt. Instead of using the excerpt this will display the begining of a post for non members.
View woocommerce-membership-post-excerpt.php
<?php
/**
* Plugin Name: WooCommerce membership custom post excerpt
* Description: Instead of using the excerpt this will display the begining of a post for non members.
* Version: 0.1
* Author: Sébastien Méric <sebastien.meric@gmail.com>
* Author URI: http://www.sebastien-meric.com/
**/
defined( 'ABSPATH' ) OR exit;
@smeric
smeric / aggregate-feed.php
Created Nov 12, 2015 — forked from smajda/aggregate-feed.php
Merge multiple RSS feeds with SimplePie
View aggregate-feed.php
<?php
/* Merge multiple RSS feeds with SimplePie
*
* Just modify the path to SimplePie and
* modify the $feeds array with the feeds you want
*
* You should probably also change the channel title, link and description,
* plus I added a CC license you may not want
*
* Help from: http://www.webmaster-source.com/2007/08/06/merging-rss-feeds-with-simplepie/
View smooth-scroll.js
/**
* Smooth scroll :
* <a href="#top" class="go-top">Top</a>
* $( '.go-top' ).click( function( e ){ e.preventDefault(); $( this ).autoscroll( $( this ).attr( 'href' ) ); });
**/
( function( $ ) {
$.fn.autoscroll = function( selector ) {
$( 'html,body' ).animate({
scrollTop: $( selector ).offset().top
}, 200);
@smeric
smeric / add2any_custom_js.php
Last active Oct 30, 2015
WordPress AddToAny custom script to : push shared data to datalayer for GTM, re-shape title to remove special characters & use shortlink for Twitter
View add2any_custom_js.php
<?php
/**
* AddToAny : custom script inserted into the document head
*
* Push shared data to datalayer for GTM
* Re-shape title to remove special characters
* Use shortlink for Twitter
*
* see https://www.addtoany.com/ext/google_analytics/
* see https://www.addtoany.com/buttons/customize/wordpress/events
@smeric
smeric / Wordpress RSS 2.0 image enclosure .php
Last active Oct 14, 2015 — 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
View Wordpress RSS 2.0 image enclosure .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 / woocommerce-add-to-cart-before-applying-coupon.php
Last active Jul 23, 2018
Made to be used with the "Smart Coupons" WooCommerce extention. If we apply coupon from url and the coupon is dedicated to a specific product, the coupon is not applied if the product is not already in cart. So, before applying the coupon we add this product to cart.
View woocommerce-add-to-cart-before-applying-coupon.php
<?php
/**
* Add to cart before applying coupon
*
* Made to be used with the "Smart Coupons" WooCommerce extention.
* If we apply coupon from url and the coupon is dedicated to a specific product, the coupon is not applied if
* the product is not already in cart. So, before applying the coupon we add this product to cart.
*
* @link
* @version 1.0.1
View plugin-name include class-plugin-name-loader.php
<?php
/**
* Register all actions, filters and shortcodes for the plugin
*
* @link http://example.com
* @since 1.0.0
*
* @package Plugin_Name
* @subpackage Plugin_Name/includes
@smeric
smeric / remove-old-slugs-redirects.php
Last active Oct 16, 2015
WordPress plugin. Removes selected old slugs/permalinks from database.
View remove-old-slugs-redirects.php
<?php
/**
* Remove old slugs redirects.
*
* Removes selected old slugs/permalinks from database.
*
* @package WordPress_Remove_Old_Slugs_Redirects
* @author Sébastien Méric <sebastien.meric@gmail.com>
* @credit Algoritmika Ltd. <http://www.algoritmika.com>
* @license GPL-2.0+
You can’t perform that action at this time.