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 / sanitize-filename.php
Last active July 15, 2016 23:17 — forked from herewithme/sanitize-filename.php
WordPress - No french punctuation and accents for filename
<?php
/*
Plugin Name: No french punctuation and accents for filename
Description: Remove all french punctuation and accents from the filename of upload for client limitation (Safari Mac/IOS)
Plugin URI: http://www.beapi.fr
Version: 1.0
Author: BeAPI
Author URI: http://www.beapi.fr
This program is free software; you can redistribute it and/or
@smeric
smeric / automatically-disable-content-access.php
Last active September 9, 2016 15:30
Make Woocommerce Membership public content go private after a certain amount of time.
<?php
/*
To allow temporary access to content with Woocommerce Membership,
you have to check this checkbox : "Check this box if you want to
force the content to be public regardless of any restriction rules
that may apply now or in the future."
Here is a way to make this access temporary without having to edit
you post to uncheck the checkbox each and every day on each new publicly
released content. Let the WordPress cron job uncheck it for you :)
@smeric
smeric / yoast-seo-social-images-sizes.php
Created October 11, 2016 13:36
Overwrite Yoast SEO Facebook & Twitter sharing images declaration with a custom one.
<?php
/**
* Std image size for social sharing.
**/
add_action( 'after_setup_theme', 'mytheme_setup_theme' );
function mytheme_setup_theme() {
add_image_size( 'social-800x420', 800, 420, true );
}
/**
@smeric
smeric / woocommerce-overwrite-default-thumbnail-sizes.php
Created October 11, 2016 13:43
Overwrite default thumbnails sizes after WooCommerce installation
<?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
);
Verifying that "sebmeric.id" is my Blockstack ID. https://onename.com/sebmeric
@smeric
smeric / woocommerce-membership-post-excerpt.php
Created November 23, 2015 14:06
WooCommerce membership custom post excerpt. Instead of using the excerpt this will display the begining of a post for non members.
<?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 / html-tags-shortcode.php
Created October 7, 2017 19:42
WordPress HTML tags shortcode. So you may add HTML to escaped form fields values :)
<?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 / nemus-slider.php
Last active December 18, 2017 09:10
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
<?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 / woocommerce-add-to-cart-before-applying-coupon.php
Last active July 23, 2018 09:16
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.
<?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 / woocommerce-custom-extra-tab.php
Last active January 21, 2019 11:04
Adds a metabox to define a custom tab title and content on woocommerce product pages.
<?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