Skip to content

Instantly share code, notes, and snippets.

Thierry Pigot thierrypigot

View GitHub Profile
View get_language_selector_flags.php
<?php
/**
* WPML - Language selector
* Thierry Pigot
*
* return html
**/
function tp_get_language_selector_flags()
{
$languages = icl_get_languages('skip_missing=0');
View equalHeight.js
/* Equal Height for html element */
function equalHeight( group )
{
var tallest = 0;
var thisHeight = 0;
group.each(function() {
thisHeight = jQuery(this).height();
if(thisHeight > tallest) {
tallest = thisHeight;
@thierrypigot
thierrypigot / tp-test.php
Created Aug 28, 2014
Translate WordPress plugin Headers
View tp-test.php
<?php
/**
* Plugin Name: Thierry Pigot - A awesome plugin!
* Plugin URI: http://www.thierry-pigot.fr/tutoriel/722/traduire-header-plugin-wordpress/
* Description: A brief description of the Plugin.
* Version:1.0
* Author: Thierry Pigot
* Author URI: http://www.thierry-pigot.fr/
* License: GPL2
* Text Domain: tp-test
@thierrypigot
thierrypigot / wp-sitemap-page.php
Last active Aug 29, 2015
wp-sitemap-page.php
View wp-sitemap-page.php
<?php
extract( shortcode_atts( array(
'wsp_exclude_pages' => trim(get_option('wsp_exclude_pages')),
'wsp_exclude_cpt_page' => get_option('wsp_exclude_cpt_page'),
'wsp_exclude_cpt_post' => get_option('wsp_exclude_cpt_post'),
'wsp_exclude_cpt_archive' => get_option('wsp_exclude_cpt_archive'),
'wsp_exclude_cpt_author' => get_option('wsp_exclude_cpt_author')
), $atts ) );
// Exclude some pages
@thierrypigot
thierrypigot / restrict.php
Created Oct 10, 2014
Redirect non admin to front
View restrict.php
<?php
/**
* Redirect non admin to front
**/
add_action( 'admin_init', 'tp_demo_redirect_non_admin_users' );
function tp_demo_redirect_non_admin_users()
{
if ( ! current_user_can( 'manage_options' ) && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] ) {
wp_safe_redirect( home_url() );
exit;
@thierrypigot
thierrypigot / hide_adminbar.php
Created Oct 10, 2014
Hide adminbar to non admin
View hide_adminbar.php
<?php
/**
* Hide adminbar to non admin
**/
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar()
{
if( ! current_user_can( 'manage_options' ) && !is_admin() && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] )
{
show_admin_bar(false);
@thierrypigot
thierrypigot / admin-in-fr.php
Last active Aug 29, 2015
Admin in FR, front in IT
View admin-in-fr.php
<?php
add_filter('locale', 'tp_setLocale');
function tp_setLocale($locale) {
if ( !is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'woocommerce_update_order_review' ) {
return 'it_IT';
}
return $locale;
}
@thierrypigot
thierrypigot / admin-search-filter.php
Created Nov 19, 2014
Dans l'admin, étendre la recherche des Custom Post Type aux métas, en plus du titre et de la description.
View admin-search-filter.php
<?php
/*
* Dans cet exemple mon Custom Post Type est "revendeurs"
*/
add_filter('posts_join', 'revendeurs_search_join' );
function revendeurs_search_join ($join){
global $pagenow, $wpdb;
// I want the filter only when performing a search on edit page of Custom Post Type named "revendeurs"
if ( is_admin() && $pagenow=='edit.php' && $_GET['post_type']=='revendeurs' && $_GET['s'] != '')
View search-filter.php
<?php
function custom_search_query( $query ) {
if( is_admin() && $query->is_main_query() && $query->query['post_type'] === 'revendeurs' && isset($query->query_vars['s']) )
{
$custom_fields = array(
// put all the meta fields you want to search for here
"raison_sociale",
);
$searchterm = $query->query_vars['s'];
@thierrypigot
thierrypigot / ajax.php
Created Jan 14, 2015
Permet de faire des traitement en Ajax, en particulier pour passer des problématiques de timeout.
View ajax.php
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
body {font-family: verdana, arial; font-size: 62.5%; margin: 0 auto; width: 80%;background-color: #f5f5f5;}
#container {background-color: #fff;padding:10px;margin:20px 0;}
h1{font-size: 3em;}
h2{font-size: 2em;}
You can’t perform that action at this time.