dynamic counter ok

This commit is contained in:
asus
2023-11-11 13:01:43 +01:00
parent 6e460f5347
commit 99aeaa82b0
7 changed files with 179 additions and 70 deletions

View File

@@ -55,6 +55,23 @@ function mp_have_no_coordinates($posts_list) {
function mp_bad_categories($posts_list) {
$posts_bad_categories = [];
foreach ($posts_list as $post) {
$value = get_field("categorie", $post->ID);
if (! is_string($value)) {
array_push($posts_bad_categories, $post);
//mp_console_log("categorie:");
//mp_console_log($value);
}
}
return $posts_bad_categories;
}
function mp_show_list_posts_no_address($posts) {
echo <<<HTML
@@ -100,6 +117,60 @@ function mp_show_list_posts_no_address($posts) {
function mp_show_list_posts_bad_categories($posts) {
echo <<<HTML
<div style="border: 1px solid red; margin: 20px 20px 20px auto; padding: 0px 20px;">
<p style="color: red;">
<b>ATTENTION !</b>
</p>
<p>
<b>
HTML;
echo count($posts);
echo '</b>';
if (count($posts) == 1)
echo " article à sa catégorie mal formatée :";
else
echo " articles ont leur catégorie mal formatée :";
echo <<<HTML
</p>
<ul style="list-style: square inside;">
HTML;
foreach ($posts as $post) {
echo <<<HTML
<li><b>
HTML;
echo 'id: ';
echo $post->ID;
echo ' (status: ';
echo $post->post_status;
echo ') - ';
if (!empty($post->mode))
echo $post->mode[0];
echo ' : </b>';
echo $post->post_title;
echo <<<HTML
<p style="margin:0px;">
<span style="color:blue;">catégorie: </span>
HTML;
$categorie = get_field("categorie", $post->ID);
echo '<span>';
var_dump($categorie);
echo '</span>';
echo <<<HTML
</p>
</li>
HTML;
}
echo <<<HTML
</ul>
</div>
HTML;
}
function mp_show_list_posts_no_coordinates($posts) {
echo <<<HTML
@@ -229,7 +300,18 @@ function ljdp_map_plugin_content() {
//mp_console_log("posts_no_coordinates: ");
//mp_console_log($posts_no_coordinates);
$posts_bad_categories = mp_bad_categories($posts_list);
//mp_console_log("posts_bad_categories: ");
//mp_console_log($posts_bad_categories);
echo <<<HTML
<style>
li {
list-style-position: outside;
margin-left: 10px;
}
</style>
<div>
<h2>JIPF map plugin</h2>
HTML;
@@ -241,6 +323,9 @@ function ljdp_map_plugin_content() {
if (count($posts_no_address) > 0)
mp_show_list_posts_no_address($posts_no_address);
if (count($posts_bad_categories) > 0)
mp_show_list_posts_bad_categories($posts_bad_categories);
if (count($posts_no_coordinates) > 0){
mp_show_list_posts_no_coordinates($posts_no_coordinates);
}