87 Commits

Author SHA1 Message Date
Hugo LAMY
cae655af7e also capturing pending paypal status 2026-02-11 12:33:52 +01:00
Hugo LAMY
17afb658af update submodules addresses 2026-02-11 10:26:08 +01:00
asus
f6b31dec8d updated private notes 2024-07-17 15:48:37 +02:00
asus
9cdc6a0091 changed submodule names 2024-07-17 15:47:28 +02:00
asus
e58e772c7c transformed xtxpatch into submodule 2024-07-17 15:37:07 +02:00
asus
edd6368a79 creation of the repo fbpatch 2024-07-17 15:32:28 +02:00
asus
9c51f794ca replaced custer by a got module 2024-07-17 15:25:16 +02:00
asus
cca1523bd7 updated notes 2024-05-28 17:54:40 +02:00
asus
ab5e209f8e fixed error in paiement fabrication when viewing paiement page back to normal prize 2024-05-04 16:16:05 +02:00
asus
3abe90b6d3 silent newsletter, and detect fabrication card on fabrication page 2024-05-04 15:49:13 +02:00
asus
03b24baaff updated notes 2024-05-02 18:09:06 +02:00
asus
b75f2718b8 wip newsletter i dont know how to detect if offer is new 2024-05-02 18:06:54 +02:00
asus
746919082a wip newsletter, started by creating the acf field and the scheduled event 2024-05-01 19:34:51 +02:00
asus
61be6143a3 cipf added new class for when state is not buying a new card at 5€ 2024-04-30 18:25:26 +02:00
asus
a73cacd5e9 deleted bat log 2024-04-30 18:23:38 +02:00
asus
0d20d71a7e custer fixed error in user id with email 2024-04-30 18:22:56 +02:00
asus
d402e9a7e3 fixed error in fbpatch dates 2024-04-25 16:24:33 +02:00
asus
101d27be55 fbatch dates new version only in front 2024-04-25 14:17:06 +02:00
asus
2205044f74 fixed error in handling dates with acf format as datepicker and not datetimepicker 2024-04-25 11:58:06 +02:00
asus
7a704a400b notes update 2024-04-25 11:24:12 +02:00
asus
fcfd52bda9 some cleaning in comments in fbpatch 2024-04-25 11:23:26 +02:00
asus
a357c64fbc fixed error when retrievieng acf dates with format 2024-04-24 19:03:31 +02:00
asus
687ac0cf4e cipf v0.5.11 added instructions for css class 2024-04-24 14:15:48 +02:00
asus
2397b24b57 fbpatch better version of dates patch 2024-04-24 11:17:35 +02:00
asus
24afcffae4 fbpatch v0.2.2 patch for dates 2024-04-24 00:28:25 +02:00
asus
343f34a15a for the moment dates have the apporpriate text output 2024-04-23 13:26:16 +02:00
asus
1447fdbc8e wip adding date to class was a mistake since it is global 2024-04-23 13:11:10 +02:00
asus
5553c78b21 wip datepicker js part is done, it creates a hidden field with date in acf format 2024-04-21 21:05:26 +02:00
asus
51097aa0de wip datepicker, added an intercepter to the originale function to get the arguments 2024-04-20 21:14:36 +02:00
asus
70b2afe577 wip resolving date format pbm, already figured out where it comes from and how to create a new one 2024-04-20 18:03:21 +02:00
asus
6bbedf52cb new update for readonly_acf field with better solution 2024-04-20 14:57:10 +02:00
asus
f2bcc51ec0 fixed pbm with field update prevention, but not sure if robust 2024-04-18 14:18:19 +02:00
asus
782d45f115 added a way to disable any acf fields 2024-04-18 10:58:53 +02:00
asus
b059101f15 fixed errors and remain files for cleaning 2024-04-17 16:56:56 +02:00
asus
3a1f0b07ee added css and functions to make some acf fields read-only 2024-04-17 16:47:14 +02:00
asus
62dcaa7672 updated offers expiration hanling with separate checkbox for each 3 offers 2024-04-16 16:43:11 +02:00
asus
d3e0fbb99e added new version number in custer 2024-04-16 14:24:20 +02:00
asus
d2e4edaec2 added comment to explain the protection 2024-04-16 14:22:44 +02:00
asus
8479efc51e added protection for first post 2024-04-16 14:19:14 +02:00
asus
f92e86a473 added function to handle deletion of image when prof is deleted in case it was not taken care of 2024-04-16 11:41:17 +02:00
asus
5a78817979 added protection if user dont exists in format user 2024-04-16 11:40:36 +02:00
asus
48ecd1d97b wip handle deleting images for prof deletion 2024-04-16 11:25:00 +02:00
asus
ba432acbfc removed error log 2024-04-16 10:34:38 +02:00
asus
5c09506356 removed error log 2024-04-16 10:29:14 +02:00
asus
6541f4d407 added info in cipf emails handling about logging 2024-04-15 18:45:18 +02:00
asus
e07aa0e57f fixed error in filter email when headers are not set or not an array 2024-04-15 18:44:09 +02:00
asus
2d6fef598b updated emails default send from true to on 2024-04-15 18:43:01 +02:00
asus
223b925097 cleaned email custer 2024-04-14 23:18:16 +02:00
asus
383de4ecb4 custer fixed error replacing all emails arguments 2024-04-14 22:59:13 +02:00
asus
f42ba9a1c3 updated email options 2024-04-14 21:00:58 +02:00
asus
14c9b6a6c2 added css class for fipf viewing user profiles 2024-04-13 10:13:03 +02:00
asus
bfa68a4dd7 cipf v 0.5.8 handle partner events 2024-04-12 17:13:57 +02:00
asus
6aa3915ef9 events actions and email for profs are now well supported, without repeatitions 2024-04-11 14:36:44 +02:00
asus
f2ca863dcb fixed error in handling emails reminder for profs card 2024-04-11 12:33:27 +02:00
asus
6a7de4dadd handle reminders before card expiration and account deletion 2024-04-11 11:34:27 +02:00
asus
6ecffc25f7 added email from 2024-04-10 22:31:43 +02:00
asus
265664537e better handling of init acf field 2024-04-10 21:04:52 +02:00
asus
114c6bfe38 new handling of events 2024-04-10 14:45:09 +02:00
asus
088c8f8c39 abort event scheduled for each actions, will try one daily check 2024-04-10 12:16:07 +02:00
asus
5cde5cd913 improved check before sending reminder emails 2024-04-10 11:55:28 +02:00
asus
215d778307 event deletion account reminder 2024-04-09 23:20:35 +02:00
asus
1775c86c25 adde event expire card reminder 2024-04-09 23:05:11 +02:00
asus
1f03fa1a7b added email when account expire 2024-04-09 22:36:02 +02:00
asus
a2e37cf621 schedult card expiration 2024-04-09 22:33:34 +02:00
asus
364553612a added email when account is deleted 2024-04-09 20:47:17 +02:00
asus
e48eb9cb51 event delete 2024-04-09 20:43:47 +02:00
asus
e77e41073f fixe small pbm with card change 2024-04-09 20:11:58 +02:00
asus
db4cd0ad55 added change card prof 5€ 2024-04-09 20:02:03 +02:00
asus
ec9bddaefd added options in paypal credential and payment 2024-04-09 18:16:38 +02:00
asus
731b69d97d new date handling 2024-04-09 15:54:44 +02:00
asus
36dc26817a cipf v 0.5.5 added history and order id acf 2024-04-09 11:46:08 +02:00
asus
272bc07f81 - added isset function in acf field centralized handling
- schedule event for order id works
2024-04-08 23:00:38 +02:00
asus
8925611217 smal fixe in history presentation 2024-04-08 22:30:56 +02:00
asus
598365330c - fixed error in acf fields handling
- added history handler
2024-04-08 22:19:02 +02:00
asus
4c0e4c001f update acf field handling to centerize every call 2024-04-08 21:43:08 +02:00
asus
1e291d16ba custer v 0.2.3 added menu with notice 2024-04-05 17:19:51 +02:00
asus
926bdc8417 added custer menu for notice 2024-04-05 00:07:01 +02:00
asus
f987c2a316 - fixed error partner page draft redirection with post id
- fixed error all logged in user could see partner post in draft
2024-04-04 22:54:28 +02:00
asus
6de3205480 added payment problem message 2024-04-04 20:27:02 +02:00
asus
29834a9b9b fixed error in checks partner own page and modify to draft 2024-04-04 17:35:32 +02:00
asus
4948298b8a - fixed error in plgntls debug logs
- fixed button partner modification page restrictions
2024-04-04 15:06:33 +02:00
asus
6cd25725e0 removed all nocache headers 2024-04-04 14:28:06 +02:00
asus
c87ba760fc - reorganized files
- fixed error in partner edti/creation page
2024-04-04 14:03:24 +02:00
asus
91a67d955b updated plgntls options to improve default with new options 2024-04-03 22:43:05 +02:00
asus
1628eac171 emails in progress 2024-04-03 16:23:14 +02:00
asus
19fc5f17a6 added protection when using get_plugins function outside amdin context 2024-04-03 16:22:42 +02:00
asus
11b4a2efcc cipf update payment handling error 2024-04-03 15:16:00 +02:00
79 changed files with 4402 additions and 4919 deletions

13
.gitmodules vendored
View File

@@ -1,6 +1,15 @@
[submodule "private"] [submodule "private"]
path = private path = private
url = git@bitbucket.org:hugogogo/2024_website_fipf_private.git url = gitea@gitea.hugulumu.com:pro/2024_WEBSITE_fipf_private.git
[submodule "wordpress_docker"] [submodule "wordpress_docker"]
path = wordpress_docker path = wordpress_docker
url = git@bitbucket.org:hugogogo/docker_wordpress.git url = gitea@gitea.hugulumu.com:perso/DOCKER_wordpress.git
[submodule "plugins/custer"]
path = plugins/custer
url = gitea@gitea.hugulumu.com:pro/2024_WORDPRESS_PLUGIN_custer.git
[submodule "plugins/fbpatch"]
path = plugins/fbpatch
url = gitea@gitea.hugulumu.com:pro/2024_WORDPRESS_PLUGIN_fbpatch.git
[submodule "plugins/xtxpatch"]
path = plugins/xtxpatch
url = gitea@gitea.hugulumu.com:pro/2024_WORDPRESS_PLUGIN_xtxpatch.git

304
gitlog.md Normal file
View File

@@ -0,0 +1,304 @@
2023-12-14 15:49:07 +0100 init with devis
2024-02-01 17:22:11 +0100 cleaned up private
2024-02-01 17:28:26 +0100 cleaned up private
2024-02-01 17:45:49 +0100 update remotes
2024-02-01 17:50:57 +0100 updated private
2024-02-07 13:19:47 +0100 added wordpress docker subomodule
2024-02-07 14:39:22 +0100 wip first shortcode
2024-02-07 18:46:28 +0100 - start a basic plugin that can send code to front - for the moment it send js scripts, css, and variables
2024-02-07 18:54:30 +0100 wip trying to get the var name directly, first try not working
2024-02-08 12:11:16 +0100 wip handle puting files and var on front
2024-02-08 12:31:07 +0100 - can add files to front with single function - can create html in shortcode with basic templates
2024-02-08 14:43:25 +0100 use compact with add_var_to_front
2024-02-08 15:24:22 +0100 added variables in create_html with compact
2024-02-08 15:28:18 +0100 removed templates in path to include html
2024-02-12 10:13:02 +0100 wip renaming plugins elements
2024-02-12 11:26:44 +0100 ini plugin
2024-02-12 11:42:56 +0100 update private notes
2024-02-13 12:35:31 +0100 correction in plugin utils function add_to_front in add_ajax_post the wp_enqueue_script has a wrong parameter with
2024-02-13 21:00:41 +0100 added notes in both submodules private and wordpress
2024-02-13 22:12:31 +0100 added corrections in submodule wordpress docker
2024-02-14 01:03:55 +0100 made a class version of plugin_tools
2024-02-14 02:49:14 +0100 added ajax call inside class plugin
2024-02-14 17:10:44 +0100 wip find user fields
2024-02-15 00:40:07 +0100 improved plugin class by changing for only one method to do all
2024-02-15 02:47:11 +0100 now ajax is in PLGMTLS object as a method
2024-02-15 02:51:22 +0100 litle bit of cleaning in plugin class
2024-02-17 20:18:36 +0100 wip trying to save acf fields from divi form builder
2024-02-18 01:21:08 +0100 - wip trying to patch jquery url validator - resolve conflict in addition of multiple vars and ajax function
2024-02-18 02:27:09 +0100 patch for jquery url validator working
2024-02-18 11:00:01 +0100 added url patch as a separate plugin
2024-02-18 13:06:02 +0100 - removed jquery validator url patch to put it in another plugin - starting to try the form_builder hooks for modif acf fields
2024-02-19 00:46:03 +0100 - moving ajax script outside plugin class, as a js file - wip trying to use the wordpress image editor
2024-02-19 02:38:50 +0100 wip image editor far from understand wordpress core
2024-02-20 10:09:05 +0100 trying to insert acf custom field to front
2024-02-20 23:44:10 +0100 submodules ipdates
2024-02-21 23:58:53 +0100 wip paypal tests
2024-02-22 11:50:01 +0100 small improvement in modals with diviengine-form-builder
2024-02-22 20:30:01 +0100 wip paypal with sdk not working
2024-02-22 23:44:22 +0100 sdk call works now, just the begining
2024-02-23 10:52:02 +0100 - added capacity in plugin tool to take urls - test front end integration ok
2024-02-23 19:36:03 +0100 - struggled to make ajax works, but now is ok - starting to make serverside works
2024-02-23 19:49:56 +0100 better file organisation
2024-02-23 21:03:34 +0100 wip route api_order
2024-02-23 23:43:23 +0100 try wordpress rest api instead of ajax
2024-02-24 01:19:39 +0100 created routes, but json parse error ate the end of transaction
2024-02-24 16:57:31 +0100 PAYPAL WORKING
2024-02-24 17:40:33 +0100 retrieving user that makes the purchase with nonce ok
2024-02-25 01:46:33 +0100 wip connecting user with payment
2024-02-25 11:02:47 +0100 wip track payment to user
2024-02-25 14:43:53 +0100 wip cron job to delete order id, but will deal with that later
2024-02-25 15:00:21 +0100 prefixed all paypal related fonctions with fipf
2024-02-25 18:11:33 +0100 payment update acf fields allright
2024-02-25 21:03:58 +0100 update private notes
2024-02-26 13:18:19 +0100 - forget old ajax wp, now use fetch wp - trying js files without imports
2024-02-27 01:54:46 +0100 wip trying to create better options to include scripts with attributes
2024-02-27 11:51:46 +0100 wip adding attributes, works with filter wp-script-attributes
2024-02-27 15:23:07 +0100 now we can add attributes to js files using the tools class
2024-02-29 01:04:41 +0100 wip trying to modify html before it is rendered
2024-02-29 23:45:02 +0100 - tests on editing author page with acf fields - some reflexions on registrations
2024-03-01 17:21:03 +0100 added inline code to plugin tools
2024-03-02 16:14:36 +0100 - added role at registration with xootix - cleaned folder
2024-03-02 21:43:43 +0100 some more little codes for restrictions and registrations
2024-03-03 01:37:10 +0100 shortcode to get user infos
2024-03-03 10:39:34 +0100 small improvement in print user infos list
2024-03-03 21:48:39 +0100 - added a reinit function for acf fields after form validation - added a plugin version of the modal patch for form builder
2024-03-04 08:52:18 +0100 renamed formbuilder patch files
2024-03-05 00:10:53 +0100 created a new function to filter emails
2024-03-05 09:55:54 +0100 upgraded email filter to filter also wp hook
2024-03-05 10:44:36 +0100 added check for logged in user in filter email
2024-03-05 17:22:11 +0100 - wip payment - already solved success and failure messages and redirection - solved increase date multiple times - users redirection works if error AND partner to posts instead of project
2024-03-06 13:53:47 +0100 wip payment kind of works with bugs
2024-03-06 23:44:46 +0100 - improved payement paypal for date and other things
2024-03-07 10:26:11 +0100 - payment : first date error corrected - payment : added httpErrorException - payment : error handling wip - profil page restriction gives access to admin and editor
2024-03-07 14:51:10 +0100 updated user info shortcode to output author page and format date
2024-03-07 15:13:16 +0100 small correction in user info
2024-03-07 17:05:55 +0100 - wip filter page prof - upgraded user info shortcode to default behavior on author page
2024-03-07 17:50:45 +0100 wip author page checks, waiting page redirection working
2024-03-07 19:03:42 +0100 updated filter email to filter the author page special keyword
2024-03-07 19:08:03 +0100 updated som error in filter email for special query author page
2024-03-07 19:21:11 +0100 update payment validation by changing prof to active
2024-03-07 21:34:48 +0100 wip prof check page now handle the success message on paiement
2024-03-07 22:32:50 +0100 changed all instances of fipf to cipf
2024-03-07 22:35:39 +0100 changed plugin name to cipf
2024-03-07 23:27:20 +0100 renew page message are working
2024-03-07 23:48:01 +0100 moved and updated reset fields into rebew file
2024-03-08 09:23:51 +0100 moved all const in class
2024-03-08 17:57:04 +0100 updates acf fields const values in class to avoid errors
2024-03-09 22:03:22 +0100 wip upgrade and clean payment process
2024-03-10 11:13:44 +0100 - added debug function - fixed issues in acf fields use
2024-03-10 14:12:24 +0100 changed meta field payment_status for acf field
2024-03-10 14:51:47 +0100 - renew state : removed - payment state : in acf
2024-03-10 22:37:38 +0100 - added a default css file to include to have a first handle - cahnged get_path/url to root_path/url - changed path setup -> now automatic from inside plugin
2024-03-10 22:53:15 +0100 added info in class about path construction
2024-03-10 23:12:20 +0100 card number id created
2024-03-11 00:02:55 +0100 changed all role occurences by a const
2024-03-11 23:20:38 +0100 wip check offres for newsletter
2024-03-12 19:54:18 +0100 - in plgntls transformed process to add fetch script even if list of srcs is empty - created a patch for form builder calculation
2024-03-12 21:53:32 +0100 - moved reset field function outside renew_card file - created a patch for formbuilder calculation pbm
2024-03-13 13:28:14 +0100 - wip create role at registration - upgraded shortcode user_infos to output acf format
2024-03-13 14:57:01 +0100 some improvments on shortcode user_info, to output the right secure string in most cases
2024-03-14 01:18:31 +0100 wip handle custom form submit
2024-03-14 10:29:02 +0100 added redirection without need of a page, use it for paypal success or failure message already
2024-03-14 12:31:31 +0100 wip debug redirections
2024-03-14 12:32:35 +0100 updated notes
2024-03-14 13:10:05 +0100 wip i broke everyhting :p
2024-03-14 13:48:19 +0100 nop it wasn't my plugin's fault
2024-03-14 13:48:37 +0100 Merge branch 'debug_routes'
2024-03-14 15:07:50 +0100 changed profil redirection so it does not need a real page anymore
2024-03-14 15:27:52 +0100 v 0.2.6
2024-03-14 18:35:21 +0100 fixed dates format error
2024-03-14 23:28:37 +0100 wip trying to force the acf id that formbuilder will use
2024-03-15 09:18:39 +0100 tried a fix on redirection without real page, by using template-redirection hook instead of init
2024-03-15 13:50:27 +0100 v0.2.8 wip can force the id of a user for a portion of page with shortcode
2024-03-17 02:27:28 +0100 created plugin custer, and removed shortcodes change_id and user_infos from cipf plugin
2024-03-17 02:28:27 +0100 custer v 0.1.1 : now fully working
2024-03-17 02:29:31 +0100 cipf v 0.2.9 : moved shortcodes change_id and user_info to another plugin, custer
2024-03-17 14:06:25 +0100 custer : changed namespace, now all function use it
2024-03-17 14:52:42 +0100 custer format output works with numbers
2024-03-17 15:28:08 +0100 - removed custom user function and put it in custer - changed main file for cipf instead of fipfcard - reset some fields after prof form validation
2024-03-17 17:59:27 +0100 price calculation now works whatever acf return is set
2024-03-17 17:59:48 +0100 redirections whould work now
2024-03-17 18:16:28 +0100 v 0.3.1 - reset cgv - price works with all acf returns for radio buttons - redirection works
2024-03-17 23:00:39 +0100 - v 0.3.2 : can hide or show admin menu
2024-03-18 12:23:27 +0100 change author id works for prof profil and prof form
2024-03-18 13:28:02 +0100 v 0.3.3 partner registration detected with slug using options and without referer
2024-03-18 13:30:17 +0100 updated notes
2024-03-19 07:11:04 +0100 v 0.1.4.1 correction new DateTime in shortcode, conflict with namespace
2024-03-19 07:11:45 +0100 v 0.1.4.2 temporary deactivate anchors
2024-03-19 07:24:53 +0100 wip registration partner role with xootix hook and hiden fields
2024-03-19 07:27:37 +0100 abandonned price calculation at payment time because of pbm with formbuilder
2024-03-19 07:28:17 +0100 wip account states
2024-03-19 07:30:59 +0100 update notes
2024-03-19 08:58:59 +0100 added dates functions for prof card
2024-03-19 12:37:16 +0100 created functions to handle all state changes
2024-03-19 13:06:16 +0100 most account states updating are working
2024-03-19 15:05:33 +0100 changed acf field access from _name to _key
2024-03-19 15:59:16 +0100 created css files for states displays
2024-03-19 16:27:38 +0100 v 0.3.4 states are now handled with specific functions for setting, getting, and adding css
2024-03-19 18:44:53 +0100 made the plugin dont redeclare font variable if used two times
2024-03-19 20:15:26 +0100 updated acf find non init field value with new technique to init with temp value first
2024-03-19 20:50:35 +0100 updated infos about states
2024-03-19 22:06:17 +0100 wip cahngin states
2024-03-19 22:47:00 +0100 fixed error in prof state for renew card
2024-03-19 23:48:40 +0100 partner redirection to page creation
2024-03-20 00:26:39 +0100 - most prof states shoud be ok - redirection partner page creation - user ids on checks states - reset cgv - restrict prof profil page
2024-03-20 01:02:46 +0100 - creates redirect-home function - restrict prof form to profs - restrict paypal page for prof only
2024-03-20 01:54:22 +0100 fixed pbm find author id ouside loop
2024-03-20 01:54:49 +0100 - hide admin bar for front user - admin page redirects non admin users
2024-03-20 01:58:37 +0100 v 0.3.9 profs are mostly ok i suppose, didn't checked all situations
2024-03-20 10:10:48 +0100 first step in making api keys modifiable in admin : using getter and setter instead of const
2024-03-20 11:24:40 +0100 fixed redirection preventing to edit in divi builder mode
2024-03-20 11:42:22 +0100 v 0.3.10 admin can validate payment from front
2024-03-20 14:44:19 +0100 new profs redirects to command
2024-03-20 15:29:34 +0100 rollback to not calculating price
2024-03-20 17:04:21 +0100 fixed error in creating card number
2024-03-20 17:06:44 +0100 debug mode false
2024-03-20 17:07:41 +0100 update making card renew after paiement only if it was new
2024-03-20 17:44:42 +0100 added important to css for display state, i am going to hell
2024-03-20 18:58:46 +0100 v 0.3.11 : - fixed error in creating card number - fixed error in creating first date limit - fixed error dont put card in valid after success payment
2024-03-20 19:31:54 +0100 fixed error when fipf see account it changes status accordgin to its own values
2024-03-20 20:02:03 +0100 changed all optionnal user_id in first parameters to last parameters
2024-03-20 21:10:56 +0100 better handle transfert validation
2024-03-21 16:09:44 +0100 added paypal diego live credentials
2024-03-21 16:10:07 +0100 small improvements in handling prof states : - card date validation now uses direct card duration, not a parameter - checker for both types of transfert valid and invalid - mv checks for transfert and date expiration in specific functions
2024-03-21 19:26:32 +0100 wip partner register role : found how to add hidden fields
2024-03-21 19:27:45 +0100 updated notes
2024-03-22 19:10:35 +0100 v 0.3.12 - update date when transfert success - role partner at creation ok
2024-03-23 15:24:14 +0100 wip adding fbpatch plugin
2024-03-23 18:25:43 +0100 wip menu can now receive form with rest api, but no nonce
2024-03-23 22:14:16 +0100 wip the nonce for the menu works
2024-03-23 23:51:35 +0100 wip nonce actually dont work
2024-03-24 11:12:11 +0100 wip nonce works now
2024-03-24 12:37:38 +0100 wip patches added to options
2024-03-24 13:23:00 +0100 wip patchs appears with informations, but are not yet updated
2024-03-24 15:05:00 +0100 option list update with form
2024-03-24 15:14:53 +0100 wip adding patchs conditionnaly
2024-03-24 16:06:47 +0100 fixed error in fetch
2024-03-24 16:16:55 +0100 adding patchs files according to form in menu
2024-03-24 17:06:10 +0100 moved all aptches from cipf plugin to fbpatch
2024-03-24 23:43:06 +0100 wip first strategy to overwrite the formbuilder post update is a dead end
2024-03-25 11:13:16 +0100 hide show post elements works
2024-03-25 11:17:16 +0100 fbpatch v 0.1.3
2024-03-25 13:07:12 +0100 fbpatch small fixes in options and hide-show
2024-03-25 15:16:19 +0100 updated options to make them not automatically loaded when added
2024-03-25 16:21:33 +0100 wip paypal credentials output in menu, but they dont update yet
2024-03-25 18:32:03 +0100 cipf v0.3.13 paypal credentials now from admin menu
2024-03-25 21:42:33 +0100 custer v 0.1.6 added special request for post url
2024-03-25 22:11:46 +0100 partner edit button not visible by someone else
2024-03-25 22:14:59 +0100 edited infos for todo and fabien
2024-03-26 22:33:41 +0100 wip filter email registration
2024-03-27 09:38:19 +0100 cipf v 0.4.1 wip trying to filter registration email
2024-03-27 13:06:48 +0100 can choose the email for registration, and wether to send one or not
2024-03-27 14:10:10 +0100 fixed error new prof choosing transfert can now access profil
2024-03-27 14:47:58 +0100 fixed default email options
2024-03-27 17:18:14 +0100 added message payments in admin menu
2024-03-27 17:23:22 +0100 small fixes in html and css for admin menu cipf
2024-03-27 18:54:57 +0100 cipf v 0.4.4 added randomization for posts if < -1
2024-03-29 21:56:12 +0100 updated plgntls : - renamed PLGNTLS_class -> Plgntls - changed method 'add_to_front()' to static method - moved fetch script as inline script, so the plgntls file is single - improved the way inline script and styles are added
2024-03-30 11:15:22 +0100 more improved in plgntls class to let add_to_front be added multiple times
2024-03-30 14:57:40 +0100 - added new plugin - improved the plgntls class for this plugin
2024-03-30 21:03:21 +0100 wip creating options and menu in plgntls
2024-03-31 01:45:25 +0100 wip trying to get the options working in class
2024-03-31 15:17:53 +0200 menu and options tools added to plgntls class in plugin xtxpatch
2024-03-31 17:34:10 +0200 more improves in optin gestion in class, automatic handling for basic cases
2024-03-31 17:59:17 +0200 fixed error with unserialization of option
2024-03-31 19:09:22 +0200 fixed error with option update
2024-03-31 19:25:39 +0200 xtxpatch saves the email settings, still need to handle them
2024-03-31 19:59:20 +0200 xtxpatch v 0.1.1 it works fine
2024-03-31 20:53:26 +0200 moved css from site to plugin
2024-03-31 23:38:04 +0200 cipf added css to hide parts of user profil when fipf see them
2024-04-01 01:39:38 +0200 prof more checks at profil and when fipf validate transfert
2024-04-01 23:09:22 +0200 - updated states to work for user_id and post_id - added states for partner page state publish-draft
2024-04-01 23:14:42 +0200 updated notes
2024-04-01 23:33:49 +0200 cipf v0.5.1
2024-04-02 13:24:22 +0200 wip event schedule
2024-04-02 15:44:33 +0200 plgntls : - added it to cipf plugin - fixed an error in using _prefix not as static value
2024-04-02 15:45:54 +0200 - updated all occurences of Plgntls:: constantes for Cipf:: const - update menu to use the new methods
2024-04-02 17:01:25 +0200 wip creating emails
2024-04-02 18:50:56 +0200 custer v0.2.2 includes queries in all output
2024-04-02 18:55:59 +0200 custer query to find admin email
2024-04-02 18:58:49 +0200 Merge branch 'master' into emails
2024-04-02 19:12:16 +0200 wip filter email subject and sender, in addition to message
2024-04-02 19:31:00 +0200 defined the emails
2024-04-02 23:39:27 +0200 added another state of error in payment if the payment is a success but the treatment has an error
2024-04-03 00:13:39 +0200 wip emails front admin menu
2024-04-03 10:31:27 +0200 html presentation of admin menu for emails
2024-04-03 12:37:04 +0200 fixed small errors in plugin tools for options and menu
2024-04-03 13:19:12 +0200 emails in admin menu and updating options seems to work
2024-04-03 13:36:28 +0200 added special query base_url
2024-04-03 13:58:03 +0200 completed email default messages
2024-04-03 14:07:25 +0200 fixed error in loop option email with _name
2024-04-03 14:21:33 +0200 fixed error with automatically adding _name to option
2024-04-03 14:53:34 +0200 emails ok, except for shcedule deletion, not yet
2024-04-03 15:16:00 +0200 cipf update payment handling error
2024-04-03 16:22:42 +0200 added protection when using get_plugins function outside amdin context
2024-04-03 16:23:14 +0200 emails in progress
2024-04-03 22:43:05 +0200 updated plgntls options to improve default with new options
2024-04-04 14:03:24 +0200 - reorganized files - fixed error in partner edti/creation page
2024-04-04 14:28:06 +0200 removed all nocache headers
2024-04-04 15:06:33 +0200 - fixed error in plgntls debug logs - fixed button partner modification page restrictions
2024-04-04 17:35:32 +0200 fixed error in checks partner own page and modify to draft
2024-04-04 20:27:02 +0200 added payment problem message
2024-04-04 22:54:28 +0200 - fixed error partner page draft redirection with post id - fixed error all logged in user could see partner post in draft
2024-04-05 00:07:01 +0200 added custer menu for notice
2024-04-05 17:19:51 +0200 custer v 0.2.3 added menu with notice
2024-04-08 21:43:08 +0200 update acf field handling to centerize every call
2024-04-08 22:19:02 +0200 - fixed error in acf fields handling - added history handler
2024-04-08 22:30:56 +0200 smal fixe in history presentation
2024-04-08 23:00:38 +0200 - added isset function in acf field centralized handling - schedule event for order id works
2024-04-09 11:46:08 +0200 cipf v 0.5.5 added history and order id acf
2024-04-09 15:54:44 +0200 new date handling
2024-04-09 18:16:38 +0200 added options in paypal credential and payment
2024-04-09 20:02:03 +0200 added change card prof 5€
2024-04-09 20:11:58 +0200 fixe small pbm with card change
2024-04-09 20:43:47 +0200 event delete
2024-04-09 20:47:17 +0200 added email when account is deleted
2024-04-09 22:33:34 +0200 schedult card expiration
2024-04-09 22:36:02 +0200 added email when account expire
2024-04-09 23:05:11 +0200 adde event expire card reminder
2024-04-09 23:20:35 +0200 event deletion account reminder
2024-04-10 11:55:28 +0200 improved check before sending reminder emails
2024-04-10 12:16:07 +0200 abort event scheduled for each actions, will try one daily check
2024-04-10 14:45:09 +0200 new handling of events
2024-04-10 21:04:52 +0200 better handling of init acf field
2024-04-10 22:31:43 +0200 added email from
2024-04-11 11:34:27 +0200 handle reminders before card expiration and account deletion
2024-04-11 12:33:27 +0200 fixed error in handling emails reminder for profs card
2024-04-11 14:36:44 +0200 events actions and email for profs are now well supported, without repeatitions
2024-04-12 17:13:57 +0200 cipf v 0.5.8 handle partner events
2024-04-13 10:13:03 +0200 added css class for fipf viewing user profiles
2024-04-14 21:00:58 +0200 updated email options
2024-04-14 22:59:13 +0200 custer fixed error replacing all emails arguments
2024-04-14 23:18:16 +0200 cleaned email custer
2024-04-15 18:43:01 +0200 updated emails default send from true to on
2024-04-15 18:44:09 +0200 fixed error in filter email when headers are not set or not an array
2024-04-15 18:45:18 +0200 added info in cipf emails handling about logging
2024-04-16 10:29:14 +0200 removed error log
2024-04-16 10:34:38 +0200 removed error log
2024-04-16 11:25:00 +0200 wip handle deleting images for prof deletion
2024-04-16 11:40:36 +0200 added protection if user dont exists in format user
2024-04-16 11:41:17 +0200 added function to handle deletion of image when prof is deleted in case it was not taken care of
2024-04-16 14:19:14 +0200 added protection for first post
2024-04-16 14:22:44 +0200 added comment to explain the protection
2024-04-16 14:24:20 +0200 added new version number in custer
2024-04-16 16:43:11 +0200 updated offers expiration hanling with separate checkbox for each 3 offers
2024-04-17 16:47:14 +0200 added css and functions to make some acf fields read-only
2024-04-17 16:56:56 +0200 fixed errors and remain files for cleaning
2024-04-18 10:58:53 +0200 added a way to disable any acf fields
2024-04-18 14:18:19 +0200 fixed pbm with field update prevention, but not sure if robust
2024-04-20 14:57:10 +0200 new update for readonly_acf field with better solution
2024-04-20 18:03:21 +0200 wip resolving date format pbm, already figured out where it comes from and how to create a new one
2024-04-20 21:14:36 +0200 wip datepicker, added an intercepter to the originale function to get the arguments
2024-04-21 21:05:26 +0200 wip datepicker js part is done, it creates a hidden field with date in acf format
2024-04-23 13:11:10 +0200 wip adding date to class was a mistake since it is global
2024-04-23 13:26:16 +0200 for the moment dates have the apporpriate text output
2024-04-24 00:28:25 +0200 fbpatch v0.2.2 patch for dates
2024-04-24 11:17:35 +0200 fbpatch better version of dates patch
2024-04-24 14:15:48 +0200 cipf v0.5.11 added instructions for css class
2024-04-24 19:03:31 +0200 fixed error when retrievieng acf dates with format
2024-04-25 11:23:26 +0200 some cleaning in comments in fbpatch
2024-04-25 11:24:12 +0200 notes update
2024-04-25 11:58:06 +0200 fixed error in handling dates with acf format as datepicker and not datetimepicker
2024-04-25 14:17:06 +0200 fbatch dates new version only in front
2024-04-25 16:24:33 +0200 fixed error in fbpatch dates

View File

@@ -4,7 +4,7 @@ Plugin Name: hggg_cipf
Plugin URI: Plugin URI:
Description: Description:
Author: hugogogo Author: hugogogo
Version: 0.5.2 Version: 0.5.15
Author URI: Author URI:
*/ */
@@ -33,24 +33,29 @@ include_once(Plgntls::root_path() . 'php/paypal/paypal.php');
// profs // profs
include_once(Plgntls::root_path() . 'php/profs_profil.php'); include_once(Plgntls::root_path() . 'php/profs_profil.php');
include_once(Plgntls::root_path() . 'php/profs_form_commande.php'); include_once(Plgntls::root_path() . 'php/profs_form_commande.php');
include_once(Plgntls::root_path() . 'php/profs_dates.php');
include_once(Plgntls::root_path() . 'php/profs_handle_states.php'); include_once(Plgntls::root_path() . 'php/profs_handle_states.php');
// partners // partners
include_once(Plgntls::root_path() . 'php/partners_register.php'); include_once(Plgntls::root_path() . 'php/partners_register.php');
include_once(Plgntls::root_path() . 'php/partners_page.php'); include_once(Plgntls::root_path() . 'php/partners_page.php');
include_once(Plgntls::root_path() . 'php/partners_form.php'); include_once(Plgntls::root_path() . 'php/partners_form.php');
include_once(Plgntls::root_path() . 'php/partners_handle_offers.php');
// utils // utils
//include_once(Plgntls::root_path() . '/php/menus.php'); include_once(Plgntls::root_path() . 'php/_utils_acf_fields.php');
include_once(Plgntls::root_path() . 'php/states.php'); include_once(Plgntls::root_path() . 'php/_utils_acf_dates.php');
include_once(Plgntls::root_path() . 'php/redirections.php'); include_once(Plgntls::root_path() . 'php/_utils_acf_disabled.php');
include_once(Plgntls::root_path() . 'php/display_css.php'); include_once(Plgntls::root_path() . 'php/_utils_redirections.php');
include_once(Plgntls::root_path() . 'php/payments.php'); include_once(Plgntls::root_path() . 'php/_utils_display_css.php');
include_once(Plgntls::root_path() . 'php/random_posts.php'); include_once(Plgntls::root_path() . 'php/_utils_checks_roles.php');
include_once(Plgntls::root_path() . 'php/scheduled_events.php'); // actions
include_once(Plgntls::root_path() . 'php/emails.php'); include_once(Plgntls::root_path() . 'php/_actions_payments.php');
include_once(Plgntls::root_path() . 'php/_actions_random_posts.php');
include_once(Plgntls::root_path() . 'php/_actions_scheduled_events.php');
include_once(Plgntls::root_path() . 'php/_actions_emails.php');
include_once(Plgntls::root_path() . 'php/_actions_newsletter.php');
// admin // admin
include_once(Plgntls::root_path() . 'php/admin_hide_bar.php'); include_once(Plgntls::root_path() . 'php/admin_hide_bar.php');
include_once(Plgntls::root_path() . 'php/admin_user_profil.php'); include_once(Plgntls::root_path() . 'php/admin_user_profil.php');
include_once(Plgntls::root_path() . 'php/admin_partner.php');
include_once(Plgntls::root_path() . 'php/admin_menu.php'); include_once(Plgntls::root_path() . 'php/admin_menu.php');
@@ -79,7 +84,24 @@ class Cipf {
const ACF_CARD_PAYMENT_STATE = ['_name'=>'etat_paiement', 'started'=>'en_cours', 'success'=>'reussi', 'failure'=>'echec', 'nothing'=>'aucun']; // radio button const ACF_CARD_PAYMENT_STATE = ['_name'=>'etat_paiement', 'started'=>'en_cours', 'success'=>'reussi', 'failure'=>'echec', 'nothing'=>'aucun']; // radio button
const ACF_ACCOUNT_STATE = ['_name'=>'etat_compte', 'new'=>'nouveau prof', 'to_pay'=>'doit payer', 'valid'=>'carte valide', 'waiting_invalid'=>'en attente invalide', 'waiting_valid'=>'en attente valide', 'expired'=>'carte expiree']; const ACF_ACCOUNT_STATE = ['_name'=>'etat_compte', 'new'=>'nouveau prof', 'to_pay'=>'doit payer', 'valid'=>'carte valide', 'waiting_invalid'=>'en attente invalide', 'waiting_valid'=>'en attente valide', 'expired'=>'carte expiree'];
const ACF_TRANSFERT_STATE = ['_name'=>'etat_virement', 'success'=>'virement validé']; const ACF_TRANSFERT_STATE = ['_name'=>'etat_virement', 'success'=>'virement validé'];
const ACF_CARD_ORDER_ID = ['_name'=>'order_id'];
const ACF_HISTORY = ['_name'=>'historique'];
const ACF_PROF_CHANGE_CARD = ['_name'=>'changement_de_carte'];
const ACF_PAGE_STATE = ['_name'=>'etat_page_partenaire', 'publish'=>'Publiee', 'draft'=>'Brouillon']; const ACF_PAGE_STATE = ['_name'=>'etat_page_partenaire', 'publish'=>'Publiee', 'draft'=>'Brouillon'];
const ACF_EMAILS_REMINDERS = ['_name'=>'rappels_emails'];
const ACF_PARTNER_DATE_OFFER_1 = ['_name'=>'fin_offre_1'];
const ACF_PARTNER_DATE_OFFER_2 = ['_name'=>'fin_offre_2'];
const ACF_PARTNER_DATE_OFFER_3 = ['_name'=>'fin_offre_3'];
const ACF_PARTNER_OFFER_1_DURATION = ['_name'=>'duree_offre_1', 'endless'=>'Permanente', 'tmp'=>'Temporaire'];
const ACF_PARTNER_OFFER_2_DURATION = ['_name'=>'duree_offre_2', 'endless'=>'Permanente', 'tmp'=>'Temporaire'];
const ACF_PARTNER_OFFER_3_DURATION = ['_name'=>'duree_offre_3', 'endless'=>'Permanente', 'tmp'=>'Temporaire'];
const ACF_PARTNER_OFFER_1_OUTPUT = ['_name'=>'afficher_offre_1', 'show'=>'Afficher', 'hide'=>'Masquer'];
const ACF_PARTNER_OFFER_2_OUTPUT = ['_name'=>'afficher_offre_2', 'show'=>'Afficher', 'hide'=>'Masquer'];
const ACF_PARTNER_OFFER_3_OUTPUT = ['_name'=>'afficher_offre_3', 'show'=>'Afficher', 'hide'=>'Masquer'];
const ACF_READONLY_CLASS = 'readonly_acf';
const ACF_DATE_FORMAT = 'Ymd';
const ACF_NEWSLETTER_RECEIVE = ['_name' => 'recevoir_la_newsletter', 'true' => 'recevoir'];
const ACF_NEWSLETTER_ID = ['_name' => 'identifiant_newsletter'];
// META // META
const META_PAYEMENT_STATUS = 'cipf_payement_status'; const META_PAYEMENT_STATUS = 'cipf_payement_status';
@@ -90,6 +112,7 @@ class Cipf {
const SLUG_COMMAND_CARD = 'commande'; const SLUG_COMMAND_CARD = 'commande';
const SLUG_PAGE_REDIRECTION = 'redirection_cipf'; const SLUG_PAGE_REDIRECTION = 'redirection_cipf';
const SLUG_PAYPAL_PAGE = 'paiement'; const SLUG_PAYPAL_PAGE = 'paiement';
const SLUG_PAYPAL_FABRICATION = 'fabrication';
const SLUG_PAYPAL_REDIRECTION_SUCCESS = self::SLUG_PAGE_REDIRECTION; const SLUG_PAYPAL_REDIRECTION_SUCCESS = self::SLUG_PAGE_REDIRECTION;
const SLUG_PAYPAL_REDIRECTION_FAILURE = self::SLUG_PAGE_REDIRECTION; const SLUG_PAYPAL_REDIRECTION_FAILURE = self::SLUG_PAGE_REDIRECTION;
const SLUG_ADMIN_VALIDATE_PROF = 'admin_activate_prof_cipf'; // for admin_modif_prof.php const SLUG_ADMIN_VALIDATE_PROF = 'admin_activate_prof_cipf'; // for admin_modif_prof.php
@@ -133,9 +156,12 @@ class Cipf {
'_name'=>'cipf_paypal_credentials', '_name'=>'cipf_paypal_credentials',
'_callback'=>'update_paypal_credentials_CIPF', '_callback'=>'update_paypal_credentials_CIPF',
'_default' => [ '_default' => [
'force_1_cent' =>false,
'is_sandbox' =>true, 'is_sandbox' =>true,
'client_id' =>'AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl', 'live_client_id' =>'Aedn5e8z__hPBvKirqw5bwlhI9ChG8_N6c1xbgybYyBr4B4oP8uVzmVdH1QVKdPQKf6bWg7orPV4PDrO',
'client_secret'=>'EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-', 'live_client_secret' =>'EGeGwfHGxHxsjnC-tH8W0IL4nN3_xlc3sXFRPCQOw5uUoWae3eOgghuDKMnZc5DVGTbP6yIjVJ1BaAra',
'sandbox_client_id' =>'AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl',
'sandbox_client_secret'=>'EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-',
], ],
]; ];
const OPTION_PAYMENT = [ const OPTION_PAYMENT = [
@@ -159,104 +185,145 @@ contactez la fipf directement",
'_name'=>'cipf_emails_option', '_name'=>'cipf_emails_option',
'_callback'=>'update_emails_settings_option_CIPF', '_callback'=>'update_emails_settings_option_CIPF',
'_default'=>[ '_default'=>[
// 1. profs : email : payment_success : validation payment prof reussi, send email
'payment_success'=>[ 'payment_success'=>[
'name'=>'prof - le paiement a réussi', 'name'=>'prof - le paiement a réussi',
'notification_send'=>true, 'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$', 'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - paiement réussi]", 'notification_subject'=>"[CIPF /prof - paiement réussi]",
'notification_message'=>'paiement réussi de la part de $$user_login$$ : $$__author_page_url__$$', 'notification_message'=>'paiement réussi de la part de $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>true, 'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - paiement réussi]", 'confirmation_subject'=>"[CIPF - paiement réussi]",
'confirmation_message'=>"paiement réussi", 'confirmation_message'=>"paiement réussi",
], ],
// 2. profs : email : payment_failure : validation payment prof echec, send email
'payment_echec'=>[ 'payment_echec'=>[
'name'=>'prof - le paiement a echoué', 'name'=>'prof - le paiement a echoué',
'notification_send'=>true, 'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$', 'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - paiement echoué]", 'notification_subject'=>"[CIPF /prof - paiement echoué]",
'notification_message'=>'paiement echoué pour $$user_login$$ : $$__author_page_url__$$', 'notification_message'=>'paiement echoué pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>true, 'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - paiement echoué]", 'confirmation_subject'=>"[CIPF - paiement echoué]",
'confirmation_message'=>"votre paiement a echoué", 'confirmation_message'=>"votre paiement a echoué",
], ],
// 3. profs : email : transfert_success : validation transfert prof reussi, send email 'payment_problem'=>[
'name'=>'prof - le paiement a rencontré un problem',
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - paiement probleme]",
'notification_message'=>'probleme de paiement pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>'off',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - paiement problème]",
'confirmation_message'=>"votre paiement a rencontré un probleme",
],
'transfert_success'=>[ 'transfert_success'=>[
'name'=>'prof - le virement a été validé', 'name'=>'prof - le virement a été validé',
'notification_send'=>true, 'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$', 'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - virement validé]", 'notification_subject'=>"[CIPF /prof - virement validé]",
'notification_message'=>'virement validé pour $$user_login$$ : $$__author_page_url__$$', 'notification_message'=>'virement validé pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>true, 'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - virement validé]", 'confirmation_subject'=>"[CIPF - virement validé]",
'confirmation_message'=>"votre virement a été validé", 'confirmation_message'=>"votre virement a été validé",
], ],
// 4. profs : email : transfert_failures : validation transfert prof echec, send email 'change_card_success'=>[
// 'transfert_echec'=>[ 'name'=>'prof - le paiement pour changer la carte a réussi',
// 'name'=>'prof - le virement a échoué', 'notification_send'=>'on',
// 'notification_send'=>true, 'notification_from'=>'$$__admin_email__$$',
// 'notification_to'=>'$$__admin_email__$$',
// 'notification_subject'=>"[CIPF /prof - virement echoué]",
// 'notification_message'=>'virement echoué pour $$user_login$$ : $$__author_page_url__$$',
// 'confirmation_send'=>true,
// 'confirmation_subject'=>"[CIPF - virement echoué]",
// 'confirmation_message'=>"votre virement a echoué",
// ],
// 5. partners : email : offer_expired : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
'offer_expired'=>[
'name'=>"partenaire - l'offre partenaire a expirée",
'notification_send'=>true,
'notification_to'=>'$$__admin_email__$$', 'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /partenaire - offre expirée]", 'notification_subject'=>"[CIPF /prof - paiement changer carte reussi]",
'notification_message'=>'offre expirée pour $$user_login$$ : $$__user_post_url__$$', 'notification_message'=>'paiement pour changer sa carte a réussi de la part de $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>true, 'confirmation_send'=>'on',
'confirmation_subject'=>"[CIPF - offre expirée]", 'confirmation_from'=>'$$__admin_email__$$',
'confirmation_message'=>'votre offre a expiré, pour la renouveler rendez-vous sur $$__base_url__$$', 'confirmation_subject'=>"[CIPF - paiement changement carte réussi]",
'confirmation_message'=>"paiement changement carte réussi",
], ],
// 6. partners : email : offer_will_expire : la gestion des offres à échéance 'card_will_expire'=>[
'offer_will_expire'=>[ 'name'=>'prof - la carte va bientot expirer',
'name'=>"partenaire - l'offre arrive bientot a expiration", 'notification_send'=>'on',
'notification_send'=>true, 'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$', 'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /partenaire - offre va expirer]", 'notification_subject'=>"[CIPF /prof - carte va expirer]",
'notification_message'=>'offre va expirer pour $$user_login$$ : $$__user_post_url__$$', 'notification_message'=>'la carte va expirer pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>true, 'confirmation_send'=>'on',
'confirmation_subject'=>"[CIPF - offre va expirer]", 'confirmation_from'=>'$$__admin_email__$$',
'confirmation_message'=>'une de vos offre va expirer, rendez-vous sur $$__base_url__$$', 'confirmation_subject'=>"[CIPF - carte va expirer]",
'confirmation_message'=>'votre carte va expirer bientot, renouvellez-la sur $$__base_url__$$',
],
'card_expired'=>[
'name'=>'prof - la carte a expiré',
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - carte expirée]",
'notification_message'=>'carte expirée pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - carte expirée]",
'confirmation_message'=>'votre carte a expiré, renouvelez-la sur $$__base_url__$$',
],
'account_will_be_deleted'=>[
'name'=>'prof - le compte va être supprimé',
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - compte bientot supprimé]",
'notification_message'=>'compte bientot supprimé pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - compte bientot supprimé]",
'confirmation_message'=>'votre compte va bientot être supprimé sur $$__base_url__$$',
], ],
// 7. payments : email : account_deleted : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte
'account_deleted'=>[ 'account_deleted'=>[
'name'=>'prof - le compte a été supprimé', 'name'=>'prof - le compte a été supprimé',
'notification_send'=>true, 'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$', 'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - compte supprimé]", 'notification_subject'=>"[CIPF /prof - compte supprimé]",
'notification_message'=>'compte supprimé pour $$user_login$$ : $$__author_page_url__$$', 'notification_message'=>'compte supprimé pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>true, 'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - compte supprimé]", 'confirmation_subject'=>"[CIPF - compte supprimé]",
'confirmation_message'=>'votre compte a été supprimé sur $$__base_url__$$', 'confirmation_message'=>'votre compte a été supprimé sur $$__base_url__$$',
], ],
// 8. payments : email : account_will_expire : faire rappels emails avant expiration 'offer_will_expire'=>[
'account_will_expire'=>[ 'name'=>"partenaire - l'offre arrive bientot a expiration",
'name'=>'prof - le compte va bientot expirer', 'notification_send'=>'on',
'notification_send'=>true, 'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$', 'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - compte va expirer]", 'notification_subject'=>"[CIPF /partenaire - offre va expirer]",
'notification_message'=>'le compte va expirer pour $$user_login$$ : $$__author_page_url__$$', 'notification_message'=>'offre va expirer pour $$user_login$$ : $$__user_post_url__$$',
'confirmation_send'=>true, 'confirmation_send'=>'on',
'confirmation_subject'=>"[CIPF - compte va expirer]", 'confirmation_from'=>'$$__admin_email__$$',
'confirmation_message'=>'votre compte va expirer bientot, renouvellez-le sur $$__base_url__$$', 'confirmation_subject'=>"[CIPF - offre va expirer]",
'confirmation_message'=>'une de vos offre va expirer, rendez-vous sur $$__base_url__$$',
], ],
// 9. payments : email : account_expired : desactiver carte expiree 'offer_expired'=>[
'account_expired'=>[ 'name'=>"partenaire - l'offre partenaire a expirée",
'name'=>'prof - le compte a expiré', 'notification_send'=>'on',
'notification_send'=>true, 'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$', 'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - compte expiré]", 'notification_subject'=>"[CIPF /partenaire - offre expirée]",
'notification_message'=>'compte expiré pour $$user_login$$ : $$__author_page_url__$$', 'notification_message'=>'offre expirée pour $$user_login$$ : $$__user_post_url__$$',
'confirmation_send'=>true, 'confirmation_send'=>'on',
'confirmation_subject'=>"[CIPF - compte expiré]", 'confirmation_from'=>'$$__admin_email__$$',
'confirmation_message'=>'votre compte a expiré, renouvelez-le sur $$__base_url__$$', 'confirmation_subject'=>"[CIPF - offre expirée]",
'confirmation_message'=>'votre offre a expiré, pour la renouveler rendez-vous sur $$__base_url__$$',
],
'cron_job'=>[
'name'=>"cron-job - une fois par jour",
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF - cron job]",
'notification_message'=>'la tache journaliere cron a bien fonctionné',
], ],
], ],
]; ];
@@ -275,10 +342,18 @@ contactez la fipf directement",
// FORMS // FORMS
const FORM_PROF_COMMANDE_ID = 'prof_commande'; const FORM_PROF_COMMANDE_ID = 'prof_commande';
const FORM_PROF_TRANSFERT_ID = 'prof_valide_virement'; const FORM_PROF_TRANSFERT_ID = 'prof_valide_virement';
const FORM_PARTNER_PAGE_ID = 'crea_partenaire';
// DURATIONS
const DURATION_CARD_VALIDITY = '+1 year'; // string : time of validity of the card (ex: '1 month' or '1 year' or '60 days')
const DURATION_OLD_ORDER_ID = '+3 days';
const DURATION_ACCOUNT_DELETE_AFTER_EXPIRE = '+6 months';
const DURATION_REMINDERS_BEFORE_ACCOUNT_EXPIRE = ['-30 days', '-7 days'];
const DURATION_REMINDERS_BEFORE_ACCOUNT_DELETE = ['-30 days', '-7 days'];
const DURATION_REMINDERS_BEFORE_OFFER_EXPIRE = ['-7 days'];
// OTHER // OTHER
const CARD_RENEW_PERIOD = 31; // int : number of days before expiration when renew card start to be possible const CARD_RENEW_PERIOD = 31; // int : number of days before expiration when renew card start to be possible
const CARD_VALIDITY_TIME = '1 year'; // string : time of validity of the card (ex: '1 month' or '1 year' or '60 days')
const USER_INFO_DATE_FORMAT = 'd/m/Y'; // for user_infos.php (date format : https://www.php.net/manual/fr/datetime.format.php) const USER_INFO_DATE_FORMAT = 'd/m/Y'; // for user_infos.php (date format : https://www.php.net/manual/fr/datetime.format.php)
const ADMIN_VALIDATE_PROF_FIELD = 'admin_activate_prof_cipf'; // for admin_modif_prof.php const ADMIN_VALIDATE_PROF_FIELD = 'admin_activate_prof_cipf'; // for admin_modif_prof.php
const INPUT_HIDDEN_ROLE = 'cipf_user_role'; const INPUT_HIDDEN_ROLE = 'cipf_user_role';

View File

@@ -0,0 +1,19 @@
/*
.read_only_cipf {
.acf-input {
position: relative;
* {
cursor: default;
pointer-events: none;
}
> * {
color: #666;
background-color: #f0f0f1;
filter: grayscale(100%);
}
textarea {
pointer-events: auto;
}
}
}
*/

View File

@@ -0,0 +1,9 @@
/*
* use this class when you want to only pay a physical new plastic card
* otherwise use the class 'payer_carte'
*
*/
[class*='cipf_display_'].cipf_display_changer_carte { display: block !important; }
[class*='cipf_display_'].cipf_display_changer_carte.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,9 @@
/*
* use this class when you dont want to pay a physical new plastic card
* otherwise use the class 'changer_carte'
*
*/
[class*='cipf_display_'].cipf_display_payer_carte { display: block !important; }
[class*='cipf_display_'].cipf_display_payer_carte.cipf_flex { display: flex !important; }

View File

@@ -7,6 +7,25 @@
/* /*
* hide all acf fields with the class 'hide_for_fipfrole_cipf'
* also hide the title if class 'hide_group_title_for_fipfrole_cipf'
*
*/
form#your-profile h2:has(+ .form-table .hide_group_for_fipfrole),
form#your-profile h2:has(+ .form-table .hide_title_for_fipfrole) {
display: none;
}
form#your-profile h2:has(+ .form-table .hide_group_for_fipfrole) + .form-table {
display: none;
}
form#your-profile .hide_for_fipfrole {
display: none;
}
/*
*
*
*/ */
form#your-profile h2:has(+ .form-table .user-rich-editing-wrap), form#your-profile h2:has(+ .form-table .user-rich-editing-wrap),
form#your-profile .form-table:has(.user-rich-editing-wrap) { form#your-profile .form-table:has(.user-rich-editing-wrap) {
@@ -14,6 +33,8 @@ form#your-profile .form-table:has(.user-rich-editing-wrap) {
} }
/* /*
*
*
*/ */
form#your-profile h2:has(+ .form-table .user-description-wrap), form#your-profile h2:has(+ .form-table .user-description-wrap),
form#your-profile .form-table:has(.user-description-wrap) { form#your-profile .form-table:has(.user-description-wrap) {
@@ -21,12 +42,16 @@ form#your-profile .form-table:has(.user-description-wrap) {
} }
/* /*
*
*
*/ */
form#your-profile #application-passwords-section { form#your-profile #application-passwords-section {
display: none; display: none;
} }
/* /*
*
*
*/ */
form#your-profile h2:has(+ .form-table.xoo-aff-form-table), form#your-profile h2:has(+ .form-table.xoo-aff-form-table),
form#your-profile .form-table.xoo-aff-form-table { form#your-profile .form-table.xoo-aff-form-table {

View File

@@ -1,6 +1,131 @@
#mytext { h1 {
border: 1px solid blue; margin-left: 15px;
margin-top: 50px;
}
form.cipf, section.cipf {
margin: 15px;
border: 1px solid black;
padding: 20px;
}
form.cipf > div {
margin: 20px 0px;
}
.define_paypal_credentials_cipf input {
width: 100%;
}
form.cipf .vertical_wrapper_cipf {
display: flex;
flex-direction: column;
}
form.cipf textarea {
resize: vertical;
height: 120px;
}
/*
* form emails
*
*/
form.emails_form_cipf {
margin: 10px;
padding: 10px;
> input[type="submit"] {
margin-left: 15px;
}
details.set_email_options_cipf {
margin: 15px;
padding: 0px 20px;
border: 1px solid black;
summary {
padding: 20px 0px;
cursor: grab;
h2 {
display: inline;
}
}
.email_type_wrapper_cipf {
margin-bottom: 50px;
.send_or_not_cipf {
margin-bottom: 20px;
}
.send_or_not_cipf:has(input:not(:checked)) + .email_options_cipf {
display: none;
}
.email_options_cipf {
padding-left: 20px;
border-left: 1px solid black;
label {
margin: 10px 0px;
}
}
}
}
}
/*
* explication class css
*
*/
section.cipf {
font-size: 1.3em;
p {
font-size: 1em;
}
> h2:not(:first-child) {
margin-top: 50px;
}
ul {
list-style: disc inside;
ul {
list-style: circle inside;
margin-top: 5px;
margin-left: 15px;
}
}
.big_space {
width: 20px;
display: inline-block;
}
details {
margin: 10px;
cursor: default;
summary {
cursor: grab;
padding: 10px;
margin-bottom: 20px;
}
.case_title {
display: flex;
margin-top: 40px;
p {
margin: auto 20px;
}
}
.case {
padding: 10px;
display: flex;
> h1, > h2 {
margin: auto 50px;
}
}
.delimiter {
border-bottom: 1px solid black;
}
.group {
background-color: lightgray;
padding: 1px 10px;
margin-bottom: 50px;
min-height: 50px;
.field {
display: flex;
.input {
border: 1px solid black;
height: 20px;
width: 300px;
margin: auto 100px;
}
}
}
} }
#mytext_2 {
border: 1px solid green;
} }

View File

@@ -0,0 +1,6 @@
#your-profile .acf-field-textarea.textarea_full_width {
textarea {
width: 100%;
max-width: 100%;
}
}

View File

@@ -1,91 +1,40 @@
<style>
h1 {
margin-left: 15px;
margin-top: 50px;
}
form {
margin: 15px;
border: 1px solid black;
padding: 20px;
}
form > div {
margin: 20px 0px;
}
.define_paypal_credentials_cipf input {
width: 100%;
}
form .vertical_wrapper_cipf {
display: flex;
flex-direction: column;
}
form textarea {
resize: vertical;
height: 120px;
}
/*
* form emails
*
*/
form.emails_form_cipf {
margin: 10px;
padding: 10px;
> input[type="submit"] {
margin-left: 15px;
}
details.set_email_options_cipf {
margin: 15px;
padding: 0px 20px;
border: 1px solid black;
summary {
padding: 20px 0px;
cursor: grab;
h2 {
display: inline;
}
}
.email_type_wrapper_cipf {
margin-bottom: 50px;
.send_or_not_cipf {
margin-bottom: 20px;
}
.send_or_not_cipf:has(input:not(:checked)) + .email_options_cipf {
display: none;
}
.email_options_cipf {
padding-left: 20px;
border-left: 1px solid black;
label {
margin: 10px 0px;
}
}
}
}
}
</style>
<!-- https://developer.wordpress.org/reference/hooks/admin_post_action/ --> <!-- https://developer.wordpress.org/reference/hooks/admin_post_action/ -->
<h1>paypal credentials</h1> <h1>paypal credentials</h1>
<?php echo Plgntls::open_form_option($option_paypal['_name']); ?> <?php echo Plgntls::open_form_option($option_paypal['_name'], 'post', 'cipf'); ?>
<div class="define_paypal_credentials_cipf define_paypal_client_id_cipf vertical_wrapper_cipf"> <div class="define_paypal_credentials_cipf vertical_wrapper_cipf">
<label for="paypal_client_id_cipf">client id : </label> <label for="paypal_live_client_id_cipf">live client id : </label>
<input type="text" id="paypal_client_id_cipf" name="client_id" value="<?php echo $option_paypal['client_id']; ?>" /> <input type="text" id="paypal_live_client_id_cipf" name="live_client_id" value="<?php echo $option_paypal['live_client_id']; ?>" />
</div> </div>
<div class="define_paypal_credentials_cipf define_paypal_secret_id_cipf vertical_wrapper_cipf"> <div class="define_paypal_credentials_cipf vertical_wrapper_cipf">
<label for="paypal_client_secret_cipf">client secret : </label> <label for="paypal_live_client_secret_cipf">live client secret : </label>
<input type="text" id="paypal_client_secret_cipf" name="client_secret" value="<?php echo $option_paypal['client_secret']; ?>" /> <input type="text" id="paypal_live_client_secret_cipf" name="live_client_secret" value="<?php echo $option_paypal['live_client_secret']; ?>" />
</div>
<div class="define_paypal_credentials_cipf vertical_wrapper_cipf">
<label for="paypal_sandbox_client_id_cipf">sandbox client id : </label>
<input type="text" id="paypal_sandbox_client_id_cipf" name="sandbox_client_id" value="<?php echo $option_paypal['sandbox_client_id']; ?>" />
</div>
<div class="define_paypal_credentials_cipf vertical_wrapper_cipf">
<label for="paypal_sandbox_client_secret_cipf">sandbox client secret : </label>
<input type="text" id="paypal_sandbox_client_secret_cipf" name="sandbox_client_secret" value="<?php echo $option_paypal['sandbox_client_secret']; ?>" />
</div> </div>
<div class="choose_sandbox_live_cipf choose_sandbox_cipf"> <div class="choose_sandbox_live_cipf choose_sandbox_cipf">
<input type="radio" id="sandbox" name="sandbox_or_live" value="sandbox" <?php if ($option_paypal['is_sandbox'] === true) {echo 'checked';} ?> /> <input type="radio" id="paypal_credentials_sandbox" name="sandbox_or_live" value="sandbox" <?php if ($option_paypal['is_sandbox'] === true) {echo 'checked';} ?> />
<label for="sandbox">sandbox</label> <label for="paypal_credentials_sandbox">sandbox</label>
</div> </div>
<div class="choose_sandbox_live_cipf choose_live_cipf"> <div class="choose_sandbox_live_cipf choose_live_cipf">
<input type="radio" id="live" name="sandbox_or_live" value="live" <?php if ($option_paypal['is_sandbox'] === false) {echo 'checked';} ?> /> <input type="radio" id="paypal_credentials_live" name="sandbox_or_live" value="live" <?php if ($option_paypal['is_sandbox'] === false) {echo 'checked';} ?> />
<label for="live">live</label> <label for="paypal_credentials_live">live</label>
</div>
<div class="">
<input type="checkbox" id="paypal_credentials_force_1_cent" name="force_1_cent" <?php if ($option_paypal['force_1_cent'] === true) {echo 'checked';} ?> />
<label for="paypal_credentials_force_1_cent">forcer le prix de 0,01€ ?</label>
</div> </div>
<input type="submit" value="send"/> <input type="submit" value="send"/>
@@ -96,7 +45,7 @@
<!-- <!--
--> -->
<h1>messages apres paiement, avant redirection</h1> <h1>messages apres paiement, avant redirection</h1>
<?php echo Plgntls::open_form_option($option_payment['_name']); ?> <?php echo Plgntls::open_form_option($option_payment['_name'], 'post', 'cipf'); ?>
<div class="define_payment_message_cipf vertical_wrapper_cipf"> <div class="define_payment_message_cipf vertical_wrapper_cipf">
<label for="define_payment_message_success_cipf">paiement réussi : </label> <label for="define_payment_message_success_cipf">paiement réussi : </label>
<textarea id="define_payment_message_success_cipf" name="message_success"><?php echo esc_html(stripslashes($option_payment['success'])); ?></textarea> <textarea id="define_payment_message_success_cipf" name="message_success"><?php echo esc_html(stripslashes($option_payment['success'])); ?></textarea>
@@ -131,7 +80,7 @@
'confirmation_message'=>"donne l'argent", 'confirmation_message'=>"donne l'argent",
--> -->
<h1>emails :</h1> <h1>emails :</h1>
<?php echo Plgntls::open_form_option($option_emails['_name'], 'POST', 'emails_form_cipf'); ?> <?php echo Plgntls::open_form_option($option_emails['_name'], 'POST', 'emails_form_cipf cipf'); ?>
<?php <?php
foreach($option_emails as $name => $email_options) { foreach($option_emails as $name => $email_options) {
@@ -144,46 +93,72 @@
<div class="email_type_wrapper_cipf email_type_notification_wrapper_cipf"> <div class="email_type_wrapper_cipf email_type_notification_wrapper_cipf">
<?php if (isset($email_options['notification_send'])) { ?>
<div class="send_or_not_cipf"> <div class="send_or_not_cipf">
<input type="checkbox" id="<?php echo esc_html(stripslashes($name)); ?>_notification_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_notification_send" <?php if ($email_options['notification_send'] === true) {echo 'checked';} ?> /> <input type="checkbox" id="<?php echo esc_html(stripslashes($name)); ?>_notification_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_notification_send" <?php if ($email_options['notification_send'] === 'on') {echo 'checked';} ?> />
<label for="<?php echo esc_html(stripslashes($name)); ?>_notification_cipf">envoyer une notification ?</label> <label for="<?php echo esc_html(stripslashes($name)); ?>_notification_cipf">envoyer une notification ?</label>
</div> </div>
<?php } ?>
<div class="email_options_cipf"> <div class="email_options_cipf">
<?php if (isset($email_options['notification_from'])) { ?>
<div class="vertical_wrapper_cipf">
<label for="<?php echo esc_html(stripslashes($name)); ?>_notification_from_cipf">de : </label>
<input type="text" id="<?php echo esc_html(stripslashes($name)); ?>_notification_from_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_notification_from" value="<?php echo esc_html(stripslashes($email_options['notification_from'])); ?>" />
</div>
<?php } ?>
<?php if (isset($email_options['notification_to'])) { ?>
<div class="vertical_wrapper_cipf"> <div class="vertical_wrapper_cipf">
<label for="<?php echo esc_html(stripslashes($name)); ?>_notification_to_cipf">destinataire : </label> <label for="<?php echo esc_html(stripslashes($name)); ?>_notification_to_cipf">destinataire : </label>
<input type="text" id="<?php echo esc_html(stripslashes($name)); ?>_notification_to_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_notification_to" value="<?php echo esc_html(stripslashes($email_options['notification_to'])); ?>" /> <input type="text" id="<?php echo esc_html(stripslashes($name)); ?>_notification_to_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_notification_to" value="<?php echo esc_html(stripslashes($email_options['notification_to'])); ?>" />
</div> </div>
<?php } ?>
<?php if (isset($email_options['notification_subject'])) { ?>
<div class="vertical_wrapper_cipf"> <div class="vertical_wrapper_cipf">
<label for="<?php echo esc_html(stripslashes($name)); ?>_notification_subject_cipf">sujet : </label> <label for="<?php echo esc_html(stripslashes($name)); ?>_notification_subject_cipf">sujet : </label>
<input type="text" id="<?php echo esc_html(stripslashes($name)); ?>_notification_subject_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_notification_subject" value="<?php echo esc_html(stripslashes($email_options['notification_subject'])); ?>" /> <input type="text" id="<?php echo esc_html(stripslashes($name)); ?>_notification_subject_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_notification_subject" value="<?php echo esc_html(stripslashes($email_options['notification_subject'])); ?>" />
</div> </div>
<?php } ?>
<?php if (isset($email_options['notification_message'])) { ?>
<div class="vertical_wrapper_cipf"> <div class="vertical_wrapper_cipf">
<label for="<?php echo esc_html(stripslashes($name)); ?>_notification_message_cipf">message : </label> <label for="<?php echo esc_html(stripslashes($name)); ?>_notification_message_cipf">message : </label>
<textarea id="<?php echo esc_html(stripslashes($name)); ?>_notification_message_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_notification_message"><?php echo esc_html(stripslashes($email_options['notification_message'])); ?></textarea> <textarea id="<?php echo esc_html(stripslashes($name)); ?>_notification_message_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_notification_message"><?php echo esc_html(stripslashes($email_options['notification_message'])); ?></textarea>
</div> </div>
<?php } ?>
</div> </div>
</div> </div>
<div class="email_type_wrapper_cipf email_type_confirmation_wrapper_cipf"> <div class="email_type_wrapper_cipf email_type_confirmation_wrapper_cipf">
<?php if (isset($email_options['confirmation_send'])) { ?>
<div class="send_or_not_cipf"> <div class="send_or_not_cipf">
<input type="checkbox" id="<?php echo esc_html(stripslashes($name)); ?>_confirmation_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_confirmation_send" <?php if ($email_options['confirmation_send'] === true) {echo 'checked';} ?> /> <input type="checkbox" id="<?php echo esc_html(stripslashes($name)); ?>_confirmation_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_confirmation_send" <?php if ($email_options['confirmation_send'] === 'on') {echo 'checked';} ?> />
<label for="<?php echo esc_html(stripslashes($name)); ?>_confirmation_cipf">envoyer une confirmation ?</label> <label for="<?php echo esc_html(stripslashes($name)); ?>_confirmation_cipf">envoyer une confirmation ?</label>
</div> </div>
<?php } ?>
<div class="email_options_cipf"> <div class="email_options_cipf">
<?php if (isset($email_options['confirmation_from'])) { ?>
<div class="vertical_wrapper_cipf">
<label for="<?php echo esc_html(stripslashes($name)); ?>_confirmation_from_cipf">de : </label>
<input type="text" id="<?php echo esc_html(stripslashes($name)); ?>_confirmation_from_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_confirmation_from" value="<?php echo esc_html(stripslashes($email_options['confirmation_from'])); ?>" />
</div>
<?php } ?>
<?php if (isset($email_options['confirmation_subject'])) { ?>
<div class="vertical_wrapper_cipf"> <div class="vertical_wrapper_cipf">
<label for="<?php echo esc_html(stripslashes($name)); ?>_confirmation_subject_cipf">sujet : </label> <label for="<?php echo esc_html(stripslashes($name)); ?>_confirmation_subject_cipf">sujet : </label>
<input type="text" id="<?php echo esc_html(stripslashes($name)); ?>_confirmation_subject_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_confirmation_subject" value="<?php echo esc_html(stripslashes($email_options['confirmation_subject'])); ?>" /> <input type="text" id="<?php echo esc_html(stripslashes($name)); ?>_confirmation_subject_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_confirmation_subject" value="<?php echo esc_html(stripslashes($email_options['confirmation_subject'])); ?>" />
</div> </div>
<?php } ?>
<?php if (isset($email_options['confirmation_message'])) { ?>
<div class="vertical_wrapper_cipf"> <div class="vertical_wrapper_cipf">
<label for="<?php echo esc_html(stripslashes($name)); ?>_confirmation_message_cipf">message : </label> <label for="<?php echo esc_html(stripslashes($name)); ?>_confirmation_message_cipf">message : </label>
<textarea id="<?php echo esc_html(stripslashes($name)); ?>_confirmation_message_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_confirmation_message"><?php echo esc_html(stripslashes($email_options['confirmation_message'])); ?></textarea> <textarea id="<?php echo esc_html(stripslashes($name)); ?>_confirmation_message_cipf" name="<?php echo esc_html(stripslashes($name)); ?>_confirmation_message"><?php echo esc_html(stripslashes($email_options['confirmation_message'])); ?></textarea>
</div> </div>
<?php } ?>
</div> </div>
@@ -195,3 +170,56 @@
<input type="submit" value="send"/> <input type="submit" value="send"/>
</form> </form>
<!--
EXPLICATIONS CLASS CSS
-->
<h1>instructions class css</h1>
<section class="cipf">
<h2>acf</h2>
<p>ajouter ces class sur chaque champs acf, dans <mark>ACF > Groupes de champs > modifier un groupe > modifier un champ > Présentation > classe</mark></p>
<ul>
<li><strong>hide_for_fipfrole : </strong>cacher un champ acf</li>
<li><strong>hide_title_for_fipfrole : </strong>cacher le titre d'un groupe de champs (a mettre sur n'importe quel champ du groupe)</li>
<li><strong>hide_group_for_fipfrole : </strong>cacher tout le groupe de champ (a mettre sur n'importe quel champ du groupe)</li>
<ul>
<details>
<summary>explications visuelles :</summary>
<?php include(dirname(__FILE__).'/explications_acf_groups.html'); ?>
</details>
</ul>
<li><strong>readonly_acf : </strong>transformer un champ en lecture-seule : il ne sera pas modifiable</li>
<li><strong>textarea_full_width : </strong>donner à un champ textarea toute la largeur de la page (surtout pour le champ 'historique')</li>
</ul>
<h2>divi</h2>
<ul>
<li><strong>partenaire_propre_page_cipf : </strong>cacher un element si la personne qui regarde la page n'est pas le ou la partenaire à qui appartient la page (l'article)</li>
<li><strong>cipf_display_ : </strong>cacher un element si la page n'est pas dans un etat precis, voici la liste de tous les etats possibles :
<ul>
<li><strong>cipf_display_carte_commande</strong></li>
<li><strong>cipf_display_carte_renouvellement</strong></li>
<li><strong>cipf_display_changer_carte</strong></li>
<li><strong>cipf_display_compte_carte_expiree</strong></li>
<li><strong>cipf_display_compte_carte_valide</strong></li>
<li><strong>cipf_display_compte_doit_payer</strong></li>
<li><strong>cipf_display_compte_en_attente_invalide</strong></li>
<li><strong>cipf_display_compte_en_attente_valide</strong></li>
<li><strong>cipf_display_compte_nouveau_prof</strong></li>
<li><strong>cipf_display_page_partenaire_brouillon</strong></li>
<li><strong>cipf_display_page_partenaire_publiee</strong></li>
<li><strong>cipf_display_paiement_aucun</strong></li>
<li><strong>cipf_display_paiement_echec</strong></li>
<li><strong>cipf_display_paiement_en_cours</strong></li>
<li><strong>cipf_display_paiement_reussi</strong></li>
<li><strong>cipf_display_type_paypal</strong></li>
<li><strong>cipf_display_type_virement</strong></li>
</ul>
</li>
</ul>
</section>

View File

@@ -0,0 +1,124 @@
<div class="case_title"><h4>le groupe de champs par defaut</h4></div>
<div class="case">
<div>
<p><strong>champ 1 : </strong>(pas de class)</p>
<p><strong>champ 2 : </strong>(pas de class)</p>
</div>
</div>
<div class="group">
<p><strong>emails profs et partenaires</strong></p>
<div class="field">
<p>champ 1</p>
<div class="input"></div>
</div>
<div class="field">
<p>champ 2</p>
<div class="input"></div>
</div>
</div>
<div class="delimiter"></div>
<div class="case_title"><h4>cacher un champ du groupe</h4><p>avec <code>hide_for_fiprole</code></p></div>
<div class="case">
<div>
<p><strong>champ 1 : </strong>hide_for_fipfrole</p>
<p><strong>champ 2 : </strong>(pas de class)</p>
</div>
</div>
<div class="group">
<p><strong>emails profs et partenaires</strong></p>
<div class="field">
<p>champ 2</p>
<div class="input"></div>
</div>
</div>
<div class="case_title"><h4>ou</h4></div>
<div class="case">
<div>
<p><strong>champ 1 : </strong>(pas de class)</p>
<p><strong>champ 2 : </strong>hide_for_fipfrole</p>
</div>
</div>
<div class="group">
<p><strong>emails profs et partenaires</strong></p>
<div class="field">
<p>champ 1</p>
<div class="input"></div>
</div>
</div>
<div class="delimiter"></div>
<div class="case_title"><h4>cacher le titre du groupe</h4><p>avec <code>hide_title_for_fiprole</code></p></div>
<div class="case">
<div>
<p><strong>champ 1 : </strong>hide_title_for_fipfrole</p>
<p><strong>champ 2 : </strong>(pas de class)</p>
</div>
<h2>ou</h2>
<div>
<p><strong>champ 1 : </strong>(pas de class)</p>
<p><strong>champ 2 : </strong>hide_title_for_fipfrole</p>
</div>
<h2>ou</h2>
<div>
<p><strong>champ 1 : </strong>hide_title_for_fipfrole</p>
<p><strong>champ 2 : </strong>hide_title_for_fipfrole</p>
</div>
</div>
<div class="group">
<div class="field">
<p>champ 1</p>
<div class="input"></div>
</div>
<div class="field">
<p>champ 2</p>
<div class="input"></div>
</div>
</div>
<div class="delimiter"></div>
<div class="case_title"><h4>cacher tout le groupe</h4><p>avec <code>hide_group_for_fiprole</code></p></div>
<div class="case">
<div>
<p><strong>champ 1 : </strong>hide_group_for_fipfrole</p>
<p><strong>champ 2 : </strong>(pas de class)</p>
</div>
<h2>ou</h2>
<div>
<p><strong>champ 1 : </strong>(pas de class)</p>
<p><strong>champ 2 : </strong>hide_group_for_fipfrole</p>
</div>
<h2>ou</h2>
<div>
<p><strong>champ 1 : </strong>hide_group_for_fipfrole</p>
<p><strong>champ 2 : </strong>hide_group_for_fipfrole</p>
</div>
</div>
<div class="group">
</div>
<div class="case_title"><h4>ou </h4><p>avec <code>hide_for_fipfrole</code> sur chaque elements et <code>hide_title_for_fipfrole</code> sur n'importe quel elements ou sur tous</p></div>
<div class="case">
<div>
<p><strong>champ 1 : </strong>hide_for_fipfrole <span class="big_space"></span>hide_title_for_fipfrole</p>
<p><strong>champ 2 : </strong>hide_for_fipfrole</p>
</div>
<h2>ou</h2>
<div>
<p><strong>champ 1 : </strong>hide_for_fipfrole</p>
<p><strong>champ 2 : </strong>hide_for_fipfrole <span class="big_space"></span>hide_title_for_fipfrole</p>
</div>
<h2>ou</h2>
<div>
<p><strong>champ 1 : </strong>hide_for_fipfrole <span class="big_space"></span>hide_title_for_fipfrole</p>
<p><strong>champ 2 : </strong>hide_for_fipfrole <span class="big_space"></span>hide_title_for_fipfrole</p>
</div>
</div>
<div class="group">
</div>

View File

@@ -34,8 +34,11 @@ export async function onApprove(data, actions) {
throw new Error(`${errorDetail.description} (${orderData.debug_id})`); throw new Error(`${errorDetail.description} (${orderData.debug_id})`);
} }
else if (!orderData.purchase_units) { else if (!orderData.purchase_units) {
// Check if error was a server-side issue but PayPal confirmed payment
if (orderData.ERROR_TREATMENT) { if (orderData.ERROR_TREATMENT) {
console.log("Capture result",orderData); console.log("Capture result - Server processing error, but payment may be valid:",orderData);
// Display problem message - payment succeeded on PayPal but failed locally
// User stays on page to see the message
resultMessage(PLGNTLS_data.paypal_message_problem); resultMessage(PLGNTLS_data.paypal_message_problem);
} }
else { else {
@@ -48,15 +51,14 @@ export async function onApprove(data, actions) {
const transaction = const transaction =
orderData?.purchase_units?.[0]?.payments?.captures?.[0] || orderData?.purchase_units?.[0]?.payments?.captures?.[0] ||
orderData?.purchase_units?.[0]?.payments?.authorizations?.[0]; orderData?.purchase_units?.[0]?.payments?.authorizations?.[0];
console.log("Capture result",orderData); console.log("Capture result - Success:",orderData);
resultMessage(PLGNTLS_data.paypal_message_success); resultMessage(PLGNTLS_data.paypal_message_success);
actions.redirect(PLGNTLS_data.paypal_redirection_success); actions.redirect(PLGNTLS_data.paypal_redirection_success);
} }
} }
catch (error) { catch (error) {
console.error(error); console.error("Payment approval error:", error);
resultMessage(PLGNTLS_data.paypal_message_failure); resultMessage(PLGNTLS_data.paypal_message_failure);
actions.redirect(PLGNTLS_data.paypal_redirection_failure); actions.redirect(PLGNTLS_data.paypal_redirection_failure);
} }
} }

View File

@@ -0,0 +1,209 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* events and emails :
*
* 1. [/] profs : payment_success : paypal payment success
* 2. [/] profs : payment_echec : paypal payment echec
* 3. [/] profs : transfert_success : validation transfert prof reussi, send email
* 4. [ ] partners : offer_expired : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
* 5. [ ] partners : offer_will_expire : la gestion des offres à échéance
* 6. [ ] prof : account_deleted : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte
* 7. [ ] prof : account_will_expire : faire rappels emails avant expiration
* 8. [ ] prof : account_expired : desactiver carte expiree
*
* maybe log mails error ? https://wordpress.stackexchange.com/a/336533/226939
*
*/
function prepare_emails_CIPF($email_name, $user_id) {
Plgntls::debug_infos();
$emails_option_object = Cipf::OPTION_EMAILS;
if (!isset($emails_option_object['_default'][$email_name])) {
return false;
}
$header_content_type = 'Content-Type: text/html; charset=UTF-8';
$emails_option = Plgntls::get_option_safe($emails_option_object);
if (!$emails_option) {
return false;
}
if (!isset($emails_option[$email_name])) {
return false;
}
$email = $emails_option[$email_name];
$emails = array();
if (isset($email['notification_send']) && $email['notification_send'] === 'on') {
$tmp_email = array();
$tmp_email['to'] = $email['notification_to'];
$tmp_email['subject'] = $email['notification_subject'];
$tmp_email['message'] = $email['notification_message'];
$tmp_email['headers'] = array();
$tmp_email['headers'][] = $header_content_type;
$tmp_email['headers']['user_id'] = $user_id;
$from = $email['notification_from'];
if (empty($from)) {
$from = get_option('admin_email');
}
if (!empty($from)) {
$tmp_email['headers'][] = 'From: '.$from;
}
$emails[] = $tmp_email;
}
if (isset($email['confirmation_send']) && $email['confirmation_send'] === 'on') {
$tmp_email = array();
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
if ($user_id === 0) {
return false;
}
$user = get_user_by('id', $user_id);
$user_email = $user->user_email;
$tmp_email['to'] = $user_email;
$tmp_email['subject'] = $email['confirmation_subject'];
$tmp_email['message'] = $email['confirmation_message'];
$tmp_email['headers'] = array();
$tmp_email['headers'][] = $header_content_type;
$tmp_email['headers']['user_id'] = $user_id;
$from = $email['confirmation_from'];
if (empty($from)) {
$from = get_option('admin_email');
}
if (!empty($from)) {
$tmp_email['headers'][] = 'From: '.$from;
}
$emails[] = $tmp_email;
}
return $emails;
}
function send_emails_CIPF($email_name, $user_id = null) {
Plgntls::debug_infos();
$emails = prepare_emails_CIPF($email_name, $user_id);
if (false === $emails) {
error_log('Email preparing failed!: ' . json_encode($email_name));
return;
}
foreach ($emails as $email) {
// dont delete, for log
error_log("send '".$email_name."' email to: ".$email['to']." (".json_encode($email).")");
$sent = wp_mail($email['to'], $email['subject'], $email['message'], $email['headers']);
if (!$sent) {
error_log('Email sending failed!: ' . json_encode($email));
}
}
}
/*
* get the acf reminders,
* - continue the ones not for the reminder_type
* - continue if date is not yet soon enough
* - continue if email was already sent
*
*/
function handle_send_reminders_CIPF($acf_id, $user_id, $date_limit, $reminder_type, $email_type) {
$is_before_reminders = true;
$reminders_choices = get_emails_reminders_choices_CIPF($acf_id);
foreach ($reminders_choices as $reminder_key => $value) {
$duration = get_duration_CIPF($reminder_key, $reminder_type);
if (false === $duration) {
continue;
}
$diff = compare_diff_with_today_CIPF($date_limit, $duration);
if ($diff > 0) {
continue;
}
$is_before_reminders = false;
if (is_email_reminder_choice_CIPF($reminder_key, $acf_id)) {
continue;
}
set_email_reminder_choice_CIPF($reminder_key, $acf_id);
send_emails_CIPF($email_type, $user_id);
return; // don't send multiple emails
}
/*
* if didnt return, it either means that :
* - today is before any reminder
* - today is after all reminders
* use 'is_before_reminders' to know
*
*/
if ($is_before_reminders) {
reset_emails_reminders_box_CIPF($reminder_type, $acf_id);
}
}
/*
* extract the duration
* returns false if not for the right type
*
*/
function get_duration_CIPF($reminder, $type) {
Plgntls::debug_infos();
$explode_reminder = explode('/', $reminder);
$explode_reminder = array_map('trim', $explode_reminder);
if ($explode_reminder[0] !== $type) {
return false;
}
$duration = $explode_reminder[1];
return $duration;
}
/*
* find the diffs :
* - the intended diff between the deletion date and the reminder
* - the diff between the deletion date and today
* and return the difference
*
*/
function compare_diff_with_today_CIPF($date, $duration) {
Plgntls::debug_infos();
$date_reminder = $date->modify($duration);
$date_diff = date_diff($date, $date_reminder);
$date_diff = (int)$date_diff->format('%R%a');
$date_now = date_create('now');
$current_date_diff = date_diff($date, $date_now);
$current_date_diff = (int)$current_date_diff->format('%R%a');
return ($date_diff - $current_date_diff);
}
?>

View File

@@ -0,0 +1,244 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* add a monthly interval to the schedules
*
*/
function cron_add_monthly_CIPF($schedules) {
// Adds once weekly to the existing schedules.
$schedules['monthly_cipf'] = array(
'interval' => MONTH_IN_SECONDS,
'display' => __( 'every month' )
);
return $schedules;
}
//add_filter( 'cron_schedules', 'cron_add_monthly_CIPF' );
/*
* create the scheduled event
*
*/
function schedule_monthly_newsletter_CIPF() {
Plgntls::debug_infos();
if (! wp_next_scheduled('CIPF_send_newsletter')) {
wp_schedule_event(strtotime('2:00:00'), 'monthly_cipf', 'CIPF_send_newsletter');
}
}
//add_action('init', 'schedule_monthly_newsletter_CIPF');
/*
* main action for the newsletter
*
*/
function send_newsletter_CIPF() {
Plgntls::debug_infos();
$email_body = compose_newsletter_body_CIPF();
error_log("email_body:" . json_encode($email_body));
$emails = get_subscribers_emails_CIPF();
error_log("emails:" . json_encode($emails));
// foreach ($emails as $email) {
//
// }
}
add_action('CIPF_send_newsletter', 'send_newsletter_CIPF');
/*
* returns an array of all the subscribers emails
*
*/
function get_subscribers_emails_CIPF() {
Plgntls::debug_infos();
$acf_newsletter_receive = Cipf::ACF_NEWSLETTER_RECEIVE;
$acf_newsletter_id = Cipf::ACF_NEWSLETTER_ID;
/*
* using LIKE to compare an array, because the content of the acf field is an array
*
*/
$args = array(
'meta_query' => array(
array(
'key' => $acf_newsletter_receive['_name'],
'value' => $acf_newsletter_receive['true'],
'compare' => 'LIKE',
),
),
'fields' => array(
'user_email',
),
);
$users = get_users($args);
/*
* transform the array of associatives arrays into an array of string :
* [['user_email' => <email>], ['user_email' => <email>]] -> [<email>, <email>]
*
*/
$users_string = array_map(function($arr) {
return reset($arr);
}, $users);
return $users_string;
}
/*
*/
function remove_subscriber_CIPF($id) {
Plgntls::debug_infos();
}
function compose_newsletter_body_CIPF() {
Plgntls::debug_infos();
$all_posts = get_all_partner_posts();
//error_log("all_posts: " . json_encode($all_posts));
$ending_offers = extract_ending_offers_CIPF($all_posts); // [<post_id> => <offer_number>, <post_id> => <offer_number>]
//error_log("ending_offers: " . json_encode($ending_offers));
$new_offers = extract_new_offers_CIPF($all_posts); // [<post_id> => <offer_number>, <post_id> => <offer_number>]
error_log("new_offers: " . json_encode($new_offers));
/*
$new_partners = extract_new_partners_CIPF($all_posts); // [<post_id>, <post_id>]
$total = count($ending_offers) + count($new_offers) + count($new_partners);
$remaining_partners = extract_partners_if_less_than_CIPF($all_posts, $total, 5); // [<post_id>, <post_id>]
ob_start();
?>
<h1>newsletter cipf</h1>
<?php foreach ($new_partners as $post_id) { ?>
<?php } ?>
<?php foreach ($new_offers as $post_id => $offer_number) { ?>
<?php } ?>
<?php foreach ($ending_offers as $post_id => $offer_number) { ?>
<?php } ?>
<?php foreach ($remaining_partners as $post_id) { ?>
<?php } ?>
<footer><a href="">se desinscrire</a></footer>
<?php
$body_html = ob_get_clean();
return $body_html;
*/
return '';
}
function extract_ending_offers_CIPF(&$all_posts) {
Plgntls::debug_infos();
$offers = array();
foreach ($all_posts as $key => $page_id) {
$ending_offer = get_ending_offer_CIPF($page_id);
if ($ending_offer !== null) {
$offers[$page_id] = $ending_offer;
unset($all_posts[$key]);
//$all_posts = array_values($all_posts);
}
}
return $offers;
}
function get_ending_offer_CIPF($page_id) {
Plgntls::debug_infos();
$i = 1;
while ($i <= 3) {
$offer_duration = get_field_init_CIPF('duree_offre_'.$i, $page_id);
if ($offer_duration !== 'Temporaire') {
++$i;
continue;
}
$offer_output = get_field_init_CIPF('afficher_offre_'.$i, $page_id);
if ($offer_output === 'Masquer') {
++$i;
continue;
}
if (is_offer_date_exceeded_CIPF($i, $page_id)) {
++$i;
continue;
}
$date_limit = get_offer_date_expiration_CIPF($i, $page_id);
if (false === $date_limit) {
++$i;
continue;
}
$date_now = date_create('today');
$date_diff = date_diff($date_now, $date_limit);
$date_diff = (int)$date_diff->format('%R%a');
if ($date_diff > 30) {
++$i;
continue;
}
return $i;
}
return null;
}
function extract_new_offers_CIPF(&$all_posts) {
Plgntls::debug_infos();
$offers = array();
foreach ($all_posts as $key => $page_id) {
$ending_offer = get_new_offer_CIPF($page_id);
if ($ending_offer !== null) {
$offers[$page_id] = $ending_offer;
unset($all_posts[$key]);
//$all_posts = array_values($all_posts);
}
}
return $offers;
}
function get_new_offer_CIPF($page_id) {
Plgntls::debug_infos();
$i = 1;
while ($i <= 3) {
$offer_output = get_field_init_CIPF('afficher_offre_'.$i, $page_id);
if ($offer_output === 'Masquer') {
++$i;
continue;
}
//return $i;
}
return null;
}
function extract_new_partners_CIPF($all_posts) {
Plgntls::debug_infos();
}
function extract_partners_if_less_than_CIPF($all_posts, $total_count, $number) {
Plgntls::debug_infos();
}
?>

View File

@@ -54,12 +54,30 @@ function get_paypal_options_CIPF() {
function get_paypal_client_id_CIPF() { function get_paypal_client_id_CIPF() {
Plgntls::debug_infos(); Plgntls::debug_infos();
$paypal_credentials = get_paypal_options_CIPF(); $paypal_credentials = get_paypal_options_CIPF();
return $paypal_credentials['client_id']; $is_sandbox = $paypal_credentials['is_sandbox'];
$client_id = '';
if ($is_sandbox) {
$client_id = $paypal_credentials['sandbox_client_id'];
}
else {
$client_id = $paypal_credentials['live_client_id'];
}
return $client_id;
} }
function get_paypal_client_secret_CIPF() { function get_paypal_client_secret_CIPF() {
Plgntls::debug_infos(); Plgntls::debug_infos();
$paypal_credentials = get_paypal_options_CIPF(); $paypal_credentials = get_paypal_options_CIPF();
return $paypal_credentials['client_secret']; $is_sandbox = $paypal_credentials['is_sandbox'];
$client_secret = '';
if ($is_sandbox) {
$client_secret = $paypal_credentials['sandbox_client_secret'];
}
else {
$client_secret = $paypal_credentials['live_client_secret'];
}
return $client_secret;
} }
function get_paypal_api_base_url_CIPF() { function get_paypal_api_base_url_CIPF() {
Plgntls::debug_infos(); Plgntls::debug_infos();
@@ -75,7 +93,33 @@ function get_paypal_api_base_url_CIPF() {
} }
return $paypal_base_url; return $paypal_base_url;
} }
function is_paypal_force_1_cent_CIPF() {
Plgntls::debug_infos();
$paypal_options = get_paypal_options_CIPF();
return $paypal_options['force_1_cent'];
}
function get_paypal_price_CIPF($user_id = null) {
Plgntls::debug_infos();
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
if (is_paypal_force_1_cent_CIPF($user_id)) {
$price = "0.01";
}
else if (is_acf_prof_change_card_CIPF($user_id)) {
$price = "5";
}
else {
$price = get_card_price_CIPF($user_id);
}
return $price;
}

View File

@@ -0,0 +1,349 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* schedule events :
* - first use a function to add the event :
* - function launch_schedule_my_evet() {
* wp_schedule_single_event($delay, 'hook_event_name');
* }
* - this will enqueue an action hook when the time will come, that you must define :
* - add_action('hook_event_name', 'callback_function');
* - and finally, define the function 'callback_function()'
*
* to define the delay, you can use the strtotime notation
* - strtotime('+1 month');
* -> https://www.php.net/manual/en/function.strtotime.php
* or the time constants in seconds :
* - time() + 3 * MINUTE_IN_SECONDS
* -> https://codex.wordpress.org/Easier_Expression_of_Time_Constants
*
*/
function get_all_profs_ids() {
Plgntls::debug_infos();
$prof = Cipf::ROLE_PROF;
$args = array(
'role' => $prof,
'fields' => 'ID',
);
$users = get_users($args);
return $users;
}
function get_all_partner_posts() {
$args = array(
'posts_per_page' => -1, // Retrieve all posts
'post_type' => 'post',
'post_status' => 'publish',
'fields' => 'ids',
);
$posts = get_posts($args);
return $posts;
}
/*
* event that check all actions
*
*/
function schedule_daily_checkup_CIPF() {
Plgntls::debug_infos();
if (! wp_next_scheduled('CIPF_daily_checkup')) {
wp_schedule_event(strtotime('2:00:00'), 'daily', 'CIPF_daily_checkup');
}
}
add_action('init', 'schedule_daily_checkup_CIPF');
function check_profs_and_partners_dates_CIPF() {
Plgntls::debug_infos();
error_log("...START daily cron job");
$profs_ids = get_all_profs_ids();
foreach ($profs_ids as $prof_id) {
handle_reminders_before_card_expire_CIPF($prof_id);
handle_card_expire_CIPF($prof_id);
handle_reminders_before_account_deleted_CIPF($prof_id);
handle_prof_account_deletion_CIPF($prof_id);
}
$partner_pages_ids = get_all_partner_posts();
foreach ($partner_pages_ids as $page_id) {
handle_partner_offers_expire_CIPF($page_id);
}
send_emails_CIPF('cron_job');
error_log("...END daily cron job");
}
add_action('CIPF_daily_checkup', 'check_profs_and_partners_dates_CIPF');
/*
* events and emails :
*
* 1. [/] payments : TIME_OLD_ORDER_ID - suppress old order_ids
* 2. [/] prof (email) : TIME_ACCOUNT_DELETE_AFTER_EXPIRE - schedule event to suppress the account xx time (6 month ?) after end of validity of the card, and supress the codes
* 3. [/] prof (email) : - schedule event to deactivate the card
* 4. [/] prof (email) : TIME_REMINDER_BEFORE_ACCOUNT_EXPIRE_FIRST - send emails reminder before account deactivate
* 5. [/] prof (email) : TIME_REMINDER_BEFORE_ACCOUNT_EXPIRE_LAST - send emails reminder before account deactivate
* 6. [/] prof (email) : TIME_REMINDER_BEFORE_ACCOUNT_DELETE_FIRST - send emails reminder before account delete
* 7. [/] prof (email) : TIME_REMINDER_BEFORE_ACCOUNT_DELETE_LAST - send emails reminder before account delete
* 8. [ ] partner (email) : TIME_REMINDER_BEFORE_OFFER_EXPIRE - send emails reminder before offer ends
* 9. [ ] partners (email) : - temp offers -> make them disappeay after end card validity -> put them in hidden
*
*/
/*
* 1. prof, add a schedule event to delete this order_id
*
*/
function schedule_delete_orderid_CIPF($order_id, $user_id) {
Plgntls::debug_infos();
$duration_order_id = Cipf::DURATION_OLD_ORDER_ID;
$delay = strtotime($duration_order_id);
wp_schedule_single_event($delay, 'CIPF_orderid_deletion_event', array($order_id, $user_id));
}
function delete_order_id_later_CIPF($order_id, $user_id) {
Plgntls::debug_infos();
if (!isset_acf_order_id_CIPF($user_id)) {
return;
}
if (!is_acf_order_id_CIPF($order_id, $user_id)) {
return;
}
reset_acf_order_id_CIPF($user_id);
}
add_action('CIPF_orderid_deletion_event', 'delete_order_id_later_CIPF', 10, 2);
/*
* 2. prof, suppress account XX time after expiration, also email
* need to include file for wp_delete_user to work : https://developer.wordpress.org/reference/functions/wp_delete_user/
*
*/
//function schedule_prof_account_deletion_CIPF($user_id) {
// Plgntls::debug_infos();
// $duration_deletion = Cipf::DURATION_ACCOUNT_DELETE_AFTER_EXPIRE;
//
// $date_limit = get_card_date_expiration_CIPF($user_id);
// if (false === $date_limit) {
// return;
// }
// $new_date = $date_limit->modify($duration_deletion);
// $delay = $new_date->getTimestamp();
// wp_schedule_single_event($delay, 'CIPF_prof_account_deletion', array($user_id));
//}
//add_action('CIPF_prof_account_deletion', 'handle_prof_account_deletion_CIPF');
/*
* 3. prof, deactivate card at expiration time, also email
*
*/
//function schedule_deactivate_expired_card_CIPF($user_id) {
// Plgntls::debug_infos();
//
// $date_limit = get_card_date_expiration_CIPF($user_id);
// if (false === $date_limit) {
// return;
// }
// $new_date = $date_limit->modify('+1 day');
// $delay = $new_date->getTimestamp();
// wp_schedule_single_event($delay, 'CIPF_deactivate_expired_card', array($user_id));
//}
//add_action('CIPF_deactivate_expired_card', 'handle_card_expire_CIPF');
/*
* 4. && 5. prof, send email reminder before account expire
*
*/
//function schedule_reminder_before_card_expire_CIPF($user_id) {
// Plgntls::debug_infos();
// $card_reminder_1 = Cipf::DURATION_REMINDER_BEFORE_ACCOUNT_EXPIRE_FIRST;
// $card_reminder_2 = Cipf::DURATION_REMINDER_BEFORE_ACCOUNT_EXPIRE_LAST;
//
// $date_limit = get_card_date_expiration_CIPF($user_id);
// if (false === $date_limit) {
// return;
// }
// $new_date_1 = $date_limit->modify($card_reminder_1);
// $new_date_2 = $date_limit->modify($card_reminder_2);
// $delay_1 = $new_date_1->getTimestamp();
// $delay_2 = $new_date_2->getTimestamp();
// wp_schedule_single_event($delay_1, 'CIPF_reminder_before_card_expire', array($user_id, $card_reminder_1));
// wp_schedule_single_event($delay_2, 'CIPF_reminder_before_card_expire', array($user_id, $card_reminder_2));
//}
//function send_emails_reminder_before_card_expire_CIPF($user_id, $duration) {
// Plgntls::debug_infos();
//
// if (!isset_acf_card_expiration_CIPF($user_id)) {
// return;
// }
// if (is_card_date_expired_CIPF($user_id)) {
// return;
// }
// $date_limit = get_card_date_expiration_CIPF($user_id);
// if (false === $date_limit) {
// return;
// }
//
// $date_reminder = $date_limit->modify($duration);
// $date_diff = date_diff($date_limit, $date_reminder);
// $date_diff = (int)$date_diff->format('%R%a');
//
// $date_now = date_create('now');
// $current_date_diff = date_diff($date_limit, $date_now);
// $current_date_diff = (int)$current_date_diff->format('%R%a');
//
// // i add +3 in case there is a difference of maximum 3 days between a 31 days month and a 28 days february
// if (abs($current_date_diff) <= (abs($date_diff + 3))) {
// send_emails_CIPF('card_will_expire', $user_id);
// }
//}
//add_action('CIPF_reminder_before_card_expire', 'send_emails_reminder_before_card_expire_CIPF', 10, 2);
/*
* 6. && 7. prof, send email reminder account deletion
*
*/
//function schedule_reminder_before_account_delete_CIPF($user_id) {
// Plgntls::debug_infos();
// $account_reminder_1 = Cipf::DURATION_REMINDER_BEFORE_ACCOUNT_DELETE_FIRST;
// $account_reminder_2 = Cipf::DURATION_REMINDER_BEFORE_ACCOUNT_DELETE_LAST;
// $duration_deletion = Cipf::DURATION_ACCOUNT_DELETE_AFTER_EXPIRE;
//
// $date_limit = get_card_date_expiration_CIPF($user_id);
// if (false === $date_limit) {
// return;
// }
//
// $date_deletion = $date_limit->modify($duration_deletion);
// $new_date_1 = $date_deletion->modify($account_reminder_1);
// $new_date_2 = $date_deletion->modify($account_reminder_2);
// $delay_1 = $new_date_1->getTimestamp();
// $delay_2 = $new_date_2->getTimestamp();
// wp_schedule_single_event($delay_1, 'CIPF_reminder_before_account_delete', array($user_id, $account_reminder_1));
// wp_schedule_single_event($delay_2, 'CIPF_reminder_before_account_delete', array($user_id, $account_reminder_2));
//}
//function send_emails_reminder_before_account_delete_CIPF($user_id, $duration) {
// Plgntls::debug_infos();
// $duration_deletion = Cipf::DURATION_ACCOUNT_DELETE_AFTER_EXPIRE;
//
// if (!isset_acf_card_expiration_CIPF($user_id)) {
// return;
// }
// if (!is_card_date_expired_CIPF($user_id)) {
// return;
// }
// $date_limit = get_card_date_expiration_CIPF($user_id);
// if (false === $date_limit) {
// return;
// }
//
// $date_deletion = $date_limit->modify($duration_deletion);
// $date_reminder = $date_deletion->modify($duration);
// $date_diff = date_diff($date_deletion, $date_reminder);
// $date_diff = (int)$date_diff->format('%R%a');
//
// $date_now = date_create('now');
// $current_date_diff = date_diff($date_deletion, $date_now);
// $current_date_diff = (int)$current_date_diff->format('%R%a');
//
// // i add +3 in case there is a difference of maximum 3 days between a 31 days month and a 28 days february
// if (abs($current_date_diff) <= (abs($date_diff + 3))) {
// send_emails_CIPF('account_will_be_deleted', $user_id);
// }
//}
//add_action('CIPF_reminder_before_account_delete', 'send_emails_reminder_before_account_delete_CIPF', 10, 2);
/*
* 8. partner, send email before offer expire
*
*/
//function schedule_partner_before_offer_expire_CIPF($user_id) {
// Plgntls::debug_infos();
// $offer_expire = Cipf::DURATION_REMINDER_BEFORE_OFFER_EXPIRE;
//
//// error_log("is_offer_1: " . json_encode(is_activ_partner_offer_1_date_CIPF($post_id)));
//// error_log("offer_1 date: " . json_encode(get_partner_offer_1_date_CIPF($post_id)));
//// error_log("is_offer_2: " . json_encode(is_activ_partner_offer_2_date_CIPF($post_id)));
//// error_log("offer_2 date: " . json_encode(get_partner_offer_2_date_CIPF($post_id)));
//// error_log("is_offer_3: " . json_encode(is_activ_partner_offer_3_date_CIPF($post_id)));
//// error_log("offer_3 date: " . json_encode(get_partner_offer_3_date_CIPF($post_id)));
//// $date_limit = get_card_date_expiration_CIPF($user_id);
// if (false === $date_limit) {
// return;
// }
//
// $new_date = $date_limit->modify($offer_expire);
// $delay = $new_date->getTimestamp();
// wp_schedule_single_event($delay, 'CIPF_partner_before_offer_expire', array($user_id));
//}
//function send_emails_reminder_before_offer_expire_CIPF($user_id) {
// Plgntls::debug_infos();
//
// send_emails_CIPF('offer_will_expire', $user_id);
//}
//add_action('CIPF_partner_before_offer_expire', 'send_emails_reminder_before_offer_expire_CIPF');
/*
* 9. partner, handle offer expire, also sens email
*
function schedule__CIPF($user_id) {
Plgntls::debug_infos();
$delay = strtotime('+3 days');
wp_schedule_single_event($delay, 'scedule_event_CIPF', array($user_id));
}
function event_CIPF($user_id) {
Plgntls::debug_infos();
}
add_action('schedule_event_CIPF', 'event_CIPF', 10, 2);
*/
?>

View File

@@ -0,0 +1,271 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* returns the date limit as a DateTime object
* or false if not set
*
*/
function get_date_CIPF($acf_date, $acf_id) {
Plgntls::debug_infos();
$acf_date_format = Cipf::ACF_DATE_FORMAT;
/*
* get acf date field
* 3d parameter is false to not format the date and get it as 'Ymd'
*
*/
$current_date_string = get_field($acf_date['_name'], $acf_id, false);
if (empty($current_date_string)) {
return false;
}
/*
* create date object from acf date
*
*/
// compare 2 dates : https://stackoverflow.com/q/8722806/9497573
// also I dont use strtotime to compare 2 ints,
// because i don't know if it will fail one day (2000y bug style)
$current_date = date_create_immutable_from_format($acf_date_format, $current_date_string);
if ($current_date === false) {
return false;
}
// /*
// * get acf date field
// *
// */
// $current_date_object = get_field_object($acf_date['_name'], $acf_id);
// if (empty($current_date_object)) {
// return false;
// }
// if (empty($current_date_object['value'])) {
// return false;
// }
//
// /*
// * create date object from acf date
// *
// */
// $current_date_string = $current_date_object['value'];
// $current_format_field = $current_date_object['return_format'];
// // compare 2 dates : https://stackoverflow.com/q/8722806/9497573
// // also I dont use strtotime to compare 2 ints,
// // because i don't know if it will fail one day (2000y bug style)
// $current_date = date_create_immutable_from_format($current_format_field, $current_date_string);
// if ($current_date === false) {
// return false;
// }
/*
* returns the date object
*
*/
return $current_date;
}
/*
* returns true if date is in paste or is empty
*
*/
function is_date_exceeded_CIPF($date) {
Plgntls::debug_infos();
if (empty($date)) {
return true;
}
if (!$date instanceof DateTimeInterface) {
return true;
}
/*
* check if expired
*
*/
$date_now = date_create('today');
$date_diff = date_diff($date_now, $date);
$date_diff = (int)$date_diff->format('%R%a');
if ($date_diff < 0) {
return true;
}
else {
return false;
}
}
/*
* add duration to date object
* duration is expected in a string format : https://www.php.net/manual/en/class.dateinterval.php
*
*/
function get_new_date_CIPF($date, $duration) {
Plgntls::debug_infos();
$current_date = $date;
// empty return true for false, null, empty string and array, and 0
if (empty($date)) {
$current_date = date_create_immutable('today');
}
else if (!$current_date instanceof DateTimeInterface) {
$current_date = date_create_immutable('today');
}
/*
* update date limit validity to add 1 year
*
*/
return $new_date = $current_date->add(date_interval_create_from_date_string($duration));
}
/*
* update acf field with new date
*
*/
function set_acf_date_CIPF($acf_date_field_to_update, $new_date, $user_id) {
Plgntls::debug_infos();
$acf_date_format = Cipf::ACF_DATE_FORMAT;
$acf_id = 'user_'.$user_id;
set_acf_field_CIPF($acf_date_field_to_update, $new_date->format($acf_date_format), $acf_id);
}
/*********************************************************************/
/*
* card date expiration
*
*/
function get_card_date_expiration_CIPF($user_id = null) {
Plgntls::debug_infos();
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
return get_date_CIPF($acf_card_expiration, $acf_id);
}
function is_card_date_expired_CIPF($user_id = null) {
Plgntls::debug_infos();
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$card_date = get_card_date_expiration_CIPF($user_id);
return is_date_exceeded_CIPF($card_date);
}
function isset_acf_card_expiration_CIPF($user_id = null) {
Plgntls::debug_infos();
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
return isset_acf_field_CIPF($acf_card_expiration, $acf_id);
}
function update_card_date_expiration_CIPF($user_id = null) {
Plgntls::debug_infos();
$acf_card_field = Cipf::ACF_CARD_EXPIRATION;
$card_duration = Cipf::DURATION_CARD_VALIDITY;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$date = get_card_date_expiration_CIPF($user_id);
$new_date = get_new_date_CIPF($date, $card_duration);
set_acf_date_CIPF($acf_card_field, $new_date, $user_id);
}
/*
* prof account deletion
*
*/
function get_prof_accound_deletion_date_CIPF($user_id = null) {
Plgntls::debug_infos();
$delete_duration = Cipf::DURATION_ACCOUNT_DELETE_AFTER_EXPIRE;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$card_expiration_date = get_card_date_expiration_CIPF($user_id);
return get_new_date_CIPF($card_expiration_date, $delete_duration);
}
function is_prof_account_deletion_date_exceeded_CIPF($user_id = null) {
Plgntls::debug_infos();
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$account_date = get_prof_accound_deletion_date_CIPF($user_id);
return is_date_exceeded_CIPF($account_date);
}
/*
* partner offers
*
*/
function get_offer_date_expiration_CIPF($offer_number, $page_id) {
Plgntls::debug_infos();
$acf_date_format = Cipf::ACF_DATE_FORMAT;
$acf_field_name = 'fin_offre_'.$offer_number;
$current_date_expiration = get_field($acf_field_name, $page_id, false);
$date_expiration = date_create_immutable_from_format($acf_date_format, $current_date_expiration);
return $date_expiration;
}
function is_offer_date_exceeded_CIPF($offer_number, $page_id) {
Plgntls::debug_infos();
$offer_date = get_offer_date_expiration_CIPF($offer_number, $page_id);
return is_date_exceeded_CIPF($offer_date);
}
?>

View File

@@ -0,0 +1,161 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
{"ID":43757,"key":"field_6617daff359b2","label":"rappels emails","name":"rappels_emails","aria-label":"","prefix":"acf", "type":"checkbox", "value":null, "menu_order":0, "instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"hide_group_for_fipfrole_cipf read_only_cipf","id":""},"choices":{"card_expiration \/ -30 days":"PROF EXPIRATION - rappel email 1 mois avant expiration de la carte","card_expiration \/ -7 days":"PROF EXPIRATION - rappel email 7 jours avant expiration de la carte","card_expired":"PROF EXPIRATION - email quand la carte a expir\u00e9","account_deletion \/ -30 days":"PROF SUPPRESSION - rappel email 1 mois avant suppression du compte","account_deletion \/ -7 days":"PROF SUPPRESSION - rappel email 7 jours avant suppression du compte","offer_expiration_1 \/ -7 days":"PARTENAIRE EXPIRATION 1 - rappel email 7 jours avant expiration d'une offre","offer_expiration_2 \/ -7 days":"PARTENAIRE EXPIRATION 2 - rappel email 7 jours avant expiration d'une offre","offer_expiration_3 \/ -7 days":"PARTENAIRE EXPIRATION 3 - rappel email 7 jours avant expiration d'une offre"},"default_value":[],"return_format":"label","allow_custom":0,"layout":"vertical","toggle":0,"save_custom":0,"custom_choice_button_text":"Add new choice","_name":"rappels_emails","_valid":1}
{"ID":43880,"key":"field_66200b6283912","label":"text_readonly","name":"text_readonly","aria-label":"","prefix":"acf", "type":"text", "value":null, "menu_order":1, "instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"default_value":"","maxlength":"","placeholder":"","prepend":"","append":"","_name":"text_readonly","_valid":1}
{"ID":43881,"key":"field_66200c4383914","label":"textarea_readonly","name":"textarea_readonly","aria-label":"","prefix":"acf","type":"textarea", "value":null, "menu_order":2, "instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"default_value":"","maxlength":"","rows":"","placeholder":"","new_lines":"","_name":"textarea_readonly","_valid":1}
{"ID":43882,"key":"field_66200b7f83913","label":"number_readonly","name":"number_readonly","aria-label":"","prefix":"acf", "type":"number", "value":null, "menu_order":3, "instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"default_value":"","min":"","max":"","placeholder":"","step":"","prepend":"","append":"","_name":"number_readonly","_valid":1}
{"ID":43883,"key":"field_66200d7583916","label":"range_readonly","name":"range_readonly","aria-label":"","prefix":"acf", "type":"range", "value":null, "menu_order":4, "instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"default_value":"","min":"","max":"","step":"","prepend":"","append":"","_name":"range_readonly","_valid":1}
{"ID":43884,"key":"field_66200da983917","label":"email_readonly","name":"email_readonly","aria-label":"","prefix":"acf", "type":"email", "value":null, "menu_order":5, "instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"default_value":"","placeholder":"","prepend":"","append":"","_name":"email_readonly","_valid":1}
{"ID":43885,"key":"field_66200dbd83918","label":"url_readonly","name":"url_readonly","aria-label":"","prefix":"acf", "type":"url", "value":null, "menu_order":6, "instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"default_value":"","placeholder":"","_name":"url_readonly","_valid":1}
{"ID":43886,"key":"field_66200dfb83919","label":"password_readonly","name":"password_readonly","aria-label":"","prefix":"acf","type":"password", "value":null, "menu_order":7, "instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"placeholder":"","prepend":"","append":"","_name":"password_readonly","_valid":1}
{"ID":43887,"key":"field_66200e0d8391a","label":"image_readonly","name":"image_readonly","aria-label":"","prefix":"acf", "type":"image", "value":null, "menu_order":8, "instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"return_format":"array","library":"all","min_width":"","min_height":"","min_size":"","max_width":"","max_height":"","max_size":"","mime_types":"","preview_size":"medium","_name":"image_readonly","_valid":1}
{"ID":43888,"key":"field_66201a805f90d","label":"file","name":"file","aria-label":"","prefix":"acf", "type":"file", "value":null, "menu_order":9, "instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"return_format":"array","library":"all","min_size":"","max_size":"","mime_types":"","_name":"file","_valid":1}
{"ID":43889,"key":"field_66201a955f90e","label":"wysiwyg","name":"wysiwyg","aria-label":"","prefix":"acf", "type":"wysiwyg", "value":null, "menu_order":10,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"default_value":"","tabs":"all","toolbar":"full","media_upload":1,"delay":0,"_name":"wysiwyg","_valid":1}
{"ID":43890,"key":"field_66201aa45f90f","label":"oembed","name":"oembed","aria-label":"","prefix":"acf", "type":"oembed", "value":null, "menu_order":11,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"width":"","height":"","_name":"oembed","_valid":1}
{"ID":43891,"key":"field_66201aad5f910","label":"select","name":"select","aria-label":"","prefix":"acf", "type":"select", "value":null, "menu_order":12,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"choices":{"one":"one","two":"two"},"default_value":false,"return_format":"value","multiple":0,"allow_null":0,"ui":0,"ajax":0,"placeholder":"","_name":"select","_valid":1}
{"ID":43892,"key":"field_66201ac05f911","label":"checkbox","name":"checkbox","aria-label":"","prefix":"acf", "type":"checkbox", "value":null, "menu_order":13,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"choices":{"one":"one","two":"two"},"default_value":[],"return_format":"value","allow_custom":0,"layout":"vertical","toggle":0,"save_custom":0,"custom_choice_button_text":"Add new choice","_name":"checkbox","_valid":1}
{"ID":43893,"key":"field_66201ad25f912","label":"radio","name":"radio","aria-label":"","prefix":"acf", "type":"radio", "value":null, "menu_order":14,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"choices":{"one":"one","two":"two"},"default_value":"","return_format":"value","allow_null":0,"other_choice":0,"layout":"vertical","save_other_choice":0,"_name":"radio","_valid":1}
{"ID":43894,"key":"field_66201adb5f913","label":"button group","name":"button_group","aria-label":"","prefix":"acf", "type":"button_group","value":null, "menu_order":15,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"choices":{"one":"one","two":"two"},"default_value":"","return_format":"value","allow_null":0,"layout":"horizontal","_name":"button_group","_valid":1}
{"ID":43895,"key":"field_66201ae95f914","label":"true-false","name":"true-false","aria-label":"","prefix":"acf", "type":"true_false", "value":null, "menu_order":16,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"message":"message","default_value":0,"ui":0,"ui_on_text":"","ui_off_text":"","_name":"true-false","_valid":1}
{"ID":43896,"key":"field_66201af35f915","label":"link","name":"link","aria-label":"","prefix":"acf", "type":"link", "value":null, "menu_order":17,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"return_format":"array","_name":"link","_valid":1}
{"ID":43897,"key":"field_66201b015f916","label":"post object","name":"post_object","aria-label":"","prefix":"acf", "type":"post_object", "value":null, "menu_order":18,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"post_type":"","post_status":"","taxonomy":"","return_format":"object","multiple":0,"allow_null":0,"bidirectional":0,"ui":1,"bidirectional_target":[],"_name":"post_object","_valid":1}
{"ID":43898,"key":"field_66201b0c5f917","label":"page link","name":"page_link","aria-label":"","prefix":"acf", "type":"page_link", "value":null, "menu_order":19,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"post_type":"","post_status":"","taxonomy":"","allow_archives":1,"multiple":0,"allow_null":0,"_name":"page_link","_valid":1}
{"ID":43899,"key":"field_66201b1a5f918","label":"relationship","name":"relationship","aria-label":"","prefix":"acf", "type":"relationship","value":null, "menu_order":20,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"post_type":"","post_status":"","taxonomy":"","filters":["search","post_type","taxonomy"],"return_format":"object","min":"","max":"","elements":"","bidirectional":0,"bidirectional_target":[],"_name":"relationship","_valid":1}
{"ID":43900,"key":"field_66201b275f919","label":"taxonomy","name":"taxonomy","aria-label":"","prefix":"acf", "type":"taxonomy", "value":null, "menu_order":21,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"taxonomy":"category","add_term":1,"save_terms":0,"load_terms":0,"return_format":"id","field_type":"checkbox","bidirectional":0,"multiple":0,"allow_null":0,"bidirectional_target":[],"_name":"taxonomy","_valid":1}
{"ID":43901,"key":"field_66201b335f91a","label":"user","name":"user","aria-label":"","prefix":"acf", "type":"user", "value":null, "menu_order":22,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"role":"","return_format":"array","multiple":0,"allow_null":0,"bidirectional":0,"bidirectional_target":[],"_name":"user","_valid":1}
{"ID":43902,"key":"field_66201b3f5f91b","label":"gmap","name":"gmap","aria-label":"","prefix":"acf", "type":"google_map", "value":null, "menu_order":23,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"center_lat":-37,"center_lng":144,"zoom":"","height":"","_name":"gmap","_valid":1}
{"ID":43903,"key":"field_66201b4c5f91c","label":"date picker","name":"date_picker","aria-label":"","prefix":"acf", "type":"date_picker", "value":null, "menu_order":24,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"display_format":"d\/m\/Y","return_format":"d\/m\/Y","first_day":1,"_name":"date_picker","_valid":1}
{"ID":43904,"key":"field_66201b565f91d","label":"date time picker","name":"date_time_picker","aria-label":"","prefix":"acf", "type":"date_picker", "value":null, "menu_order":25,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"display_format":"d\/m\/Y","return_format":"d\/m\/Y","first_day":1,"_name":"date_time_picker","_valid":1}
{"ID":43905,"key":"field_66201b5e5f91e","label":"time picker","name":"time_picker","aria-label":"","prefix":"acf", "type":"time_picker", "value":null, "menu_order":26,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"display_format":"g:i a","return_format":"g:i a","_name":"time_picker","_valid":1}
{"ID":43906,"key":"field_66201b685f91f","label":"color picker","name":"color_picker","aria-label":"","prefix":"acf", "type":"color_picker","value":null, "menu_order":27,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"default_value":"","enable_opacity":0,"return_format":"string","_name":"color_picker","_valid":1}
{"ID":43907,"key":"field_66201b745f920","label":"message","name":"","aria-label":"","prefix":"acf", "type":"message", "value":false,"menu_order":28,"instructions":"","required":0,"id":"","class":"","conditional_logic":0,"parent":43775,"wrapper":{"width":"","class":"read_only_cipf","id":""},"message":"message","new_lines":"wpautop","esc_html":0,"_name":"","_valid":1}
-> $field['disabled'] = 1;
27. [/] text class-acf-field-text.php* : <input type="text" id="acf-field_66200b6283912" name="acf[field_66200b6283912]">
28. [/] textarea class-acf-field-textarea.php* : <textarea id="acf-field_66200c4383914" name="acf[field_66200c4383914]" rows="8"></textarea>
14. [/] number class-acf-field-number.php* : <input type="number" id="acf-field_66200b7f83913" name="acf[field_66200b7f83913]" step="any">
7. [/] email class-acf-field-email.php* : <input type="email" id="acf-field_66200da983917" name="acf[field_66200da983917]">
31. [/] url class-acf-field-url.php* : <input type="url" id="acf-field_66200dbd83918" name="acf[field_66200dbd83918]">
18. [x] password (text) class-acf-field-password.php* : <input type="password" id="acf-field_66200dfb83919" name="acf[field_66200dfb83919]">
5. [/] date_picker class-acf-field-date_picker.php* : <input type="text" class="input hasDatepicker" value="" id="dp1713386193796">
6. [/] date_picker class-acf-field-date_time_picker.php* : <input type="text" class="input hasDatepicker" value="" id="dp1713386193797">
29. [/] time_picker class-acf-field-time_picker.php* : <input type="text" class="input hasDatepicker" value="" id="dp1713386193798">
23. [/] select class-acf-field-select.php* : <select id="acf-field_66201aad5f910" class="" name="acf[field_66201aad5f910]" data-ui="0" data-ajax="0" data-multiple="0" data-placeholder="Select" data-allow_null="0"></select>
-> has the option
3. [/] checkbox class-acf-field-checkbox.php* : <input type="checkbox" id="acf-field_66201ac05f911-one" name="acf[field_66201ac05f911][]" value="one">
20. [/] radio class-acf-field-radio.php* : <input type="radio" id="acf-field_66201ad25f912-one" name="acf[field_66201ad25f912]" value="one">
-> has elements
21. [/] range class-acf-field-range.php* : <input type="range" id="acf-field_66200d7583916" name="acf[field_66200d7583916]" value="0" min="0" max="100" step="1"><input type="number" id="acf-field_66200d7583916-alt" value="0" step="1" style="width: 3.9em;">
2. [x] button_group class-acf-field-button-group.php* : <input type="radio" name="acf[field_66201adb5f913]" value="one">
4. [x] color_picker class-acf-field-color_picker.php* : <button type="button" class="button wp-color-result et-wp-color-result-updated" aria-expanded="false" title="Select Color" data-legacy_title="Select" data-current="Current Color" style="height: 24px; margin: 0px 6px 6px 0px; padding: 0px 0px 0px 30px; font-size: 11px;"></button>
17. [x] page_link class-acf-field-page_link.php* : <select id="acf-field_66201b0c5f917" class="select2-hidden-accessible" name="acf[field_66201b0c5f917]" data-ui="1" data-multiple="0" data-placeholder="Select" data-allow_null="0" data-select2-id="acf-field_66201b0c5f917" tabindex="-1" aria-hidden="true" data-ajax="1"></select>
19. [x] post_object class-acf-field-post_object.php* : <select id="acf-field_66201b015f916" class="select2-hidden-accessible" name="acf[field_66201b015f916]" data-ui="1" data-multiple="0" data-placeholder="Select" data-allow_null="0" data-select2-id="acf-field_66201b015f916" tabindex="-1" aria-hidden="true" data-ajax="1"></select>
26. [x] taxonomy class-acf-field-taxonomy.php* : <input type="checkbox" name="acf[field_66201b275f919][]" value="1">
30. [x] true_false class-acf-field-true_false.php* : <input type="checkbox" id="acf-field_66201ae95f914" name="acf[field_66201ae95f914]" value="1" class="" autocomplete="off" checked="checked">
32. [x] user class-acf-field-user.php* : <select id="acf-field_66201b335f91a" class="select2-hidden-accessible" name="acf[field_66201b335f91a]" data-ui="1" data-multiple="0" data-placeholder="Select" data-allow_null="0" data-query-nonce="1340e351c6" data-select2-id="acf-field_66201b335f91a" tabindex="-1" aria-hidden="true" data-ajax="1"></select>
33. [x] wysiwyg class-acf-field-wysiwyg.php* : <textarea id="acf-editor-87" class="wp-editor-area" name="acf[field_66201a955f90e]" style="height:300px;"></textarea>
-> no need
13. [x] message class-acf-field-message.php* : /
1. [x] class-acf-field-accordion.php* : /
25. [x] class-acf-field-tab.php* : /
10. [x] class-acf-field-group.php* : /
8. [x] file class-acf-field-file.php* : /
9. [x] google_map class-acf-field-google-map.php* : /
11. [x] image class-acf-field-image.php* : /
12. [x] link class-acf-field-link.php* : /
15. [x] oembed class-acf-field-oembed.php* : /
22. [x] relationship class-acf-field-relationship.php* : /
*/
/*
* there is one action hook suitable to close the fieldset element :
* -> ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/advanced-custom-fields/includes/acf-field-functions.php
* line 807 : do_action( 'acf/render_field', $field );
*
* acf uses priority 9 for its 'acf/render_field' hook
* so we hook before and after
*
*
*
*/
function add_fieldset_start_to_acf_disabled_CIPF($field) {
Plgntls::debug_infos();
if (contains_class_disabled_CIPF($field)) {
echo "<fieldset disabled class='acf_disabled_fieldset_cipf' style='border:none; margin:0px; padding:0px;'>\n";
}
return $field;
}
function add_fieldset_end_to_acf_disabled_CIPF($field) {
Plgntls::debug_infos();
if (!contains_class_disabled_CIPF($field)) {
return;
}
echo "</fieldset>\n";
}
add_action('acf/render_field', 'add_fieldset_start_to_acf_disabled_CIPF', 8);
add_action('acf/render_field', 'add_fieldset_end_to_acf_disabled_CIPF', 10);
/*
* checks if the acf field wrapper contains the class 'read_only_cipf'
*
*/
function contains_class_disabled_CIPF($field) {
Plgntls::debug_infos();
$readonly_class = Cipf::ACF_READONLY_CLASS;
if (!isset($field['wrapper'])) {
error_log("the acf field should have property field['wrapper']: " . json_encode($field));
return false;
}
if (!isset($field['wrapper']['class'])) {
error_log("the acf field should have property field['wrapper']['class']: " . json_encode($field));
return false;
}
$class = $field['wrapper']['class'];
if (!str_contains($class, $readonly_class)) {
return false;
}
return true;
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,124 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
*
*
*/
function has_partner_post() {
Plgntls::debug_infos();
$current_user_id = get_current_user_id();
$args = array(
'post_type' => 'post',
'author' => $current_user_id,
'posts_per_page' => 1,
'post_status' => array('publish', 'draft'),
);
$post = get_posts($args);
if (empty($post)) {
return false;
}
else {
return reset($post);
}
}
/*
* to use is_user_logged_in at early init hook
* 1162 : wordpress_docker/volumes/wp_volume/wp-includes/pluggable.php
*
*/
function is_user_logged_in_CIPF() {
Plgntls::debug_infos(2);
if (function_exists('is_user_logged_in')) {
return is_user_logged_in();
}
else {
$user = wp_get_current_user();
return $user->exists();
}
Plgntls::debug_infos();
}
/*
* to use current_user_can at early init hook
* 877 : wordpress_docker/volumes/wp_volume/wp-includes/capabilities.php
*
*/
function current_user_can_CIPF($capability) {
Plgntls::debug_infos(2);
if (function_exists('current_user_can')) {
return current_user_can($capability);
}
else {
$user = wp_get_current_user();
return user_can($user, $capability);
}
Plgntls::debug_infos();
}
/*
* checks if current user is role
* works as soon as 'init' hook
*
* first hook to use is...() is parse_query
* -> https://developer.wordpress.org/apis/hooks/action-reference/
* - after 'init', before 'wp'
* but 'init' already has set user, so we can recreate the functions
*
*/
function is_role_CIPF($role) {
Plgntls::debug_infos();
if (!is_user_logged_in_CIPF()) {
return false;
}
if (!current_user_can_CIPF($role)) {
return false;
}
return true;
}
function is_admin_CIPF() {
Plgntls::debug_infos();
$role_admin = Cipf::ROLE_ADMIN;
return is_role_CIPF($role_admin);
}
function is_fipf_CIPF() {
Plgntls::debug_infos();
$role_fipf = Cipf::ROLE_FIPF;
return is_role_CIPF($role_fipf);
}
function is_partner_CIPF() {
Plgntls::debug_infos();
$role_partner = Cipf::ROLE_PARTNER;
return is_role_CIPF($role_partner);
}
function is_prof_CIPF() {
Plgntls::debug_infos();
$role_prof = Cipf::ROLE_PROF;
return is_role_CIPF($role_prof);
}
?>

View File

@@ -92,6 +92,17 @@ function display_states_css_CIPF($user_id = null) {
$css_for_states[] = 'css/display_states/type_virement.css'; $css_for_states[] = 'css/display_states/type_virement.css';
} }
/*
* prof change carte
*
*/
if (is_acf_prof_change_card_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/carte_changer.css';
}
else {
$css_for_states[] = 'css/display_states/carte_payer.css';
}
/* /*
* page partenaire * page partenaire
* - 'Publiee' * - 'Publiee'
@@ -112,4 +123,6 @@ function display_states_css_CIPF($user_id = null) {
?> ?>

View File

@@ -19,7 +19,6 @@ function redirect_home_CIPF(){
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes // Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers(); nocache_headers();
wp_redirect(home_url(), 301); wp_redirect(home_url(), 301);
exit; exit;
} }
@@ -31,13 +30,12 @@ function redirect_home_CIPF(){
* redirects new prof to commande * redirects new prof to commande
* *
*/ */
function redirect_command_CIPF(){ function redirect_prof_command_CIPF(){
Plgntls::debug_infos(); Plgntls::debug_infos();
$slug_command_card = Cipf::SLUG_COMMAND_CARD; $slug_command_card = Cipf::SLUG_COMMAND_CARD;
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes // Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers(); nocache_headers();
wp_redirect(home_url($slug_command_card), 301); wp_redirect(home_url($slug_command_card), 301);
exit; exit;
} }
@@ -60,8 +58,6 @@ function redirection_profil_CIPF(){
$partner_page_creation = home_url($slug_partner_create_page); $partner_page_creation = home_url($slug_partner_create_page);
$current_user_id = get_current_user_id(); $current_user_id = get_current_user_id();
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers();
if (!is_user_logged_in()) { if (!is_user_logged_in()) {
redirect_home_CIPF(); redirect_home_CIPF();
@@ -73,6 +69,8 @@ function redirection_profil_CIPF(){
*/ */
if (current_user_can($role_prof)) { if (current_user_can($role_prof)) {
$user_page = get_author_posts_url($current_user_id); $user_page = get_author_posts_url($current_user_id);
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers();
wp_redirect($user_page, 301); wp_redirect($user_page, 301);
exit; exit;
} }
@@ -82,25 +80,15 @@ function redirection_profil_CIPF(){
* *
*/ */
if (current_user_can($role_partner)) { if (current_user_can($role_partner)) {
$args = array( $partner_post = has_partner_post();
'post_type' => 'post', if (false === $partner_post) {
'author' => $current_user_id,
'posts_per_page' => 1,
);
$posts = get_posts($args);
/*
* if post exists, redirects to it
* otherwise redirects to post creation
*
*/
if (empty($posts)) {
$redirect_url = $partner_page_creation; $redirect_url = $partner_page_creation;
} }
else { else {
$query = reset($posts); $redirect_url = get_post_url_CIPF($partner_post->ID);
$redirect_url = get_permalink($query->ID);
} }
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers();
wp_redirect($redirect_url, 301); wp_redirect($redirect_url, 301);
exit; exit;
} }
@@ -111,6 +99,28 @@ function redirection_profil_CIPF(){
/*
* get the url from a post_id
* dont use permalink since it returns an url with post_id in case post is draft :
* ex: https://site.com/?p=40772
*
*/
function get_post_url_CIPF($post_id = null) {
Plgntls::debug_infos(2);
if (empty($post_id)) {
return;
}
$post = get_post($post_id);
if (empty($post)) {
return;
}
$post_url = home_url($post->post_name);
return $post_url;
}
/* /*
* redirects when trying to access the page with SLUG_PAGE_REDIRECTION * redirects when trying to access the page with SLUG_PAGE_REDIRECTION
@@ -149,6 +159,30 @@ add_action('template_redirect', 'redirection_page_CIPF');
/*
* checks if partner current user is partner
* works as soon as 'init' hook
*
* first hook to use is...() is parse_query
* -> https://developer.wordpress.org/apis/hooks/action-reference/
* - after 'init', before 'wp'
* but 'init' already has set user, so we can recreate the functions
*
*/
//function redirects_home_if_not_partner() {
// Plgntls::debug_infos();
// $role_partner = Cipf::ROLE_PARTNER;
//
// if (!is_user_logged_in_CIPF()) {
// redirect_home_CIPF();
// }
// if (!current_user_can_CIPF($role_partner)) {
// redirect_home_CIPF();
// }
//}
?> ?>

View File

@@ -35,11 +35,14 @@ function add_plugin_content_CIPF() {
* options * options
* *
*/ */
//delete_option($option_paypal_object['_name']);
$option_paypal = Plgntls::get_option_safe($option_paypal_object, true); $option_paypal = Plgntls::get_option_safe($option_paypal_object, true);
//delete_option($option_payment_object['_name']);
$option_payment = Plgntls::get_option_safe($option_payment_object, true); $option_payment = Plgntls::get_option_safe($option_payment_object, true);
//delete_option($option_emails_object['_name']); //delete_option($option_emails_object['_name']);
$option_emails = Plgntls::get_option_safe($option_emails_object, true); $option_emails = Plgntls::get_option_safe($option_emails_object, true);
Plgntls::add_to_front(array('css/menu/menu.css'));
ob_start(); ob_start();
include(Plgntls::root_path() . '/html/menu/cipf_menu.html'); include(Plgntls::root_path() . '/html/menu/cipf_menu.html');
$html = ob_get_clean(); $html = ob_get_clean();
@@ -96,50 +99,46 @@ function update_payment_messages_option_CIPF($request, $option_name, $option_dat
function update_paypal_credentials_CIPF($request, $option_name, $option_data, $option_default) { function update_paypal_credentials_CIPF($request, $option_name, $option_data, $option_default) {
Plgntls::debug_infos(); Plgntls::debug_infos();
if (!isset(
$request['sandbox_or_live'],
$request['live_client_id'],
$request['live_client_secret'],
$request['sandbox_client_id'],
$request['sandbox_client_secret'],
)) {
return;
}
/*
* force price 1 cent ?
*
*/
$force_1_cent = false;
if (isset($request['force_1_cent'])) {
$force_1_cent = true;
}
/* /*
* is sandbox or live ? * is sandbox or live ?
* *
*/ */
$is_sandbox = false; $is_sandbox = false;
if (!isset($request['sandbox_or_live'])) {
return;
}
if ($request['sandbox_or_live'] === 'sandbox') { if ($request['sandbox_or_live'] === 'sandbox') {
$is_sandbox = true; $is_sandbox = true;
} }
else if ($request['sandbox_or_live'] === 'live') { else if ($request['sandbox_or_live'] === 'live') {
$is_sandbox = false; $is_sandbox = false;
} }
else {
return;
}
/* /*
* client id * ids
* *
*/ */
$client_id = ''; $live_client_id = $request['live_client_id'];
if (!isset($request['client_id'])) { $live_client_secret = $request['live_client_secret'];
return; $sandbox_client_id = $request['sandbox_client_id'];
} $sandbox_client_secret = $request['sandbox_client_secret'];
else {
$client_id = $request['client_id'];
}
/*
* client secret
*
*/
$client_secret = '';
if (!isset($request['client_secret'])) {
return;
}
else {
$client_secret = $request['client_secret'];
}
/* /*
@@ -148,9 +147,12 @@ function update_paypal_credentials_CIPF($request, $option_name, $option_data, $o
set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret); set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret);
*/ */
$data = array( $data = array(
'force_1_cent' => $force_1_cent,
'is_sandbox' => $is_sandbox, 'is_sandbox' => $is_sandbox,
'client_id' => $client_id, 'live_client_id' => $live_client_id,
'client_secret' => $client_secret, 'live_client_secret' => $live_client_secret,
'sandbox_client_id' => $sandbox_client_id,
'sandbox_client_secret' => $sandbox_client_secret,
); );
Plgntls::update_option_safe($option_name, $data); Plgntls::update_option_safe($option_name, $data);
} }
@@ -167,71 +169,86 @@ function update_paypal_credentials_CIPF($request, $option_name, $option_data, $o
function update_emails_settings_option_CIPF($request, $option_name, $option_data, $option_default) { function update_emails_settings_option_CIPF($request, $option_name, $option_data, $option_default) {
Plgntls::debug_infos(); Plgntls::debug_infos();
//error_log("---"); /*
//error_log("request: " . json_encode($request)); * first check if saved option has the same data as default option
//error_log("option_data bedore: " . json_encode($option_data)); *
foreach ($option_data as $email_type => $email_options) { */
//error_log("email_type: " . $email_type); $new_option = update_option_with_default_CIPF($option_data, $option_default);
// if ($email_type === '_name') {
// continue;
// }
// $ret_email = update_email_by_type_CIPF($email_type, $email_options, $request);
// if ($ret_email !== false) {
// $option_data[$email_type] = $ret_email;
// }
$option_data[$email_type] = update_email_by_type_CIPF($email_type, $email_options, $request);
}
//error_log("option_data after : " . json_encode($option_data));
Plgntls::update_option_safe($option_name, $option_data); /*
* then update the option with the request
*
*/
foreach ($new_option as $email_type => $email_options) {
$new_option[$email_type] = update_email_type_with_request_CIPF($email_type, $email_options, $request);
} }
Plgntls::update_option_safe($option_name, $new_option);
}
/* /*
* utility function to update the emails * utility
* *
*/ */
function update_email_by_type_CIPF($email_type, $email_options, $request) { function update_option_with_default_CIPF($option_data, $option_default) {
Plgntls::debug_infos(); Plgntls::debug_infos();
//error_log("email type: " . $email_type);
//if ($email_type === '_name') {
// return false;
//}
/* $new_option_values = array();
* set notification/confirmation_send to false by default, foreach ($option_default as $email_type => $email_default_options) {
* because the request only contains the value 'on' if checked, nothing for false if (!isset($option_data[$email_type])) {
* $new_option_values[$email_type] = $email_default_options;
*/
$email_options['notification_send'] = false;
$email_options['confirmation_send'] = false;
/*
* loop through all options to update them
*
*/
foreach ($email_options as $option => $value) {
if (!isset($request[$email_type.'_'.$option])) {
continue;
}
$new_value = $request[$email_type.'_'.$option];
if ($new_value === $value) {
continue;
}
if ($option === 'notification_send' || $option === 'confirmation_send') {
$email_options[$option] = true;
} }
else { else {
// error_log("option: " . $option); $new_email_options = update_email_type_with_default_CIPF($option_data[$email_type], $email_default_options);
// error_log("- previous value: " . $value); $new_option_values[$email_type] = $new_email_options;
// error_log("- newvalue : " . $new_value);
$email_options[$option] = $new_value;
} }
} }
return $new_option_values;
}
function update_email_type_with_default_CIPF($email_options, $email_default_options) {
Plgntls::debug_infos();
$new_email_type = array();
foreach ($email_default_options as $default_key => $default_value) {
if (!isset($email_options[$default_key])) {
$new_email_type[$default_key] = $default_value;
}
else {
$new_email_type[$default_key] = $email_options[$default_key];
}
}
return $new_email_type;
}
function update_email_type_with_request_CIPF($email_type, $email_options, $request) {
Plgntls::debug_infos();
foreach ($email_options as $email_key => $email_value) {
/*
* special update for notification/confirmation_send
* default them to false, since they will only be in request if they value 'on'
*
*/
if (in_array($email_key, array('notification_send', 'confirmation_send'))) {
$email_options[$email_key] = 'off';
}
//error_log("email_options: " . json_encode($email_options)); /*
* search in request needs the prefix
*
*/
$request_name = $email_type.'_'.$email_key;
if (isset($request[$request_name])) {
$email_options[$email_key] = $request[$request_name];
}
}
return $email_options; return $email_options;
} }
@@ -239,4 +256,6 @@ function update_email_by_type_CIPF($email_type, $email_options, $request) {
?> ?>

View File

@@ -0,0 +1,30 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* load css for user profil admin page
* if fipf is weing user profil in admin, hide some fields
* 278 : ../../../wordpress_docker/volumes/wp_volume/wp-admin/user-edit.php
*
*/
function admin_partner_page_css_CIPF() {
Plgntls::debug_infos();
Plgntls::add_to_front(array('css/acf_fields.css'));
}
add_action('admin_enqueue_scripts', 'admin_partner_page_css_CIPF');
?>

View File

@@ -11,19 +11,31 @@ if (!defined('ABSPATH')) {
/* /*
* load css for user profil admin page
* if fipf is weing user profil in admin, hide some fields
* 278 : ../../../wordpress_docker/volumes/wp_volume/wp-admin/user-edit.php * 278 : ../../../wordpress_docker/volumes/wp_volume/wp-admin/user-edit.php
* *
function admin_user_profil_css_CIPF($user_id) {
*/ */
function admin_user_profil_css_CIPF() { function admin_user_profil_css_CIPF() {
Plgntls::debug_infos(); Plgntls::debug_infos();
$role_fipf = Cipf::ROLE_FIPF; $role_fipf = Cipf::ROLE_FIPF;
/*
* for everyone viewing user profil
*
*/
Plgntls::add_to_front(array('css/user_profile.css', 'css/acf_fields.css'));
if (!current_user_can($role_fipf)) { if (!current_user_can($role_fipf)) {
return; return;
} }
/*
* for fipf viewing user profil
*
*/
Plgntls::add_to_front(array('css/fipf_user_profile.css')); Plgntls::add_to_front(array('css/fipf_user_profile.css'));
} }
add_action('user_edit_form_tag', 'admin_user_profil_css_CIPF'); add_action('user_edit_form_tag', 'admin_user_profil_css_CIPF');

View File

@@ -1,204 +0,0 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* events and emails :
*
* 1. [/] profs : payment_success : paypal payment success
* 2. [/] profs : payment_echec : paypal payment echec
* 3. [/] profs : transfert_success : validation transfert prof reussi, send email
* 4. [ ] partners : offer_expired : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
* 5. [ ] partners : offer_will_expire : la gestion des offres à échéance
* 6. [ ] prof : account_deleted : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte
* 7. [ ] prof : account_will_expire : faire rappels emails avant expiration
* 8. [ ] prof : account_expired : desactiver carte expiree
*
*/
function prepare_emails_CIPF($email_name, $user_id) {
Plgntls::debug_infos();
$emails_option_object = Cipf::OPTION_EMAILS;
if (!isset($emails_option_object['_default'][$email_name])) {
return false;
}
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$user = get_user_by('id', $user_id);
$user_email = $user->user_email;
$headers = array('Content-Type: text/html; charset=UTF-8');
$emails_option = Plgntls::get_option_safe($emails_option_object);
if (!$emails_option) {
return false;
}
if (!isset($emails_option[$email_name])) {
return false;
}
$email = $emails_option[$email_name];
$emails = array();
if ($email['notification_send']) {
$tmp_email = array();
$tmp_email['to'] = $email['notification_to'];
$tmp_email['subject'] = $email['notification_subject'];
$tmp_email['message'] = $email['notification_message'];
$tmp_email['headers'] = $headers;
$emails[] = $tmp_email;
}
if ($email['confirmation_send']) {
$tmp_email = array();
$tmp_email['to'] = $user_email;
$tmp_email['subject'] = $email['confirmation_subject'];
$tmp_email['message'] = $email['confirmation_message'];
$tmp_email['headers'] = $headers;
$emails[] = $tmp_email;
}
return $emails;
}
function send_emails_CIPF($email_name, $user_id = null) {
Plgntls::debug_infos();
$emails = prepare_emails_CIPF($email_name, $user_id);
if (false === $emails) {
error_log('Email preparing failed!: ' . json_encode($emails));
return;
}
foreach ($emails as $email) {
$sent = wp_mail($email['to'], $email['subject'], $email['message'], $email['headers']);
}
if (!$sent) {
error_log('Email sending failed!: ' . json_encode($email));
}
}
//function email_payment_success_CIPF($user_id = null) {
// Plgntls::debug_infos();
//error_log("email payment success: " . json_encode($email_payment_success));
//
// send_email_CIPF($email_payment_success, $user_id);
// $user = get_user_by('id', $user_id);
//// $to = $user->user_email;
// $to = '$$__admin_email__$$';
// $subject = 'My Custom Email Subject';
// $message = 'Hello, This is a test email sent from my WordPress plugin!';
// $headers = array('Content-Type: text/html; charset=UTF-8');
//
//
// // Check if the email was sent successfully
//}
/*
'payment_success'=>[
'notification_send'=>true,
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"paiement réussi",
'notification_message'=>"par ici la monnaie",
'confirmation_send'=>true,
'confirmation_subject'=>"paiement réussi",
'confirmation_mesage'=>"donne l'argent",
],
// 2. profs : email : payment_failure : validation payment prof echec, send email
'payment_echec'=>[
'notification_send'=>true,
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"",
'notification_message'=>"",
'confirmation_send'=>true,
'confirmation_subject'=>"",
'confirmation_mesage'=>"",
],
// 3. profs : email : transfert_success : validation transfert prof reussi, send email
'transfert_success'=>[
'notification_send'=>true,
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"",
'notification_message'=>"",
'confirmation_send'=>true,
'confirmation_subject'=>"",
'confirmation_mesage'=>"",
],
// 4. profs : email : transfert_failures : validation transfert prof echec, send email
'transfert_echec'=>[
'notification_send'=>true,
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"",
'notification_message'=>"",
'confirmation_send'=>true,
'confirmation_subject'=>"",
'confirmation_mesage'=>"",
],
// 5. partners : email : offer_expired : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
'offer_expired'=>[
'notification_send'=>true,
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"",
'notification_message'=>"",
'confirmation_send'=>true,
'confirmation_subject'=>"",
'confirmation_mesage'=>"",
],
// 6. partners : email : offer_will_expire : la gestion des offres à échéance
'offer_will_expire'=>[
'notification_send'=>true,
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"",
'notification_message'=>"",
'confirmation_send'=>true,
'confirmation_subject'=>"",
'confirmation_mesage'=>"",
],
// 7. payments : email : account_deleted : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte
'account_deleted'=>[
'notification_send'=>true,
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"",
'notification_message'=>"",
'confirmation_send'=>true,
'confirmation_subject'=>"",
'confirmation_mesage'=>"",
],
// 8. payments : email : account_will_expire : faire rappels emails avant expiration
'eccount_will_expire'=>[
'notification_send'=>true,
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"",
'notification_message'=>"",
'confirmation_send'=>true,
'confirmation_subject'=>"",
'confirmation_mesage'=>"",
],
// 9. payments : email : account_expired : desactiver carte expiree
'account_expired'=>[
'notification_send'=>true,
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"",
'notification_message'=>"",
'confirmation_send'=>true,
'confirmation_subject'=>"",
'confirmation_mesage'=>"",
],
*/
?>

View File

@@ -1,44 +0,0 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* menu deconnexion
* 1. il faut creer un menu personalisé dans Apparence > Menus
* 2. dans le code ci-dessous, changer la valeur de $menu_title pour correspondre au titre du menu
* 3. et si besoin changer la valeur de $menu_redirect pour choisir la page de redirection :
* - si laissée vide, la redirection se fera sur la page de connexion de wordpress
* - avec $current_url la redirection se fera sur la page actuelle
* - avec $base_url on redirige vers la page d'accueil du site (l'url sans chemin supplementaire)
* cette variable $base_url peut etre utilisee pour construire une autre url :
* - $menu_redirect = $base_url -> https://le_site_actuel.com/
* - $menu_redirect = $base_url . 'contact' -> https://le_site_actuel.com/contact
* - $menu_redirect = $current_url -> https://le_site_actuel.com/la_meme_page
* - $menu_redirect = 'www.un_autre_site.net/contact' -> https://www.un_autre_site.net/contact
*/
function change_menu_logout($items){
Plgntls::debug_infos();
$menu_title = 'special logout';
// quelques urls utiles :
$base_url = home_url();
$current_url = home_url( $_SERVER['REQUEST_URI'] );
$menu_redirect = '';
foreach($items as $item){
if( $item->title === $menu_title){
$item->url = wp_nonce_url( wp_logout_url( $menu_redirect ), 'log-out' );
}
}
return $items;
}
add_filter('wp_nav_menu_objects', 'change_menu_logout');
?>

View File

@@ -9,6 +9,50 @@ if (!defined('ABSPATH')) {
/*
* the earliest hook to use is_..() is parse_query
* -> https://developer.wordpress.org/apis/hooks/action-reference/
*
*/
function is_partner_form_creation_page_CIPF() {
Plgntls::debug_infos();
$slug_partner_create_page = Cipf::SLUG_PARTNER_CREATE_PAGE;
/*
* only for the partner form creation page
* first available hook is parse_query
* -> https://developer.wordpress.org/apis/hooks/action-reference/
* 584 : wordpress_docker/volumes/wp_volume/wp-includes/query.php
* 4427 : wordpress_docker/volumes/wp_volume/wp-includes/class-wp-query.php
*
*/
if (!is_page($slug_partner_create_page)) {
return false;
}
return true;
}
/*
* action to be done at the init state of the page
*
*/
function partner_form_creation_page_init_CIPF() {
Plgntls::debug_infos(2);
if (!is_partner_CIPF()) {
return;
}
Plgntls::debug_infos();
// https://developer.wordpress.org/reference/functions/get_query_var/#more-information
global $wp;
$wp->add_query_var('pid');
}
add_action('init','partner_form_creation_page_init_CIPF');
@@ -18,33 +62,39 @@ if (!defined('ABSPATH')) {
*/ */
function partner_form_creation_page_CIPF() { function partner_form_creation_page_CIPF() {
Plgntls::debug_infos(2); Plgntls::debug_infos(2);
$role_partner = Cipf::ROLE_PARTNER;
$slug_partner_create_page = Cipf::SLUG_PARTNER_CREATE_PAGE;
/* if (!is_partner_CIPF()) {
* only for the partner form creation page return;
* }
*/ if (!is_partner_form_creation_page_CIPF()) {
if (!is_page($slug_partner_create_page)) {
return; return;
} }
Plgntls::debug_infos(); Plgntls::debug_infos();
/* /*
* redirect anyone that is not a partner * -> if partner don't have page yet && this is not edit page -> let him access it
* if partner dont' have page yet && this is edit page -> redirect him
* if partner have page && this is not edit page -> redirect him
* -> if partner have page && this is edit page && this edit its page -> let him access it
* if partner have page && this is edit page && this dont edit its page -> redirect him
*
* to check for pid, add 'pid' to query vars in 'init' hook
* -> https://developer.wordpress.org/reference/functions/get_query_var/#more-information
* *
*/ */
if (!is_user_logged_in()) { $is_edit_id = get_query_var('pid', false);
redirect_home_CIPF(); $partner_post = has_partner_post();
if (false === $partner_post) {
if (false === $is_edit_id) {
return;
}
}
else {
$post_id = $partner_post->ID;
if ($is_edit_id == $post_id) {
return;
} }
if (!current_user_can($role_partner)) {
redirect_home_CIPF();
} }
/*
* if a partner already has a page, redirect it
*
*/
redirection_profil_CIPF(); redirection_profil_CIPF();
} }
add_action('template_redirect', 'partner_form_creation_page_CIPF'); add_action('template_redirect', 'partner_form_creation_page_CIPF');
@@ -56,11 +106,4 @@ add_action('template_redirect', 'partner_form_creation_page_CIPF');
?> ?>

View File

@@ -0,0 +1,79 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
function handle_partner_offers_expire_CIPF($page_id) {
Plgntls::debug_infos();
//$post = get_post($page_id);
$i = 1;
while ($i <= 3) {
$offer_duration = get_field_init_CIPF('duree_offre_'.$i, $page_id);
if ($offer_duration !== 'Temporaire') {
++$i;
continue;
}
$offer_output = get_field_init_CIPF('afficher_offre_'.$i, $page_id);
if ($offer_output === 'Masquer') {
++$i;
continue;
}
//$offer_title = get_field_init_CIPF('offre_'.$i.'_titre', $page_id);
//error_log("- post: ".$post->post_title." - titre offre: ".$offer_title);
handle_offer_will_expire_CIPF($i, $page_id);
handle_offer_is_expired_CIPF($i, $page_id);
++$i;
}
}
function handle_offer_will_expire_CIPF($i, $page_id) {
Plgntls::debug_infos();
if (is_offer_date_exceeded_CIPF($i, $page_id)) {
return;
}
$date_limit = get_offer_date_expiration_CIPF($i, $page_id);
if (false === $date_limit) {
return;
}
$post = get_post($page_id);
$user_id = $post->post_author;
handle_send_reminders_CIPF($page_id, $user_id, $date_limit, 'offer_expiration_'.$i, 'offer_will_expire');
}
function handle_offer_is_expired_CIPF($i, $page_id) {
Plgntls::debug_infos();
if (!is_offer_date_exceeded_CIPF($i, $page_id)) {
return;
}
update_field('afficher_offre_'.$i, 'Masquer', $page_id);
$post = get_post($page_id);
$user_id = $post->post_author;
send_emails_CIPF('offer_expired', $user_id);
}
?>

View File

@@ -10,30 +10,30 @@ if (!defined('ABSPATH')) {
/* /*
* utility function that checks if the current page is owned by the logged in partner * checks if the current page is owned by the logged in partner
* dont work in 'init' hook
* works in 'wp' hook
* *
*/ */
function is_own_partner() { function is_own_partner_CIPF() {
Plgntls::debug_infos(2); Plgntls::debug_infos(2);
$role_partner = Cipf::ROLE_PARTNER; $role_partner = Cipf::ROLE_PARTNER;
if (!is_partner_CIPF()) {
return false;
}
if (!is_single()) { if (!is_single()) {
return false; return false;
} }
if (!is_user_logged_in()) { Plgntls::debug_infos();
return false;
}
if (!current_user_can($role_partner)) {
return false;
}
global $post; global $post;
if (is_null($post)) { if (is_null($post)) {
return false; return false;
} }
Plgntls::debug_infos(); $current_post_author_id = (int)($post->post_author);
$current_post_author = (int)($post->post_author);
$current_user_id = (int)get_current_user_id(); $current_user_id = (int)get_current_user_id();
if ($current_user_id !== $current_post_author) { if ($current_user_id !== $current_post_author_id) {
return false; return false;
} }
@@ -42,6 +42,30 @@ function is_own_partner() {
/*
* action to be done at the init state of the page
*
*/
function partner_page_init_CIPF() {
Plgntls::debug_infos(2);
if (!is_partner_CIPF()) {
return;
}
Plgntls::debug_infos();
// https://developer.wordpress.org/reference/functions/get_query_var/#more-information
global $wp;
$wp->add_query_var('action');
}
add_action('init','partner_page_init_CIPF');
/* /*
* upload scripts and styles on partner page * upload scripts and styles on partner page
* *
@@ -67,7 +91,7 @@ function partner_page_scripts_CIPF() {
* then check if is partner own page * then check if is partner own page
* *
*/ */
if (!is_own_partner()) { if (!is_own_partner_CIPF()) {
return; return;
} }
@@ -82,28 +106,85 @@ add_action('wp_enqueue_scripts', 'partner_page_scripts_CIPF', 11);
/*
* prevent access to the post if in draft
*
*/
function restrict_partner_page_draft_CIPF() {
Plgntls::debug_infos(2);
/*
* the restrictions only concerns logged in users
* and on post (partner pages)
* -> own partners are not restricted
* -> also not admin and fipf
*
*/
if (!is_single()) {
return;
}
if (!is_user_logged_in()) {
return;
}
if (is_fipf_CIPF()) {
return;
}
if (is_admin_CIPF()) {
return;
}
if (is_own_partner_CIPF()) {
return;
}
Plgntls::debug_infos();
/*
* get the post id and object
*
*/
$post_id = get_the_ID();
$current_post = get_post($post_id);
if (is_null($current_post)) {
return;
}
/*
* if post is draft, nobody should see it,
* except own partner (but they are already out this function)
*
*/
if ($current_post->post_status === 'draft') {
redirect_home_CIPF();
}
}
add_action('template_redirect', 'restrict_partner_page_draft_CIPF');
/* /*
* listen to the front button to toggle page publish/draft * listen to the front button to toggle page publish/draft
* *
*/ */
function toggle_partner_page_CIPF() { function toggle_partner_page_CIPF() {
Plgntls::debug_infos(); Plgntls::debug_infos(2);
$toggle_partner_page = Cipf::QUERY_TOGGLE_PARTNER_PAGE; $toggle_partner_page = Cipf::QUERY_TOGGLE_PARTNER_PAGE;
/* /*
* check if : * check if :
* - is own partner * - is own partner
* - has query action * - has query action
* to check for 'action' query, add 'action' to query vars in 'init' hook
* -> https://developer.wordpress.org/reference/functions/get_query_var/#more-information
* *
*/ */
if (!is_own_partner()) { if (!is_own_partner_CIPF()) {
return; return;
} }
Plgntls::debug_infos(); Plgntls::debug_infos();
if (!isset($_GET['action'])) { $is_action_toggle = get_query_var('action', false);
return; if ($is_action_toggle !== $toggle_partner_page) {
}
if ($_GET['action'] !== $toggle_partner_page) {
return; return;
} }
@@ -141,13 +222,52 @@ function toggle_partner_page_CIPF() {
* *
*/ */
$url = remove_query_arg('action'); $url = remove_query_arg('action');
error_log("url: " . $url);
wp_safe_redirect($url); wp_safe_redirect($url);
exit; exit;
} }
add_action('template_redirect', 'toggle_partner_page_CIPF'); add_action('template_redirect', 'toggle_partner_page_CIPF', 5);
/*
* if url uses post id, ex: /?p=40772
* make redirects to its post_name version, ex: /la-fipf
*
*/
function partner_page_check_url_CIPF() {
Plgntls::debug_infos(2);
if (!is_own_partner_CIPF()) {
return;
}
Plgntls::debug_infos();
/*
* get the post name
*
*/
$post_id = get_the_ID();
$current_post = get_post($post_id);
if (is_null($current_post)) {
return;
}
/*
*
*
*/
$current_slug = trim($_SERVER['REQUEST_URI'], '/');
$slug = trim($current_post->post_name, '/');
if ($slug !== $current_slug) {
wp_safe_redirect(home_url($slug));
exit;
}
}
add_action('template_redirect', 'partner_page_check_url_CIPF', 9);
@@ -161,7 +281,7 @@ function page_partner_check_CIPF() {
Plgntls::debug_infos(2); Plgntls::debug_infos(2);
// is partner own page // is partner own page
if (!is_own_partner()) { if (!is_own_partner_CIPF()) {
return; return;
} }
Plgntls::debug_infos(); Plgntls::debug_infos();

View File

@@ -10,6 +10,27 @@ if (!defined('ABSPATH')) {
/*
* action to be done at the init state of the page
*
*/
function prof_payment_page_init_CIPF() {
Plgntls::debug_infos(2);
if (!is_prof_CIPF()) {
return;
}
Plgntls::debug_infos();
// https://developer.wordpress.org/reference/functions/get_query_var/#more-information
global $wp;
$wp->add_query_var('prof_card_change');
}
add_action('init','prof_payment_page_init_CIPF');
/* /*
@@ -29,7 +50,8 @@ function payment_page_checks_CIPF() {
// get the user id // get the user id
$user_id = get_current_user_id(); $user_id = get_current_user_id();
// do checks here // also reset change card for 5€
reset_acf_prof_change_card_CIPF();
} }
add_action('wp', 'payment_page_checks_CIPF'); add_action('wp', 'payment_page_checks_CIPF');
@@ -37,6 +59,45 @@ add_action('wp', 'payment_page_checks_CIPF');
/*
* check on fabrication page to check card change
*
*/
function fabrication_page_checks_CIPF() {
Plgntls::debug_infos(2);
$slug_paypal_fabrication = Cipf::SLUG_PAYPAL_FABRICATION;
// check the slug
if (!is_page($slug_paypal_fabrication)) {
return;
}
Plgntls::debug_infos();
// get the user id
$user_id = get_current_user_id();
/*
* check for query card change
* and modify acf field accordingly
*
*/
$is_card_change = get_query_var('prof_card_change', false);
if ($is_card_change == true) {
set_acf_prof_change_card_CIPF();
}
else {
reset_acf_prof_change_card_CIPF();
}
}
add_action('wp', 'fabrication_page_checks_CIPF');
/* /*
* only profs can access this page * only profs can access this page
* *

View File

@@ -34,8 +34,9 @@ function handle_orders_request_CIPF($request_data) {
*/ */
try { try {
$can_pay = check_can_pay_CIPF(); $can_pay = check_can_pay_CIPF();
if (is_wp_error($can_pay)) if (is_wp_error($can_pay)) {
throw new HttpException('not allowed to pay : ' . $can_pay->get_error_message(), 403); throw new HttpException('not allowed to pay : ' . $can_pay->get_error_message(), 403);
}
$order_response = create_order_CIPF(); $order_response = create_order_CIPF();
$json_response = $order_response['json_response']; $json_response = $order_response['json_response'];
@@ -92,14 +93,9 @@ function handle_orders_request_CIPF($request_data) {
function create_order_CIPF() { function create_order_CIPF() {
Plgntls::debug_infos(); Plgntls::debug_infos();
$paypal_api_base_url = get_paypal_api_base_url_CIPF(); $paypal_api_base_url = get_paypal_api_base_url_CIPF();
$acf_card_price_total = Cipf::ACF_CARD_PRICE_TOTAL;
$access_token = generate_access_token_CIPF(); $access_token = generate_access_token_CIPF();
$price = get_paypal_price_CIPF();
$user_id = get_current_user_id();
$acf_id = 'user_' . $user_id;
$price = get_field($acf_card_price_total['_name'], $acf_id);
// $price = 0.01;
$url = $paypal_api_base_url . '/v2/checkout/orders'; $url = $paypal_api_base_url . '/v2/checkout/orders';
$payload = array( $payload = array(

View File

@@ -18,31 +18,6 @@ function handle_orders_capture_request_CIPF($request) {
/* /*
* ask paypal about the finished order
*
*/
try {
$response_json = capture_order_cipf($order_id);
$http_status_code = $response_json['http_status_code'];
$json_response = $response_json['json_response'];
}
catch (HttpException $error) {
$status_code = $error->getStatusCode();
$message = 'Failed to capture order in server :' . $error->getMessage();
return new WP_REST_Response($message, $status_code);
}
catch (Exception $error) {
$message = 'Failed to capture order in server : ' . $error->getMessage();
return new WP_REST_Response($message, 500);
}
/*
* update the client situation
* and return the response of paypal
*
* capture status : https://developer.paypal.com/docs/api/orders/v2/#definition-order_status * capture status : https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
* - COMPLETED * - COMPLETED
* - DECLINED * - DECLINED
@@ -53,17 +28,23 @@ function handle_orders_capture_request_CIPF($request) {
* *
*/ */
try { try {
update_user_post_capture_CIPF($json_response, 'end'); $response_json = capture_order_CIPF($order_id);
$http_status_code = $response_json['http_status_code'];
$json_response = $response_json['json_response'];
update_user_post_capture_CIPF($json_response);
return new WP_REST_Response($json_response, $http_status_code); return new WP_REST_Response($json_response, $http_status_code);
} }
catch (HttpException $error) { catch (HttpException $error) {
$status_code = $error->getStatusCode(); $status_code = $error->getStatusCode();
$message = array('ERROR_TREATMENT'=>true, 'message'=>'Failed to handle order after capture in server: ' . $error->getMessage()); $message = array('ERROR_TREATMENT'=>true, 'message'=>'Failed to handle order after capture in server: ' . $error->getMessage());
send_emails_CIPF('payment_problem');
return new WP_REST_Response($message, $status_code); return new WP_REST_Response($message, $status_code);
} }
catch (Exception $error) { catch (Exception $error) {
$message = array('ERROR_TREATMENT'=>true, 'message'=>'Failed to handle order after capture in server: ' . $error->getMessage()); $message = array('ERROR_TREATMENT'=>true, 'message'=>'Failed to handle order after capture in server: ' . $error->getMessage());
send_emails_CIPF('payment_problem');
return new WP_REST_Response($message, 500); return new WP_REST_Response($message, 500);
} }

View File

@@ -24,8 +24,6 @@ function paypal_shortcode_content_CIPF() {
$paypal_message_failure = get_payment_message_failure_CIPF(); $paypal_message_failure = get_payment_message_failure_CIPF();
$paypal_message_problem = get_payment_message_problem_CIPF(); $paypal_message_problem = get_payment_message_problem_CIPF();
// if (!can_pay_now_CIPF())
// return no_payment_CIPF();
$pp_client_id = $paypal_client_id; $pp_client_id = $paypal_client_id;
$pp_sdk_currency = "EUR"; $pp_sdk_currency = "EUR";
@@ -55,10 +53,6 @@ function paypal_shortcode_content_CIPF() {
add_shortcode('cipf_paypal_shortcode', 'paypal_shortcode_content_CIPF'); add_shortcode('cipf_paypal_shortcode', 'paypal_shortcode_content_CIPF');
function no_payment_CIPF() {
Plgntls::debug_infos();
return;
}

View File

@@ -30,6 +30,7 @@ if (!defined('ABSPATH')) {
* *
*/ */
/* /*
* *
* *
@@ -37,20 +38,17 @@ if (!defined('ABSPATH')) {
function update_user_pre_order_CIPF($message) { function update_user_pre_order_CIPF($message) {
Plgntls::debug_infos(); Plgntls::debug_infos();
$acf_payment_status = Cipf::ACF_CARD_PAYMENT_STATE; $acf_payment_status = Cipf::ACF_CARD_PAYMENT_STATE;
$meta_order_id = Cipf::META_ORDER_ID;
$order_id = $message->id; $order_id = $message->id;
$user_id = get_current_user_id(); $user_id = get_current_user_id();
$acf_id = 'user_'.$user_id;
/* /*
* - delete previous order ids * set new order_id
* -> it will delete the previous one
* -> if we are here it's because a new order will try to be created * -> if we are here it's because a new order will try to be created
* - addind order_id to cipf_order_id meta field
* *
*/ */
delete_user_meta($user_id, $meta_order_id); set_acf_order_id_CIPF($order_id, $user_id);
add_user_meta($user_id, $meta_order_id, $order_id);
/* /*
* create a meta field to check states of payements on prof author page : * create a meta field to check states of payements on prof author page :
@@ -76,8 +74,9 @@ function update_user_post_capture_CIPF($message) {
$order_id = $message->id; $order_id = $message->id;
$user_id = get_current_user_id(); $user_id = get_current_user_id();
$status = null; $status = null;
if (is_object($message) && isset($message->status)) if (is_object($message) && isset($message->status)) {
$status = $message->status; $status = $message->status;
}
/* /*
* capture status : https://developer.paypal.com/docs/api/orders/v2/#definition-order_status * capture status : https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
@@ -95,17 +94,22 @@ function update_user_post_capture_CIPF($message) {
* -> it is at least necessary to find the user who did the purchase * -> it is at least necessary to find the user who did the purchase
* *
*/ */
// find the user containing the order_id and delete this order_id
$user_id_to_update = find_user_with_order_id_CIPF($user_id, $order_id); $user_id_to_update = find_user_with_order_id_CIPF($user_id, $order_id);
if ($user_id_to_update === false) if ($user_id_to_update === false) {
throw new HttpException('cannot find user with this order_id', 502); throw new HttpException('cannot find user with this order_id', 502);
if ($status === 'COMPLETED') {
// proceed to validate payment for user
success_payment_for_user_CIPF($user_id_to_update, $order_id);
} }
else if ($status === 'PENDING') { /*
// i don't know what to do yet, maybe make more checks and output a message to contact diego ? * PayPal capture status: https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
// https://developer.paypal.com/docs/api/orders/v2/#definition-capture_status_details * - COMPLETED: Payment captured successfully
* - PENDING: Payment authorized, awaiting capture (valid for some payment methods)
* - DECLINED: Payment was declined
* - PARTIALLY_REFUNDED: Order partially refunded
* - REFUNDED: Order fully refunded
* - FAILED: Order failed
*/
if ($status === 'COMPLETED' || $status === 'PENDING') {
// proceed to validate payment for user (both COMPLETED and PENDING are successful)
success_payment_for_user_CIPF($user_id_to_update, $order_id);
} }
else { else {
failure_payment_for_user_CIPF($user_id_to_update, $order_id, $status); failure_payment_for_user_CIPF($user_id_to_update, $order_id, $status);
@@ -128,22 +132,30 @@ function update_user_post_capture_CIPF($message) {
*/ */
function failure_payment_for_user_CIPF($user_id, $order_id, $status) { function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
Plgntls::debug_infos(); Plgntls::debug_infos();
$meta_order_id = Cipf::META_ORDER_ID;
$acf_id = 'user_'.$user_id; $acf_id = 'user_'.$user_id;
schedule_delete_orderid_CIPF($order_id, $user_id);
set_payment_failure_CIPF($user_id);
send_emails_CIPF('payment_echec', $user_id);
/* /*
* remove the order_id from user meta * if payment was only for card change
* *
*/ */
delete_user_meta($user_id, $meta_order_id, $order_id); if (is_acf_prof_change_card_CIPF($user_id)) {
reset_acf_prof_change_card_CIPF($user_id);
return;
set_payment_failure_CIPF($user_id);
set_account_to_pay_CIPF($user_id);
send_emails_CIPF('payment_echec', $user_id);
} }
/*
* else
*
*/
set_account_to_pay_CIPF($user_id);
}
/* /*
* things to do when a payment is a success * things to do when a payment is a success
@@ -151,27 +163,36 @@ function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
*/ */
function success_payment_for_user_CIPF($user_id, $order_id) { function success_payment_for_user_CIPF($user_id, $order_id) {
Plgntls::debug_infos(); Plgntls::debug_infos();
$meta_order_id = Cipf::META_ORDER_ID;
$acf_id = 'user_'.$user_id; $acf_id = 'user_'.$user_id;
schedule_delete_orderid_CIPF($order_id, $user_id);
/* /*
* remove the order_id from user meta * if payment was only for card change
* *
*/ */
delete_user_meta($user_id, $meta_order_id, $order_id); if (is_acf_prof_change_card_CIPF($user_id)) {
reset_acf_prof_change_card_CIPF($user_id);
send_emails_CIPF('change_card_success', $user_id);
return;
}
/*
* else
* order is important for some
* -> first update date, then the rest
*
*/
update_card_date_expiration_CIPF($user_id);
update_card_expiration_CIPF($user_id); if (is_card_new_CIPF($user_id)) {
if (is_card_new_CIPF()) {
set_card_number_CIPF($user_id); set_card_number_CIPF($user_id);
set_card_renew_CIPF($user_id); set_card_renew_CIPF($user_id);
} }
set_payment_success_CIPF($user_id); set_payment_success_CIPF($user_id);
set_account_valid_CIPF($user_id); set_account_valid_CIPF($user_id);
reset_emails_reminders_choices_CIPF($acf_id);
send_emails_CIPF('payment_success', $user_id); send_emails_CIPF('payment_success', $user_id);
} }
@@ -180,7 +201,6 @@ function success_payment_for_user_CIPF($user_id, $order_id) {
/* /*
* @return mixed num - user_id * @return mixed num - user_id
* bool false - if no match found * bool false - if no match found
@@ -188,10 +208,10 @@ function success_payment_for_user_CIPF($user_id, $order_id) {
*/ */
function find_user_with_order_id_CIPF($current_user_id, $order_id) { function find_user_with_order_id_CIPF($current_user_id, $order_id) {
Plgntls::debug_infos(); Plgntls::debug_infos();
$meta_order_id = Cipf::META_ORDER_ID; $acf_order_id = Cipf::ACF_CARD_ORDER_ID;
$role_prof = Cipf::ROLE_PROF; $role_prof = Cipf::ROLE_PROF;
$user_metas = get_user_meta($current_user_id, $meta_order_id, false); $user_metas = get_user_meta($current_user_id, $acf_order_id['_name'], false);
if (in_array($order_id, $user_metas)) { if (in_array($order_id, $user_metas)) {
return $current_user_id; return $current_user_id;
} }
@@ -202,16 +222,18 @@ function find_user_with_order_id_CIPF($current_user_id, $order_id) {
* https://developer.wordpress.org/reference/classes/WP_User_Query/prepare_query/ * https://developer.wordpress.org/reference/classes/WP_User_Query/prepare_query/
* *
*/ */
$users = get_users(array( $user = get_users(array(
'role' => $role_prof, 'role' => $role_prof,
'meta_key' => $meta_order_id, 'meta_key' => $acf_order_id,
'meta_value' => $order_id, 'meta_value' => $order_id,
'fields' => 'ID', 'fields' => 'ID',
)); ));
if (count($users) > 1) if (count($user) > 1) {
throw new HttpException('multiple users with same order_id', 502); throw new HttpException('multiple users with same order_id', 502);
else if (count($users) === 1) }
return reset($users); else if (count($user) === 1) {
return reset($user);
}
return false; return false;
} }

View File

@@ -54,6 +54,8 @@ function check_can_pay_CIPF() {
$user_id = get_current_user_id(); $user_id = get_current_user_id();
$acf_id = 'user_' . $user_id; $acf_id = 'user_' . $user_id;
/* /*
* check if payment is virement or immediat * check if payment is virement or immediat
* *
@@ -94,6 +96,16 @@ function check_can_pay_CIPF() {
return new WP_Error('cannot_purchase', "price is 0, nothing to purchase"); return new WP_Error('cannot_purchase', "price is 0, nothing to purchase");
} }
/*
* if is new account and is only to change card
*
*/
if (is_card_new_CIPF()) {
if (is_acf_prof_change_card_CIPF()) {
return new WP_Error('cannot_purchase', "account is new, you cannot change your card");
}
}
/* /*
* date validity is empty * date validity is empty

View File

@@ -1,206 +0,0 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* returns the date limit as a DateTime object
* or false if not set
*
*/
function get_date_limit_CIPF($user_id = null) {
Plgntls::debug_infos();
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
/*
* define ids
*
*/
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
/*
* get acf date field
*
*/
$current_date_limit_object = get_field_object($acf_card_expiration['_name'], $acf_id);
if ($current_date_limit_object === false) {
return false;
}
else if (empty($current_date_limit_object['value'])) {
return false;
}
/*
* create date object from acf date
*
*/
$current_date_limit_string = $current_date_limit_object['value'];
$current_format_field = $current_date_limit_object['return_format'];
// compare 2 dates : https://stackoverflow.com/q/8722806/9497573
// also I dont use strtotime to compare 2 ints,
// because i don't know if it will fail one day (2000y bug style)
$current_date_limit = date_create_from_format($current_format_field, $current_date_limit_string);
if ($current_date_limit === false) {
return false;
}
/*
* returns the date object
*
*/
return $current_date_limit;
}
/*
* returns the diff in days between today and the expiration date of the card
* returns false if the expiration date field is empty
*
*/
function card_date_diff_CIPF($user_id = null) {
Plgntls::debug_infos();
/*
* get date limit as DateTime object
*
*/
$current_date_limit = get_date_limit_CIPF($user_id);
if ($current_date_limit === false) {
return false;
}
/*
* returns diff in days
*
*/
$date_now = date_create('today');
$date_diff = date_diff($date_now, $current_date_limit);
return (int)$date_diff->format('%R%a');
}
/*
* returns true if date is in paste or is empty
* use is_card_date_exists_CIPF to check if the field is empty
*
*/
function is_card_date_expired_CIPF($user_id = null) {
Plgntls::debug_infos();
/*
* define user_id
*
*/
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
/*
* check if expired
*
*/
$date_diff = card_date_diff_CIPF($user_id);
if ($date_diff === false) {
return true;
}
else if ($date_diff < 0) {
return true;
}
return false;
}
/*
* returns true if date is empty
*
*/
function card_date_exists_CIPF($user_id = null) {
Plgntls::debug_infos();
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
/*
* define ids
*
*/
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
/*
* get acf date field
*
*/
$date_now = date_create('today');
$current_date = get_field($acf_card_expiration['_name'], $acf_id);
if (empty($current_date)) {
return false;
}
if (is_null($current_date)) {
return false;
}
return true;
}
/*
* will add card_duration to card
* card_duration is expected in a string format : https://www.php.net/manual/en/class.dateinterval.php
*
*/
function update_card_expiration_CIPF($user_id = null) {
Plgntls::debug_infos();
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
$card_duration = Cipf::CARD_VALIDITY_TIME;
/*
* define acf id and acf date format
*
*/
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
$acf_date_format = 'Y-m-d H:i:s';
/*
* get date limit as DateTime object
*
*/
$current_date_limit = get_date_limit_CIPF($user_id);
if ($current_date_limit === false) {
$current_date_limit = date_create('today');
}
/*
* update date limit validity to add 1 year
*
*/
$date_plus_one_year = $current_date_limit->add(date_interval_create_from_date_string('+'.$card_duration));
update_field($acf_card_expiration['_name'], $date_plus_one_year->format($acf_date_format), $acf_id);
}
?>

View File

@@ -16,13 +16,14 @@ if (!defined('ABSPATH')) {
* *
*/ */
function prof_after_form_commande_CIPF($form_id, $post_array, $form_type) { function prof_after_form_commande_CIPF($form_id, $post_array, $form_type) {
Plgntls::debug_infos(); Plgntls::debug_infos(2);
$acf_account_state = Cipf::ACF_ACCOUNT_STATE; $acf_account_state = Cipf::ACF_ACCOUNT_STATE;
$form_prof_commande_id = Cipf::FORM_PROF_COMMANDE_ID; $form_prof_commande_id = Cipf::FORM_PROF_COMMANDE_ID;
if ($form_prof_commande_id !== $form_id) { if ($form_prof_commande_id !== $form_id) {
return; return;
} }
Plgntls::debug_infos();
//$user_id = get_current_user_id(); //$user_id = get_current_user_id();
$user_id = $post_array['ID']; $user_id = $post_array['ID'];

View File

@@ -19,6 +19,7 @@ if (!defined('ABSPATH')) {
function handle_transfert_validation_CIPF($user_id) { function handle_transfert_validation_CIPF($user_id) {
Plgntls::debug_infos(); Plgntls::debug_infos();
$acf_id = 'user_'.$user_id;
/* /*
* check and reset the acf fielf for transfert * check and reset the acf fielf for transfert
* *
@@ -44,9 +45,10 @@ function handle_transfert_validation_CIPF($user_id) {
* *
*/ */
set_account_valid_CIPF($user_id); set_account_valid_CIPF($user_id);
update_card_expiration_CIPF($user_id); update_card_date_expiration_CIPF($user_id);
set_card_number_CIPF($user_id); set_card_number_CIPF($user_id);
set_card_renew_CIPF($user_id); set_card_renew_CIPF($user_id);
reset_emails_reminders_choices_CIPF($acf_id);
send_emails_CIPF('transfert_success', $user_id); send_emails_CIPF('transfert_success', $user_id);
} }
@@ -60,7 +62,9 @@ function handle_transfert_validation_CIPF($user_id) {
*/ */
function handle_card_expire_CIPF($user_id) { function handle_card_expire_CIPF($user_id) {
Plgntls::debug_infos(); Plgntls::debug_infos();
if (false === card_date_exists_CIPF($user_id)) { $acf_id = 'user_'.$user_id;
if (false === isset_acf_card_expiration_CIPF($user_id)) {
return; return;
} }
if (is_card_date_expired_CIPF($user_id)) { if (is_card_date_expired_CIPF($user_id)) {
@@ -70,6 +74,10 @@ function handle_card_expire_CIPF($user_id) {
else { else {
set_account_expired_CIPF($user_id); set_account_expired_CIPF($user_id);
} }
if (!is_email_reminder_choice_CIPF('card_expired', $acf_id)) {
set_email_reminder_choice_CIPF('card_expired', $acf_id);
send_emails_CIPF('card_expired', $user_id);
}
} }
else { else {
if (is_account_waiting_transfert_CIPF($user_id)) { if (is_account_waiting_transfert_CIPF($user_id)) {
@@ -78,6 +86,8 @@ function handle_card_expire_CIPF($user_id) {
else { else {
set_account_valid_CIPF($user_id); set_account_valid_CIPF($user_id);
} }
reset_emails_reminders_box_CIPF('account_deletion', $acf_id);
unset_email_reminder_choice_CIPF('card_expired', $acf_id);
} }
} }
@@ -85,4 +95,136 @@ function handle_card_expire_CIPF($user_id) {
/*
* this function will delete the account if the deletion date is expired
* it is called both by e scheduled event, and every time a prof go on its page
*
*/
function handle_prof_account_deletion_CIPF($user_id) {
Plgntls::debug_infos();
/*
* check if account still exists
*
*/
if (false === get_user_by('id', $user_id)) {
return;
}
/*
* check if account should be deleted
*
*/
if (!is_prof_account_deletion_date_exceeded_CIPF($user_id)) {
return;
}
send_emails_CIPF('account_deleted', $user_id);
include_once(ABSPATH.'wp-admin/includes/user.php');
// dont delete, for log
$user = get_user_by('id', $user_id);
error_log("delete prof: " . $user->user_login);
wp_delete_user($user_id);
}
/*
* it should not be necessary, but just in case
* ! no sens : it hooks after user is deleted, so images are already added to another user if they are not deleted
*
*/
//function prof_deletion_ensure_images_are_deleted_CIPF($user_id, $reassign, $user) {
// Plgntls::debug_infos();
// $role_prof = Cipf::ROLE_PROF;
//
// if (!in_array($role_prof, $user->roles)) {
// return;
// }
//
// $images = get_posts(array(
// 'post_type' => 'attachment',
// 'post_mime_type' => 'image',
// 'posts_per_page' => -1,
// 'author' => $user_id,
// ));
// if (empty($images)) {
// return;
// }
// foreach ($images as $image) {
// $image_id = $image->ID;
// // Set the second argument to true to permanently delete the attachment
// $result = wp_delete_attachment($image_id, true);
// if ($result === false) {
// error_log('- failed to delete image: ' . $image_id);
// }
// else {
// error_log('- delete image: ' . $image_id);
// }
// }
//}
//add_action('deleted_user', 'prof_deletion_ensure_images_are_deleted_CIPF', 10, 3);
/*
* this function will check if users should be sent an email
* to remind them of their card expiration date
*
*/
function handle_reminders_before_card_expire_CIPF($user_id) {
Plgntls::debug_infos();
$emails_reminders = Cipf:: ACF_EMAILS_REMINDERS;
if (!isset_acf_card_expiration_CIPF($user_id)) {
return;
}
if (is_card_date_expired_CIPF($user_id)) {
return;
}
$date_limit = get_card_date_expiration_CIPF($user_id);
if (false === $date_limit) {
return;
}
handle_send_reminders_CIPF('user_'.$user_id, $user_id, $date_limit, 'card_expiration', 'card_will_expire');
}
/*
* this function will check if users should be sent an email
* to remind them of their account beeing soon deleted
*
*/
function handle_reminders_before_account_deleted_CIPF($user_id) {
Plgntls::debug_infos();
$duration_deletion = Cipf::DURATION_ACCOUNT_DELETE_AFTER_EXPIRE;
if (!isset_acf_card_expiration_CIPF($user_id)) {
return;
}
$acf_id = 'user_'.$user_id;
if (!is_card_date_expired_CIPF($user_id)) {
reset_emails_reminders_box_CIPF('account_deletion', $acf_id);
return;
}
$date_limit = get_card_date_expiration_CIPF($user_id);
if (false === $date_limit) {
return;
}
$date_deletion = $date_limit->modify($duration_deletion);
handle_send_reminders_CIPF($acf_id, $user_id, $date_deletion, 'account_deletion', 'account_will_be_deleted');
}
?> ?>

View File

@@ -52,11 +52,12 @@ function prof_profil_check_CIPF() {
$author_id = get_queried_object_id(); $author_id = get_queried_object_id();
/* /*
* in case event didn't fire, handle card changes * in case event didn't fire, handle changes
* *
*/ */
handle_transfert_validation_CIPF($author_id); handle_transfert_validation_CIPF($author_id);
handle_card_expire_CIPF($author_id); handle_card_expire_CIPF($author_id);
handle_prof_account_deletion_CIPF($author_id);
} }
add_action('wp', 'prof_profil_check_CIPF', 11); add_action('wp', 'prof_profil_check_CIPF', 11);
@@ -121,7 +122,7 @@ function prof_profil_redirects_CIPF() {
* *
*/ */
if (is_account_new_CIPF()) { if (is_account_new_CIPF()) {
redirect_command_CIPF(); redirect_prof_command_CIPF();
} }
} }
add_action('template_redirect', 'prof_profil_redirects_CIPF', 11); add_action('template_redirect', 'prof_profil_redirects_CIPF', 11);

View File

@@ -1,95 +0,0 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* schedule events :
* - first use a function to add the event :
* - function launch_schedule_my_evet() {
* wp_schedule_single_event($delay, 'hook_event_name');
* }
* - this will enqueue an action hook when the time will come, that you must define :
* - add_action('hook_event_name', 'callback_function');
* - and finally, define the function 'callback_function()'
*
* to define the delay, you can use the strtotime notation
* - strtotime('+1 month');
* -> https://www.php.net/manual/en/function.strtotime.php
* or the time constants in seconds :
* - time() + 3 * MINUTE_IN_SECONDS
* -> https://codex.wordpress.org/Easier_Expression_of_Time_Constants
*
*/
/*
* events and emails :
*
* - payments : action : : suppress old order_ids
* - profs : : email : validation payment prof, send email
* - profs : : email : validation transfert prof, send email
* - partners : action : : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
* - partners : action : : la gestion des offres à échéance
* - payments : action : email : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte
* - payments : action : email : schedule event pour supprimer les codes
* - payments : action : email : schedule event pour desactiver la carte
* - payments : action : email : faire rappels emails
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
/*
* add a schedule event to delete this order_id
* after 3 days ?
*
*/
function schedule_delete_orderid_CIPF($user_id, $order_id) {
Plgntls::debug_infos();
$delay = strtotime('+3 days');
wp_schedule_single_event($delay, 'orderid_deletion_event_CIPF', array($user_id, $order_id));
}
function delete_order_id_later_CIPF($user_id, $order_id) {
Plgntls::debug_infos();
delete_user_meta($user_id, 'cipf_order_id', $order_id);
}
add_action('orderid_deletion_event_CIPF', 'delete_order_id_later_CIPF', 10, 2);
?>

View File

@@ -1,498 +0,0 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* [/] etat compte ('etat_compte') :
* 1. new . 'nouveau prof' -> ok 1/1 : [1: at inscription - ok]
* 2. to_pay . 'doit payer' -> ko 3/4 : [1: after form & new - ok], [2: after form choose paypal & expired - ok], [3: after payment failed - ok], [4: after transfert failed - ko]
* 3. valid . 'carte valide' -> ko 1/2 : [1: after payment success - ok], [2: after transfert success - ko]
* 4. waiting_invalid . 'en attente invalide' -> ko 3/4 : [1: after form choose transfert & expired - ok], [2: after card changes to expired & was waiting valid - ok], [3: verify at prof profil page - ok], [4: when event for expire fire - ko]
* 5. waiting_valid . 'en attente valide' -> ok 1/1 : [1: after form choose transfert & not expired - ok]
* 6. expired . 'carte expiree' -> ko 1/2 : [1: when prof access profil & expired - ok], [2: when event card expired fire - ko]
*
* [/] etat carte ('etat_carte') :
* - 'Commande' -> ok 1/1 : [1: at inscription - ok]
* - 'Renouvellement' -> ko 1/1 : [1: after succees payement - ok]
*
* [/] etat paiement ('etat_paiement') :
* - 'en_cours' -> ok 1/1 : [1: start payment - ok]
* - 'reussi' -> ok 1/1 : [1: after payment success - ok]
* - 'echec' -> ok 1/1 : [1: after payment failure - ok]
* - 'aucun' -> ok 2/2 : [1: default - ko], [2: after payment message is shown one time on profil page - ok]
*
* [/] type paiement ('paiement') :
* - 'Paypal' -> ok 1/1 : [1: modified by diviformbuilder at form validation - ok]
* - 'Virement' -> ok 1/1 : [1: modified by diviformbuilder at form validation - ok]
*
* [/] etat partenaire ('etat_page_partenaire') :
* - 'publie'
* - 'brouillon'
*
* [/] numero de carte ('numero_de_la_carte') -> ok 1/1 : [1: after payment & card is 'commande' - ok]
*
* [/] etat_virement -> ko 2/3 : [1: at form validation - ok], [2: check on profil page - ko], [3: when transfert is started, reset - ok]]
*
* [/] cgv
*
*
*/
function get_field_init_CIPF($acf_field_name, $acf_id) {
Plgntls::debug_infos();
$acf_state = get_field($acf_field_name, $acf_id);
if ($acf_state !== null) {
return $acf_state;
}
/*
* if get_field returns null, it means it is not initialized
* - initialize it with 'temp' value
* - then find it's default value, and update with it
* - if no default value, update with first value
*
*/
update_field($acf_field_name, 'temp', $acf_id);
$acf_object = get_field_object($acf_field_name, $acf_id);
$default = $acf_object['default_value'];
if (empty($default)) {
$choices = $acf_object['choices'];
if (!is_array($choices)) {
return false;
}
$default = reset($choices);
}
update_field($acf_field_name, $default, $acf_id);
$acf_state = get_field($acf_field_name, $acf_id);
return $acf_state;
}
/*
* global 'setter' and 'izzer' for this file
*
*/
function is_acf_state_CIPF($acf_field, $state_name, $acf_id) {
Plgntls::debug_infos();
/*
* when acf fields have not been initated a first time, you can't find them by name
* - one solution is to use key instead
* but it means knowing the key, in my case it prevents fabien to create a field himself
* - another solution would be to :
* try if is null,
* if yes it means it was not initalize,
* then initalize with any value,
* find the default value,
* and assign it
*
$acf_state = get_field($acf_field['_key'], $acf_id);
*/
$acf_state = get_field_init_CIPF($acf_field['_name'], $acf_id);;
if ($acf_state === $acf_field[$state_name]) {
return true;
}
return false;
}
function set_acf_state_CIPF($acf_field, $state_name, $acf_id) {
Plgntls::debug_infos();
update_field($acf_field['_name'], $acf_field[$state_name], $acf_id);
}
/*
* etat compte ('etat_compte') :
* 1. new . 'nouveau prof' -> ok : [1: a l'inscription - ok]
* 2. to_pay . 'doit payer' -> ko : [1: apres premier form - ok], [2: apres form qui suit carte expiree - ok], [3: apres paiement immediat echoue - ko], [4: apres virement echoue - ko]
* 3. valid . 'carte valide' ->
* 4. waiting_invalid . 'en attente invalide' ->
* 5. waiting_valid . 'en attente valide' ->
* 6. expired . 'carte expiree' ->
*
* receives the name of the state, and compare it to the current state
* either use the is_acf_card_state_CIPF() function directly,
* or one of the specific functions
*
*/
function is_account_state_CIPF($state_name, $user_id = null) {
Plgntls::debug_infos();
$acf_account_state = Cipf::ACF_ACCOUNT_STATE;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
return is_acf_state_CIPF($acf_account_state, $state_name, $acf_id);
}
function is_account_new_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_account_state_CIPF('new', $user_id);
}
function is_account_to_pay_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_account_state_CIPF('to_pay', $user_id);
}
function is_account_valid_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_account_state_CIPF('valid', $user_id);
}
function is_account_waiting_invalid_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_account_state_CIPF('waiting_invalid', $user_id);
}
function is_account_waiting_valid_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_account_state_CIPF('waiting_valid', $user_id);
}
function is_account_expired_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_account_state_CIPF('expired', $user_id);
}
// additional : check both waitings
function is_account_waiting_transfert_CIPF($user_id = null) {
Plgntls::debug_infos();
if (is_account_waiting_valid_CIPF($user_id)) {
return true;
}
if (is_account_waiting_invalid_CIPF($user_id)) {
return true;
}
return false;
}
/*
* setters :
*/
function set_account_state_CIPF($state_name, $user_id = null) {
Plgntls::debug_infos();
$acf_account_state = Cipf::ACF_ACCOUNT_STATE;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
set_acf_state_CIPF($acf_account_state, $state_name, $acf_id);
}
function set_account_new_CIPF($user_id = null) {
Plgntls::debug_infos();
set_account_state_CIPF('new', $user_id);
}
function set_account_to_pay_CIPF($user_id = null) {
Plgntls::debug_infos();
set_account_state_CIPF('to_pay', $user_id);
}
function set_account_valid_CIPF($user_id = null) {
Plgntls::debug_infos();
set_account_state_CIPF('valid', $user_id);
}
function set_account_waiting_invalid_CIPF($user_id = null) {
Plgntls::debug_infos();
set_account_state_CIPF('waiting_invalid', $user_id);
}
function set_account_waiting_valid_CIPF($user_id = null) {
Plgntls::debug_infos();
set_account_state_CIPF('waiting_valid', $user_id);
}
function set_account_expired_CIPF($user_id = null) {
Plgntls::debug_infos();
set_account_state_CIPF('expired', $user_id);
}
/*
* etat carte ('etat_carte') :
* - 'Commande'
* - 'Renouvellement'
*
*/
function is_card_state_CIPF($state, $user_id = null) {
Plgntls::debug_infos();
$acf_card_state = Cipf::ACF_CARD_STATE;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
return is_acf_state_CIPF($acf_card_state, $state, $acf_id);
}
function is_card_new_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_card_state_CIPF('new', $user_id);
}
function is_card_renew_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_card_state_CIPF('renew', $user_id);
}
/*
* setters :
*/
function set_card_state_CIPF($state, $user_id = null) {
Plgntls::debug_infos();
$acf_card_state = Cipf::ACF_CARD_STATE;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
set_acf_state_CIPF($acf_card_state, $state, $acf_id);
}
function set_card_new_CIPF($user_id = null) {
Plgntls::debug_infos();
set_card_state_CIPF('new', $user_id);
}
function set_card_renew_CIPF($user_id = null) {
Plgntls::debug_infos();
set_card_state_CIPF('renew', $user_id);
}
/*
* etat page partenaire ('etat_page_partenaire') :
* - 'Publiee'
* - 'Brouillon'
*
*/
function is_page_state_CIPF($state, $post_id = null) {
Plgntls::debug_infos();
$acf_page_state = Cipf::ACF_PAGE_STATE;
if (is_null($post_id)) {
$post_id = get_the_ID();
}
$acf_id = $post_id;
return is_acf_state_CIPF($acf_page_state, $state, $acf_id);
}
function is_page_publish_CIPF($post_id = null) {
Plgntls::debug_infos();
return is_page_state_CIPF('publish', $post_id);
}
function is_page_draft_CIPF($post_id = null) {
Plgntls::debug_infos();
return is_page_state_CIPF('draft', $post_id);
}
/*
* setters :
*/
function set_page_state_CIPF($state, $post_id = null) {
Plgntls::debug_infos();
$acf_page_state = Cipf::ACF_PAGE_STATE;
if (is_null($post_id)) {
$post_id = get_the_ID();
}
$acf_id = $post_id;
set_acf_state_CIPF($acf_page_state, $state, $acf_id);
}
function set_page_publish_CIPF($post_id = null) {
Plgntls::debug_infos();
set_page_state_CIPF('publish', $post_id);
}
function set_page_draft_CIPF($post_id = null) {
Plgntls::debug_infos();
set_page_state_CIPF('draft', $post_id);
}
/*
* type paiement ('paiement') :
* - 'paypal'=>'Paypal'
* - 'transfert'=>'Virement'
*
*/
function is_card_method_CIPF($state, $user_id = null) {
Plgntls::debug_infos();
$acf_card_payment_method = Cipf::ACF_CARD_PAYMENT_METHOD;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
return is_acf_state_CIPF($acf_card_payment_method, $state, $acf_id);
}
function is_payment_method_paypal_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_card_method_CIPF('paypal', $user_id);
}
function is_payment_method_transfert_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_card_method_CIPF('transfert', $user_id);
}
/*
* etat paiement ('etat_paiement') :
* - 'en_cours'
* - 'reussi'
* - 'echec'
* - 'aucun'
*
* 'started'=>'en_cours', 'success'=>'reussi', 'failure'=>'echec', 'nothing'=>'aucun'
*
*/
function is_payment_state_CIPF($type, $user_id = null) {
Plgntls::debug_infos();
$acf_card_payment_state = Cipf::ACF_CARD_PAYMENT_STATE;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
return is_acf_state_CIPF($acf_card_payment_state, $type, $acf_id);
}
function is_payment_started_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_payment_state_CIPF('started', $user_id);
}
function is_payment_success_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_payment_state_CIPF('success', $user_id);
}
function is_payment_failure_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_payment_state_CIPF('failure', $user_id);
}
function is_payment_nothing_CIPF($user_id = null) {
Plgntls::debug_infos();
return is_payment_state_CIPF('nothing', $user_id);
}
/*
* setters
*/
function set_payment_state_CIPF($type, $user_id = null) {
Plgntls::debug_infos();
$acf_card_payment_state = Cipf::ACF_CARD_PAYMENT_STATE;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
set_acf_state_CIPF($acf_card_payment_state, $type, $acf_id);
}
function set_payment_started_CIPF($user_id = null) {
Plgntls::debug_infos();
set_payment_state_CIPF('started', $user_id);
}
function set_payment_success_CIPF($user_id = null) {
Plgntls::debug_infos();
set_payment_state_CIPF('success', $user_id);
}
function set_payment_failure_CIPF($user_id = null) {
Plgntls::debug_infos();
set_payment_state_CIPF('failure', $user_id);
}
function set_payment_nothing_CIPF($user_id = null) {
Plgntls::debug_infos();
set_payment_state_CIPF('nothing', $user_id);
}
/*
* numero de carte
*
*/
function set_card_number_CIPF($user_id = null) {
Plgntls::debug_infos();
$acf_card_number = Cipf::ACF_CARD_NUMBER;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
$date_now = date_create('today');
$card_id = $date_now->format('Ymd') . $user_id;
update_field($acf_card_number['_name'], $card_id, $acf_id);
}
/*
* cgv
*
*/
function reset_acf_cgv_CIPF($user_id = null) {
Plgntls::debug_infos();
$acf_cgv = Cipf::ACF_PROF_CGV;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
update_field($acf_cgv['_name'], array(""), $acf_id);
}
/*
* etat virement
*
*/
function is_transfert_success_CIPF($user_id = null) {
Plgntls::debug_infos();
$acf_transfert_state = Cipf::ACF_TRANSFERT_STATE;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
$transfert_state = get_field($acf_transfert_state['_name'], $acf_id);
/*
* before first use : returns null
* if checked : returns value
* if unchecked : returns empty
*/
if (is_null($transfert_state)) {
return false;
}
else if (empty($transfert_state)) {
return false;
}
else {
return true;
}
}
function reset_acf_transfert_CIPF($user_id = null) {
Plgntls::debug_infos();
$acf_transfert_state = Cipf::ACF_TRANSFERT_STATE;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
$acf_id = 'user_'.$user_id;
update_field($acf_transfert_state['_name'], array(""), $acf_id);
}
?>

View File

@@ -55,6 +55,8 @@ class Plgntls {
* typical for early hooks like 'init' or 'wp', where there is a first check to see if you should 'enter' in this function, level 1 will be present after thoses checks * typical for early hooks like 'init' or 'wp', where there is a first check to see if you should 'enter' in this function, level 1 will be present after thoses checks
* 2 : output everything * 2 : output everything
* *
private static $_DEBUG_INFOS = 2;
private static $_DEBUG_INFOS = 1;
*/ */
private static $_DEBUG_INFOS = 0; private static $_DEBUG_INFOS = 0;
@@ -252,6 +254,10 @@ class Plgntls {
self::$_plugin_dir_path = str_replace('/'.plugin_basename(__DIR__).'/', '', plugin_dir_path(__FILE__)); self::$_plugin_dir_path = str_replace('/'.plugin_basename(__DIR__).'/', '', plugin_dir_path(__FILE__));
// https://wordpress.stackexchange.com/questions/19900/how-to-get-main-plugin-theme-file // https://wordpress.stackexchange.com/questions/19900/how-to-get-main-plugin-theme-file
// https://wordpress.stackexchange.com/questions/149802/get-plugins-doesnt-work-after-plugins-loaded
if (!function_exists('get_plugins')) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugin_data = get_plugins("/".self::$_plugin_dir); $plugin_data = get_plugins("/".self::$_plugin_dir);
self::$_main_file = array_keys($plugin_data)[0]; self::$_main_file = array_keys($plugin_data)[0];
@@ -331,6 +337,7 @@ class Plgntls {
$function = $trace[1]['function']; $function = $trace[1]['function'];
$file = $trace[0]['file']; $file = $trace[0]['file'];
$line = $trace[0]['line']; $line = $trace[0]['line'];
error_log("-debug: function '".$function."' (in ".$file.", line ".$line .')');
} }
@@ -940,6 +947,8 @@ class Plgntls {
'capability'=> 'manage_options', 'capability'=> 'manage_options',
'slug' => $menu_options['name'], 'slug' => $menu_options['name'],
'callback' => $menu_options['callback'], 'callback' => $menu_options['callback'],
'icon' => '',
'position' => 10,
'toggle' => true, 'toggle' => true,
); );
foreach ($default as $key => $value) { foreach ($default as $key => $value) {
@@ -949,7 +958,15 @@ class Plgntls {
} }
if (false === $menu_options['toggle']) { if (false === $menu_options['toggle']) {
add_menu_page($menu_options['page_title'], $menu_options['name'], $menu_options['capability'], $menu_options['slug'], $menu_options['callback']); add_menu_page(
$menu_options['page_title'],
$menu_options['name'],
$menu_options['capability'],
$menu_options['slug'],
$menu_options['callback'],
$menu_options['icon'],
$menu_options['position'],
);
} }
else { else {
self::_toggle_menu($menu_options['page_title'], $menu_options['name'], $menu_options['capability'], $menu_options['slug'], $menu_options['callback']); self::_toggle_menu($menu_options['page_title'], $menu_options['name'], $menu_options['capability'], $menu_options['slug'], $menu_options['callback']);
@@ -1088,6 +1105,10 @@ class Plgntls {
* *
*/ */
$option_data = get_option($option_name); $option_data = get_option($option_name);
if (!is_string($option_data)) {
$ret_option = $option_data;
}
else {
$false_serialized = serialize(false); $false_serialized = serialize(false);
$option_unserialized = @unserialize($option_data); $option_unserialized = @unserialize($option_data);
if ($option_unserialized === false && $option_data != $false_serialized) { if ($option_unserialized === false && $option_data != $false_serialized) {
@@ -1096,6 +1117,7 @@ class Plgntls {
else { else {
$ret_option = $option_unserialized; $ret_option = $option_unserialized;
} }
}
/* /*
* $name is true, * $name is true,
@@ -1207,9 +1229,6 @@ class Plgntls {
if (!isset($option['_default'])) { if (!isset($option['_default'])) {
return false; return false;
} }
if (isset($option['_db'])) {
return $option['_name'];
}
/* /*
* if wp option does not already exists, just add it * if wp option does not already exists, just add it
@@ -1218,7 +1237,8 @@ class Plgntls {
*/ */
$name = $option['_name']; $name = $option['_name'];
if (false === get_option($name)) { if (false === get_option($name)) {
add_option($name, $option['_default'], '', 'no'); add_option($name, '', '', 'no');
self::update_option_safe($name, $option['_default']);
} }
/* /*
@@ -1254,7 +1274,6 @@ class Plgntls {
*/ */
$options_serialized = get_option(self::$_options_list); $options_serialized = get_option(self::$_options_list);
$options_unserialized = unserialize($options_serialized); $options_unserialized = unserialize($options_serialized);
$option['_db'] = null;
$options_unserialized[$name] = $option; $options_unserialized[$name] = $option;
update_option(self::$_options_list, serialize($options_unserialized), '', 'no'); update_option(self::$_options_list, serialize($options_unserialized), '', 'no');

1
plugins/custer Submodule

Submodule plugins/custer added at b551112094

View File

@@ -1,48 +0,0 @@
<?php
namespace CUSTER;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* the construction of the admin menu page
*
*/
function custer_plugin_content() {
echo "<p>hello</p>";
}
/*
* menu plugin
*/
function custer_plugin_menu() {
$menu_page_title = 'custer';
$menu_title = 'custer';
$menu_capability = 'manage_options';
$menu_slug = 'custer-plugin';
$menu_callback = __NAMESPACE__.'\custer_plugin_content';
\CUSTER\toggle_menu($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback);
}
add_action('admin_menu', __NAMESPACE__.'\custer_plugin_menu');
?>

View File

@@ -1,108 +0,0 @@
<?php
namespace CUSTER;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
function toggle_menu($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback) {
$toggle_menu = Custer::OPTION_TOGGLE_MENU;
if (false === get_option($toggle_menu['_name'])) {
add_option($toggle_menu['_name'], $toggle_menu['hide'], '', 'no');
}
$toggle = get_option($toggle_menu['_name']);
if ($toggle === $toggle_menu['hide']) {
remove_menu_page($menu_slug);
}
else if ($toggle === $toggle_menu['show']) {
add_menu_page($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback);
}
}
/*
* add link under the plugin in the plugins admin page
*
*/
function add_link_to_custer_plugin($links) {
$slug_toggle = Custer::SLUG_TOOGLE_ADMIN_MENU;
$toggle_menu = Custer::OPTION_TOGGLE_MENU;
$toggle = get_option($toggle_menu['_name']);
if ($toggle === $toggle_menu['hide']) {
$links[] = '<a href="/'.$slug_toggle['_name'].'?'.$slug_toggle['toggle'].'='.$slug_toggle['show'].'">show menu</a>';
}
else if ($toggle === $toggle_menu['show']) {
$links[] = '<a href="/'.$slug_toggle['_name'].'?'.$slug_toggle['toggle'].'='.$slug_toggle['hide'].'">hide menu</a>';
}
return $links;
}
add_filter('plugin_action_links_custer/custer.php', __NAMESPACE__.'\add_link_to_custer_plugin');
/*
* handle the toggle menu when url is reached
*
*/
function toggle_custer_plugin_menu() {
$slug_toggle = Custer::SLUG_TOOGLE_ADMIN_MENU;
$toggle_menu = Custer::OPTION_TOGGLE_MENU;
global $wp;
$current_slug = $wp->request;
if ($current_slug !== $slug_toggle['_name']) {
return;
}
$show = null;
if (!isset($_GET)) {
$show = null;
}
else if (empty($_GET)) {
$show = null;
}
if (!isset($_GET[$slug_toggle['toggle']])) {
$show = null;
}
else if ($_GET[$slug_toggle['toggle']] === $slug_toggle['show']) {
$show = true;
}
else if ($_GET[$slug_toggle['toggle']] === $slug_toggle['hide']) {
$show = false;
}
if ($show === true) {
update_option($toggle_menu['_name'], $toggle_menu['show']);
}
else if ($show === false) {
update_option($toggle_menu['_name'], $toggle_menu['hide']);
}
$plugins_menu_url = admin_url('plugins.php');
wp_redirect($plugins_menu_url, 301);
exit;
}
add_action('template_redirect', __NAMESPACE__.'\toggle_custer_plugin_menu');
?>

View File

@@ -1,147 +0,0 @@
<?php
namespace CUSTER;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* change the current user to the author id of the current object
* the only option is to force the author
* -> there is no sens in forcing the logged_in, because it's already the default
*
* [custer_author_id] -> give current user the id of author
* [custer_author_id off] -> reset to logged_in
*
* ! anchors not workink for the moment
* //[custer_author_id set_anchor='anchor_name'] -> create anchor for author user
* //[custer_author_id anchor='anchor_name'] -> give current user the id stored in the anchor_name
*
*/
function shortcode_author_id($options) {
$anchor_name = '';
$option = '';
$is_set_anchor = false;
/*
* set option value :
* 'off', 'author', 'set_anchor', or 'anchor'
*
*/
if (empty($options)) {
$option = 'author';
}
if (isset($options['set_anchor'])) {
$option = 'author';
// $is_set_anchor = true;
// $anchor_name = $options['set_anchor'];
// if (empty($anchor_name)) {
// return;
// }
unset($options['set_anchor']);
}
if (isset($options['anchor'])) {
// if ($is_set_anchor) {
// return;
// }
// $option = 'anchor';
// $anchor_name = $options['anchor'];
// if (empty($anchor_name)) {
// return;
// }
unset($options['anchor']);
}
if (is_array($options) && in_array('off', $options)) {
$option = 'off';
}
if (empty($option)) {
return;
}
/*
* find id according to option
* if option is set_anchor, it sets it and return 0
*
*/
$id = \CUSTER\find_id_wih_option($option, $anchor_name);
if ($id === 0) {
return;
}
/*
* set current user
*
*/
if ($is_set_anchor) {
\CUSTER\create_anchor($anchor_name, $id);
}
else {
wp_set_current_user($id);
}
}
add_shortcode('custer_author_id', __NAMESPACE__.'\shortcode_author_id');
function create_anchor($anchor_name, $id) {
$option_anchor = Custer::OPTION_ANCHOR;
/*
* if needed, create the option
*
*/
if (false === get_option($option_anchor)) {
add_option($option_anchor, array());
}
/*
* add or update the id for the anchor name
*
*/
$anchors = get_option($option_anchor);
$anchors[$anchor_name] = $id;
update_option($option_anchor, $anchors);
}
/*
* find ids according to options :
* - author : change the current user to the author of the page or post
* - anchor : uses the id stored in options with anchor_name
* - off : reset current user to the id before the changes
*
*/
function find_id_wih_option($option, $anchor_name) {
if ($option === 'author') {
$id = \CUSTER\get_author_id();
Custer::set_current_user_backup();
}
else if ($option === 'anchor') {
$id = \CUSTER\get_anchor_id($anchor_name);
Custer::set_current_user_backup();
}
else if ($option === 'off') {
$id = Custer::reset_current_user_backup();
}
return $id;
}
?>

View File

@@ -1,35 +0,0 @@
<?php
/*
Plugin Name: hggg_custer
Plugin URI:
Description: customize user : output infos on page, on email, and change current user id momentarly
Author: hugogogo
Version: 0.2.2
Author URI:
*/
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
include_once(plugin_dir_path(__FILE__) . '/custer_class.php');
include_once(plugin_dir_path(__FILE__) . '/get_user_id.php');
include_once(plugin_dir_path(__FILE__) . '/change_id.php');
include_once(plugin_dir_path(__FILE__) . '/format_user_infos.php');
include_once(plugin_dir_path(__FILE__) . '/user_infos.php');
include_once(plugin_dir_path(__FILE__) . '/filter_mail.php');
include_once(plugin_dir_path(__FILE__) . '/queries.php');
include_once(plugin_dir_path(__FILE__) . '/admin_menu.php');
include_once(plugin_dir_path(__FILE__) . '/admin_menu_toggle.php');
?>

View File

@@ -1,62 +0,0 @@
<?php
namespace CUSTER;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
*
*/
class Custer {
const USER_INFO_DATE_FORMAT = 'd/m/Y'; // for user_infos.php (date format : https://www.php.net/manual/fr/datetime.format.php)
const SLUG_TOOGLE_ADMIN_MENU = ['_name'=>'toogle_admin_menu_url_custer', 'toggle'=>'toggle', 'show'=>'show', 'hide'=>'hide'];
const OPTION_TOGGLE_MENU = ['_name'=>'toggle_admin_menu_option_custer', 'show'=>'show', 'hide'=>'hide'];
const OPTION_ANCHOR = 'custer_anchor_ids';
const QUERIES = [
'__author_page_url__',
'__user_post_url__',
'__admin_email__',
'__base_url__',
];
private static $_backup_current_user = null;
/*
* setter and getter for current user backup
*
*/
public static function set_current_user_backup() {
if (self::$_backup_current_user !== null)
return;
self::$_backup_current_user = get_current_user_id();
}
public static function get_current_user_backup() {
return self::$_backup_current_user;
}
public static function reset_current_user_backup() {
$backup_user = self::$_backup_current_user;
if ($backup_user === null) {
$backup_user = get_current_user_id();
}
self::$_backup_current_user = null;
return $backup_user;
}
}
?>

View File

@@ -1,140 +0,0 @@
<?php
namespace CUSTER;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* callback to provide the user info corresponding to the $$key_word$$
*
*/
function replace_words($matches, $user_id = null) {
if ($user_id !== null) {
$current_user = get_user_by('id', $user_id);
}
else if (is_user_logged_in()) {
$current_user = wp_get_current_user();
$user_id = get_current_user_id();
}
else {
return "";
}
if ($current_user === false) {
return "";
}
$query = $matches[1];
$result = \CUSTER\format_user_info($query, $user_id);
/*
* if result is array, take the first element (not ideal)
*
*/
if (is_array($result)) {
$result = reset($result);
}
/*
* if no match, return $$<query>$$
*
*/
if (empty($result)) {
return $matches[0];
}
return $result;
}
/*
* filter emails in the form-builder hook, before the wp_mail hook
* it receives the id of the user, no need to have the user still logged-in
*
*/
//function filter_email_fb_CIPF($reply_body, $post_array) {
// PLGNTLS_class::debug_infos();
// $id = $post_array['ID'];
// // pattern : anything surrounded by '$$', ex : $$value$$
// $pattern = '/\$\$(.*?)\$\$/';
//
// // inline callback, with 'use' to get the id
// $new_body = preg_replace_callback($pattern, function($matches) use ($id) {
// return replace_words_CIPF($matches, $id);
// }, $reply_body);
//
// return $new_body;
//}
//add_filter('df_confirmation_body', __NAMESPACE__.'\filter_email_fb_CIPF', 10, 2); // the receive an email
//add_filter('df_notification_body', __NAMESPACE__.'\filter_email_fb_CIPF', 10, 2); // the admin receive a notification
/*
* filter emails at the final point : the wp_mail hook
* it uses a callback that rely on the logged-in user
* it will works well most of the time, but it's possible
* that a user logged out before the email is sent
* or event that a different user has already logged in
*/
function filter_email_wp($args) {
// pattern : anything surrounded by '$$', ex : $$value$$
$pattern = '/\$\$(.*?)\$\$/';
error_log("email args: " . json_encode($args));
/*
email args: {
"to":"ruknafetri@gufum.com",
"subject":"My Custom Email Subject",
"message":"Hello, This is a test email sent from my WordPress plugin!",
"headers":["Content-Type: text\/html; charset=UTF-8"],
"attachments":[]
}
*/
$old_to = $args['to'];
$new_to = preg_replace_callback($pattern, __NAMESPACE__.'\replace_words', $old_to);
$args['to'] = $new_to;
$old_subject = $args['subject'];
$new_subject = preg_replace_callback($pattern, __NAMESPACE__.'\replace_words', $old_subject);
$args['subject'] = $new_subject;
$old_message = $args['message'];
$new_message = preg_replace_callback($pattern, __NAMESPACE__.'\replace_words', $old_message);
$args['message'] = $new_message;
return $args;
}
add_filter('wp_mail', __NAMESPACE__.'\filter_email_wp', 10, 1);
/*
* add this filter specifically for the new users, since otherwise we would not have their id
*
*/
function filter_regitration_email_CIPF($wp_new_user_notification_email, $user, $blogname) {
$user_id = $user->ID;
$pattern = '/\$\$(.*?)\$\$/';
$old_body = $wp_new_user_notification_email['message'];
$new_body = preg_replace_callback($pattern, function($matches) use ($user_id) {
return \CUSTER\replace_words($matches, $user_id);
}, $old_body);
$wp_new_user_notification_email['message'] = $new_body;
return $wp_new_user_notification_email;
}
add_filter('wp_new_user_notification_email', __NAMESPACE__.'\filter_regitration_email_CIPF', 22, 3);
?>

View File

@@ -1,136 +0,0 @@
<?php
namespace CUSTER;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* return the result
*
*/
function return_result($output, $if_empty = '') {
/*
* if empty, apply options, or default empty string ''
*
*/
if (empty($output)) {
$output = $if_empty;
}
/*
* if number, output a string
*
*/
if (is_numeric($output)) {
$output = (string)$output;
}
/*
* if not scalar, stringify output
*
*/
if (!is_scalar($output)) {
$output = json_encode($output, JSON_UNESCAPED_SLASHES);
}
return esc_html($output);
}
/*
* format the output
* if is acf, use acf default format
*/
function format_user_info($query, $user_id, $if_empty = '') {
$output_date_format = Custer::USER_INFO_DATE_FORMAT;
$special_queries = Custer::QUERIES;
$current_user = get_user_by('id', $user_id);
$is_acf = false;
/*
* if is special query
*
*/
if (in_array($query, $special_queries, true)) {
$trimmed_query = trim($query, '_');
$function_name = __NAMESPACE__.'\find_'.$trimmed_query;
$output = $function_name($user_id);
return \CUSTER\return_result($output, $if_empty);
}
/*
* check if it's an acf field
*
*/
$acf_id = 'user_'.$user_id;
$acf_object = get_field_object($query, $acf_id);
if ($acf_object !== false)
$is_acf = true;
/*
* if is acf, use the acf return format
* otherwise, use the default wordpress value
*
*/
if ($is_acf) {
$output = get_field($query, $acf_id);
}
else {
$output = $current_user->$query;
}
/*
* try to extract a single entity
* for example : ["string"] -> "string"
* or : ["", "string"] -> "string"
*
*/
$output = \CUSTER\extract_smallest_entity($output);
/*
* if is not acf
* check if is a date
* and format it
* to create a DateTime from a time stamp : https://stackoverflow.com/a/12039058/9497573
*
*/
if (!$is_acf) {
$timestamp = false;
if (is_string($output)) {
$timestamp = strtotime($output);
}
if ($timestamp !== false) {
//$date = new \DateTime('@' . $timestamp);
$date = date_create('@' . $timestamp);
$output = $date->format($output_date_format);
}
}
/*
* check options to format the result
*
*/
return \CUSTER\return_result($output, $if_empty);
}
?>

View File

@@ -1,69 +0,0 @@
<?php
namespace CUSTER;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* get the current author id
* return 0 if not found
* get id outside loop : https://wordpress.stackexchange.com/q/65548
*
*/
function get_author_id() {
if (is_author()) {
$user_id = get_queried_object_id();
}
else {
$user_id = get_the_author_meta('ID');
}
return $user_id;
}
/*
* get the anker user id
* return 0 if not found
*
*/
//function get_anchor_id($anchor_name) {
// $option_anchor = Custer::OPTION_ANCHOR;
//error_log("anchor_name:");
//error_log($anchor_name);
//
// $anchors = get_option($option_anchor);
//error_log("anchors:");
//error_log(json_encode($anchors));
// if ($anchors === false) {
//error_log("anchors === false");
// return 0;
// }
//
// if (isset($anchors[$anchor_name])) {
// $user_id = $anchors[$anchor_name];
// }
//
// if (empty($user_id)) {
// return 0;
// }
//
// return $user_id;
//}
?>

View File

@@ -1,85 +0,0 @@
<?php
namespace CUSTER;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
function get_queries($user_id, $if_empty) {
$special_queries = Custer::QUERIES;
$queries = array();
foreach($special_queries as $query) {
$queries[$query] = \CUSTER\format_user_info($query, $user_id, $if_empty);
}
return $queries;
}
function find_author_page_url($user_id) {
return get_author_posts_url($user_id);
}
/*
* find the posts of the user and return the first one
*
*/
function find_user_post_url($user_id) {
$user_post_url = '';
$args = array(
'post_type' => 'post',
'author' => $user_id,
'posts_per_page' => 1,
);
$posts = get_posts($args);
if (empty($posts)) {
$user_post_url = '';
}
else {
$query = reset($posts);
$user_post_url = get_permalink($query->ID);
}
return $user_post_url;
}
/*
*
*
*/
function find_admin_email($user_id) {
$admin_email = get_option( 'admin_email' );
return $admin_email;
}
/*
*
*
*/
function find_base_url($user_id) {
$base_url = home_url();
return $base_url;
}
?>

View File

@@ -1,195 +0,0 @@
<?php
namespace CUSTER;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
function extract_smallest_entity($value) {
$size = 1;
while (is_array($value) && $size === 1) {
// https://stackoverflow.com/questions/2216052/how-to-check-whether-an-array-is-empty-using-php#answer-20177855
$tmp_array = array_filter($value);
$size = count($tmp_array);
if ($size === 1) {
$value = reset($tmp_array);
}
}
return $value;
}
function merge_arrays(...$arrays) {
// extract first element
$new_array = array_shift($arrays);
// then loop through the next arrays
foreach ($arrays as $array) {
foreach ($array as $key => $value) {
$value = \CUSTER\extract_smallest_entity($value);
// if key does not already exist, simply add it and the value to new array
if (!isset($new_array[$key])) {
$new_array[$key] = $value;
continue;
}
// if key already exist, add a new key with a (number) suffix
$i = 1;
while (isset($new_array[$key.'('.$i.')'])) {
++$i;
}
$new_array[$key.'('.$i.')'] = $value;
}
}
uksort($new_array, 'strnatcasecmp');
return $new_array;
}
function output_list_front($array, $user_id, $if_empty) {
$output = '<ul>';
foreach ($array as $key => $value) {
if (str_starts_with($key, '_')) {
if (!str_starts_with($key, '__')) {
continue ;
}
}
$value = \CUSTER\format_user_info($key, $user_id, $if_empty);
$output .= '<li>';
$output .= '<span>';
$output .= $key;
$output .= ' : ';
$output .= $value;
$output .= '</span>';
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
/*
* shortcode to write user info of post author
* 0 or 1 argument, usage :
* - [custer_user_info] -> list of all availables infos
* - [custer_user_info user_email] -> display the email
* - [custer_user_info user_email user_login] -> display the email
* - [custer_user_info user_email id='logged_in'] -> display the email of the connected user
* - [custer_user_info user_email id='author'] -> display the email of the creator of the page/post
* - [custer_user_info user_email id='logged_in' important] -> display the email of the connected user, even if surrounded by shortcode 'custer_change_id'
* important keyword has no effect if id='author'
* - [custer_user_info user_email if_empty="value"] -> display 'value' if the user_email is empty or does not exist
*
*/
function current_user_infos($atts) {
$is_important = false;
/*
* choose the default id target :
* - logged_in
* - author
*
$id_is = 'logged_in';
*/
$id_is = 'author';
$if_empty = '';
/*
* has parameter 'id' ?
* has parameter important ?
* has parameter if_empty ?
* if yes, handle them and removes them from $atts
*
*/
if (is_array($atts)) {
if (isset($atts['id'])) {
$id_is = $atts['id'];
unset($atts['id']);
}
if ($id_is === 'logged_in') {
if (in_array('important', $atts)) {
$is_important = true;
$key = array_search('important', $atts);
unset($atts[$key]);
}
}
if (isset($atts['if_empty'])) {
$if_empty = $atts['if_empty'];
unset($atts['if_empty']);
}
}
/*
* should output all or a specific parameter ?
*
*/
$output_all = false;
if (empty($atts))
$output_all = true;
else if (count($atts) === 0)
$output_all = true;
/*
* get id according to attributes,
* and the atts of the other shortcode 'custer_change_id' if in use
*
*/
if ($id_is === 'logged_in') {
if ($is_important) {
$user_id = Custer::get_current_user_backup();
if ($user_id === null)
$user_id = get_current_user_id();
}
else {
$user_id = get_current_user_id();
}
}
else if ($id_is === 'author') {
$user_id = \CUSTER\get_author_id();
}
else {
return '';
}
/*
* output all the available parameters (for help)
*
*/
if ($output_all) {
$user_properties = (array) get_userdata($user_id)->data;
$user_metas = get_user_meta($user_id);
$queries = \CUSTER\get_queries($user_id, $if_empty);
$user_infos = \CUSTER\merge_arrays($user_metas, $user_properties, $queries);
return \CUSTER\output_list_front($user_infos, $user_id, $if_empty);
}
/*
* real purpose of this shortcode :
* only return the first argument
*
*/
if (is_array($atts))
$query = $atts[0];
else if (is_string($atts))
$query = $atts;
else
return '';
return \CUSTER\format_user_info($query, $user_id, $if_empty);
}
add_shortcode('custer_user_info', __NAMESPACE__.'\current_user_infos');
?>

1
plugins/fbpatch Submodule

Submodule plugins/fbpatch added at 551dd7eee4

View File

@@ -1,31 +0,0 @@
<?php
/*
Plugin Name: hggg_fbpatch
Plugin URI:
Description: some patchs for the form_builder plugin's bugs
Author: hugogogo
Version: 0.2.0
Author URI:
*/
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
include_once(plugin_dir_path(__FILE__) . '/php/fbpatch_class.php');
include_once(plugin_dir_path(__FILE__) . '/menu/admin_menu.php');
include_once(plugin_dir_path(__FILE__) . '/menu/admin_menu_toggle.php');
include_once(plugin_dir_path(__FILE__) . '/menu/menu_content.php');
\FBPATCH\Fbpatch::init_hook();
?>

View File

@@ -1,24 +0,0 @@
<!--
{"calculations":false,"hide_show":false}
-->
<style>
.patches_wrapper {
margin: 20px 5px;
}
</style>
<!-- https://developer.wordpress.org/reference/hooks/admin_post_action/ -->
<form method="POST" action="<?php echo admin_url( 'admin-post.php' ); ?>">
<input type="hidden" name="action" value="<?php echo $admin_post_patches; ?>">
<?php wp_nonce_field($nonce['_action'], $nonce['_name']); ?>
<?php foreach($patches as $patch => $options) {?>
<div class="patches_wrapper">
<input type="checkbox" id="<?php echo $patch; ?>" name="<?php echo $patch; ?>" <?php echo $options['checked'] === true ? "checked" : "" ?> />
<label for="<?php echo $patch; ?>"><b><?php echo $options['title']; ?> : </b><?php echo $options['description']; ?></label>
</div>
<?php } ?>
<input type="submit" value="send"/>
</form>

View File

@@ -1,70 +0,0 @@
function patch_form_calculation_CIPF() {
let form_calculation = document.querySelector('form.fb_form.multistep');
if (form_calculation === null)
return;
/*
* finds the input:checked in the element .calculate_field
* and trigger the event 'change' on it
* - this event 'change' is added by form builder in divi-form-calc-min.js :
* $(document).on(
* 'change',
* '.calculate_field input:not([type="hidden"]), .calculate_field select',
* function () {
* ...
* }
* );
*
*/
function trigger_change(element) {
/*
* jquery version
*
let inputs = $(element).find('input:checked');
inputs.trigger('change');
*/
/*
* js version
*
*/
let inputs = element.querySelectorAll('input:checked');
// loop through inputs and trigger 'change' event on each
inputs.forEach(function(input) {
// Triggering 'change' event
let change_event = new Event('change', {
bubbles: true,
cancelable: true,
});
input.dispatchEvent(change_event);
});
}
// create an observer on form to check if child nodes are modified
const observer_form = new MutationObserver(wait_for_calculation_class);
observer_form.observe(form_calculation, {
subtree: true,
attributes: true,
});
// observe mutations to see if they include the addition of class .calculate_field
// if the class is added, call the function that might trigger the change event on it
function wait_for_calculation_class(mutationsList) {
mutationsList.forEach((mutation) => {
// check if class where added
if (mutation.type !== 'attributes')
return;
if (mutation.attributeName !== 'class')
return;
// check if added class is .calculate_field
let target = mutation.target;
if (target.classList.contains('calculate_field')) {
// If the class is added, trigger the 'change' event
trigger_change(target);
}
});
}
}
patch_form_calculation_CIPF();

View File

@@ -1,29 +0,0 @@
let modal_wrapper_CIPF = document.querySelector('#de-fb-modal-wrapper-');
// create an observer on first #de-fb-modal-wrapper- to check if child nodes are added
const observer_CIPF = new MutationObserver(wait_for_close_button_CIPF);
observer_CIPF.observe(modal_wrapper_CIPF, {
subtree: true,
childList: true,
});
// observe mutations to see if they include the creation of the button .modal-close
// if the button is created, add an eventListener to it
function wait_for_close_button_CIPF(mutationsList) {
mutationsList.forEach((mutation) => {
// check if nodes were added
if (mutation.type !== 'childList')
return;
// check if added nodes includes the button .modal-close
let modal_close = document.querySelector('#de-fb-modal-wrapper- .modal-close');
if (modal_close !== null) {
modal_close.addEventListener("click", delete_modal_CIPF);
}
});
}
// when triggered, the .modal-close button will remove all childs from #de-fb-modal-wrapper-
function delete_modal_CIPF() {
modal_wrapper_CIPF.innerHTML = '';
}

View File

@@ -1,9 +0,0 @@
// https://stackoverflow.com/questions/12741517/how-to-make-url-validation-without-http-or-add-it-after-validation-passed/44848476#44848476
let old_url = jQuery.validator.methods.url;
jQuery.validator.addMethod( 'url', function(value, element) {
let url = old_url.bind(this);
return url(value, element) || url('http://' + value, element);
}, 'Please enter a valid URL'
);

View File

@@ -1,38 +0,0 @@
<?php
namespace FBPATCH;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* creates the plugin menu
*
*/
function plugin_menu() {
$menu_page_title = 'fbpatch';
$menu_title = 'fbpatch';
$menu_capability = 'manage_options';
$menu_slug = 'fbpatch-plugin';
$menu_callback = __NAMESPACE__.'\plugin_content';
\FBPATCH\toggle_menu($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback);
}
add_action('admin_menu', __NAMESPACE__.'\plugin_menu');
?>

View File

@@ -1,108 +0,0 @@
<?php
namespace FBPATCH;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
function toggle_menu($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback) {
$toggle_menu = Fbpatch::OPTION_TOGGLE_MENU;
if (false === get_option($toggle_menu['_name'])) {
add_option($toggle_menu['_name'], $toggle_menu['hide'], '', 'no');
}
$toggle = get_option($toggle_menu['_name']);
if ($toggle === $toggle_menu['hide']) {
remove_menu_page($menu_slug);
}
else if ($toggle === $toggle_menu['show']) {
add_menu_page($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback);
}
}
/*
* add link under the plugin in the plugins admin page
*
*/
function add_link_to_plugin($links) {
$slug_toggle = Fbpatch::SLUG_TOOGLE_ADMIN_MENU;
$toggle_menu = Fbpatch::OPTION_TOGGLE_MENU;
$toggle = get_option($toggle_menu['_name']);
if ($toggle === $toggle_menu['hide']) {
$links[] = '<a href="/'.$slug_toggle['_name'].'?'.$slug_toggle['toggle'].'='.$slug_toggle['show'].'">show menu</a>';
}
else if ($toggle === $toggle_menu['show']) {
$links[] = '<a href="/'.$slug_toggle['_name'].'?'.$slug_toggle['toggle'].'='.$slug_toggle['hide'].'">hide menu</a>';
}
return $links;
}
add_filter('plugin_action_links_fbpatch/fbpatch.php', __NAMESPACE__.'\add_link_to_plugin');
/*
* handle the toggle menu when url is reached
*
*/
function toggle_plugin_menu() {
$slug_toggle = Fbpatch::SLUG_TOOGLE_ADMIN_MENU;
$toggle_menu = Fbpatch::OPTION_TOGGLE_MENU;
global $wp;
$current_slug = $wp->request;
if ($current_slug !== $slug_toggle['_name']) {
return;
}
$show = null;
if (!isset($_GET)) {
$show = null;
}
else if (empty($_GET)) {
$show = null;
}
if (!isset($_GET[$slug_toggle['toggle']])) {
$show = null;
}
else if ($_GET[$slug_toggle['toggle']] === $slug_toggle['show']) {
$show = true;
}
else if ($_GET[$slug_toggle['toggle']] === $slug_toggle['hide']) {
$show = false;
}
if ($show === true) {
update_option($toggle_menu['_name'], $toggle_menu['show']);
}
else if ($show === false) {
update_option($toggle_menu['_name'], $toggle_menu['hide']);
}
$plugins_menu_url = admin_url('plugins.php');
wp_redirect($plugins_menu_url, 301);
exit;
}
add_action('template_redirect', __NAMESPACE__.'\toggle_plugin_menu');
?>

View File

@@ -1,104 +0,0 @@
<?php
namespace FBPATCH;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* the construction of the admin menu page
*
*/
function plugin_content() {
$patches = Fbpatch::get_patches();
$nonce = Fbpatch::NONCE;
$admin_post_patches = Fbpatch::ADMIN_POST_PATCH_CHOICE;
ob_start();
include(Fbpatch::root_path() . '/html/menu.html');
$html = ob_get_clean();
echo $html;
}
/*
* use this hook 'admin_post_{$action}' to receive a form post
* https://developer.wordpress.org/reference/hooks/admin_post_action/
*
* add the url to the action atrtibute of form, and the value of the action in an hidden input
* <form method="POST" action="<?php echo admin_url( 'admin-post.php' ); ?>">
* <input type="hidden" name="action" value="<?php echo $admin_post_patches; ?>">
*
*/
function patches_choice() {
$nonce = Fbpatch::NONCE;
if (!isset($_POST[$nonce['_name']])) {
\FBPATCH\redirect_menu_referer($_POST);
exit;
}
if (!wp_verify_nonce($_POST[$nonce['_name']], $nonce['_action'])) {
\FBPATCH\redirect_menu_referer($_POST);
exit;
}
/*
*
*
[24-Mar-2024 12:24:08 UTC] -> _POST {
"action":"add_patches",
"nonce_name":"7eeb560dc0",
"_wp_http_referer":"\/wp-admin\/admin.php?page=fbpatch-plugin",
"hide_show":"on"
}
*/
$pathes_on = array();
foreach($_POST as $key => $value) {
if ($value !== 'on') {
continue;
}
$pathes_on[] = $key;
}
Fbpatch::set_patches($pathes_on);
\FBPATCH\redirect_menu_referer($_POST);
}
add_action('admin_post_'.Fbpatch::ADMIN_POST_PATCH_CHOICE, __NAMESPACE__.'\patches_choice');
function redirect_menu_referer($post) {
if (!isset($post)) {
wp_redirect(admin_url(), 301);
exit;
}
if (is_null($post)) {
wp_redirect(admin_url(), 301);
exit;
}
if (empty($post)) {
wp_redirect(admin_url(), 301);
exit;
}
if (!isset($post['_wp_http_referer'])) {
wp_redirect(admin_url(), 301);
exit;
}
wp_redirect(home_url($post['_wp_http_referer']), 301);
exit;
}
?>

View File

@@ -1,216 +0,0 @@
<?php
namespace FBPATCH;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
*
*/
class Fbpatch {
const SLUG_TOOGLE_ADMIN_MENU = ['_name'=>'toogle_admin_menu_url_fbpatch', 'toggle'=>'toggle', 'show'=>'show', 'hide'=>'hide'];
const OPTION_TOGGLE_MENU = ['_name'=>'toggle_admin_menu_option_fbpatch', 'show'=>'show', 'hide'=>'hide'];
const NONCE = ['_name'=>'nonce_name', '_action'=>'action_name'];
const ADMIN_POST_PATCH_CHOICE = 'add_patches';
/*
* get path an url from plugin root
*
*/
public static function root_path() {
return plugin_dir_path(__DIR__);
}
public static function root_url() {
return plugin_dir_url(__DIR__);
}
/*
* ---------------------------------------------------------------------------
* OPTIONS
* these functions are used to select which patch is applied
*
*/
private static $_patches = [
'_name'=>'fbpatch_list_of_patches',
'calculations'=>['checked'=>true, 'title'=>'calculations', 'description'=>"afficher le total des calculs dès l'ouverture des formulaires"],
'hide_show' =>['checked'=>true, 'title'=>'masquer les offres', 'description'=>"permettre de masquer les offres en editant un formulaire, sans les supprimer"],
'modals' =>['checked'=>false, 'title'=>'modals', 'description'=>"permettre plusieurs modals sur une meme page"],
'urls' =>['checked'=>false, 'title'=>'urls', 'description'=>"permettre de rentrer des urls sans 'http://'"],
];
private static function set_option_patches() {
/*
* get the list of patches in option
* create option if needed
*
*/
$raw_patches_option = get_option(self::$_patches['_name']);
if (false === $raw_patches_option) {
add_option(self::$_patches['_name'], '', '', 'no');
}
$patches_option = unserialize($raw_patches_option);
if (empty($patches_option)) {
$patches_option = array();
}
/*
* if the option miss patches, add them
*
*/
foreach (self::$_patches as $patch => $data) {
if ($patch === '_name') {
continue;
}
if (isset($patches_option[$patch])) {
// updates the title and the description
$patches_option[$patch]['title'] = $data['title'];
$patches_option[$patch]['description'] = $data['description'];
}
else {
// add the option
$patches_option[$patch] = $data;
}
}
/*
* if the option has additional patches, delete them
*
*/
foreach ($patches_option as $patch => $data) {
if (isset(self::$_patches[$patch])) {
continue;
}
unset($patches_option[$patch]);
}
/*
* change the option list with the update patches
*
*/
ksort($patches_option);
$serialize_patches_option = serialize($patches_option);
update_option(self::$_patches['_name'], $serialize_patches_option);
}
public static function get_patches() {
self::set_option_patches();
$patches = get_option(self::$_patches['_name']);
return unserialize($patches);
}
public static function set_patches($patches_on) {
/*
* loop through the option list and update occording to the received list
*
*/
$raw_patches = get_option(self::$_patches['_name']);
$patches_option = unserialize($raw_patches);
foreach($patches_option as $patch => $data) {
if (in_array($patch, $patches_on)) {
$patches_option[$patch]['checked'] = true;
}
else {
$patches_option[$patch]['checked'] = false;
}
}
/*
* change the option list with the update patches
*
*/
ksort($patches_option);
$serialize_patches_option = serialize($patches_option);
update_option(self::$_patches['_name'], $serialize_patches_option);
}
/*
* this function will include the files of the different patches if they are set in the options
*
*/
public static function init_hook() {
$patches = Fbpatch::get_patches();
foreach($patches as $patch => $data) {
if ($data['checked'] === true) {
include_once(self::root_path() . '/php/patches/'.$patch.'.php');
}
}
}
/*
* ---------------------------------------------------------------------------
* HIDE SHOW
* to hide the chosen elements of the form without deleting the data in acf fields
*
*/
private static $_post_id = 0;
private static $_has_elements_to_skip = false;
private static $_skip_elements = array();
public static function is_post_id($id) {
return self::$_post_id == $id;
}
public static function is_to_skip($key) {
return in_array($key, self::$_skip_elements);
}
/*
* create an array of the elements to forget
*
*/
public static function set_post_elements_to_forget($id, $is_to_skip, $skip_array) {
self::$_post_id = $id;
self::$_has_elements_to_skip = $is_to_skip;
self::$_skip_elements = $skip_array;
}
/*
* if there is elements to skip, add the filter
*
*/
public static function init_skip_hook() {
if (true === self::$_has_elements_to_skip) {
add_filter("update_post_metadata", __NAMESPACE__.'\filter_elements_to_skip', 10, 5);
}
}
/*
* after insertion finished, removes filter and reset variables
*
*/
public static function end_skip_hook() {
if (true === self::$_has_elements_to_skip) {
remove_filter("update_post_metadata", __NAMESPACE__.'\filter_elements_to_skip');
}
self::$_post_id = 0;
self::$_has_elements_to_skip = false;
self::$_skip_elements = array();
}
}
?>

View File

@@ -1,27 +0,0 @@
<?php
namespace FBPATCH;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
*/
function add_form_builder_calculations_patch() {
$handle = 'form_builder_calculations_patch';
$url = Fbpatch::root_url() . '/js/calculations.js';
$dependencies = array('de_fb_calc');
$version = null;
$defer = true;
wp_enqueue_script($handle, $url, $dependencies, $version, $defer);
}
add_action('wp_enqueue_scripts', __NAMESPACE__.'\add_form_builder_calculations_patch', 22);
?>

View File

@@ -1,120 +0,0 @@
<?php
namespace FBPATCH;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* prevents the meta data to be updated directly in the meta_post_update filter
* because nor form_builder nor wp provides filters to modify post_array
*
*/
/*
* 305 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php
*
*/
function form_partner_before_process($form_id, $post_array, $form_type) {
//error_log("post_array: " . json_encode($post_array));
if (is_null($post_array) || empty($post_array)) {
//nothing to overwrite
return Fbpatch::set_post_elements_to_forget(0, false, array());
}
if (!isset($post_array['meta_input']) || empty($post_array['meta_input'])) {
//nothing to overwrite
return Fbpatch::set_post_elements_to_forget(0, false, array());
}
/*
* creating a meta_input list without the prefix
*
*/
$raw_meta_input = $post_array['meta_input'];
$meta_input = array();
$prefix = 'de_fb_';
foreach($raw_meta_input as $meta) {
if (substr($meta, 0, strlen($prefix)) === $prefix) {
$meta_input[] = substr($meta, strlen($prefix));
}
}
/*
* if there is meta to skip, init the variables
*
*/
$to_skip = array();
foreach($meta_input as $meta) {
if (!isset($post_array[$meta])) {
$to_skip[] = $meta;
}
}
if (empty($to_skip)) {
//nothing to overwrite
return Fbpatch::set_post_elements_to_forget(0, false, array());
}
return Fbpatch::set_post_elements_to_forget($post_array["ID"], true, $to_skip);
}
add_action('df_before_process', __NAMESPACE__.'\form_partner_before_process', 10, 3);
/*
* 506 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php
*
*/
function form_partner_before_insert($form_id, $post_array) {
//error_log("--form_id : " . json_encode($form_id));
//error_log("post_array : " . json_encode($post_array));
Fbpatch::init_skip_hook();
}
add_action('df_before_insert_post', __NAMESPACE__.'\form_partner_before_insert', 10, 2);
/*
* 235 : ../../../../wordpress_docker/volumes/wp_volume/wp-includes/meta.php
* $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
* "Returning a non-null value will effectively short-circuit the function."
* filter is added in Fbpatch class
*
*/
function filter_elements_to_skip($null, $object_id, $meta_key, $meta_value, $prev_value) {
if (false === Fbpatch::is_post_id($object_id)) {
return null;
}
if (false === Fbpatch::is_to_skip($meta_key)) {
return null;
}
return false;
}
/*
* 558 : ../../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php
* do_action( 'df_after_insert_post', $form_id, $post_id, $post_array );
*
*/
function after_form_inserted($form_id, $post_id, $post_array) {
//error_log("--form_id : " . json_encode($form_id));
//error_log("post_id: " . json_encode($post_id));
//error_log("post_array: " . json_encode($post_array));
Fbpatch::end_skip_hook();
}
add_action('df_after_insert_post', __NAMESPACE__.'\after_form_inserted', 10, 3);
?>

View File

@@ -1,25 +0,0 @@
<?php
namespace FBPATCH;
/**
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
function test_modal() {
$handle = 'form_builder_modals_patch';
$url = Fbpatch::root_url() . '/js/modals.js';
$dependencies = array();
$version = null;
$defer = true;
wp_enqueue_script($handle, $url, $dependencies, $version, $defer);
}
add_shortcode('test_modal', __NAMESPACE__.'\test_modal');
?>

View File

@@ -1,30 +0,0 @@
<?php
namespace FBPATCH;
/**
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/**
* in `wp-content/plugins/divi-form-builder/includes/DiviFormBuilder.php`
* also :
* - Undefined variable: min_length in /var/www/html/wp-content/plugins/divi-form-builder/includes/modules/FormField/FormField.php on line 5933
* - Undefined variable: use_icon in /var/www/html/wp-content/plugins/divi-form-builder/includes/modules/FormField/FormField.php on line 5984
*/
function add_my_jquery_patch() {
$handle = 'jquery_validator_url_patch';
$url = Fbpatch::root_url() . 'js/urls.js';
$dependencies = array('de_fb_validate');
$version = null;
$defer = true;
wp_enqueue_script( $handle, $url, $dependencies, $version, $defer);
}
add_action('wp_enqueue_scripts', __NAMESPACE__.'\add_my_jquery_patch');
?>

1
plugins/xtxpatch Submodule

Submodule plugins/xtxpatch added at e8ee5c898d

View File

@@ -1,50 +0,0 @@
<style>
h1 {
margin-left: 15px;
margin-top: 50px;
}
form {
margin: 15px;
border: 1px solid black;
padding: 20px;
}
form > div {
margin: 20px 0px;
}
.define_paypal_credentials_cipf input {
width: 100%;
}
form .vertical_wrapper {
display: flex;
flex-direction: column;
}
form textarea {
resize: vertical;
height: 120px;
}
</style>
<h1>email a la creation de compte</h1>
<?php echo Plgntls_xtx::open_form_option($option_register_email_name); ?>
<div class="define_email_registration vertical_wrapper">
<label for="define_email_registration_cipf">email : </label>
<textarea id="define_email_registration_cipf" name="email"><?php echo $option_register_email_value['email']; ?></textarea>
</div>
<!--
-->
<div class="send_email">
<input type="checkbox" id="send_email_prof_cipf" name="is_email_prof" <?php if ($option_register_email_value['is_email_prof'] === true) {echo 'checked';} ?> />
<label for="send_email_prof_cipf">envoyer un email à l'inscription des profs ?</label>
</div>
<div class="send_email">
<input type="checkbox" id="send_email_partner_cipf" name="is_email_partner" <?php if ($option_register_email_value['is_email_partner'] === true) {echo 'checked';} ?> />
<label for="send_email_partner_cipf">envoyer un email à l'inscription des partenaires ?</label>
</div>
<input type="submit" value="send"/>
</form>

File diff suppressed because it is too large Load Diff

View File

@@ -1,36 +0,0 @@
<?php
namespace XTXPATCH;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
*
*/
class Xtxpatch {
const ROLE_PROF = 'professeur__professeure';
const ROLE_PARTNER = 'partenaire';
const OPTION_REGISTER_EMAIL = [
'_name'=>'define_email_at_register_xtxpatch',
'_callback'=>__NAMESPACE__.'\define_register_email',
'_default'=>[
'email'=>
'Bonjour,
Vous venez de créer un compte sur le site carteprof.org avec lidentifiant : $$user_login$$
La FIPF',
'is_email_prof'=>true,
'is_email_partner'=>true,
],
];
}
?>

View File

@@ -1,136 +0,0 @@
<?php
namespace XTXPATCH;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* creates the plugin menu
*
*/
function add_plugin_menu() {
\Plgntls_xtx::add_menu(__NAMESPACE__.'\menu_content');
}
add_action('admin_menu', __NAMESPACE__.'\add_plugin_menu');
/*
* the construction of the admin menu page
*
*/
function menu_content() {
$option_register_email = Xtxpatch::OPTION_REGISTER_EMAIL;
$option_register_email_name = $option_register_email['_name'];
$option_register_email_value = \Plgntls_xtx::get_option_safe($option_register_email);
ob_start();
include(\Plgntls_xtx::root_path() . 'html/admin_menu.html');
echo ob_get_clean();
}
function define_register_email($request, $option_name, $option_value, $option_default) {
/*
* email
*
*/
$email = '';
if (isset($request['email'])) {
$email = $request['email'];
}
/*
* is email ?
*
*/
$is_email_prof = false;
if (isset($request['is_email_prof']) && $request['is_email_prof'] === 'on') {
$is_email_prof = true;
}
$is_email_partner = false;
if (isset($request['is_email_partner']) && $request['is_email_partner'] === 'on') {
$is_email_partner = true;
}
/*
* update the option with new values
*
*/
$option_data = array(
'email' => $email,
'is_email_prof' => $is_email_prof,
'is_email_partner' => $is_email_partner,
);
\Plgntls_xtx::update_option_safe($option_name, $option_data);
}
/*
* ../../../wordpress_docker/volumes/wp_volume/wp-includes/pluggable.php
* 2210 : $send_notification_to_user = apply_filters( 'wp_send_new_user_notification_to_user', true, $user );
*
*/
function send_registration_email($send, $user) {
$role_partner = Xtxpatch::ROLE_PARTNER;
$role_prof = Xtxpatch::ROLE_PROF;
$option_register_email = Xtxpatch::OPTION_REGISTER_EMAIL;
$email_option = \Plgntls_xtx::get_option_safe($option_register_email['_name']);
if (user_can($user, $role_prof)) {
$send = $email_option['is_email_prof'];
}
else if (user_can($user, $role_partner)) {
$send = $email_option['is_email_partner'];
}
return $send;
}
add_filter( 'wp_send_new_user_notification_to_user', __NAMESPACE__.'\send_registration_email', 10, 2);
/*
* use this filter to modify the message of the notification email
* you can use the specials custer expansions as $$<field>$$
* ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
* 24 : add_filter( 'wp_new_user_notification_email', array( __CLASS__, 'newuser_notification_email' ), 20, 3 );
*
*/
function filter_regitration_email($wp_new_user_notification_email, $user, $blogname) {
$option_register_email = Xtxpatch::OPTION_REGISTER_EMAIL;
$email_option = \Plgntls_xtx::get_option_safe($option_register_email['_name']);
$wp_new_user_notification_email['message'] = $email_option['email'];
return $wp_new_user_notification_email;
}
add_filter('wp_new_user_notification_email', __NAMESPACE__.'\filter_regitration_email', 21, 3);
?>

View File

@@ -1,29 +0,0 @@
<?php
/*
Plugin Name: hggg_xtxpatch
Plugin URI:
Description: some patchs for the xootix login/registration plugin
Author: hugogogo
Version: 0.1.1
Author URI:
*/
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
include_once(plugin_dir_path(__FILE__) . '/php/classes/plgntls_class.php');
include_once(Plgntls_xtx::root_path() . 'php/classes/xtxpatch_class.php');
include_once(Plgntls_xtx::root_path() . 'php/menu/admin_menu.php');
?>

Submodule private updated: 360ed6d219...d68983ea9b

273
todo.md Normal file
View File

@@ -0,0 +1,273 @@
## TODO :
---
### DEV
- [/] `0...` formbuilder mise a jour automatique ?
- [/] `0...` regarder où mettre les infos de debug dans le fichier wp-config pour eviter qu'elles soient ecrasees a la mise a jour
- [/] `0...` user info shortcodes : inverser fonctinnement par defaut 'author' ou 'logged-in'
- [/] `0...` user info shortcodes : pbm apostrophe backskash
- [/] `0...` meilleur gestion des champs acf et de leur valeur, tout mettre en constantes dans class
- [/] `0...` create menu for custer, that we can hide with an action on the plugin list
- [/] `0...` cipf plugin empeche validation de certains forms ?
- [/] `0...` ne pas continuer sur les anchors (pas besoin de modifier la page en tant qu'admin)
- [/] `0...` pourquoi la page de redirection ne marche pas ? -> mauvais hook
- [/] `0...` noter dans le code tous les endroits oú je fais appel a du css ecrit du coté de fabien, pour info pour le futur (dans l'ideal, je devrais tout faire dans le plugin) -> finalement je les ai changé
- [/] `0...` nouvelle installation creer des bugs : pas tres grave, il suffit de desactiver et reactiver nimporte quel plugin
- [/] `0...` creer champ recherche __image_profil_url__ -> acf renvoit deja l'url
- [/] `0...` schedule events
- [/] `0...` acf fields history -> `history`
- [/] `0...` j'ai cree un job cron daily
- [/] `0...` ajouté une tache cron dans infomaniak
- [/] `0...` ajouté une info dans wp-config.php : `define( 'DISABLE_WP_CRON', true );`
- [/] `0...` ajouté adresse ip du server pour maintenance infomaniak: 83.166.138.108 (trouvee avec la commande `hostname -I`)
- [/] `0...` resolu le pbm des dates : il faut bien penser a regler le site en francais, et mettre le format acf sur 'l d F Y' (L minuscule) (d: 01, ou alors j: 1)
### INSCRIPTION/CONNECTION
- [/] `0...` front end
- [/] `0...` par roles
- [/] `0...` autovalidation mail (profs)
- [/] `0...` validation admin (partners)
- [/] `0...` redirection
- [/] `0...` gerer le cas d'adresse email existante
- [/] `0...` front end
- [/] `0...` redirection
- [/] `0...` apres connexion : cacher bouton se connecter : 'conditional menus'
- [/] `0...` quand on change le mdp depuis le form front, ca marche avec la connexion via le formulaire de connexion de de formbuilder, mais pas avec celle de wp (attendre que fabien confirme le pbm)
- [/] `0...` affichage de l'oeil avec form builder parfois bug -> on n'utilise plus form builder pour ca
- [/] `0...` redirection (regarder ce que divi permet de faire)
- [/] `0...` changer mdp
- [/] `0...` popup login - lien email creation de mdp
- [/] `0...` popup login - attribuer role
- [/] `0...` option mdp oublié
- [/] `0...` popup login n'apparait pas sur chrome
- [/] `0...` plugin xootix : trouver un meilleur moyen d'identifier que c'est un partenaire qui s'inscrit (redirection methode bloque les autres redirections, c'est relou)
- [/] `0...` login avec xootix : champs password avec 'autocomplete=new-password' -> safari croit que c'est un nouveau mot de passe a creer -> g ecrit a plugin
- [/] `0...` cacher le champ 'remember me'
- [/] `0...` verifier que tous les liens fonctionnent (warning les liens pour les mots de passe oublies)
### ADMIN
- [/] `0...` admin et editor doivent avoir acces aux fiches profs
- [/] `0...` pourquoi la validation de la carte depuis fipf foncitonne meme quand le champs n'est pas relié ?
- [/] `0...` montrer barre admin pour la fipf
- [/] `0...` page prof vue par admin : lien telechargement photo
- [/] `0...` compte secretaria doit pouvoir modifier fiches partenaires
- [/] `0...` fipf regarde profil prof : ne voit pas le bouton pour valider le virement
- [/] `0...` gestion listes mdp offres partenaires -> cr en option
- [/] `0...` gestion listes mdp inscription carte -> geré a la main par diego (avec le champs observation)
- [/] `0...` admin et editor redirection emmene pas sur la bonne page
- [/] `0...` faire des options de recherches plus poussees pour le compte FIPF pour les profs
- [/] `0...` cacher infos admin fipf : Options personnelles, À propos du compte, Mots de passe dapplication, et Login/Signup
- [/] `0...` ecrire mode emplois custer queries
- [/] `0...` ajout class `.hide_for_fipfrole_cipf` pour les champs acf a cacher pour la fipf
- [/] `0...` ajout class `.hide_title_for_fipfrole_cipf` pour cacher le titre du groupe de champ (a rajouter sur n'importe quel champ du groupe)
- [/] `0...` ajout class `.hide_group_for_fipfrole_cipf` pour cacher tout le groupe de champ (a rajouter sur n'importe quel champ du groupe)
- [/] `0...` j'ai ajouté class `.textarea_full_width` sur historique
- [/] `0...` pour acf field 'historique' faire gaffe a cocher 'new lines'>'no formatting'
- [/] `0...` ajout de class css `readonly_acf`
### FRONT END
- [/] `0...` champs pre-remplis
- [/] `0...` editer champs
- [/] `0...` editions form multistep pbm ac images qui doivent revalider
- [/] `0...` dans les pages on ne peut pas montrer le champ email -> pourquoi ? que faire ?
- [/] `0...` what is honeypot captcha field ?
- [/] `0...` formbuilder emails notification et confirmation pbm
- [/] `0...` footer en bas de page
- [/] `0...` footer avec espace blanc en bas https://cipf.lejourdesprofs.org/inscription/
- [/] `0...` footer en bas de page pour page 404 (page non trouvee de members)
- [/] `0...` creer un shortcode pour recuperer les noms et prenoms de la personne connectee, comme pour lemail
- [/] `0...` form builder multiple modals don't work
- [/] `0...` plusieurs modals
- [/] `0...` creer carte en pdf : 'e2pdf' champs textes (fabien)
- [/] `0...` creer carte en pdf : 'e2pdf' champs images
- [/] `0...` empecher ouvrir pdf a chargement page
- [/] `0...` afficher le nom et le prénom : au lieu que le menu s'appel 'nom prenom', qu'ils s'appel 'hugo lamy' -> plus besoin
- [/] `0...` (abandonné) modal form builder - labels disparus
- [/] `0...` (abandonné) modal form builder - css cassé
- [/] `0...` (abandonné) modal form builder - icone de fermeture non modifiee
- [/] `0...` redirection dont' work
- [/] `0...` cacher flash page
- [/] `0...` quand fabien utilise les champs acf du calcul, meme a d'autres endroits, il a besoin du text, pas du nombre, donc voir une solution
- [/] `0...` verifier que le mappage des champs acf pour le calcul fonctionnent bien -> pas avec 0 en value (et apostrophe ?)
- [/] `0...` avant validation formulaire, revoir tous les choix
- [/] `0...` `cipf_user_info` : si pas la ressource, affiche actuellement 'false' (justificatif), afficher 'non' ? ou 'vide' ?
- [/] `0...` images upload : trouver lien site pour modifier photo en ligne
- [/] `0...` images upload : site exterieur ? https://www.img2go.com/fr/recadrer-image
- [/] `0...` images upload : redimensionner images crop -> on oublie
- [/] `0...` affichage aleatoire partenaires
- [/] `0...` champs textarea : resize none `https://www.w3schools.com/cssref/css3_pr_resize.php`
- [/] `0...` pbm affichage responsive hauteur de la barre menu
- [/] `0...` simplifier text editeur wysiwyg
- [/] `0...` creation roles par default : prof ? partenaire ? -> prof
- [/] `0...` voir avec fabien le css des menus
- [/] `0...` restrictions pages profs
- [/] `0...` restrictions pages partenaires
- [/] `0...` `$$etat_carte$$` et `$$livraison$$` reste en l'état dans le mail alors que `$$paiement$$` (par exemple) donne le bon résultat
- [/] `0...` css carte prof responsive mobile
- [/] `0...` pbm addresse email d'envois
- [/] `0...` supprimer images dans media a suppression compte
- [/] `0...` voir le pbm des conditions avec divi
- [/] `0...` personnes non admin qui essayent d'acceder a l'admin -> rediriger vers page accueil (au lieu de voir message 'interdit d'acces')
- [/] `0...` pbm : prof telecharger justificatif activite professionnelle : formats jpeg (jpEg) non acceptés (mais jpg oui)
### PROFS
- [/] `0...` creation prof, champ mdp ne bloque pas en cas d'erreur (trop court ou pas identiques) (~ mis a derniere etape)
- [/] `0...` message mauvais mdp n'apparait pas a l'etape finale (~ mis a derniere etape)
- [/] `0...` prof ne peut pas voir sa page -> acces interdit
- [/] `0...` menu prof -> la procédure de déconnexion
- [/] `0...` menu prof -> faire le lien vers le compte
- [/] `0...` remetre les champs de formulaire de la derniere etape a zero (accepter conditions utilisation, etc...)
- [/] `0...` e2pdf -> afficher image
- [/] `0...` sur page commender carte, si pas connecté, forcer popup connexion/inscription
- [/] `0...` page achat carte : afficher le bon message 'commander' ou 'renouveler'
- [/] `0...` pbm calcul champs formulaire
- [/] `0...` apres paiement, condition message reussite/echec
- [/] `0...` champs formulaires pas remis a zero, pourquoi ? et aussi remettre a zero le champ 10/15 (total 5 champs (+ virement))
- [/] `0...` bloc virement pour admin et editor, pas vu par profs
- [/] `0...` condition pour voir page prof : si choix paiement par viremenet, tant que virement pas recu (case non cochee par diego) alors pas possible de voir la page -> redirection vers page 'votre compte n'est pas encore validé'
- [/] `0...` sur page prof : condition afficher bouton 'renouveler'/'non disponible' -> plus besoin
- [/] `0...` resset cgv champe dans form prof
- [/] `0...` au calcul du prix dans paypal, prendre la bonne valeur meme si acf return est en label ou array
- [/] `0...` pbm prof form don't validate change in livraison
- [/] `0...` peut-etre verifier a ouverture de page profil si virement en attente invalide mais date valide -> passer en attente valide
- [/] `0...` ajouter !important sur les css des etapes pour surpasser d'autres css qui forcent un display pas none
- [/] `0...` page commander carte n'affiche pas renouveler carte
- [/] `0...` la mise a jour des etapes est toute cassee, apres paiement
- [/] `0...` faire gaffe bouton front valider virement : ne pas valider si pas de virement en cours
- [/] `0...` creation prof -> redirection commande
- [/] `0...` bouton front valider virement
- [/] `0...` ne pas calculer les prix, laisser formbuilder le faire
- [/] `0...` afficher les messages en fonction des etapes
- [/] `0...` some fields in form prof are not set second time or already set first time
- [/] `0...` empecher personnes deconnectees d'acceder a la page de commande
- [/] `0...` prof visite son profil : verifications sur les virements ? -> trop lourd de faire toutes les verifs a chaque fois
- [/] `0...` validation virement -> mettre a jour la date
- [/] `0...` Quand je renouvelle ma carte -> 0 ou 5 euros est décoché et quand je coche le bouton de validation disparaît
- [/] `0...` chez fabien, message 'paiement reussi/echoue' ne s'affiche pas
- [/] `0...` condition pour voir page prof : si premier paiement raté ? -> finalement, uniquement si nouveau
- [/] `0...` quand carte a expiree, changer champ date avec 'carte a renouveler' et couleur rose #ed009e
- [/] `0...` quand carte a expiree, changer champ 'telecharger' avec 'renouveler'
- [/] `0...` pour admin, gerer bouton 'activer compte' (inactif en attente de virement)
- [/] `0...` champ acf mettre a jour a l'achat et lors de rappels : carte pas valide -> etat 'commander'
- [/] `0...` penser a remettre champ acf 'compte actif' a zero a expiration de la carte
- [/] `0...` creer numero des cartes (yyyymmddx-A) A: carte generees sur le site / cartes imprimees lui-meme
- [/] `0...` dans formulaire prof achat carte, pourquoi le champ de livraison est remis a zero ?
- [/] `0...` sur page prof, vue par admin/editor : afficher lien du fichier certificat, au lieu de son numero
- [/] `0...` en attente de virement : si ancienne carte deja cree et encore valide, ne pas bloquer acces au compte
- [/] `0...` changer date de validite uniquement apres virement validé, pas avant
- [/] `0...` page prof si paiement en cours : pourquoi refaire passer a aucun ?
- [/] `0...` bouton suppresion de compte -> faire en sorte qu'il supprime le compte :p -> finalement non, gestion par admin
- [/] `0...` redirection sur la page du prof n'a pas lieu depuis "creer un compte" depuis le bouton "mon espace" de la page d'accueil
- [/] `0...` prof a cree carte et veut faire virement, mais il est redirigé vers formulaire quand il va sur son compte
- [/] `0...` resumé des options de formulaire avant validation
- [/] `0...` page 'compte en attente de validation' -> rediriger vers compte si actif
- [/] `0...` messages payements reussi ou echouer n'apparaissent plus
- [/] `0...` calculs prix pour paypal, bien prendre la valeur, pas le libellé, meme si on a reglé le retour sur libellé
- [/] `0...` la carte n'a pas de numéro
- [/] `0...` pour les cartes offertes (50 cartes par ex) : un code a usage unique ? -> ct une option
- [/] `0...` pas de message d'erreur si prof modifie son email par une adress existante
- [/] `0...` que faire en cas de virement : valider status virement dès validation formulaire ? si la personne n'a finalement pas envoyé son virement, et qu'elle se dit qu'elle va plutot payer par paypal ? si elle a envoyé son virement, qu'il n'est pas encore validé, est-ce qu'elle peut payer par paypal ? est-ce qu'elle risque de se tromper ?
- [/] `0...` paiement par virement du prof, fipf valide la carte : creer numero, ajouter 1 an, changer etat 'commande'->'renouvellement'
- [/] `0...` page profil prof, faire le check si la carte n'est pas expiree (le check si la carte est expiree fonctionne deja)
- [/] `0...` page profil prof, faire le check si la carte est expiree mais en attente de virement
- [/] `0...` apres validation premier form, mais avant paiement, la page front affiche 'renouveller' au lieu de acheter
- [/] `0...` profs roles peuvent lirent les articles privés et autre
### PARTENAIRES
- [/] `0...` virer image a suppression post
- [/] `0...` editer offres
- [/] `0...` affiche offre en fonction valeur de champs acf
- [/] `0...` css : pbm photo plusieurs offres partenaire (grid ? float ?)
- [/] `0...` css : menus droite partenaire : centrer dans la colonne
- [/] `0...` grid text vers le haut
- [/] `0...` text toute la largeur si pas d'image
- [/] `0...` creer css pour cacher champs de connexion des profs (nom et prenom) -> plus besoin
- [/] `0...` creer une redirection vers la page partenaire quand on valide le formulaire
- [/] `0...` menu partenaire -> faire un lien vers sa page
- [/] `0...` css image partenaires - occuper toute la largeur
- [/] `0...` css image partenaires - garder format 16/9
- [/] `0...` css image partenaires - pour cipf-prtnr-img * et post title img
- [/] `0...` a la creation d'un compte partenaire, creer automatiquement sa page avec son adress email ? -> finalement non, plutot rediriger vers formulaire de creation de page
- [/] `0...` find right role at creation account, without referer
- [/] `0...` si page partenaire n'existe pas, rediriger sur la page creation de page
- [/] `0...` shortcode user infos trouve pas author sur page partenaire
- [/] `0...` verifier si identification partenaire avec options fonctionne quand plusieurs connexions - non, trouver une autre methode
- [/] `0...` inscription partenaire role
- [/] `0...` email a validation de formulaire de creation de page ne contient pas l'url du partenaire
- [/] `0...` empecher les autres utilisateurs de voir le bouton de modificaiton de sa page partenaire
- [/] `0...` verifier les acces a la modification de page partenaire : pour l'instant tous les partenaires voient le bouton, et seuls les auteurs et les admins peuvent modifier, mais les admins ne devraient pas pouvoir modifier
- [/] `0...` sur page partenaire, offres, faire css pour simuler fonctionnement masquer/afficher (parce que les conditions divi perdent la memoire)
- [/] `0...` trouver une autre solution que `HTTP_REFERER` pour creer le role partenaire -> la redirection ?
- [/] `0...` ajouter option offre a duree determinee
- [/] `0...` css white-space: break-space des offres -> finalement acf gere ca
- [/] `0...` creer un mot cle special pour les emails pour creer un lien vers la page partenaire pour diego, similaires a __author_page__
- [/] `0...` voir comment cacher bouton modification pages partenaire sauf pour creator et admin et fipf (hook ? css ?)
- [/] `0...` voir comment empecher les gens d'acceder a la page de modificaiton des offres partenaires, sauf creator et admin et fipf
- [/] `0...` montrer la barre d'admin pour la fipf et les admins
- [/] `0...` empecher role fipf de supprimer les admins
- [/] `0...` sur page partenaire, si aucune offre, afficher un message (un bloc html preparé par fabien), et passer la page en brouillon pour qu'elle n'apparaisse plus sur la liste des partenaires
- [/] `0...` btn url à masquer si vide (fabien m'a ecrit ca, je ne suis pas sur de ce que ca veut dire, peut-etre un bouton sur la page partenaire ?)
- [/] `0...` empecher d'acceder a la page de creation de formulaire, uniquement celle de modification
- [/] `0...` un bouton publier ou ne pas publier ma page ? -> ajouter un bouton sous le bouton modifier la page, relié a un champs acf radio 'publier'/'masquer' -> toogle l'etat
- [/] `0...` partenaire, boutons publier / masquer : creer une class pour montrer un seul des deux
- [/] `0...` partenaire logo pbm
- [/] `0...` pbm redirection apres page partner changee en brouillon (url avec post id)
- [/] `0...` tous les partenaires peuvent voir les pages des autres partenaires en brouillon
### EMAILS
- [/] `0...` filtrer email formbuilder $$field$$
- [/] `0...` email, faire que diego puisse clicker sur un lien quand un prof fait un changement, qui l'emmene vers la profil du prof -> ajouter url de la page author du prof dans le shortcode user infos
- [/] `0...` some variables in email dont expand well (numbers ?)
- [/] `0...` filter email user info : si page author, diviFB ne retrouve pas l'id pour le prof, donc chercher le miens
- [/] `0...` filtrer les mails : dates ne s'affichent pas en dd/mm/yyyy (en tout cas pas toujours)
- [/] `0...` virer le mail de creation de mdp a creation de compte
- [/] `0...` emails envoyés depuis compte admin modifiant prof : les champs $$field$$ montrent la personne connectee, pas le prof -> finamelement les admins ne modifient pas les profs depuis le front
- [/] `0...` xootix pbm email en cas de reinitialisation du mdp : pas de liens
- [/] `0...` faire lien email pour que diego puisse voir la page partenaire ou prof qui a ete modifiee
- [/] `0...` pouvoir personnaliser les mails de inscription de xootix
- [/] `0...` email creation compte pour modifier mdp : manque le lien, et de toute maniere l'email est inutil -> possible d'empecher de l'envoyer ?
- [/] `0...` xootix pbm email liens : s'ils ne le resolvent pas, faire un filtre sur wp email
- [/] `0...` enlever liste de mail dans les mails smtp : This message is from a mailing list
- [/] `0...` pouvoir personnaliser les mails de oublie de xootix
- [/] `0...` cacher 'se souvenir de moi' sur la creation/inscription des comptes
- [/] `0...` pbm addresse email d'envois
- [/] `0...` form-builder change les urls des emails, c'est chelou -> en fait c'est brevo (sendinblue) qui fait ca, mais pourquoi, et comment l'eviter ?
- [/] `0...` profs : validation payment prof, envoyer email
- [/] `0...` profs : validation virement prof, envoyer email
- [/] `0...` changer l'adresse d'envois des emails
- [/] `0...` permettre d'afficher l'image de profil dans un email avec la balise <img>
- [/] `0...` emails, changer 'le compte' par 'la carte' pour expiration, et changer l'ordre
- [/] `0...` rajouter un email a diego en cas de problem de paiement
- [/] `0...` creation un groupe de champs acf prof/partner pour les emails
- [/] `0...` j'ai desactivé l'option qui force les 'emails from' dans wp-mail-smtp
- [/] `0...` j'ai ajouté un email qui peut s'envoyer a chaque fois que ce job tourne, pour alerte
- [/] `0...` changé contenu dans acf emails reminders pour ajouter chaque offres
### PAYMENT
- [/] `0...` mettre en place paiement paypal securise
- [/] `0...` valider paiement par prof
- [/] `0...` mettre a jour infos paiement et carte
- [/] `0...` - paiement : pbm mise en place date premier paiement
- [/] `0...` recuperer champs acf de somme totale `somme_a_regler`
- [/] `0...` date ajoute plusieurs annees
- [/] `0...` bloquer renouvellement de payement avant xx temps de la date d'echeance (ex: 30 jours)
- [/] `0...` redirection vers page ma carte, avec selector :active pour activer le message reussi ou raté
- [/] `0...` erreur dans le calcul du prix
- [/] `0...` tester paypal avec compte diego
- [/] `0...` condition fenetre moyens de paiements paypal ou virement
- [/] `0...` tester avec compte live
- [/] `0...` gerer les redirections
- [/] `0...` tester les differents formats de dates de acf
- [/] `0...` paiements : gerer les erreurs de mon code qui n'invalident pas les paiements
- [/] `0...` mieux gerer les cas d'erreur
- [/] `0...` paypal: notification payment reussi ou raté, ajouter numero de transaction -> `order_id`
- [/] `0...` bouton renouveller carte a 5€ -> ajouter bouton avec lien `/paiement/?prof_card_change=true` + css `.cipf_display_changer_carte`
### MENU
- [/] `0...` text payement reussi ou raté : ajouter texte dans menu ? garder le systeme des backticks ?
- [/] `0...` paypal : entrer les infos du compte
### SCHEDULE EVENTS
- [ ] `..2.` payments : supprimer order-id trop vieux
- [ ] `..2.` partners : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
- [ ] `..2.` partners : la gestion des offres à échéance
- [ ] `..2.` payments : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte
- [ ] `..2.` payments : schedule event pour supprimer les codes
- [ ] `..2.` payments : schedule event pour desactiver la carte
- [ ] `..2.` payments : faire rappels emails
### NEWSLETTER
- [ ] `..2.` voir comment implementer ca
- [ ] `..2.` comment savoir si une offre est nouvelle
- [ ] `..2.` comment gerer si un partenaire a plusieurs nouvelles offres