change architecture of files
+ hide filter before css is loaded + fusion categories 'autre' and arrow + put categorie 'autre' at bottom of list
This commit is contained in:
@@ -31,9 +31,11 @@
|
|||||||
- [/] filtres sur chrome
|
- [/] filtres sur chrome
|
||||||
- [/] infowindow new design
|
- [/] infowindow new design
|
||||||
- [/] infowindow enlever scroll border
|
- [/] infowindow enlever scroll border
|
||||||
- [ ] reduire hauteur du select menu
|
- [ ] hide filters before css ready
|
||||||
|
- [x] reduire hauteur du select menu
|
||||||
- [ ] zoom sur cluster problem
|
- [ ] zoom sur cluster problem
|
||||||
- [ ] dans categories, placer "autres" en bas, et transformer fleches en "autres"
|
- [/] dans categories, placer "autres" en bas
|
||||||
|
- [/] dans categories, transformer fleches en "autres"
|
||||||
- [ ] effacer les fenetres, au moins sur le bouton effacer, ou sur mouvement
|
- [ ] effacer les fenetres, au moins sur le bouton effacer, ou sur mouvement
|
||||||
|
|
||||||
#### verifications:
|
#### verifications:
|
||||||
|
|||||||
@@ -16,53 +16,31 @@ Author URI:
|
|||||||
* inclusions :
|
* inclusions :
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include_once(dirname(__FILE__) . '/mp_console_log.php');
|
include_once(dirname(__FILE__) . '/utils/mp_console_log.php');
|
||||||
|
|
||||||
|
require_once(dirname(__FILE__) . '/mp_enqueue.php');
|
||||||
|
|
||||||
require_once(dirname(__FILE__) . '/settings/mp_required.php');
|
require_once(dirname(__FILE__) . '/settings/mp_required.php');
|
||||||
require_once(dirname(__FILE__) . '/settings/mp_optionnals.php');
|
require_once(dirname(__FILE__) . '/settings/mp_optionnals.php');
|
||||||
require_once(dirname(__FILE__) . '/settings/mp_globals.php');
|
require_once(dirname(__FILE__) . '/settings/mp_globals.php');
|
||||||
|
require_once(dirname(__FILE__) . '/settings/mp_url_api.php');
|
||||||
|
|
||||||
require_once(dirname(__FILE__) . '/mp_url_api.php');
|
require_once(dirname(__FILE__) . '/srcs/errors/mp_address_errors.php');
|
||||||
require_once(dirname(__FILE__) . '/mp_add_to_scripts.php');
|
|
||||||
require_once(dirname(__FILE__) . '/mp_get_coordinates.php');
|
|
||||||
require_once(dirname(__FILE__) . '/mp_get_events.php');
|
|
||||||
require_once(dirname(__FILE__) . '/mp_get_locations.php');
|
|
||||||
require_once(dirname(__FILE__) . '/mp_get_filters.php');
|
|
||||||
require_once(dirname(__FILE__) . '/mp_address_errors.php');
|
|
||||||
require_once(dirname(__FILE__) . '/mp_create_div.php');
|
|
||||||
|
|
||||||
|
require_once(dirname(__FILE__) . '/srcs/map/mp_add_to_scripts.php');
|
||||||
|
require_once(dirname(__FILE__) . '/srcs/map/mp_create_div.php');
|
||||||
|
require_once(dirname(__FILE__) . '/srcs/map/mp_get_events.php');
|
||||||
|
require_once(dirname(__FILE__) . '/srcs/map/mp_get_filters.php');
|
||||||
|
require_once(dirname(__FILE__) . '/srcs/map/mp_get_locations.php');
|
||||||
|
|
||||||
|
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');
|
||||||
|
|
||||||
// // temp test
|
|
||||||
//
|
|
||||||
// add_action( 'wp', 'my_front_end_function');
|
|
||||||
// function my_front_end_function() {
|
|
||||||
// if ( is_admin() )
|
|
||||||
// return;
|
|
||||||
// if ( get_post_type() != "post" )
|
|
||||||
// return;
|
|
||||||
// if ( get_post_status() != "publish" )
|
|
||||||
// return;
|
|
||||||
//
|
|
||||||
// $location = get_field(location);
|
|
||||||
// mp_console_log("location:");
|
|
||||||
// mp_console_log($location);
|
|
||||||
//
|
|
||||||
// $coordinates = $location->coordinates;
|
|
||||||
// mp_console_log("coordinates:");
|
|
||||||
// mp_console_log($coordinates);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function is_event_post() {
|
|
||||||
if ( is_admin() )
|
|
||||||
return false;
|
|
||||||
if ( get_post_type() != "post" )
|
|
||||||
return 0;
|
|
||||||
if ( get_post_status() != "publish" )
|
|
||||||
return 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -73,75 +51,21 @@ function is_event_post() {
|
|||||||
|
|
||||||
function mp_ljdp_map() {
|
function mp_ljdp_map() {
|
||||||
|
|
||||||
|
mp_enqueue_scripts_and_styles();
|
||||||
/* * * * * * * * * * * * * * *
|
|
||||||
* ENQUEUE SCRIPTS AND STYLES
|
|
||||||
*/
|
|
||||||
|
|
||||||
// https://developers.google.com/maps/documentation/javascript/marker-clustering
|
|
||||||
$marker_clusterer = "https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js";
|
|
||||||
|
|
||||||
wp_enqueue_style('mp__style', plugins_url('styles/mp__style.css', __FILE__), '', '', false);
|
|
||||||
|
|
||||||
// enqueue header
|
|
||||||
wp_enqueue_script('mp_info_window', plugins_url('scripts/mp_info_window.js', __FILE__), '', '', false);
|
|
||||||
wp_enqueue_script('mp_errors_map', plugins_url('scripts/mp_errors_map.js', __FILE__), '', '', false);
|
|
||||||
wp_enqueue_script('mp_create_filters', plugins_url('scripts/mp_create_filters.js', __FILE__), '', '', false);
|
|
||||||
wp_enqueue_script('mp_create_markers', plugins_url('scripts/mp_create_markers.js', __FILE__), '', '', false);
|
|
||||||
wp_enqueue_script('mp_create_map', plugins_url('scripts/mp_create_map.js', __FILE__), '', '', false);
|
|
||||||
wp_enqueue_script('mp_draw_clusters', plugins_url('scripts/mp_draw_clusters.js', __FILE__), '', '', false);
|
|
||||||
wp_enqueue_script('mp_filter_events', plugins_url('scripts/mp_filter_events.js', __FILE__), '', '', false);
|
|
||||||
|
|
||||||
// enqueue footer
|
|
||||||
wp_enqueue_script('mp_marker_clusterer', $marker_clusterer, '', '', true);
|
|
||||||
wp_enqueue_script('mp_init_map', plugins_url('scripts/mp_init_map.js', __FILE__), ['mp_marker_clusterer'],'', true);
|
|
||||||
wp_enqueue_script('mp_google_api', mp_url_api(), ['mp_init_map'], '', true);
|
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * *
|
|
||||||
* FIND LOCATIONS
|
|
||||||
*/
|
|
||||||
|
|
||||||
$events = mp_get_published_events();
|
$events = mp_get_published_events();
|
||||||
//mp_console_log("php events:");
|
|
||||||
//mp_console_log($events);
|
|
||||||
|
|
||||||
$locations = mp_sort_events($events);
|
$locations = mp_sort_events($events);
|
||||||
//mp_console_log("php locations:");
|
|
||||||
//mp_console_log($locations);
|
|
||||||
|
|
||||||
$filters = mp_get_filters($events);
|
$filters = mp_get_filters($events);
|
||||||
//mp_console_log("php filters:");
|
// if post event instead of map page, change coordinate and zoom
|
||||||
//mp_console_log($filters);
|
mp_post_event_pages_setting();
|
||||||
|
|
||||||
// if post event instead of map page, change ccoordinate and zoom
|
mp_add_to_scripts(array(
|
||||||
global $mp_zoom;
|
|
||||||
global $mp_zoom_set;
|
|
||||||
global $mp_coordinates_default;
|
|
||||||
if (is_event_post()) {
|
|
||||||
$mp_zoom = $mp_zoom_set[1];
|
|
||||||
|
|
||||||
$location = get_field("location");
|
|
||||||
$coordinates = $location->coordinates;
|
|
||||||
|
|
||||||
$mp_coordinates_default = $coordinates;
|
|
||||||
}
|
|
||||||
|
|
||||||
$to_add = array(
|
|
||||||
"locations" => $locations,
|
"locations" => $locations,
|
||||||
"filters" => $filters,
|
"filters" => $filters,
|
||||||
);
|
));
|
||||||
|
|
||||||
mp_add_to_scripts($to_add);
|
return mp_create_div($filters);
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * *
|
|
||||||
* ADD FILTERS
|
|
||||||
*/
|
|
||||||
|
|
||||||
$mp_map_div = mp_create_div($filters);
|
|
||||||
|
|
||||||
return $mp_map_div;
|
|
||||||
}
|
}
|
||||||
add_shortcode('lejourduprof_map', 'mp_ljdp_map');
|
add_shortcode('lejourduprof_map', 'mp_ljdp_map');
|
||||||
|
|
||||||
@@ -153,38 +77,8 @@ add_shortcode('lejourduprof_map', 'mp_ljdp_map');
|
|||||||
* re-publish posts
|
* re-publish posts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function mp_update_publish() {
|
|
||||||
$post_args = array(
|
|
||||||
'numberposts' => -1,
|
|
||||||
//'post_status' => 'draft',
|
|
||||||
'post_status' => 'publish',
|
|
||||||
'post_type' => 'post',
|
|
||||||
);
|
|
||||||
$post_list = get_posts($post_args);
|
|
||||||
foreach ($post_list as $post) {
|
|
||||||
wp_update_post(array(
|
|
||||||
'ID' => $post->ID,
|
|
||||||
//'post_status' => 'draft',
|
|
||||||
'post_status' => 'publish',
|
|
||||||
));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
add_action( 'admin_post_update_publish', 'mp_update_publish' );
|
|
||||||
add_action( 'admin_post_nopriv_update_publish', 'mp_update_publish' );
|
|
||||||
// https://developer.wordpress.org/reference/hooks/admin_post_action/
|
|
||||||
// https://wordpress.stackexchange.com/questions/309440/wordpress-plugin-how-to-run-function-when-button-is-clicked
|
|
||||||
function mp_add_update_button() {
|
function mp_add_update_button() {
|
||||||
$content = '
|
return mp_create_republish_button();
|
||||||
<br />
|
|
||||||
<p>cliquez sur ce bouton pour mettre a jour toutes les publications<p>
|
|
||||||
<p>une nouvelle page vide va s\'ouvrir dans un nouvel onglet, vous pouvez la fermer<p>
|
|
||||||
<form action="'.admin_url('admin-post.php').'" method="post" target="_blank">
|
|
||||||
<input type="hidden" name="action" value="update_publish">
|
|
||||||
<input type="submit" value="mettre a jour">
|
|
||||||
</form>
|
|
||||||
<br />
|
|
||||||
';
|
|
||||||
return $content;
|
|
||||||
}
|
}
|
||||||
add_shortcode('ljdp_update_publish', 'mp_add_update_button');
|
add_shortcode('ljdp_update_publish', 'mp_add_update_button');
|
||||||
|
|
||||||
|
|||||||
26
srcs/plugins/map_prof/mp_enqueue.php
Normal file
26
srcs/plugins/map_prof/mp_enqueue.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function mp_enqueue_scripts_and_styles() {
|
||||||
|
|
||||||
|
// https://developers.google.com/maps/documentation/javascript/marker-clustering
|
||||||
|
$marker_clusterer = "https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js";
|
||||||
|
|
||||||
|
wp_enqueue_style('mp__style', plugins_url('styles/mp__style.css' , __FILE__), '', '', false);
|
||||||
|
|
||||||
|
// enqueue header
|
||||||
|
wp_enqueue_script('mp_info_window', plugins_url('scripts/mp_info_window.js' , __FILE__), '', '', false);
|
||||||
|
wp_enqueue_script('mp_errors_map', plugins_url('scripts/mp_errors_map.js' , __FILE__), '', '', false);
|
||||||
|
wp_enqueue_script('mp_create_filters', plugins_url('scripts/mp_create_filters.js' , __FILE__), '', '', false);
|
||||||
|
wp_enqueue_script('mp_create_markers', plugins_url('scripts/mp_create_markers.js' , __FILE__), '', '', false);
|
||||||
|
wp_enqueue_script('mp_create_map', plugins_url('scripts/mp_create_map.js' , __FILE__), '', '', false);
|
||||||
|
wp_enqueue_script('mp_draw_clusters', plugins_url('scripts/mp_draw_clusters.js' , __FILE__), '', '', false);
|
||||||
|
wp_enqueue_script('mp_filter_events', plugins_url('scripts/mp_filter_events.js' , __FILE__), '', '', false);
|
||||||
|
|
||||||
|
// enqueue footer
|
||||||
|
wp_enqueue_script('mp_marker_clusterer', $marker_clusterer, '', '', true);
|
||||||
|
wp_enqueue_script('mp_init_map', plugins_url('scripts/mp_init_map.js' , __FILE__), ['mp_marker_clusterer'],'', true);
|
||||||
|
wp_enqueue_script('mp_google_api', mp_url_api(), ['mp_init_map'], '', true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -58,7 +58,7 @@ function mp_create_div(&$filters) {
|
|||||||
$mp_map_div = '
|
$mp_map_div = '
|
||||||
<div id="ljdp_map_wrapper">
|
<div id="ljdp_map_wrapper">
|
||||||
<form id="ljdp_form" style="display:none;"></form>
|
<form id="ljdp_form" style="display:none;"></form>
|
||||||
<div id="ljdp_map_filters">
|
<div id="ljdp_map_filters" style="display:none;">
|
||||||
';
|
';
|
||||||
|
|
||||||
foreach ($filters as $key => $filter) {
|
foreach ($filters as $key => $filter) {
|
||||||
@@ -115,7 +115,9 @@ function mp_fill_fields_value($id) {
|
|||||||
$event = (object)[];
|
$event = (object)[];
|
||||||
foreach($fields as $field) {
|
foreach($fields as $field) {
|
||||||
$value = get_field($field, $id);
|
$value = get_field($field, $id);
|
||||||
if (gettype($value) == "string")
|
if ($value === "↓")
|
||||||
|
$value = "Autre";
|
||||||
|
if (gettype($value) === "string")
|
||||||
$value = trim($value, " ");
|
$value = trim($value, " ");
|
||||||
$event->$field = $value;
|
$event->$field = $value;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function mp_filter_compare($a, $b) {
|
function mp_filter_compare($a, $b) {
|
||||||
return strcmp($a->_name, $b->_name);
|
|
||||||
|
$compare = strcmp($a->_name, $b->_name);
|
||||||
|
|
||||||
|
if ($a->_name === "Autre") {
|
||||||
|
if ($compare !== 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ($b->_name === "Autre") {
|
||||||
|
if ($compare !== 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $compare;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mp_already_in_menu(&$menu, $name) {
|
function mp_already_in_menu(&$menu, $name) {
|
||||||
@@ -14,12 +26,15 @@ function mp_already_in_menu(&$menu, $name) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* creates the menus
|
||||||
|
* from the events fields
|
||||||
|
* and add the index of the event as it is in location (events when they are sorted)
|
||||||
|
*
|
||||||
* fields: [ countries:"", cities:"", categories:"", ... ]
|
* fields: [ countries:"", cities:"", categories:"", ... ]
|
||||||
* name : field's values -> countries, cities, categories, ...
|
* name : field's values -> countries, cities, categories, ...
|
||||||
* menu : [ { _name:"", field_1:[], field_2:[] }, ... ]
|
* menu : [ { _name:"", field_1:[], field_2:[] }, ... ]
|
||||||
* index : index of this event in locations[] array
|
* index : index of this event in locations[] array
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function mp_fill_name($fields, $name, &$menu, $index) {
|
function mp_fill_name($fields, $name, &$menu, $index) {
|
||||||
if ($fields[$name] == null)
|
if ($fields[$name] == null)
|
||||||
return;
|
return;
|
||||||
@@ -85,10 +100,10 @@ function mp_get_filters(&$events) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// fill all menu with other menus without doubles
|
// fill all menu with other menus without doubles
|
||||||
foreach ($fields as $key => $value) {
|
foreach ($fields as $name => $value) {
|
||||||
if (! isset($filters->$key))
|
if (! isset($filters->$name))
|
||||||
$filters->$key = [];
|
$filters->$name = [];
|
||||||
mp_fill_name($fields, $key, $filters->$key, $index);
|
mp_fill_name($fields, $name, $filters->$name, $index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function is_event_post() {
|
||||||
|
if ( is_admin() )
|
||||||
|
return false;
|
||||||
|
if ( get_post_type() != "post" )
|
||||||
|
return 0;
|
||||||
|
if ( get_post_status() != "publish" )
|
||||||
|
return 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mp_post_event_pages_setting() {
|
||||||
|
global $mp_zoom;
|
||||||
|
global $mp_zoom_set;
|
||||||
|
global $mp_coordinates_default;
|
||||||
|
if (is_event_post()) {
|
||||||
|
$mp_zoom = $mp_zoom_set[1];
|
||||||
|
|
||||||
|
$location = get_field("location");
|
||||||
|
$coordinates = $location->coordinates;
|
||||||
|
|
||||||
|
$mp_coordinates_default = $coordinates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
44
srcs/plugins/map_prof/srcs/publish/mp_update_publish.php
Normal file
44
srcs/plugins/map_prof/srcs/publish/mp_update_publish.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function mp_update_publish() {
|
||||||
|
$post_args = array(
|
||||||
|
'numberposts' => -1,
|
||||||
|
//'post_status' => 'draft',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_type' => 'post',
|
||||||
|
);
|
||||||
|
$post_list = get_posts($post_args);
|
||||||
|
foreach ($post_list as $post) {
|
||||||
|
wp_update_post(array(
|
||||||
|
'ID' => $post->ID,
|
||||||
|
//'post_status' => 'draft',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
add_action( 'admin_post_update_publish', 'mp_update_publish' );
|
||||||
|
add_action( 'admin_post_nopriv_update_publish', 'mp_update_publish' );
|
||||||
|
|
||||||
|
// https://developer.wordpress.org/reference/hooks/admin_post_action/
|
||||||
|
// https://wordpress.stackexchange.com/questions/309440/wordpress-plugin-how-to-run-function-when-button-is-clicked
|
||||||
|
function mp_create_republish_button() {
|
||||||
|
$content = '
|
||||||
|
<br />
|
||||||
|
<div style="border:1px solid black;padding:20px;">
|
||||||
|
<h2>mettre a jour les publications</h2>
|
||||||
|
<p>
|
||||||
|
cliquez sur ce bouton pour mettre a jour toutes les publications
|
||||||
|
<br />
|
||||||
|
une nouvelle page vide va s\'ouvrir dans un nouvel onglet, vous pouvez la fermer
|
||||||
|
</p>
|
||||||
|
<form action="'.admin_url('admin-post.php').'" method="post" target="_blank">
|
||||||
|
<input type="hidden" name="action" value="update_publish">
|
||||||
|
<input type="submit" value="mettre a jour">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
';
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -3,15 +3,10 @@
|
|||||||
* FILTERS
|
* FILTERS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#ba197a;
|
#ba197a;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* **************************************
|
/* **************************************
|
||||||
GENERAL SETTINGS
|
GENERAL SETTINGS
|
||||||
*/
|
*/
|
||||||
@@ -27,6 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ljdp_map_filters {
|
#ljdp_map_filters {
|
||||||
|
display: flex !important;
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
@@ -60,6 +56,11 @@
|
|||||||
color: #666;
|
color: #666;
|
||||||
border: 1px solid #ba197a;
|
border: 1px solid #ba197a;
|
||||||
}
|
}
|
||||||
|
#ljdp_map_filters .filter_menu_drop option {
|
||||||
|
font-size: 100%;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user