handlign artisans custom functions
This commit is contained in:
parent
a3a0fa4830
commit
655ff4bc73
|
|
@ -5,7 +5,9 @@
|
||||||
require_once(__DIR__ . '/includes/errorlog.php');
|
require_once(__DIR__ . '/includes/errorlog.php');
|
||||||
require_once(__DIR__ . '/includes/init.php');
|
require_once(__DIR__ . '/includes/init.php');
|
||||||
require_once(__DIR__ . '/includes/post_types.php');
|
require_once(__DIR__ . '/includes/post_types.php');
|
||||||
|
require_once(__DIR__ . '/includes/artisans.php');
|
||||||
require_once(__DIR__ . '/includes/admin.php');
|
require_once(__DIR__ . '/includes/admin.php');
|
||||||
require_once(__DIR__ . '/includes/taxonomy.php');
|
require_once(__DIR__ . '/includes/taxonomy.php');
|
||||||
require_once(__DIR__ . '/includes/api.php');
|
require_once(__DIR__ . '/includes/api.php');
|
||||||
require_once(__DIR__ . '/includes/blocks.php');
|
require_once(__DIR__ . '/includes/blocks.php');
|
||||||
|
require_once(__DIR__ . '/includes/utilities.php');
|
||||||
|
|
|
||||||
28
includes/artisans.php
Normal file
28
includes/artisans.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
function metiers_patrimoine_artisant_post_title_updater($post_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (!$post_id) return;
|
||||||
|
|
||||||
|
$my_post = array();
|
||||||
|
$my_post['ID'] = $post_id;
|
||||||
|
$name = get_field("name", $post_id);
|
||||||
|
$address = get_field("adresse", $post_id);
|
||||||
|
|
||||||
|
if (get_post_type() == 'artisans' && $name) {
|
||||||
|
$my_post['post_title'] = "";
|
||||||
|
$my_post['post_title'] = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($address && isset($address['country'])) {
|
||||||
|
$stateGenericName = getGenericStateNameFromAcfStateName($address['state']) ?? "";
|
||||||
|
// write_log($stateGenericName);
|
||||||
|
// Met à jour le champ personnalisé 'country' avec la valeur du pays de l'adresse
|
||||||
|
update_post_meta($post_id, 'state', $stateGenericName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write_log($address);
|
||||||
|
wp_update_post($my_post);
|
||||||
|
}
|
||||||
|
add_action('acf/save_post', 'metiers_patrimoine_artisant_post_title_updater', 20);
|
||||||
|
|
@ -43,22 +43,3 @@ function metiers_patrimoine_create_posttype()
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('init', 'metiers_patrimoine_create_posttype');
|
add_action('init', 'metiers_patrimoine_create_posttype');
|
||||||
|
|
||||||
|
|
||||||
function metiers_patrimoine_artisant_post_title_updater($post_id)
|
|
||||||
{
|
|
||||||
if (!$post_id) return;
|
|
||||||
|
|
||||||
$my_post = array();
|
|
||||||
$my_post['ID'] = $post_id;
|
|
||||||
$name = get_field("name", $post_id);
|
|
||||||
|
|
||||||
if (get_post_type() == 'artisans' && $name) {
|
|
||||||
$my_post['post_title'] = "";
|
|
||||||
$my_post['post_title'] = $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wp_update_post($my_post);
|
|
||||||
}
|
|
||||||
add_action('acf/save_post', 'metiers_patrimoine_artisant_post_title_updater', 20);
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user