Skip to content

Instantly share code, notes, and snippets.

<?php
add_action('init', 'hwk_acf_taxonomy_register');
function hwk_acf_taxonomy_register(){
register_taxonomy('acf-field-group-type', array('acf-field-group'), array(
'labels' => array(
'name' => _x( 'ACF Field Groups Types', 'taxonomy general name', 'textdomain' ),
'singular_name' => _x( 'Type', 'taxonomy singular name', 'textdomain' ),
'search_items' => __( 'Search Types', 'textdomain' ),
'all_items' => __( 'All Types', 'textdomain' ),
<?php
add_action('acf/input/admin_footer', 'hwk_flexible_content_layout_no_popup');
function hwk_flexible_content_layout_no_popup() {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
try{
// ACF Flexible Content: Supprimer la popup si il n'y a qu'un seul Layout
<?php
add_action('acf/input/admin_footer', 'hwk_flexible_content_layout_popup_class');
function hwk_flexible_content_layout_popup_class() {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
try{
// ACF Flexible Content: Ajouter une class à la modal de sélection de Layouts
<?php get_header(); ?>
<div class="row">
<!-- Contenu Principal -->
<div class="col-lg-8">
<!-- Template: loop.php -->
<!-- Query: WP_Query globale (page en cours) -->
<!-- Not_found: Traitement dans le fichier de template -->
<?php
// On vérifie que notre Template est bien appelé via hwk_loop()
// $loop a accès à toutes les arguments de hwk_loop()
if(!$loop = get_query_var('hwk_loop'))
return;
?>
<!-- Traitement de la boucle -->
<!-- Les résultats sont stockés dans $loop['result'] -->
<?php
function hwk_loop($args = array()){
// Arguments par défaut
$args = wp_parse_args_recursive($args, array(
'template' => 'loop.php', // Fichier de Template par défaut: /wp-content/themes/<theme>/loop.php
'not_found' => false, // Fichier de Template en cas de résultat non trouvé
'pagination' => false, // Paramètre de pagination. Utilisé par le fichier de Template. true | false
'query' => array(), // Arguments de WP_Query. Si vide, alors utiliser la WP_Query globale
<?php
if(!function_exists('wp_parse_args_recursive')){
function wp_parse_args_recursive(&$a, $b){
$a = (array) $a;
$b = (array) $b;
$result = $b;
foreach($a as $k => &$v){
if (is_array($v) && isset($result[$k])){
<?php
/**
* Plugin Name: Mon Plugin
* Description: Ça, c'est mon plugin. Il y en a beaucoup comme ça, mais lui, c'est le mien.
* Author: mon-login-wordpress-org
* Version: 0.1
* Author URI: https://www.monsite.com
*/
=== Mon Plugin ===
Contributors: mon-login-wordpress-org
Donate link: https://www.monsite.com
Tags: mon, tag, trop, cool
Requires at least: 4.0
Tested up to: 4.9.5
Requires PHP: 5.3
Stable tag: 0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
<?php
add_filter('hwk_ajax_configs', 'hwk_ajax_declare_config_advanced');
function hwk_ajax_declare_config_advanced($config){
$config[] = array(
'id' => 'hwk_ajax_heavy_query_post',
'template' => 'templates/modules/module-heavy-post',
'cache' => 'templates/modules/cache/module-heavy-post-%param%', // %param% sera remplacé par la valeur indiqué dans le paramètre 'param'
'param' => get_the_ID(),
'flush' => get_the_ID(),