Skip to content

Instantly share code, notes, and snippets.

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

Antoinebr

:octocat:
🔥
View GitHub Profile
@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');
}
?>
@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 / 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 / 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-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 / 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 / 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 / gmap-distanceApi.php
Created March 21, 2016 20:46
Quick & dirty gmap API use
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lato:300,400' rel='stylesheet' type='text/css'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
@Antoinebr
Antoinebr / forbiden-url.php
Created March 30, 2016 17:36
Permet d'interdire des pages de l'admin
<?php
function forbidden_url(){
$forbidenUrls = array(
'theme-editor.php',
'themes.php',
'plugin-editor.php',
'plugin-install.php',
'plugins.php',
@Antoinebr
Antoinebr / .htaccess
Last active September 2, 2016 14:56
htaccess speedup !
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset UTF-8
# Force UTF-8 for a number of file formats
<IfModule mod_mime.c>
AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml
</IfModule>
# FileETag None is not enough for every server.
<IfModule mod_headers.c>