Skip to content

Instantly share code, notes, and snippets.

View Antoinebr's full-sized avatar
:octocat:
🔥

Antoinebr

:octocat:
🔥
  • Fastly
  • Paris / Rennes
View GitHub Profile
@Antoinebr
Antoinebr / pop-under.js
Created March 16, 2016 13:21
pop-under.js
function popunder(url, width, height, name) {
// On désactive le popunder sur les sites mobiles
if (typeof window.DetectMobileLong == 'function' && typeof window.DetectTierTablet == 'function') {
if(DetectMobileLong() || DetectTierTablet() || document.location.href.match(/test_mobile/))
return false;
}
// On effectue un traitement différent pour Chrome
if(navigator.userAgent.match('Chrome')) {
// Ouverture de la nouvelle page (Simulation d'un Shift+Clic)
@Antoinebr
Antoinebr / anim-menu.css
Last active March 16, 2016 17:28
Animation des elements d'un menu un par un
.menu-haut ul li{
display: inline-block;
opacity: 0;
visibility: hidden;
}
@Antoinebr
Antoinebr / wp-redirect-subscribers.md
Created February 25, 2016 15:39
wp-redirect-subscribers

Rediriger les abonnés sur la HP

//interdire l'accès aux non admins
add_action( 'current_screen', 'redirect_non_authorized_user' );
function redirect_non_authorized_user() {
	// Si t'es pas admin, tu vires
	if ( is_user_logged_in() && ! current_user_can( 'manage_options' ) ) {
 wp_redirect( home_url() ); // on les redirige vers la home
@Antoinebr
Antoinebr / pollylang.md
Last active April 2, 2016 20:26
pollylang.md

utiliser pollylang

Enregistrer une chaine

Permet de pouvoir la traduire dans le BO

Dans functions.php faire pour chaque chaine

Il faut tester l'existance de la functions ! Otherwise your site will badly break with a fatal error at next Polylang update (as WordPress deletes the plugin when updtating it).

@Antoinebr
Antoinebr / wp-regenerate-slug.php
Created February 16, 2016 21:54
wp-regenerate-slug.php
<?php
$posts = get_posts(array(
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'menu_order',
'numberposts' => 999999
));
foreach ( $posts as $post )
{
@Antoinebr
Antoinebr / instagram.js
Created February 9, 2016 14:54
instagram.js
var userId = 1282926470;
var clientId = 'b2c4628sdsdda9900914746bb80f0c4523ef7fa6';
var myurl = "https://api.instagram.com/v1/users/"+userId+"/media/recent/?client_id="+clientId;
$.ajax({
dataType: "jsonp", // Pour eviter de prbs avec le cross domaine on met jsonp
url: myurl ,
}).done(function ( data ) {
@Antoinebr
Antoinebr / hide.php
Created December 1, 2015 10:28
Cache la barre d'admin WP aux non-admin
<?php
if ( is_user_logged_in() && ! current_user_can( 'manage_options' ) ) {
add_filter('show_admin_bar','__return_false');
}
?>
<?php
global $woocommerce;
$args = array(
'post_type' => 'shop_order',
'post_status' => 'publish',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
zip -r mes-logs.zip other_vhosts_access.log*
@Antoinebr
Antoinebr / gist:845f8c55a3c8451cf698
Last active October 18, 2015 11:39
Appel de la fonction promo WC
<?php
promo_product(get_field('gift-Product-ID','option'),2,18);
?>