Skip to content

Instantly share code, notes, and snippets.

View hrenaud's full-sized avatar

hrenaud

View GitHub Profile
/**
* Display a custom taxonomy dropdown in admin
* @author Mike Hemberger
* @link http://thestizmedia.com/custom-post-type-filter-admin-custom-taxonomy/
*/
add_action('restrict_manage_posts', 'tsm_filter_post_type_by_taxonomy');
function tsm_filter_post_type_by_taxonomy() {
global $typenow;
$post_type = 'menu_item'; // change to your post type
$taxonomy = 'menu_items_category'; // change to your taxonomy
add_action('wp_footer', function () {
if (!defined('ELEMENTOR_VERSION')) {
return;
}
?>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
$header_height = $(".elementor-location-header").css('height');
if (typeof $header_height === "undefined") {
function displayValue($value){
echo '<pre>';
var_dump($value);
echo '</pre>';
}
<?php
add_action(
/* Pre-Elementor 2.5.1 use this:
'elementor_pro/posts/query/lwp_related_posts', */
'elementor/query/lwp_contributeurs_de_travaux',
'lwp_0001_contributeurs_de_travaux'
);
function lwp_0001_contributeurs_de_travaux( $query ) {
global $post;
<?php
add_filter('acf/update_value/key=field_5a67cc16e1169', 'acf_reciprocal_relationship', 10, 3); //edit this with your ID - field one
add_filter('acf/update_value/key=field_5b7d60a26c7b5', 'acf_reciprocal_relationship', 10, 3); //edit this with your ID - field two
function acf_reciprocal_relationship($value, $post_id, $field) {
// set the two fields that you want to create
// a two way relationship for
// these values can be the same field key
<?php
function bidirectional_acf_update_value($value, $post_id, $field)
{
// vars
$field_name = $field['name'];
$field_key = $field['key'];
$global_name = 'is_updating_' . $field_name;
<?php
/**
* Ajouter une page option configurable avec ACF
* https://www.advancedcustomfields.com/resources/acf_add_options_page/
*/
add_action('acf/init', 'my_acf_op_init');
function my_acf_op_init() {
// https://wpastra.com/docs/remove-inline-css-from-astra/
// https://klbtheme.com/elementor-if-the-page-is_elementor/
function astra_force_remove_style() {
add_filter( 'print_styles_array', function($styles) {
// Set styles to remove.
$styles_to_remove = array('astra-theme-css', 'astra-addon-css', 'la-moissonniere-astra-child-theme-css');
$id = get_the_ID();
<?php
if (function_exists('my_plugin_function')) {
remove_action('CALLED_HOOK', 'my_plugin_function');
add_action('CALLED_HOOK', 'my_NEW_plugin_function');
} else {
add_action('admin_notices', 'my_plugin_patch_error');
}
function my_plugin_patch_error()
{
$class = 'notice notice-error';