Skip to content

Instantly share code, notes, and snippets.

View thierrypigot's full-sized avatar

Thierry Pigot thierrypigot

View GitHub Profile
@thierrypigot
thierrypigot / .htaccess
Created May 28, 2015 08:16
.htaccess : Redirection d’une url sans www vers une url avec www
Options +Followsymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
@thierrypigot
thierrypigot / wp-config.php
Created May 28, 2015 08:19
WordPress : Activer le débogage
// Par défaut
define('WP_DEBUG', false);
/*------------------------------------*/
// Active le debogage
define('WP_DEBUG', true);
// Indique à WordPress de tout logger dans /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
@thierrypigot
thierrypigot / search-replace.sql
Created May 28, 2015 08:21
MySQL : Remplacer caractères par d’autres
UPDATE
nom_de_la_table
SET
nom_de_la_colonne = REPLACE(
nom_de_la_colonne,
'STR_source',
'STR_destination'
)
;
@thierrypigot
thierrypigot / wp-config.php
Created May 28, 2015 08:22
WordPress : Désactiver le versionning des articles
<?php
// suppression des révisions
define('WP_POST_REVISIONS', false);
// nombre de sauvegarde : 5
define('WP_POST_REVISIONS', 5);
@thierrypigot
thierrypigot / functions.php
Created May 28, 2015 08:23
WordPress : Ajouter un champ extrait aux pages
<?php
function tp_excerpt_pages()
{
add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'page', 'normal', 'core');
}
add_action( 'admin_menu', 'tp_excerpt_pages' );
@thierrypigot
thierrypigot / functions.php
Created May 28, 2015 08:24
WordPress : Ajouter un lien d’action dans liste plugins
<?php
function tp_googlemaps_action_links( $links, $file )
{
if (strstr($file, 'tp-googlemaps/tp-googlemaps.php'))
{
$settings_link = '<a href="admin.php?page=tp_googlemaps-menu">'. __('Settings').'</a>';
array_unshift( $links, $settings_link );
}
return $links;
}
@thierrypigot
thierrypigot / tpl-pageProduit.php
Created May 28, 2015 08:25
WordPress : Type de page personnalisé
<?php
/**
* Ajouter en tête de fichier de template, choisir un nom pour le type de page
*
* Template Name: Page Produit
**/
@thierrypigot
thierrypigot / wp-config.php
Created May 28, 2015 08:30
WordPress : un wp-config.php aux hormones
<?php
/** Errors Management **/
@ini_set('display_errors', false);
define('WP_DEBUG', false);
/** Revisions Management **/
define('WP_POST_REVISIONS', false);
/** Disable auto update **/
define( 'WP_AUTO_UPDATE_CORE', false );
@thierrypigot
thierrypigot / maintenance.php
Created May 28, 2015 08:34
WordPress : custom maintenance page - Add file in "wp-content" folder
<?php
$admin_email = '[email protected]';
$admin_tel = '06 01 95 63 81';
/* Tell search engines that the site is temporarily unavailable */
$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0';
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
header( 'Retry-After: 600' );
@thierrypigot
thierrypigot / functions.php
Created May 28, 2015 08:39
WordPress : use widget inside content page
<?php
// [widget type="WP_Widget_Archives"]
add_shortcode( 'widget', 'tp_widget_shortcode' );
function tp_widget_shortcode( $atts )
{
// Configure defaults and extract the attributes into variables
extract( shortcode_atts(
array(
'type' => '',