resolve some errors in php logic, like strlen with str containing space that is interpreted as array instead of string
This commit is contained in:
@@ -135,8 +135,8 @@ add_action( 'publish_post', 'post_published_coordinates', 10, 2 );
|
||||
|
||||
function ljdp_map_menu() {
|
||||
add_menu_page(
|
||||
'ljdp map', // page_title
|
||||
'ljdp map', // menu_title
|
||||
'JIPF map', // page_title
|
||||
'JIPF map', // menu_title
|
||||
'manage_options', // capability
|
||||
'ljdp-map-plugin', // menu_slug
|
||||
'ljdp_map_plugin_content' // callback function to display page content
|
||||
|
||||
@@ -53,6 +53,8 @@ function mp_fill_name($fields, $name, &$menu, $index) {
|
||||
continue;
|
||||
if (! isset($menu_item->$key_field) )
|
||||
$menu_item->$key_field = [];
|
||||
if (!is_string($value))
|
||||
continue;
|
||||
if (strlen($value) != 0) {
|
||||
if (! in_array($value, $menu_item->$key_field) )
|
||||
array_push($menu_item->$key_field, $value);
|
||||
@@ -71,6 +73,8 @@ function mp_fill_name($fields, $name, &$menu, $index) {
|
||||
if ($key_field == $name)
|
||||
continue;
|
||||
$menu_item->$key_field = [];
|
||||
if (!is_string($value))
|
||||
continue;
|
||||
if (strlen($value) != 0)
|
||||
array_push($menu_item->$key_field, $value);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,8 @@ function mp_show_list_posts_no_address($posts) {
|
||||
echo ' (status: ';
|
||||
echo $post->post_status;
|
||||
echo ') - ';
|
||||
echo $post->mode[0];
|
||||
if (!empty($post->mode))
|
||||
echo $post->mode[0];
|
||||
echo ' : </b>';
|
||||
echo $post->post_title;
|
||||
echo <<<HTML
|
||||
@@ -128,7 +129,8 @@ function mp_show_list_posts_no_coordinates($posts) {
|
||||
echo ' (status: ';
|
||||
echo $post->post_status;
|
||||
echo ') - ';
|
||||
echo $post->mode[0];
|
||||
if (!empty($post->mode))
|
||||
echo $post->mode[0];
|
||||
echo ' : </b>';
|
||||
echo $post->post_title;
|
||||
echo <<<HTML
|
||||
@@ -229,7 +231,7 @@ function ljdp_map_plugin_content() {
|
||||
|
||||
echo <<<HTML
|
||||
<div>
|
||||
<h2>ljdp map plugin</h2>
|
||||
<h2>JIPF map plugin</h2>
|
||||
HTML;
|
||||
|
||||
mp_show_post_number($posts_list, $posts_published);
|
||||
@@ -239,8 +241,9 @@ function ljdp_map_plugin_content() {
|
||||
if (count($posts_no_address) > 0)
|
||||
mp_show_list_posts_no_address($posts_no_address);
|
||||
|
||||
if (count($posts_no_coordinates) > 0)
|
||||
if (count($posts_no_coordinates) > 0){
|
||||
mp_show_list_posts_no_coordinates($posts_no_coordinates);
|
||||
}
|
||||
else {
|
||||
echo <<<HTML
|
||||
<p style="color: green;">✔ tous les articles ont des coordonnees correctes :)</p>
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
function mp_get_address($id) {
|
||||
$presentiel = get_field("mode", $id);
|
||||
|
||||
if (empty($presentiel))
|
||||
return null;
|
||||
|
||||
// irl or online
|
||||
if ($presentiel[0] === "En présentiel")
|
||||
|
||||
Reference in New Issue
Block a user