Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdba54cdb7 | ||
|
|
11270c5e69 | ||
|
|
cab7757043 | ||
|
|
8b024074f1 | ||
|
|
9a259a93ca | ||
|
|
f53faf934b | ||
|
|
3d765cd3bd | ||
|
|
47dcaad60f |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -51,6 +51,3 @@ Thumbs.db
|
||||
|
||||
# ssl certificates
|
||||
ssl/
|
||||
|
||||
# others
|
||||
volumes/
|
||||
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,6 +0,0 @@
|
||||
[submodule "private"]
|
||||
path = private
|
||||
url = git@bitbucket.org:hugogogo/2023_website_jipf_private.git
|
||||
[submodule "wordpress_docker"]
|
||||
path = wordpress_docker
|
||||
url = git@bitbucket.org:hugogogo/docker_wordpress.git
|
||||
119
Makefile
119
Makefile
@@ -1,12 +1,47 @@
|
||||
|
||||
GRAY := "\e[0;30m"
|
||||
RED := "\e[0;31m"
|
||||
GREEN := "\e[0;32m"
|
||||
YELLOW := "\e[0;33m"
|
||||
BLUE := "\e[0;34m"
|
||||
PURPLE := "\e[0;35m"
|
||||
CYAN := "\e[0;36m"
|
||||
WHITE := "\e[0;37m"
|
||||
|
||||
B_GRAY := "\e[1;30m"
|
||||
B_RED := "\e[1;31m"
|
||||
B_GREEN := "\e[1;32m"
|
||||
B_YELLOW := "\e[1;33m"
|
||||
B_BLUE := "\e[1;34m"
|
||||
B_PURPLE := "\e[1;35m"
|
||||
B_CYAN := "\e[1;36m"
|
||||
B_WHITE := "\e[1;37m"
|
||||
|
||||
RESET := "\e[0m"
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
# . name = value \ . += append to a variable #
|
||||
# . name = value \ . := no reevaluat when used #
|
||||
# VARIABLES . value . != set result of command #
|
||||
# . name is case sensitive . ?= set if not already set #
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
|
||||
WP_DOCKER = ./wordpress_docker
|
||||
COMPOSE_FILE := ./srcs/docker-compose.yml
|
||||
ENV_PATH := ./srcs/.env
|
||||
|
||||
# get env variables from .env file :
|
||||
SOURCE_ENV := . $(ENV_PATH)
|
||||
# list of volumes
|
||||
VOLUME_ENV := set | grep "^HOST_VOLUME_" | cut -d "=" -f 2
|
||||
VOLUMES_D = $(shell $(SOURCE_ENV) ; $(VOLUME_ENV) )
|
||||
# url for wordpress, use in makefile to change local
|
||||
WP_URL = $(shell $(SOURCE_ENV) ; echo $$WP_URL )
|
||||
WP_COMPLETE_URL = $(shell $(SOURCE_ENV) ; echo $$WP_COMPLETE_URL )
|
||||
|
||||
# list of running containers, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile
|
||||
RUNNING := $(shell docker ps -q)
|
||||
# list of volumes
|
||||
VOLUMES := $(shell docker volume ls -q)
|
||||
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
@@ -16,21 +51,77 @@ WP_DOCKER = ./wordpress_docker
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
|
||||
|
||||
all:
|
||||
$(MAKE) $@ -C $(WP_DOCKER)
|
||||
all: require build up
|
||||
logs: require build_logs up
|
||||
|
||||
fclean:
|
||||
$(MAKE) $@ -C $(WP_DOCKER)
|
||||
require:
|
||||
# create .env file
|
||||
@echo $(B_PURPLE)"create the .env file"$(RESET)
|
||||
./srcs/env_generator/create_env.sh ./srcs/model.env
|
||||
# create the volumes directories
|
||||
@echo $(B_PURPLE)"create the volumes directories"$(RESET)
|
||||
mkdir -p $(VOLUMES_D)
|
||||
# verify if the wordpress url is added to the local path
|
||||
@echo $(B_PURPLE)"verify if the wordpress url is added to the local path"$(RESET)
|
||||
-@ if ! awk "/127.0.0.1/ && /$(WP_URL)/" /etc/hosts 2> /dev/null; then \
|
||||
echo $(B_PURPLE)"nop ! trying to add it (might need sudo)"$(RESET); \
|
||||
bash -c 'echo -e "\n adding for lejourduprof (you can delete it)\n127.0.0.1 $(WP_URL)" >> /etc/hosts'; \
|
||||
if ! awk "/127.0.0.1/ && /$(WP_URL)/" /etc/hosts 2> /dev/null; then \
|
||||
echo $(B_RED)"it didn't succeed :/ try again with sudo"$(RESET); \
|
||||
else \
|
||||
echo $(B_GREEN)"it has been succesfully added :)"$(RESET); \
|
||||
fi \
|
||||
fi
|
||||
|
||||
re:
|
||||
$(MAKE) $@ -C $(WP_DOCKER)
|
||||
build:
|
||||
docker compose -f $(COMPOSE_FILE) build
|
||||
# --progress plain : everything will be output at build time, you can see commands like "echo" or "ls" in RUN command in dockerfile
|
||||
# --no-cache : this will prevent builder to use previous cached action, so it rebuild everything
|
||||
build_logs:
|
||||
docker compose -f $(COMPOSE_FILE) build --progress plain --no-cache
|
||||
|
||||
up:
|
||||
docker compose -f $(COMPOSE_FILE) up -d
|
||||
@echo $(B_PURPLE)"you can now connect at "$(B_YELLOW)"https://$(WP_COMPLETE_URL)"$(B_PURPLE)" or 127.0.0.1"$(RESET)
|
||||
|
||||
down:
|
||||
docker compose -f $(COMPOSE_FILE) down
|
||||
|
||||
# list images, containers, volumes
|
||||
list:
|
||||
@echo $(B_YELLOW)"\nimages:"$(RESET)
|
||||
@docker images -a
|
||||
@echo $(B_YELLOW)"\nvolumes:"$(RESET)
|
||||
@docker volume ls
|
||||
@echo $(B_YELLOW)"\nvolumes content:"$(RESET)
|
||||
- @ls $(VOLUMES_D)
|
||||
@echo $(B_YELLOW)"\nnetworks:"$(RESET)
|
||||
@docker network ls
|
||||
@echo $(B_YELLOW)"\ncontainers:"$(RESET)
|
||||
@docker ps -a
|
||||
@echo ""
|
||||
|
||||
# remove project images and containers not used
|
||||
clean:
|
||||
- docker stop $(RUNNING)
|
||||
docker network prune -f
|
||||
docker system prune -f
|
||||
|
||||
# remove everything except local volumes data
|
||||
fclean-images: clean
|
||||
- docker stop $(RUNNING)
|
||||
docker system prune -af
|
||||
fclean-volumes: clean
|
||||
- docker volume rm $(VOLUMES)
|
||||
fclean: fclean-images fclean-volumes
|
||||
|
||||
re: fclean all
|
||||
|
||||
# !! remove everything everything
|
||||
erase:
|
||||
$(MAKE) $@ -C $(WP_DOCKER)
|
||||
- rm -rf $(VOLUMES_D)
|
||||
$(MAKE) fclean
|
||||
new: erase $(NAME)
|
||||
|
||||
new:
|
||||
$(MAKE) $@ -C $(WP_DOCKER)
|
||||
|
||||
|
||||
.PHONY : all fclean re erase new
|
||||
.PHONY : all $(VOLUMES_D) require build up list clean fclean re erase new require
|
||||
|
||||
|
||||
309
README.md
309
README.md
@@ -1,39 +1,308 @@
|
||||
# jipf 2023
|
||||
debug :
|
||||
- **docker ps** : to see all the containers running
|
||||
- **docker logs <container name>** : to see if there is logs of errors
|
||||
|
||||
### install
|
||||
---
|
||||
|
||||
this project uses submodules recursively, so you after cloning you need to :
|
||||
# toc :
|
||||
|
||||
`git submodule update --init --recursive`
|
||||
- 1. MAP
|
||||
- 1.1. v2 2023
|
||||
- 1.2. todo
|
||||
- 1.3. temps de travail
|
||||
- 2. docker
|
||||
- 2.1. install docker
|
||||
- 2.2. docker ressources
|
||||
- 3. old versions
|
||||
- 3.1. v1 2022
|
||||
- 3.1.1. todo
|
||||
- 3.1.2. verifications
|
||||
- 3.1.3. improvement suggestions
|
||||
- 3.1.4. questions traitees
|
||||
- 3.1.5. todo
|
||||
|
||||
|
||||
### presentation
|
||||
---
|
||||
|
||||
- this repo is a plugin for wordpress, designed to be used inside a specific website : [2022.lejourdesprofs.org](https://2022.lejourdesprofs.org/#programme)
|
||||
- this is a website for an event, that took place in november 2022, and was proposing hundreds of speakers all around the world
|
||||
- and this plugin generates a map, based on google maps, with markers that places every speach
|
||||
- it allows for filters and selections
|
||||
- I made a script that goes through all posts each time the map is loaded,
|
||||
extracts the right info, creates the "locations" object as a global variable,
|
||||
and serves it to the front end js. It also get the coordinates, but only
|
||||
when a post is published, and it adds them in the meta field of the post
|
||||
- that's absurd, all the info should be added to the meta field, and only
|
||||
reevaluated when post is saved or change status
|
||||
- I made a rapid check of some errors in plugin menu, but that would be much
|
||||
better to add the errors to a common place, maybe a post meta fiel, during
|
||||
the processing of the data
|
||||
|
||||
|
||||
### how the markers colapse and multiply with zoom
|
||||
---
|
||||
|
||||

|
||||
# 1. MAP
|
||||
|
||||
## 1.1. v2 2023
|
||||
|
||||
## 1.2. todo
|
||||
|
||||
- [/] create wp plugin menu
|
||||
- [/] add infos in menu
|
||||
- [/] gmaps api key
|
||||
- [/] missing addresses
|
||||
- [/] error strlen
|
||||
- [/] add counter
|
||||
- [/] menu select published posts
|
||||
- [/] menu show error format in categories
|
||||
|
||||
## 1.3. temps de travail
|
||||
|
||||
30€/h * 8h = 240€/j
|
||||
|
||||
- 03/09/23
|
||||
- begin: 14h30
|
||||
- mes: "setting up docker"
|
||||
- end: 16h00
|
||||
- len: 1h30
|
||||
- begin: 16h30
|
||||
- mes: "launch worpdress"
|
||||
- end: 18h00
|
||||
- len: 1h30
|
||||
- total: 3h00
|
||||
- money: 90€
|
||||
|
||||
- 09/09/23
|
||||
- begin: 16h30
|
||||
- mes: "trying to copy wp site"
|
||||
- end: 17h30
|
||||
- len: 1h00
|
||||
- total: 1h00
|
||||
- money: 30€
|
||||
|
||||
- 10/09/23
|
||||
- begin: 10h00
|
||||
- mes: "trying to fix makefile and .env volume variable"
|
||||
- end: 12h00
|
||||
- len: 2h00
|
||||
- total: 2h00
|
||||
- money: 60€
|
||||
|
||||
- 11/09/23
|
||||
- begin: 10h00
|
||||
- mes: "fixed volume variable"
|
||||
- end: 13h30
|
||||
- len: 3h30
|
||||
- total: 3h30
|
||||
- money: 105€
|
||||
|
||||
- 12/09/23
|
||||
- begin: 9h30
|
||||
- mes: "resolve some env var pbm"
|
||||
- end: 12h15
|
||||
- len: 2h45
|
||||
- total: 2h45
|
||||
- money: 82€50
|
||||
|
||||
- 14/09/23
|
||||
- begin: 11h30
|
||||
- mes: "resolve env pbm with sudo"
|
||||
- end: 12h00
|
||||
- len: 0h30
|
||||
- begin: 13h00
|
||||
- mes: "env pbm with sudo resolved"
|
||||
- end: 13h45
|
||||
- len: 0h45
|
||||
- begin: 13h45
|
||||
- mes: "launch process duplicator"
|
||||
- end: 14h30
|
||||
- len: 0h45
|
||||
- begin: 14h45
|
||||
- mes: "copy site duplicator"
|
||||
- end: 15h30
|
||||
- len: 0h45
|
||||
- total: 2h45
|
||||
- money: 82€50
|
||||
|
||||
- 18/09/23
|
||||
- begin: 10h00
|
||||
- mes: "rediscover plugin"
|
||||
- end: 12h00
|
||||
- len: 2h00
|
||||
- begin: 13h00
|
||||
- mes: "try to get acf fields"
|
||||
- end: 15h45
|
||||
- len: 2h45
|
||||
- total: 4h45
|
||||
- money: 142€50
|
||||
|
||||
- 20/09/23
|
||||
- begin: 14h00
|
||||
- mes: "pbm api keys and acf7 form"
|
||||
- end: 15h30
|
||||
- len: 1h30
|
||||
- total: 1h30
|
||||
- money: 45€
|
||||
|
||||
- 21/09/23
|
||||
- begin: 9h45
|
||||
- mes: "understand how custom fields works"
|
||||
- end: 12h45
|
||||
- len: 3h00
|
||||
- begin: 15h15
|
||||
- mes: "create plugin menu"
|
||||
- end: 19h30
|
||||
- len: 4h15
|
||||
- total: 7h15
|
||||
- money: 217€50
|
||||
|
||||
- 21/09/23
|
||||
- begin: 11h30
|
||||
- mes: ""
|
||||
- end: h
|
||||
- len: h
|
||||
- total: h
|
||||
- money: €
|
||||
|
||||
|
||||
### how the filters allow for selection
|
||||
#### total : 90 + 30 = 120€
|
||||
|
||||
## 1.4. duplicator wordpress
|
||||
|
||||
- https://duplicator.com/knowledge-base/classic-install/
|
||||
- installer.php has two errors :
|
||||
- delete first blank line
|
||||
- close last line comment
|
||||
|
||||
---
|
||||
|
||||

|
||||
# 2. docker :
|
||||
|
||||
## 2.1. install docker
|
||||
|
||||
- [install docker engine](https://docs.docker.com/engine/install/ubuntu/)
|
||||
- [uninstall docker engine](https://docs.docker.com/engine/install/ubuntu/#uninstall-docker-engine)
|
||||
- [docker engine vs docker desktop](https://docs.docker.com/desktop/faqs/linuxfaqs/#what-is-the-difference-between-docker-desktop-for-linux-and-docker-engine)
|
||||
- [manage docker as non root user](https://docs.docker.com/engine/install/linux-postinstall/)
|
||||
|
||||
## 2.2. docker ressources
|
||||
|
||||
- [docker compose man](https://docs.docker.com/compose/compose-file/#volumes)
|
||||
- [Dockerfile man](https://docs.docker.com/engine/reference/builder/)
|
||||
- [determine the parent image](https://forums.docker.com/t/determine-the-parent-image/48611)
|
||||
- [docker image from scratch](https://codeburst.io/docker-from-scratch-2a84552470c8)
|
||||
- [build context and image context](https://stackoverflow.com/questions/55108649/what-is-app-working-directory-for-a-dockerfile/55109065#55109065)
|
||||
- [run without sudo on linux](https://docs.docker.com/engine/install/linux-postinstall/)
|
||||
- [run docker deamon rootless](https://docs.docker.com/engine/security/rootless/)
|
||||
- [dangling images '<none>'](https://projectatomic.io/blog/2015/07/what-are-docker-none-none-images/)
|
||||
- [go inside docker to debug it](https://docs.docker.com/engine/reference/commandline/container_exec/)
|
||||
- [docker debug image with "docker run -it"](https://blog.devgenius.io/how-to-debug-docker-build-6c2588401188)
|
||||
- `docker exec -ti <container-name> bash` to run bash inside a running container
|
||||
- [docker CMD vs ENTRYPOINT](https://phoenixnap.com/kb/docker-cmd-vs-entrypoint)
|
||||
- [use env variable with compose](https://docs.docker.com/compose/environment-variables/)
|
||||
- [using DEBIAN_FRONTEND=noninteractive disouraged in dockerfile](https://bobcares.com/blog/debian_frontendnoninteractive-docker/)
|
||||
- [docker network](https://docs.docker.com/network/)
|
||||
- [depends_on](https://docs.docker.com/compose/compose-file/#depends_on)
|
||||
- [compose and env var](https://docs.docker.com/compose/environment-variables/)
|
||||
- [specify path to named volumes](https://docs.docker.com/compose/compose-file/#volumes-top-level-element)
|
||||
- [pass secret to container](https://medium.com/@zdk/simple-and-secure-way-to-pass-secrets-and-credentials-into-docker-containers-c2f66175b0a4)
|
||||
|
||||
|
||||
### technologie
|
||||
---
|
||||
|
||||
- wordpress backend
|
||||
- php
|
||||
- vanilla javascript front-end
|
||||
- google maps api
|
||||
# 3. old versions
|
||||
|
||||
## 3.1. v1 2022
|
||||
|
||||
### 3.1.1. todo
|
||||
|
||||
- [/] copy recent site version
|
||||
- [/] create links
|
||||
- [/] make links having map
|
||||
- [/] transform filter list in inputs
|
||||
- [/] zoom in
|
||||
- [/] style input filters
|
||||
- [x] enlever le bandeau de scroll des menus
|
||||
- [/] effacer -> bouton carre, fond violet, ecriture blanche, en capitale, arrondis de 3px sur les coins
|
||||
- [/] ne pas ouvrir sur un nouvel onglet
|
||||
- [/] "effacer" au lieu de "sans filtre"
|
||||
- [/] accents et majuscules : "Effacer", "Pays" et "Categories"
|
||||
- [/] responsive
|
||||
- pays
|
||||
- categories
|
||||
- irl / online
|
||||
- effacer
|
||||
- [/] sur ordi carte hauteur 600px, sur telephone 500px
|
||||
- [/] make two infowindow size
|
||||
- [/] infowindow with date in background color purple, and croice white
|
||||
- [/] check errors on real site
|
||||
- [/] create action to publish all
|
||||
- [/] deal with multiplication of filters
|
||||
- [/] deal with window size
|
||||
- [/] la carte ne s'affiche pas sur les pages
|
||||
- [/] filtres sur chrome
|
||||
- [/] infowindow new design
|
||||
- [/] infowindow enlever scroll border
|
||||
|
||||
- [/] hide filters before css ready
|
||||
- [x] reduire hauteur du select menu
|
||||
- [/] dans categories, placer "autres" en bas
|
||||
- [/] dans categories, transformer fleches en "autres"
|
||||
- [/] effacer les fenetres, au moins sur le bouton effacer, ou sur mouvement
|
||||
- [/] zoom sur cluster problem
|
||||
- [/] transform names without space
|
||||
- [/] change appearance of filter according to other filters
|
||||
- [/] change title of select options that appears on cursor hover
|
||||
- [ ] deal with error double event irl and online
|
||||
|
||||
### 3.1.2. verifications:
|
||||
|
||||
- api only for this site on fabien's google account
|
||||
- erased tmp css on site headers
|
||||
|
||||
### 3.1.3. improvement suggestions:
|
||||
|
||||
- add a field "more infos" to address
|
||||
- localise on map when form is filled
|
||||
|
||||
### 3.1.4. questions traitees:
|
||||
|
||||
- zoom : toujours zoomer, pour un seul marqueur pas trop, et enlever les villes
|
||||
- resoudre probleme mauvais markers de pays
|
||||
- faire un bouton select (afficher la seletion plutot que le nom du menu)
|
||||
|
||||
- bound la carte limite pour ne pas voir la zone grise
|
||||
- quelles infos on mets dans les infowindow
|
||||
- adresse en haut (surtout pour les markers avec plusieurs evenements)
|
||||
- filtres: au dessus de la carte
|
||||
- zoom : on reste avec le fonctionnement par defaut
|
||||
- est-ce qu'on peut changer la phrase "ctrl + scroll" pour un truc en francais ?
|
||||
- comment gerer les mauvaises adresses
|
||||
- verifier la maniere dont je les recuperes, tous les posts devraient avoir un pays
|
||||
- comportement des infowindows
|
||||
- centrees, c nickel
|
||||
- markers avec plusieurs evenements a la meme adresse
|
||||
- utiliser uniquement les markers qui servent actuellement pour les clusters
|
||||
- quand c'est un cluster, on zoom,
|
||||
- quand c'est plusieurs evenements au meme endroit, on les affiche
|
||||
|
||||
### 3.1.5. todo:
|
||||
|
||||
- add info-window
|
||||
- add filter options
|
||||
- deal with bad address
|
||||
- redsign + and - for zoom -> color and thickness
|
||||
- how to put the map on other pages
|
||||
- how to send plugin to fabien
|
||||
- [changed plugin directory in wp](https://wordpress.stackexchange.com/questions/120075/how-to-change-location-of-the-plugins-wordpress-themes-folder)
|
||||
- googlemap api key : AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE
|
||||
- [discussion on googlemap wp implementation](https://wordpress.org/support/topic/google-maps-where-to-place-api-key/)
|
||||
- [exemple of googlemap plugin creation](https://www.inkthemes.com/implement-google-map-plugin-for-wordpress/)
|
||||
- [Error: not a valid JSON response](https://wordpress.org/support/topic/publishing-failed-error-message-the-response-is-not-a-valid-json-response-2/)
|
||||
- [permalink broken](https://wordpress.org/support/topic/permalinks-change-breaks-all-links/)
|
||||
- [console.log in php](https://stackify.com/how-to-log-to-console-in-php/)
|
||||
- [plugins_url with symlink pbm](https://wordpress.stackexchange.com/questions/102681/plugins-url-file-wp-plugin-url-with-sym-links)
|
||||
- [make nginx follow symlinks](https://unix.stackexchange.com/questions/157022/make-nginx-follow-symlinks)
|
||||
- [nginx not following symlink maybe due to permissions](https://stackoverflow.com/questions/12624358/nginx-not-following-symlinks)
|
||||
- [symlink pbm with php-fpm](https://joshtronic.com/2019/07/29/symlinks-with-nginx-and-php-fpm/)
|
||||
- [my post on unix stack](https://unix.stackexchange.com/questions/722503/symlink-doent-works-with-nginx-and-php-fpm-and-docker/722511#722511)
|
||||
- [my post on wordpress stack](https://wordpress.stackexchange.com/questions/410735/i-dont-understand-how-symlinks-in-plugin-work)
|
||||
- [maps api in php](http://www.learningaboutelectronics.com/Articles/Google-maps-API-JSON-PHP.php)
|
||||
- [google maps api url parameters](https://developers.google.com/maps/documentation/javascript/url-params)
|
||||
- [google maps api references](https://developers.google.com/maps/documentation/javascript/reference)
|
||||
- [remove marker cluster](https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html#removeMarker)
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.4 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 10 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.2 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 855 KiB |
305
notes.md
305
notes.md
@@ -1,24 +1,303 @@
|
||||
# toc :
|
||||
|
||||
### infos
|
||||
- 1. MAP
|
||||
- 1.1. v2 2023
|
||||
- 1.2. todo
|
||||
- 1.3. temps de travail
|
||||
- 2. docker
|
||||
- 2.1. install docker
|
||||
- 2.2. docker ressources
|
||||
- 3. old versions
|
||||
- 3.1. v1 2022
|
||||
- 3.1.1. todo
|
||||
- 3.1.2. verifications
|
||||
- 3.1.3. improvement suggestions
|
||||
- 3.1.4. questions traitees
|
||||
- 3.1.5. todo
|
||||
|
||||
- need acf installed on wp to work, because it uses the acf function `get_field()`
|
||||
---
|
||||
|
||||
### duplicator wordpress
|
||||
- I made a script that goes through all posts each time the map is loaded,
|
||||
extracts the right info, creates the "locations" object as a global variable,
|
||||
and serves it to the front end js. It also get the coordinates, but only
|
||||
when a post is published, and it adds them in the meta field of the post
|
||||
- that's absurd, all the info should be added to the meta field, and only
|
||||
reevaluated when post is saved or change status
|
||||
- I made a rapid check of some errors in plugin menu, but that would be much
|
||||
better to add the errors to a common place, maybe a post meta fiel, during
|
||||
the processing of the data
|
||||
|
||||
---
|
||||
|
||||
# 1. MAP
|
||||
|
||||
## 1.1. v2 2023
|
||||
|
||||
## 1.2. todo
|
||||
|
||||
- [/] create wp plugin menu
|
||||
- [/] add infos in menu
|
||||
- [/] gmaps api key
|
||||
- [/] missing addresses
|
||||
- [/] error strlen
|
||||
- [/] add counter
|
||||
- [/] menu select published posts
|
||||
- [/] menu show error format in categories
|
||||
|
||||
## 1.3. temps de travail
|
||||
|
||||
30€/h * 8h = 240€/j
|
||||
|
||||
- 03/09/23
|
||||
- begin: 14h30
|
||||
- mes: "setting up docker"
|
||||
- end: 16h00
|
||||
- len: 1h30
|
||||
- begin: 16h30
|
||||
- mes: "launch worpdress"
|
||||
- end: 18h00
|
||||
- len: 1h30
|
||||
- total: 3h00
|
||||
- money: 90€
|
||||
|
||||
- 09/09/23
|
||||
- begin: 16h30
|
||||
- mes: "trying to copy wp site"
|
||||
- end: 17h30
|
||||
- len: 1h00
|
||||
- total: 1h00
|
||||
- money: 30€
|
||||
|
||||
- 10/09/23
|
||||
- begin: 10h00
|
||||
- mes: "trying to fix makefile and .env volume variable"
|
||||
- end: 12h00
|
||||
- len: 2h00
|
||||
- total: 2h00
|
||||
- money: 60€
|
||||
|
||||
- 11/09/23
|
||||
- begin: 10h00
|
||||
- mes: "fixed volume variable"
|
||||
- end: 13h30
|
||||
- len: 3h30
|
||||
- total: 3h30
|
||||
- money: 105€
|
||||
|
||||
- 12/09/23
|
||||
- begin: 9h30
|
||||
- mes: "resolve some env var pbm"
|
||||
- end: 12h15
|
||||
- len: 2h45
|
||||
- total: 2h45
|
||||
- money: 82€50
|
||||
|
||||
- 14/09/23
|
||||
- begin: 11h30
|
||||
- mes: "resolve env pbm with sudo"
|
||||
- end: 12h00
|
||||
- len: 0h30
|
||||
- begin: 13h00
|
||||
- mes: "env pbm with sudo resolved"
|
||||
- end: 13h45
|
||||
- len: 0h45
|
||||
- begin: 13h45
|
||||
- mes: "launch process duplicator"
|
||||
- end: 14h30
|
||||
- len: 0h45
|
||||
- begin: 14h45
|
||||
- mes: "copy site duplicator"
|
||||
- end: 15h30
|
||||
- len: 0h45
|
||||
- total: 2h45
|
||||
- money: 82€50
|
||||
|
||||
- 18/09/23
|
||||
- begin: 10h00
|
||||
- mes: "rediscover plugin"
|
||||
- end: 12h00
|
||||
- len: 2h00
|
||||
- begin: 13h00
|
||||
- mes: "try to get acf fields"
|
||||
- end: 15h45
|
||||
- len: 2h45
|
||||
- total: 4h45
|
||||
- money: 142€50
|
||||
|
||||
- 20/09/23
|
||||
- begin: 14h00
|
||||
- mes: "pbm api keys and acf7 form"
|
||||
- end: 15h30
|
||||
- len: 1h30
|
||||
- total: 1h30
|
||||
- money: 45€
|
||||
|
||||
- 21/09/23
|
||||
- begin: 9h45
|
||||
- mes: "understand how custom fields works"
|
||||
- end: 12h45
|
||||
- len: 3h00
|
||||
- begin: 15h15
|
||||
- mes: "create plugin menu"
|
||||
- end: 19h30
|
||||
- len: 4h15
|
||||
- total: 7h15
|
||||
- money: 217€50
|
||||
|
||||
- 21/09/23
|
||||
- begin: 11h30
|
||||
- mes: ""
|
||||
- end: h
|
||||
- len: h
|
||||
- total: h
|
||||
- money: €
|
||||
|
||||
|
||||
#### total : 90 + 30 = 120€
|
||||
|
||||
## 1.4. duplicator wordpress
|
||||
|
||||
- https://duplicator.com/knowledge-base/classic-install/
|
||||
- installer.php has two errors :
|
||||
- delete first blank line
|
||||
- close last line comment
|
||||
1. download .zip and installer.php
|
||||
2. put them on the server :
|
||||
- in an empty file, accessible with url
|
||||
- then go to this file with url, and go to installer.php
|
||||
- in the steps you have to inform a database
|
||||
- use a new database, because it will erase everything
|
||||
- use localhost for the host, i dont know why
|
||||
|
||||
### commands
|
||||
---
|
||||
|
||||
# 2. docker :
|
||||
|
||||
## 2.1. install docker
|
||||
|
||||
- [install docker engine](https://docs.docker.com/engine/install/ubuntu/)
|
||||
- [uninstall docker engine](https://docs.docker.com/engine/install/ubuntu/#uninstall-docker-engine)
|
||||
- [docker engine vs docker desktop](https://docs.docker.com/desktop/faqs/linuxfaqs/#what-is-the-difference-between-docker-desktop-for-linux-and-docker-engine)
|
||||
- [manage docker as non root user](https://docs.docker.com/engine/install/linux-postinstall/)
|
||||
|
||||
## 2.2. docker ressources
|
||||
|
||||
- [docker compose man](https://docs.docker.com/compose/compose-file/#volumes)
|
||||
- [Dockerfile man](https://docs.docker.com/engine/reference/builder/)
|
||||
- [determine the parent image](https://forums.docker.com/t/determine-the-parent-image/48611)
|
||||
- [docker image from scratch](https://codeburst.io/docker-from-scratch-2a84552470c8)
|
||||
- [build context and image context](https://stackoverflow.com/questions/55108649/what-is-app-working-directory-for-a-dockerfile/55109065#55109065)
|
||||
- [run without sudo on linux](https://docs.docker.com/engine/install/linux-postinstall/)
|
||||
- [run docker deamon rootless](https://docs.docker.com/engine/security/rootless/)
|
||||
- [dangling images '<none>'](https://projectatomic.io/blog/2015/07/what-are-docker-none-none-images/)
|
||||
- [go inside docker to debug it](https://docs.docker.com/engine/reference/commandline/container_exec/)
|
||||
- [docker debug image with "docker run -it"](https://blog.devgenius.io/how-to-debug-docker-build-6c2588401188)
|
||||
- `docker exec -ti <container-name> bash` to run bash inside a running container
|
||||
- `docker logs <container_name>` to see the logs on standard output of a container
|
||||
- `docker ps` to list the container, and see their names
|
||||
- [docker CMD vs ENTRYPOINT](https://phoenixnap.com/kb/docker-cmd-vs-entrypoint)
|
||||
- [use env variable with compose](https://docs.docker.com/compose/environment-variables/)
|
||||
- [using DEBIAN_FRONTEND=noninteractive disouraged in dockerfile](https://bobcares.com/blog/debian_frontendnoninteractive-docker/)
|
||||
- [docker network](https://docs.docker.com/network/)
|
||||
- [depends_on](https://docs.docker.com/compose/compose-file/#depends_on)
|
||||
- [compose and env var](https://docs.docker.com/compose/environment-variables/)
|
||||
- [specify path to named volumes](https://docs.docker.com/compose/compose-file/#volumes-top-level-element)
|
||||
- [pass secret to container](https://medium.com/@zdk/simple-and-secure-way-to-pass-secrets-and-credentials-into-docker-containers-c2f66175b0a4)
|
||||
|
||||
|
||||
---
|
||||
|
||||
# 3. old versions
|
||||
|
||||
## 3.1. v1 2022
|
||||
|
||||
### 3.1.1. todo
|
||||
|
||||
- [/] copy recent site version
|
||||
- [/] create links
|
||||
- [/] make links having map
|
||||
- [/] transform filter list in inputs
|
||||
- [/] zoom in
|
||||
- [/] style input filters
|
||||
- [x] enlever le bandeau de scroll des menus
|
||||
- [/] effacer -> bouton carre, fond violet, ecriture blanche, en capitale, arrondis de 3px sur les coins
|
||||
- [/] ne pas ouvrir sur un nouvel onglet
|
||||
- [/] "effacer" au lieu de "sans filtre"
|
||||
- [/] accents et majuscules : "Effacer", "Pays" et "Categories"
|
||||
- [/] responsive
|
||||
- pays
|
||||
- categories
|
||||
- irl / online
|
||||
- effacer
|
||||
- [/] sur ordi carte hauteur 600px, sur telephone 500px
|
||||
- [/] make two infowindow size
|
||||
- [/] infowindow with date in background color purple, and croice white
|
||||
- [/] check errors on real site
|
||||
- [/] create action to publish all
|
||||
- [/] deal with multiplication of filters
|
||||
- [/] deal with window size
|
||||
- [/] la carte ne s'affiche pas sur les pages
|
||||
- [/] filtres sur chrome
|
||||
- [/] infowindow new design
|
||||
- [/] infowindow enlever scroll border
|
||||
|
||||
- [/] hide filters before css ready
|
||||
- [x] reduire hauteur du select menu
|
||||
- [/] dans categories, placer "autres" en bas
|
||||
- [/] dans categories, transformer fleches en "autres"
|
||||
- [/] effacer les fenetres, au moins sur le bouton effacer, ou sur mouvement
|
||||
- [/] zoom sur cluster problem
|
||||
- [/] transform names without space
|
||||
- [/] change appearance of filter according to other filters
|
||||
- [/] change title of select options that appears on cursor hover
|
||||
- [ ] deal with error double event irl and online
|
||||
|
||||
### 3.1.2. verifications:
|
||||
|
||||
- api only for this site on fabien's google account
|
||||
- erased tmp css on site headers
|
||||
|
||||
### 3.1.3. improvement suggestions:
|
||||
|
||||
- add a field "more infos" to address
|
||||
- localise on map when form is filled
|
||||
|
||||
### 3.1.4. questions traitees:
|
||||
|
||||
- zoom : toujours zoomer, pour un seul marqueur pas trop, et enlever les villes
|
||||
- resoudre probleme mauvais markers de pays
|
||||
- faire un bouton select (afficher la seletion plutot que le nom du menu)
|
||||
|
||||
- bound la carte limite pour ne pas voir la zone grise
|
||||
- quelles infos on mets dans les infowindow
|
||||
- adresse en haut (surtout pour les markers avec plusieurs evenements)
|
||||
- filtres: au dessus de la carte
|
||||
- zoom : on reste avec le fonctionnement par defaut
|
||||
- est-ce qu'on peut changer la phrase "ctrl + scroll" pour un truc en francais ?
|
||||
- comment gerer les mauvaises adresses
|
||||
- verifier la maniere dont je les recuperes, tous les posts devraient avoir un pays
|
||||
- comportement des infowindows
|
||||
- centrees, c nickel
|
||||
- markers avec plusieurs evenements a la meme adresse
|
||||
- utiliser uniquement les markers qui servent actuellement pour les clusters
|
||||
- quand c'est un cluster, on zoom,
|
||||
- quand c'est plusieurs evenements au meme endroit, on les affiche
|
||||
|
||||
### 3.1.5. todo:
|
||||
|
||||
- add info-window
|
||||
- add filter options
|
||||
- deal with bad address
|
||||
- redsign + and - for zoom -> color and thickness
|
||||
- how to put the map on other pages
|
||||
- how to send plugin to fabien
|
||||
- [changed plugin directory in wp](https://wordpress.stackexchange.com/questions/120075/how-to-change-location-of-the-plugins-wordpress-themes-folder)
|
||||
- googlemap api key : AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE
|
||||
- [discussion on googlemap wp implementation](https://wordpress.org/support/topic/google-maps-where-to-place-api-key/)
|
||||
- [exemple of googlemap plugin creation](https://www.inkthemes.com/implement-google-map-plugin-for-wordpress/)
|
||||
- [Error: not a valid JSON response](https://wordpress.org/support/topic/publishing-failed-error-message-the-response-is-not-a-valid-json-response-2/)
|
||||
- [permalink broken](https://wordpress.org/support/topic/permalinks-change-breaks-all-links/)
|
||||
- [console.log in php](https://stackify.com/how-to-log-to-console-in-php/)
|
||||
- [plugins_url with symlink pbm](https://wordpress.stackexchange.com/questions/102681/plugins-url-file-wp-plugin-url-with-sym-links)
|
||||
- [make nginx follow symlinks](https://unix.stackexchange.com/questions/157022/make-nginx-follow-symlinks)
|
||||
- [nginx not following symlink maybe due to permissions](https://stackoverflow.com/questions/12624358/nginx-not-following-symlinks)
|
||||
- [symlink pbm with php-fpm](https://joshtronic.com/2019/07/29/symlinks-with-nginx-and-php-fpm/)
|
||||
- [my post on unix stack](https://unix.stackexchange.com/questions/722503/symlink-doent-works-with-nginx-and-php-fpm-and-docker/722511#722511)
|
||||
- [my post on wordpress stack](https://wordpress.stackexchange.com/questions/410735/i-dont-understand-how-symlinks-in-plugin-work)
|
||||
- [maps api in php](http://www.learningaboutelectronics.com/Articles/Google-maps-API-JSON-PHP.php)
|
||||
- [google maps api url parameters](https://developers.google.com/maps/documentation/javascript/url-params)
|
||||
- [google maps api references](https://developers.google.com/maps/documentation/javascript/reference)
|
||||
- [remove marker cluster](https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html#removeMarker)
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
@@ -1,171 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: map_prof
|
||||
Plugin URI:
|
||||
Description: add/remove locations on map at publication/deletion of posts
|
||||
Author: hugogogo
|
||||
Version: 1.2.0
|
||||
Author URI:
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* inclusions :
|
||||
*/
|
||||
|
||||
include_once(dirname(__FILE__) . '/utils/mp_console_log.php');
|
||||
include_once(dirname(__FILE__) . '/utils/mp_get_ip.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__) . '/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');
|
||||
|
||||
require_once(dirname(__FILE__) . '/srcs/menu/mp_menu_content.php');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* when 'shortcode' found in page, enqueue scripts and styles,
|
||||
* run php script, and replace shortcode by return value
|
||||
*/
|
||||
|
||||
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);
|
||||
//foreach ($events as $event) {
|
||||
// if (gettype($event->categorie) === "array") {
|
||||
// mp_console_log($event->categorie);
|
||||
// }
|
||||
// if (str_starts_with($event->categorie, '["')) {
|
||||
// mp_console_log($event->categorie);
|
||||
// }
|
||||
//}
|
||||
|
||||
$locations = mp_sort_events($events); // mp_get_locations.php
|
||||
//mp_console_log("locations: ");
|
||||
//mp_console_log($locations);
|
||||
|
||||
$filters = mp_get_filters($events); // mp_get_filters.php
|
||||
|
||||
// if post event instead of map page, change coordinate and zoom
|
||||
mp_post_event_pages_setting();
|
||||
|
||||
mp_add_to_scripts(array(
|
||||
"locations" => $locations,
|
||||
"filters" => $filters,
|
||||
"jipf_events" => $events,
|
||||
));
|
||||
|
||||
return mp_create_div($filters);
|
||||
}
|
||||
add_shortcode('lejourduprof_map', 'mp_ljdp_map');
|
||||
|
||||
|
||||
/*
|
||||
script in divi :
|
||||
|
||||
<script type="text/javascript">
|
||||
console.log("events:");
|
||||
console.log(events);
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
let counter = document.getElementById('jipf_activity_counter_map');
|
||||
console.log(counter);
|
||||
counter.dataset.numberValue = 20;
|
||||
});
|
||||
</script>
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* re-publish posts
|
||||
*/
|
||||
|
||||
// function mp_add_update_button() {
|
||||
// return mp_create_republish_button();
|
||||
// }
|
||||
// add_shortcode('ljdp_update_publish', 'mp_add_update_button');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* errors map
|
||||
*/
|
||||
|
||||
function mp_errors_map() {
|
||||
return mp_find_address_errors();
|
||||
}
|
||||
add_shortcode('ljdp_errors_map', 'mp_errors_map');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* when a post is saved or published or updated,
|
||||
* find its coordinates
|
||||
*/
|
||||
|
||||
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(
|
||||
'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
|
||||
);
|
||||
}
|
||||
add_action('admin_menu', 'ljdp_map_menu');
|
||||
|
||||
?>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?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);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,103 +0,0 @@
|
||||
function fill_filters(filters_div) {
|
||||
|
||||
/*
|
||||
* following variable are created by mp_add_to_script.php
|
||||
*
|
||||
* { }
|
||||
* { [ ] }
|
||||
* - filters: { - pays : [ { - _name : "" } ] }
|
||||
* { [ { - villes : [] } ] }
|
||||
* { [ { - categories: [] } ] }
|
||||
* { [ { - mode : [] }, ...] }
|
||||
* { [ ] }
|
||||
* { }
|
||||
* { [ ] }
|
||||
* { - villes : [ { - _name : "" } ] }
|
||||
* { [ { - pays : [] } ] }
|
||||
* { [ { - categories: [] } ] }
|
||||
* { [ { - mode : [] }, ...] }
|
||||
* { [ ] }
|
||||
* { }
|
||||
* { [ ] }
|
||||
* { - categories: [ { - _name : "" } ] }
|
||||
* { [ { - pays : [] } ] }
|
||||
* { [ { - villes : [] } ] }
|
||||
* { [ { - mode : [] }, ...] }
|
||||
* { [ ] }
|
||||
* { }
|
||||
* { }
|
||||
* { [ ] }
|
||||
* { - mode : [ { - _name : "" } ] }
|
||||
* { [ { - pays : [] } ] }
|
||||
* { [ { - villes : [] } ] }
|
||||
* { [ { - categories: [] }, ...] }
|
||||
* { [ ] }
|
||||
* { }
|
||||
*
|
||||
*/
|
||||
|
||||
let content = "";
|
||||
// use Object.keys to obtain an array of object keys
|
||||
let keys = Object.keys(filters);
|
||||
keys.forEach((key) => {
|
||||
|
||||
// // version input checkbox
|
||||
//
|
||||
// content += `
|
||||
// <div class="filter_menu">
|
||||
// <input id="filter_menu_title_${key}" class="filter_menu_title" type="checkbox" />
|
||||
// <label for="filter_menu_title_${key}" class="filter_menu_title">
|
||||
// <p>${key}</p>
|
||||
// </label>
|
||||
// <div class="filter_menu_drop">
|
||||
// `;
|
||||
// for (value of filters[key]) {
|
||||
// content += `
|
||||
// <p>${value._name}</p>
|
||||
// `;
|
||||
// }
|
||||
// content += `
|
||||
// </div>
|
||||
// </div>
|
||||
// `;
|
||||
|
||||
// // version select
|
||||
//
|
||||
// content += `
|
||||
// <div class="filter_menu">
|
||||
// <select id="filter_menu_drop_${key}" class="filter_menu_drop" name="${key}">
|
||||
// `;
|
||||
// for (value of filters[key]) {
|
||||
// content += `
|
||||
// <option value="${value._name}"><p>${value._name}</p></option>
|
||||
// `;
|
||||
// }
|
||||
// content += `
|
||||
// </select>
|
||||
// </div>
|
||||
// `;
|
||||
|
||||
// // version div
|
||||
//
|
||||
content += `
|
||||
<div class="filter_menu">
|
||||
<div class="filter_menu_title" tabindex=0>
|
||||
<p>${key}</p>
|
||||
</div>
|
||||
<div class="filter_menu_drop" tabindex=0>
|
||||
<p>PAS DE FILTRE</p>
|
||||
`;
|
||||
for (value of filters[key]) {
|
||||
content += `
|
||||
<p>${value._name}</p>
|
||||
`;
|
||||
}
|
||||
content += `
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
});
|
||||
|
||||
filters_div.innerHTML = content;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
|
||||
function restrict_map(restrict) {
|
||||
let map_restriction = {
|
||||
latLngBounds: g_world_bound,
|
||||
strictBounds: true,
|
||||
};
|
||||
if (restrict)
|
||||
g_map.setOptions({restriction: map_restriction,});
|
||||
else
|
||||
g_map.setOptions({restriction: null,});
|
||||
};
|
||||
|
||||
function create_map(map_div) {
|
||||
// default map center to france
|
||||
let map_center = coordinates_default;
|
||||
// map_center = {lat:-2.515748362923059, lng:32.93366215464864};
|
||||
let map_restriction = {
|
||||
latLngBounds: g_world_bound,
|
||||
strictBounds: true,
|
||||
};
|
||||
let map_options = {
|
||||
/* map options : https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions */
|
||||
disableDefaultUI: true,
|
||||
zoomControl: true,
|
||||
scaleControl: true,
|
||||
zoom: map_zoom,
|
||||
|
||||
//gestureHandling: "cooperative",
|
||||
gestureHandling: "greedy",
|
||||
//gestureHandling: "none",
|
||||
//gestureHandling: "auto",
|
||||
|
||||
//disableDoubleClickZoom: "false", // deprecated
|
||||
//draggable: "true", // deprecated
|
||||
|
||||
center: map_center,
|
||||
restriction: map_restriction,
|
||||
}
|
||||
|
||||
return new google.maps.Map(map_div, map_options);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
function create_markers(map, locations, infowindow) {
|
||||
|
||||
/*
|
||||
* following variable are created by mp_add_to_script.php
|
||||
* - let icon_color = ""
|
||||
* - let icon_color_back = ""
|
||||
* - let icon_size = [x, y]
|
||||
* - let cluster_size_factor = Number
|
||||
* - let icon_stroke_width = Number
|
||||
*/
|
||||
|
||||
let icon_circle_radius = 40 - icon_stroke_width / 2;
|
||||
|
||||
let markers = [];
|
||||
for (loc of locations) {
|
||||
|
||||
if (loc.coordinates == null)
|
||||
continue;
|
||||
|
||||
let count = loc.events.length;
|
||||
|
||||
let marker_icon_size = [
|
||||
icon_size[0] + ( icon_size_factor * (count - 2) ),
|
||||
icon_size[1] + ( icon_size_factor * (count - 2) )
|
||||
];
|
||||
let svg_icon = window.btoa(`
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="${marker_icon_size[0]}" height="${marker_icon_size[1]}">
|
||||
<circle cx="50%" cy="50%" r="${icon_circle_radius}%" stroke="${icon_color}" stroke-width="${icon_stroke_width}" fill="${icon_color_back}" />
|
||||
</svg>
|
||||
`);
|
||||
let icon_options = {
|
||||
url: `data:image/svg+xml;base64,${svg_icon}`,
|
||||
scaledSize: new google.maps.Size(marker_icon_size[0], marker_icon_size[1]),
|
||||
};
|
||||
let marker_label = {
|
||||
text: String(count),
|
||||
color: icon_color,
|
||||
fontSize: "12px",
|
||||
fontWeight: "bold",
|
||||
};
|
||||
let marker_title = `address of ${count} events`;
|
||||
|
||||
let marker = new google.maps.Marker({
|
||||
position: loc.coordinates,
|
||||
map: map,
|
||||
icon: icon_options,
|
||||
title: marker_title,
|
||||
label: marker_label,
|
||||
});
|
||||
|
||||
attach_info_window(map, marker, loc.events, infowindow);
|
||||
|
||||
markers.push(marker);
|
||||
};
|
||||
|
||||
return markers;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
function draw_clusters(map, markers) {
|
||||
|
||||
/*
|
||||
* following variable are created by mp_add_to_script.php
|
||||
* - let icon_color = ""
|
||||
* - let icon_color_back = ""
|
||||
* - let icon_size = [x, y]
|
||||
* - let icon_size_factor = Number
|
||||
* - let icon_stroke_width = Number
|
||||
*/
|
||||
|
||||
let icon_circle_radius = 40 - icon_stroke_width / 2;
|
||||
|
||||
let renderer = {
|
||||
render({ count, position }, stats) {
|
||||
|
||||
/* CLUSTERS SETTINGS */
|
||||
|
||||
let marker_icon_size = [
|
||||
icon_size[0] + ( icon_size_factor * (count - 2) ),
|
||||
icon_size[1] + ( icon_size_factor * (count - 2) )
|
||||
];
|
||||
let cluster_svg = window.btoa(`
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="${marker_icon_size[0]}" height="${marker_icon_size[1]}">
|
||||
<circle cx="50%" cy="50%" r="${icon_circle_radius}%" stroke="${icon_color}" stroke-width="${icon_stroke_width}" fill="${icon_color_back}" />
|
||||
</svg>
|
||||
`);
|
||||
let cluster_icon = {
|
||||
url: `data:image/svg+xml;base64,${cluster_svg}`,
|
||||
scaledSize: new google.maps.Size(marker_icon_size[0], marker_icon_size[1]),
|
||||
};
|
||||
let cluster_label = {
|
||||
text: String(count),
|
||||
color: icon_color,
|
||||
fontSize: "12px",
|
||||
fontWeight: "bold",
|
||||
};
|
||||
let cluster_title = `Cluster of ${count} markers`;
|
||||
let cluster_zIndex = Number(google.maps.Marker.MAX_ZINDEX) + count;
|
||||
|
||||
return new google.maps.Marker({
|
||||
position,
|
||||
icon: cluster_icon,
|
||||
label: cluster_label,
|
||||
title: cluster_title,
|
||||
zIndex: cluster_zIndex,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let onClusterClick = (_, cluster, map) => {
|
||||
restrict_map(false);
|
||||
map.fitBounds(cluster.bounds);
|
||||
restrict_map(true);
|
||||
};
|
||||
|
||||
return new markerClusterer.MarkerClusterer({ map, markers, renderer, onClusterClick });
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
function print_error(error) {
|
||||
let div_map = document.getElementById("ljdp_map");
|
||||
let p_err = document.createElement('p');
|
||||
|
||||
p_err.textContent = error;
|
||||
div_map.after(p_err);
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
|
||||
// https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html
|
||||
// add true for noDraw
|
||||
// bounds : https://stackoverflow.com/questions/19304574/center-set-zoom-of-map-to-cover-all-visible-markers/19304625#19304625
|
||||
|
||||
|
||||
|
||||
function array_first_not_in_second(first, second) {
|
||||
let temp_array = [];
|
||||
for (let index of first) {
|
||||
if (second.indexOf(index) == -1) {
|
||||
temp_array.push(index);
|
||||
}
|
||||
}
|
||||
return temp_array;
|
||||
}
|
||||
|
||||
function filter_selection_indexes(menu, indexes, reverse, add) {
|
||||
|
||||
if (indexes.length === 0) {
|
||||
// if array of index is empty, delete menu
|
||||
delete g_indexes[menu];
|
||||
}
|
||||
else if (reverse) {
|
||||
// if reverse is true, delete all indexes in g_indexes.menu
|
||||
// https://stackoverflow.com/questions/5113374/javascript-check-if-variable-exists-is-defined-initialized
|
||||
if ( typeof(g_indexes[menu]) !== "undefined" && g_indexes[menu] !== null ) {
|
||||
// creates an array with all values of g_indexes[menu] minus indexes
|
||||
let temp_array = array_first_not_in_second(g_indexes[menu], indexes);
|
||||
if (temp_array.length === 0)
|
||||
delete g_indexes[menu];
|
||||
else
|
||||
g_indexes[menu] = [].concat(temp_array);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (add && typeof(g_indexes[menu]) !== "undefined") {
|
||||
// add array of menus to g_indexes{}
|
||||
// creates an array with all values of indexes that are not in g_indexes[menu] already
|
||||
let temp_array = array_first_not_in_second(indexes, g_indexes[menu]);
|
||||
g_indexes[menu] = g_indexes[menu].concat(temp_array);
|
||||
}
|
||||
else {
|
||||
// replace or create array of menu in g_indexes{}
|
||||
g_indexes[menu] = [].concat(indexes);
|
||||
}
|
||||
}
|
||||
|
||||
// loop through all arrays of g_indexes to find intersection
|
||||
// take first one as comparison
|
||||
let keys = Object.keys(g_indexes);
|
||||
let intersection = [];
|
||||
let compare = [];
|
||||
keys.forEach((key, i) => {
|
||||
if (i == 0) {
|
||||
intersection = g_indexes[key];
|
||||
}
|
||||
else {
|
||||
let temp = [];
|
||||
compare = g_indexes[key];
|
||||
for (let index of intersection) {
|
||||
if (compare.indexOf(index) != -1)
|
||||
temp.push(index);
|
||||
}
|
||||
intersection = [].concat(temp);
|
||||
}
|
||||
});
|
||||
return intersection;
|
||||
}
|
||||
|
||||
function redraw_clusters(indexes) {
|
||||
|
||||
let indexes_count = indexes.length;
|
||||
|
||||
if (indexes_count !== 0) {
|
||||
// if index array, hide all other markers, and if zoomin, zoom to new markers
|
||||
g_marker_cluster.clearMarkers(true);
|
||||
|
||||
let marker = g_markers[0];
|
||||
let current_bounds = g_map.getBounds();
|
||||
let bounds = new google.maps.LatLngBounds();
|
||||
|
||||
let outside_bounds = false;
|
||||
for (let index of indexes) {
|
||||
marker = g_markers[index];
|
||||
position = marker.getPosition();
|
||||
if (! current_bounds.contains(position))
|
||||
outside_bounds = true;
|
||||
bounds.extend(position);
|
||||
|
||||
g_marker_cluster.addMarker(marker, true);
|
||||
}
|
||||
if (outside_bounds) {
|
||||
if (indexes_count === 1) {
|
||||
g_map.setCenter(position);
|
||||
g_map.setZoom(max_zoom);
|
||||
}
|
||||
else if (indexes_count > 1) {
|
||||
g_map.fitBounds(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if ( Object.keys(g_indexes).length === 0 ) {
|
||||
// object is empty, there are no filters
|
||||
g_map.setCenter(coordinates_default);
|
||||
g_map.setZoom(2);
|
||||
g_marker_cluster.addMarkers(g_markers, true);
|
||||
}
|
||||
else {
|
||||
// filters intersection lets no markers on the map
|
||||
g_marker_cluster.clearMarkers(true);
|
||||
}
|
||||
|
||||
g_marker_cluster.render();
|
||||
}
|
||||
|
||||
function html_item(menu_name, menu_item) {
|
||||
let item = menu_item.replace(/ /g, "_");
|
||||
let html_id = `filter_${menu_name}_${item}`;
|
||||
return document.getElementById(html_id);
|
||||
}
|
||||
|
||||
function toggle_menu_items(menu_name, x_abled) {
|
||||
|
||||
let name = menu_name.replace(/ /g, "_");
|
||||
let class_name = `filter_menu_${name}`;
|
||||
let items = document.getElementsByClassName(class_name);
|
||||
|
||||
if (x_abled === "disable") {
|
||||
for (let item of items) {
|
||||
// if item is a menu title (like 'categorie' or 'pays')
|
||||
// don't remove 'enable', instead add it, because it's not in the list of 'to_enable'
|
||||
if (item.selected) {
|
||||
item.classList.add('enable');
|
||||
}
|
||||
else {
|
||||
item.classList.remove('enable');
|
||||
}
|
||||
if (item.classList.contains('to_enable')) {
|
||||
item.classList.replace('to_enable', 'enable');
|
||||
item.removeAttribute('disabled');
|
||||
}
|
||||
else if (! item.selected)
|
||||
item.setAttribute('disabled', '');
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (let item of items) {
|
||||
item.classList.remove('enable');
|
||||
item.removeAttribute('disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function disable_menus(menu_name_ori, menu_item_ori, reverse, menu_index) {
|
||||
|
||||
let menu_item_name = "";
|
||||
if (menu_item_ori == null) // it's a menu name
|
||||
menu_item_name = menu_name_ori;
|
||||
else
|
||||
menu_item_name = menu_item_ori._name;
|
||||
let item_ori_html = html_item(menu_name_ori, menu_item_name);
|
||||
let is_enabled = item_ori_html.classList.contains('enable');
|
||||
|
||||
// in case it's a menu title, like "Pays" or "Categories",
|
||||
// and it does'nt contains 'enable'
|
||||
// just act like Reset button
|
||||
// it's too bad it will also go through this menu items even though it's unnecessary
|
||||
if (menu_index == 'menu_name') { // it's a menu name
|
||||
if (! is_enabled) {
|
||||
// "item" as a menu name will select all items in all menus
|
||||
toggle_menu_items("item", "enable");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// if it's Mode menu,
|
||||
// and it was the first selection, meaning it does'nt contains 'enable'
|
||||
// and both (irl and online) are abled or disabled,
|
||||
// just act like Reset button
|
||||
// it's too bas it will also go through this menu items even though it's unnecessary
|
||||
if (menu_name_ori === "mode") {
|
||||
let mode_menus = document.getElementsByClassName("filter_menu_mode");
|
||||
let state = 0;
|
||||
for (let mode_menu of mode_menus) {
|
||||
if (mode_menu.checked)
|
||||
state++;
|
||||
else
|
||||
state--;
|
||||
}
|
||||
if (state != 0) { // state equal 0 if both have a different state, because (0 + 1 - 1 = 0) and (0 - 1 + 1 = 0)
|
||||
if (! is_enabled) {
|
||||
// "item" as a menu name will select all items in all menus
|
||||
toggle_menu_items("item", "enable");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (reverse) { // menu is "mode" and only one item is selected and the action was to deselect one, so the action has trigered one item but really we want to see the options of the other item, so let's switch them
|
||||
if (menu_index == 0)
|
||||
menu_index++;
|
||||
else
|
||||
menu_index--;
|
||||
menu_item_ori = filters[menu_name_ori][menu_index];
|
||||
}
|
||||
}
|
||||
|
||||
let keys = Object.keys(menu_item_ori);
|
||||
// loop through list of other menu_items available for this menu_item
|
||||
// loop though menu names (pays, categories, mode)
|
||||
for (let menu_name of keys) {
|
||||
if (menu_name === "_name")
|
||||
continue;
|
||||
if (menu_name === "indexes")
|
||||
continue;
|
||||
else if (! is_enabled) {
|
||||
|
||||
// // it's too bad it will disable all and then enable certains, it would be better to check each time
|
||||
// toggle_menu_items(menu_name, "disable");
|
||||
// // loop through items in menu names (ex. for "pays" : france, chili, cuba)
|
||||
// for (let item of menu_item_ori[menu_name]) {
|
||||
// let item_html = html_item(menu_name, item);
|
||||
// item_html.classList.add('enable');
|
||||
// item_html.removeAttribute('disabled');
|
||||
// }
|
||||
|
||||
for (let item of menu_item_ori[menu_name]) {
|
||||
let item_html = html_item(menu_name, item);
|
||||
item_html.classList.add('to_enable');
|
||||
}
|
||||
toggle_menu_items(menu_name, "disable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function filter_show_only(element, menu_name) {
|
||||
|
||||
g_infowindow.close();
|
||||
|
||||
let menu_index = element.getAttribute("data-menu_index");
|
||||
let menu_item = null;
|
||||
let indexes = [];
|
||||
if (menu_index != "menu_name") {
|
||||
menu_item = filters[menu_name][menu_index];
|
||||
indexes = menu_item.indexes;
|
||||
}
|
||||
|
||||
add = false;
|
||||
reverse = false;
|
||||
if (element.type === "checkbox") {
|
||||
reverse = ! element.checked;
|
||||
add = true;
|
||||
}
|
||||
|
||||
disable_menus(menu_name, menu_item, reverse, menu_index);
|
||||
|
||||
let index_array = filter_selection_indexes(menu_name, indexes, reverse, add);
|
||||
|
||||
redraw_clusters(index_array);
|
||||
}
|
||||
|
||||
function filter_show_all() {
|
||||
|
||||
g_infowindow.close();
|
||||
|
||||
// "item" as a menu name will select all items in all menus
|
||||
toggle_menu_items("item", "enable");
|
||||
|
||||
g_indexes = {};
|
||||
g_marker_cluster.clearMarkers(true);
|
||||
g_marker_cluster.addMarkers(g_markers);
|
||||
/* dont use fitBounds because it's not well centered */
|
||||
/* instead use setCenter and setZoom */
|
||||
//g_map.fitBounds(g__init_bounds);
|
||||
g_map.setCenter(coordinates_default);
|
||||
g_map.setZoom(2);
|
||||
}
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
|
||||
function attach_info_window(map, marker, events, infowindow) {
|
||||
|
||||
/*
|
||||
* https://developers.google.com/maps/documentation/javascript/infowindows
|
||||
* https://stackoverflow.com/questions/11106671/google-maps-api-multiple-markers-with-infowindows
|
||||
*/
|
||||
|
||||
let window_content = `
|
||||
<div id="infowindow_limits">
|
||||
<div class="infowindow">
|
||||
<div class="infowindow_head">
|
||||
<p>${events[0].location.address}</p>
|
||||
<div id="infowindow_close" onclick="g_infowindow.close()"></div>
|
||||
</div>
|
||||
`;
|
||||
for (key in events) {
|
||||
window_content += `
|
||||
<a class="infowindow_body" href="${events[key].url}">
|
||||
<p>${events[key].title}</p>
|
||||
</a>
|
||||
`;
|
||||
};
|
||||
window_content += `
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
marker.addListener('click', () => {
|
||||
|
||||
let view_center = map.getCenter();
|
||||
// height must be half css value (mp_info_windows.css -> '--size: XXXpx;')
|
||||
let window_offset = { width: 0, height: 275 };
|
||||
|
||||
infowindow.setOptions({
|
||||
//disableAutoPan: true,
|
||||
disableAutoPan: false,
|
||||
content: window_content,
|
||||
|
||||
/* dimensions */
|
||||
//maxWidth: 400,
|
||||
//minWidth: 400,
|
||||
|
||||
/* center window */
|
||||
position: view_center,
|
||||
pixelOffset: window_offset,
|
||||
|
||||
//shouldFocus: false,
|
||||
});
|
||||
|
||||
infowindow.open(map);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
event : {}
|
||||
- heure_de_debut : "";
|
||||
- heure_de_fin : "";
|
||||
- categorie : "";
|
||||
- date : "";
|
||||
- pays : "";
|
||||
- ville : "";
|
||||
- adresse : "";
|
||||
- prenom : "";
|
||||
- nom : "";
|
||||
- irl : bool;
|
||||
- id : x;
|
||||
- index : x (default null);
|
||||
- title : "";
|
||||
- url : "";
|
||||
- location : {}
|
||||
- street : "";
|
||||
- city : "";
|
||||
- country : "";
|
||||
- address : "";
|
||||
- approximate : bool;
|
||||
- coordinates : {}
|
||||
- lat : x;
|
||||
- lng : x;
|
||||
*/
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
|
||||
let g_map = {};
|
||||
let g_markers = [];
|
||||
let g_marker_cluster = {};
|
||||
let g_indexes = {};
|
||||
let g_infowindow = {};
|
||||
const g_world_bound = {
|
||||
north: 80,
|
||||
south: -80,
|
||||
west: -180,
|
||||
east: 180,
|
||||
};
|
||||
|
||||
/*
|
||||
* following variable are created by mp_add_to_script.php
|
||||
* - let events
|
||||
* - let locations = [
|
||||
* {
|
||||
* coordinates: {}
|
||||
* events : [{}, ...]
|
||||
* },
|
||||
* ...
|
||||
* ]
|
||||
*
|
||||
* { }
|
||||
* { [ ] }
|
||||
* - let filters: { - pays : [ { - _name : "" } ] }
|
||||
* { [ { - villes : [] } ] }
|
||||
* { [ { - categories: [] } ] }
|
||||
* { [ { - indexes : [] } ] }
|
||||
* { [ { - mode : [] }, ...] }
|
||||
* { [ ] }
|
||||
* { }
|
||||
* { - villes : ... }
|
||||
* { - categories: ... }
|
||||
* { - mode : ... }
|
||||
* { }
|
||||
*
|
||||
* - let coordinates_default = {lat: ,lng: }
|
||||
* - let icon_color = ""
|
||||
* - let icon_color_back = ""
|
||||
* - let icon_size = [x, y]
|
||||
* - let cluster_size_factor = Number
|
||||
* - let map_zoom = x
|
||||
* - let max_zoom = x
|
||||
*/
|
||||
|
||||
function mp_init_map() {
|
||||
|
||||
let map_div = document.getElementById("ljdp_map");
|
||||
//let filters_div = document.getElementById("ljdp_map_filters");
|
||||
g_infowindow = new google.maps.InfoWindow();
|
||||
|
||||
g_map = create_map(map_div);
|
||||
g_markers = create_markers(g_map, locations, g_infowindow);
|
||||
g_marker_cluster = draw_clusters(g_map, g_markers);
|
||||
|
||||
// add listener to close infowindow
|
||||
// https://developers.google.com/maps/documentation/javascript/events
|
||||
g_map.addListener('click', function() {
|
||||
g_infowindow.close();
|
||||
});
|
||||
g_map.addListener('drag', function() {
|
||||
g_infowindow.close();
|
||||
});
|
||||
g_map.addListener('zoom_changed', function() {
|
||||
g_infowindow.close();
|
||||
});
|
||||
|
||||
//g_map.addListener('clusteringbegin', restrict_map(false));
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
|
||||
console.log("publish error");
|
||||
|
||||
wp.data.dispatch( 'core/notices' ).createNotice(
|
||||
'error', // Can be one of: success, info, warning, error.
|
||||
'impossible de publier : le pays est invalide', // Text string to display.
|
||||
{
|
||||
isDismissible: true, // Whether the user can dismiss the notice.
|
||||
}
|
||||
);
|
||||
|
||||
//( function ( wp ) {
|
||||
// console.log("publish error");
|
||||
// wp.data.dispatch( 'core/notices' ).createNotice(
|
||||
// 'error', // Can be one of: success, info, warning, error.
|
||||
// 'impossible de publie : le pays est invalide', // Text string to display.
|
||||
// {
|
||||
// isDismissible: true, // Whether the user can dismiss the notice.
|
||||
// }
|
||||
// );
|
||||
//} )( window.wp );
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* global variables :
|
||||
*
|
||||
* DO NOT MODIFY !
|
||||
* modify mp_optionnals.php or mp_required.php instead
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* ICON SIZE
|
||||
*/
|
||||
$mp_icon_size = [40, 40];
|
||||
if (isset($mp_settings_icon_size)) {
|
||||
if (is_array($mp_settings_icon_size)) {
|
||||
if (count($mp_settings_icon_size) === 2) {
|
||||
if ( is_numeric($mp_settings_icon_size[0]) && is_numeric($mp_settings_icon_size[1]) ) {
|
||||
$mp_icon_size = $mp_settings_icon_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ICON COLOR
|
||||
*/
|
||||
$mp_icon_color = "#ba197a";
|
||||
if (isset($mp_settings_icon_color))
|
||||
$mp_icon_color = $mp_settings_icon_color;
|
||||
|
||||
|
||||
/* ICON FACTOR SIZE
|
||||
*/
|
||||
$mp_icon_size_factor = 2.5;
|
||||
if (isset($mp_settings_icon_size_factor))
|
||||
$mp_icon_size_factor = $mp_settings_icon_size_factor;
|
||||
|
||||
|
||||
/* DEFAULT ZOOM
|
||||
*/
|
||||
$mp_zoom_set = [2, 5];
|
||||
if (isset($mp_settings_zoom_set))
|
||||
$mp_zoom_set = $mp_settings_zoom_set;
|
||||
// also create the variable, and set to map page by default
|
||||
$mp_zoom = $mp_zoom_set[0];
|
||||
|
||||
|
||||
/* DEFAULT COORDINATES
|
||||
*/
|
||||
$mp_coordinates_default = (object)["lat" => 46.227638, "lng" => 2.213749]; // france
|
||||
if (isset($mp_settings_coordinates_default))
|
||||
$mp_coordinates_default = $mp_settings_coordinates_default;
|
||||
|
||||
|
||||
/* ICON COLOR
|
||||
*/
|
||||
$mp_icon_color = "#ba197a";
|
||||
$mp_icon_color_back = "#ffffff99";
|
||||
if (isset($mp_settings_icon_color))
|
||||
$mp_icon_color = $mp_settings_icon_color;
|
||||
if (isset($mp_settings_icon_color_back))
|
||||
$mp_icon_color_back = $mp_settings_icon_color_back;
|
||||
|
||||
|
||||
/* ICON STROKE WIDTH
|
||||
*/
|
||||
$mp_icon_stroke_width = 6;
|
||||
if (isset($mp_settings_icon_stroke_width))
|
||||
$mp_icon_stroke_width = $mp_settings_icon_stroke_width;
|
||||
|
||||
|
||||
/* MAX ZOOM
|
||||
*/
|
||||
$mp_max_zoom = 5;
|
||||
if (isset($mp_settings_max_zoom))
|
||||
$mp_max_zoom = $mp_settings_max_zoom;
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* de-commenter les parametres pour les appliquer
|
||||
*
|
||||
* les parametres suivants sont optionnels pour le fonctionnement du plugin
|
||||
* le plugin fonctionne sans eux, grace a des valeurs par defauts
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* ************************************
|
||||
facteur de taille des clusters
|
||||
_
|
||||
valeur par defaut "2.5"
|
||||
************************************ */
|
||||
//$mp_settings_icon_size_factor = 4;
|
||||
|
||||
|
||||
|
||||
/* ************************************
|
||||
zoom initial
|
||||
- pour les pages
|
||||
- pour les posts
|
||||
_
|
||||
valeur par defaut [2, 5]
|
||||
************************************ */
|
||||
//$mp_settings_zoom_set = [1, 6];
|
||||
|
||||
|
||||
|
||||
/* ************************************
|
||||
coordonnees par defaut
|
||||
(pour centrer la carte globale,
|
||||
et en cas de mauvaises adresses)
|
||||
_
|
||||
valeur par defaut "france"
|
||||
************************************ */
|
||||
$mp_settings_coordinates_default = (object)["lat" => 30.0, "lng" => -1.0]; // carte mieux centree
|
||||
|
||||
|
||||
|
||||
/* ************************************
|
||||
couleurs d'icones
|
||||
- couleur de contour
|
||||
- couleur de remplissage
|
||||
_
|
||||
valeurs par defaut "#ba197a"
|
||||
"#ffffff99"
|
||||
************************************ */
|
||||
//$mp_settings_icon_color = "#d168a8";
|
||||
//$mp_settings_icon_color_back = "#ffffff80"; // transparency :
|
||||
// 0.0 : 00
|
||||
// 0.1 : 1a
|
||||
// 0.2 : 33
|
||||
// 0.3 : 4d
|
||||
// 0.4 : 66
|
||||
// 0.5 : 80
|
||||
// 0.6 : 99
|
||||
// 0.7 : b3
|
||||
// 0.8 : cc
|
||||
// 0.9 : e6
|
||||
|
||||
|
||||
|
||||
/* ************************************
|
||||
epaisseur de trait des icones
|
||||
_
|
||||
valeurs par defaut "6"
|
||||
************************************ */
|
||||
$mp_settings_icon_stroke_width = 8;
|
||||
|
||||
|
||||
|
||||
|
||||
/* ************************************
|
||||
zoom automatique maximum sur les
|
||||
marqueurs
|
||||
_
|
||||
valeurs par defaut "5"
|
||||
************************************ */
|
||||
$mp_settings_max_zoom = 4;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* les parametres suivants sont necessaires pour le fonctionnement du plugin
|
||||
*/
|
||||
|
||||
/* cle api google maps pour carte
|
||||
"Maps Javascript API" */
|
||||
//$mp_api_key = 'AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE'; // fabien
|
||||
$mp_api_key = 'AIzaSyDAZv8QNRQjnVY6kdzJRxWmZDaNIcgYp9E'; // hugo
|
||||
|
||||
/* cle api google maps pour serveur
|
||||
"Geocoding API" */
|
||||
//$mp_api_key_geo = 'AIzaSyAEMZHpMxBQaovU_so_RH7p_pZbjaB2jO8'; // fabien
|
||||
$mp_api_key_geo = 'AIzaSyBskxuBhowQdLjJmIj2gc66KoP1GLO3SEg'; // hugo
|
||||
|
||||
?>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
function mp_url_api() {
|
||||
global $mp_api_key;
|
||||
$mp_url = array(
|
||||
'src' => 'https://maps.googleapis.com/maps/api/js',
|
||||
'key' => $mp_api_key,
|
||||
'callback' => 'mp_init_map',
|
||||
);
|
||||
$mp_src = "";
|
||||
foreach ($mp_url as $url_key => $url_value) {
|
||||
if ($url_key === 'src') {
|
||||
$mp_src .= $url_value;
|
||||
if (count($mp_url) > 1)
|
||||
$mp_src .= "?";
|
||||
}
|
||||
else
|
||||
$mp_src .= "&" . $url_key . "=" . $url_value;
|
||||
};
|
||||
|
||||
return $mp_src;
|
||||
}
|
||||
?>
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
function mp_is_precise($post, $id, $location) {
|
||||
|
||||
// is presentiel but not complete address ?
|
||||
$presentiel = get_field("mode", $id);
|
||||
if ($presentiel[0] === "En présentiel") {
|
||||
if ($location->approximate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function mp_is_address_complete($post, $id, $location) {
|
||||
|
||||
// is presentiel but not complete address ?
|
||||
$presentiel = get_field("mode", $id);
|
||||
if ($presentiel[0] === "En présentiel") {
|
||||
if (strlen($location->street) == 0) {
|
||||
return false;
|
||||
}
|
||||
if (strlen($location->city) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function mp_is_valid_address($post, $id, $location) {
|
||||
|
||||
// is coordinates ?
|
||||
if ($location->coordinates == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function mp_fill_address_message($post, $id, $location) {
|
||||
|
||||
$message = '<br /><p>article : "'
|
||||
. $post->post_title . '"</p><p>- adresse fournie : "'
|
||||
. get_field('adresse', $id) . ', '
|
||||
. get_field('ville', $id) . ', '
|
||||
. get_field('pays', $id)
|
||||
. '"</p><p>- adresse trouvée : "'
|
||||
. $location->address
|
||||
. '"</p>';
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
function mp_find_address_errors() {
|
||||
|
||||
$errors = "";
|
||||
$incompletes = "";
|
||||
$approximates = "";
|
||||
$count_errors = 0;
|
||||
$count_incompletes = 0;
|
||||
$count_approximates = 0;
|
||||
|
||||
$get_posts_args = array(
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'post',
|
||||
);
|
||||
$posts = get_posts($get_posts_args);
|
||||
foreach ($posts as $post) {
|
||||
$id = $post->ID;
|
||||
$location = get_field('location', $id);
|
||||
if (! mp_is_valid_address($post, $id, $location)) {
|
||||
$count_errors++;
|
||||
$errors .= mp_fill_address_message($post, $id, $location);
|
||||
}
|
||||
// else if (! mp_is_address_complete($post, $id, $location)) {
|
||||
// $count_incompletes++;
|
||||
// $incompletes .= mp_fill_address_message($post, $id, $location);
|
||||
// }
|
||||
else if (! mp_is_precise($post, $id, $location)) {
|
||||
$count_approximates++;
|
||||
$approximates .= mp_fill_address_message($post, $id, $location);
|
||||
}
|
||||
}
|
||||
$message = "<h2>nombre d'erreurs : " . $count_errors . "</h2>";
|
||||
// $message .= "<h2>nombre d'adresses incompletes pour des evenements en presentiels : " . $count_incompletes . "</h2>";
|
||||
$message .= "<h2>nombre d'adresses approximatives pour des evenements en presentiels : " . $count_approximates . "</h2>";
|
||||
$message .= "<br /><h2>erreurs :</h2>" . $errors;
|
||||
// $message .= "<br /><h2>adresses incompletes:</h2>" . $incompletes;
|
||||
$message .= "<br /><h2>approximatives :</h2>" . $approximates;
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
function mp_php_to_js($php_var, $js_var_name) {
|
||||
$js_var = 'let ' . $js_var_name . ' = ';
|
||||
$js_var .= json_encode($php_var);
|
||||
$js_var .= ';';
|
||||
return $js_var;
|
||||
}
|
||||
|
||||
function mp_add_to_scripts($to_add) {
|
||||
global $mp_icon_size;
|
||||
global $mp_icon_color;
|
||||
global $mp_icon_color_back;
|
||||
global $mp_icon_size_factor;
|
||||
global $mp_zoom;
|
||||
global $mp_coordinates_default;
|
||||
global $mp_icon_stroke_width;
|
||||
global $mp_max_zoom;
|
||||
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_size, 'icon_size'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_color, 'icon_color'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_color_back, 'icon_color_back'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_size_factor, 'icon_size_factor'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_zoom, 'map_zoom'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_coordinates_default, 'coordinates_default'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_stroke_width, 'icon_stroke_width'), 'before');
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_max_zoom, 'max_zoom'), 'before');
|
||||
|
||||
foreach ($to_add as $key => $var) {
|
||||
wp_add_inline_script('mp_init_map', mp_php_to_js($var, $key), 'before');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
|
||||
function mp_filter_drop_down($key, &$filter) {
|
||||
/*
|
||||
onfocusin="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".')"
|
||||
onclick="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".')"
|
||||
onfocus="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".')"
|
||||
onclick="filter_show_only_selection(this, '.json_encode(array()).', '."'".$key."'".')"
|
||||
onchange="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".')"
|
||||
|
||||
onchange="filter_show_only_selection(this, '.json_encode(array()).', '."'".$key."'".')"
|
||||
onchange="filter_event(this, this.options[this.selectedIndex], \''.$key.'\')"
|
||||
*/
|
||||
$menu_name_class = 'filter_menu_'.str_replace(" ", "_", $key).'';
|
||||
$id = "filter_"
|
||||
. $key
|
||||
. "_"
|
||||
. $key
|
||||
;
|
||||
$content = '
|
||||
<select
|
||||
form="ljdp_form"
|
||||
class="filter_menu filter_menu_drop"
|
||||
onchange="filter_show_only(this.options[this.selectedIndex], \''.$key.'\')"
|
||||
>
|
||||
<option
|
||||
selected
|
||||
id="'.$id.'"
|
||||
class="filter_menu_item '.$menu_name_class.'"
|
||||
data-menu_index="menu_name"
|
||||
>
|
||||
'.$key.'
|
||||
</option>
|
||||
';
|
||||
foreach ($filter as $key_filter => $value) {
|
||||
$id = "filter_"
|
||||
. $key
|
||||
. "_"
|
||||
. str_replace( " ", "_", $value->_name)
|
||||
;
|
||||
$content .= '
|
||||
<option
|
||||
id="'.$id.'"
|
||||
class="filter_menu_item '.$menu_name_class.'"
|
||||
data-menu_index="'.$key_filter.'"
|
||||
>
|
||||
'.$value->_name.'
|
||||
</option>
|
||||
';
|
||||
}
|
||||
$content .= '
|
||||
</select>
|
||||
';
|
||||
|
||||
return $content;
|
||||
};
|
||||
|
||||
function mp_filter_buttons($key, &$filter) {
|
||||
|
||||
/*
|
||||
onclick="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".', true)"
|
||||
*/
|
||||
$menu_name_class = 'filter_menu_'.str_replace(" ", "_", $key).'';
|
||||
$content = '';
|
||||
foreach ($filter as $key_filter => $value) {
|
||||
$id = "filter_"
|
||||
. $key
|
||||
. "_"
|
||||
. str_replace( " ", "_", $value->_name)
|
||||
;
|
||||
$content .= '
|
||||
<input
|
||||
type="checkbox"
|
||||
form="ljdp_form"
|
||||
id="'.$id.'"
|
||||
class="filter_menu_checkbox filter_menu_item '.$menu_name_class.'"
|
||||
onclick="filter_show_only(this, \''.$key.'\')"
|
||||
style="display:none;"
|
||||
data-menu_index="'.$key_filter.'",
|
||||
>
|
||||
<label
|
||||
for="'.$id.'"
|
||||
class="filter_menu filter_menu_checkbox"
|
||||
>
|
||||
<p>'.$value->_name.'</p>
|
||||
</label>
|
||||
';
|
||||
}
|
||||
|
||||
return $content;
|
||||
};
|
||||
|
||||
function mp_create_div(&$filters) {
|
||||
$mp_map_div = '
|
||||
<div id="ljdp_map_wrapper">
|
||||
<form id="ljdp_form" style="display:none;"></form>
|
||||
<div id="ljdp_map_filters">
|
||||
';
|
||||
|
||||
foreach ($filters as $key => $filter) {
|
||||
|
||||
if ($key == "mode")
|
||||
$mp_map_div .= mp_filter_buttons($key, $filter);
|
||||
else
|
||||
$mp_map_div .= mp_filter_drop_down($key, $filter);
|
||||
};
|
||||
|
||||
$mp_map_div .= '
|
||||
<input
|
||||
type="reset"
|
||||
form="ljdp_form"
|
||||
id="filter_menu_reset"
|
||||
class="filter_menu_button"
|
||||
onclick="filter_show_all()"
|
||||
style="display:none;"
|
||||
>
|
||||
<label
|
||||
for="filter_menu_reset"
|
||||
class="filter_menu filter_menu_reset"
|
||||
>
|
||||
<p>Effacer</p>
|
||||
</label>
|
||||
';
|
||||
|
||||
$mp_map_div .= '
|
||||
</div>
|
||||
<div id="ljdp_map"></div>
|
||||
</div>
|
||||
';
|
||||
|
||||
return $mp_map_div;
|
||||
};
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,196 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
GET_POST :
|
||||
|
||||
1 ID: 29693
|
||||
2 comment_count: "0"
|
||||
3 comment_status: "closed"
|
||||
4 filter: "raw"
|
||||
5 guid: "https://local_lejourduprof.com/?p=29693"
|
||||
6 menu_order: 0
|
||||
7 ping_status: "closed"
|
||||
8 pinged: ""
|
||||
9 post_author: "1"
|
||||
10 post_content: ""
|
||||
11 post_content_filtered: ""
|
||||
12 post_date: "2022-11-04 18:05:49"
|
||||
13 post_date_gmt: "2022-11-04 17:05:49"
|
||||
14 post_excerpt: "Les enseignants vont présenter les projets développés dans leurs classes et partager leurs pratiques et expériences."
|
||||
15 post_mime_type: ""
|
||||
16 post_modified: "2022-11-05 09:39:46"
|
||||
17 post_modified_gmt: "2022-11-05 08:39:46"
|
||||
18 post_name: "construisons-ensemble-lavenir"
|
||||
19 post_parent: 0
|
||||
20 post_password: ""
|
||||
21 post_status: "draft"
|
||||
22 post_title: "Construisons ensemble l'avenir"
|
||||
23 post_type: "post"
|
||||
24 to_ping: ""
|
||||
*/
|
||||
|
||||
/*
|
||||
GET_POST_CUSTOM :
|
||||
|
||||
activite_concerne : "les enseignants de français langue étrangère ou français langue seconde"
|
||||
adresse : "Institut français du Liban, Beirut, Lebanon"
|
||||
adresse_courriel : "ihoteit@hotmail.com"
|
||||
adresse_courriel_de_contact : "ihoteit@hotmail.com"
|
||||
categorie : "Rencontre/Témoignage"
|
||||
composition : [ "Association de professeurs de français membre du réseau FIPF", "Ambassade de France/Institut français", "Bureau ou représentation de l'OIF" ]
|
||||
composition_1 : "Association Libanaise des Enseignants de Français, ALEF"
|
||||
composition_2 : "Institut français au Liban"
|
||||
composition_3 : "Représentation OIF"
|
||||
composition_4 : ""
|
||||
composition_autres : ""
|
||||
date : "2023-11-23"
|
||||
depenses_prevues : " collation, pins-souvenirs , déplacements, filmage et photos, affiches, secrétariat et frais divers"
|
||||
description_courte : "Une rencontre-témoignage festive en présence des décideurs, des acteurs de la francophonie au Liban, pays fier de son plurilinguisme et sa diversité\n"
|
||||
description_longue : "Enseignants et élèves témoigneront des opportunités et des atouts que l’enseignement et l’apprentissage du français leur offrent à tous les niveaux : éducatif, personnel, professionnel, social, interculturel et humain. Leur amour pour le français, moyen d’ouverture au monde francophone ainsi qu’à l’international, est sans égal dans un pays plurilingue comme le Liban !\nUne réception clôturera cette belle journée de tous ceux qui œuvrent pour l’expansion de la langue et des valeurs françaises et francophones.\nProgramme\nOuverture: Discours des officiels\nChansons et musique. Trois performances musicales animeraient la cérémonie, au début, au milieu et à la fin\ntémoignages des enseignants .\n\n\n"
|
||||
engagement : ""
|
||||
fichier : "https://lejourdesprofs.org/wp-content/uploads/2023/09/Budget_previsionnel_JIPF_2023-envoye.docx"
|
||||
financement : [ 'a:1:{i:0;s:3:"oui";}' ]
|
||||
fonction : "Secrétaire Générale"
|
||||
heure_de_debut : "16H "
|
||||
heure_de_fin : "18H"
|
||||
institution : "Association Libanaise des Enseignants de Français,ALEF"
|
||||
lien_internet : "http://alef-liban.org"
|
||||
liste_des_depenses : "collation, pins-souvenirs , déplacements, filmage et photos, gestion de la communication , suivi logistique et technique, affiches , secrétariat et frais divers .\n"
|
||||
location : { address:"VGJ7+34P, Beyrouth, Liban", approximate:false, city:"Beyrouth", country:"Liban", street:"", coordinates:{ lat:33.8802185, lng:35.5128288 } }
|
||||
mode : [ "En présentiel" ]
|
||||
montant_demande : "1400 euros"
|
||||
nom : "Slim-Hoteit"
|
||||
participation : "100 participants"
|
||||
pays : ""
|
||||
plan_de_communication : "Avant : diffusion très large de l'information concernant la JIPF : réseaux sociaux et sites internet ALEF, FIPF, IFprof et journaux (L'Orient le Jour)\nPendant : présence des journalistes et couverture en directe sur la page facebook de l'ALEF\nAprès : large diffusion des rapports ,photos et vidéos dans la presse et sur les réseaux sociaux"
|
||||
prenom : "Ilham"
|
||||
public_vise : "100 personnes: officiels, enseignants, élèves, étudiants "
|
||||
recettes_prevues : "Participation de l'ALEF: gestion de la communication avant, pendant et après , suivi logistique et technique"
|
||||
resultat_attendu : " les recettes couvriront les dépenses"
|
||||
resultats_attendus : "Echanger dans une ambiance festive et rendre hommage aux enseignantes et enseignants le jour de leur fete internationale"
|
||||
se_connecter : ""
|
||||
telephone : "009613180576"
|
||||
*/
|
||||
|
||||
function mp_get_published_posts() {
|
||||
|
||||
$get_posts_args = array(
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'post',
|
||||
);
|
||||
$posts_published = get_posts($get_posts_args);
|
||||
|
||||
return $posts_published;
|
||||
}
|
||||
|
||||
function mp_fill_fields_value($id) {
|
||||
|
||||
/*
|
||||
* get_field is an ACF function
|
||||
* in "pure" worpdress use :
|
||||
* get_post_meta or get_post_custom
|
||||
* - https://developer.wordpress.org/reference/functions/get_post_meta/
|
||||
* - https://developer.wordpress.org/reference/functions/get_post_custom/
|
||||
* if you try to use `get_fields(id)` to retrieve all the acf7 custom fields,
|
||||
* sometimes it fails eventhough you can get a specific value with `get_field(value, id)`,
|
||||
* it's because acf7 didn´t insert the field itself and so some hidden data is not there :
|
||||
* - https://coreysalzano.com/wordpress/acf-get_fields-not-working-but-get_field-does/
|
||||
*/
|
||||
|
||||
// add fields
|
||||
$fields = array(
|
||||
"heure_de_debut" => "string",
|
||||
"heure_de_fin" => "string",
|
||||
"categorie" => "string",
|
||||
"date" => "string",
|
||||
"pays" => "string",
|
||||
"adresse" => "string",
|
||||
"prenom" => "string",
|
||||
"nom" => "string",
|
||||
"location" => "object",
|
||||
);
|
||||
$event = (object)[];
|
||||
foreach($fields as $field => $of_type) {
|
||||
$value = get_field($field, $id);
|
||||
|
||||
//$actual_type = gettype($value);
|
||||
//if ($actual_type !== $of_type) {
|
||||
// mp_console_log("field '" . $field . "' has a value of type '" . $actual_type . "' instead of '" . $of_type . "'");
|
||||
//}
|
||||
|
||||
if ($value === "↓")
|
||||
$value = "Autre";
|
||||
if (gettype($value) === "string")
|
||||
$value = trim($value, " ");
|
||||
$event->$field = $value;
|
||||
}
|
||||
|
||||
// add mode irl or online (irl: true | false)
|
||||
$presentiel = get_field("mode", $id);
|
||||
$event->irl = false;
|
||||
if (isset($presentiel[0])) {
|
||||
if ($presentiel[0] === "En présentiel")
|
||||
$event->irl = true;
|
||||
}
|
||||
|
||||
// add post url
|
||||
$event->url = get_post_permalink($id);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
function mp_get_published_events() {
|
||||
$posts_list = mp_get_published_posts();
|
||||
|
||||
$events = [];
|
||||
foreach ($posts_list as $post) {
|
||||
$event = mp_fill_fields_value($post->ID);
|
||||
$event->id = $post->ID;
|
||||
$event->title = trim($post->post_title, " ");
|
||||
$event->index = null;
|
||||
array_push($events, $event);
|
||||
}
|
||||
return $events;
|
||||
}
|
||||
|
||||
/*
|
||||
event : {}
|
||||
- heure_de_debut : "";
|
||||
- heure_de_fin : "";
|
||||
- categorie : "";
|
||||
- date : "";
|
||||
- pays : "";
|
||||
- ville : "";
|
||||
- adresse : "";
|
||||
- prenom : "";
|
||||
- nom : "";
|
||||
- irl : bool;
|
||||
- id : x;
|
||||
- index : x (default null);
|
||||
- title : "";
|
||||
- url : "";
|
||||
- location : {}
|
||||
- street : "";
|
||||
- city : "";
|
||||
- country : "";
|
||||
- address : "";
|
||||
- approximate : bool;
|
||||
- coordinates : {}
|
||||
- lat : x;
|
||||
- lng : x;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------
|
||||
|
||||
Object {
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,169 +0,0 @@
|
||||
<?php
|
||||
|
||||
function mp_filter_compare($a, $b) {
|
||||
|
||||
$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) {
|
||||
foreach ($menu as $field) {
|
||||
if ($field->_name == $name)
|
||||
return $field;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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:"", ... ]
|
||||
* name : field's values -> countries, cities, categories, ...
|
||||
* menu : [ { _name:"", field_1:[], field_2:[] }, ... ]
|
||||
* index : index of this event in locations[] array
|
||||
*/
|
||||
function mp_fill_name($fields, $name, &$menu, $index, &$event) {
|
||||
if ($fields[$name] == null)
|
||||
return;
|
||||
if (gettype($fields[$name]) != 'string')
|
||||
return;
|
||||
if (strlen($fields[$name]) == 0)
|
||||
return;
|
||||
// menu_item, ex: for menu "countries" -> france
|
||||
$menu_item = mp_already_in_menu($menu, $fields[$name]);
|
||||
if ($menu_item != null) {
|
||||
// add to this menu item, eg "Austria", the infos of this
|
||||
// event, like "city" or "category", if not there already
|
||||
foreach ($fields as $key_field => $value) {
|
||||
// no need to add name if already exist
|
||||
if ($key_field == $name)
|
||||
continue;
|
||||
if (! isset($menu_item->$key_field) )
|
||||
$menu_item->$key_field = [];
|
||||
if (!is_string($value)) {
|
||||
//mp_console_log("pour l'article '$event->title', le champ '$key_field' est supposé être de type 'string', mais il est de type '" . gettype($value) . "'");
|
||||
//if ( ! add_post_meta( $id, 'problem', "$value", true ) )
|
||||
// update_post_meta( $id, 'problem', "" );
|
||||
continue;
|
||||
}
|
||||
if (strlen($value) != 0) {
|
||||
if (! in_array($value, $menu_item->$key_field) )
|
||||
array_push($menu_item->$key_field, $value);
|
||||
}
|
||||
}
|
||||
// add location index, if not there already
|
||||
if (! in_array($index, $menu_item->indexes) ) {
|
||||
array_push($menu_item->indexes, $index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$menu_item = (object)[];
|
||||
$menu_item->_name = $fields[$name];
|
||||
// add lists of event info (cities, countries, ...)
|
||||
foreach ($fields as $key_field => $value) {
|
||||
if ($key_field == $name)
|
||||
continue;
|
||||
$menu_item->$key_field = [];
|
||||
if (!is_string($value)) {
|
||||
//mp_console_log("pour l'article '$event->title', le champ '$key_field' est supposé être de type 'string', mais il est de type '" . gettype($value) . "'");
|
||||
continue;
|
||||
}
|
||||
if (strlen($value) != 0)
|
||||
array_push($menu_item->$key_field, $value);
|
||||
}
|
||||
// add list of location index
|
||||
$menu_item->indexes = [$index];
|
||||
|
||||
// and add this item to list of menu
|
||||
array_push($menu, $menu_item);
|
||||
}
|
||||
}
|
||||
|
||||
function mp_get_filters(&$events) {
|
||||
$filters = (object)[];
|
||||
|
||||
foreach ($events as $event) {
|
||||
|
||||
// no index means no coordinates
|
||||
$index = $event->index;
|
||||
if ($index === null)
|
||||
continue;
|
||||
|
||||
// create array of menus
|
||||
$fields = array(
|
||||
"Pays" => $event->location->country,
|
||||
"Catégories" => $event->categorie,
|
||||
"mode" => ($event->irl)? "En présentiel" : "En ligne",
|
||||
);
|
||||
//mp_console_log("event: ");
|
||||
//mp_console_log($event);
|
||||
|
||||
// fill all menu with other menus without doubles
|
||||
foreach ($fields as $name => $value) {
|
||||
if (! isset($filters->$name))
|
||||
$filters->$name = [];
|
||||
mp_fill_name($fields, $name, $filters->$name, $index, $event);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($filters as $key => $value) {
|
||||
usort($filters->$key, 'mp_filter_compare');
|
||||
}
|
||||
|
||||
return $filters;
|
||||
}
|
||||
|
||||
/*
|
||||
{ }
|
||||
{ [ ] }
|
||||
filters: { - countries : [ { - _name : "" } ] }
|
||||
{ [ { - categories: [] } ] }
|
||||
{ [ { - indexes : [] }, ... ] }
|
||||
{ [ ] }
|
||||
{ }
|
||||
{ - categories: }
|
||||
{ - modes : }
|
||||
{ }
|
||||
*/
|
||||
|
||||
/*
|
||||
event : {}
|
||||
- heure_de_debut : "";
|
||||
- heure_de_fin : "";
|
||||
- categorie : "";
|
||||
- date : "";
|
||||
- pays : "";
|
||||
- ville : "";
|
||||
- adresse : "";
|
||||
- prenom : "";
|
||||
- nom : "";
|
||||
- irl : bool;
|
||||
- id : x;
|
||||
- index : x;
|
||||
- url : "";
|
||||
- title : "";
|
||||
- location : {}
|
||||
- street : "";
|
||||
- city : "";
|
||||
- country : "";
|
||||
- address : "";
|
||||
- approximate : bool;
|
||||
- coordinates : {}
|
||||
- lat : x;
|
||||
- lng : x;
|
||||
*/
|
||||
|
||||
?>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
function mp_coord_already_exist(&$coordinates, &$locations) {
|
||||
foreach ($locations as $location) {
|
||||
if ($location->coordinates->lat == $coordinates->lat)
|
||||
if ($location->coordinates->lng == $coordinates->lng)
|
||||
return $location;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function mp_sort_n_insert(&$event, &$locations) {
|
||||
$coordinates = $event->location->coordinates;
|
||||
if ($coordinates == null)
|
||||
return;
|
||||
|
||||
$already_exist = mp_coord_already_exist($coordinates, $locations);
|
||||
if ($already_exist) {
|
||||
// add index to the event
|
||||
$index = $already_exist->index;
|
||||
$event->index = $index;
|
||||
// add event to events[]
|
||||
array_push($already_exist->events, $event);
|
||||
}
|
||||
else {
|
||||
// create new location object
|
||||
$location = (object)[];
|
||||
$location->events = [];
|
||||
|
||||
// add index to the location and event
|
||||
$index = count($locations);
|
||||
$location->index = $index;
|
||||
$event->index = $index;
|
||||
// add coordinates to the location
|
||||
$location->coordinates = $coordinates;
|
||||
// add first event to events[]
|
||||
array_push($location->events, $event);
|
||||
// add this location to locations[]
|
||||
array_push($locations, $location);
|
||||
}
|
||||
}
|
||||
|
||||
function mp_sort_events(&$events) {
|
||||
$locations = [];
|
||||
|
||||
foreach ($events as $event) {
|
||||
mp_sort_n_insert($event, $locations);
|
||||
};
|
||||
|
||||
return $locations;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
locations = [
|
||||
{
|
||||
index : x
|
||||
coordinates: {}
|
||||
events : [{}, ...]
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,405 +0,0 @@
|
||||
<?php
|
||||
|
||||
function mp_get_all_posts() {
|
||||
|
||||
$get_posts_args = array(
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'any',
|
||||
'post_type' => 'post',
|
||||
);
|
||||
$posts_list = get_posts($get_posts_args);
|
||||
|
||||
return $posts_list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_posts_published($posts_list) {
|
||||
|
||||
$posts_published = [];
|
||||
foreach ($posts_list as $post) {
|
||||
$status = $post->post_status;
|
||||
if ($status == "publish")
|
||||
array_push($posts_published, $post);
|
||||
}
|
||||
return $posts_published;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_have_no_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_have_no_coordinates($posts_list) {
|
||||
|
||||
$posts_no_coordinates = [];
|
||||
foreach ($posts_list as $post) {
|
||||
$location = get_field("location", $post->ID);
|
||||
if (empty($location))
|
||||
array_push($posts_no_coordinates, $post);
|
||||
else if (empty($location->coordinates))
|
||||
array_push($posts_no_coordinates, $post);
|
||||
}
|
||||
return $posts_no_coordinates;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
if (str_starts_with($value, '["')) {
|
||||
array_push($posts_bad_categories, $post);
|
||||
}
|
||||
}
|
||||
return $posts_bad_categories;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function count_publish($arr_posts) {
|
||||
return($arr_posts->post_status === "publish");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function mp_show_list_posts_no_address($posts) {
|
||||
|
||||
$all_posts = count($posts);
|
||||
$published_posts = count(array_filter($posts, "count_publish"));
|
||||
|
||||
echo <<<HTML
|
||||
<div style="border: 1px solid red; margin: 20px 20px 20px auto; padding: 0px 20px;">
|
||||
<p style="color: red;">
|
||||
<b>ATTENTION !</b>
|
||||
</p>
|
||||
<input type="checkbox" class="hide_not_published" id="posts_no_address_published">
|
||||
<label for="posts_no_address_published">afficher uniquement les articles publiés</label>
|
||||
<p>
|
||||
<b>
|
||||
HTML;
|
||||
echo "<span class='count_all_posts'>$all_posts</span>";
|
||||
echo "<span class='count_published_posts'>$published_posts</span>";
|
||||
echo '</b>';
|
||||
if (count($posts) == 1)
|
||||
echo " article n'a pas d'adresse :";
|
||||
else
|
||||
echo " articles n'ont pas d'adresses :";
|
||||
echo <<<HTML
|
||||
</p>
|
||||
<ul style="list-style: square inside;">
|
||||
HTML;
|
||||
foreach ($posts as $post) {
|
||||
if ($post->post_status === "publish") {
|
||||
echo <<<HTML
|
||||
<li class="jipf_post_publish"><b>
|
||||
HTML;
|
||||
}
|
||||
else {
|
||||
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
|
||||
</li>
|
||||
HTML;
|
||||
}
|
||||
echo <<<HTML
|
||||
</ul>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_show_list_posts_bad_categories($posts) {
|
||||
|
||||
$all_posts = count($posts);
|
||||
$published_posts = count(array_filter($posts, "count_publish"));
|
||||
|
||||
echo <<<HTML
|
||||
<div style="border: 1px solid red; margin: 20px 20px 20px auto; padding: 0px 20px;">
|
||||
<p style="color: red;">
|
||||
<b>ATTENTION !</b>
|
||||
</p>
|
||||
<input type="checkbox" class="hide_not_published" id="posts_bad_categories_published">
|
||||
<label for="posts_bad_categories_published">afficher uniquement les articles publiés</label>
|
||||
<p>
|
||||
<b>
|
||||
HTML;
|
||||
echo "<span class='count_all_posts'>$all_posts</span>";
|
||||
echo "<span class='count_published_posts'>$published_posts</span>";
|
||||
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) {
|
||||
if ($post->post_status === "publish") {
|
||||
echo <<<HTML
|
||||
<li class="jipf_post_publish"><b>
|
||||
HTML;
|
||||
}
|
||||
else {
|
||||
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) {
|
||||
|
||||
$all_posts = count($posts);
|
||||
$published_posts = count(array_filter($posts, "count_publish"));
|
||||
|
||||
echo <<<HTML
|
||||
<div style="border: 1px solid blue; margin: 20px 20px 20px auto; padding: 0px 20px;">
|
||||
<p style="color: blue;">
|
||||
<b>INFORMATION :</b>
|
||||
</p>
|
||||
<input type="checkbox" class="hide_not_published" id="posts_no_coordinates_published">
|
||||
<label for="posts_no_coordinates_published">afficher uniquement les articles publiés</label>
|
||||
<p>
|
||||
<b>
|
||||
HTML;
|
||||
echo "<span class='count_all_posts'>$all_posts</span>";
|
||||
echo "<span class='count_published_posts'>$published_posts</span>";
|
||||
echo '</b>';
|
||||
if (count($posts) == 1)
|
||||
echo " article n'a pas de coordonnees :";
|
||||
else
|
||||
echo " articles n'ont pas de coordonnees :";
|
||||
echo <<<HTML
|
||||
</p>
|
||||
<ul style="list-style: square inside;">
|
||||
HTML;
|
||||
foreach ($posts as $post) {
|
||||
if ($post->post_status === "publish") {
|
||||
echo <<<HTML
|
||||
<li class="jipf_post_publish"><b>
|
||||
HTML;
|
||||
}
|
||||
else {
|
||||
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
|
||||
</li>
|
||||
HTML;
|
||||
}
|
||||
echo <<<HTML
|
||||
</ul>
|
||||
<p style="background-color: lightblue; padding: 5px 10px; width: fit-content;">
|
||||
<b>pour actualiser les coordonnees d'un article, il suffit de le remettre en "brouillon" puis de le publier a nouveau</b>
|
||||
</p>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_show_post_number($posts_list, $posts_published) {
|
||||
|
||||
echo <<<HTML
|
||||
<p>nombre d'articles au total : <b>
|
||||
HTML;
|
||||
echo count($posts_list);
|
||||
echo "</b> (dont <b>";
|
||||
echo count($posts_published) . "</b>";
|
||||
if (count($posts_published) == 1)
|
||||
echo " publié)</p>";
|
||||
else
|
||||
echo " publiés)</p>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mp_show_api_key_n_ip() {
|
||||
global $mp_api_key;
|
||||
global $mp_api_key_geo;
|
||||
|
||||
echo <<<HTML
|
||||
<p>l'adresse ip du serveur est : <b>
|
||||
HTML;
|
||||
$external_ip = mp_get_ip();
|
||||
echo $external_ip;
|
||||
echo <<<HTML
|
||||
</b></p>
|
||||
HTML;
|
||||
|
||||
echo <<<HTML
|
||||
<p>les cles api de google maps utilisees sont :</p>
|
||||
<ul style="list-style: square inside; max-width: 500px;">
|
||||
<li>pour la carte : <b style='float:right; margin-right: 10px;'>
|
||||
HTML;
|
||||
echo $mp_api_key;
|
||||
echo <<<HTML
|
||||
</b></li>
|
||||
<li>pour les coordonnees : <b style='float:right; margin-right: 10px;'>
|
||||
HTML;
|
||||
echo $mp_api_key_geo;
|
||||
echo <<<HTML
|
||||
</b></li></ul>
|
||||
<p>(elles sont inscrites dans ./settings/mp_required.php)</p>
|
||||
HTML;
|
||||
|
||||
// need to use an api key with special restrictions :
|
||||
// https://stackoverflow.com/questions/42167695/api-key-browser-api-keys-cannot-have-referer-restrictions-when-used-with-this-ap
|
||||
echo <<<HTML
|
||||
<p style="color: blue;">
|
||||
<b>→ pour la carte : </b>
|
||||
cette cle api peut etre restreinte par url, et par api avec l'api <b>"Maps Javascript API"</b>
|
||||
</p>
|
||||
<p style="color: blue;">
|
||||
<b>→ pour les coordonnees : </b>
|
||||
cette cle api ne doit pas etre restreinte par url, elle peut etre restreinte par adresse ip du serveur, et par api avec l'api <b>"Geocoding API"</b>
|
||||
</p>
|
||||
<p style="color: blue;">
|
||||
<b>→ pour utiliser une seule cle api : </b>
|
||||
cette cle api ne doit pas etre restreinte ni par url ni par adresse ip, elle peut etre restreinte par api avec les deux apis <b>"Maps Javascript API"</b> et <b>"Geocoding API"</b>
|
||||
</p>
|
||||
HTML;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ljdp_map_plugin_content() {
|
||||
|
||||
$posts_list = mp_get_all_posts();
|
||||
//mp_console_log("posts_list: ");
|
||||
//mp_console_log($posts_list);
|
||||
|
||||
$posts_published = mp_posts_published($posts_list);
|
||||
|
||||
$posts_no_address = mp_have_no_address($posts_list);
|
||||
//mp_console_log("posts_no_address: ");
|
||||
//mp_console_log($posts_no_address);
|
||||
|
||||
$posts_no_coordinates = mp_have_no_coordinates($posts_list);
|
||||
//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;
|
||||
}
|
||||
input.hide_not_published:checked ~ ul li:not(.jipf_post_publish) {
|
||||
display: none;
|
||||
}
|
||||
.count_published_posts {
|
||||
display: none;
|
||||
}
|
||||
input.hide_not_published:checked ~ p .count_all_posts {
|
||||
display: none;
|
||||
}
|
||||
input.hide_not_published:checked ~ p .count_published_posts {
|
||||
display: inline;
|
||||
}
|
||||
</style>
|
||||
<div>
|
||||
<h2>JIPF map plugin</h2>
|
||||
HTML;
|
||||
|
||||
mp_show_post_number($posts_list, $posts_published);
|
||||
|
||||
mp_show_api_key_n_ip();
|
||||
|
||||
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);
|
||||
}
|
||||
else {
|
||||
echo <<<HTML
|
||||
<p style="color: green;">✔ tous les articles ont des coordonnees correctes :)</p>
|
||||
HTML;
|
||||
}
|
||||
|
||||
echo <<<HTML
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
function mp_get_address($id) {
|
||||
$presentiel = get_field("mode", $id);
|
||||
|
||||
if (empty($presentiel))
|
||||
return null;
|
||||
|
||||
// irl or online
|
||||
if ($presentiel[0] === "En présentiel")
|
||||
$address = get_field("adresse", $id);
|
||||
else
|
||||
$address = get_field("pays", $id);
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
||||
function mp_get_coordinates($id) {
|
||||
global $mp_api_key_geo;
|
||||
$event = (object)[];
|
||||
$location = (object)[];
|
||||
$location->coordinates = null;
|
||||
$location->street = "";
|
||||
$location->city = "";
|
||||
$location->country = "";
|
||||
$location->address = "";
|
||||
$location->approximate = false;
|
||||
|
||||
$address = mp_get_address($id);
|
||||
//mp_console_log("adresse: " . $address);
|
||||
|
||||
// get coordinates from google maps api
|
||||
$geolocation = 'https://maps.googleapis.com/maps/api/geocode/json'
|
||||
. '?language=fr'
|
||||
. '&address=' . urlencode($address)
|
||||
. '&key=' . $mp_api_key_geo;
|
||||
//mp_console_log("geolocation: " . $geolocation);
|
||||
$jsoncontent = file_get_contents($geolocation);
|
||||
//mp_console_log("jsoncontent: " . $jsoncontent);
|
||||
|
||||
// extract coordinates from json
|
||||
// https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Types
|
||||
$content = json_decode($jsoncontent);
|
||||
$location->coordinates = $content->results[0]->geometry->location;
|
||||
$location->address = $content->results[0]->formatted_address;
|
||||
foreach ($content->results[0]->address_components as $component) {
|
||||
if (in_array("street_number", $component->types))
|
||||
$location->street = $component->long_name;
|
||||
else if (in_array("route", $component->types)) {
|
||||
if (strlen($location->street) != 0)
|
||||
$location->street .= " ";
|
||||
$location->street .= $component->long_name;
|
||||
}
|
||||
else if (in_array("locality", $component->types))
|
||||
$location->city = $component->long_name;
|
||||
else if (in_array("postal_town", $component->types)) {
|
||||
if (strlen($location->city) != 0)
|
||||
$location->city .= "/";
|
||||
$location->city .= $component->long_name;
|
||||
}
|
||||
else if (in_array("country", $component->types))
|
||||
$location->country = $component->long_name;
|
||||
}
|
||||
if ($content->results[0]->geometry->location_type == "APPROXIMATE")
|
||||
$location->approximate = true;
|
||||
|
||||
// clean strings
|
||||
foreach ($location as $value) {
|
||||
if (gettype($value) != "string")
|
||||
continue;
|
||||
$value = trim($value, " ");
|
||||
}
|
||||
|
||||
return $location;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
@import "mp_info_windows.css";
|
||||
@import "mp_zoom.css";
|
||||
@import "mp_filters.css";
|
||||
|
||||
#ljdp_map_wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#ljdp_map {
|
||||
height: 600px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
@media only screen and (max-width: 700px) {
|
||||
#ljdp_map {
|
||||
height: 400px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
|
||||
/*
|
||||
* FILTERS
|
||||
*/
|
||||
|
||||
/*
|
||||
#ba197a;
|
||||
*/
|
||||
|
||||
/* **************************************
|
||||
GENERAL SETTINGS
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
#ljdp_map_filters,
|
||||
#ljdp_map_filters * {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
position: relative;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#ljdp_map_filters {
|
||||
display: flex !important;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
#ljdp_map_filters .filter_menu {
|
||||
display: flex !important;
|
||||
width: auto;
|
||||
cursor: pointer;
|
||||
border-radius: 3px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* **************************************
|
||||
DROP DOWN MENU
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
#ljdp_map_filters .filter_menu_drop {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
margin: 0px;
|
||||
padding: 5px;
|
||||
font-size: 100%;
|
||||
font-weight: 500;
|
||||
color: #666;
|
||||
border: 1px solid #ba197a;
|
||||
}
|
||||
#ljdp_map_filters .filter_menu_drop option {
|
||||
font-size: 100%;
|
||||
font-weight: 500;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* **************************************
|
||||
MENU CHECKBOX
|
||||
*/
|
||||
|
||||
#ljdp_map_filters .filter_menu_checkbox p {
|
||||
--size: 16px;
|
||||
--left-offset: calc( var(--size) + 5px );
|
||||
margin-left: var(--left-offset);
|
||||
}
|
||||
|
||||
#ljdp_map_filters .filter_menu_checkbox p::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: calc( 50% - var(--size) / 2 - 1px );
|
||||
left: calc( var(--left-offset) * -1 );
|
||||
border: 1px solid #ba197a;
|
||||
border-radius: 3px;
|
||||
box-sizing: border-box;
|
||||
width: var(--size);
|
||||
height: var(--size);
|
||||
}
|
||||
|
||||
#ljdp_map_filters input.filter_menu_checkbox:checked
|
||||
+ label.filter_menu_checkbox p::before {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
#ljdp_map_filters input.filter_menu_checkbox:disabled
|
||||
+ label.filter_menu_checkbox {
|
||||
cursor: default;
|
||||
}
|
||||
#ljdp_map_filters input.filter_menu_checkbox:disabled
|
||||
+ label.filter_menu_checkbox p::before {
|
||||
border-color: #ccc;
|
||||
background-color: #ccc;
|
||||
}
|
||||
#ljdp_map_filters input.filter_menu_checkbox:disabled
|
||||
+ label.filter_menu_checkbox p {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* **************************************
|
||||
MENU RESET
|
||||
*/
|
||||
|
||||
#ljdp_map_filters .filter_menu_reset {
|
||||
/*
|
||||
flex-shrink: 2;
|
||||
white-space: nowrap;
|
||||
*/
|
||||
border: 1px solid #ba197a;
|
||||
background-color: #ba197a;
|
||||
color: #fff;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* **************************************
|
||||
RESONSIVE DESIGN
|
||||
*/
|
||||
|
||||
|
||||
@media only screen and (max-width: 700px) {
|
||||
#ljdp_map_filters {
|
||||
flex-wrap: wrap;
|
||||
margin: 10px;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
|
||||
/*
|
||||
* INFO WINDOW
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/* **************************************
|
||||
GOOGLE WINDOW
|
||||
*/
|
||||
|
||||
div.gm-style-iw.gm-style-iw-c {
|
||||
padding: 0px !important;
|
||||
background-color: transparent;
|
||||
pointer-events: none;
|
||||
box-shadow: 0 2px 7px 1px rgba(0,0,0,.3);
|
||||
box-shadow: none;
|
||||
border-radius: 0 !important;
|
||||
max-width: 75vw !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* **************************************
|
||||
GOOGLE TRIANGLE
|
||||
*/
|
||||
|
||||
.gm-style-iw-tc {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* **************************************
|
||||
GOOGLE CROICE
|
||||
*/
|
||||
|
||||
button.gm-ui-hover-effect {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* **************************************
|
||||
CONTENT
|
||||
*/
|
||||
|
||||
#infowindow_limits,
|
||||
#infowindow_limits * {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
position: relative;
|
||||
margin: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#infowindow_limits {
|
||||
/* height must be twice js 'height' value (mp_info_windows.js -> '{ ... height: XXX }' */
|
||||
height: 550px;
|
||||
max-width: 380px;
|
||||
flex-direction: column;
|
||||
pointer-events: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#infowindow_limits .infowindow {
|
||||
pointer-events: auto;
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
padding: 0px;
|
||||
overflow: scroll;
|
||||
flex-direction: column;
|
||||
border-radius: 3px;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
#infowindow_limits #infowindow_close {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#infowindow_limits #infowindow_close::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: calc(50% - 0.8px);
|
||||
left: 25%;
|
||||
width: 50%;
|
||||
height: 1.6px;
|
||||
background-color: #fff;
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
#infowindow_limits #infowindow_close::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: calc(50% - 0.8px);
|
||||
left: 25%;
|
||||
width: 50%;
|
||||
height: 1.6px;
|
||||
background-color: #fff;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
#infowindow_limits .infowindow_head {
|
||||
padding: 5px 10px;
|
||||
margin: 0px;
|
||||
background-color: #ab197a;
|
||||
}
|
||||
|
||||
#infowindow_limits .infowindow_head p {
|
||||
font-size: 115%;
|
||||
font-weight: 500;
|
||||
line-height: 1.7em;
|
||||
color: #fff;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
#infowindow_limits .infowindow_body {
|
||||
padding: 10px 10px 10px 10px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#infowindow_limits .infowindow_body::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
margin: 0px;
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
#infowindow_limits .infowindow_body p {
|
||||
font-size: 115%;
|
||||
font-weight: 500;
|
||||
line-height: 1.7em;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* **************************************
|
||||
HIDE SCROLL BARS
|
||||
*/
|
||||
/* chrome safari opera */
|
||||
.gm-style-iw-d::-webkit-scrollbar,
|
||||
#infowindow_limits::-webkit-scrollbar,
|
||||
#infowindow_limits .infowindow::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.gm-style-iw-d,
|
||||
#infowindow_limits,
|
||||
#infowindow_limits .infowindow {
|
||||
-ms-overflow-style: none; /* Ie edge */
|
||||
scrollbar-width: none; /* firefox */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* **************************************
|
||||
MOBILE RESPONSIVE
|
||||
*/
|
||||
|
||||
@media only screen and (max-width: 400px) {
|
||||
#infowindow_limits .infowindow_body p,
|
||||
#infowindow_limits .infowindow_head p {
|
||||
font-size: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
/*
|
||||
* ZOOM BUTTONS
|
||||
*/
|
||||
|
||||
|
||||
/* hide the rectangular box container
|
||||
div.gmnoprint div {
|
||||
visibility: hidden;
|
||||
}
|
||||
*/
|
||||
/* shape buttons in circles
|
||||
button.gm-control-active {
|
||||
visibility: visible;
|
||||
border-radius: 50% !important;
|
||||
background-color: rgb(255, 255, 255) !important;
|
||||
}
|
||||
*/
|
||||
/* gap between the buttons
|
||||
button.gm-control-active ~ div {
|
||||
height: 10px !important;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
// https://stackify.com/how-to-log-to-console-in-php/
|
||||
|
||||
function mp_log($output) {
|
||||
$type = gettype($output);
|
||||
if ($type == 'object')
|
||||
$output = serialize($output);
|
||||
$time = date('H:i');
|
||||
$file = '/var/www/html/wp-debug.log';
|
||||
file_put_contents($file, $time . " " . $output . "\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
function mp_console_log($output) {
|
||||
$js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) . ');';
|
||||
$js_code = '<script>' . $js_code . '</script>';
|
||||
echo $js_code;
|
||||
}
|
||||
|
||||
// function mp_console_log($output, $with_script_tags = true) {
|
||||
// $js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) .
|
||||
// ');';
|
||||
// if ($with_script_tags) {
|
||||
// $js_code = '<script>' . $js_code . '</script>';
|
||||
// }
|
||||
// echo $js_code;
|
||||
// }
|
||||
|
||||
?>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
function mp_get_ip() {
|
||||
$external_ip = "";
|
||||
// curl with php :
|
||||
// https://www.php.net/manual/en/function.curl-init.php
|
||||
$ch = curl_init('https://ifconfig.me/ip');
|
||||
// CURLOPT_RETURNTRANSFER is set to true, which means that cURL should return the response from the HTTP request as a string, rather than printing it to the screen
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$external_ip = curl_exec($ch);
|
||||
//mp_console_log("ip:");
|
||||
//mp_console_log($external_ip);
|
||||
curl_close($ch);
|
||||
|
||||
return $external_ip;
|
||||
}
|
||||
|
||||
?>
|
||||
1
private
1
private
Submodule private deleted from d2e8cfabeb
19
srcs/.env
Normal file
19
srcs/.env
Normal file
@@ -0,0 +1,19 @@
|
||||
DB_HOST=mariadb
|
||||
DB_NAME=db_wp_jipf
|
||||
DB_PSWD='you dont want to know'
|
||||
DB_USER=user_wp_jipf
|
||||
EXECUTION_TIME=300
|
||||
HOME_PATH=/home/asususus
|
||||
HOST_VOLUME_DB=/home/asususus/data/lejourduprof/db_volume
|
||||
HOST_VOLUME_WP=/home/asususus/data/lejourduprof/wp_volume
|
||||
MAX_UPLOAD_SIZE=512
|
||||
NG_VOLUME_CERTS=/etc/ssl
|
||||
PROJECT=jipf
|
||||
WP_ADMIN=admin
|
||||
WP_ADMIN_EMAIL=admin@email.fr
|
||||
WP_ADMIN_PSWD='you shall not password !'
|
||||
WP_COMPLETE_URL=local_lejourduprof.com:3003
|
||||
WP_PORT=3003
|
||||
WP_TITLE=title
|
||||
WP_URL=local_lejourduprof.com
|
||||
WP_VOLUME_DIR=/var/www/html
|
||||
91
srcs/docker-compose.yml
Normal file
91
srcs/docker-compose.yml
Normal file
@@ -0,0 +1,91 @@
|
||||
# doc : https://docs.docker.com/compose/compose-file/compose-versioning/
|
||||
# version : https://docs.docker.com/compose/compose-file/compose-versioning/
|
||||
# version to download : https://github.com/docker/compose/releases/
|
||||
# had to remove the apt version because it was not up to date (sudo apt remove docker-compose)
|
||||
# then install as recommended : curl -SL https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
|
||||
# or (neat) : https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
|
||||
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
# ---------------------------------
|
||||
nginx:
|
||||
restart: on-failure
|
||||
networks:
|
||||
- inception
|
||||
ports:
|
||||
- "${WP_PORT}:443"
|
||||
volumes:
|
||||
- wp_volume:${WP_VOLUME_DIR}
|
||||
build:
|
||||
context: ./requirements/nginx
|
||||
args:
|
||||
- WP_URL=${WP_URL}
|
||||
- MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE}
|
||||
- WP_VOLUME_DIR=${WP_VOLUME_DIR}
|
||||
- NG_VOLUME_CERTS=${NG_VOLUME_CERTS}
|
||||
image: nginx
|
||||
container_name: nginx_container
|
||||
depends_on:
|
||||
wordpress:
|
||||
condition: service_started
|
||||
# ---------------------------------
|
||||
mariadb:
|
||||
restart: on-failure
|
||||
env_file: .env
|
||||
networks:
|
||||
- inception
|
||||
volumes:
|
||||
- db_volume:/var/lib/mysql
|
||||
build:
|
||||
context: ./requirements/mariadb
|
||||
args:
|
||||
- DB_HOST=${DB_HOST}
|
||||
- DB_NAME=${DB_NAME}
|
||||
- DB_USER=${DB_USER}
|
||||
- DB_PSWD=${DB_PSWD}
|
||||
healthcheck:
|
||||
test: mariadb -h ${DB_HOST} -u ${DB_USER} -p"${DB_PSWD}" -e exit 2> /dev/null
|
||||
interval: 1s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
image: mariadb
|
||||
container_name: mariadb_container
|
||||
# ---------------------------------
|
||||
wordpress:
|
||||
restart: on-failure
|
||||
env_file: .env
|
||||
networks:
|
||||
- inception
|
||||
volumes:
|
||||
- wp_volume:${WP_VOLUME_DIR}
|
||||
build:
|
||||
context: ./requirements/wordpress
|
||||
args:
|
||||
- WP_VOLUME_DIR=${WP_VOLUME_DIR}
|
||||
- MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE}
|
||||
- EXECUTION_TIME=${EXECUTION_TIME}
|
||||
image: wordpress
|
||||
container_name: wordpress_container
|
||||
depends_on:
|
||||
mariadb:
|
||||
condition: service_healthy
|
||||
|
||||
# specify path to named volumes : https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference
|
||||
volumes:
|
||||
db_volume:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
o: "bind"
|
||||
device: ${HOST_VOLUME_DB}
|
||||
wp_volume:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
o: "bind"
|
||||
device: ${HOST_VOLUME_WP}
|
||||
|
||||
networks:
|
||||
inception:
|
||||
|
||||
47
srcs/env_generator/create_env.sh
Executable file
47
srcs/env_generator/create_env.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# - this script creates a .env file in the same directory of the model.env
|
||||
# - the model.env file is given in argument, otherwise it default to current path
|
||||
|
||||
# change to where the script is relatively to where the execution is made
|
||||
#cd $(dirname $0)
|
||||
|
||||
CURRENT_PATH=$(dirname $0)
|
||||
if [ $# -eq 0 ]; then
|
||||
FILE_PATH="${CURRENT_PATH}/model.env"
|
||||
ENV_PATH=${CURRENT_PATH}
|
||||
else
|
||||
FILE_PATH="$1"
|
||||
ENV_PATH=$(dirname $FILE_PATH)
|
||||
fi
|
||||
if [ ! -f "$FILE_PATH" ]; then
|
||||
echo ""
|
||||
echo " no file 'model.env' found"
|
||||
echo ""
|
||||
echo " you need to create one in the same directory of this script,"
|
||||
echo " or to give the path to a valide one in argument"
|
||||
echo ""
|
||||
echo " like './create_env path/to/model.env'"
|
||||
echo " "
|
||||
echo " note that the .env file will be created where the model.env is"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TMP_FILE="tmpfile_3289442091310922474928"
|
||||
TMP_BEFORE="env_before.tmp"
|
||||
TMP_AFTER="env_after.tmp"
|
||||
|
||||
# add lines at beginning and end of a temp env file
|
||||
echo "set | sort > ${TMP_BEFORE}" > ${TMP_FILE}
|
||||
cat ${FILE_PATH} >> ${TMP_FILE}
|
||||
echo "set | sort > ${TMP_AFTER}" >> ${TMP_FILE}
|
||||
|
||||
source ${TMP_FILE}
|
||||
|
||||
# diff between the two set files == the newly created env var
|
||||
NEW_ENV=$(comm -13 ${TMP_BEFORE} ${TMP_AFTER} | grep -v "^_=")
|
||||
echo "${NEW_ENV}" > ${ENV_PATH}/.env
|
||||
|
||||
rm -f ${TMP_BEFORE} ${TMP_AFTER} ${TMP_FILE}
|
||||
|
||||
67
srcs/model.env
Normal file
67
srcs/model.env
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
PROJECT=jipf
|
||||
|
||||
# NGINX SETUP
|
||||
|
||||
NG_VOLUME_CERTS=/etc/ssl
|
||||
MAX_UPLOAD_SIZE=512
|
||||
|
||||
# MARIADB SETUP
|
||||
|
||||
DB_HOST=mariadb
|
||||
DB_NAME=db_wp_${PROJECT}
|
||||
DB_USER=user_wp_${PROJECT}
|
||||
DB_PSWD="you dont want to know"
|
||||
|
||||
# WORDPRESS SETUP
|
||||
|
||||
WP_URL=local_lejourduprof.com
|
||||
WP_PORT=3003
|
||||
# concat url with port if not 443
|
||||
WP_COMPLETE_URL="${WP_URL}"
|
||||
if [ ! ${WP_PORT} -eq 443 ]; then
|
||||
WP_COMPLETE_URL="${WP_URL}:${WP_PORT}"
|
||||
fi
|
||||
WP_VOLUME_DIR=/var/www/html
|
||||
#WP_VOLUME_PLUGINS=/home/www-data
|
||||
WP_TITLE=title
|
||||
|
||||
WP_ADMIN=admin
|
||||
WP_ADMIN_PSWD="you shall not password !"
|
||||
WP_ADMIN_EMAIL=admin@email.fr
|
||||
|
||||
# MAP
|
||||
|
||||
EXECUTION_TIME=300
|
||||
|
||||
# if you want to get the home directory you can use $(HOME)
|
||||
# however, this will not give the same result if you use sudo, ex :
|
||||
# ./create_env : /home/asususus
|
||||
# sudo ./create_env : /root
|
||||
# but you can use this command `eval echo "~$SUDO_USER"` to get
|
||||
# the home directory of the user using sudo, it works in non-sudo also :
|
||||
# - echo "$SUDO_USER" :
|
||||
# - in normal mode it outputs : ""
|
||||
# - in sudo mode it outputs the user : "username"
|
||||
# - same as $USER in normal mode
|
||||
# - echo "~$SUDO_USER" :
|
||||
# - in linux "~USER" is the home directory of a user
|
||||
# - but echo "something" will treat ~ as a string litteral
|
||||
# - so the output in mormal mode will be : "~"
|
||||
# - and in sudo mode it will be : "~username"
|
||||
# - eval echo "~$SUDO_USER" :
|
||||
# - eval will evaluate the expression and perform expansion one more time
|
||||
# - so it will evaluate the output of `echo "~$SUDO_USER"`
|
||||
# - in normal mode :
|
||||
# - it will evaluate : "~"
|
||||
# - and ouptput : "/home/username"
|
||||
# - in sudo mode :
|
||||
# - it will evaluate : "~username"
|
||||
# - and output : "/home/username"
|
||||
# - because "~username" expand in the home (~) directory of given user
|
||||
# https://stackoverflow.com/questions/77088135/makefile-subst-doesnt-use-make-variable-as-expected
|
||||
HOME_PATH=$(eval echo "~$SUDO_USER")
|
||||
|
||||
HOST_VOLUME_WP=${HOME_PATH}/data/lejourduprof/wp_volume
|
||||
HOST_VOLUME_DB=${HOME_PATH}/data/lejourduprof/db_volume
|
||||
|
||||
33
srcs/requirements/mariadb/Dockerfile
Normal file
33
srcs/requirements/mariadb/Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
FROM alpine:3.15
|
||||
|
||||
# vim and bash for debug
|
||||
RUN apk update && apk add \
|
||||
mariadb \
|
||||
mariadb-client \
|
||||
vim bash \
|
||||
&& \
|
||||
rm -rf /var/cache/apk*
|
||||
|
||||
# config file .cnf :
|
||||
COPY ./conf/mariadb-server.cnf.alpine /etc/my.cnf.d/mariadb-server.cnf
|
||||
|
||||
ARG DB_HOST
|
||||
ARG DB_NAME
|
||||
ARG DB_USER
|
||||
ARG DB_PSWD
|
||||
|
||||
# init mysql database
|
||||
RUN mysql_install_db --user=mysql --ldata=/var/lib/mysql && \
|
||||
mkdir -p /var/run/mysqld && \
|
||||
chown -R mysql:root /var/run/mysqld
|
||||
|
||||
# configure wp database
|
||||
COPY ./conf/create_db.sql /usr/bin/create_db.sql
|
||||
RUN sed -i "s/\${DB_HOST}/${DB_HOST}/g" /usr/bin/create_db.sql && \
|
||||
sed -i "s/\${DB_NAME}/${DB_NAME}/g" /usr/bin/create_db.sql && \
|
||||
sed -i "s/\${DB_USER}/${DB_USER}/g" /usr/bin/create_db.sql && \
|
||||
sed -i "s/\${DB_PSWD}/${DB_PSWD}/g" /usr/bin/create_db.sql
|
||||
|
||||
ENTRYPOINT [ "mysqld", "--user=mysql", "--init-file=/usr/bin/create_db.sql" ]
|
||||
|
||||
5
srcs/requirements/mariadb/conf/create_db.sql
Normal file
5
srcs/requirements/mariadb/conf/create_db.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
USE mysql;
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS ${DB_NAME};
|
||||
CREATE USER IF NOT EXISTS '${DB_USER}'@'%' IDENTIFIED BY '${DB_PSWD}';
|
||||
GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'%' with grant option;
|
||||
70
srcs/requirements/mariadb/conf/mariadb-server.cnf.alpine
Normal file
70
srcs/requirements/mariadb/conf/mariadb-server.cnf.alpine
Normal file
@@ -0,0 +1,70 @@
|
||||
# https://wiki.alpinelinux.org/wiki/MariaDB
|
||||
# inception modifications :
|
||||
#
|
||||
# [mysqld] :
|
||||
# < socket=/run/mysqld/mysqld.sock
|
||||
# >
|
||||
#
|
||||
# [mysqld] :
|
||||
# < skip-networking = false
|
||||
# > skip-networking
|
||||
# ---
|
||||
# < datadir = /var/lib/mysql
|
||||
# >
|
||||
# ---
|
||||
# < port = 3306
|
||||
# >
|
||||
# ---
|
||||
# < socket=/run/mysqld/mysqld.sock
|
||||
# >
|
||||
|
||||
#
|
||||
# These groups are read by MariaDB server.
|
||||
# Use it for options that only the server (but not clients) should see
|
||||
|
||||
# this is read by the standalone daemon and embedded servers
|
||||
[server]
|
||||
socket=/run/mysqld/mysqld.sock
|
||||
|
||||
# this is only for the mysqld standalone daemon
|
||||
[mysqld]
|
||||
skip-networking = false
|
||||
datadir = /var/lib/mysql
|
||||
port = 3306
|
||||
socket=/run/mysqld/mysqld.sock
|
||||
|
||||
# sock was in : /run/mysqld/mysqld.sock
|
||||
# mariadb thought it was in : /var/lib/mysql/mysql.sock
|
||||
# so I made : ln -s /run/mysqld/mysqld.sock /var/lib/mysql/mysql.sock
|
||||
|
||||
# Galera-related settings
|
||||
[galera]
|
||||
# Mandatory settings
|
||||
#wsrep_on=ON
|
||||
#wsrep_provider=
|
||||
#wsrep_cluster_address=
|
||||
#binlog_format=row
|
||||
#default_storage_engine=InnoDB
|
||||
#innodb_autoinc_lock_mode=2
|
||||
#
|
||||
# Allow server to accept connections on all interfaces.
|
||||
#
|
||||
#bind-address=0.0.0.0
|
||||
#
|
||||
# Optional setting
|
||||
#wsrep_slave_threads=1
|
||||
#innodb_flush_log_at_trx_commit=0
|
||||
|
||||
# this is only for embedded server
|
||||
[embedded]
|
||||
|
||||
# This group is only read by MariaDB servers, not by MySQL.
|
||||
# If you use the same .cnf file for MySQL and MariaDB,
|
||||
# you can put MariaDB-only options here
|
||||
[mariadb]
|
||||
|
||||
# This group is only read by MariaDB-10.5 servers.
|
||||
# If you use the same .cnf file for MariaDB of different versions,
|
||||
# use this group for options that older servers don't understand
|
||||
[mariadb-10.5]
|
||||
|
||||
56
srcs/requirements/nginx/Dockerfile
Normal file
56
srcs/requirements/nginx/Dockerfile
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
FROM alpine:3.15
|
||||
|
||||
# vim and bash for debug
|
||||
RUN apk update && apk add \
|
||||
nginx openssl \
|
||||
vim bash \
|
||||
&& \
|
||||
rm -rf /var/cache/apk*
|
||||
|
||||
# nginx conf
|
||||
COPY ./conf/nginx_main.conf.alpine /etc/nginx/nginx.conf
|
||||
COPY ./conf/nginx_http_server.conf /etc/nginx/http.d/
|
||||
# dir for logs
|
||||
RUN mkdir -p /var/log/nginx/
|
||||
|
||||
# create user www-data and assign it to group www-data
|
||||
RUN adduser -S www-data && \
|
||||
adduser www-data www-data && \
|
||||
adduser www-data nginx && \
|
||||
chmod +rwx /var/lib/nginx/tmp
|
||||
|
||||
# ARG variables are not persistent after the build process, in opposite to ENV
|
||||
ARG WP_URL
|
||||
ARG MAX_UPLOAD_SIZE
|
||||
ARG WP_VOLUME_DIR
|
||||
ARG NG_VOLUME_CERTS
|
||||
|
||||
# replace WP_URL
|
||||
RUN sed -i "s/\${WP_URL}/${WP_URL}/g" /etc/nginx/http.d/nginx_http_server.conf
|
||||
# replace max file size upload
|
||||
RUN sed -i "s/\(client_max_body_size \).*\(m;\)/\1${MAX_UPLOAD_SIZE}\2/g" /etc/nginx/nginx.conf
|
||||
|
||||
# create ssl certificates
|
||||
# command openssl :
|
||||
# - req : create a certificate signing request (CSR) or a self-signed certificate
|
||||
# - newkey rsa:2048 : generate a new RSA key pair with a key length of 2048 bits
|
||||
# - nodes : the private key should not be encrypted with a passphrase. This is useful for automated processes where entering a passphrase is not practical
|
||||
# - x509 : a self-signed certificate should be created
|
||||
# - days 365 : sets the validity period of the certificate to 365 days
|
||||
# - subj : sets the subject, information about the entity the certificate is issued to
|
||||
# - C, ST, L, O, OU, CN : country, state, locality, organization, organizational unit, and common name
|
||||
# - keyout : the filename for the private key file
|
||||
# - out : the filename for the output certificate file
|
||||
ARG SSL_KEY=${NG_VOLUME_CERTS}/private/${WP_URL}.key
|
||||
ARG SSL_CERT=${NG_VOLUME_CERTS}/certs/${WP_URL}.crt
|
||||
RUN mkdir -p ${NG_VOLUME_CERTS}; \
|
||||
cd ${NG_VOLUME_CERTS}; \
|
||||
mkdir private certs; \
|
||||
openssl req -newkey rsa:2048 -nodes -x509 -days 365 \
|
||||
-subj "/C=fr/ST=ile-de-france/L=paris/O=wp/OU=wp_local/CN=${WP_URL}" \
|
||||
-keyout ${SSL_KEY} \
|
||||
-out ${SSL_CERT};
|
||||
|
||||
ENTRYPOINT [ "nginx", "-g", "daemon off;" ]
|
||||
|
||||
52
srcs/requirements/nginx/conf/nginx_http_server.conf
Normal file
52
srcs/requirements/nginx/conf/nginx_http_server.conf
Normal file
@@ -0,0 +1,52 @@
|
||||
# doc :
|
||||
# https://nginx.org/en/docs/dirindex.html
|
||||
# https://www.nginx.com/resources/wiki/start/
|
||||
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
|
||||
# https://wiki.debian.org/Nginx/DirectoryStructure
|
||||
|
||||
server {
|
||||
listen 443 ssl; # for ipv4, on port 443, specifying that accepted connections should works in ssl mode
|
||||
listen [::]:443 ssl; # for ipv6
|
||||
server_name ${WP_URL};
|
||||
ssl_certificate /etc/ssl/certs/${WP_URL}.crt; # specifies the file with the ssl certificate (self signed here) generated by openssl
|
||||
ssl_certificate_key /etc/ssl/private/${WP_URL}.key; # specifies the file with the secret key of the certificate
|
||||
|
||||
root /var/www/html/; # contains default nginx index.nginx-debian.html
|
||||
index index.html index.php; # defines files that will be used as index (https://nginx.org/en/docs/http/ngx_http_index_module.html)
|
||||
|
||||
access_log /var/log/nginx/${WP_URL}.access.log;
|
||||
error_log /var/log/nginx/${WP_URL}.error.log;
|
||||
|
||||
# use fastcgi for all php files
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass wordpress:9000;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
# followings are from :
|
||||
# https://www.farinspace.com/wordpress-nginx-rewrite-rules/
|
||||
|
||||
# unless the request is for a valid file, send to bootstrap
|
||||
# without this, permalinks changes don't work
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^(.+)$ /index.php?q=$1 last;
|
||||
}
|
||||
|
||||
## enforce NO www
|
||||
#if ($host ~* ^www\.(.*)) {
|
||||
# set $host_without_www $1;
|
||||
# rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
|
||||
#}
|
||||
|
||||
## catch all
|
||||
#error_page 404 /index.php;
|
||||
|
||||
## deny access to apache .htaccess files
|
||||
#location ~ /\.ht {
|
||||
# deny all;
|
||||
#}
|
||||
|
||||
}
|
||||
|
||||
114
srcs/requirements/nginx/conf/nginx_main.conf.alpine
Normal file
114
srcs/requirements/nginx/conf/nginx_main.conf.alpine
Normal file
@@ -0,0 +1,114 @@
|
||||
# modifications from original :
|
||||
#
|
||||
# user :
|
||||
# < user www-data
|
||||
# > user nginx
|
||||
#
|
||||
# protocols :
|
||||
#
|
||||
# < ssl_protocols TLSv1.2 TLSv1.3;
|
||||
# > ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
|
||||
# /etc/nginx/nginx.conf
|
||||
|
||||
user www-data;
|
||||
|
||||
# Set number of worker processes automatically based on number of CPU cores.
|
||||
worker_processes auto;
|
||||
|
||||
# Enables the use of JIT for regular expressions to speed-up their processing.
|
||||
pcre_jit on;
|
||||
|
||||
# Configures default error logger.
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
|
||||
# Includes files with directives to load dynamic modules.
|
||||
include /etc/nginx/modules/*.conf;
|
||||
|
||||
# Uncomment to include files with config snippets into the root context.
|
||||
# NOTE: This will be enabled by default in Alpine 3.15.
|
||||
#include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
events {
|
||||
# The maximum number of simultaneous connections that can be opened by
|
||||
# a worker process.
|
||||
worker_connections 1024;
|
||||
}
|
||||
http {
|
||||
# Includes mapping of file name extensions to MIME types of responses
|
||||
# and defines the default type.
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Name servers used to resolve names of upstream servers into addresses.
|
||||
# It's also needed when using tcpsocket and udpsocket in Lua modules.
|
||||
#resolver 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001;
|
||||
|
||||
# Don't tell nginx version to the clients. Default is 'on'.
|
||||
server_tokens off;
|
||||
|
||||
# Specifies the maximum accepted body size of a client request, as
|
||||
# indicated by the request header Content-Length. If the stated content
|
||||
# length is greater than this size, then the client receives the HTTP
|
||||
# error code 413. Set to 0 to disable. Default is '1m'.
|
||||
client_max_body_size 1m;
|
||||
|
||||
# Sendfile copies data between one FD and other from within the kernel,
|
||||
# which is more efficient than read() + write(). Default is off.
|
||||
sendfile on;
|
||||
|
||||
# Causes nginx to attempt to send its HTTP response head in one packet,
|
||||
# instead of using partial frames. Default is 'off'.
|
||||
tcp_nopush on;
|
||||
|
||||
|
||||
# Enables the specified protocols. Default is TLSv1 TLSv1.1 TLSv1.2.
|
||||
# TIP: If you're not obligated to support ancient clients, remove TLSv1.1.
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
|
||||
# Path of the file with Diffie-Hellman parameters for EDH ciphers.
|
||||
# TIP: Generate with: `openssl dhparam -out /etc/ssl/nginx/dh2048.pem 2048`
|
||||
#ssl_dhparam /etc/ssl/nginx/dh2048.pem;
|
||||
|
||||
# Specifies that our cipher suits should be preferred over client ciphers.
|
||||
# Default is 'off'.
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Enables a shared SSL cache with size that can hold around 8000 sessions.
|
||||
# Default is 'none'.
|
||||
ssl_session_cache shared:SSL:2m;
|
||||
|
||||
# Specifies a time during which a client may reuse the session parameters.
|
||||
# Default is '5m'.
|
||||
ssl_session_timeout 1h;
|
||||
|
||||
# Disable TLS session tickets (they are insecure). Default is 'on'.
|
||||
ssl_session_tickets off;
|
||||
|
||||
|
||||
# Enable gzipping of responses.
|
||||
#gzip on;
|
||||
|
||||
# Set the Vary HTTP header as defined in the RFC 2616. Default is 'off'.
|
||||
gzip_vary on;
|
||||
|
||||
# Helper variable for proxying websockets.
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
# Specifies the main log format.
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
# Sets the path, format, and configuration for a buffered log write.
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
# Includes virtual hosts configs.
|
||||
include /etc/nginx/http.d/*.conf;
|
||||
}
|
||||
|
||||
# TIP: Uncomment if you use stream module.
|
||||
#include /etc/nginx/stream.conf;
|
||||
54
srcs/requirements/wordpress/Dockerfile
Normal file
54
srcs/requirements/wordpress/Dockerfile
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
FROM alpine:3.15
|
||||
|
||||
# all packages (from : https://mricher.fr/post/all-php-modules-for-alpine/)
|
||||
# apk update && apk add php7-bcmath php7-bz2 php7-calendar php7-cgi php7-common php7-ctype php7-curl php7-dba php7-dbg php7-dev php7-doc php7-dom php7-embed php7-enchant php7-exif php7-fileinfo php7-fpm php7-ftp php7-gd php7-gettext php7-gmp php7-iconv php7-imap php7-intl php7-json php7-ldap php7-litespeed php7-mbstring php7-mysqli php7-mysqlnd php7-odbc php7-opcache php7-openssl php7-pcntl php7-pdo php7-pdo_dblib php7-pdo_mysql php7-pdo_odbc php7-pdo_pgsql php7-pdo_sqlite php7-pear php7-pgsql php7-phar php7-phpdbg php7-posix php7-pspell php7-recode php7-session php7-shmop php7-simplexml php7-snmp php7-soap php7-sockets php7-sodium php7-sqlite3 php7-static php7-sysvmsg php7-sysvsem php7-sysvshm php7-tidy php7-tokenizer php7-wddx php7-xml php7-xmlreader php7-xmlrpc php7-xmlwriter php7-xsl php7-zip php7-pecl-xhprof php7-pecl-xhprof-assets php7-pecl-uuid php7-pecl-protobuf php7-pecl-xdebug php7-pecl-memcached php7-pecl-oauth php7-pecl-ssh2 php7-pecl-imagick php7-pecl-imagick-dev php7-pecl-vips php7-pecl-ast php7-pecl-event php7-pecl-redis php7-phalcon php7-pecl-apcu php7-pecl-timezonedb php7-pecl-mcrypt php7-pecl-mailparse php7-pecl-msgpack php7-pecl-yaml php7-pecl-zmq php7-brotli php7-pecl-amqp php7-pecl-couchbase php7-pecl-gmagick php7-pecl-igbinary php7-pecl-lzf
|
||||
# bash and vim for debug
|
||||
RUN apk update && apk add \
|
||||
php7 \
|
||||
php7-fpm \
|
||||
php7-mysqli \
|
||||
php7-phar \
|
||||
php7-json \
|
||||
php7-iconv \
|
||||
\
|
||||
php7-tokenizer \
|
||||
php7-zip \
|
||||
php7-dom \
|
||||
php7-curl \
|
||||
\
|
||||
mariadb-client \
|
||||
curl \
|
||||
bash vim
|
||||
RUN rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# fpm config
|
||||
COPY ./conf/www.conf /etc/php7/php-fpm.d/
|
||||
RUN mkdir /run/php/
|
||||
|
||||
ARG WP_VOLUME_DIR
|
||||
ARG MAX_UPLOAD_SIZE
|
||||
ARG EXECUTION_TIME
|
||||
|
||||
# replace max file size upload and execution time
|
||||
RUN sed -i "s/\(upload_max_filesize = \).*\(M\)/\1${MAX_UPLOAD_SIZE}\2/g" /etc/php7/php.ini && \
|
||||
sed -i "s/\(post_max_size = \).*\(M\)/\1${MAX_UPLOAD_SIZE}\2/g" /etc/php7/php.ini && \
|
||||
sed -i "s/\(max_execution_time = \).*/\1${EXECUTION_TIME}/g" /etc/php7/php.ini
|
||||
|
||||
# create www-data user and add to group
|
||||
RUN adduser -S www-data && \
|
||||
adduser www-data www-data
|
||||
|
||||
ENV PHP_VERSION="php-fpm7"
|
||||
|
||||
# install wp-cli : https://wp-cli.org/#installing
|
||||
# bug with wp commands : https://github.com/wp-cli/config-command/issues/31
|
||||
# change : mv wp-cli.phar /usr/local/bin/wp -> cp wp-cli.phar /usr/local/bin/wp
|
||||
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar &&\
|
||||
chmod +x wp-cli.phar && \
|
||||
cp wp-cli.phar /usr/local/bin/wp
|
||||
|
||||
COPY ./conf/wp_entrypoint.sh ./
|
||||
|
||||
ENTRYPOINT [ "sh", "wp_entrypoint.sh" ]
|
||||
|
||||
80
srcs/requirements/wordpress/conf/wp_entrypoint.sh
Normal file
80
srcs/requirements/wordpress/conf/wp_entrypoint.sh
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
|
||||
GRAY="\e[0;30m"
|
||||
RED="\e[0;31m"
|
||||
GREEN="\e[0;32m"
|
||||
YELLOW="\e[0;33m"
|
||||
BLUE="\e[0;34m"
|
||||
PURPLE="\e[0;35m"
|
||||
CYAN="\e[0;36m"
|
||||
WHITE="\e[0;37m"
|
||||
RESET="\e[0m"
|
||||
|
||||
# it gets the ENV variables from .env because specified in the docker-compose.yml file
|
||||
|
||||
# install wordpress with cli : https://make.wordpress.org/cli/handbook/how-to-install/
|
||||
# commands : https://developer.wordpress.org/cli/commands/
|
||||
# bug with wp commands : https://github.com/wp-cli/config-command/issues/31
|
||||
# -> use `php wp-cli.phar` instead of `wp` as command
|
||||
|
||||
echo -e ${YELLOW}download wordpress :${RESET}
|
||||
if ! wp core version --path="${WP_VOLUME_DIR}" 2> /dev/null
|
||||
then
|
||||
echo -e ${YELLOW}wp core download...${RESET}
|
||||
mkdir -p ${WP_VOLUME_DIR}
|
||||
#wp core download --path="${WP_VOLUME_DIR}" --allow-root
|
||||
php wp-cli.phar core download --path="${WP_VOLUME_DIR}" --allow-root
|
||||
else
|
||||
echo -e ${GREEN}already there !${RESET}
|
||||
fi
|
||||
|
||||
|
||||
# install wp if not already installed
|
||||
if ! wp core is-installed --path="${WP_VOLUME_DIR}" 2> /dev/null
|
||||
then
|
||||
echo -e ${YELLOW}installing :${RESET}
|
||||
|
||||
#wp config create \
|
||||
echo -e ${YELLOW}wp config create...${RESET}
|
||||
php wp-cli.phar config create \
|
||||
--dbhost="${DB_HOST}" \
|
||||
--dbname="${DB_NAME}" \
|
||||
--dbuser="${DB_USER}" \
|
||||
--dbpass="${DB_PSWD}" \
|
||||
--path="${WP_VOLUME_DIR}" --allow-root
|
||||
|
||||
#wp core install \
|
||||
echo -e ${YELLOW}wp core install...${RESET}
|
||||
php wp-cli.phar core install \
|
||||
--url="${WP_URL}" \
|
||||
--title="${WP_TITLE}" \
|
||||
--admin_user="${WP_ADMIN}" \
|
||||
--admin_email="${WP_ADMIN_EMAIL}" \
|
||||
--admin_password="${WP_ADMIN_PSWD}" \
|
||||
--skip-email \
|
||||
--path="${WP_VOLUME_DIR}" --allow-root
|
||||
|
||||
echo -e ${YELLOW}chown and chmod...${RESET}
|
||||
chown -R www-data:www-data /var/www/*
|
||||
chmod 755 -R /var/www/*
|
||||
|
||||
echo -e ${GREEN}done !${RESET}
|
||||
|
||||
else
|
||||
echo -e ${GREEN}wp is installed${RESET}
|
||||
|
||||
#https://stackoverflow.com/questions/56344567/wordpress-prevent-redirection-to-main-url
|
||||
echo -e ${YELLOW}checking config.php file with current url...${RESET}
|
||||
HOME=$(php wp-cli.phar config get WP_HOME --path=${WP_VOLUME_DIR})
|
||||
if [ ${HOME} != ${WP_COMPLETE_URL} ] ; then
|
||||
php wp-cli.phar config set WP_HOME ${WP_COMPLETE_URL} --path=${WP_VOLUME_DIR}
|
||||
fi
|
||||
SITEURL=$(php wp-cli.phar config get WP_SITEURL --path=${WP_VOLUME_DIR})
|
||||
if [ ${SITEURL} != ${WP_COMPLETE_URL} ] ; then
|
||||
php wp-cli.phar config set WP_SITEURL ${WP_COMPLETE_URL} --path=${WP_VOLUME_DIR}
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
exec "${PHP_VERSION}" -FR
|
||||
|
||||
446
srcs/requirements/wordpress/conf/www.conf
Normal file
446
srcs/requirements/wordpress/conf/www.conf
Normal file
@@ -0,0 +1,446 @@
|
||||
; inception modifications :
|
||||
;
|
||||
; listen :
|
||||
; < listen = wordpress:9000
|
||||
; > listen = /run/php/php7.3-fpm.sock
|
||||
|
||||
|
||||
; Start a new pool named 'www'.
|
||||
; the variable $pool can be used in any directive and will be replaced by the
|
||||
; pool name ('www' here)
|
||||
[www]
|
||||
|
||||
; Per pool prefix
|
||||
; It only applies on the following directives:
|
||||
; - 'access.log'
|
||||
; - 'slowlog'
|
||||
; - 'listen' (unixsocket)
|
||||
; - 'chroot'
|
||||
; - 'chdir'
|
||||
; - 'php_values'
|
||||
; - 'php_admin_values'
|
||||
; When not set, the global prefix (or /usr) applies instead.
|
||||
; Note: This directive can also be relative to the global prefix.
|
||||
; Default Value: none
|
||||
;prefix = /path/to/pools/$pool
|
||||
|
||||
; Unix user/group of processes
|
||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
||||
; will be used.
|
||||
user = www-data
|
||||
group = www-data
|
||||
|
||||
; The address on which to accept FastCGI requests.
|
||||
; Valid syntaxes are:
|
||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||
; a specific port;
|
||||
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||
; a specific port;
|
||||
; 'port' - to listen on a TCP socket to all addresses
|
||||
; (IPv6 and IPv4-mapped) on a specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = wordpress:9000
|
||||
|
||||
; Set listen(2) backlog.
|
||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||
;listen.backlog = 511
|
||||
|
||||
; Set permissions for unix socket, if one is used. In Linux, read/write
|
||||
; permissions must be set in order to allow connections from a web server. Many
|
||||
; BSD-derived systems allow connections regardless of permissions. The owner
|
||||
; and group can be specified either by name or by their numeric IDs.
|
||||
; Default Values: user and group are set as the running user
|
||||
; mode is set to 0660
|
||||
listen.owner = www-data
|
||||
listen.group = www-data
|
||||
;listen.mode = 0660
|
||||
; When POSIX Access Control Lists are supported you can set them using
|
||||
; these options, value is a comma separated list of user/group names.
|
||||
; When set, listen.owner and listen.group are ignored
|
||||
;listen.acl_users =
|
||||
;listen.acl_groups =
|
||||
|
||||
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
|
||||
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
||||
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
||||
; must be separated by a comma. If this value is left blank, connections will be
|
||||
; accepted from any ip address.
|
||||
; Default Value: any
|
||||
;listen.allowed_clients = 127.0.0.1
|
||||
|
||||
; Specify the nice(2) priority to apply to the pool processes (only if set)
|
||||
; The value can vary from -19 (highest priority) to 20 (lower priority)
|
||||
; Note: - It will only work if the FPM master process is launched as root
|
||||
; - The pool processes will inherit the master process priority
|
||||
; unless it specified otherwise
|
||||
; Default Value: no set
|
||||
; process.priority = -19
|
||||
|
||||
; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
|
||||
; or group is differrent than the master process user. It allows to create process
|
||||
; core dump and ptrace the process for the pool user.
|
||||
; Default Value: no
|
||||
; process.dumpable = yes
|
||||
|
||||
; Choose how the process manager will control the number of child processes.
|
||||
; Possible Values:
|
||||
; static - a fixed number (pm.max_children) of child processes;
|
||||
; dynamic - the number of child processes are set dynamically based on the
|
||||
; following directives. With this process management, there will be
|
||||
; always at least 1 children.
|
||||
; pm.max_children - the maximum number of children that can
|
||||
; be alive at the same time.
|
||||
; pm.start_servers - the number of children created on startup.
|
||||
; pm.min_spare_servers - the minimum number of children in 'idle'
|
||||
; state (waiting to process). If the number
|
||||
; of 'idle' processes is less than this
|
||||
; number then some children will be created.
|
||||
; pm.max_spare_servers - the maximum number of children in 'idle'
|
||||
; state (waiting to process). If the number
|
||||
; of 'idle' processes is greater than this
|
||||
; number then some children will be killed.
|
||||
; ondemand - no children are created at startup. Children will be forked when
|
||||
; new requests will connect. The following parameter are used:
|
||||
; pm.max_children - the maximum number of children that
|
||||
; can be alive at the same time.
|
||||
; pm.process_idle_timeout - The number of seconds after which
|
||||
; an idle process will be killed.
|
||||
; Note: This value is mandatory.
|
||||
pm = dynamic
|
||||
|
||||
; The number of child processes to be created when pm is set to 'static' and the
|
||||
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
|
||||
; This value sets the limit on the number of simultaneous requests that will be
|
||||
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
|
||||
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
|
||||
; CGI. The below defaults are based on a server without much resources. Don't
|
||||
; forget to tweak pm.* to fit your needs.
|
||||
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
|
||||
; Note: This value is mandatory.
|
||||
pm.max_children = 5
|
||||
|
||||
; The number of child processes created on startup.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
|
||||
pm.start_servers = 2
|
||||
|
||||
; The desired minimum number of idle server processes.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.min_spare_servers = 1
|
||||
|
||||
; The desired maximum number of idle server processes.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.max_spare_servers = 3
|
||||
|
||||
; The number of seconds after which an idle process will be killed.
|
||||
; Note: Used only when pm is set to 'ondemand'
|
||||
; Default Value: 10s
|
||||
;pm.process_idle_timeout = 10s;
|
||||
|
||||
; The number of requests each child process should execute before respawning.
|
||||
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||
; Default Value: 0
|
||||
;pm.max_requests = 500
|
||||
|
||||
; The URI to view the FPM status page. If this value is not set, no URI will be
|
||||
; recognized as a status page. It shows the following informations:
|
||||
; pool - the name of the pool;
|
||||
; process manager - static, dynamic or ondemand;
|
||||
; start time - the date and time FPM has started;
|
||||
; start since - number of seconds since FPM has started;
|
||||
; accepted conn - the number of request accepted by the pool;
|
||||
; listen queue - the number of request in the queue of pending
|
||||
; connections (see backlog in listen(2));
|
||||
; max listen queue - the maximum number of requests in the queue
|
||||
; of pending connections since FPM has started;
|
||||
; listen queue len - the size of the socket queue of pending connections;
|
||||
; idle processes - the number of idle processes;
|
||||
; active processes - the number of active processes;
|
||||
; total processes - the number of idle + active processes;
|
||||
; max active processes - the maximum number of active processes since FPM
|
||||
; has started;
|
||||
; max children reached - number of times, the process limit has been reached,
|
||||
; when pm tries to start more children (works only for
|
||||
; pm 'dynamic' and 'ondemand');
|
||||
; Value are updated in real time.
|
||||
; Example output:
|
||||
; pool: www
|
||||
; process manager: static
|
||||
; start time: 01/Jul/2011:17:53:49 +0200
|
||||
; start since: 62636
|
||||
; accepted conn: 190460
|
||||
; listen queue: 0
|
||||
; max listen queue: 1
|
||||
; listen queue len: 42
|
||||
; idle processes: 4
|
||||
; active processes: 11
|
||||
; total processes: 15
|
||||
; max active processes: 12
|
||||
; max children reached: 0
|
||||
;
|
||||
; By default the status page output is formatted as text/plain. Passing either
|
||||
; 'html', 'xml' or 'json' in the query string will return the corresponding
|
||||
; output syntax. Example:
|
||||
; http://www.foo.bar/status
|
||||
; http://www.foo.bar/status?json
|
||||
; http://www.foo.bar/status?html
|
||||
; http://www.foo.bar/status?xml
|
||||
;
|
||||
; By default the status page only outputs short status. Passing 'full' in the
|
||||
; query string will also return status for each pool process.
|
||||
; Example:
|
||||
; http://www.foo.bar/status?full
|
||||
; http://www.foo.bar/status?json&full
|
||||
; http://www.foo.bar/status?html&full
|
||||
; http://www.foo.bar/status?xml&full
|
||||
; The Full status returns for each process:
|
||||
; pid - the PID of the process;
|
||||
; state - the state of the process (Idle, Running, ...);
|
||||
; start time - the date and time the process has started;
|
||||
; start since - the number of seconds since the process has started;
|
||||
; requests - the number of requests the process has served;
|
||||
; request duration - the duration in µs of the requests;
|
||||
; request method - the request method (GET, POST, ...);
|
||||
; request URI - the request URI with the query string;
|
||||
; content length - the content length of the request (only with POST);
|
||||
; user - the user (PHP_AUTH_USER) (or '-' if not set);
|
||||
; script - the main script called (or '-' if not set);
|
||||
; last request cpu - the %cpu the last request consumed
|
||||
; it's always 0 if the process is not in Idle state
|
||||
; because CPU calculation is done when the request
|
||||
; processing has terminated;
|
||||
; last request memory - the max amount of memory the last request consumed
|
||||
; it's always 0 if the process is not in Idle state
|
||||
; because memory calculation is done when the request
|
||||
; processing has terminated;
|
||||
; If the process is in Idle state, then informations are related to the
|
||||
; last request the process has served. Otherwise informations are related to
|
||||
; the current request being served.
|
||||
; Example output:
|
||||
; ************************
|
||||
; pid: 31330
|
||||
; state: Running
|
||||
; start time: 01/Jul/2011:17:53:49 +0200
|
||||
; start since: 63087
|
||||
; requests: 12808
|
||||
; request duration: 1250261
|
||||
; request method: GET
|
||||
; request URI: /test_mem.php?N=10000
|
||||
; content length: 0
|
||||
; user: -
|
||||
; script: /home/fat/web/docs/php/test_mem.php
|
||||
; last request cpu: 0.00
|
||||
; last request memory: 0
|
||||
;
|
||||
; Note: There is a real-time FPM status monitoring sample web page available
|
||||
; It's available in: /usr/share/php/7.3/fpm/status.html
|
||||
;
|
||||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
;pm.status_path = /status
|
||||
|
||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||
; URI will be recognized as a ping page. This could be used to test from outside
|
||||
; that FPM is alive and responding, or to
|
||||
; - create a graph of FPM availability (rrd or such);
|
||||
; - remove a server from a group if it is not responding (load balancing);
|
||||
; - trigger alerts for the operating team (24/7).
|
||||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
;ping.path = /ping
|
||||
|
||||
; This directive may be used to customize the response of a ping request. The
|
||||
; response is formatted as text/plain with a 200 response code.
|
||||
; Default Value: pong
|
||||
;ping.response = pong
|
||||
|
||||
; The access log file
|
||||
; Default: not set
|
||||
;access.log = log/$pool.access.log
|
||||
|
||||
; The access log format.
|
||||
; The following syntax is allowed
|
||||
; %%: the '%' character
|
||||
; %C: %CPU used by the request
|
||||
; it can accept the following format:
|
||||
; - %{user}C for user CPU only
|
||||
; - %{system}C for system CPU only
|
||||
; - %{total}C for user + system CPU (default)
|
||||
; %d: time taken to serve the request
|
||||
; it can accept the following format:
|
||||
; - %{seconds}d (default)
|
||||
; - %{miliseconds}d
|
||||
; - %{mili}d
|
||||
; - %{microseconds}d
|
||||
; - %{micro}d
|
||||
; %e: an environment variable (same as $_ENV or $_SERVER)
|
||||
; it must be associated with embraces to specify the name of the env
|
||||
; variable. Some exemples:
|
||||
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
|
||||
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
|
||||
; %f: script filename
|
||||
; %l: content-length of the request (for POST request only)
|
||||
; %m: request method
|
||||
; %M: peak of memory allocated by PHP
|
||||
; it can accept the following format:
|
||||
; - %{bytes}M (default)
|
||||
; - %{kilobytes}M
|
||||
; - %{kilo}M
|
||||
; - %{megabytes}M
|
||||
; - %{mega}M
|
||||
; %n: pool name
|
||||
; %o: output header
|
||||
; it must be associated with embraces to specify the name of the header:
|
||||
; - %{Content-Type}o
|
||||
; - %{X-Powered-By}o
|
||||
; - %{Transfert-Encoding}o
|
||||
; - ....
|
||||
; %p: PID of the child that serviced the request
|
||||
; %P: PID of the parent of the child that serviced the request
|
||||
; %q: the query string
|
||||
; %Q: the '?' character if query string exists
|
||||
; %r: the request URI (without the query string, see %q and %Q)
|
||||
; %R: remote IP address
|
||||
; %s: status (response code)
|
||||
; %t: server time the request was received
|
||||
; it can accept a strftime(3) format:
|
||||
; %d/%b/%Y:%H:%M:%S %z (default)
|
||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
|
||||
; %T: time the log has been written (the request has finished)
|
||||
; it can accept a strftime(3) format:
|
||||
; %d/%b/%Y:%H:%M:%S %z (default)
|
||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
|
||||
; %u: remote user
|
||||
;
|
||||
; Default: "%R - %u %t \"%m %r\" %s"
|
||||
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
|
||||
|
||||
; The log file for slow requests
|
||||
; Default Value: not set
|
||||
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||
;slowlog = log/$pool.log.slow
|
||||
|
||||
; The timeout for serving a single request after which a PHP backtrace will be
|
||||
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
;request_slowlog_timeout = 0
|
||||
|
||||
; Depth of slow log stack trace.
|
||||
; Default Value: 20
|
||||
;request_slowlog_trace_depth = 20
|
||||
|
||||
; The timeout for serving a single request after which the worker process will
|
||||
; be killed. This option should be used when the 'max_execution_time' ini option
|
||||
; does not stop script execution for some reason. A value of '0' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
;request_terminate_timeout = 0
|
||||
|
||||
; The timeout set by 'request_terminate_timeout' ini option is not engaged after
|
||||
; application calls 'fastcgi_finish_request' or when application has finished and
|
||||
; shutdown functions are being called (registered via register_shutdown_function).
|
||||
; This option will enable timeout limit to be applied unconditionally
|
||||
; even in such cases.
|
||||
; Default Value: no
|
||||
;request_terminate_timeout_track_finished = no
|
||||
|
||||
; Set open file descriptor rlimit.
|
||||
; Default Value: system defined value
|
||||
;rlimit_files = 1024
|
||||
|
||||
; Set max core size rlimit.
|
||||
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
||||
; Default Value: system defined value
|
||||
;rlimit_core = 0
|
||||
|
||||
; Chroot to this directory at the start. This value must be defined as an
|
||||
; absolute path. When this value is not set, chroot is not used.
|
||||
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
|
||||
; of its subdirectories. If the pool prefix is not set, the global prefix
|
||||
; will be used instead.
|
||||
; Note: chrooting is a great security feature and should be used whenever
|
||||
; possible. However, all PHP paths will be relative to the chroot
|
||||
; (error_log, sessions.save_path, ...).
|
||||
; Default Value: not set
|
||||
;chroot =
|
||||
|
||||
; Chdir to this directory at the start.
|
||||
; Note: relative path can be used.
|
||||
; Default Value: current directory or / when chroot
|
||||
;chdir = /var/www
|
||||
|
||||
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
||||
; stderr will be redirected to /dev/null according to FastCGI specs.
|
||||
; Note: on highloaded environement, this can cause some delay in the page
|
||||
; process time (several ms).
|
||||
; Default Value: no
|
||||
;catch_workers_output = yes
|
||||
|
||||
; Decorate worker output with prefix and suffix containing information about
|
||||
; the child that writes to the log and if stdout or stderr is used as well as
|
||||
; log level and time. This options is used only if catch_workers_output is yes.
|
||||
; Settings to "no" will output data as written to the stdout or stderr.
|
||||
; Default value: yes
|
||||
;decorate_workers_output = no
|
||||
|
||||
; Clear environment in FPM workers
|
||||
; Prevents arbitrary environment variables from reaching FPM worker processes
|
||||
; by clearing the environment in workers before env vars specified in this
|
||||
; pool configuration are added.
|
||||
; Setting to "no" will make all environment variables available to PHP code
|
||||
; via getenv(), $_ENV and $_SERVER.
|
||||
; Default Value: yes
|
||||
;clear_env = no
|
||||
|
||||
; Limits the extensions of the main script FPM will allow to parse. This can
|
||||
; prevent configuration mistakes on the web server side. You should only limit
|
||||
; FPM to .php extensions to prevent malicious users to use other extensions to
|
||||
; execute php code.
|
||||
; Note: set an empty value to allow all extensions.
|
||||
; Default Value: .php
|
||||
;security.limit_extensions = .php .php3 .php4 .php5 .php7
|
||||
|
||||
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
||||
; the current environment.
|
||||
; Default Value: clean env
|
||||
;env[HOSTNAME] = $HOSTNAME
|
||||
;env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||
;env[TMP] = /tmp
|
||||
;env[TMPDIR] = /tmp
|
||||
;env[TEMP] = /tmp
|
||||
|
||||
; Additional php.ini defines, specific to this pool of workers. These settings
|
||||
; overwrite the values previously defined in the php.ini. The directives are the
|
||||
; same as the PHP SAPI:
|
||||
; php_value/php_flag - you can set classic ini defines which can
|
||||
; be overwritten from PHP call 'ini_set'.
|
||||
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
||||
; PHP call 'ini_set'
|
||||
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
||||
|
||||
; Defining 'extension' will load the corresponding shared extension from
|
||||
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
|
||||
; overwrite previously defined php.ini values, but will append the new value
|
||||
; instead.
|
||||
|
||||
; Note: path INI options can be relative and will be expanded with the prefix
|
||||
; (pool, global or /usr)
|
||||
|
||||
; Default Value: nothing is defined by default except the values in php.ini and
|
||||
; specified at startup with the -d argument
|
||||
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
|
||||
;php_flag[display_errors] = off
|
||||
;php_admin_value[error_log] = /var/log/fpm-php.www.log
|
||||
;php_admin_flag[log_errors] = on
|
||||
;php_admin_value[memory_limit] = 32M
|
||||
Submodule wordpress_docker deleted from 846a41063e
Reference in New Issue
Block a user