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:
@@ -16,53 +16,31 @@ Author URI:
|
||||
* 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_optionnals.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__) . '/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/errors/mp_address_errors.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() {
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * *
|
||||
* 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
|
||||
*/
|
||||
mp_enqueue_scripts_and_styles();
|
||||
|
||||
$events = mp_get_published_events();
|
||||
//mp_console_log("php events:");
|
||||
//mp_console_log($events);
|
||||
|
||||
$locations = mp_sort_events($events);
|
||||
//mp_console_log("php locations:");
|
||||
//mp_console_log($locations);
|
||||
|
||||
$filters = mp_get_filters($events);
|
||||
//mp_console_log("php filters:");
|
||||
//mp_console_log($filters);
|
||||
// if post event instead of map page, change coordinate and zoom
|
||||
mp_post_event_pages_setting();
|
||||
|
||||
// if post event instead of map page, change ccoordinate and zoom
|
||||
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(
|
||||
mp_add_to_scripts(array(
|
||||
"locations" => $locations,
|
||||
"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');
|
||||
|
||||
@@ -153,38 +77,8 @@ add_shortcode('lejourduprof_map', 'mp_ljdp_map');
|
||||
* 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() {
|
||||
$content = '
|
||||
<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;
|
||||
return mp_create_republish_button();
|
||||
}
|
||||
add_shortcode('ljdp_update_publish', 'mp_add_update_button');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user