Skip to content

Instantly share code, notes, and snippets.

View willybahuaud's full-sized avatar

Willy Bahuaud willybahuaud

View GitHub Profile
@willybahuaud
willybahuaud / rescue.php
Last active August 29, 2015 14:04
Script de nettoyage pour les sites WordPress infectés par la vague d'attaque de juillet 2014
<?php
// code à insérer dans un fichier déposé à la racine de l'intallation
// regardez aussi s'il n'y a pas une image wordpress1.jpg, dans votre dossier uploads, à supprimer
// et bien sur changer tous les mots de passe après ^^
// et même, c'est pas sur que cela soit suffisant
function rglob( $pattern = '*', $path = '', $flags = 0 ) {
$paths = glob( $path . '*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
$files = glob( $path . $pattern, $flags );
foreach ( $paths as $path ) {
@willybahuaud
willybahuaud / gist:1ad49811b8af2cf5abe5
Created July 23, 2014 13:37
Template de recherche en ajax
<?php
$o = array();
$o[ 'title' ] = wp_title( '', false ); //me sert pour mettre à jour le titre de la fenêtre de navigation
$o[ 'type' ] = 'liste'; // le type du template
$o[ 'breadcrumb' ] = ffeeeedd__ariane(); //me sert pour mettre à jour le fil d'ariane
$q = get_search_query();
if( have_posts() ) :
jQuery( document ).ready( function( $ ) {
function resizeCallback() {
var size = 0;
$blocs = $( '.same-size' )
$blocs.css( 'height', 'auto' );
$blocs.each( function() {
size = $( this ).innerHeight() > size ? $( this ).innerHeight() : size;
} );
$blocs.css( 'height', size );
}
<?php
// Ajout de metabox dans le BO
add_action("add_meta_boxes", "willy_create_metaboxes", 10, 2);
function willy_create_metaboxes( $post_type, $post ) {
if ( 'product' == $post_type ) {
add_meta_box("artiste","Artiste","artiste_zik", $post_type,"side","high");
}
}
add_action('save_post', 'willy_save_post');
@willybahuaud
willybahuaud / espace-membre-css-override
Last active August 29, 2015 14:07
To update espace-membre
.willy-espace-membre-wrapper{
margin-right:-57px;
}
.willy-espace-membre{
margin-top:-18px;
}
.willy-espace-membre .w-button{
font-size:13px;
//Ligne 49 à 56
// Remplace...
$urlinscr = ( $idc = get_option( 'wem_page_inscr' ) ) ? esc_url( get_permalink( $idc ) ) : '';
$out[] = '<button class="willy-espace-membre-connexion w-button" data-target="wem-connexion" id="wem-connexion-button">' . __( 'Connexion', 'wem' ) . '</button> <span class="wem-pipe">|</span>';
$out[] = '<a class="willy-espace-membre-inscription w-button" href="' . $urlinscr . '">' . __( 'Inscription', 'wem' ) . '</a>';
$connectform = array();
$styleform = isset( $_GET['message'], $_GET['shake'] ) ? 'style="display:block;"' : 'style="display:none;"';
$connectform[] = '<div class="willy-espace-membre-connect-form" id="wem-connexion" ' . $styleform . '>';
@willybahuaud
willybahuaud / avatar espace membre
Created October 23, 2014 10:41
avatar espace membre
<?php
// a rajouter ligne 420
echo '<div class="wem-avatar">' . get_avatar( $userdata->user_email, 100, get_option( 'avatar_default' ), $userdata->display_name ) . '<p class="wem-modif-avatar">' . sprintf( __( 'Utilisez <a href="%s" target="_blank">le service Gravatar</a> pour personnaliser votre image de profil.', 'wem' ), 'https://fr.gravatar.com/' ) . '</p></div>';
// CSS à rajouter
/*
.wem-avatar{
padding-bottom:1em;
overflow:hidden;
@willybahuaud
willybahuaud / gist:8897ff6fb73b392115a4
Last active August 29, 2015 14:08
Arrangement des slugs
<?php
/**
* Pour avoir une structure de slug plus logique
*/
add_action( 'init', 'mescpts' );
function mescpts() {
register_post_type( 'recette', array(
'label' => 'Recettes',
'public' => true,
'supports' => array( 'title', 'editor', 'thumbnail' ),
<?php
add_filter( 'get_sample_permalink_html', 'willy_filter_fake_permalink', 10, 4 );
function willy_filter_fake_permalink( $return, $id, $newtitle, $newslug ) {
remove_filter( 'get_sample_permalink_html', 'willy_filter_fake_permalink' );
if ( $newslug === NULL ) {
if ( 'post' == get_post_type( $id ) ) {
$return = preg_replace( "/id=\"editable-post-name\"([^>]*)>/", "id=\"editable-post-name\"$1>actualite-", $return );
$return = preg_replace( "/id=\"editable-post-name-full\">/", "id=\"editable-post-name-full\">actualite-", $return );
}
}
@willybahuaud
willybahuaud / translate.php
Created November 18, 2014 09:46
translate wpm ajax requests
<?php
add_action( 'plugins_loaded', function() {
global $sitepress;
if( ! isset( $_REQUEST['icl_ajx_action'] ) && isset( $_POST[ 'mylang' ] ) ) {
$reflection = new ReflectionClass( 'SitePress' );
$admin_language = $reflection->getProperty( 'admin_language' );
$admin_language->setAccessible( true );
$admin_language->setValue( $sitepress, $_POST[ 'mylang' ] );
}
} );