Skip to content

Instantly share code, notes, and snippets.

View younes-dro's full-sized avatar
🏡
Working from home

WordPress | React | Gutenberg Developer younes-dro

🏡
Working from home
View GitHub Profile
@younes-dro
younes-dro / regex-3-lettre-3-number
Created January 9, 2020 05:37
Verify a pattern : 6 char lenght ( 3 string and 3 number)
if(isset($_POST['log']) && !empty($_POST['log']) && $_POST['log']==1){
$login = trim($_POST['login']);
$pw = trim($_POST['pw']);
if(strlen($login) == 6 && strlen($pw) == 6){
$n_log=0;
add_action('pre_get_posts', 'cgy_same_day');
function cgy_same_day($query) {
if ($query->is_home() && $query->is_main_query()) {
$today = getdate();
$query->set('date_query', array(
array(
'day' => $today['mday'],
@younes-dro
younes-dro / gist:97bb6a0a4f8f8f225e129f6b8448870b
Last active October 9, 2019 15:41
Display vairation products as a table
add_action('plugins_loaded', function(){
function woocommerce_variable_add_to_cart() {
global $product, $post;
// print_r($product->product_type);
$variations = $product->get_available_variations();
// ob_start(); // Start buffering
?>
<form class="cart" action="<?php echo esc_url($product->add_to_cart_url()); ?>" method="post" enctype="multipart/form-data">
<table class="dro-variable-product" id="dro-variable-product">
<tbody>
@younes-dro
younes-dro / custom widget glyph icon
Created September 6, 2019 00:41
generate custom widget glyph icon using Sass : loop , mixin , map
@mixin sidebar-title-icon($content){
.widget-title{
&::before{
font-family: "Ionicons";
content: $content;
display: inline-block;
margin: 0 10px 0 0;
}
}
}
@younes-dro
younes-dro / wp add age slug in body css class
Created September 3, 2019 23:02
Add page slug in body css class
/**
* Add page slug in body class
*
* @global type $post
* @param string $classes
* @return string
*/
//Page Slug Body Class
function add_slug_body_class( $classes ) {
@younes-dro
younes-dro / sass-extend-and-loop-for
Created September 3, 2019 22:59
combine @extend and a loop for with Sass
%white-div{
color:#fff;
}
@for $j from 1 to 6{
div-#{$j}{
@extend %white-div;
}
}