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
View gist:80a825e8010e74311c1bbafc77cedea1
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@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 / wearewp-cpt-glance.php
Created Sep 16, 2019
Custom post type counts in 'Right now' Dashboard widget
View wearewp-cpt-glance.php
<?php
/*
Plugin Name: Custom post type counts
Description: Custom post type counts in 'Right now' Dashboard widget
Plugin URI: https://www.wearewp.pro
Version: 1.0
Author: WeAre[WP]
Author URI: https://www.wearewp.pro
*/
@thierrypigot
thierrypigot / wpml-config.xml
Created Aug 23, 2019
Beaver Builder theme cutomizer translation with Polylang and WPML
View wpml-config.xml
<wpml-config>
<admin-texts>
<key name="theme_mods_{THEMENAME}">
<key name="fl-topbar-col1-text" />
<key name="fl-logo-image-retina" />
<key name="fl-logo-image" />
</key>
</admin-texts>
</wpml-config>
@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-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;
}
You can’t perform that action at this time.