Skip to content

Instantly share code, notes, and snippets.

<?php
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices ) {
$choices['Utilisateur']['user_id'] = 'ID utilisateur';
return $choices;
}
add_filter('acf/location/rule_values/user_id', 'acf_location_rules_values_user');
[
{
"id": "20768",
"title": "Event 1",
"start": 1531828524,
"end": 1531832124,
"allDay": false
},
{
"id": "20773",
[
{
"id": "20768",
"title": "Event 1",
"start": 1531828524,
"end": 1531832124,
"allDay": false
},
{
"id": "20773",
@will83
will83 / index.php
Last active November 1, 2022 10:21
PHP function to translate WGS84 to GPS coordinates
<?php
$lat = -24.108764;
$lng = 16.500156;
function WGS84toGPS($lat, $lng){
$lat = number_format($lat, 6);
$lng = number_format($lng, 6);
// define latitude coordinate with minutes and seconds
$lat_card = ($lat > 0) ? 'N' : 'S';
@will83
will83 / Autoloader.php
Last active November 2, 2017 22:48
Autoloader OOP
<?php
namespace Namespace;
class Autoloader{
static function register(){
spl_autoload_register(array(__CLASS__, 'autoload'));
}
static function autoload($class){
@will83
will83 / func_menu_item_has_children.php
Last active September 25, 2015 18:24
Function to know if a menu item has children
<?php
function menu_item_has_children($id){
global $wpdb;
$myrows = $wpdb->get_results( "SELECT * FROM `wp_postmeta` WHERE `meta_key` LIKE '_menu_item_menu_item_parent' AND `meta_value` LIKE ".$id );
if(empty($myrows)) :
return false;
else :
return true;
endif;
@will83
will83 / func_object_depth.php
Last active August 29, 2015 14:27
Object depth function
function get_object_depth( $object_id, $object_type ){
$ancestors = get_ancestors( $object_id, $object_type );
return count($ancestors);
// 0 => level 1 (first parent)
// 1 => level 2
// ...
}
@will83
will83 / rewrite_custom_taxonomies_routes.php
Created July 16, 2015 13:56
Rewrite Custom Taxonomies Routes
<?php
/*
* Replace Taxonomy slug with Post Type slug in url
* Version: 1.1
*/
function ss_fix_portfolio_rewrite($wp_rewrite) {
$rules = array();
// get all custom taxonomies
@will83
will83 / get_all_post_custom_fields.php
Created April 3, 2015 17:03
Function to get all custom fields within the $post global
<?php
function get_all_post_custom_fields( $posts ) {
for ( $i = 0; $i < count($posts); $i++ ) {
$custom_fields = get_post_custom( $posts[$i]->ID );
$posts[$i]->custom_fields = $custom_fields;
}
return $posts;
}
add_filter( 'the_posts', 'get_all_post_custom_fields' );
echo '<pre>';
print_r(get_category());
echo '</pre>';