258 Commits

Author SHA1 Message Date
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
asus
15b315b4f3 emails ok, except for shcedule deletion, not yet 2024-04-03 14:53:34 +02:00
asus
d2b2967218 fixed error with automatically adding _name to option 2024-04-03 14:21:33 +02:00
asus
8ac16dc1f4 fixed error in loop option email with _name 2024-04-03 14:07:25 +02:00
asus
913165a056 completed email default messages 2024-04-03 13:58:03 +02:00
asus
a34b9173cf added special query base_url 2024-04-03 13:36:28 +02:00
asus
ffc47a0295 emails in admin menu and updating options seems to work 2024-04-03 13:19:12 +02:00
asus
59b9acc55e fixed small errors in plugin tools for options and menu 2024-04-03 12:37:04 +02:00
asus
1553490444 html presentation of admin menu for emails 2024-04-03 10:31:27 +02:00
asus
1d36093d9f wip emails front admin menu 2024-04-03 00:13:39 +02:00
asus
9abe24b3bb added another state of error in payment if the payment is a success but the treatment has an error 2024-04-02 23:39:27 +02:00
asus
9e903a2ecf defined the emails 2024-04-02 19:31:00 +02:00
asus
2329482aa1 wip filter email subject and sender, in addition to message 2024-04-02 19:12:16 +02:00
asus
7a5b1f63d3 Merge branch 'master' into emails 2024-04-02 18:58:49 +02:00
asus
67bebe4cfc custer query to find admin email 2024-04-02 18:55:59 +02:00
asus
ccb800c203 custer v0.2.2 includes queries in all output 2024-04-02 18:50:56 +02:00
asus
47360119e8 wip creating emails 2024-04-02 17:01:25 +02:00
asus
1f5fff26d6 - updated all occurences of Plgntls:: constantes for Cipf:: const
- update menu to use the new methods
2024-04-02 15:45:54 +02:00
asus
64dc0ffbc5 plgntls :
- added it to cipf plugin
- fixed an error in using _prefix not as static value
2024-04-02 15:44:33 +02:00
asus
bc06828093 wip event schedule 2024-04-02 13:24:22 +02:00
asus
86539d5c14 cipf v0.5.1 2024-04-01 23:33:49 +02:00
asus
b24f0f4210 updated notes 2024-04-01 23:14:42 +02:00
asus
fb146ecda4 - updated states to work for user_id and post_id
- added states for partner page state publish-draft
2024-04-01 23:09:22 +02:00
asus
4d7906be40 prof more checks at profil and when fipf validate transfert 2024-04-01 01:39:38 +02:00
asus
75205571fe cipf added css to hide parts of user profil when fipf see them 2024-03-31 23:38:04 +02:00
asus
0a30bca907 moved css from site to plugin 2024-03-31 20:53:26 +02:00
asus
5d4be76102 xtxpatch v 0.1.1 it works fine 2024-03-31 19:59:20 +02:00
asus
995e230e32 xtxpatch saves the email settings, still need to handle them 2024-03-31 19:25:39 +02:00
asus
b4745ff672 fixed error with option update 2024-03-31 19:09:22 +02:00
asus
3e2174a23f fixed error with unserialization of option 2024-03-31 17:59:17 +02:00
asus
7ad01a51ba more improves in optin gestion in class, automatic handling for basic cases 2024-03-31 17:34:10 +02:00
asus
ca13c5dccb menu and options tools added to plgntls class in plugin xtxpatch 2024-03-31 15:17:53 +02:00
asus
0f554444dd wip trying to get the options working in class 2024-03-31 01:45:25 +01:00
asus
1268dc56e3 wip creating options and menu in plgntls 2024-03-30 21:03:21 +01:00
asus
95c292c626 - added new plugin
- improved the plgntls class for this plugin
2024-03-30 14:57:40 +01:00
asus
2682f3bcd4 more improved in plgntls class to let add_to_front be added multiple times 2024-03-30 11:15:22 +01:00
asus
ade0be87ce 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-29 21:56:12 +01:00
asus
42e8cbc4e9 cipf v 0.4.4 added randomization for posts if < -1 2024-03-27 18:54:57 +01:00
asus
50c05df2b6 small fixes in html and css for admin menu cipf 2024-03-27 17:23:22 +01:00
asus
dd0d4dfbeb added message payments in admin menu 2024-03-27 17:18:14 +01:00
asus
a0018c903b fixed default email options 2024-03-27 14:47:58 +01:00
asus
8b70bea62a fixed error new prof choosing transfert can now access profil 2024-03-27 14:10:10 +01:00
asus
ab6d825724 can choose the email for registration, and wether to send one or not 2024-03-27 13:06:48 +01:00
asus
0808c83589 cipf v 0.4.1 wip trying to filter registration email 2024-03-27 09:38:19 +01:00
asus
0136be4316 wip filter email registration 2024-03-26 22:33:41 +01:00
asus
dbb6dc0d19 edited infos for todo and fabien 2024-03-25 22:14:59 +01:00
asus
27e1e69dfb partner edit button not visible by someone else 2024-03-25 22:11:46 +01:00
asus
90fb5bc0b6 custer v 0.1.6 added special request for post url 2024-03-25 21:42:33 +01:00
asus
44a5d93f77 cipf v0.3.13 paypal credentials now from admin menu 2024-03-25 18:32:03 +01:00
asus
c9f0522ecc wip paypal credentials output in menu, but they dont update yet 2024-03-25 16:21:33 +01:00
asus
4036f4300d updated options to make them not automatically loaded when added 2024-03-25 15:16:19 +01:00
asus
6ec621a20b fbpatch small fixes in options and hide-show 2024-03-25 13:07:12 +01:00
asus
8ebbb8bff2 fbpatch v 0.1.3 2024-03-25 11:17:16 +01:00
asus
f055a10d1c hide show post elements works 2024-03-25 11:13:16 +01:00
asus
85e5a34e42 wip first strategy to overwrite the formbuilder post update is a dead end 2024-03-24 23:43:06 +01:00
asus
569f4524d3 moved all aptches from cipf plugin to fbpatch 2024-03-24 17:06:10 +01:00
asus
1745d8754d adding patchs files according to form in menu 2024-03-24 16:16:55 +01:00
asus
28a1f7922d fixed error in fetch 2024-03-24 16:06:47 +01:00
asus
1856943bc9 wip adding patchs conditionnaly 2024-03-24 15:14:53 +01:00
asus
f882caf850 option list update with form 2024-03-24 15:05:00 +01:00
asus
1415fc14a2 wip patchs appears with informations, but are not yet updated 2024-03-24 13:23:00 +01:00
asus
94dbe05f87 wip patches added to options 2024-03-24 12:37:38 +01:00
asus
5c93938b53 wip nonce works now 2024-03-24 11:12:11 +01:00
asus
b05b5f375e wip nonce actually dont work 2024-03-23 23:51:35 +01:00
asus
46885fe10e wip the nonce for the menu works 2024-03-23 22:14:16 +01:00
asus
aae40be620 wip menu can now receive form with rest api, but no nonce 2024-03-23 18:25:43 +01:00
asus
b6d1d63b93 wip adding fbpatch plugin 2024-03-23 15:24:14 +01:00
asus
1fe5379845 v 0.3.12
- update date when transfert success
- role partner at creation ok
2024-03-22 19:10:35 +01:00
asus
cb9042a746 updated notes 2024-03-21 19:27:45 +01:00
asus
ab9afab160 wip partner register role : found how to add hidden fields 2024-03-21 19:26:32 +01:00
asus
66fbbfd586 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 16:10:07 +01:00
asus
782ae1b1d8 added paypal diego live credentials 2024-03-21 16:09:44 +01:00
asus
fcd7aae681 better handle transfert validation 2024-03-20 21:10:56 +01:00
asus
dc77784fef changed all optionnal user_id in first parameters to last parameters 2024-03-20 20:02:03 +01:00
asus
68905de5d5 fixed error when fipf see account it changes status accordgin to its own values 2024-03-20 19:31:54 +01:00
asus
c973af3131 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 18:58:46 +01:00
asus
b57fb6156c added important to css for display state, i am going to hell 2024-03-20 17:44:42 +01:00
asus
c69df03c75 update making card renew after paiement only if it was new 2024-03-20 17:07:41 +01:00
asus
8933b3d321 debug mode false 2024-03-20 17:06:44 +01:00
asus
abd9717fe0 fixed error in creating card number 2024-03-20 17:04:21 +01:00
asus
578502838e rollback to not calculating price 2024-03-20 15:29:34 +01:00
asus
b93a3298d2 new profs redirects to command 2024-03-20 14:44:19 +01:00
asus
0717a7d9e4 v 0.3.10 admin can validate payment from front 2024-03-20 11:42:22 +01:00
asus
58f287f00f fixed redirection preventing to edit in divi builder mode 2024-03-20 11:24:40 +01:00
asus
4eee697078 first step in making api keys modifiable in admin : using getter and setter instead of const 2024-03-20 10:10:48 +01:00
asus
f9788fa96e v 0.3.9 profs are mostly ok i suppose, didn't checked all situations 2024-03-20 01:58:37 +01:00
asus
0ab26c0b31 - hide admin bar for front user
- admin page redirects non admin users
2024-03-20 01:54:49 +01:00
asus
227d07fe46 fixed pbm find author id ouside loop 2024-03-20 01:54:22 +01:00
asus
33adb095e5 - creates redirect-home function
- restrict prof form to profs
- restrict paypal page for prof only
2024-03-20 01:02:46 +01:00
asus
0127d8db4c - most prof states shoud be ok
- redirection partner page creation
- user ids on checks states
- reset cgv
- restrict prof profil page
2024-03-20 00:26:39 +01:00
asus
61063cabd9 partner redirection to page creation 2024-03-19 23:48:40 +01:00
asus
1248c2339d fixed error in prof state for renew card 2024-03-19 22:47:00 +01:00
asus
d264e6c321 wip cahngin states 2024-03-19 22:06:17 +01:00
asus
4de26b79fc updated infos about states 2024-03-19 20:50:35 +01:00
asus
58d02708b9 updated acf find non init field value with new technique to init with temp value first 2024-03-19 20:15:26 +01:00
asus
cbfbfabd18 made the plugin dont redeclare font variable if used two times 2024-03-19 18:44:53 +01:00
asus
f7c805f22b v 0.3.4 states are now handled with specific functions for setting, getting, and adding css 2024-03-19 16:28:15 +01:00
asus
db1d16bd91 created css files for states displays 2024-03-19 15:59:16 +01:00
asus
2f0b15dd6f changed acf field access from _name to _key 2024-03-19 15:05:33 +01:00
asus
aad98c5188 most account states updating are working 2024-03-19 13:06:16 +01:00
asus
5010b70d79 created functions to handle all state changes 2024-03-19 12:37:16 +01:00
asus
f221e43807 added dates functions for prof card 2024-03-19 08:58:59 +01:00
asus
5e7ca4f0f1 update notes 2024-03-19 07:30:59 +01:00
asus
0b8b479584 wip account states 2024-03-19 07:28:17 +01:00
asus
e1f4799150 abandonned price calculation at payment time because of pbm with formbuilder 2024-03-19 07:27:37 +01:00
asus
9cda6f13bd wip registration partner role with xootix hook and hiden fields 2024-03-19 07:24:53 +01:00
asus
cabee4db30 v 0.1.4.2 temporary deactivate anchors 2024-03-19 07:11:45 +01:00
asus
ba1d3e3707 v 0.1.4.1 correction new DateTime in shortcode, conflict with namespace 2024-03-19 07:11:04 +01:00
asus
c1b687064f updated notes 2024-03-18 13:30:17 +01:00
asus
5be80d1566 v 0.3.3 partner registration detected with slug using options and without referer 2024-03-18 13:28:48 +01:00
asus
98dfb17bf4 change author id works for prof profil and prof form 2024-03-18 12:23:27 +01:00
asus
82b6593dd9 - v 0.3.2 : can hide or show admin menu 2024-03-17 23:00:39 +01:00
asus
fcb15c97d1 v 0.3.1
- reset cgv
- price works with all acf returns for radio buttons
- redirection works
2024-03-17 18:16:28 +01:00
asus
874736fd8a redirections whould work now 2024-03-17 17:59:48 +01:00
asus
c39a656ab1 price calculation now works whatever acf return is set 2024-03-17 17:59:27 +01:00
asus
a245bd4350 - 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 15:28:08 +01:00
asus
eaa45c4ed1 custer format output works with numbers 2024-03-17 14:52:42 +01:00
asus
70d8998a3f custer : changed namespace, now all function use it 2024-03-17 14:06:25 +01:00
asus
fc41f7d36b cipf v 0.2.9 : moved shortcodes change_id and user_info to another plugin, custer 2024-03-17 02:29:31 +01:00
asus
f9b245c39c custer v 0.1.1 : now fully working 2024-03-17 02:28:27 +01:00
asus
6ad1fb5137 created plugin custer, and removed shortcodes change_id and user_infos from cipf plugin 2024-03-17 02:27:28 +01:00
asus
494943e4f7 v0.2.8 wip can force the id of a user for a portion of page with shortcode 2024-03-15 13:50:27 +01:00
asus
6c7b269052 tried a fix on redirection without real page, by using template-redirection hook instead of init 2024-03-15 09:18:39 +01:00
asus
9ebce56025 wip trying to force the acf id that formbuilder will use 2024-03-14 23:28:37 +01:00
asus
70888d384c fixed dates format error 2024-03-14 18:35:21 +01:00
asus
0d6d475ce0 v 0.2.6 2024-03-14 15:27:52 +01:00
asus
4c81476336 changed profil redirection so it does not need a real page anymore 2024-03-14 15:07:50 +01:00
asus
30c84135ef Merge branch 'debug_routes' 2024-03-14 13:48:37 +01:00
asus
d0bfe90715 nop it wasn't my plugin's fault 2024-03-14 13:48:19 +01:00
asus
e14acfb739 wip i broke everyhting :p 2024-03-14 13:10:05 +01:00
asus
4220c34c7f updated notes 2024-03-14 12:32:35 +01:00
asus
76f2e8ba00 wip debug redirections 2024-03-14 12:31:31 +01:00
asus
ecc072e25b added redirection without need of a page, use it for paypal success or failure message already 2024-03-14 10:29:02 +01:00
asus
2f4a5bb9ef wip handle custom form submit 2024-03-14 01:18:31 +01:00
asus
12de8ee12f some improvments on shortcode user_info, to output the right secure string in most cases 2024-03-13 14:57:01 +01:00
asus
10ca070d81 - wip create role at registration
- upgraded shortcode user_infos to output acf format
2024-03-13 13:28:14 +01:00
asus
f6e092f67d - moved reset field function outside renew_card file
- created a patch for formbuilder calculation pbm
2024-03-12 21:53:32 +01:00
asus
38f9b0ba72 - 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 19:54:18 +01:00
asus
591add448f wip check offres for newsletter 2024-03-11 23:20:38 +01:00
asus
046b31579c changed all role occurences by a const 2024-03-11 00:02:55 +01:00
asus
4f4bfd1c88 card number id created 2024-03-10 23:12:20 +01:00
asus
c1944dbc39 added info in class about path construction 2024-03-10 22:53:15 +01:00
asus
1021d9bf71 - 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:37:38 +01:00
asus
9ee35b23bc - renew state : removed
- payment state : in acf
2024-03-10 14:51:47 +01:00
asus
b457ed119e changed meta field payment_status for acf field 2024-03-10 14:12:24 +01:00
asus
faefa98114 - added debug function
- fixed issues in acf fields use
2024-03-10 11:13:44 +01:00
asus
f3a9be5a89 wip upgrade and clean payment process 2024-03-09 22:03:22 +01:00
asus
fc3a205359 updates acf fields const values in class to avoid errors 2024-03-08 17:57:04 +01:00
asus
789a361871 moved all const in class 2024-03-08 09:23:51 +01:00
asus
022468c096 moved and updated reset fields into rebew file 2024-03-07 23:48:01 +01:00
asus
909a34cd37 renew page message are working 2024-03-07 23:27:20 +01:00
asus
9b5e44dfd3 changed plugin name to cipf 2024-03-07 22:35:39 +01:00
asus
be79310404 changed all instances of fipf to cipf 2024-03-07 22:32:50 +01:00
asus
f870f77a2c wip prof check page now handle the success message on paiement 2024-03-07 21:34:48 +01:00
asus
5e28bf3059 update payment validation by changing prof to active 2024-03-07 19:21:11 +01:00
asus
afd34e5296 updated som error in filter email for special query author page 2024-03-07 19:08:03 +01:00
asus
4916defcaa updated filter email to filter the author page special keyword 2024-03-07 19:03:42 +01:00
asus
31c3ed55f4 wip author page checks, waiting page redirection working 2024-03-07 17:50:45 +01:00
asus
d65af4cd43 - wip filter page prof
- upgraded user info shortcode to default behavior on author page
2024-03-07 17:05:55 +01:00
asus
b244b59deb small correction in user info 2024-03-07 15:13:16 +01:00
asus
60f46265c2 updated user info shortcode to output author page and format date 2024-03-07 14:51:10 +01:00
asus
b8fbd84d53 - payment : first date error corrected
- payment : added httpErrorException
- payment : error handling wip
- profil page restriction gives access to admin and editor
2024-03-07 10:26:11 +01:00
asus
2fb1ec35aa - improved payement paypal for date and other things 2024-03-06 23:44:46 +01:00
asus
1661f16aff wip payment kind of works with bugs 2024-03-06 13:53:47 +01:00
asus
917d51a097 - 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-05 17:22:11 +01:00
asus
620aa9329b added check for logged in user in filter email 2024-03-05 10:44:36 +01:00
asus
39c9f492dc upgraded email filter to filter also wp hook 2024-03-05 09:55:54 +01:00
asus
63cc1f28c0 created a new function to filter emails 2024-03-05 00:10:53 +01:00
asus
44e122d415 renamed formbuilder patch files 2024-03-04 08:52:18 +01:00
asus
cf9a020162 - added a reinit function for acf fields after form validation
- added a plugin version of the modal patch for form builder
2024-03-03 21:48:39 +01:00
asus
483c02a4c6 small improvement in print user infos list 2024-03-03 10:39:34 +01:00
asus
cae80d7d24 shortcode to get user infos 2024-03-03 01:37:10 +01:00
asus
8862bab1bd some more little codes for restrictions and registrations 2024-03-02 21:43:43 +01:00
103 changed files with 8658 additions and 4698 deletions

13
.gitmodules vendored
View File

@@ -1,6 +1,15 @@
[submodule "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"]
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

View File

@@ -1,4 +1,4 @@
# fipf 2024
# cipf 2024
- this project uses submodules recursively, so after cloning you need to do :
`git submodule update --init --recursive`

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

@@ -0,0 +1,368 @@
<?php
/*
Plugin Name: hggg_cipf
Plugin URI:
Description:
Author: hugogogo
Version: 0.5.15
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__) . '/plgntls_class.php');
/*
* general inclusions
// utils :
*/
include_once(Plgntls::root_path() . 'php/utils/globals.php');
include_once(Plgntls::root_path() . 'php/utils/console_log.php');
// paypal
include_once(Plgntls::root_path() . 'php/paypal/paypal.php');
// profs
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_handle_states.php');
// partners
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_form.php');
include_once(Plgntls::root_path() . 'php/partners_handle_offers.php');
// utils
include_once(Plgntls::root_path() . 'php/_utils_acf_fields.php');
include_once(Plgntls::root_path() . 'php/_utils_acf_dates.php');
include_once(Plgntls::root_path() . 'php/_utils_acf_disabled.php');
include_once(Plgntls::root_path() . 'php/_utils_redirections.php');
include_once(Plgntls::root_path() . 'php/_utils_display_css.php');
include_once(Plgntls::root_path() . 'php/_utils_checks_roles.php');
// actions
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
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_partner.php');
include_once(Plgntls::root_path() . 'php/admin_menu.php');
/*
*
*
*/
class Cipf {
/*
* const declarations
*
*/
// ACF
const ACF_CARD_STATE = ['_name'=>'etat_carte', 'new'=>'Commande', 'renew'=>'Renouvellement']; // radio button
const ACF_CARD_PAYMENT_METHOD = ['_name'=>'paiement', 'paypal'=>'Paypal', 'transfert'=>'Virement']; // radio button
const ACF_CARD_PRICE_CHOICE = ['_name'=>'tarif', 'low'=>'10', 'high'=>'15']; // radio button
const ACF_CARD_PRICE_DELIVERY = ['_name'=>'livraison', 'pdf'=>'0', 'post'=>'5']; // radio button
const ACF_PROF_IS_ACTIV = ['_name'=>'compte-actif', 'activ'=>'Actif', 'inactiv'=>'Inactif']; // radio button
const ACF_PROF_CGV = ['_name'=>'cgv', 'cgv'=>'cgv']; // checkbox
const ACF_CARD_PRICE_TOTAL = ['_name'=>'somme_a_regler']; // number
const ACF_CARD_NUMBER = ['_name'=>'numero_de_la_carte']; // number
const ACF_CARD_EXPIRATION = ['_name'=>'fin_de_validite']; // date picker
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_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_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
const META_PAYEMENT_STATUS = 'cipf_payement_status';
const META_ORDER_ID = 'cipf_order_id';
// SLUG
const SLUG_PROF_INACTIV = 'validation-en-cours';
const SLUG_COMMAND_CARD = 'commande';
const SLUG_PAGE_REDIRECTION = 'redirection_cipf';
const SLUG_PAYPAL_PAGE = 'paiement';
const SLUG_PAYPAL_FABRICATION = 'fabrication';
const SLUG_PAYPAL_REDIRECTION_SUCCESS = 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_PARTNER_REGISTRATION = 'compte-partenaire';
const SLUG_PARTNER_CREATE_PAGE = 'ma-page-partenaire';
// URL
const URL_BASE_REST_ROUTE = 'cipf_plugin/api/v1'; // for routes, in php/paypal/routes.php && php/admin_modif_prof.php
// QUERY
const QUERY_TOGGLE_PARTNER_PAGE = 'toggle_partner_page_cipf';
// PAYPAL
const PAYPAL_SBOX_API_BASE_URL = "https://api-m.sandbox.paypal.com";
const PAYPAL_LIVE_API_BASE_URL = "https://api-m.paypal.com";
const PAYPAL_HUGO_SBOX_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl";
const PAYPAL_HUGO_SBOX_CLIENT_SECRET = "EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-";
const PAYPAL_HUGO_LIVE_CLIENT_ID = "Aedn5e8z__hPBvKirqw5bwlhI9ChG8_N6c1xbgybYyBr4B4oP8uVzmVdH1QVKdPQKf6bWg7orPV4PDrO";
const PAYPAL_HUGO_LIVE_CLIENT_SECRET = "EGeGwfHGxHxsjnC-tH8W0IL4nN3_xlc3sXFRPCQOw5uUoWae3eOgghuDKMnZc5DVGTbP6yIjVJ1BaAra";
const PAYPAL_DIEGO_SBOX_CLIENT_ID = "AegZZ6vDrTBzUNGf-UOVoUwh51YU4cvjGGPQkOQ7gM3H2xij9Pdkf751WO1ZvLoFjqbeNN-M5F6WqrdL";
const PAYPAL_DIEGO_SBOX_CLIENT_SECRET = "ENH2n-trvWrs4B6IWdhl7NM_Wp-Rpyo5ONJJMjJFevGVJ2wtSdORPXFx-vPZ2RQGV0RUQzAp6qt4_qVn";
const PAYPAL_DIEGO_LIVE_CLIENT_ID = "Abp6y2Outx8bMsEQRXBjH7qYK7-sTHmCMWlmJcw0Ctl5c9XpNsbGt5Vl1tD1ZmFhuBGGjT8ec3FKoLCo";
const PAYPAL_DIEGO_LIVE_CLIENT_SECRET = "EFLFOATSMM1m9BZwfj209qAeYDrsH-ltcFnVBmyPAJM-KjQiMtUVDQNPeyikDO1Y41yMiKu_IoELp_vD";
//const PAYPAL_CLIENT_ID = self::PAYPAL_HUGO_LIVE_CLIENT_ID;
//const PAYPAL_CLIENT_SECRET = self::PAYPAL_HUGO_LIVE_CLIENT_SECRET;
//const PAYPAL_API_BASE_URL = self::PAYPAL_HUGO_LIVE_API_BASE_URL;
const PAYPAL_MESSAGE_SUCCESS = 'Paiement réussi, vous allez être redirigé-es vers votre espace';
const PAYPAL_MESSAGE_PROBLEM = "Paiement réussi, mais une erreure est survenue dans le traitement de la commande, si vous voyez que votre compte n'est pas mis à jour correctement, contactez la fipf directement";
const PAYPAL_MESSAGE_FAILURE = 'Paiement raté, vous allez être redirigé-es vers votre espace';
// ROLES
const ROLE_PROF = 'professeur__professeure';
const ROLE_PARTNER = 'partenaire';
const ROLE_FIPF = 'fipf';
const ROLE_ADMIN = 'administrator';
// SHORTCODES
// OPTIONS
const OPTION_PAYPAL = [
'_name'=>'cipf_paypal_credentials',
'_callback'=>'update_paypal_credentials_CIPF',
'_default' => [
'force_1_cent' =>false,
'is_sandbox' =>true,
'live_client_id' =>'Aedn5e8z__hPBvKirqw5bwlhI9ChG8_N6c1xbgybYyBr4B4oP8uVzmVdH1QVKdPQKf6bWg7orPV4PDrO',
'live_client_secret' =>'EGeGwfHGxHxsjnC-tH8W0IL4nN3_xlc3sXFRPCQOw5uUoWae3eOgghuDKMnZc5DVGTbP6yIjVJ1BaAra',
'sandbox_client_id' =>'AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl',
'sandbox_client_secret'=>'EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-',
],
];
const OPTION_PAYMENT = [
'_name'=>'cipf_payment_messages',
'_callback'=>'update_payment_messages_option_CIPF',
'_default'=>[
'success'=>
'Paiement réussi,
vous allez être redirigés vers votre espace',
'failure'=>
'Paiement échoué,
vous allez être redirigés vers votre espace',
'problem'=>
"Paiement réussi,
mais une erreur est survenue dans le traitement de la commande,
si vous voyez que votre compte n'est pas mis à jour correctement,
contactez la fipf directement",
],
];
const OPTION_EMAILS = [
'_name'=>'cipf_emails_option',
'_callback'=>'update_emails_settings_option_CIPF',
'_default'=>[
'payment_success'=>[
'name'=>'prof - le paiement a réussi',
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - paiement réussi]",
'notification_message'=>'paiement réussi de la part de $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - paiement réussi]",
'confirmation_message'=>"paiement réussi",
],
'payment_echec'=>[
'name'=>'prof - le paiement a echoué',
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - paiement echoué]",
'notification_message'=>'paiement echoué pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - paiement echoué]",
'confirmation_message'=>"votre paiement a echoué",
],
'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'=>[
'name'=>'prof - le virement a été validé',
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - virement validé]",
'notification_message'=>'virement validé pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - virement validé]",
'confirmation_message'=>"votre virement a été validé",
],
'change_card_success'=>[
'name'=>'prof - le paiement pour changer la carte a réussi',
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - paiement changer carte reussi]",
'notification_message'=>'paiement pour changer sa carte a réussi de la part de $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - paiement changement carte réussi]",
'confirmation_message'=>"paiement changement carte réussi",
],
'card_will_expire'=>[
'name'=>'prof - la carte va bientot expirer',
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - carte va expirer]",
'notification_message'=>'la carte va expirer pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'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__$$',
],
'account_deleted'=>[
'name'=>'prof - le compte a été supprimé',
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /prof - compte supprimé]",
'notification_message'=>'compte supprimé pour $$user_login$$ : $$__author_page_url__$$',
'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - compte supprimé]",
'confirmation_message'=>'votre compte a été supprimé sur $$__base_url__$$',
],
'offer_will_expire'=>[
'name'=>"partenaire - l'offre arrive bientot a expiration",
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /partenaire - offre va expirer]",
'notification_message'=>'offre va expirer pour $$user_login$$ : $$__user_post_url__$$',
'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'confirmation_subject'=>"[CIPF - offre va expirer]",
'confirmation_message'=>'une de vos offre va expirer, rendez-vous sur $$__base_url__$$',
],
'offer_expired'=>[
'name'=>"partenaire - l'offre partenaire a expirée",
'notification_send'=>'on',
'notification_from'=>'$$__admin_email__$$',
'notification_to'=>'$$__admin_email__$$',
'notification_subject'=>"[CIPF /partenaire - offre expirée]",
'notification_message'=>'offre expirée pour $$user_login$$ : $$__user_post_url__$$',
'confirmation_send'=>'on',
'confirmation_from'=>'$$__admin_email__$$',
'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é',
],
],
];
// ADMIN MENU
const SLUG_TOOGLE_ADMIN_MENU = ['_name'=>'toogle_admin_menu_url_cipf', 'toggle'=>'toggle', 'show'=>'show', 'hide'=>'hide'];
const TOGGLE_ADMIN_MENU = ['_name'=>'toggle_admin_menu_option_cipf', 'show'=>'show', 'hide'=>'hide'];
const ADMIN_POST_PAYPAL = 'paypal_credentials_CIPF';
const ADMIN_MENU_NONCE_PAYPAL = ['_name'=>'nonce_paypal_cipf', '_action'=>'action_admin_menu_paypal_cipf'];
const ADMIN_POST_EMAIL_REGISTRATION = 'email_registration_message_CIPF';
const ADMIN_MENU_NONCE_EMAIL_REGISTRATION = ['_name'=>'nonce_email_cipf', '_action'=>'action_admin_menu_email_registration_cipf'];
const ADMIN_POST_PAYMENT_MESSAGES = 'payment_messages_CIPF';
const ADMIN_MENU_NONCE_PAYMENT_MESSAGES = ['_name'=>'nonce_payment_cipf', '_action'=>'action_admin_menu_payment_messages_cipf'];
// FORMS
const FORM_PROF_COMMANDE_ID = 'prof_commande';
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
const CARD_RENEW_PERIOD = 31; // int : number of days before expiration when renew card start to be possible
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 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,3 @@
[class*='cipf_display_'] {
display: none !important;
}

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,4 @@
[class*='cipf_display_'].cipf_display_carte_commande { display: block !important; }
[class*='cipf_display_'].cipf_display_carte_commande.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

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_carte_renouvellement { display: block !important; }
[class*='cipf_display_'].cipf_display_carte_renouvellement.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_compte_carte_expiree { display: block !important; }
[class*='cipf_display_'].cipf_display_compte_carte_expiree.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_compte_carte_valide { display: block !important; }
[class*='cipf_display_'].cipf_display_compte_carte_valide.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_compte_doit_payer { display: block !important; }
[class*='cipf_display_'].cipf_display_compte_doit_payer.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_compte_en_attente_invalide { display: block !important; }
[class*='cipf_display_'].cipf_display_compte_en_attente_invalide.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_compte_en_attente_valide { display: block !important; }
[class*='cipf_display_'].cipf_display_compte_en_attente_valide.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_compte_nouveau_prof { display: block !important; }
[class*='cipf_display_'].cipf_display_compte_nouveau_prof.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_page_partenaire_brouillon { display: block !important; }
[class*='cipf_display_'].cipf_display_page_partenaire_brouillon.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_page_partenaire_publiee { display: block !important; }
[class*='cipf_display_'].cipf_display_page_partenaire_publiee.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_paiement_aucun { display: block !important; }
[class*='cipf_display_'].cipf_display_paiement_aucun.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_paiement_echec { display: block !important; }
[class*='cipf_display_'].cipf_display_paiement_echec.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_paiement_en_cours { display: block !important; }
[class*='cipf_display_'].cipf_display_paiement_en_cours.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_paiement_reussi { display: block !important; }
[class*='cipf_display_'].cipf_display_paiement_reussi.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_type_paypal { display: block !important; }
[class*='cipf_display_'].cipf_display_type_paypal.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,4 @@
[class*='cipf_display_'].cipf_display_type_virement { display: block !important; }
[class*='cipf_display_'].cipf_display_type_virement.cipf_flex { display: flex !important; }

View File

@@ -0,0 +1,59 @@
/*
* [/] Options personnelles,
* [/] À propos du compte,
* [/] Mots de passe dapplication,
* [/] Login/Signup
*/
/*
* 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 .form-table:has(.user-rich-editing-wrap) {
display: none;
}
/*
*
*
*/
form#your-profile h2:has(+ .form-table .user-description-wrap),
form#your-profile .form-table:has(.user-description-wrap) {
display: none;
}
/*
*
*
*/
form#your-profile #application-passwords-section {
display: none;
}
/*
*
*
*/
form#your-profile h2:has(+ .form-table.xoo-aff-form-table),
form#your-profile .form-table.xoo-aff-form-table {
display: none;
}

View File

@@ -0,0 +1,131 @@
h1 {
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;
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
.partenaire_propre_page_cipf {
display: none;
}

View File

@@ -0,0 +1,3 @@
div.partenaire_propre_page_cipf {
display: block;
}

View File

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

View File

@@ -0,0 +1,225 @@
<!-- https://developer.wordpress.org/reference/hooks/admin_post_action/ -->
<h1>paypal credentials</h1>
<?php echo Plgntls::open_form_option($option_paypal['_name'], 'post', 'cipf'); ?>
<div class="define_paypal_credentials_cipf vertical_wrapper_cipf">
<label for="paypal_live_client_id_cipf">live client id : </label>
<input type="text" id="paypal_live_client_id_cipf" name="live_client_id" value="<?php echo $option_paypal['live_client_id']; ?>" />
</div>
<div class="define_paypal_credentials_cipf vertical_wrapper_cipf">
<label for="paypal_live_client_secret_cipf">live client secret : </label>
<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 class="choose_sandbox_live_cipf choose_sandbox_cipf">
<input type="radio" id="paypal_credentials_sandbox" name="sandbox_or_live" value="sandbox" <?php if ($option_paypal['is_sandbox'] === true) {echo 'checked';} ?> />
<label for="paypal_credentials_sandbox">sandbox</label>
</div>
<div class="choose_sandbox_live_cipf choose_live_cipf">
<input type="radio" id="paypal_credentials_live" name="sandbox_or_live" value="live" <?php if ($option_paypal['is_sandbox'] === false) {echo 'checked';} ?> />
<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>
<input type="submit" value="send"/>
</form>
<!--
-->
<h1>messages apres paiement, avant redirection</h1>
<?php echo Plgntls::open_form_option($option_payment['_name'], 'post', 'cipf'); ?>
<div class="define_payment_message_cipf vertical_wrapper_cipf">
<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>
</div>
<div class="define_payment_message_cipf vertical_wrapper_cipf">
<label for="define_payment_message_failure_cipf">paiement echec : </label>
<textarea id="define_payment_message_failure_cipf" name="message_failure"><?php echo esc_html(stripslashes($option_payment['failure'])); ?></textarea>
</div>
<div class="define_payment_message_cipf vertical_wrapper_cipf">
<label for="define_payment_message_problem_cipf">paiement problem (dans le cas où le paiement est réussi, mais il y eu une erreur dans son traitement sur le site) : </label>
<textarea id="define_payment_message_problem_cipf" name="message_problem"><?php echo esc_html(stripslashes($option_payment['problem'])); ?></textarea>
</div>
<input type="submit" value="send"/>
</form>
<!--
'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_message'=>"donne l'argent",
-->
<h1>emails :</h1>
<?php echo Plgntls::open_form_option($option_emails['_name'], 'POST', 'emails_form_cipf cipf'); ?>
<?php
foreach($option_emails as $name => $email_options) {
if ($name === '_name') {
continue;
}
?>
<details class="set_email_options_cipf">
<summary><h2><?php echo esc_html(stripslashes($email_options['name'])); ?> :</h2></summary>
<div class="email_type_wrapper_cipf email_type_notification_wrapper_cipf">
<?php if (isset($email_options['notification_send'])) { ?>
<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'] === 'on') {echo 'checked';} ?> />
<label for="<?php echo esc_html(stripslashes($name)); ?>_notification_cipf">envoyer une notification ?</label>
</div>
<?php } ?>
<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">
<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'])); ?>" />
</div>
<?php } ?>
<?php if (isset($email_options['notification_subject'])) { ?>
<div class="vertical_wrapper_cipf">
<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'])); ?>" />
</div>
<?php } ?>
<?php if (isset($email_options['notification_message'])) { ?>
<div class="vertical_wrapper_cipf">
<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>
</div>
<?php } ?>
</div>
</div>
<div class="email_type_wrapper_cipf email_type_confirmation_wrapper_cipf">
<?php if (isset($email_options['confirmation_send'])) { ?>
<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'] === 'on') {echo 'checked';} ?> />
<label for="<?php echo esc_html(stripslashes($name)); ?>_confirmation_cipf">envoyer une confirmation ?</label>
</div>
<?php } ?>
<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">
<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'])); ?>" />
</div>
<?php } ?>
<?php if (isset($email_options['confirmation_message'])) { ?>
<div class="vertical_wrapper_cipf">
<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>
</div>
<?php } ?>
</div>
</div>
</details>
<?php } ?>
<input type="submit" value="send"/>
</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

@@ -0,0 +1,2 @@
<div id="paypal-button-container"></div>
<p id="result-message"></p>

View File

@@ -1,44 +1,39 @@
import { resultMessage } from './result_message.js';
import { PLGNTLS_fetch } from '../../utils/plgntls_fetch.js';
/**
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
*/
//async function createOrder() {
/*
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
*
*/
export async function createOrder() {
try {
//const fetch_create_url = PLGNTLS_data.fetch_url + "/fipf_plugin/api/v1/orders";
//console.log("fetch_create_url:", fetch_create_url);
//const response = await fetch(fetch_create_url, {
const response = await PLGNTLS_fetch('/fipf_plugin/api/v1/orders', {
const response = await PLGNTLS_fetch('/cipf_plugin/api/v1/orders', {
method: "POST",
headers: {
"Content-Type": "application/json",
//"X-WP-Nonce": PLGNTLS_data.rest_nonce,
},
// use the "body" param to optionally pass additional order information
// like product ids and quantities
body: JSON.stringify({
cart: [
{
id: "1234",
quantity: "1",
},
],
}),
});
const orderData = await response.json();
/*
* is it necessary since the error is catched according to the presence of id ?
* -> i think yes, because we want to know the type of http error, right ?
* -> actually the http error code will be shown in the console anyway, so...
*
if (!response.ok) {
throw new Error('Network response was not ok : ' + orderData.data.status + ' message : ' + orderData.message);
}
*/
if (orderData.id) {
return orderData.id;
} else {
}
else { // throw an error
const errorDetail = orderData?.details?.[0];
const errorMessage = errorDetail
? `${errorDetail.issue} ${errorDetail.description} (${orderData.debug_id})`
: JSON.stringify(orderData);
throw new Error(errorMessage);
}
} catch (error) {
@@ -52,7 +47,7 @@ export async function createOrder() {
*
// Call your server to set up the transaction
function createOrder(data, actions) {
const fetch_create_url = PLGNTLS_data.fetch_url + "/fipf_plugin/api/v1/orders";
const fetch_create_url = PLGNTLS_data.fetch_url + "/cipf_plugin/api/v1/orders";
console.log("fetch_create_url:", fetch_create_url);
return fetch(fetch_create_url, {
method: 'post'

View File

@@ -0,0 +1,62 @@
import { resultMessage } from './result_message.js';
/*
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
*
*/
export async function onApprove(data, actions) {
try {
const fetch_approve_url = PLGNTLS_data.fetch_url + "/cipf_plugin/api/v1/orders/" + data.orderID + "/capture";
const response = await PLGNTLS_fetch('/cipf_plugin/api/v1/orders/' + data.orderID + '/capture', {
method: "POST",
headers: {
"Content-Type": "application/json",
},
});
const orderData = await response.json();
// Three cases to handle:
// (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart()
// (2) Other non-recoverable errors -> Show a failure message
// (3) Successful transaction -> Show confirmation or thank you message
// + hugogogo treatment error but success order
const errorDetail = orderData?.details?.[0];
if (errorDetail?.issue === "INSTRUMENT_DECLINED") {
// (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart()
// recoverable state, per https://developer.paypal.com/docs/checkout/standard/customize/handle-funding-failures/
return actions.restart();
}
else if (errorDetail) {
// (2) Other non-recoverable errors -> Show a failure message
throw new Error(`${errorDetail.description} (${orderData.debug_id})`);
}
else if (!orderData.purchase_units) {
if (orderData.ERROR_TREATMENT) {
console.log("Capture result",orderData);
resultMessage(PLGNTLS_data.paypal_message_problem);
}
else {
throw new Error(JSON.stringify(orderData));
}
}
else {
// (3) Successful transaction -> Show confirmation or thank you message
// Or go to another URL: actions.redirect('thank_you.html');
const transaction =
orderData?.purchase_units?.[0]?.payments?.captures?.[0] ||
orderData?.purchase_units?.[0]?.payments?.authorizations?.[0];
console.log("Capture result",orderData);
resultMessage(PLGNTLS_data.paypal_message_success);
actions.redirect(PLGNTLS_data.paypal_redirection_success);
}
}
catch (error) {
console.error(error);
resultMessage(PLGNTLS_data.paypal_message_failure);
actions.redirect(PLGNTLS_data.paypal_redirection_failure);
}
}

View File

@@ -2,6 +2,8 @@
// Example function to show a result to the user. Your site's UI library can be used instead.
//function resultMessage(message) {
export function resultMessage(message) {
const buttons = document.querySelector("#paypal-button-container");
const container = document.querySelector("#result-message");
buttons.style.display = 'none';
container.innerHTML = message;
}

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

@@ -0,0 +1,177 @@
<?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 set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret) {
// Plgntls::debug_infos();
// $option_paypal = Cipf::OPTION_PAYPAL;
//
// $option_data = array();
// $option_data['is_sandbox'] = $is_sandbox;
// $option_data['client_id'] = $client_id;
// $option_data['client_secret'] = $client_secret;
//
// update_option($option_paypal['_name'], serialize($option_data), '', 'no');
//}
//function get_paypal_options_CIPF() {
// Plgntls::debug_infos();
// $option_paypal = Cipf::OPTION_PAYPAL;
//
// $paypal_credentials_serialized = get_option($option_paypal['_name']);
// if (false === $paypal_credentials_serialized) {
// add_option($option_paypal['_name'], serialize($option_paypal['_default']), '', 'no');
// $paypal_credentials_serialized = get_option($option_paypal['_name']);
// }
//
// return unserialize($paypal_credentials_serialized);
//}
function get_paypal_options_CIPF() {
Plgntls::debug_infos();
$option_paypal = Cipf::OPTION_PAYPAL;
return Plgntls::get_option_safe($option_paypal);
}
function get_paypal_client_id_CIPF() {
Plgntls::debug_infos();
$paypal_credentials = get_paypal_options_CIPF();
$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() {
Plgntls::debug_infos();
$paypal_credentials = get_paypal_options_CIPF();
$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() {
Plgntls::debug_infos();
$paypal_credentials = get_paypal_options_CIPF();
$paypal_base_url = '';
$is_sandbox = $paypal_credentials['is_sandbox'];
if ($is_sandbox) {
$paypal_base_url = Cipf::PAYPAL_SBOX_API_BASE_URL;
}
else {
$paypal_base_url = Cipf::PAYPAL_LIVE_API_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;
}
/*
* OPTIONS MESSAGES PAIMENT
*
*/
//function set_payment_messages_option_CIPF($success, $failure) {
// Plgntls::debug_infos();
// $option_payment = Cipf::OPTION_PAYMENT;
//
// $option_data = array();
// $option_data['success'] = $success;
// $option_data['failure'] = $failure;
//
// update_option($option_payment['_name'], serialize($option_data), '', 'no');
//}
//function get_payment_messages_option_CIPF() {
// Plgntls::debug_infos();
// $option_payment = Cipf::OPTION_PAYMENT;
//
// $payment_option_serialized = get_option($option_payment['_name']);
// if (false === $payment_option_serialized) {
// add_option($option_payment['_name'], serialize($option_payment['_default']), '', 'no');
// $payment_option_serialized = get_option($option_payment['_name']);
// }
//
// return unserialize($payment_option_serialized);
//}
function get_payment_messages_option_CIPF() {
Plgntls::debug_infos();
$option_payment = Cipf::OPTION_PAYMENT;
return Plgntls::get_option_safe($option_payment);
}
function get_payment_message_success_CIPF() {
Plgntls::debug_infos();
$payment_option = get_payment_messages_option_CIPF();
return $payment_option['success'];
}
function get_payment_message_failure_CIPF() {
Plgntls::debug_infos();
$payment_option = get_payment_messages_option_CIPF();
return $payment_option['failure'];
}
function get_payment_message_problem_CIPF() {
Plgntls::debug_infos();
$payment_option = get_payment_messages_option_CIPF();
return $payment_option['problem'];
}
?>

View File

@@ -0,0 +1,40 @@
<?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!');
}
/*
* randomize post output
* posts are to randomize if the query ask for a negative number of posts
* -1 is already used by worpdress to means ALL posts
* -> so this randomization will not work for 1 post
*
*/
function randomize_post_output_CIPF($query) {
Plgntls::debug_infos(2);
$posts_per_page = $query->get('posts_per_page');
if (is_null($posts_per_page)) {
return;
}
if ($posts_per_page >= -1) {
return;
}
Plgntls::debug_infos();
$query->set('orderby', 'rand');
}
add_action('pre_get_posts', 'randomize_post_output_CIPF');
?>

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

@@ -0,0 +1,128 @@
<?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 display_states_css_CIPF($user_id = null) {
Plgntls::debug_infos();
$css_for_states = array();
Plgntls::add_to_front(array('css/display_states/_default.css'));
/*
* etat paiement
* - 'en_cours'
* - 'reussi'
* - 'echec'
* - 'aucun'
*/
if (is_payment_success_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/paiement_reussi.css';
set_payment_nothing_CIPF($user_id);
}
else if (is_payment_failure_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/paiement_echec.css';
set_payment_nothing_CIPF($user_id);
}
else if (is_payment_started_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/paiement_en_cours.css';
}
else if (is_payment_nothing_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/paiement_aucun.css';
}
/*
* etat compte ('etat_compte') :
* 1. new . 'nouveau prof'
* 2. to_pay . 'doit payer'
* 3. valid . 'carte valide'
* 4. waiting_invalid . 'en attente invalide'
* 5. waiting_valid . 'en attente valide'
* 6. expired . 'carte expiree'
*/
if (is_account_new_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/compte_nouveau_prof.css';
}
else if (is_account_to_pay_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/compte_doit_payer.css';
}
else if (is_account_valid_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/compte_carte_valide.css';
}
else if (is_account_waiting_invalid_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/compte_en_attente_invalide.css';
}
else if (is_account_waiting_valid_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/compte_en_attente_valide.css';
}
else if (is_account_expired_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/compte_carte_expiree.css';
}
/*
* etat carte
* - 'Commande'
* - 'Renouvellement'
*
*/
if (is_card_new_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/carte_commande.css';
}
else if (is_card_renew_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/carte_renouvellement.css';
}
/*
* paiement
* - 'Paypal'
* - 'Virement'
*
*/
if (is_payment_method_paypal_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/type_paypal.css';
}
else if (is_payment_method_transfert_CIPF($user_id)) {
$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
* - 'Publiee'
* - 'Brouillon'
*
*/
if (is_page_publish_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/page_partenaire_publish.css';
}
else if (is_page_draft_CIPF($user_id)) {
$css_for_states[] = 'css/display_states/page_partenaire_draft.css';
}
Plgntls::add_to_front($css_for_states);
}
?>

View File

@@ -0,0 +1,188 @@
<?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!');
}
/*
* redirects to home
*
*/
function redirect_home_CIPF(){
Plgntls::debug_infos();
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers();
wp_redirect(home_url(), 301);
exit;
}
/*
* redirects new prof to commande
*
*/
function redirect_prof_command_CIPF(){
Plgntls::debug_infos();
$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
nocache_headers();
wp_redirect(home_url($slug_command_card), 301);
exit;
}
/*
* redirect users to profil
* if prof -> author page
* if partenaire -> post page || home page
*
*/
function redirection_profil_CIPF(){
Plgntls::debug_infos();
$role_prof = Cipf::ROLE_PROF;
$role_partner = Cipf::ROLE_PARTNER;
$slug_partner_create_page = Cipf::SLUG_PARTNER_CREATE_PAGE;
$partner_page_creation = home_url($slug_partner_create_page);
$current_user_id = get_current_user_id();
if (!is_user_logged_in()) {
redirect_home_CIPF();
}
/*
* if prof
*
*/
if (current_user_can($role_prof)) {
$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);
exit;
}
/*
* if partner
*
*/
if (current_user_can($role_partner)) {
$partner_post = has_partner_post();
if (false === $partner_post) {
$redirect_url = $partner_page_creation;
}
else {
$redirect_url = get_post_url_CIPF($partner_post->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);
exit;
}
else {
redirect_home_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
* no matter if it exists or not
*
* get current page url : https://wordpress.stackexchange.com/q/274569/226939
* -> global $wp; add_query_arg( $wp->query_vars, home_url( $wp->request ) );
*
*/
function redirection_page_CIPF(){
Plgntls::debug_infos(2);
$slug_page_redirection = Cipf::SLUG_PAGE_REDIRECTION;
/*
* why is_page($slug_page_redirection); didn't work ?
* or maybe it did ? it seemed to fail,
* maybe because the page does not actually exist
* anyway $wp->request works
*
*/
global $wp;
$current_slug = $wp->request;
if ($current_slug !== $slug_page_redirection) {
return;
}
Plgntls::debug_infos();
redirection_profil_CIPF();
}
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

@@ -0,0 +1,95 @@
<?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!');
}
/*
* hide admin bar if access a front page and is not an admin
*/
function hide_admin_bar_CIPF() {
Plgntls::debug_infos(2);
$role_admin = Cipf::ROLE_ADMIN;
$role_fipf = Cipf::ROLE_FIPF;
/*
* on admin page, don't hide bar of course
*
*/
if (is_admin()) {
return;
}
Plgntls::debug_infos();
/*
* check multiple user roles
* https://developer.wordpress.org/reference/functions/current_user_can/#div-comment-4083
*
*/
$current_user = wp_get_current_user();
$allowed_roles = array($role_admin, $role_fipf);
if (array_intersect($allowed_roles, $current_user->roles)) {
return;
}
show_admin_bar(false);
}
add_action('after_setup_theme', 'hide_admin_bar_CIPF');
/*
* prevent users to access admin page
*
*/
function restrict_admin_access_CIPF() {
Plgntls::debug_infos(2);
$role_admin = Cipf::ROLE_ADMIN;
$role_fipf = Cipf::ROLE_FIPF;
/*
* this concerns logged_in users, for admin page
*
*/
if (!is_user_logged_in()) {
return;
}
if (!is_admin()) {
return;
}
Plgntls::debug_infos();
/*
* some roles are allowed to access the admin panel
*
*/
$current_user = wp_get_current_user();
$allowed_roles = array($role_admin, $role_fipf);
if (array_intersect($allowed_roles, $current_user->roles))
return;
/*
* every other roles are redirected
*
*/
redirection_profil_CIPF();
}
//add_action('init', 'restrict_admin_access_CIPF', 100);
?>

View File

@@ -0,0 +1,261 @@
<?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 plugin
*/
function cipf_plugin_menu_CIPF() {
Plgntls::debug_infos();
Plgntls::add_menu('add_plugin_content_CIPF');
}
add_action('admin_menu', 'cipf_plugin_menu_CIPF');
function add_plugin_content_CIPF() {
Plgntls::debug_infos();
$option_paypal_object = Cipf::OPTION_PAYPAL;
$option_payment_object = Cipf::OPTION_PAYMENT;
$option_emails_object = Cipf::OPTION_EMAILS;
/*
* options
*
*/
//delete_option($option_paypal_object['_name']);
$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);
//delete_option($option_emails_object['_name']);
$option_emails = Plgntls::get_option_safe($option_emails_object, true);
Plgntls::add_to_front(array('css/menu/menu.css'));
ob_start();
include(Plgntls::root_path() . '/html/menu/cipf_menu.html');
$html = ob_get_clean();
echo $html;
}
function update_payment_messages_option_CIPF($request, $option_name, $option_data, $option_default) {
Plgntls::debug_infos();
/*
* success
* failure
*
*/
$success = '';
$failure = '';
$problem = '';
if (!isset($request['message_success'])) {
return;
}
if (!isset($request['message_failure'])) {
return;
}
if (!isset($request['message_problem'])) {
return;
}
$success = $request['message_success'];
$failure = $request['message_failure'];
$problem = $request['message_problem'];
/*
* update the option with new values
*
set_payment_messages_option_CIPF($success, $failure);
*/
$data = array(
'success' => $success,
'failure' => $failure,
'problem' => $problem,
);
Plgntls::update_option_safe($option_name, $data);
}
function update_paypal_credentials_CIPF($request, $option_name, $option_data, $option_default) {
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 = false;
if ($request['sandbox_or_live'] === 'sandbox') {
$is_sandbox = true;
}
else if ($request['sandbox_or_live'] === 'live') {
$is_sandbox = false;
}
/*
* ids
*
*/
$live_client_id = $request['live_client_id'];
$live_client_secret = $request['live_client_secret'];
$sandbox_client_id = $request['sandbox_client_id'];
$sandbox_client_secret = $request['sandbox_client_secret'];
/*
* update the option with new credentials
*
set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret);
*/
$data = array(
'force_1_cent' => $force_1_cent,
'is_sandbox' => $is_sandbox,
'live_client_id' => $live_client_id,
'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);
}
/*
* update emails
*
*/
function update_emails_settings_option_CIPF($request, $option_name, $option_data, $option_default) {
Plgntls::debug_infos();
/*
* first check if saved option has the same data as default option
*
*/
$new_option = update_option_with_default_CIPF($option_data, $option_default);
/*
* 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 update_option_with_default_CIPF($option_data, $option_default) {
Plgntls::debug_infos();
$new_option_values = array();
foreach ($option_default as $email_type => $email_default_options) {
if (!isset($option_data[$email_type])) {
$new_option_values[$email_type] = $email_default_options;
}
else {
$new_email_options = update_email_type_with_default_CIPF($option_data[$email_type], $email_default_options);
$new_option_values[$email_type] = $new_email_options;
}
}
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';
}
/*
* 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;
}
?>

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

@@ -0,0 +1,48 @@
<?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_user_profil_css_CIPF() {
Plgntls::debug_infos();
$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)) {
return;
}
/*
* for fipf viewing user profil
*
*/
Plgntls::add_to_front(array('css/fipf_user_profile.css'));
}
add_action('user_edit_form_tag', 'admin_user_profil_css_CIPF');
?>

View File

@@ -0,0 +1,109 @@
<?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!');
}
/*
* 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');
/*
* check if partner can access the form to create a new page
*
*/
function partner_form_creation_page_CIPF() {
Plgntls::debug_infos(2);
if (!is_partner_CIPF()) {
return;
}
if (!is_partner_form_creation_page_CIPF()) {
return;
}
Plgntls::debug_infos();
/*
* -> 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
*
*/
$is_edit_id = get_query_var('pid', false);
$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;
}
}
redirection_profil_CIPF();
}
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

@@ -0,0 +1,308 @@
<?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!');
}
/*
* 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_CIPF() {
Plgntls::debug_infos(2);
$role_partner = Cipf::ROLE_PARTNER;
if (!is_partner_CIPF()) {
return false;
}
if (!is_single()) {
return false;
}
Plgntls::debug_infos();
global $post;
if (is_null($post)) {
return false;
}
$current_post_author_id = (int)($post->post_author);
$current_user_id = (int)get_current_user_id();
if ($current_user_id !== $current_post_author_id) {
return false;
}
return true;
}
/*
* 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
*
*/
function partner_page_scripts_CIPF() {
Plgntls::debug_infos(2);
/*
* if on post, load css
* - to hide partner own stuff
* - for states
*
*/
if (!is_single()) {
return;
}
Plgntls::debug_infos();
Plgntls::add_to_front(array('css/partner_page.css'));
$post_id = get_the_ID();
display_states_css_CIPF($post_id);
/*
* then check if is partner own page
*
*/
if (!is_own_partner_CIPF()) {
return;
}
/*
* on partner own page, load css to show own stuff
*
*/
Plgntls::add_to_front(array('css/partner_page_own.css'));
}
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
*
*/
function toggle_partner_page_CIPF() {
Plgntls::debug_infos(2);
$toggle_partner_page = Cipf::QUERY_TOGGLE_PARTNER_PAGE;
/*
* check if :
* - is own partner
* - 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_CIPF()) {
return;
}
Plgntls::debug_infos();
$is_action_toggle = get_query_var('action', false);
if ($is_action_toggle !== $toggle_partner_page) {
return;
}
/*
* get the post id and object
*
*/
$post_id = get_the_ID();
$current_post = get_post($post_id);
if (is_null($current_post)) {
return;
}
/*
* toogle the status
*
*/
if ($current_post->post_status === 'publish') {
wp_update_post(array(
'ID' => $post_id,
'post_status' => 'draft',
));
set_page_draft_CIPF($post_id);
}
else if ($current_post->post_status === 'draft') {
wp_update_post(array(
'ID' => $post_id,
'post_status' => 'publish',
));
set_page_publish_CIPF($post_id);
}
/*
* redirects without the query
*
*/
$url = remove_query_arg('action');
wp_safe_redirect($url);
exit;
}
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);
/*
* early checks on partner page
*
*/
function page_partner_check_CIPF() {
Plgntls::debug_infos(2);
// is partner own page
if (!is_own_partner_CIPF()) {
return;
}
Plgntls::debug_infos();
$post_id = get_the_ID();
$current_post = get_post($post_id);
/*
* checks if the acf state field is set accrodingly to page state
*
*/
if ($current_post->post_status === 'publish') {
set_page_publish_CIPF($post_id);
}
else if ($current_post->post_status === 'draft') {
set_page_draft_CIPF($post_id);
}
}
add_action('wp', 'page_partner_check_CIPF', 11);
?>

View File

@@ -0,0 +1,71 @@
<?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!');
}
/*
* hook to add a field in the xootix form
* 30 : ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/templates/global/xoo-el-register-section.php
*
*/
function add_fields_register_CIPF($args) {
Plgntls::debug_infos();
$role_partner = Cipf::ROLE_PARTNER;
$slug_partner_registration = Cipf::SLUG_PARTNER_REGISTRATION;
$input_hidden_role = Cipf::INPUT_HIDDEN_ROLE;
/*
* compare current slug to partner-register slug
* if it match, add a hidden field
*
*/
global $wp;
$current_slug = $wp->request;
if ($current_slug === $slug_partner_registration) {
echo "<input type='hidden' name='$input_hidden_role' value='$role_partner'>";
}
}
add_action('xoo_el_register_add_fields', 'add_fields_register_CIPF');
/*
* filter to modify user before xootix create new user
* 437 : ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
*
* at registration, if form query is for partner
* -> change role to 'partenaire'
*
*/
function add_role_partners_CIPF($customer_data){
Plgntls::debug_infos();
$role_partner = Cipf::ROLE_PARTNER;
$input_hidden_role = Cipf::INPUT_HIDDEN_ROLE;
/*
* check query of form submit
* if contains parner, change role for partner
*
*/
if (!isset($_POST[$input_hidden_role])) {
return $customer_data;
}
if ($_POST[$input_hidden_role] === $role_partner) {
$customer_data['role'] = $role_partner;
}
return $customer_data;
}
add_filter('xoo_el_register_new_customer_data', 'add_role_partners_CIPF', 10, 1);
?>

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!');
}
/*
* 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');
/*
* early checks on payment page
*
*/
function payment_page_checks_CIPF() {
Plgntls::debug_infos(2);
$slug_paypal_page = Cipf::SLUG_PAYPAL_PAGE;
// check the slug
if (!is_page($slug_paypal_page)) {
return;
}
Plgntls::debug_infos();
// get the user id
$user_id = get_current_user_id();
// also reset change card for 5€
reset_acf_prof_change_card_CIPF();
}
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
*
*/
function payment_page_redirects_CIPF() {
Plgntls::debug_infos(2);
$slug_paypal_page = Cipf::SLUG_PAYPAL_PAGE;
$role_prof = Cipf::ROLE_PROF;
// don't redirect if it is the divi builder mode
if (et_fb_is_enabled()) {
return;
}
// check the slug
if (!is_page($slug_paypal_page)) {
return;
}
Plgntls::debug_infos();
/*
* if prof, don't redirect
* for everyone else, redirect
*
*/
if (current_user_can($role_prof)) {
return;
}
redirect_home_CIPF();
}
add_action('template_redirect', 'payment_page_redirects_CIPF');
/*
* time to upload some scripts and styles on prof profil page
*
*/
function payment_page_scripts_CIPF() {
Plgntls::debug_infos(2);
$slug_paypal_page = Cipf::SLUG_PAYPAL_PAGE;
// check the slug
if (!is_page($slug_paypal_page)) {
return;
}
Plgntls::debug_infos();
// get the user id
$user_id = get_current_user_id();
// enqueue files here
display_states_css_CIPF($user_id);
}
add_action('wp_enqueue_scripts', 'payment_page_scripts_CIPF');
?>

View File

@@ -0,0 +1,27 @@
<?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!');
}
include_once(Plgntls::root_path() . '/php/utils/http_errors.php');
include_once(Plgntls::root_path() . '/php/paypal/route_api_utils.php');
include_once(Plgntls::root_path() . '/php/paypal/user_can_pay.php');
include_once(Plgntls::root_path() . '/php/paypal/update_user_payment.php');
include_once(Plgntls::root_path() . '/php/paypal/shortcode.php');
include_once(Plgntls::root_path() . '/php/paypal/route_api_orders.php');
include_once(Plgntls::root_path() . '/php/paypal/route_api_orders_capture.php');
include_once(Plgntls::root_path() . '/php/paypal/routes.php');
include_once(Plgntls::root_path() . '/php/paypal/payment_page.php');
?>

View File

@@ -0,0 +1,145 @@
<?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!');
}
/*
* this function runs before the paiement, it initiate the order
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
*
* in this function and the insides functions,
* explicit errors are thrown with HttpException,
* otherwise it's an unexpected error to catch with Exception
*
*/
function handle_orders_request_CIPF($request_data) {
Plgntls::debug_infos();
// declaring outside the try..catch scope
$order_response = array();
/*
* - check if user can pay, according to conditions
* - process the order and get the response
* if it fails here : the order was not created
*
*/
try {
$can_pay = check_can_pay_CIPF();
if (is_wp_error($can_pay)) {
throw new HttpException('not allowed to pay : ' . $can_pay->get_error_message(), 403);
}
$order_response = create_order_CIPF();
$json_response = $order_response['json_response'];
$http_status_code = $order_response['http_status_code'];
}
catch (HttpException $error) {
$status_code = $error->getStatusCode();
$message = 'Failed to create order in server :' . $error->getMessage();
return new WP_REST_Response($message, $status_code);
}
catch (Exception $error) {
$message = 'Failed to create order in server :' . $error->getMessage();
return new WP_REST_Response($message, 500);
}
/*
* - add infos of the initiated order into user profil
* - return the created order to the front
* if it fails here : the order was created in paypal
* but a pbm occured in treating it with the user
*
*/
try {
update_user_pre_order_CIPF($json_response, 'start');
/*
* https://developer.wordpress.org/reference/classes/wp_rest_response/
* extends from https://developer.wordpress.org/reference/classes/wp_http_response/
* __construct( $data = null, $status = 200, $headers = array() )
*
*/
return new WP_REST_Response($json_response, $http_status_code);
}
catch (HttpException $error) {
$status_code = $error->getStatusCode();
$message = 'Order created, but failed in treatment :' . $error->getMessage();
return new WP_REST_Response($message, $status_code);
}
catch (Exception $error) {
$message = 'Order created, but failed in treatment :' . $error->getMessage();
return new WP_REST_Response($message, 500);
}
}
/*
* Create an order to start the transaction.
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_create
*
*/
function create_order_CIPF() {
Plgntls::debug_infos();
$paypal_api_base_url = get_paypal_api_base_url_CIPF();
$access_token = generate_access_token_CIPF();
$price = get_paypal_price_CIPF();
$url = $paypal_api_base_url . '/v2/checkout/orders';
$payload = array(
'intent' => "CAPTURE",
'purchase_units' => array(
array(
'amount' => array(
'currency_code' => "EUR",
'value' => $price,
),
),
),
);
$headers = array(
"Content-Type: application/json",
"Authorization: Bearer " . $access_token
// Uncomment one of these to force an error for negative testing (in sandbox mode only). Documentation:
// https://developer.paypal.com/tools/sandbox/negative-testing/request-headers/
// "PayPal-Mock-Response": '{"mock_application_codes": "MISSING_REQUIRED_PARAMETER"}'
// "PayPal-Mock-Response": '{"mock_application_codes": "PERMISSION_DENIED"}'
// "PayPal-Mock-Response": '{"mock_application_codes": "INTERNAL_SERVER_ERROR"}'
);
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Execute cURL session and get the response
$response_json = curl_exec($ch);
// in utils
$response = handle_json_response_CIPF($response_json, $ch);
// Close cURL session
curl_close($ch);
return $response;
};
?>

View File

@@ -0,0 +1,99 @@
<?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_orders_capture_request_CIPF($request) {
Plgntls::debug_infos();
$order_id = $request['orderID'];
// declaring outside the try..catch scope
$response_json = array();
/*
* ask paypal about the finished order
* update the client situation
* and return the response of paypal
*
* capture status : https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
* - COMPLETED
* - DECLINED
* - PARTIALLY_REFUNDED
* - PENDING
* - REFUNDED
* - FAILED
*
*/
try {
$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, 'end');
return new WP_REST_Response($json_response, $http_status_code);
}
catch (HttpException $error) {
$status_code = $error->getStatusCode();
$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);
}
catch (Exception $error) {
$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);
}
}
/**
* Capture payment for the created order to complete the transaction.
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture
*/
function capture_order_CIPF($order_id) {
Plgntls::debug_infos();
$paypal_api_base_url = get_paypal_api_base_url_CIPF();
$access_token = generate_access_token_CIPF();
$url = $paypal_api_base_url . '/v2/checkout/orders/' . $order_id . '/capture';
$headers = array(
"Content-Type: application/json",
"Authorization: Bearer " . $access_token
// Uncomment one of these to force an error for negative testing (in sandbox mode only). Documentation:
// https://developer.paypal.com/tools/sandbox/negative-testing/request-headers/
// 'PayPal-Mock-Response: {"mock_application_codes": "INSTRUMENT_DECLINED"}',
// 'PayPal-Mock-Response: {"mock_application_codes": "TRANSACTION_REFUSED"}',
// 'PayPal-Mock-Response: {"mock_application_codes": "INTERNAL_SERVER_ERROR"}'
);
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute cURL session and get the response
$response_json = curl_exec($ch);
// in utils
$response = handle_json_response_CIPF($response_json, $ch);
// Close cURL session
curl_close($ch);
return $response;
};
?>

View File

@@ -0,0 +1,129 @@
<?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!');
}
/*
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
*
*/
function handle_json_response_CIPF($response, $ch) {
Plgntls::debug_infos();
if ($response === false)
throw new HttpException('cURL error: ' . curl_error($ch), 502);
// Decode JSON response
$json_response = json_decode($response);
// https://stackoverflow.com/questions/2348152/detect-bad-json-data-in-php-json-decode
if ($json_response === null && json_last_error() !== JSON_ERROR_NONE) {
throw new HttpException('JSON decoding error: ' . json_last_error_msg(), 502);
}
// Return response data along with HTTP status code
return array(
'json_response' => $json_response,
'http_status_code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
);
}
function handle_response_CIPF($response) {
Plgntls::debug_infos();
try
{
// Decode JSON response
$json_response = json_decode($response);
return array(
'json_response' => $json_response,
'http_status_code' => http_response_code()
);
}
catch (Exception $err)
{
// Get error message from response
$error_message = $response->text();
throw new Exception($error_message);
}
}
/**
* Generate an OAuth 2.0 access token for authenticating with PayPal REST APIs.
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
* @see https://developer.paypal.com/api/rest/authentication/
*/
function generate_access_token_CIPF() {
Plgntls::debug_infos();
$paypal_client_id = get_paypal_client_id_CIPF();
$paypal_client_secret = get_paypal_client_secret_CIPF();
$paypal_api_base_url = get_paypal_api_base_url_CIPF();
/*
try
{
*/
if ( !$paypal_client_id || !$paypal_client_secret ) {
throw new HttpException("MISSING_API_CREDENTIALS", 403);
}
$credentials = $paypal_client_id . ":" . $paypal_client_secret;
$auth = base64_encode($credentials);
$url = $paypal_api_base_url . '/v1/oauth2/token';
$body = http_build_query(array('grant_type' => 'client_credentials'));
// Initialize curl
$ch = curl_init();
// Set curl options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . $auth,
));
/********************/
// Execute cURL session and get the response
$data_json = curl_exec($ch);
// in utils
$data = handle_json_response_CIPF($data_json, $ch);
// Close cURL session
curl_close($ch);
return $data['json_response']->access_token;
/********************/
/*
// Execute curl and get the response
$data_json = curl_exec($ch);
if ( $data_json === false)
throw new Exception('cURL error: ' . curl_error($ch));
// Close curl
curl_close($ch);
$data = json_decode($data_json);
return $data->access_token;
}
catch (Exception $error)
{
error_log("Failed to generate Access Token:");
error_log($error->getMessage());
}
*/
};
?>

View File

@@ -0,0 +1,34 @@
<?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!');
}
// handling routes and endpoints
// diff routes and endpoints : https://stackoverflow.com/q/56075017/9497573
function routes_endpoints_CIPF() {
Plgntls::debug_infos();
if (is_admin()) {
return;
}
$base_rest_route = Cipf::URL_BASE_REST_ROUTE;
register_rest_route($base_rest_route, '/orders', array(
'methods' => 'POST',
'callback' => 'handle_orders_request_CIPF',
));
register_rest_route($base_rest_route, '/orders/(?P<orderID>[a-zA-Z0-9]+)/capture', array(
'methods' => 'POST',
'callback' => 'handle_orders_capture_request_CIPF',
));
};
add_action('rest_api_init', 'routes_endpoints_CIPF');
?>

View File

@@ -0,0 +1,59 @@
<?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!');
}
/**
* call to paypal_shortcode_content()
*/
function paypal_shortcode_content_CIPF() {
Plgntls::debug_infos();
$slug_paypal_redirection_success = Cipf::SLUG_PAYPAL_REDIRECTION_SUCCESS;
$slug_paypal_redirection_failure = Cipf::SLUG_PAYPAL_REDIRECTION_FAILURE;
$paypal_client_id = get_paypal_client_id_CIPF();
$paypal_message_success = get_payment_message_success_CIPF();
$paypal_message_failure = get_payment_message_failure_CIPF();
$paypal_message_problem = get_payment_message_problem_CIPF();
$pp_client_id = $paypal_client_id;
$pp_sdk_currency = "EUR";
$pp_sdk_base_url = "https://www.paypal.com";
$pp_sdk_url = "{$pp_sdk_base_url}/sdk/js?client-id={$pp_client_id}&currency={$pp_sdk_currency}";
$paypal_redirection_success = home_url() . '/' . $slug_paypal_redirection_success;
$paypal_redirection_failure = home_url() . '/' . $slug_paypal_redirection_failure;
$added_to_front = Plgntls::add_to_front(
array(
$pp_sdk_url,
array("js/paypal/paypal.js", 'type'=>'module'),
"html/paypal/paypal.html",
),
compact (
'paypal_redirection_success',
'paypal_redirection_failure',
'paypal_message_success',
'paypal_message_failure',
'paypal_message_problem',
),
);
return $added_to_front;
}
add_shortcode('cipf_paypal_shortcode', 'paypal_shortcode_content_CIPF');
?>

View File

@@ -0,0 +1,235 @@
<?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!');
}
/*
* see documentation in private 'paypal.md'
* basically it check if the user who initiate the transaction
* is the same that finish it
*
* add_user_meta('user_id', 'cipf_order_id', 'aaaaaa');
* ['aaaaaa']
* add_user_meta('user_id', 'cipf_order_id', 'bbbbbb');
* ['aaaaaa', 'bbbbbb']
* add_user_meta('user_id', 'cipf_order_id', 'bbbbbb');
* ['aaaaaa', 'bbbbbb', 'bbbbbb']
* get_user_meta('user_id', 'cipf_order_id');
* ['aaaaaa', 'bbbbbb', 'bbbbbb']
* $del_ret = delete_user_meta('user_id', 'cipf_order_id', 'bbbbbb');
* ['aaaaaa'] - $del_ret === true
* $del_ret = delete_user_meta('user_id', 'cipf_order_id', 'bbbbbb');
* ['aaaaaa'] - $del_ret === false
*
*/
/*
*
*
*/
function update_user_pre_order_CIPF($message) {
Plgntls::debug_infos();
$acf_payment_status = Cipf::ACF_CARD_PAYMENT_STATE;
$order_id = $message->id;
$user_id = get_current_user_id();
/*
* 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
*
*/
set_acf_order_id_CIPF($order_id, $user_id);
/*
* create a meta field to check states of payements on prof author page :
* - 'started' -> at order creation
* - 'success' -> at capture success (on author page, it means success, then make it empty)
* - 'failure' -> at capture failure (on author page, it means failure, then make it empty)
* - 'nothing' -> output nothing on author page
*
*/
set_payment_started_CIPF($user_id);
}
/*
*
*
*/
function update_user_post_capture_CIPF($message) {
Plgntls::debug_infos();
$order_id = $message->id;
$user_id = get_current_user_id();
$status = null;
if (is_object($message) && isset($message->status)) {
$status = $message->status;
}
/*
* capture status : https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
* - COMPLETED
* - DECLINED
* - PARTIALLY_REFUNDED
* - PENDING
* - REFUNDED
* - FAILED
*/
/*
* delete order_id and update user
* -> is it necessary to delete order_id since we delete it when creating a new order ?
* -> it is at least necessary to find the user who did the purchase
*
*/
$user_id_to_update = find_user_with_order_id_CIPF($user_id, $order_id);
if ($user_id_to_update === false) {
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 {
failure_payment_for_user_CIPF($user_id_to_update, $order_id, $status);
}
}
/*
* things to do when a payment has failed
* failed payement means order status is not COMPLETED or PENDING
* it can be :
* - DECLINED
* - PARTIALLY_REFUNDED
* - REFUNDED
* - FAILED
* -> capture status : https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
* in any cases, the price was not paid
*
*/
function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
Plgntls::debug_infos();
$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);
/*
* if payment was only for card change
*
*/
if (is_acf_prof_change_card_CIPF($user_id)) {
reset_acf_prof_change_card_CIPF($user_id);
return;
}
/*
* else
*
*/
set_account_to_pay_CIPF($user_id);
}
/*
* things to do when a payment is a success
*
*/
function success_payment_for_user_CIPF($user_id, $order_id) {
Plgntls::debug_infos();
$acf_id = 'user_'.$user_id;
schedule_delete_orderid_CIPF($order_id, $user_id);
/*
* if payment was only for card change
*
*/
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);
if (is_card_new_CIPF($user_id)) {
set_card_number_CIPF($user_id);
set_card_renew_CIPF($user_id);
}
set_payment_success_CIPF($user_id);
set_account_valid_CIPF($user_id);
reset_emails_reminders_choices_CIPF($acf_id);
send_emails_CIPF('payment_success', $user_id);
}
/*
* @return mixed num - user_id
* bool false - if no match found
*
*/
function find_user_with_order_id_CIPF($current_user_id, $order_id) {
Plgntls::debug_infos();
$acf_order_id = Cipf::ACF_CARD_ORDER_ID;
$role_prof = Cipf::ROLE_PROF;
$user_metas = get_user_meta($current_user_id, $acf_order_id['_name'], false);
if (in_array($order_id, $user_metas)) {
return $current_user_id;
}
/*
* it means the current user didn't have this order_id
* so we look for another user
* https://developer.wordpress.org/reference/classes/WP_User_Query/prepare_query/
*
*/
$user = get_users(array(
'role' => $role_prof,
'meta_key' => $acf_order_id,
'meta_value' => $order_id,
'fields' => 'ID',
));
if (count($user) > 1) {
throw new HttpException('multiple users with same order_id', 502);
}
else if (count($user) === 1) {
return reset($user);
}
return false;
}
?>

View File

@@ -0,0 +1,150 @@
<?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!');
}
/*
* return value of an acf field, no matter if the field is set up to return label or value
*
*/
function get_acf_value_CIPF($acf_field, $acf_id) {
$field = get_field_init_CIPF($acf_field['_name'], $acf_id);
$field_object = get_field_object($acf_field['_name'], $acf_id);
$return_format = $field_object['return_format'];
$value = null;
if ($return_format === 'array') {
$value = $field['value'];
}
else if ($return_format === 'value') {
$value = $field;
}
else if ($return_format === 'label') {
$choices = $field_object['choices'];
$value = array_search($field, $choices);
}
return $value;
}
/*
* can pay in certain conditions
* @return true / wp_error
*
*/
function check_can_pay_CIPF() {
Plgntls::debug_infos();
$acf_card_payment_method = Cipf::ACF_CARD_PAYMENT_METHOD;
$acf_card_price_choice = Cipf::ACF_CARD_PRICE_CHOICE;
$acf_card_price_delivery = Cipf::ACF_CARD_PRICE_DELIVERY;
$acf_card_price_total = Cipf::ACF_CARD_PRICE_TOTAL;
$acf_card_expiration = Cipf::ACF_CARD_EXPIRATION;
$card_renew_period = Cipf::CARD_RENEW_PERIOD;
$current_user = wp_get_current_user();
$user_id = get_current_user_id();
$acf_id = 'user_' . $user_id;
/*
* check if payment is virement or immediat
*
$payement = get_field($acf_card_payment_method['_name'], $acf_id);
if (strtolower($payement) === 'virement') {
return false;
}
*/
/*
* ABANDONNED : bug with formbuilder
* calculate price
* update the price even if form builder already did it
* in case it was changed from admin pannel
*
$tarif = get_acf_value_CIPF($acf_card_price_choice, $acf_id);
$livraison = get_acf_value_CIPF($acf_card_price_delivery, $acf_id);
if ($tarif !== null && $livraison !== null) {
$price = $tarif + $livraison;
}
else {
$price = 0;
}
update_field($acf_card_price_total['_name'], $price, $acf_id);
*/
/*
* price is not empty or 0
*
*/
$price = get_field($acf_card_price_total['_name'], $acf_id);
if (empty($price)) {
return new WP_Error('cannot_purchase', "no price selected");
}
if ($price === 0) {
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
* or is paste
* or is less than 1 month
*
$validity_field = get_field_object($acf_card_expiration, $acf_id);
if ($validity_field === false)
return true;
$validity = $validity_field['value'];
$format_field = $validity_field['return_format'];
if (empty($validity))
return true;
$date_validity = date_create_from_format($format_field, $validity);
$date_now = date_create('today');
$diff = date_diff($date_now, $date_validity)->format('%R%a');
if ((int)$diff <= 0) {
// date end of validity in the past
return true;
}
else if ((int)$diff <= $card_renew_period) {
// date expiration is in less that renew period time (ex: 30 days)
return true;
}
else {
// date end of validity is in more than renew perdio (ex: 3 month)
return new WP_Error('cannot_purchase', "it's too soon to renew your card");
}
*/
return true;
}
?>

View File

@@ -0,0 +1,128 @@
<?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!');
}
/*
* actions after prof form commande is validated
*
*/
function prof_after_form_commande_CIPF($form_id, $post_array, $form_type) {
Plgntls::debug_infos(2);
$acf_account_state = Cipf::ACF_ACCOUNT_STATE;
$form_prof_commande_id = Cipf::FORM_PROF_COMMANDE_ID;
if ($form_prof_commande_id !== $form_id) {
return;
}
Plgntls::debug_infos();
//$user_id = get_current_user_id();
$user_id = $post_array['ID'];
/*
* reset cgv
*
*/
reset_acf_cgv_CIPF($user_id);
/*
* change status to :
* if paypal & new prof : 'to pay'
* if paypal & expired card : 'to_pay'
* if transfert $ expired card : 'waiting_invalid', reset transfert validation
* if transfert $ valid card : 'waiting_valid' , reset transfert validation
* if transfert $ neither valid nor expired state : 'waiting_invalid' , reset transfert validation
*
*/
if (is_payment_method_paypal_CIPF($user_id)) {
if (is_account_new_CIPF($user_id)) {
set_account_to_pay_CIPF($user_id);
}
if (is_account_expired_CIPF($user_id)) {
set_account_to_pay_CIPF($user_id);
}
}
else if (is_payment_method_transfert_CIPF($user_id)) {
if (is_account_expired_CIPF($user_id)) {
set_account_waiting_invalid_CIPF($user_id);
}
else if (is_account_valid_CIPF($user_id)) {
set_account_waiting_valid_CIPF($user_id);
}
else {
set_account_waiting_invalid_CIPF($user_id);
}
reset_acf_transfert_CIPF($user_id);
}
}
add_action('df_after_process', 'prof_after_form_commande_CIPF', 10, 3);
/*
* only profs can access this form
*
*/
function prof_form_restrictions_CIPF(){
Plgntls::debug_infos(2);
$slug_command_card = Cipf::SLUG_COMMAND_CARD;
$role_prof = Cipf::ROLE_PROF;
// don't redirect if it is the divi builder mode
if (et_fb_is_enabled()) {
return;
}
if (!is_page($slug_command_card)) {
return;
}
Plgntls::debug_infos();
/*
* if prof, don't redirect
* for everyone else, redirect
*
*/
if (current_user_can($role_prof)) {
return;
}
redirect_home_CIPF();
}
add_action('template_redirect', 'prof_form_restrictions_CIPF');
/*
* enqueue scripts and styles on page prof
*
*/
function renew_page_filter_message_CIPF(){
Plgntls::debug_infos(2);
$slug_command_card = Cipf::SLUG_COMMAND_CARD;
if (!is_page($slug_command_card))
return;
Plgntls::debug_infos();
$user_id = get_current_user_id();
display_states_css_CIPF($user_id);
}
add_action('wp_enqueue_scripts', 'renew_page_filter_message_CIPF');
?>

View File

@@ -0,0 +1,230 @@
<?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!');
}
/*
* if the acf field for transfert validation is checked,
* it means we need to validate the transfert
*
*/
function handle_transfert_validation_CIPF($user_id) {
Plgntls::debug_infos();
$acf_id = 'user_'.$user_id;
/*
* check and reset the acf fielf for transfert
*
*/
if (false === is_transfert_success_CIPF($user_id)) {
return;
}
reset_acf_transfert_CIPF($user_id);
/*
* if the account is not in transfert state, nothing to do
*
*/
if (false === is_account_waiting_transfert_CIPF($user_id)) {
return;
}
/*
* set account valid
* create card number
* add one year
* change state 'commande'->'renouvellement'
*
*/
set_account_valid_CIPF($user_id);
update_card_date_expiration_CIPF($user_id);
set_card_number_CIPF($user_id);
set_card_renew_CIPF($user_id);
reset_emails_reminders_choices_CIPF($acf_id);
send_emails_CIPF('transfert_success', $user_id);
}
/*
* if card expire, makes some changes
*
*/
function handle_card_expire_CIPF($user_id) {
Plgntls::debug_infos();
$acf_id = 'user_'.$user_id;
if (false === isset_acf_card_expiration_CIPF($user_id)) {
return;
}
if (is_card_date_expired_CIPF($user_id)) {
if (is_account_waiting_transfert_CIPF($user_id)) {
set_account_waiting_invalid_CIPF($user_id);
}
else {
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 {
if (is_account_waiting_transfert_CIPF($user_id)) {
set_account_waiting_valid_CIPF($user_id);
}
else {
set_account_valid_CIPF($user_id);
}
reset_emails_reminders_box_CIPF('account_deletion', $acf_id);
unset_email_reminder_choice_CIPF('card_expired', $acf_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

@@ -0,0 +1,155 @@
<?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!');
}
/*
* actions after prof form transfert validation is processed
*
*/
function prof_after_form_transfert_validation_CIPF($form_id, $post_array, $form_type) {
Plgntls::debug_infos();
$acf_account_state = Cipf::ACF_ACCOUNT_STATE;
$form_prof_transfert_id = Cipf::FORM_PROF_TRANSFERT_ID;
if ($form_prof_transfert_id !== $form_id) {
return;
}
//$user_id = get_current_user_id();
$user_id = $post_array['ID'];
// the check is not really connected to the form, it check the acf value, whatever the form value is, the form validation is just a trigger for this check
handle_transfert_validation_CIPF($user_id);
}
add_action('df_after_process', 'prof_after_form_transfert_validation_CIPF', 10, 3);
/*
* early checks on profil page
*
*/
function prof_profil_check_CIPF() {
Plgntls::debug_infos(2);
// is an author page
if (!is_author())
return;
Plgntls::debug_infos();
// the way to find the id of the author of an author_page
$author_id = get_queried_object_id();
/*
* in case event didn't fire, handle changes
*
*/
handle_transfert_validation_CIPF($author_id);
handle_card_expire_CIPF($author_id);
handle_prof_account_deletion_CIPF($author_id);
}
add_action('wp', 'prof_profil_check_CIPF', 11);
/*
* if profil needs redirection, it happens here
*
*/
function prof_profil_redirects_CIPF() {
Plgntls::debug_infos(2);
$role_fipf = Cipf::ROLE_FIPF;
$role_admin = Cipf::ROLE_ADMIN;
$role_partner = Cipf::ROLE_PARTNER;
// is an author page
if (!is_author())
return;
// don't redirect if it is the divi builder mode
if (et_fb_is_enabled()) {
return;
}
Plgntls::debug_infos();
/*
* check multiple user roles
* https://developer.wordpress.org/reference/functions/current_user_can/#div-comment-4083
* if user->role is found in array of allowed role, no redirection needed
*
*/
$current_user = wp_get_current_user();
$allowed_roles = array($role_admin, $role_fipf);
if (array_intersect($allowed_roles, $current_user->roles))
return;
/*
* if partner, redirect
*
*/
if (current_user_can($role_partner)) {
redirect_home_CIPF();
}
/*
* if connected user is not author, get out
*
*/
// the way to find the id of the author of an author_page
$author_id = get_queried_object_id();
$current_user_id = get_current_user_id();
if ($current_user_id != $author_id) {
redirect_home_CIPF();
}
/*
* if connected prof is new, redirect to form commande
*
*/
if (is_account_new_CIPF()) {
redirect_prof_command_CIPF();
}
}
add_action('template_redirect', 'prof_profil_redirects_CIPF', 11);
/*
* time to upload some scripts and styles on prof profil page
*
*/
function prof_profil_scripts_CIPF() {
Plgntls::debug_infos(2);
// is an author page
if (!is_author())
return;
Plgntls::debug_infos();
// the way to find the id of the author of an author_page
$author_id = get_queried_object_id();
display_states_css_CIPF($author_id);
}
add_action('wp_enqueue_scripts', 'prof_profil_scripts_CIPF', 11);
?>

View File

@@ -12,7 +12,8 @@ if (!defined('ABSPATH')) {
https://stackify.com/how-to-log-to-console-in-php/
*/
function console_log(...$outputs) {
if (FIPFCARD_CONSOLE_OFF)
Plgntls::debug_infos();
if (CIPF_CONSOLE_OFF)
return;
foreach($outputs as $output)
{

View File

@@ -0,0 +1,68 @@
<?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!');
}
/*
* globals variables
* const vs define : https://stackoverflow.com/questions/2447791/php-define-vs-const
*/
/* switch console_log
const CONSOLE_OFF = true;
*/
const CIPF_CONSOLE_OFF = false;
/*
* paypal credentials
*
* LIVE :
*
* const PAYPAL_CLIENT_ID = "Aedn5e8z__hPBvKirqw5bwlhI9ChG8_N6c1xbgybYyBr4B4oP8uVzmVdH1QVKdPQKf6bWg7orPV4PDrO";
* const PAYPAL_CLIENT_SECRET = "EGeGwfHGxHxsjnC-tH8W0IL4nN3_xlc3sXFRPCQOw5uUoWae3eOgghuDKMnZc5DVGTbP6yIjVJ1BaAra";
*
* SANBOX :
*
* const PAYPAL_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl";
* const PAYPAL_CLIENT_SECRET = "EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-";
*
const PAYPAL_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl";
const PAYPAL_CLIENT_SECRET = "EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-";
*/
/*
* paypal api base url
const PAYPAL_API_BASE_URL = "https://api-m.sandbox.paypal.com";
*/
/*
* paypal messages
* put the message betweeen backticks `message` and then between single quotes '`message`'
* because it will be evaluated in front by js, so it need something to evaluate, in ``
* you can then use variables available in the context of execution : '`Transaction ${transaction.status}`'
* is it good strategy ? idk
const PAYPAL_MESSAGE_SUCCESS = '`Transaction ${transaction.status}: ${transaction.id}<br><br>See console for all available details`';
const PAYPAL_MESSAGE_FAILURE = '`Sorry, your transaction could not be processed...<br><br>${error}`';
const PAYPAL_MESSAGE_SUCCESS = '`paiement reussi`';
const PAYPAL_MESSAGE_FAILURE = '`paiement raté`';
*/
/*
* acf fields for card :
* - card_is_valid : has valid card
* - card_date_purchase : date of purchase
* - card_date_validity : date end of validity
const CARD_IS_VALID = 'carte_est_valide';
const CARD_DATE_PURCHASE = 'date_d_achat';
const CARD_DATE_VALIDITY = 'date_fin_validite';
*/
?>

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!');
}
// Define a custom exception class for HTTP errors
class HttpException extends Exception {
// HTTP status code
private $statusCode;
public function __construct($message, $statusCode) {
parent::__construct($message);
$this->statusCode = $statusCode;
}
public function getStatusCode() {
return $this->statusCode;
}
}
?>

File diff suppressed because it is too large Load Diff

1
plugins/custer Submodule

Submodule plugins/custer added at b551112094

1
plugins/fbpatch Submodule

Submodule plugins/fbpatch added at 551dd7eee4

View File

@@ -1,6 +0,0 @@
#mytext {
border: 1px solid blue;
}
#mytext_2 {
border: 1px solid green;
}

View File

@@ -1,95 +0,0 @@
<?php
/*
Plugin Name: fipfcard_plugin
Plugin URI:
Description:
Author: hugogogo
Version: 1.1.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!');
}
/*
* plugin dir root
*/
include_once( plugin_dir_path(__FILE__) . '/utils/plgntls_class.php');
PLGNTLS_class::set_root_dir( plugin_dir_path(__FILE__), plugin_dir_url(__FILE__) );
/*
* general inclusions
*/
include_once(PLGNTLS_class::get_path() . '/utils/globals.php');
include_once(PLGNTLS_class::get_path() . '/utils/console_log.php');
include_once(PLGNTLS_class::get_path() . '/php/paypal/paypal.php');
include_once(PLGNTLS_class::get_path() . '/php/register/partenaires.php');
/*
* test the class PLGNTLS
*/
add_shortcode('fipfcard_plugin', 'fipfcard_test_class_tools');
/*
*
function custom_frontend_posting_form() {
$my_image = the_field('image_ratio');
error_log("my_image");
error_log(json_encode($my_image));
return $my_image;
}
add_shortcode('custom_frontend_posting_form', 'custom_frontend_posting_form');
*/
/*
* menu plugin
*/
include_once(PLGNTLS_class::get_path() . '/php/menu/example_menu.php');
function fipfcard_plugin_menu()
{
add_menu_page
(
'fipf_card', // webpage title
'fipf_card', // menu title
'manage_options', // capability
'fipfcard-plugin', // menu_slug
'fipfcard_plugin_content' // callback function to display page content
);
}
add_action('admin_menu', 'fipfcard_plugin_menu');
?>

View File

@@ -1,5 +0,0 @@
<input type='text' id='mytext'>
<button id='mybutton'>send</button>
<input type='text' id='mytext_2'>
<button id='mybutton_2'>send</button>

View File

@@ -1,24 +0,0 @@
<h1>old button :</h1>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="H876N9DGSCLKS" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="image" src="https://www.paypalobjects.com/fr_XC/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" title="PayPal, votre réflexe sécurité pour payer en ligne." alt="Acheter" />
</form>
<h1>new button :</h1>
<div id="paypal-button-container"></div>
<!--
custom card fields
@see https://developer.paypal.com/docs/checkout/advanced/integrate#link-addpaypalbuttonsandcardfields
<div id="card-name-field-container"></div>
<div id="checkout-form">
<div id="card-number-field-container"></div>
<div id="card-expiry-field-container"></div>
<div id="card-cvv-field-container"></div>
<button id="card-field-submit-button" type="button">
Pay now with Card
</button>
</div>
-->
<p id="result-message"></p>

File diff suppressed because it is too large Load Diff

View File

@@ -1,381 +0,0 @@
console.log("---------------inside image_editor.js--------------");
const edit_image_button = document.getElementById('edit_image');
const image_id_field = document.getElementById('image_id');
const media_editor = document.getElementById('media_editor');
edit_image_button.addEventListener('click', () => {
const image_id = image_id_field.value;
//PLGNTLS_ajax("postid", image_id, 'image-editor')
const data_obj = {
'postid': image_id,
};
PLGNTLS_ajax(data_obj, 'image_editor_PLGNTLS')
.then((response) => response.json())
.then((data) => {
console.log("data: ");
console.log(data);
media_editor.innerHTML = data.data.html;
})
.catch((error) => {
console.log("error: ");
console.log(error);
});
});
/*
open: function (e, t, i) { // t: nonce
this._view = i; // div: #media-editor-114
var a = c('#image-editor-' + e), // e: image id
o = c('#media-head-' + e),
r = c('#imgedit-open-btn-' + e),
s = r.siblings('.spinner');
if (!r.hasClass('button-activated')) return s.addClass('is-active'),
c.ajax({
url: ajaxurl,
type: 'post',
data: {
action: 'image-editor',
_ajax_nonce: t,
postid: e,
do : 'open'},
beforeSend: function () {
r.addClass('button-activated')
}
}).done(
function (t) {
var i;
'-1' === t &&
(
i = n('Could not load the preview image.'),
a.html(
'<div class="notice notice-error" tabindex="-1" role="alert"><p>' + i + '</p></div>'
)
),
t.data &&
t.data.html &&
a.html(t.data.html),
o.fadeOut(
'fast',
function () {
a.fadeIn(
'fast',
function () {
i &&
c(document).trigger('image-editor-ui-ready')
}
),
r.removeClass('button-activated'),
s.removeClass('is-active')
}
),
l.init(e)
}
) },
imgLoaded: function (t) {
var i = c('#image-preview-' + t),
e = c('#imgedit-crop-' + t);
void 0 === this.hold.sizer &&
this.init(t),
this.initCrop(t, i, e),
this.setCropSelection(
t,
{
x1: 0,
y1: 0,
x2: 0,
y2: 0,
width: i.innerWidth(),
height: i.innerHeight()
}
),
this.toggleEditor(t, 0, !0)
},
focusManager: function () {
setTimeout(
function () {
var t = c('.notice[role="alert"]');
(t = t.length ? t : c('.imgedit-wrap').find(':tabbable:first')).attr('tabindex', '-1').trigger('focus')
},
100
)
},
initCrop: function (a, t, i) {
var o = this,
r = c('#imgedit-sel-width-' + a),
s = c('#imgedit-sel-height-' + a),
n = c('#imgedit-start-x-' + a),
d = c('#imgedit-start-y-' + a),
t = c(t);
t.data('imgAreaSelect') ||
(
o.iasapi = t.imgAreaSelect({
parent: i,
instance: !0,
handles: !0,
keys: !0,
minWidth: 3,
minHeight: 3,
onInit: function (t) {
c(t).next().css('position', 'absolute').nextAll('.imgareaselect-outer').css('position', 'absolute'),
i.children().on(
'mousedown, touchstart',
function (t) {
var i,
e = !1;
t.shiftKey &&
(
t = o.iasapi.getSelection(),
i = o.getSelRatio(a),
e = t &&
t.width &&
t.height ? t.width + ':' + t.height : i
),
o.iasapi.setOptions({
aspectRatio: e
})
}
)
},
onSelectStart: function () {
l.setDisabled(c('#imgedit-crop-sel-' + a), 1),
l.setDisabled(c('.imgedit-crop-clear'), 1),
l.setDisabled(c('.imgedit-crop-apply'), 1)
},
onSelectEnd: function (t, i) {
l.setCropSelection(a, i),
c('#imgedit-crop > *').is(':visible') ||
l.toggleControls(c('.imgedit-crop.button'))
},
onSelectChange: function (t, i) {
var e = l.hold.sizer;
r.val(l.round(i.width / e)),
s.val(l.round(i.height / e)),
n.val(l.round(i.x1 / e)),
d.val(l.round(i.y1 / e))
}
})
)
},
setCropSelection: function (t, i) {
if (!(i = i || 0) || i.width < 3 && i.height < 3) return this.setDisabled(c('.imgedit-crop', '#imgedit-panel-' + t), 1),
this.setDisabled(c('#imgedit-crop-sel-' + t), 1),
c('#imgedit-sel-width-' + t).val(''),
c('#imgedit-sel-height-' + t).val(''),
c('#imgedit-start-x-' + t).val('0'),
c('#imgedit-start-y-' + t).val('0'),
c('#imgedit-selection-' + t).val(''),
!1;
i = {
x: i.x1,
y: i.y1,
w: i.width,
h: i.height
},
this.setDisabled(c('.imgedit-crop', '#imgedit-panel-' + t), 1),
c('#imgedit-selection-' + t).val(JSON.stringify(i))
},
close: function (t, i) {
if ((i = i || !1) && this.notsaved(t)) return !1;
this.iasapi = {},
this.hold = {},
this._view ? this._view.back() : c('#image-editor-' + t).fadeOut(
'fast',
function () {
c('#media-head-' + t).fadeIn(
'fast',
function () {
c('#imgedit-open-btn-' + t).trigger('focus')
}
),
c(this).empty()
}
)
},
notsaved: function (t) {
var i = c('#imgedit-history-' + t).val(),
i = '' !== i ? JSON.parse(i) : [];
return this.intval(c('#imgedit-undone-' + t).val()) < i.length &&
!confirm(c('#imgedit-leaving-' + t).text())
},
addStep: function (t, i, e) {
for (
var a = this,
o = c('#imgedit-history-' + i),
r = '' !== o.val() ? JSON.parse(o.val()) : [],
s = c('#imgedit-undone-' + i),
n = a.intval(s.val());
0 < n;
) r.pop(),
n--;
s.val(0),
r.push(t),
o.val(JSON.stringify(r)),
a.refreshEditor(
i,
e,
function () {
a.setDisabled(c('#image-undo-' + i), !0),
a.setDisabled(c('#image-redo-' + i), !1)
}
)
},
rotate: function (t, i, e, a) {
if (c(a).hasClass('disabled')) return !1;
this.closePopup(a),
this.addStep({
r: {
r: t,
fw: this.hold.h,
fh: this.hold.w
}
}, i, e)
},
flip: function (t, i, e, a) {
if (c(a).hasClass('disabled')) return !1;
this.closePopup(a),
this.addStep({
f: {
f: t,
fw: this.hold.w,
fh: this.hold.h
}
}, i, e)
},
crop: function (t, i, e) {
var a = c('#imgedit-selection-' + t).val(),
o = this.intval(c('#imgedit-sel-width-' + t).val()),
r = this.intval(c('#imgedit-sel-height-' + t).val());
if (c(e).hasClass('disabled') || '' === a) return !1;
0 < (a = JSON.parse(a)).w &&
0 < a.h &&
0 < o &&
0 < r &&
(a.fw = o, a.fh = r, this.addStep({
c: a
}, t, i)),
c('#imgedit-sel-width-' + t).val(''),
c('#imgedit-sel-height-' + t).val(''),
c('#imgedit-start-x-' + t).val('0'),
c('#imgedit-start-y-' + t).val('0')
},
undo: function (i, t) {
var e = this,
a = c('#image-undo-' + i),
o = c('#imgedit-undone-' + i),
r = e.intval(o.val()) + 1;
a.hasClass('disabled') ||
(
o.val(r),
e.refreshEditor(
i,
t,
function () {
var t = c('#imgedit-history-' + i),
t = '' !== t.val() ? JSON.parse(t.val()) : [];
e.setDisabled(c('#image-redo-' + i), !0),
e.setDisabled(a, r < t.length),
t.length === r &&
c('#image-redo-' + i).trigger('focus')
}
)
)
},
redo: function (t, i) {
var e = this,
a = c('#image-redo-' + t),
o = c('#imgedit-undone-' + t),
r = e.intval(o.val()) - 1;
a.hasClass('disabled') ||
(
o.val(r),
e.refreshEditor(
t,
i,
function () {
e.setDisabled(c('#image-undo-' + t), !0),
e.setDisabled(a, 0 < r),
0 == r &&
c('#image-undo-' + t).trigger('focus')
}
)
)
},
setNumSelection: function (t, i) {
var e = c('#imgedit-sel-width-' + t),
a = c('#imgedit-sel-height-' + t),
o = c('#imgedit-start-x-' + t),
r = c('#imgedit-start-y-' + t),
o = this.intval(o.val()),
r = this.intval(r.val()),
s = this.intval(e.val()),
n = this.intval(a.val()),
d = c('#image-preview-' + t),
l = d.height(),
d = d.width(),
h = this.hold.sizer,
g = this.iasapi;
if (!1 !== this.validateNumeric(i)) return s < 1 ? (e.val(''), !1) : n < 1 ? (a.val(''), !1) : void (
(s && n || o && r) &&
(i = g.getSelection()) &&
(
s = i.x1 + Math.round(s * h),
n = i.y1 + Math.round(n * h),
o = o === i.x1 ? i.x1 : Math.round(o * h),
i = r === i.y1 ? i.y1 : Math.round(r * h),
d < s &&
(o = 0, s = d, e.val(Math.round(s / h))),
l < n &&
(i = 0, n = l, a.val(Math.round(n / h))),
g.setSelection(o, i, s, n),
g.update(),
this.setCropSelection(t, g.getSelection())
)
)
},
round: function (t) {
var i;
return t = Math.round(t),
0.6 < this.hold.sizer ? t : '1' === (i = t.toString().slice( - 1)) ? t - 1 : '9' === i ? t + 1 : t
},
setRatioSelection: function (t, i, e) {
var a = this.intval(c('#imgedit-crop-width-' + t).val()),
o = this.intval(c('#imgedit-crop-height-' + t).val()),
r = c('#image-preview-' + t).height();
!1 === this.validateNumeric(e) ? this.iasapi.setOptions({
aspectRatio: null
}) : a &&
o &&
(
this.iasapi.setOptions({
aspectRatio: a + ':' + o
}),
e = this.iasapi.getSelection(!0)
) &&
(
r < (a = Math.ceil(e.y1 + (e.x2 - e.x1) / (a / o))) ? (
a = r,
o = n(
'Selected crop ratio exceeds the boundaries of the image. Try a different ratio.'
),
c('#imgedit-crop-' + t).prepend(
'<div class="notice notice-error" tabindex="-1" role="alert"><p>' + o + '</p></div>'
),
wp.a11y.speak(o, 'assertive'),
c(i ? '#imgedit-crop-height-' + t : '#imgedit-crop-width-' + t).val('')
) : void 0 !== (r = c('#imgedit-crop-' + t).find('.notice-error')) &&
r.remove(),
this.iasapi.setSelection(e.x1, e.y1, e.x2, a),
this.iasapi.update()
)
},
validateNumeric: function (t) {
if (!1 === this.intval(c(t).val())) return c(t).val(''),
!1
}
}
}(jQuery);
*/

View File

@@ -1,4 +0,0 @@
import { test_fetch } from './example_submenu.js';
test_fetch();

View File

@@ -1,29 +0,0 @@
const inputElement2 = document.getElementById('mytext_2');
const sendButton2 = document.getElementById('mybutton_2');
sendButton2.addEventListener('click', () => {
let inputValue = inputElement2.value;
inputValue = {
key1: 'value1',
key2: 'value2'
};
inputValue = JSON.stringify(inputValue);
console.log("inputValue:");
console.log(inputValue);
PLGNTLS_fetch('/plgntls/get_data', {
method: "POST",
})
//PLGNTLS_fetch('get_data', {body: {inputValue}})
.then((response) => response.json())
.then((data) => {
console.log("dataaa: ");
console.log(data);
})
.catch((error) => {
console.log("error: ");
console.log(error);
});
});

View File

@@ -1,33 +0,0 @@
import { PLGNTLS_fetch } from '../../utils/plgntls_fetch.js';
export function test_fetch() {
const inputElement = document.getElementById('mytext');
const sendButton = document.getElementById('mybutton');
sendButton.addEventListener('click', () => {
let inputValue = inputElement.value;
inputValue = {
key1: 'value1',
key2: 'value2'
};
inputValue = JSON.stringify(inputValue);
console.log("inputValue:");
console.log(inputValue);
PLGNTLS_fetch('/plgntls/get_data', {
method: "POST",
})
//PLGNTLS_fetch('get_data', {body: {inputValue}})
.then((response) => response.json())
.then((data) => {
console.log("dataaa: ");
console.log(data);
})
.catch((error) => {
console.log("error: ");
console.log(error);
});
});
}

View File

@@ -1,107 +0,0 @@
import { resultMessage } from './result_message.js';
import { PLGNTLS_fetch } from '../../utils/plgntls_fetch.js';
/**
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
*/
//async function onApprove(data, actions) {
export async function onApprove(data, actions) {
try {
const fetch_approve_url = PLGNTLS_data.fetch_url + "/fipf_plugin/api/v1/orders/" + data.orderID + "/capture";
console.log("fetch_approve_url:", fetch_approve_url);
//const response = await fetch(fetch_approve_url, {
const response = await PLGNTLS_fetch('/fipf_plugin/api/v1/orders/' + data.orderID + '/capture', {
method: "POST",
headers: {
"Content-Type": "application/json",
//"X-WP-Nonce": PLGNTLS_data.rest_nonce,
},
});
const orderData = await response.json();
// Three cases to handle:
// (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart()
// (2) Other non-recoverable errors -> Show a failure message
// (3) Successful transaction -> Show confirmation or thank you message
const errorDetail = orderData?.details?.[0];
if (errorDetail?.issue === "INSTRUMENT_DECLINED") {
// (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart()
// recoverable state, per https://developer.paypal.com/docs/checkout/standard/customize/handle-funding-failures/
return actions.restart();
} else if (errorDetail) {
// (2) Other non-recoverable errors -> Show a failure message
throw new Error(`${errorDetail.description} (${orderData.debug_id})`);
} else if (!orderData.purchase_units) {
throw new Error(JSON.stringify(orderData));
} else {
// (3) Successful transaction -> Show confirmation or thank you message
// Or go to another URL: actions.redirect('thank_you.html');
const transaction =
orderData?.purchase_units?.[0]?.payments?.captures?.[0] ||
orderData?.purchase_units?.[0]?.payments?.authorizations?.[0];
// to show a message on page
//resultMessage(`Transaction ${transaction.status}: ${transaction.id}<br><br>See console for all available details`,);
console.log(
"Capture result",
orderData,
JSON.stringify(orderData, null, 2),
);
actions.redirect('https://local_fipfcard_plugin.com/');
}
} catch (error) {
console.error(error);
resultMessage(
`Sorry, your transaction could not be processed...<br><br>${error}`,
);
}
}
/**
* @see https://developer.paypal.com/demo/checkout/#/pattern/server
*
// Call your server to finalize the transaction
function onApprove (data, actions) {
const fetch_approve_url = PLGNTLS_data.fetch_url + "/fipf_plugin/api/v1/orders/" + data.orderID + "/capture";
console.log("fetch_approve_url:", fetch_approve_url);
return fetch(fetch_approve_url, {
method: 'post'
}).then(function(res) {
return res.json();
}).then(function(orderData) {
// Three cases to handle:
// (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart()
// (2) Other non-recoverable errors -> Show a failure message
// (3) Successful transaction -> Show confirmation or thank you
// This example reads a v2/checkout/orders capture response, propagated from the server
// You could use a different API or structure for your 'orderData'
var errorDetail = Array.isArray(orderData.details) && orderData.details[0];
if (errorDetail && errorDetail.issue === 'INSTRUMENT_DECLINED') {
return actions.restart(); // Recoverable state, per:
// https://developer.paypal.com/docs/checkout/integration-features/funding-failure/
}
if (errorDetail) {
var msg = 'Sorry, your transaction could not be processed.';
if (errorDetail.description) msg += '\n\n' + errorDetail.description;
if (orderData.debug_id) msg += ' (' + orderData.debug_id + ')';
return alert(msg); // Show a failure message (try to avoid alerts in production environments)
}
// Successful capture! For demo purposes:
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
var transaction = orderData.purchase_units[0].payments.captures[0];
alert('Transaction '+ transaction.status + ': ' + transaction.id + '\n\nSee console for all available details');
// Replace the above to show a success message within this page, e.g.
// const element = document.getElementById('paypal-button-container');
// element.innerHTML = '';
// element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
}
*/

View File

@@ -1,13 +0,0 @@
//function PLGNTLS_fetch(url, options = {}) {
export function PLGNTLS_fetch(url, options = {}) {
console.log("inside PLGNTLS_fetch");
url = PLGNTLS_data.fetch_url + url;
options.headers = options.headers || {};
options.headers['X-WP-Nonce'] = PLGNTLS_data.fetch_nonce,
console.log("options:", options);
return fetch(url, options);
}

View File

@@ -1,23 +0,0 @@
<?php acf_form_head(); ?>
<?php get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<p>My custom field: <?php the_field('my_custom_field'); ?></p>
<?php acf_form(); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,89 +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!');
}
/*
function fipfcard_image_editor()
{
// ob_start();
// wp_image_editor('33545');
// return ob_get_clean();
$fipfcard_image_editor = new PLGNTLS_class();
return $fipfcard_image_editor->add_to_front(
array(
"js/image_editor.js",
"html/image_editor.html",
)
);
// if ( ! has_action( "wp_ajax_{$action}" ) ) {
// it returns error 400
}
add_shortcode('fipfcard_image_editor', 'fipfcard_image_editor');
*/
/**
* Handles image editing via AJAX.
* from wp-admin/includes/ajax-action.php
*/
/*
function wp_ajax_image_editor() {
$attachment_id = (int) $_POST['postid'];
// $attachment_id = 33555;
// if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) {
// wp_die( -1 );
// }
// check_ajax_referer( "image_editor-$attachment_id" );
// require_once ABSPATH . 'wp-admin/includes/image-edit.php';
$msg = false;
switch ( $_POST['do'] ) {
case 'save':
$msg = wp_save_image( $attachment_id );
if ( ! empty( $msg->error ) ) {
wp_send_json_error( $msg );
}
wp_send_json_success( $msg );
break;
case 'scale':
$msg = wp_save_image( $attachment_id );
break;
case 'restore':
$msg = wp_restore_image( $attachment_id );
break;
}
ob_start();
wp_image_editor( $attachment_id, $msg );
$html = ob_get_clean();
if ( ! empty( $msg->error ) ) {
wp_send_json_error(
array(
'message' => $msg,
'html' => $html,
)
);
}
wp_send_json_success(
array(
'message' => $msg,
'html' => $html,
)
);
}
add_action( 'wp_ajax_image_editor', 'wp_ajax_image_editor' );
*/
?>

View File

@@ -1,54 +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!');
}
function fipfcard_plugin_content() {
$fipfcard = new PLGNTLS_class();
$my_css = '
#mytext {
background-color: lightblue;
}
#mytext_2 {
background-color: lightgreen;
}
';
echo $fipfcard->add_to_front( array(
array("js/menu/example_menu.js", 'type'=>'module'),
"css/menu/menu.css",
"PLGNTLS_menu_css" => array('css'=>$my_css),
"js/menu/example_menu_2.js",
"html/menu/example_menu.html",
));
}
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ajax
- https://stackoverflow.com/questions/43557755/how-to-call-ajax-in-wordpress
- in `add_action( 'wp_ajax_get_data', 'my_ajax_handler' );`
the 'wp_ajax_get_data' is a hooks formated as 'wp_ajax_{$action}'
the `$action` param is passed in the data object of the ajax call
- to access the content of the data object properties of the ajax call :
use $_POST['property_name']
*/
function fipfcard_menu_fetch_handler()
{
return new WP_REST_Response('hello', 200);
}
function fipfcard_menu_endpoint()
{
register_rest_route('plgntls', '/get_data', array(
'methods' => 'POST',
'callback' => 'fipfcard_menu_fetch_handler',
));
};
add_action('rest_api_init', 'fipfcard_menu_endpoint');
?>

View File

@@ -1,110 +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!');
}
include_once(PLGNTLS_class::get_path() . '/php/paypal/route_api_orders.php');
include_once(PLGNTLS_class::get_path() . '/php/paypal/route_api_orders_capture.php');
/*
function check_paypal_request()
{
error_log("----");
if (is_page('test_paypal_payment'))
error_log("on test_paypal_payment");
else if (is_page('test_paypal_ok'))
error_log("on test_paypal_ok");
else if (is_page('test_paypal_infos'))
error_log("on test_paypal_infos");
else
return;
error_log("_GET");
error_log(json_encode($_GET));
error_log("_POST");
error_log(json_encode($_POST));
// error_log("_COOKIE");
// error_log(json_encode($_COOKIE));
}
add_action('template_redirect', 'check_paypal_request');
*/
/**
* call to paypal_shortcode_content()
*/
function fipf_paypal_shortcode_content()
{
$fipfcard_paypal = new PLGNTLS_class();
$pp_sdk_currency = "EUR";
$pp_sdk_debug = "true";
$pp_sdk_base_url="https://sandbox.paypal.com";
$pp_sdk_base_url="https://www.paypal.com";
// $pp_sdk_client_token="abc123xyz==";
$pp_sdk_src="$pp_sdk_base_url/sdk/js?client-id=" . PAYPAL_CLIENT_ID . "&currency=$pp_sdk_currency&debug=$pp_sdk_debug";
$pp_sdk_src="$pp_sdk_base_url/sdk/js?client-id=" . PAYPAL_CLIENT_ID ;
// $pp_sdk_attributes="src='$pp_sdk_src' data-client-token='$pp_sdk_client_token'";
// $pp_sdk_attributes="src='$pp_sdk_src'";
// $pp_sdk_html_script="<script $pp_sdk_attributes></script>";
$added_to_front = $fipfcard_paypal->add_to_front(
array(
$pp_sdk_src,
// 'js/paypal/result_message.js',
// 'js/paypal/create_order.js',
// 'js/paypal/on_approve.js',
//"js/paypal/paypal.js",
array("js/paypal/paypal.js", 'type'=>'module'),
"html/paypal/paypal.html",
),
);
return $added_to_front;
}
add_shortcode('fipf_paypal_shortcode', 'fipf_paypal_shortcode_content');
/**
* the js file paypal.js needs to be imported as a module to use import
* @see https://developer.wordpress.org/reference/hooks/script_loader_tag/
function fipf_add_id_to_script( $tag, $handle, $src ) {
if ( $handle === 'PLGNTLS_paypal_js' ) {
$tag = '<script type="module" src="' . esc_url( $src ) . '" ></script>';
}
return $tag;
}
add_filter( 'script_loader_tag', 'fipf_add_id_to_script', 10, 3 );
*/
// handling routes and endpoints
// diff routes and endpoints : https://stackoverflow.com/q/56075017/9497573
function fipf_routes_endpoints()
{
$base_rest_route = "fipf_plugin/api/v1";
register_rest_route($base_rest_route, '/orders', array(
'methods' => 'POST',
'callback' => 'fipf_handle_orders_request',
));
// https://local_fipfcard_plugin.com/wp-json/fipf_plugin/api/v1/orders/21T129305J264761D/capture
register_rest_route($base_rest_route, '/orders/(?P<orderID>[a-zA-Z0-9]+)/capture', array(
'methods' => 'POST',
'callback' => 'fipf_handle_orders_capture_request',
));
};
add_action('rest_api_init', 'fipf_routes_endpoints');
?>

View File

@@ -1,97 +0,0 @@
<?php
include_once(PLGNTLS_class::get_path() . '/php/paypal/route_api_utils.php');
include_once(PLGNTLS_class::get_path() . '/php/paypal/update_user_payment.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!');
}
/**
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
*/
function fipf_handle_orders_request($request_data) {
try {
// Extract cart information from request body
$cart = $request_data['cart'];
// Process the order and get the response
$order_response = fipf_create_order($cart);
$json_response = $order_response['json_response'];
$http_status_code = $order_response['http_status_code'];
fipf_update_user_payment($json_response, 'start');
// Return response
return new WP_REST_Response($json_response, $http_status_code);
} catch (Exception $e) {
// Handle errors
error_log('Failed to create order: ' . $e->getMessage());
return new WP_Error('500', 'Failed to create order.', array('status' => 500));
}
}
/**
* Create an order to start the transaction.
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_create
*/
function fipf_create_order( $cart )
{
// use the cart information passed from the front-end to calculate the purchase unit details
$access_token = fipf_generate_access_token();
$url = PAYPAL_API_BASE_URL . '/v2/checkout/orders';
$payload = array(
'intent' => "CAPTURE",
'purchase_units' => array(
array(
'amount' => array(
'currency_code' => "USD",
'value' => "100.00",
),
),
),
);
$headers = array(
"Content-Type: application/json",
"Authorization: Bearer " . $access_token
// Uncomment one of these to force an error for negative testing (in sandbox mode only). Documentation:
// https://developer.paypal.com/tools/sandbox/negative-testing/request-headers/
// "PayPal-Mock-Response": '{"mock_application_codes": "MISSING_REQUIRED_PARAMETER"}'
// "PayPal-Mock-Response": '{"mock_application_codes": "PERMISSION_DENIED"}'
// "PayPal-Mock-Response": '{"mock_application_codes": "INTERNAL_SERVER_ERROR"}'
);
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Execute cURL session and get the response
$response = curl_exec($ch);
if ($response === false)
throw new Exception('cURL error: ' . curl_error($ch));
// Close cURL session
curl_close($ch);
// in utils
return fipf_handle_response($response);
};
?>

View File

@@ -1,74 +0,0 @@
<?php
include_once(PLGNTLS_class::get_path() . '/php/paypal/route_api_utils.php');
include_once(PLGNTLS_class::get_path() . '/php/paypal/update_user_payment.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 fipf_handle_orders_capture_request($request) {
$order_id = $request['orderID'];
try {
// Implement captureOrder function logic here
// Make sure you implement captureOrder function similar to the Node.js code
$response_data = fipf_capture_order($order_id);
$http_status_code = $response_data['http_status_code'];
$json_response = $response_data['json_response'];
fipf_update_user_payment($json_response, 'end');
return new WP_REST_Response($json_response, $http_status_code);
}
catch (Exception $e) {
error_log('Failed to capture order: ' . $e->getMessage());
return new WP_REST_Response(array('error' => 'Failed to capture order.'), 500);
}
}
/**
* Capture payment for the created order to complete the transaction.
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture
*/
function fipf_capture_order($orderID) {
$access_token = fipf_generate_access_token();
$url = PAYPAL_API_BASE_URL . '/v2/checkout/orders/' . $orderID . '/capture';
$headers = array(
"Content-Type: application/json",
"Authorization: Bearer " . $access_token
// Uncomment one of these to force an error for negative testing (in sandbox mode only). Documentation:
// https://developer.paypal.com/tools/sandbox/negative-testing/request-headers/
// 'PayPal-Mock-Response: {"mock_application_codes": "INSTRUMENT_DECLINED"}',
// 'PayPal-Mock-Response: {"mock_application_codes": "TRANSACTION_REFUSED"}',
// 'PayPal-Mock-Response: {"mock_application_codes": "INTERNAL_SERVER_ERROR"}'
);
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute cURL session and get the response
$response = curl_exec($ch);
if ($response === false)
throw new Exception('cURL error: ' . curl_error($ch));
// Close cURL session
curl_close($ch);
// in utils
return fipf_handle_response($response);
};
?>

View File

@@ -1,98 +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!');
}
/**
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
*/
function fipf_handle_response($response) {
try
{
// Decode JSON response
$json_response = json_decode($response);
return array(
'json_response' => $json_response,
'http_status_code' => http_response_code()
);
}
catch (Exception $err)
{
// Get error message from response
$error_message = $response->text();
throw new Exception($error_message);
}
}
/*
async function handleResponse(response) {
try {
const jsonResponse = await response.json();
return {
jsonResponse,
httpStatusCode: response.status,
};
} catch (err) {
const errorMessage = await response.text();
throw new Error(errorMessage);
}
}
*/
/**
* Generate an OAuth 2.0 access token for authenticating with PayPal REST APIs.
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
* @see https://developer.paypal.com/api/rest/authentication/
*/
function fipf_generate_access_token()
{
try
{
if ( !PAYPAL_CLIENT_ID || !PAYPAL_CLIENT_SECRET ) {
throw new Exception( "MISSING_API_CREDENTIALS" );
}
$credentials = PAYPAL_CLIENT_ID . ":" . PAYPAL_CLIENT_SECRET;
$auth = base64_encode($credentials);
$url = PAYPAL_API_BASE_URL . '/v1/oauth2/token';
$body = http_build_query(array('grant_type' => 'client_credentials'));
// Initialize curl
$ch = curl_init();
// Set curl options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . $auth,
));
// Execute curl and get the response
$data_json = curl_exec($ch);
if ( $data_json === false)
throw new Exception('cURL error: ' . curl_error($ch));
// Close curl
curl_close($ch);
$data = json_decode($data_json);
return $data->access_token;
}
catch (Exception $error)
{
error_log("Failed to generate Access Token:");
error_log($error->getMessage());
}
};
?>

View File

@@ -1,209 +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!');
}
/**
* see documentation in private 'paypal.md'
* basically it check if the user who initiate the transaction
* is the same that finish it
*
* add_user_meta('user_id', 'fipf_order_id', 'aaaaaa');
* ['aaaaaa']
* add_user_meta('user_id', 'fipf_order_id', 'bbbbbb');
* ['aaaaaa', 'bbbbbb']
* add_user_meta('user_id', 'fipf_order_id', 'bbbbbb');
* ['aaaaaa', 'bbbbbb', 'bbbbbb']
* get_user_meta('user_id', 'fipf_order_id');
* ['aaaaaa', 'bbbbbb', 'bbbbbb']
* $del_ret = delete_user_meta('user_id', 'fipf_order_id', 'bbbbbb');
* ['aaaaaa'] - $del_ret === true
* $del_ret = delete_user_meta('user_id', 'fipf_order_id', 'bbbbbb');
* ['aaaaaa'] - $del_ret === false
*
*/
function fipf_update_user_payment($message, $step)
{
$order_id = $message->id;
$user_id = get_current_user_id();
/*
order status : https://developer.paypal.com/docs/api/orders/v2/#orders_capture!c=201&path=status&t=response
CREATED
SAVED
APPROVED ?
VOIDED
- COMPLETED
PAYER_ACTION_REQUIRED
*/
$status = $message->status;
//error_log("--- in update_user_payment, step :");
//error_log($step);
////error_log("message :");
////error_log(json_encode($message));
//error_log("order_id :");
//error_log($order_id);
//error_log("status :");
//error_log($status);
//$user_meta_order_id = get_user_meta($user_id, 'fipf_order_id');
//error_log("user_meta->fipf_order_id :");
//error_log(json_encode($user_meta_order_id));
//error_log("... update user");
// addind order_id to fipf_order_id meta field
// it can duplicate, it's not a problem : delete_user_meta will delete all
add_user_meta($user_id, 'fipf_order_id', $order_id);
// add a schedule event to delete this order_id
fipf_schedule_delete_orderid($user_id, $order_id);
fipf_validate_payment_for_user($user_id, $order_id);
// if transaction is COMPLETED, then delete order_id and update user
if ($status === 'COMPLETED')
{
// find the user containing the order_id and delete this order_id
$user_id_to_update = fipf_delete_order_id_on_success($user_id, $order_id);
// proceed to validate payment for user
fipf_validate_payment_for_user($user_id_to_update, $order_id);
}
//$user_meta_order_id = get_user_meta($user_id, 'fipf_order_id');
//error_log("user_meta->fipf_order_id :");
//error_log(json_encode($user_meta_order_id));
//error_log("--- out update_user_payment");
}
/**
*
* change acf field [carte_est_valide](validite) to true
* change acf field [date_d_achat](achat) to new current date
* change acf field [date_fin_validite](echance) to previous date + 1 year
*
* create scheduled emails to inform of end of validity
*
* acf uses 'Y-m-d H:i:s' format :
* -> https://www.advancedcustomfields.com/resources/date-time-picker/
*/
function fipf_validate_payment_for_user($user_id, $order_id)
{
$acf_date_format = 'Y-m-d H:i:s';
/**
* update card validity to true
*/
$post_id = 'user_'.$user_id;
update_field('carte_est_valide', true, $post_id);
/**
* update purchase date to now
*/
$date_now = date($acf_date_format);
update_field('date_d_achat', $date_now, $post_id);
/**
* update date limit validity to add 1 year
*/
$current_date_limit = get_field('date_fin_validite', $post_id);
// output is in format 'dd/mm/yyyy' which is not understood by php dates functions
// so i clean it
// -> not a reliable solution, someone can change the ouput format in dashboard
$current_date_limit = str_replace('/', '-', $current_date_limit);
// id current date limit is not in the futur, use now date
if ($current_date_limit === null)
$current_date_limit = $date_now;
else
{
// 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 (2000 bug like)
$comp_current_date_limit = date_create($current_date_limit);
$comp_date_now = date_create($date_now);
$date_is_in_past = date_diff($comp_date_now, $comp_current_date_limit)->format("%R%a") < 0;
if ($date_is_in_past)
$current_date_limit = $date_now;
}
// add one year to current date limit
$time_plus_one_year = strtotime('+1 year', strtotime($current_date_limit));
$new_date_limit = date('Y-m-d H:i:s', $time_plus_one_year);
update_field('date_fin_validite', $new_date_limit, $post_id);
}
/**
* add a schedule event to delete this order_id
* after 3 days ?
* time() + 60 = one minute from now
* time() + MINUTE_IN_SECONDS = one minute from now
* -> https://codex.wordpress.org/Easier_Expression_of_Time_Constants
* -> also strtotime : https://www.php.net/manual/en/function.strtotime.php
*/
function fipf_schedule_delete_orderid($user_id, $order_id)
{
$delay = time() + MINUTE_IN_SECONDS;
wp_schedule_single_event($delay, 'fipf_orderid_deletion_event', array($user_id, $order_id));
}
/**
* action hook for the scheduled event
* TODO: ne marche pas je ne sais pas pourquoi, pas urgent a resoudre
*/
function fipf_delete_order_id_later($user_id, $order_id)
{
error_log("delete order_id[$order_id] from user_id[$user_id]");
delete_user_meta($user_id, 'fipf_order_id', $order_id);
}
add_action('fipf_orderid_deletion_event', 'fipf_delete_order_id_later', 5, 2);
/**
* @return mixed num - user_id
* bool false - if no match found
*/
function fipf_delete_order_id_on_success($current_user_id, $order_id)
{
$del_ret = delete_user_meta($current_user_id, 'fipf_order_id', $order_id);
if ($del_ret === true)
return $current_user_id;
// it means the current user didn't have this order_id
// so we look for another user
$users = get_users();
foreach ($users as $user)
{
$user_id = $user->ID;
$del_ret = delete_user_meta($user_id, 'fipf_order_id', $order_id);
if ($del_ret === true)
return $user_id;
}
return false;
}
?>

View File

@@ -1,15 +0,0 @@
<?php
function add_partenaires_PLGNTLS($customer_data){
$current_url = $_SERVER['HTTP_REFERER'];
$path_brut = parse_url($current_url, PHP_URL_PATH);
$path = trim($path_brut, '/');
if ($path === 'creation-du-compte-partenaire')
$customer_data['role'] = 'partenaire';
return $customer_data;
}
add_filter( 'xoo_el_register_new_customer_data', 'add_partenaires_PLGNTLS', 10, 1 );
?>

View File

@@ -1,55 +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!');
}
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
globals variables
const vs define : https://stackoverflow.com/questions/2447791/php-define-vs-const
*/
/* switch console_log
const CONSOLE_OFF = true;
*/
const FIPFCARD_CONSOLE_OFF = false;
/**
* a variable that will contain the name of the first script enqueued
*/
$fipfcard_first_script = null;
/**
* path to ajax.js file, from root of js dir
*/
$fipfcard_ajax_file = "utils/ajax.js";
/**
* paypal credentials
*
* LIVE :
*
* const PAYPAL_CLIENT_ID = "Aedn5e8z__hPBvKirqw5bwlhI9ChG8_N6c1xbgybYyBr4B4oP8uVzmVdH1QVKdPQKf6bWg7orPV4PDrO";
* const PAYPAL_CLIENT_SECRET = "EGeGwfHGxHxsjnC-tH8W0IL4nN3_xlc3sXFRPCQOw5uUoWae3eOgghuDKMnZc5DVGTbP6yIjVJ1BaAra";
*
* SANBOX :
*
* const PAYPAL_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl";
* const PAYPAL_CLIENT_SECRET = "EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-";
*
*/
const PAYPAL_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl";
const PAYPAL_CLIENT_SECRET = "EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-";
/**
* paypal api base url
*/
const PAYPAL_API_BASE_URL = "https://api-m.sandbox.paypal.com";
?>

View File

@@ -1,455 +0,0 @@
<?php
/**
* include those two lines at the top of the main plugin file
*
* include_once( plugin_dir_path(__FILE__) . '/php/utils/plugin_tools.php');
* PLGNTLS_class::set_root_dir( plugin_dir_path(__FILE__), plugin_dir_url(__FILE__) );
*
* PLGNTLS means PLUGIN TOOLS
*
* .add_to_front() : this method is made to add files and codes all at once
* otherwise use the wp functions (wp_enqueue_*, wp_add_inline_*, etc)
*
*
* ex:
*
* $my_plugin_class = new PLGNTLS_class();
* $var_1 = 'value_1';
* $var_2 = 'value_2';
* $var_3 = 'value_3';
* return $my_plugin_class->add_to_front(
* array( // files added in order by types
* 'path/to/style1.css', //
* 'path/to/script1.js', //
* 'path/to/style2.css', // -> depends on style1.css
* 'http://my_url1.com', //
* 'path/to/script2.js', // -> depends on script1.js
* 'path/to/file1.html', // | will be returned
* 'path/to/file2.html', // -> | as expanded html
* 'path/to/file3.html', // | in the order included
* 'handle_name' => 'path/to/script3.js', // -> depends on the script with handle 'handle_name'
* array( //
* 'path/to/script4.js', // | add a script with attributes
* 'attribute_1' => 'value_1', // -> | first element of array must be
* 'attribute_2' => 'value_2', // | the script, without explicit key
* ), //
* array( 'js' => 'var_js' ), // -> add inline js, only first element will be used
* array( 'css' => 'var_css' ), // -> add inline css, only first element will be used
* ),
* compact( // these variables are added to html and js files
* 'var_1', // - in html files you can access them directly
* 'var_2', // - in js files they are properties of object PLGNTLS_data
* 'var_3', // like PLGNTLS_data.var_1;
* )
* );
*
*/
class PLGNTLS_class
{
private static $_root_path;
private static $_root_url;
private $_first_script;
private $_first_style;
private $_prefix;
private $_js_dependencies;
private $_css_dependencies;
private $_scripts_attributes;
/**
*/
public function __construct() {
$this->_prefix = "PLGNTLS";
$this->_first_script = null;
$this->_first_style = null;
$this->_js_dependencies = array();
$this->_css_dependencies = array();
$this->_scripts_attributes = array();
}
/**
* can be used before class is instanciated :
* PLGNTLS_class::set_root_dir( plugin_dir_path(__FILE__), plugin_dir_url(__FILE__) );
*/
public static function set_root_dir($path, $url) {
if (isset( self::$_root_path ))
return ;
if (isset( self::$_root_url ))
return ;
self::$_root_path = $path;
self::$_root_url = $url;
}
public static function get_path() {
return(self::$_root_path);
}
public static function get_url() {
return(self::$_root_url);
}
public function add_to_front($srcs_arr = null, $vars = null) {
if (!is_array($vars))
$vars = array();
if (!is_null($srcs_arr))
$this->add_fetch($srcs_arr, $vars);
$srcs = array();
foreach($srcs_arr as $src_key => $src_value) {
$init = $this->init_src($src_key, $src_value);
if ($init !== null)
$srcs[] = $init;
}
if (!is_null($srcs_arr))
$this->add_srcs_to_front($srcs);
if (!is_null($vars))
$this->add_vars_to_front($vars);
return $this->create_html($srcs, $vars);
}
/**
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* PRIVATES FUNCTIONS
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
/**
* for fetch, we add the file script that contains the fetch function
* it is an es6 module with the export keyword
* that way, it can also be used by modules scripts
* to achieve that, we wouldn't need to include it here though
* but we need that the fetch function is also available for inline scripts
* so we could attach a copy of the script file without the export keyword
* but instead, inside the file, we add the fetch function to the global scope
*/
private function add_fetch(&$srcs_arr, &$vars) {
// add fetch script at beginning of scripts list
array_unshift($srcs_arr, array("utils/plgntls_fetch.js", 'type'=>'module'));
// for the custom endpoints in rest api to work
// they need to have a nonce named 'wp_rest'
// see : https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/
$fetch_nonce = array("fetch_nonce" => wp_create_nonce('wp_rest'));
$fetch_url = array("fetch_url" => get_site_url() . "/wp-json");
$vars = array_merge($vars, $fetch_nonce);
$vars = array_merge($vars, $fetch_url);
}
/**
* @param two arguments :
* 1. html files to include in front
* - can be a string of 1 filename
* - or an array of strings of filenames
* ( https://stackoverflow.com/q/4747876/9497573 )
* - it's probably better to only add 1 file, and let it include other files
* 2. list of variables to make available to this files
* - in the form of key => val
* - recommanded to do it with compact()
* ex: create_html( "file.html", compact("var1","var2",) );
* ex: create_html( array("file1.html", "file2.html"), array("var1"=>"value") );
* @return a string of html code
*
* using ob_start() and ob_get_clean()
* allows to have php expansion inside the html loaded
* in opposition to the methode file_get_contents()
*
* https://stackoverflow.com/a/4402045/9497573
*/
private function create_html($files = null, $vars = null) {
if (is_null($files))
return null;
$plgn_dir = $this->get_path();
if (!is_null($vars))
extract($vars);
ob_start();
foreach($files as $file) {
if ($file->ext === 'html')
include($file->path);
}
$html = ob_get_clean();
return $html;
}
/**
* pass variables to js front as global variables
* @param array : list of key => value
* with the key being name of the variable, like this :
* 'my_var' => 'value',
* simpler way to do it is to use compact when calling the function :
* add_var_to_front(compact("var1", "var2", "var3"));
* @param string (optionnal) : name of first embended script that need these variables
* (it will be available to this script and all followings)
* this name is the filename + "_" + extension :
* init.js -> init_js
*/
private function add_vars_to_front($vars_arr)
{
if (is_null($this->_first_script))
return ;
if (is_null($vars_arr))
return ;
$handle = $this->_first_script;
$object_name = $this->_prefix . "_data";
$vars_json = json_encode($vars_arr);
$front = "let $object_name = $vars_json;";
wp_add_inline_script($handle, $front, 'before');
}
/**
* @param array : list of files :
* - with their path from root of their type of file (ex: from js/ to .js files)
* - and with their extension
* @param boolean
* - to add ajax script and variables
* - default to true
*/
private function add_srcs_to_front($srcs_arr) {
//wp_enqueue_script(<give_it_a_name>, /url/to/script, [depends on], version, defer? );
//wp_enqueue_style( <give_it_a_name>, /url/to/script, [depends on], version, media );
$previous_css_basename = '';
$previous_js_basename = '';
foreach ($srcs_arr as $src) {
if ($src->inline !== null) {
if ($src->inline === "js")
$this->add_inline_script($src);
else if ($src->inline === "css")
$this->add_inline_style($src);
}
else if (in_array($src->ext, array("js", "url"))) {
$this->add_script($src, $previous_js_basename);
$previous_js_basename = $src->handle;
}
else if ($src->ext === "css") {
$this->add_style($src, $previous_css_basename);
$previous_css_basename = $src->handle;
}
}
// https://developer.wordpress.org/reference/hooks/wp_script_attributes/
// https://wordpress.stackexchange.com/questions/66843/attach-a-private-function-at-a-hook
add_filter( 'wp_script_attributes', fn($attr)=>$this->add_attributes_to_script($attr), 10, 1 );
/*
* uncomment to print all enqueued files, can be usefull
global $wp_scripts;
error_log("wp_scripts->queue:");
error_log(json_encode($wp_scripts->queue));
global $wp_styles;
error_log("wp_styles->queue:");
error_log(json_encode($wp_styles->queue));
*/
}
private function add_script($script, $previous_js_basename) {
if (is_null($this->_first_script))
$this->_first_script = $script->handle;
$depends_on = $this->check_dependencies($script, $previous_js_basename);
if ($depends_on !== null)
wp_enqueue_script( $script->handle, $script->url, $depends_on, $script->version, true);
}
private function add_style($style, $previous_css_basename) {
if (is_null($this->_first_style))
$this->_first_style = $style->handle;
$depends_on = $this->check_dependencies($style, $previous_css_basename);
if ($depends_on !== null)
wp_enqueue_style( $style->handle, $style->url, $depends_on, $style->version, '');
}
private function add_inline_script($src) {
$handle = $src->depends;
if ($handle === null)
$handle = $this->_first_script;
wp_add_inline_script($src->depends, $src->src, 'before');
}
private function add_inline_style($src) {
error_log("inside add_inline_style");
$handle = $src->depends;
if ($handle === null)
$handle = $this->_first_style;
wp_add_inline_style($src->depends, $src->src);
}
private function add_attributes_to_script($attr) {
if (empty($attr['id']))
return $attr;
$handle = $attr['id'];
if (isset($this->_scripts_attributes[$handle]))
$script = $this->_scripts_attributes[$handle];
else
return $attr;
foreach($script as $key => $value){
$attr[$key] = $value;
}
unset($this->_scripts_attributes[$handle]);
return $attr;
}
private function check_dependencies(&$src, $previous_basename)
{
if (in_array($src->ext, array("js", "url")))
{
global $wp_scripts;
$already_enqueued = array_search($src->handle, $wp_scripts->queue);
if ($already_enqueued !== false)
return null;
}
else if ($src->ext === "css")
{
global $wp_styles;
$already_enqueued = array_search($src->handle, $wp_styles->queue);
if ($already_enqueued !== false)
return null;
}
$depends_on = array();
if (isset($src->depends) && $src->depends !== '')
$depends_on[] = $src->depends;
if (isset($previous_basename) && $previous_basename !== '')
$depends_on[] = $previous_basename;
return $depends_on;
}
/**
* @param string : name of the file, with its path from its extension directory
* - from js/ root for .js files
* - from css/ root for .css files
* @return object / null :
* - null if file is not valid
* - or an object with all the necessary infos :
* 0. src : array("name.js", ...) -> "name.js"
* "name.js" -> "name.js"
* 1. ext : name.js -> "js"
* 2. basename : name.js -> "name"
* 3. handle : name.js -> "name_js"
* 4. url : url to file in wordpress
* 5. path : path to file in server
* 6. version : used to avoid browser caching
* 7. depends : string if depends on a handle, or ''
* 8. attr : associative array of html attribute like 'type'=>'module'
* 9. inline : array("js" => "name.js") -> js
* array("css" => "name.css") -> css
*/
private function init_src($key, $value) {
if (empty($value))
return null;
$src = (object)[
'src' => null,
'ext' => null,
'basename' => null,
'handle' => null,
'url' => null,
'path' => null,
'version' => null,
'depends' => null,
'attr' => null,
'inline' => null,
];
// 7. depends
$src->depends = '';
if (is_string($key))
$src->depends = $key;
// 0. src
// 8. attr
// 9. inline
// first element of array is used, so must not be empty
// value => ['path/to/file', 'key1'=>'value1', 'key2'=>'value2']
// src => 'path/to/file'
// attr => ['key1'=>'value1', 'key2'=>'value2']
if (is_array($value)){
$first_key = array_keys($value)[0];
if (empty($value[$first_key]))
return null;
if ($first_key === 0) { // is a script file or url with attributes
$src->src = array_shift($value);
$src->attr = $value;
}
else if ($first_key === "js" || $first_key === "css") { // is an inline code
$src->src = $value[$first_key];
$src->inline = $first_key;
return $src; // inline only needs 'depends', 'src' and 'inline'
}
}
else {
$src->src = $value;
$src->attr = null;
}
// 1. ext
if(filter_var($src->src, FILTER_VALIDATE_URL))
$src->ext = "url";
else
$src->ext = pathinfo($src->src, PATHINFO_EXTENSION);
if (! in_array($src->ext, array("js", "css", "html", "url")))
return null;
// 2. basename
// 3. handle
// basename handle
// https://www.url.com/route -> www.url.com/route -> www_url_com_route
// path/to/script.js -> script.js -> script_js
if ($src->ext === "url")
{
$url = parse_url($src->src);
$src->basename = $url['host'] . $url['path'];
}
else
$src->basename = pathinfo($src->src, PATHINFO_BASENAME);
$src->handle = "PLGNTLS_" . str_replace(array('.', '/'), "_", $src->basename);
// 4. url
// 5. path
// 6. version
if ($src->ext === "url") {
$src->url = $src->src;
$src->path = null;
$src->version = null;
}
else {
$src->url = $this->get_url().$src->src;
$src->path = $this->get_path().$src->src;
$src->version = date("ymd-Gis", filemtime($src->path));
}
// if ext is 'js' or 'url' and attr is not empty
// also add to global variable to access in 'wp_script_attributes' filter
if ($src->ext === 'js' || $src->ext === 'url') {
if ($src->attr !== null) {
$this->_scripts_attributes[$src->handle.'-js'] = $src->attr;
}
}
return $src;
}
}
?>

View File

@@ -1,22 +0,0 @@
/**
* this file is there for scripts that uses modules import
*/
export function PLGNTLS_fetch(url, options = {}) {
console.log("inside PLGNTLS_fetch");
url = PLGNTLS_data.fetch_url + url;
options.headers = options.headers || {};
options.headers['X-WP-Nonce'] = PLGNTLS_data.fetch_nonce,
console.log("options:", options);
return fetch(url, options);
}
/**
* For non-module scripts, attach to the global scope
*/
if (typeof window !== 'undefined') {
window.PLGNTLS_fetch = PLGNTLS_fetch;
}

View File

@@ -1,28 +0,0 @@
<?php
/*
Plugin Name: formbuilder url patch
Plugin URI:
Description:
Author: hugogogo
Version: 1.1.0
Author URI:
*/
/**
* 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 = plugin_dir_url(__FILE__) . 'jquery_validator_url_patch.js';
$dependencies = array('de_fb_validate');
$version = '';
$defer = true;
wp_enqueue_script( $handle, $url, $dependencies, $version, $defer);
}
add_action('wp_enqueue_scripts', 'add_my_jquery_patch');
?>

View File

@@ -1,8 +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'
);

1
plugins/xtxpatch Submodule

Submodule plugins/xtxpatch added at e8ee5c898d

Some files were not shown because too many files have changed in this diff Show More