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 / woocommerce-custom-extra-tab.php
Last active Jan 21, 2019
Adds a metabox to define a custom tab title and content on woocommerce product pages.
View woocommerce-custom-extra-tab.php
<?php
/**
* Woocommerce custom extra tab
*
* Adds a metabox to define a custom tab label and content on woocommerce product pages. Also remove predifined
* description tab title so we can define our own directly inside tab content.
*
* @link https://gist.github.com/smeric/ff09b2f993dc8378a04a
* @version 1.0.1
* @package woocommerce_custom_extra_tab
@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
@smeric
smeric / yoast-seo-breadcrumbs-for-woocommerce.php
Last active Jan 11, 2018
Add WooCommerce endpoints to Yoast SEO breadcrumbs
View yoast-seo-breadcrumbs-for-woocommerce.php
<?php
/**
* Add WooCommerce endpoints to Yoast SEO breadcrumbs
*
* @link https://gist.github.com/smeric/b544f154ea752e47d0427f3e1ae901b5
* @version 1.0.0
* @package yoast_seo_breadcrumbs_for_woocommerce_endpoints
*
* @wordpress-plugin
* Plugin Name: Yoast SEO breadcrumbs addon
@smeric
smeric / nemus-slider.php
Last active Dec 18, 2017
WordPress Nemus Slider : PHP Fatal error: Call to a member function add_cap() on a non-object in /PATH/TO/SITE/FOLDER/wp-content/plugins/nemus-slider/nemus-slider.php on line 97
View nemus-slider.php
<?php
/*
* Nemus Slider
* https://wordpress.org/plugins/nemus-slider/
* nemus-slider.php line 75
* Reported issue : https://wordpress.org/support/topic/php-fatal-error-call-to-a-member-function-add_cap-on-a-non-object/
*/
//Capabilities
function nemus_slider_add_caps_to_admin() {
@smeric
smeric / extend-woocommerce-memberships-period.php
Created Oct 6, 2016
WooCommerce Memberships : allow renewal for active memberships even before membership expiration.
View extend-woocommerce-memberships-period.php
<?php
/**
* Allow membership renewal for active memberships
*/
add_filter( 'wc_memberships_valid_membership_statuses_for_renewal', 'my_valid_membership_statuses_for_renewal' );
function my_valid_membership_statuses_for_renewal( $statuses = array() ) {
$statuses[] = 'active';
return $statuses;
}
@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 / html-tags-shortcode.php
Created Oct 7, 2017
WordPress HTML tags shortcode. So you may add HTML to escaped form fields values :)
View html-tags-shortcode.php
<?php
/**
* HTML tags shortcode
*
* Usage: [html tag="span" class="myClass" id="firstSpan"]Lorem ipsum[html tag='br']dolor sit amet[/html]
*/
function html_tag_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'tag' => 'div',
'id' => '',
@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;
View Blockstack ID
Verifying that "sebmeric.id" is my Blockstack ID. https://onename.com/sebmeric
@smeric
smeric / woocommerce-overwrite-default-thumbnail-sizes.php
Created Oct 11, 2016
Overwrite default thumbnails sizes after WooCommerce installation
View woocommerce-overwrite-default-thumbnail-sizes.php
<?php
add_action( 'after_setup_theme', 'mytheme_woocommerce_set_image_dimensions' );
function mytheme_woocommerce_set_image_dimensions() {
// Do not set sizes multiple times
if ( ! get_option( 'mytheme_shop_image_sizes_set' ) ) {
$catalog = array(
'width' => '768', // px
'height' => '', // px
'crop' => 0 // no-crop
);
You can’t perform that action at this time.