diff --git a/README.md b/README.md index 66f21ab..0e51162 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,13 @@ ## 1.2. todo +- [ ] create wp plugin menu +- [ ] add infos in menu + - [ ] gmaps api key + - [ ] missing addresses +- [ ] +- [ ] +- [ ] - [ ] ## 1.3. temps de travail @@ -115,9 +122,13 @@ - 21/09/23 - begin: 9h45 + - mes: "understand how custom fields works" + - end: 12h45 + - len: 3h00 + - begin: 15h15 - mes: "" - end: h - - len: h + - len: 3h - total: h - money: € diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php index a1f21e0..f2f1d0f 100644 --- a/srcs/plugins/map_prof/map_prof_hooks.php +++ b/srcs/plugins/map_prof/map_prof_hooks.php @@ -38,6 +38,8 @@ require_once(dirname(__FILE__) . '/srcs/map_posts/mp_post_events_pages.php'); require_once(dirname(__FILE__) . '/srcs/publish/mp_get_coordinates.php'); require_once(dirname(__FILE__) . '/srcs/publish/mp_update_publish.php'); +require_once(dirname(__FILE__) . '/srcs/menu/mp_menu_content.php'); + @@ -54,8 +56,8 @@ function mp_ljdp_map() { mp_enqueue_scripts_and_styles(); $events = mp_get_published_events(); // mp_get_events.php -// mp_console_log("events :"); -// mp_console_log($events); + mp_console_log("events :"); + mp_console_log($events); // foreach ($events as $event) { // mp_console_log("--------------- event :"); // mp_console_log("id: " . $event->id); @@ -95,10 +97,11 @@ add_shortcode('lejourduprof_map', 'mp_ljdp_map'); * re-publish posts */ -function mp_add_update_button() { - return mp_create_republish_button(); -} -add_shortcode('ljdp_update_publish', 'mp_add_update_button'); +// function mp_add_update_button() { +// return mp_create_republish_button(); +// } +// add_shortcode('ljdp_update_publish', 'mp_add_update_button'); + @@ -121,14 +124,35 @@ add_shortcode('ljdp_errors_map', 'mp_errors_map'); * find its coordinates */ -// function post_published_coordinates($id, $post) { -// -// $location = mp_get_coordinates($id); -// -// if ( ! add_post_meta( $id, 'location', $location, true ) ) -// update_post_meta( $id, 'location', $location ); -// -// } -// add_action( 'publish_post', 'post_published_coordinates', 10, 2 ); +function post_published_coordinates($id, $post) { + + $location = mp_get_coordinates($id); + mp_console_log("location: "); + mp_console_log($location); + +// if ( ! add_post_meta( $id, 'location', $location, true ) ) +// update_post_meta( $id, 'location', $location ); + +} +add_action( 'publish_post', 'post_published_coordinates', 10, 2 ); + + + + + +/** + * menu plugin + */ + +function ljdp_map_menu() { + add_menu_page( + 'ljdp map', // page_title + 'ljdp map', // menu_title + 'manage_options', // capability + 'ljdp-map-plugin', // menu_slug + 'ljdp_map_plugin_content' // callback function to display page content + ); +} +add_action('admin_menu', 'ljdp_map_menu'); ?> diff --git a/srcs/plugins/map_prof/srcs/map/mp_get_events.php b/srcs/plugins/map_prof/srcs/map/mp_get_events.php index ff98e7f..dad16c4 100644 --- a/srcs/plugins/map_prof/srcs/map/mp_get_events.php +++ b/srcs/plugins/map_prof/srcs/map/mp_get_events.php @@ -143,32 +143,32 @@ function mp_fill_fields_value($id) { function mp_get_published_events() { $posts_list = mp_get_published_posts(); - mp_console_log("posts :"); - mp_console_log($posts_list); - foreach ($posts_list as $post) { - mp_console_log("--------------- post :"); - $id = $post->ID; - mp_console_log("id: " . $id); +// mp_console_log("posts :"); +// mp_console_log($posts_list); +// foreach ($posts_list as $post) { +// mp_console_log("--------------- post :"); +// $id = $post->ID; +// mp_console_log("id: " . $id); // mp_console_log("adresse: " . $event->adresse); // mp_console_log("pays: " . $event->pays); // mp_console_log("ville: " . $event->ville); // mp_console_log("irl: " . $event->irl); // mp_console_log($event); // - $fields = get_fields($id); - mp_console_log("fields:"); - mp_console_log($fields); - $field_heure = get_field("heure_de_debut", $id); - mp_console_log("field_heure: " . $field_heure); - $post_metas = get_post_meta($id); - mp_console_log("post_metas:"); - mp_console_log($post_metas); - $post_custom = get_post_custom($id); - mp_console_log("post_custom:"); - mp_console_log($post_custom); +// $fields = get_fields($id); +// mp_console_log("fields:"); +// mp_console_log($fields); +// $field_heure = get_field("heure_de_debut", $id); +// mp_console_log("field_heure: " . $field_heure); +// $post_metas = get_post_meta($id); +// mp_console_log("post_metas:"); +// mp_console_log($post_metas); +// $post_custom = get_post_custom($id); +// mp_console_log("post_custom:"); +// mp_console_log($post_custom); // foreach( $fields as $name => $value ) // mp_console_log($name . " : " . $value); - } +// } $events = []; foreach ($posts_list as $post) { diff --git a/srcs/plugins/map_prof/srcs/menu/mp_menu_content.php b/srcs/plugins/map_prof/srcs/menu/mp_menu_content.php new file mode 100644 index 0000000..3950b2d --- /dev/null +++ b/srcs/plugins/map_prof/srcs/menu/mp_menu_content.php @@ -0,0 +1,91 @@ + -1, + 'post_type' => 'post', + ); + $posts_list = get_posts($get_posts_args); + + return $posts_list; +} + + + +function mp_have_address($posts_list) { + + $posts_no_address = []; + foreach ($posts_list as $post) { + $address = mp_get_address($post->ID); + if (empty($address)) + array_push($posts_no_address, $post); + } + return $posts_no_address; +} + + + +function mp_show_list_posts_no_address($posts) { + + echo << +

+ ATTENTION ! +

+

+ + HTML; + echo count($posts); + echo << + articles n'ont pas d'adresse : +

+