Skip to content

Instantly share code, notes, and snippets.

View emulsion-io's full-sized avatar
🏠
Working from home

Fabrice emulsion-io

🏠
Working from home
View GitHub Profile
@emulsion-io
emulsion-io / MY_Input.php
Created October 17, 2024 16:05
Ajoute la prise en compte de ->input->json() dans Codeingniter 3
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Input extends CI_Input {
/**
* Instance de CI_Security
*
* @var CI_Security
*/
@emulsion-io
emulsion-io / bot-wordpress.php
Last active October 7, 2024 14:20
Filtre des bots sur get_refreshed_fragments pour woo commerce
<?php
function block_get_refreshed_fragments_for_specific_bots() {
// Vérifie si la requête est celle de WooCommerce pour les fragments
if (isset($_REQUEST['wc-ajax']) && $_REQUEST['wc-ajax'] === 'get_refreshed_fragments') {
// Liste des patterns pour les user agents à bloquer (exemples)
$bot_patterns = array(
' YLT',
'^Aether',
'^Amazon Simple Notification Service Agent$',
/*
* Permet de rendre une checkbox obligatoire parmis plusieurs
*
* Jquery required.
*
* <input name="tranche[]" type="checkbox" class="tel-checkbox" id="modal-usual-call-matin" value="matin" required>
* <input name="tranche[]" type="checkbox" class="tel-checkbox" id="modal-usual-call-midi" value="midi" required>
* <input name="tranche[]" type="checkbox" class="tel-checkbox" id="modal-usual-call-apmidi" value="apres-midi" required>
* <input name="tranche[]" type="checkbox" class="tel-checkbox" id="modal-usual-call-soir" value="soir" required>
*
@emulsion-io
emulsion-io / lazy.php
Created April 30, 2020 16:57
add attr lazyload functions.php wordpress
function add_loading_lazy_to_images($attr) {
$attr['loading'] = 'lazy';
return $attr;
}
add_filter( 'wp_get_attachment_image_attributes', 'add_loading_lazy_to_images');
@emulsion-io
emulsion-io / python_php.php
Created May 5, 2017 16:37
Exécute un script python sans paralyser php
<?php
session_start() ;
$cmd1 = 'python -u /var/www/blabla/test/Test.py';
$proc=proc_open($cmd1,
array(
array("pipe","r"),
array("pipe","w"),
array("pipe","w")
),
@emulsion-io
emulsion-io / copypasta.js
Last active August 29, 2015 14:25
Ajoute du texte a la fin d'un c/c sur une page web avec possibilité d'envoyer la valeur c/c en ajax sur une api
jQuery(document).ready(function($)
{
function CopyPasta()
{
var commentaire = " : coucou : ";
var url = window.location.href;
var copy = window.getSelection();
var brut = copy.toString();
var divPaste = document.createElement('div');
@emulsion-io
emulsion-io / new_gist_file.js
Created July 20, 2015 09:53
Récupère les paramètres d'une URL en javascript.
function getUrlParam(name) {
var results = new RegExp('[\\?&]' + name + '=([^]*)').exec(window.location.href);
return (results && results[1]) || undefined;
}
@emulsion-io
emulsion-io / close_navigateur.js
Created July 20, 2015 09:45
Détection de la fermeture du navigateur
function checkBrowser() {
// Alt+F4 , File->Close detection
if(window.event.clientX < 0 && window.event.clientY < 0) {
// do action
}
}
@emulsion-io
emulsion-io / is_semaine.php
Created April 7, 2014 07:53
Bool des jours de semaine et week-end pour CodeIgniter Helper
<?php
if ( ! function_exists('isLundi'))
{
function isLundi($date = FALSE) {
if($date === FALSE)
{
return (date('N', strtotime(date("Y-m-d H:i:s"))) == 1);
}
return (date('N', strtotime($date)) == 1);
}
@emulsion-io
emulsion-io / select_form_heure_min.php
Created December 22, 2013 11:23
Créer les select html pour heure et minute
<div class="form-group">
<label for="f_nom_arret">Heure de passage normal : </label>
<select name="heure">
<option value="h">heure</option>
<?php for ($heure = 00 ; $heure <= 23 ; $heure++):
$hour = sprintf("%02d", $heure);
?>
<option value="<?php echo $hour ?>"><?=$hour;?></option>
<?php endfor; ?>
</select>