Skip to content

Instantly share code, notes, and snippets.

Thierry Pigot thierrypigot

Block or report user

Report or block thierrypigot

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thierrypigot
thierrypigot / exclude-categories-search.php
Last active Jul 27, 2019
Exclude page / category from search on WordPress frontend
View exclude-categories-search.php
<?php
/**
* Exlcude categories ids: 2, 3 and 5
**/
function tp_SearchFilter($query)
{
if( !$query->is_admin && $query->is_search )
{
$query->set( 'category__not_in', array( 2, 3, 5 ) );
}
@thierrypigot
thierrypigot / functions.php
Last active Jul 15, 2019
Defer WordPress javascript
View functions.php
<?php
// Show javascript handle
add_filter( 'script_loader_tag', 'wearewp_add_script_handle', 10, 3 );
function wearewp_add_script_handle( $tag, $handle, $src ) {
return str_replace( '<script', sprintf(
'<script data-handle="%1$s"',
esc_attr( $handle )
), $tag );
}
@thierrypigot
thierrypigot / acf-missing.php
Created Jun 3, 2016
WordPress mu plugins to check if "Advanced Custom Fields Pro" is active.
View acf-missing.php
<?php
if( !class_exists('acf') )
{
$tp_acf_notice_msg = __( 'This website needs "Advanced Custom Fields Pro" to run. Please download and activate it', 'tp-notice-acf' );
/*
* Admin notice
*/
add_action( 'admin_notices', 'tp_notice_missing_acf' );
function tp_notice_missing_acf()
@thierrypigot
thierrypigot / acf-polylang.php
Created Jan 5, 2017
Add polylang support to ACF fields group
View acf-polylang.php
<?php
add_filter('pll_get_post_types', 'wearewp_add_acf_pll', 10, 2);
function wearewp_add_acf_pll( $post_types, $is_settings ) {
$post_types[] = 'acf-field-group';
return $post_types;
}
@thierrypigot
thierrypigot / waw-publishing.php
Last active May 21, 2019
Use this script to publish future post by server cron. USE: {site OR sub-site URL}/waw-publishing.php
View waw-publishing.php
<?php
/**
Description: Use this script to publish future post by server cron. USE: {site OR sub-site URL}/waw-publishing.php
Author: WeAre[WP]
Author URI: https://www.wearewp.pro
Version: 1.0
CRON
wget -O /dev/null https://site-A.com/waw-publishing.php
@thierrypigot
thierrypigot / install-wp.sh
Last active May 6, 2019
Local by flywheel - Custom WordPress install script
View install-wp.sh
#!/usr/bin/env bash
while ! mysqladmin ping --silent; do
sleep 1
done
if mysql -e "SELECT USER(),CURRENT_USER();" -proot 2> /dev/null
then
echo "mysql password: root"
mysql -e "DROP DATABASE IF EXISTS local; CREATE DATABASE local;" -proot
View screen-reader-text.css
.screen-reader-text {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
overflow: hidden;
position: absolute !important;
width: 1px;
word-wrap: normal !important;
}
@thierrypigot
thierrypigot / wearewp-disable-gutenberg.php
Created Oct 31, 2018
Disable Gutenberg in WordPress 5.0
View wearewp-disable-gutenberg.php
<?php
/*
Plugin Name: WeAreWP Gutenberg
Description: Disable Gutenberg in WordPress 5.0
Plugin URI: https://www.wearewp.pro
Version: 1.0
Author: WeAre[WP]
Author URI: https://www.wearewp.pro
*/
@thierrypigot
thierrypigot / script.js
Created Oct 20, 2017
Smooth scroll Javascript
View script.js
jQuery(document).ready(function ($) {
'use strict';
// Smooth scroll
// https://css-tricks.com/snippets/jquery/smooth-scrolling/
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
@thierrypigot
thierrypigot / tp_toolbox.php
Created Oct 3, 2016
WordPress: Register taxonomy hack WordPress. In the register_taxonomy function, add : $args = array( 'meta_box_cb' => 'tp_taxonomy_radio_meta_box' );
View tp_toolbox.php
<?php
/**
* Display taxonomy selection as radios
*
* @param WP_Post $post
* @param array $box
*/
if( !function_exists('tp_taxonomy_radio_meta_box') ) {
function tp_taxonomy_radio_meta_box($post, $box) {
You can’t perform that action at this time.