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 / functions-class.php
Last active Nov 28, 2017
Add WordPress admin menu + submenu
View functions-class.php
<?php
class WeAreWP {
function __construct() {
}
function init() {
add_action( 'admin_menu', array( $this, 'wearewp_plugin_top_menu' ) );
}
@thierrypigot
thierrypigot / functions.php
Last active Nov 23, 2017
Set a custom post type to not show up on the front end
View functions.php
Besoin de support WordPress ou de maintenance WordPress ?
Contactez WP Assistance : https://www.wp-assistance.fr
<?php
add_action( 'template_redirect', 'wearewp_template_redirect', 1);
function wearewp_template_redirect() {
global $wp_query;
// redirect CPT_NAME_HERE CPT to home page
if ( is_archive('CPT_NAME_HERE') || is_singular('CPT_NAME_HERE') ) {
@thierrypigot
thierrypigot / functions.php
Last active Nov 23, 2017
WordPress: Enables Editor in Media edit screen
View functions.php
Besoin de support WordPress ou de maintenance WordPress ?
Contactez WP Assistance : https://www.wp-assistance.fr
<?php
// Enables Editor in Media edit screen.
add_filter( 'wp_editor_settings', 'wearewp_add_editor_support_for_attachments' );
function wearewp_add_editor_support_for_attachments($settings) {
if( get_post_type() == 'attachment'){
$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,ul,ol,li,code,close' );
$settings = array(
@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 / script.js
Created Oct 17, 2017
jQuery move bloc when you resize the window.
View script.js
// Example here: www.sesame-consultants.com/nos-services/etudes-et-investigations/
(function($) {
"use strict";
function wearewp_resize(){
var cta = $('.container-cta');
if( window.matchMedia("(max-width: 991px)").matches ) {
@thierrypigot
thierrypigot / joke.php
Last active Sep 16, 2017
WordCamp Marseille 2017 - Les contenus personnalisés dans WordPress - Fichier d'exemple
View joke.php
<?php
/*
Plugin Name: Jokes
Plugin URI: https://www.wearewp.pro
Description: Manage jokes
Author: WeAre[WP]
Author URI: https://www.wearewp.pro
Text Domain: waw-joke
Domain Path: /languages/
Version: 1.0
@thierrypigot
thierrypigot / functions.php
Last active Aug 13, 2017
Add custom google font to Beaver Builder theme
View functions.php
<?php
// Add this function in the functions.php of your theme
add_filter( 'fl_theme_google_fonts', 'wearewp_theme_google_fonts' );
function wearewp_theme_google_fonts( $google ){
// Add a font from https://fonts.google.com/ : font name => font size (100, 200...)
$google['Saira'] = array(
"100",
"200",
"400",
@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
@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 / functions.php
Last active Feb 18, 2018
Get all entries for WordPress attachments on attachment archive page
View functions.php
<?php
add_filter( 'register_post_type_args', 'tp_change_attachment_post_type_args', 10, 2 );
function tp_change_attachment_post_type_args($args, $post_type){
if( 'attachment' == $post_type ){
$args['has_archive'] = true;
$args['rewrite'] = array( 'slug' => 'media' );
}
return $args;
}
You can’t perform that action at this time.