Skip to content

Instantly share code, notes, and snippets.

View graphicom's full-sized avatar

Mohamed Amine MAHASSINE graphicom

View GitHub Profile
@graphicom
graphicom / custom-acf-admin.js
Created November 5, 2021 12:15 — forked from MogulChris/custom-acf-admin.js
Hierarchical select for native Advanced Custom Fields taxonomy fields.
jQuery(document).ready(function($){
//Modify select2 ajax request to include a parent_id parameter, used by custom_acf_taxonomy_hierarchy()
acf.add_filter('select2_ajax_data', function( data, args, $input, field, instance ){
var target_field_key = 'field_5c7634ca3413f'; //YOUR TARGET FIELD KEY HERE
if(data.field_key == target_field_key){
var parent_id = 0; //by default we want terms with parent of 0 (top level)
@graphicom
graphicom / theme-scripts.php
Created November 5, 2021 12:14 — forked from MogulChris/theme-scripts.php
Automatic versioning with WordPress CSS and JS files (avoid hard refresh problems)
<?php
//When registering styles and scripts in WordPress, you can specify a 'version' parameter which is appended to the file's URL.
//This is fine, but it's inconvenient having to bump the version number whenever you make a change. So why not do it automatically?
//Note we use get_stylesheet_directory() instead of get_stylesheet_directory_uri(), so we get an absolute file path for filemtime()
$mtime = filemtime(get_stylesheet_directory() .'/js/script.js');
wp_register_script( 'theme-js', get_stylesheet_directory_uri() .'/js/script.js', array( 'jquery' ), $mtime, true );
wp_enqueue_script( 'theme-js' );
@graphicom
graphicom / fixwrongutf8encoding.php
Created March 30, 2021 17:36 — forked from kasperkamperman/fixwrongutf8encoding.php
Function to fix ut8 special characters displayed as 2 characters (utf-8 interpreted as ISO-8859-1 or Windows-1252)
<?php header('Content-Type: text/html; charset=utf-8'); ?>
<html>
<head>
<title>Fix wrong encoded UTF8 characters</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
<body>
<pre>
<?php
/* Problem description: