Skip to content

Instantly share code, notes, and snippets.

View flistefliste's full-sized avatar

flistefliste

  • Wallie
  • Seignosse, Soorts-Hossegor, France
View GitHub Profile
@flistefliste
flistefliste / rate_stars.php
Created February 15, 2018 11:29
Rate to fa-stars
<?php
/**
* Convert rate (ie. 3.5/5) into fontAwesome stars
*
* @param int $rate
* @return string
*/
function getStars($rate){
$max_rate = (int) 5 ;
$output = '<div class="widget-rating-stars">';
@flistefliste
flistefliste / trackCf7Submissions.php
Last active January 25, 2018 12:01
Track Contact Form 7 submissions events in WordPress and send it to Google Analytics
<?php
/**
* @desc CF7 submission tracking. Trigger ga_send (Google Analytics events tracking) when submitting CF7 form.
* @return void
*/
function trackCf7Submissions()
{
?>
<script>
//get current languages if necessary
@flistefliste
flistefliste / woocommerce_updated_checkout.js
Created May 9, 2016 14:06
Trigger events after checkout updated
jQuery( document ).on( 'updated_checkout', function() {
console.log( 'Checkout has been updated...' );
} );
@flistefliste
flistefliste / MaterializeCSS datepicker in french
Last active April 3, 2023 23:15
French translation for Materialize CSS datepicker plugin
$('.datepicker').pickadate({
selectMonths: true, // Creates a dropdown to control month
selectYears: 2, // Creates a dropdown of 15 years to control year
labelMonthNext: 'Mois suivant',
labelMonthPrev: 'Mois précédent',
labelMonthSelect: 'Selectionner le mois',
labelYearSelect: 'Selectionner une année',
monthsFull: [ 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre' ],
monthsShort: [ 'Jan', 'Fev', 'Mar', 'Avr', 'Mai', 'Jun', 'Jul', 'Aou', 'Sep', 'Oct', 'Nov', 'Dec' ],
weekdaysFull: [ 'Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi' ],
@flistefliste
flistefliste / woocommerce_mm_into_cm.php
Created August 27, 2015 10:36
Change display unit on product page woocommerce (dimensions are set into mm in woocommerce settings, but we want an display cm)
<?php
add_filter( 'woocommerce_product_dimensions', 'convert_dimensions_into_cm' ,100, 1 );
if(!function_exists('convert_dimensions_into_cm')){
function convert_dimensions_into_cm($dimensions){
//dimensions are set in mm in WC settings, but we want to display cm
$dimensions = explode('x', $dimensions) ;
$cm = array();
foreach ($dimensions as $elem) {
$cm[$elem] = $elem / 10 ;
}
@flistefliste
flistefliste / woocommerce_prepend_zero_to_product_weight.php
Last active August 29, 2015 14:26
Prepend "0" to product weight in WooCommerce when product weight notation is ie. ".19 kg" instead of "0.19 kg"
<?php
//prepend "0" to product weight in WooCommerce
add_filter( 'woocommerce_product_get_weight', 'prepend_zero' ,100, 1 );
if(!function_exists('prepend_zero')){
function prepend_zero($weight){
//check if first char is a dot "."
if (substr($weight, 0, 1) === '.'){
$weight = "0".$weight ;
}
return $weight ;
@flistefliste
flistefliste / is_shop_manager.php
Last active August 29, 2015 14:11
Function is_shop_manager() for WooCommerce
<?php
// function is shop manager
function is_shop_manager() {
global $current_user;
$user = wp_get_current_user();
if ( isset( $user->roles[0] ) && $user->roles[0] == 'shop_manager' ) {
return true; // when user is shop manager
} else {
return false; // when user is not shop manager
@flistefliste
flistefliste / gist:f8de3fa23b8252be520f
Created December 15, 2014 10:33
google map : make control panel and other images showing properly (despite general img{max-width:100%}
.gmnoprint img, .gm-style img {
max-width: none;
}
@flistefliste
flistefliste / woocommerce-whipping-methods.php
Last active September 10, 2018 08:01
$order->get_items( 'shipping' ) is useful to get all data from shipping method
<?php
$shipping_items = $order->get_items( 'shipping' );
foreach($shipping_items as $el){
$shipping_method_id = $el['method_id'] ;
}
?>