Compare commits
215 Commits
debug_rout
...
fix-paymen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cae655af7e | ||
|
|
17afb658af | ||
|
|
f6b31dec8d | ||
|
|
9cdc6a0091 | ||
|
|
e58e772c7c | ||
|
|
edd6368a79 | ||
|
|
9c51f794ca | ||
|
|
cca1523bd7 | ||
|
|
ab5e209f8e | ||
|
|
3abe90b6d3 | ||
|
|
03b24baaff | ||
|
|
b75f2718b8 | ||
|
|
746919082a | ||
|
|
61be6143a3 | ||
|
|
a73cacd5e9 | ||
|
|
0d20d71a7e | ||
|
|
d402e9a7e3 | ||
|
|
101d27be55 | ||
|
|
2205044f74 | ||
|
|
7a704a400b | ||
|
|
fcfd52bda9 | ||
|
|
a357c64fbc | ||
|
|
687ac0cf4e | ||
|
|
2397b24b57 | ||
|
|
24afcffae4 | ||
|
|
343f34a15a | ||
|
|
1447fdbc8e | ||
|
|
5553c78b21 | ||
|
|
51097aa0de | ||
|
|
70b2afe577 | ||
|
|
6bbedf52cb | ||
|
|
f2bcc51ec0 | ||
|
|
782d45f115 | ||
|
|
b059101f15 | ||
|
|
3a1f0b07ee | ||
|
|
62dcaa7672 | ||
|
|
d3e0fbb99e | ||
|
|
d2e4edaec2 | ||
|
|
8479efc51e | ||
|
|
f92e86a473 | ||
|
|
5a78817979 | ||
|
|
48ecd1d97b | ||
|
|
ba432acbfc | ||
|
|
5c09506356 | ||
|
|
6541f4d407 | ||
|
|
e07aa0e57f | ||
|
|
2d6fef598b | ||
|
|
223b925097 | ||
|
|
383de4ecb4 | ||
|
|
f42ba9a1c3 | ||
|
|
14c9b6a6c2 | ||
|
|
bfa68a4dd7 | ||
|
|
6aa3915ef9 | ||
|
|
f2ca863dcb | ||
|
|
6a7de4dadd | ||
|
|
6ecffc25f7 | ||
|
|
265664537e | ||
|
|
114c6bfe38 | ||
|
|
088c8f8c39 | ||
|
|
5cde5cd913 | ||
|
|
215d778307 | ||
|
|
1775c86c25 | ||
|
|
1f03fa1a7b | ||
|
|
a2e37cf621 | ||
|
|
364553612a | ||
|
|
e48eb9cb51 | ||
|
|
e77e41073f | ||
|
|
db4cd0ad55 | ||
|
|
ec9bddaefd | ||
|
|
731b69d97d | ||
|
|
36dc26817a | ||
|
|
272bc07f81 | ||
|
|
8925611217 | ||
|
|
598365330c | ||
|
|
4c0e4c001f | ||
|
|
1e291d16ba | ||
|
|
926bdc8417 | ||
|
|
f987c2a316 | ||
|
|
6de3205480 | ||
|
|
29834a9b9b | ||
|
|
4948298b8a | ||
|
|
6cd25725e0 | ||
|
|
c87ba760fc | ||
|
|
91a67d955b | ||
|
|
1628eac171 | ||
|
|
19fc5f17a6 | ||
|
|
11b4a2efcc | ||
|
|
15b315b4f3 | ||
|
|
d2b2967218 | ||
|
|
8ac16dc1f4 | ||
|
|
913165a056 | ||
|
|
a34b9173cf | ||
|
|
ffc47a0295 | ||
|
|
59b9acc55e | ||
|
|
1553490444 | ||
|
|
1d36093d9f | ||
|
|
9abe24b3bb | ||
|
|
9e903a2ecf | ||
|
|
2329482aa1 | ||
|
|
7a5b1f63d3 | ||
|
|
67bebe4cfc | ||
|
|
ccb800c203 | ||
|
|
47360119e8 | ||
|
|
1f5fff26d6 | ||
|
|
64dc0ffbc5 | ||
|
|
bc06828093 | ||
|
|
86539d5c14 | ||
|
|
b24f0f4210 | ||
|
|
fb146ecda4 | ||
|
|
4d7906be40 | ||
|
|
75205571fe | ||
|
|
0a30bca907 | ||
|
|
5d4be76102 | ||
|
|
995e230e32 | ||
|
|
b4745ff672 | ||
|
|
3e2174a23f | ||
|
|
7ad01a51ba | ||
|
|
ca13c5dccb | ||
|
|
0f554444dd | ||
|
|
1268dc56e3 | ||
|
|
95c292c626 | ||
|
|
2682f3bcd4 | ||
|
|
ade0be87ce | ||
|
|
42e8cbc4e9 | ||
|
|
50c05df2b6 | ||
|
|
dd0d4dfbeb | ||
|
|
a0018c903b | ||
|
|
8b70bea62a | ||
|
|
ab6d825724 | ||
|
|
0808c83589 | ||
|
|
0136be4316 | ||
|
|
dbb6dc0d19 | ||
|
|
27e1e69dfb | ||
|
|
90fb5bc0b6 | ||
|
|
44a5d93f77 | ||
|
|
c9f0522ecc | ||
|
|
4036f4300d | ||
|
|
6ec621a20b | ||
|
|
8ebbb8bff2 | ||
|
|
f055a10d1c | ||
|
|
85e5a34e42 | ||
|
|
569f4524d3 | ||
|
|
1745d8754d | ||
|
|
28a1f7922d | ||
|
|
1856943bc9 | ||
|
|
f882caf850 | ||
|
|
1415fc14a2 | ||
|
|
94dbe05f87 | ||
|
|
5c93938b53 | ||
|
|
b05b5f375e | ||
|
|
46885fe10e | ||
|
|
aae40be620 | ||
|
|
b6d1d63b93 | ||
|
|
1fe5379845 | ||
|
|
cb9042a746 | ||
|
|
ab9afab160 | ||
|
|
66fbbfd586 | ||
|
|
782ae1b1d8 | ||
|
|
fcd7aae681 | ||
|
|
dc77784fef | ||
|
|
68905de5d5 | ||
|
|
c973af3131 | ||
|
|
b57fb6156c | ||
|
|
c69df03c75 | ||
|
|
8933b3d321 | ||
|
|
abd9717fe0 | ||
|
|
578502838e | ||
|
|
b93a3298d2 | ||
|
|
0717a7d9e4 | ||
|
|
58f287f00f | ||
|
|
4eee697078 | ||
|
|
f9788fa96e | ||
|
|
0ab26c0b31 | ||
|
|
227d07fe46 | ||
|
|
33adb095e5 | ||
|
|
0127d8db4c | ||
|
|
61063cabd9 | ||
|
|
1248c2339d | ||
|
|
d264e6c321 | ||
|
|
4de26b79fc | ||
|
|
58d02708b9 | ||
|
|
cbfbfabd18 | ||
|
|
f7c805f22b | ||
|
|
db1d16bd91 | ||
|
|
2f0b15dd6f | ||
|
|
aad98c5188 | ||
|
|
5010b70d79 | ||
|
|
f221e43807 | ||
|
|
5e7ca4f0f1 | ||
|
|
0b8b479584 | ||
|
|
e1f4799150 | ||
|
|
9cda6f13bd | ||
|
|
cabee4db30 | ||
|
|
ba1d3e3707 | ||
|
|
c1b687064f | ||
|
|
5be80d1566 | ||
|
|
98dfb17bf4 | ||
|
|
82b6593dd9 | ||
|
|
fcb15c97d1 | ||
|
|
874736fd8a | ||
|
|
c39a656ab1 | ||
|
|
a245bd4350 | ||
|
|
eaa45c4ed1 | ||
|
|
70d8998a3f | ||
|
|
fc41f7d36b | ||
|
|
f9b245c39c | ||
|
|
6ad1fb5137 | ||
|
|
494943e4f7 | ||
|
|
6c7b269052 | ||
|
|
9ebce56025 | ||
|
|
70888d384c | ||
|
|
0d6d475ce0 | ||
|
|
4c81476336 | ||
|
|
30c84135ef | ||
|
|
4220c34c7f |
13
.gitmodules
vendored
13
.gitmodules
vendored
@@ -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
|
||||
|
||||
304
gitlog.md
Normal file
304
gitlog.md
Normal 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
|
||||
368
plugins/cipf_plugin/cipf_plugin.php
Normal file
368
plugins/cipf_plugin/cipf_plugin.php
Normal 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';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
19
plugins/cipf_plugin/css/acf_fields.css
Normal file
19
plugins/cipf_plugin/css/acf_fields.css
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
3
plugins/cipf_plugin/css/display_states/_default.css
Normal file
3
plugins/cipf_plugin/css/display_states/_default.css
Normal file
@@ -0,0 +1,3 @@
|
||||
[class*='cipf_display_'] {
|
||||
display: none !important;
|
||||
}
|
||||
9
plugins/cipf_plugin/css/display_states/carte_changer.css
Normal file
9
plugins/cipf_plugin/css/display_states/carte_changer.css
Normal 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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
9
plugins/cipf_plugin/css/display_states/carte_payer.css
Normal file
9
plugins/cipf_plugin/css/display_states/carte_payer.css
Normal 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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
4
plugins/cipf_plugin/css/display_states/type_paypal.css
Normal file
4
plugins/cipf_plugin/css/display_states/type_paypal.css
Normal 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; }
|
||||
|
||||
4
plugins/cipf_plugin/css/display_states/type_virement.css
Normal file
4
plugins/cipf_plugin/css/display_states/type_virement.css
Normal 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; }
|
||||
|
||||
59
plugins/cipf_plugin/css/fipf_user_profile.css
Normal file
59
plugins/cipf_plugin/css/fipf_user_profile.css
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* [/] Options personnelles,
|
||||
* [/] À propos du compte,
|
||||
* [/] Mots de passe d’application,
|
||||
* [/] 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;
|
||||
}
|
||||
@@ -1,6 +1,131 @@
|
||||
#mytext {
|
||||
border: 1px solid blue;
|
||||
h1 {
|
||||
margin-left: 15px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
#mytext_2 {
|
||||
border: 1px solid green;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
plugins/cipf_plugin/css/partner_page.css
Normal file
3
plugins/cipf_plugin/css/partner_page.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.partenaire_propre_page_cipf {
|
||||
display: none;
|
||||
}
|
||||
3
plugins/cipf_plugin/css/partner_page_own.css
Normal file
3
plugins/cipf_plugin/css/partner_page_own.css
Normal file
@@ -0,0 +1,3 @@
|
||||
div.partenaire_propre_page_cipf {
|
||||
display: block;
|
||||
}
|
||||
6
plugins/cipf_plugin/css/user_profile.css
Normal file
6
plugins/cipf_plugin/css/user_profile.css
Normal file
@@ -0,0 +1,6 @@
|
||||
#your-profile .acf-field-textarea.textarea_full_width {
|
||||
textarea {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: cipf_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
|
||||
PLGNTLS_class::set_root_dir( plugin_dir_path(__FILE__), plugin_dir_url(__FILE__) );
|
||||
*/
|
||||
include_once( plugin_dir_path(__FILE__) . '/utils/plgntls_class.php');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* general inclusions
|
||||
*/
|
||||
// utils :
|
||||
include_once(PLGNTLS_class::root_path() . 'php/utils/globals.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'utils/console_log.php');
|
||||
|
||||
include_once(PLGNTLS_class::root_path() . 'php/admin_menu/example_menu.php');
|
||||
|
||||
include_once(PLGNTLS_class::root_path() . 'php/paypal/paypal.php');
|
||||
|
||||
include_once(PLGNTLS_class::root_path() . '/php/user_infos.php');
|
||||
//include_once(PLGNTLS_class::root_path() . '/php/hide_admin.php');
|
||||
//include_once(PLGNTLS_class::root_path() . '/php/menus.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/register_partenaires.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/redirections.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/author_restriction.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/filter_mail.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/prof_check_page.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/renew_card.php');
|
||||
//include_once(PLGNTLS_class::root_path() . 'php/reset_card_form.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/partner_check_page.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/format_user_infos.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/admin_modif_prof.php');
|
||||
|
||||
|
||||
// form builder patch :
|
||||
/*
|
||||
include_once(PLGNTLS_class::root_path() . 'php/form_builder_patch/url_validation.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/form_builder_patch/multiple_modals.php');
|
||||
include_once(PLGNTLS_class::root_path() . 'php/form_builder_patch/form_calculation.php');
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
225
plugins/cipf_plugin/html/menu/cipf_menu.html
Normal file
225
plugins/cipf_plugin/html/menu/cipf_menu.html
Normal 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>
|
||||
@@ -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>
|
||||
124
plugins/cipf_plugin/html/menu/explications_acf_groups.html
Normal file
124
plugins/cipf_plugin/html/menu/explications_acf_groups.html
Normal 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>
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
|
||||
cipf_admin_activate_prof_form
|
||||
*/
|
||||
|
||||
function admin_activate_form_submit_prevent_CIPF() {
|
||||
let form_activate_prof = document.querySelector('#cipf_admin_activate_prof_form form');
|
||||
console.log("form:");
|
||||
console.log(form_activate_prof);
|
||||
if (form_activate_prof === null)
|
||||
return;
|
||||
|
||||
function handle_form(event) {
|
||||
event.preventDefault();
|
||||
let form_data = new FormData(event.target);
|
||||
for (var pair of form_data.entries()) {
|
||||
console.log(pair[0]+ ': ' + pair[1]);
|
||||
}
|
||||
}
|
||||
|
||||
form_activate_prof.addEventListener('submit', handle_form);
|
||||
}
|
||||
admin_activate_form_submit_prevent_CIPF();
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
|
||||
function patch_form_calculation_CIPF() {
|
||||
let form_calculation = document.querySelector('form.fb_form.multistep');
|
||||
if (form_calculation === null)
|
||||
return;
|
||||
|
||||
/*
|
||||
* finds the input:checked in the element .calculate_field
|
||||
* and trigger the event 'change' on it
|
||||
* - this event 'change' is added by form builder in divi-form-calc-min.js :
|
||||
* $(document).on(
|
||||
* 'change',
|
||||
* '.calculate_field input:not([type="hidden"]), .calculate_field select',
|
||||
* function () {
|
||||
* ...
|
||||
* }
|
||||
* );
|
||||
*
|
||||
*/
|
||||
function trigger_change(element) {
|
||||
/*
|
||||
* jquery version
|
||||
*
|
||||
let inputs = $(element).find('input:checked');
|
||||
inputs.trigger('change');
|
||||
*/
|
||||
|
||||
/*
|
||||
* js version
|
||||
*
|
||||
*/
|
||||
let inputs = element.querySelectorAll('input:checked');
|
||||
// loop through inputs and trigger 'change' event on each
|
||||
inputs.forEach(function(input) {
|
||||
// Triggering 'change' event
|
||||
let change_event = new Event('change', {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
});
|
||||
input.dispatchEvent(change_event);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// create an observer on form to check if child nodes are modified
|
||||
const observer_form = new MutationObserver(wait_for_calculation_class);
|
||||
observer_form.observe(form_calculation, {
|
||||
subtree: true,
|
||||
attributes: true,
|
||||
});
|
||||
|
||||
// observe mutations to see if they include the addition of class .calculate_field
|
||||
// if the class is added, call the function that might trigger the change event on it
|
||||
function wait_for_calculation_class(mutationsList) {
|
||||
mutationsList.forEach((mutation) => {
|
||||
// check if class where added
|
||||
if (mutation.type !== 'attributes')
|
||||
return;
|
||||
if (mutation.attributeName !== 'class')
|
||||
return;
|
||||
// check if added class is .calculate_field
|
||||
let target = mutation.target;
|
||||
if (target.classList.contains('calculate_field')) {
|
||||
// If the class is added, trigger the 'change' event
|
||||
trigger_change(target);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
patch_form_calculation_CIPF();
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
let modal_wrapper_CIPF = document.querySelector('#de-fb-modal-wrapper-');
|
||||
|
||||
// create an observer on first #de-fb-modal-wrapper- to check if child nodes are added
|
||||
const observer_CIPF = new MutationObserver(wait_for_close_button_CIPF);
|
||||
observer_CIPF.observe(modal_wrapper_CIPF, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
});
|
||||
|
||||
// observe mutations to see if they include the creation of the button .modal-close
|
||||
// if the button is created, add an eventListener to it
|
||||
function wait_for_close_button_CIPF(mutationsList) {
|
||||
mutationsList.forEach((mutation) => {
|
||||
// check if nodes were added
|
||||
if (mutation.type !== 'childList')
|
||||
return;
|
||||
// check if added nodes includes the button .modal-close
|
||||
let modal_close = document.querySelector('#de-fb-modal-wrapper- .modal-close');
|
||||
if (modal_close !== null) {
|
||||
modal_close.addEventListener("click", delete_modal_CIPF);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// when triggered, the .modal-close button will remove all childs from #de-fb-modal-wrapper-
|
||||
function delete_modal_CIPF() {
|
||||
modal_wrapper_CIPF.innerHTML = '';
|
||||
}
|
||||
|
||||
@@ -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,4 +0,0 @@
|
||||
|
||||
import { test_fetch } from './example_submenu.js';
|
||||
|
||||
test_fetch();
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { resultMessage } from './result_message.js';
|
||||
import { PLGNTLS_fetch } from '../../utils/plgntls_fetch.js';
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
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
|
||||
@@ -22,6 +20,7 @@ export async function onApprove(data, actions) {
|
||||
// (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];
|
||||
|
||||
@@ -35,7 +34,16 @@ export async function onApprove(data, actions) {
|
||||
throw new Error(`${errorDetail.description} (${orderData.debug_id})`);
|
||||
}
|
||||
else if (!orderData.purchase_units) {
|
||||
throw new Error(JSON.stringify(orderData));
|
||||
// Check if error was a server-side issue but PayPal confirmed payment
|
||||
if (orderData.ERROR_TREATMENT) {
|
||||
console.log("Capture result - Server processing error, but payment may be valid:",orderData);
|
||||
// Display problem message - payment succeeded on PayPal but failed locally
|
||||
// User stays on page to see the message
|
||||
resultMessage(PLGNTLS_data.paypal_message_problem);
|
||||
}
|
||||
else {
|
||||
throw new Error(JSON.stringify(orderData));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// (3) Successful transaction -> Show confirmation or thank you message
|
||||
@@ -43,16 +51,14 @@ export async function onApprove(data, actions) {
|
||||
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`);
|
||||
resultMessage(eval(PLGNTLS_data.paypal_message_success));
|
||||
console.log("Capture result - Success:",orderData);
|
||||
resultMessage(PLGNTLS_data.paypal_message_success);
|
||||
actions.redirect(PLGNTLS_data.paypal_redirection_success);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
//resultMessage(`Sorry, your transaction could not be processed...<br><br>${error}`);
|
||||
resultMessage(eval(PLGNTLS_data.paypal_message_failure));
|
||||
}
|
||||
catch (error) {
|
||||
console.error("Payment approval error:", error);
|
||||
resultMessage(PLGNTLS_data.paypal_message_failure);
|
||||
actions.redirect(PLGNTLS_data.paypal_redirection_failure);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
209
plugins/cipf_plugin/php/_actions_emails.php
Normal file
209
plugins/cipf_plugin/php/_actions_emails.php
Normal 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);
|
||||
}
|
||||
|
||||
?>
|
||||
244
plugins/cipf_plugin/php/_actions_newsletter.php
Normal file
244
plugins/cipf_plugin/php/_actions_newsletter.php
Normal 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
177
plugins/cipf_plugin/php/_actions_payments.php
Normal file
177
plugins/cipf_plugin/php/_actions_payments.php
Normal 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'];
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
40
plugins/cipf_plugin/php/_actions_random_posts.php
Normal file
40
plugins/cipf_plugin/php/_actions_random_posts.php
Normal 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');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
349
plugins/cipf_plugin/php/_actions_scheduled_events.php
Normal file
349
plugins/cipf_plugin/php/_actions_scheduled_events.php
Normal 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);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
271
plugins/cipf_plugin/php/_utils_acf_dates.php
Normal file
271
plugins/cipf_plugin/php/_utils_acf_dates.php
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
161
plugins/cipf_plugin/php/_utils_acf_disabled.php
Normal file
161
plugins/cipf_plugin/php/_utils_acf_disabled.php
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
1008
plugins/cipf_plugin/php/_utils_acf_fields.php
Normal file
1008
plugins/cipf_plugin/php/_utils_acf_fields.php
Normal file
File diff suppressed because it is too large
Load Diff
124
plugins/cipf_plugin/php/_utils_checks_roles.php
Normal file
124
plugins/cipf_plugin/php/_utils_checks_roles.php
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
128
plugins/cipf_plugin/php/_utils_display_css.php
Normal file
128
plugins/cipf_plugin/php/_utils_display_css.php
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
188
plugins/cipf_plugin/php/_utils_redirections.php
Normal file
188
plugins/cipf_plugin/php/_utils_redirections.php
Normal 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();
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
95
plugins/cipf_plugin/php/admin_hide_bar.php
Normal file
95
plugins/cipf_plugin/php/admin_hide_bar.php
Normal 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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
261
plugins/cipf_plugin/php/admin_menu.php
Normal file
261
plugins/cipf_plugin/php/admin_menu.php
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* it means someone outside wp is accessing the file, in this case kill it.
|
||||
*/
|
||||
if (!defined('ABSPATH')) {
|
||||
die('You can not access this file!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* menu plugin
|
||||
*/
|
||||
function cipfcard_plugin_menu() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
add_menu_page
|
||||
(
|
||||
'cipf_card', // webpage title
|
||||
'cipf_card', // menu title
|
||||
'manage_options', // capability
|
||||
'cipfcard-plugin', // menu_slug
|
||||
'cipfcard_plugin_content' // callback function to display page content
|
||||
);
|
||||
}
|
||||
add_action('admin_menu', 'cipfcard_plugin_menu');
|
||||
|
||||
|
||||
|
||||
|
||||
function cipfcard_plugin_content() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$cipfcard = new PLGNTLS_class();
|
||||
|
||||
$my_css = '
|
||||
#mytext {
|
||||
background-color: lightblue;
|
||||
}
|
||||
#mytext_2 {
|
||||
background-color: lightgreen;
|
||||
}
|
||||
';
|
||||
echo $cipfcard->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 cipfcard_menu_fetch_handler() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
return new WP_REST_Response('hello', 200);
|
||||
}
|
||||
function cipfcard_menu_endpoint() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
register_rest_route('plgntls', '/get_data', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'cipfcard_menu_fetch_handler',
|
||||
));
|
||||
};
|
||||
add_action('rest_api_init', 'cipfcard_menu_endpoint');
|
||||
|
||||
?>
|
||||
@@ -1,207 +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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* custom action in php on custom form submission
|
||||
* custom forms are not processed by divi form builder
|
||||
* so they don't change between hooks before and after process
|
||||
*
|
||||
*/
|
||||
function admin_validate_prof_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* calling the action to validate from the FormBuilder hook
|
||||
*
|
||||
*/
|
||||
function custom_form_admin_validate_prof_CIPF($form_id, $post_array, $form_type) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$admin_validate_prof_field = PLGNTLS_class::ADMIN_VALIDATE_PROF_FIELD;
|
||||
|
||||
if ($form_type !== 'custom')
|
||||
return;
|
||||
error_log("---");
|
||||
error_log("in test_form_CIPF");
|
||||
// error_log("form_id");
|
||||
// error_log(json_encode($form_id));
|
||||
// error_log("post_array");
|
||||
// error_log(json_encode($post_array));
|
||||
// error_log("form_type");
|
||||
// error_log(json_encode($form_type));
|
||||
|
||||
$field_id = $post_array['field_id'];
|
||||
$contains_id = in_array($admin_validate_prof_field, $field_id);
|
||||
if ($contains_id === false)
|
||||
return;
|
||||
|
||||
admin_validate_prof_CIPF();
|
||||
}
|
||||
add_action('df_before_process', 'custom_form_admin_validate_prof_CIPF', 10, 3);
|
||||
|
||||
|
||||
/*
|
||||
* calling the action to validate from the
|
||||
*
|
||||
function custom_link_intercept() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$query_page_redirection = PLGNTLS_class::QUERY_REDIRECTION_PROFIL;
|
||||
|
||||
// Check if the request contains ?QUERY_REDIRECTION_PROFIL
|
||||
if(isset($_GET[$query_page_redirection])) {
|
||||
admin_validate_prof_CIPF();
|
||||
}
|
||||
}
|
||||
add_action('init', 'custom_link_intercept');
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
before :
|
||||
|
||||
|
||||
in test_form_CIPF
|
||||
form_id
|
||||
""
|
||||
post_array
|
||||
{"field_title":["\u00c9tat du compte"],"field_name":["de_fb_compte-actif"],"field_id":["de_fb_field_1"],"form_type_confirm":""}
|
||||
form_type
|
||||
"custom"
|
||||
|
||||
---
|
||||
|
||||
after :
|
||||
|
||||
|
||||
in test_form_CIPF
|
||||
form_id
|
||||
""
|
||||
post_array
|
||||
{"field_title":["\u00c9tat du compte"],"field_name":["de_fb_compte-actif"],"field_id":["de_fb_field_1"],"form_type_confirm":""}
|
||||
form_type
|
||||
"custom"
|
||||
|
||||
---
|
||||
|
||||
exploded view :
|
||||
|
||||
{
|
||||
"field_title":["\u00c9tat du compte"],
|
||||
"field_name":["de_fb_compte-actif"],
|
||||
"field_id":["de_fb_field_1"],
|
||||
"form_type_confirm":""
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
"field_title":["\u00c9tat du compte"],
|
||||
"field_name":["de_fb_compte-actif"],
|
||||
"field_id":["de_fb_field_1"],
|
||||
"compte-actif":"Actif",
|
||||
"form_type_confirm":""
|
||||
}
|
||||
CIPF_admin_activation_prof
|
||||
{
|
||||
"field_title":["\u00c9tat du compte"],
|
||||
"field_name":["compte-actif"],
|
||||
"field_id":["cipf_admin_activation_prof"],
|
||||
"compte-actif":"Inactif",
|
||||
"form_type_confirm":""
|
||||
}
|
||||
|
||||
--- with field test :
|
||||
|
||||
{
|
||||
"field_title":["\u00c9tat du compte","test"],
|
||||
"field_name":["compte-actif","de_fb_field_3"],
|
||||
"field_id":["cipf_admin_activation_prof","de_fb_field_3"],
|
||||
"field_3":"",
|
||||
"form_type_confirm":""
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ABORTED
|
||||
* tried to receive the form in ajax from front with wp REST API
|
||||
* but I cannot verify if the user is logged in
|
||||
* so it does not work
|
||||
*
|
||||
function admin_validate_prof_form_CIPF($request) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
|
||||
error_log("-----");
|
||||
error_log("inside admin_validate_prof_form_CIPF");
|
||||
error_log("request");
|
||||
error_log(json_encode($request));
|
||||
error_log("_POST");
|
||||
error_log(json_encode($_POST));
|
||||
// _POST : {"field_title":["\u00c9tat du compte"],"field_name":["compte-actif"],"field_id":["cipf_admin_activate_prof"],"form_key":"40781-1","unique_id":"91eed9aa-2b92-4da7-a0b4-e94f24515223","form_type":"custom","divi-form-submit":"yes","form_id":"","form_type_confirm":""}
|
||||
|
||||
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
|
||||
nocache_headers();
|
||||
$redirect_url = home_url() . '/' . $slug_page_redirection;
|
||||
wp_redirect($redirect_url, 301);
|
||||
exit;
|
||||
}
|
||||
function endpoint_form_admin_activate_prof_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$base_rest_route = PLGNTLS_class::URL_BASE_REST_ROUTE;
|
||||
|
||||
register_rest_route($base_rest_route, '/admin_prof_activate_form', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'admin_validate_prof_form_CIPF',
|
||||
));
|
||||
};
|
||||
add_action('rest_api_init', 'endpoint_form_admin_activate_prof_CIPF');
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ABORTED
|
||||
* enqueue script that should prevent the form to submit, but does not work
|
||||
*
|
||||
function admin_validate_prof_prevent_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$handle = 'admin_prevent_submit';
|
||||
$url = PLGNTLS_class::root_url() . 'js/admin_prevent_submit.js';
|
||||
$dependencies = array();
|
||||
$version = null;
|
||||
$defer = true;
|
||||
wp_enqueue_script($handle, $url, $dependencies, $version, $defer);
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'admin_validate_prof_prevent_CIPF');
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
30
plugins/cipf_plugin/php/admin_partner.php
Normal file
30
plugins/cipf_plugin/php/admin_partner.php
Normal 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');
|
||||
|
||||
|
||||
|
||||
?>
|
||||
48
plugins/cipf_plugin/php/admin_user_profil.php
Normal file
48
plugins/cipf_plugin/php/admin_user_profil.php
Normal 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');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -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 restrict_author_page_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$role_fipf = PLGNTLS_class::ROLE_FIPF;
|
||||
$role_admin = PLGNTLS_class::ROLE_ADMIN;
|
||||
|
||||
if (!is_author())
|
||||
return;
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
$allowed_roles = array($role_admin, $role_fipf);
|
||||
if (array_intersect($allowed_roles, $current_user->roles))
|
||||
return;
|
||||
|
||||
/*
|
||||
* get_queried_object_id() would work too
|
||||
* here get_the_author_meta works and is more explicit
|
||||
*
|
||||
$author_id = get_queried_object_id();
|
||||
*/
|
||||
$author_id = get_the_author_meta( 'ID' );
|
||||
|
||||
$current_user_id = get_current_user_id();
|
||||
|
||||
if ($current_user_id != $author_id) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
add_action('template_redirect', 'restrict_author_page_CIPF', 10);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,140 +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::root_path() . 'php/format_user_infos.php');
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* callback to provide the user info corresponding to the $$key_word$$
|
||||
*
|
||||
*/
|
||||
function replace_words_CIPF($matches, $user_id = null) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
if ($user_id !== null) {
|
||||
$current_user = get_user_by('id', $user_id);
|
||||
}
|
||||
else if (is_user_logged_in()) {
|
||||
$current_user = wp_get_current_user();
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
|
||||
if ($current_user === false)
|
||||
return "";
|
||||
|
||||
$query = $matches[1];
|
||||
$result = format_user_info_CIPF($query, $current_user, $user_id);
|
||||
|
||||
/*
|
||||
* if result is array, take the first element (not ideal)
|
||||
*
|
||||
*/
|
||||
if (is_array($result))
|
||||
$result = reset($result);
|
||||
|
||||
/*
|
||||
* if is special query __author_page__
|
||||
* return author page url
|
||||
*
|
||||
*/
|
||||
if ($query === '__author_page__') {
|
||||
$current_user_id = get_current_user_id();
|
||||
$result = get_author_posts_url($current_user_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* if no match, return $$<query>$$
|
||||
*
|
||||
*/
|
||||
if (empty($result))
|
||||
return $matches[0];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* filter emails in the form-builder hook, before the wp_mail hook
|
||||
* it receives the id of the user, no need to have the user still logged-in
|
||||
*
|
||||
*/
|
||||
function filter_email_fb_CIPF($reply_body, $post_array) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$id = $post_array['ID'];
|
||||
// pattern : anything surrounded by '$$', ex : $$value$$
|
||||
$pattern = '/\$\$(.*?)\$\$/';
|
||||
|
||||
// inline callback, with 'use' to get the id
|
||||
$new_body = preg_replace_callback($pattern, function($matches) use ($id) {
|
||||
return replace_words_CIPF($matches, $id);
|
||||
}, $reply_body);
|
||||
|
||||
return $new_body;
|
||||
}
|
||||
add_filter('df_confirmation_body', 'filter_email_fb_CIPF', 10, 2); // the receive an email
|
||||
add_filter('df_notification_body', 'filter_email_fb_CIPF', 10, 2); // the admin receive a notification
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* filter emails at the final point : the wp_mail hook
|
||||
* it uses a callback that rely on the logged-in user
|
||||
* it will works well most of the time, but it's possible
|
||||
* that a user logged out before the email is sent
|
||||
* or event that a different user has already logged in
|
||||
*/
|
||||
function filter_email_wp_CIPF($args) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
// pattern : anything surrounded by '$$', ex : $$value$$
|
||||
$pattern = '/\$\$(.*?)\$\$/';
|
||||
|
||||
$old_body = $args['message'];
|
||||
$new_body = preg_replace_callback($pattern, 'replace_words_CIPF', $old_body);
|
||||
$args['message'] = $new_body;
|
||||
|
||||
return $args;
|
||||
}
|
||||
add_filter('wp_mail', 'filter_email_wp_CIPF', 10, 1);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
all filters in form_builder :
|
||||
|
||||
1 $body = apply_filters( 'df_notification_body', $body, $post_array );
|
||||
2 $email = apply_filters( 'df_notifcation_recipient', $email, $form_id, $post_array );
|
||||
3 $title = apply_filters( 'wpml_translate_single_string', $title_get, 'divi-form-builder', 'Edit Post Button Title Text' );
|
||||
|
||||
4 $body = apply_filters( 'df_contact_body', $body, $post_array );
|
||||
5 $body = apply_filters( 'df_contact_body', $body, $post_array );
|
||||
|
||||
6 $email = apply_filters( 'df_contact_recipient', $email, $form_id, $post_array );
|
||||
7 $email = apply_filters( 'df_contact_recipient', $email, $form_id, $processed_post_array );
|
||||
|
||||
8 $reply_body = apply_filters( 'df_confirmation_body', $reply_body, $post_array );
|
||||
9 $reply_body = apply_filters( 'df_confirmation_body', $reply_body, $post_array );
|
||||
10 $reply_body = apply_filters( 'df_confirmation_body', $reply_body, $post_array );
|
||||
11 $reply_body = apply_filters( 'df_confirmation_body', $reply_body, $post_array );
|
||||
|
||||
12 $message_content = apply_filters( 'the_content', get_post_field( 'post_content', $message_array['layout'] ) );
|
||||
13 $content = apply_filters( 'the_content', get_post_field( 'post_content', $message_array['layout'] ) );
|
||||
14 $content = apply_filters( 'the_content', get_post_field( 'post_content', $html_content_divi_layout) );
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,27 +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 add_form_calculation_patch_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$handle = 'form_calculation_patch';
|
||||
$url = PLGNTLS_class::root_url() . 'js/form_builder_patch/form_calculation.js';
|
||||
$dependencies = array('de_fb_calc');
|
||||
$version = null;
|
||||
$defer = true;
|
||||
wp_enqueue_script( $handle, $url, $dependencies, $version, $defer);
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'add_form_calculation_patch_CIPF', 999);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,24 +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 test_modal_PLGNTLS() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$cipf_modal = new PLGNTLS_class();
|
||||
$cipf_modal->add_to_front(
|
||||
array(
|
||||
'js/form_builder_patch/multiple_modals.js',
|
||||
));
|
||||
}
|
||||
add_shortcode('test_modal', 'test_modal_PLGNTLS');
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,31 +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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$handle = 'jquery_validator_url_patch';
|
||||
$url = PLGNTLS_class::root_url() . 'js/form_builder_patch/url_validation.js';
|
||||
$dependencies = array('de_fb_validate');
|
||||
$version = null;
|
||||
$defer = true;
|
||||
wp_enqueue_script( $handle, $url, $dependencies, $version, $defer);
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'add_my_jquery_patch');
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,92 +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 format_user_info_CIPF($query, &$current_user, $user_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$output_date_format = PLGNTLS_class::USER_INFO_DATE_FORMAT;
|
||||
|
||||
$is_acf = false;
|
||||
$is_date = false;
|
||||
|
||||
/*
|
||||
* check if it's an acf field
|
||||
* first method : check if _field exist
|
||||
*
|
||||
$_acf_field = '_'.$query;
|
||||
$acf_field = $current_user->$_acf_field;
|
||||
if (!empty($acf_field))
|
||||
$is_acf = true;
|
||||
*/
|
||||
|
||||
/*
|
||||
* check if it's an acf field, and a date
|
||||
* second method : check what get_field_object() returns
|
||||
*
|
||||
*/
|
||||
$acf_id = 'user_'.$user_id;
|
||||
$acf_object = get_field_object($query, $acf_id);
|
||||
if ($acf_object !== false)
|
||||
$is_acf = true;
|
||||
|
||||
|
||||
/*
|
||||
* if is acf, use the acf return format
|
||||
* otherwise, use the default wordpress value
|
||||
*
|
||||
*/
|
||||
if ($is_acf)
|
||||
$output = get_field($query, $acf_id);
|
||||
else
|
||||
$output = $current_user->$query;
|
||||
|
||||
|
||||
/*
|
||||
* check if is date
|
||||
*
|
||||
*/
|
||||
if ($is_acf) {
|
||||
$acf_type = $acf_object['type'];
|
||||
if ($acf_type && $acf_type === "date_picker")
|
||||
$is_date = true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* if is date, transform format
|
||||
*
|
||||
*/
|
||||
if ($is_date) {
|
||||
$acf_date_string = $acf_object['value'];
|
||||
$acf_date_format = $acf_object['return_format'];
|
||||
$date = date_create_from_format($acf_date_format, $acf_date_string);
|
||||
$output = $date->format($output_date_format);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* return the result
|
||||
*
|
||||
*/
|
||||
while (is_array($output) && count($output) === 1)
|
||||
$output = reset($output);
|
||||
if (is_array($output) && count($output) === 0)
|
||||
$output = '';
|
||||
if (!is_string($output))
|
||||
$output = json_encode($output, JSON_UNESCAPED_SLASHES);
|
||||
return esc_html($output);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,28 +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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* hide admin bar if access a front page and is not an admin
|
||||
*/
|
||||
function hide_admin_bar_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$role_admin = PLGNTLS_class::ROLE_ADMIN;
|
||||
|
||||
if (!current_user_can($role_admin) && !is_admin()) {
|
||||
show_admin_bar(false);
|
||||
}
|
||||
}
|
||||
add_action('after_setup_theme', 'hide_admin_bar_CIPF');
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* it means someone outside wp is accessing the file, in this case kill it.
|
||||
*/
|
||||
if (!defined('ABSPATH')) {
|
||||
die('You can not access this file!');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* menu deconnexion
|
||||
* 1. il faut creer un menu personalisé dans Apparence > Menus
|
||||
* 2. dans le code ci-dessous, changer la valeur de $menu_title pour correspondre au titre du menu
|
||||
* 3. et si besoin changer la valeur de $menu_redirect pour choisir la page de redirection :
|
||||
* - si laissée vide, la redirection se fera sur la page de connexion de wordpress
|
||||
* - avec $current_url la redirection se fera sur la page actuelle
|
||||
* - avec $base_url on redirige vers la page d'accueil du site (l'url sans chemin supplementaire)
|
||||
* cette variable $base_url peut etre utilisee pour construire une autre url :
|
||||
* - $menu_redirect = $base_url -> https://le_site_actuel.com/
|
||||
* - $menu_redirect = $base_url . 'contact' -> https://le_site_actuel.com/contact
|
||||
* - $menu_redirect = $current_url -> https://le_site_actuel.com/la_meme_page
|
||||
* - $menu_redirect = 'www.un_autre_site.net/contact' -> https://www.un_autre_site.net/contact
|
||||
*/
|
||||
function change_menu_logout($items){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$menu_title = 'special logout';
|
||||
|
||||
// quelques urls utiles :
|
||||
$base_url = home_url();
|
||||
$current_url = home_url( $_SERVER['REQUEST_URI'] );
|
||||
|
||||
$menu_redirect = '';
|
||||
foreach($items as $item){
|
||||
if( $item->title === $menu_title){
|
||||
$item->url = wp_nonce_url( wp_logout_url( $menu_redirect ), 'log-out' );
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
add_filter('wp_nav_menu_objects', 'change_menu_logout');
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,125 +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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* series of actions to do before printing a partner author page
|
||||
*
|
||||
function check_partner_page_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
|
||||
// the way to find the id of the author of an author_page
|
||||
$author_id = get_queried_object_id();
|
||||
|
||||
}
|
||||
add_action('template_redirect', 'check_partner_page_CIPF', 11);
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
in test_partner_CIPF
|
||||
|
||||
form_id
|
||||
"crea_partenaire"
|
||||
|
||||
post_array
|
||||
{
|
||||
"post_status":"publish",
|
||||
"field_title":[
|
||||
"Nom commercial",
|
||||
"Votre site Internet",
|
||||
"Dans quelle rubrique devez-vous para\u00eetre ? ",
|
||||
"L\\'accroche en t\u00eate de page",
|
||||
"Pr\u00e9sentez-vous",
|
||||
"Votre logo ",
|
||||
"Image principale",
|
||||
"Voulez-vous afficher cette offre ?",
|
||||
"Titre",
|
||||
"Texte de l\\'offre",
|
||||
"Image (facultatif)",
|
||||
"Voulez-vous ajouter une offre ?",
|
||||
"Voulez-vous afficher cette offre ?",
|
||||
"Titre",
|
||||
"Texte de l\\'offre",
|
||||
"Image (facultatif)",
|
||||
"Voulez-vous ajouter une offre ?",
|
||||
"Voulez-vous afficher l\\'offre ?",
|
||||
"Titre",
|
||||
"Texte de l\\'offre",
|
||||
"Image (facultatif)",
|
||||
"slug"
|
||||
],
|
||||
"post_title":"test page partner",
|
||||
"meta_input":[
|
||||
"de_fb_url_partenaire",
|
||||
"de_fb_logo_partenaire",
|
||||
"de_fb_afficher_offre_1",
|
||||
"de_fb_offre_1_titre",
|
||||
"de_fb_offre_1_txt",
|
||||
"de_fb_offre_1_image",
|
||||
"de_fb_ajouter_offre_2",
|
||||
"de_fb_afficher_offre_2",
|
||||
"de_fb_offre_2_titre",
|
||||
"de_fb_offre_2_txt",
|
||||
"de_fb_offre_2_image",
|
||||
"de_fb_ajouter_offre_3",
|
||||
"de_fb_afficher_offre_3",
|
||||
"de_fb_offre_3_titre",
|
||||
"de_fb_offre_3_txt",
|
||||
"de_fb_offre_3_image"
|
||||
],
|
||||
"url_partenaire":"",
|
||||
"tax_input":["de_fb_category"],
|
||||
"category":"autres",
|
||||
"post_excerpt":"accroche test page partner",
|
||||
"post_content":"presentation test page partner",
|
||||
"_ajax_linking_nonce":"2088c0ea4f",
|
||||
"logo_partenaire":"40763",
|
||||
"post_thumbnail":"40764",
|
||||
"afficher_offre_1":"Afficher",
|
||||
"offre_1_titre":"titre offre 1",
|
||||
"offre_1_txt":"text offre 1",
|
||||
"offre_1_image":"",
|
||||
"ajouter_offre_2":"Oui",
|
||||
"afficher_offre_2":"Masquer",
|
||||
"offre_2_titre":"titre offre 2",
|
||||
"offre_2_txt":"text offre 2",
|
||||
"offre_2_image":"",
|
||||
"ajouter_offre_3":"Oui",
|
||||
"afficher_offre_3":"Afficher",
|
||||
"offre_3_titre":"titre offre 3",
|
||||
"offre_3_txt":"text offre 3",
|
||||
"offre_3_image":"",
|
||||
"post_name":"test-page-partner",
|
||||
"ID":"40765",
|
||||
"form_type_confirm":""
|
||||
}
|
||||
|
||||
form_type
|
||||
"post"
|
||||
|
||||
|
||||
function test_partner_CIPF($form_id, $post_array) {
|
||||
error_log("---");
|
||||
error_log("in test_partner_CIPF");
|
||||
error_log("form_id");
|
||||
error_log(json_encode($form_id));
|
||||
error_log("post_array");
|
||||
error_log(json_encode($post_array));
|
||||
}
|
||||
add_action( 'df_before_process', 'test_partner_CIPF', 10, 2);
|
||||
add_action( 'df_after_process', 'test_partner_CIPF', 10, 2);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
?>
|
||||
109
plugins/cipf_plugin/php/partners_form.php
Normal file
109
plugins/cipf_plugin/php/partners_form.php
Normal 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');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
79
plugins/cipf_plugin/php/partners_handle_offers.php
Normal file
79
plugins/cipf_plugin/php/partners_handle_offers.php
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
308
plugins/cipf_plugin/php/partners_page.php
Normal file
308
plugins/cipf_plugin/php/partners_page.php
Normal 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);
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
71
plugins/cipf_plugin/php/partners_register.php
Normal file
71
plugins/cipf_plugin/php/partners_register.php
Normal 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);
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
161
plugins/cipf_plugin/php/paypal/payment_page.php
Normal file
161
plugins/cipf_plugin/php/paypal/payment_page.php
Normal 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');
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -9,14 +9,15 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
|
||||
include_once(PLGNTLS_class::root_path() . '/php/utils/http_errors.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/route_api_utils.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/user_can_pay.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/update_user_payment.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/shortcode.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/route_api_orders.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/route_api_orders_capture.php');
|
||||
include_once(PLGNTLS_class::root_path() . '/php/paypal/routes.php');
|
||||
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');
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
function handle_orders_request_CIPF($request_data) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
|
||||
// declaring outside the try..catch scope
|
||||
$order_response = array();
|
||||
@@ -34,8 +34,9 @@ function handle_orders_request_CIPF($request_data) {
|
||||
*/
|
||||
try {
|
||||
$can_pay = check_can_pay_CIPF();
|
||||
if (is_wp_error($can_pay))
|
||||
if (is_wp_error($can_pay)) {
|
||||
throw new HttpException('not allowed to pay : ' . $can_pay->get_error_message(), 403);
|
||||
}
|
||||
|
||||
$order_response = create_order_CIPF();
|
||||
$json_response = $order_response['json_response'];
|
||||
@@ -90,14 +91,11 @@ function handle_orders_request_CIPF($request_data) {
|
||||
*
|
||||
*/
|
||||
function create_order_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$paypal_api_base_url = PLGNTLS_class::PAYPAL_API_BASE_URL;
|
||||
Plgntls::debug_infos();
|
||||
$paypal_api_base_url = get_paypal_api_base_url_CIPF();
|
||||
|
||||
$access_token = generate_access_token_CIPF();
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$acf_id = 'user_' . $user_id;
|
||||
$price = get_field('somme_a_regler', $acf_id);
|
||||
$price = get_paypal_price_CIPF();
|
||||
|
||||
$url = $paypal_api_base_url . '/v2/checkout/orders';
|
||||
$payload = array(
|
||||
|
||||
@@ -11,38 +11,13 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
function handle_orders_capture_request_CIPF($request) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
$order_id = $request['orderID'];
|
||||
// declaring outside the try..catch scope
|
||||
$response_json = array();
|
||||
|
||||
|
||||
/*
|
||||
* ask paypal about the finished order
|
||||
*
|
||||
*/
|
||||
try {
|
||||
$response_json = capture_order_cipf($order_id);
|
||||
$http_status_code = $response_json['http_status_code'];
|
||||
$json_response = $response_json['json_response'];
|
||||
}
|
||||
catch (HttpException $error) {
|
||||
$status_code = $error->getStatusCode();
|
||||
$message = 'Failed to capture order in server :' . $error->getMessage();
|
||||
return new WP_REST_Response($message, $status_code);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
$message = 'Failed to capture order in server : ' . $error->getMessage();
|
||||
return new WP_REST_Response($message, 500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* update the client situation
|
||||
* and return the response of paypal
|
||||
*
|
||||
* capture status : https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
|
||||
* - COMPLETED
|
||||
* - DECLINED
|
||||
@@ -53,17 +28,23 @@ function handle_orders_capture_request_CIPF($request) {
|
||||
*
|
||||
*/
|
||||
try {
|
||||
update_user_post_capture_CIPF($json_response, 'end');
|
||||
$response_json = capture_order_CIPF($order_id);
|
||||
$http_status_code = $response_json['http_status_code'];
|
||||
$json_response = $response_json['json_response'];
|
||||
|
||||
update_user_post_capture_CIPF($json_response);
|
||||
|
||||
return new WP_REST_Response($json_response, $http_status_code);
|
||||
}
|
||||
catch (HttpException $error) {
|
||||
$status_code = $error->getStatusCode();
|
||||
$message = 'Failed to handle order after capture in server :' . $error->getMessage();
|
||||
$message = array('ERROR_TREATMENT'=>true, 'message'=>'Failed to handle order after capture in server: ' . $error->getMessage());
|
||||
send_emails_CIPF('payment_problem');
|
||||
return new WP_REST_Response($message, $status_code);
|
||||
}
|
||||
catch (Exception $error) {
|
||||
$message = 'Failed to handle order after capture in server :' . $error->getMessage();
|
||||
$message = array('ERROR_TREATMENT'=>true, 'message'=>'Failed to handle order after capture in server: ' . $error->getMessage());
|
||||
send_emails_CIPF('payment_problem');
|
||||
return new WP_REST_Response($message, 500);
|
||||
}
|
||||
|
||||
@@ -75,8 +56,8 @@ function handle_orders_capture_request_CIPF($request) {
|
||||
* @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture
|
||||
*/
|
||||
function capture_order_CIPF($order_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$paypal_api_base_url = PLGNTLS_class::PAYPAL_API_BASE_URL;
|
||||
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';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
function handle_json_response_CIPF($response, $ch) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
if ($response === false)
|
||||
throw new HttpException('cURL error: ' . curl_error($ch), 502);
|
||||
|
||||
@@ -33,7 +33,7 @@ function handle_json_response_CIPF($response, $ch) {
|
||||
);
|
||||
}
|
||||
function handle_response_CIPF($response) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
try
|
||||
{
|
||||
// Decode JSON response
|
||||
@@ -60,10 +60,10 @@ function handle_response_CIPF($response) {
|
||||
* @see https://developer.paypal.com/api/rest/authentication/
|
||||
*/
|
||||
function generate_access_token_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$paypal_client_id = PLGNTLS_class::PAYPAL_CLIENT_ID;
|
||||
$paypal_client_secret = PLGNTLS_class::PAYPAL_CLIENT_SECRET;
|
||||
$paypal_api_base_url = PLGNTLS_class::PAYPAL_API_BASE_URL;
|
||||
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
|
||||
|
||||
@@ -12,8 +12,11 @@ if (!defined('ABSPATH')) {
|
||||
// handling routes and endpoints
|
||||
// diff routes and endpoints : https://stackoverflow.com/q/56075017/9497573
|
||||
function routes_endpoints_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$base_rest_route = PLGNTLS_class::URL_BASE_REST_ROUTE;
|
||||
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',
|
||||
|
||||
@@ -16,16 +16,14 @@ if (!defined('ABSPATH')) {
|
||||
* call to paypal_shortcode_content()
|
||||
*/
|
||||
function paypal_shortcode_content_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_paypal_redirection_success = PLGNTLS_class::SLUG_PAYPAL_REDIRECTION_SUCCESS;
|
||||
$slug_paypal_redirection_failure = PLGNTLS_class::SLUG_PAYPAL_REDIRECTION_FAILURE;
|
||||
$paypal_client_id = PLGNTLS_class::PAYPAL_CLIENT_ID;
|
||||
$paypal_message_success = PLGNTLS_class::PAYPAL_MESSAGE_SUCCESS;
|
||||
$paypal_message_failure = PLGNTLS_class::PAYPAL_MESSAGE_FAILURE;
|
||||
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();
|
||||
|
||||
// if (!can_pay_now_CIPF())
|
||||
// return no_payment_CIPF();
|
||||
$cipfcard_paypal = new PLGNTLS_class();
|
||||
|
||||
$pp_client_id = $paypal_client_id;
|
||||
$pp_sdk_currency = "EUR";
|
||||
@@ -35,7 +33,7 @@ function paypal_shortcode_content_CIPF() {
|
||||
$paypal_redirection_success = home_url() . '/' . $slug_paypal_redirection_success;
|
||||
$paypal_redirection_failure = home_url() . '/' . $slug_paypal_redirection_failure;
|
||||
|
||||
$added_to_front = $cipfcard_paypal->add_to_front(
|
||||
$added_to_front = Plgntls::add_to_front(
|
||||
array(
|
||||
$pp_sdk_url,
|
||||
array("js/paypal/paypal.js", 'type'=>'module'),
|
||||
@@ -46,6 +44,7 @@ function paypal_shortcode_content_CIPF() {
|
||||
'paypal_redirection_failure',
|
||||
'paypal_message_success',
|
||||
'paypal_message_failure',
|
||||
'paypal_message_problem',
|
||||
),
|
||||
);
|
||||
|
||||
@@ -54,10 +53,6 @@ function paypal_shortcode_content_CIPF() {
|
||||
add_shortcode('cipf_paypal_shortcode', 'paypal_shortcode_content_CIPF');
|
||||
|
||||
|
||||
function no_payment_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -30,27 +30,25 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function update_user_pre_order_CIPF($message) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE;
|
||||
$meta_order_id = PLGNTLS_class::META_ORDER_ID;
|
||||
Plgntls::debug_infos();
|
||||
$acf_payment_status = Cipf::ACF_CARD_PAYMENT_STATE;
|
||||
|
||||
$order_id = $message->id;
|
||||
$user_id = get_current_user_id();
|
||||
$acf_id = 'user_'.$user_id;
|
||||
|
||||
/*
|
||||
* - delete previous order ids
|
||||
* ->if we are here it's because a new order will try to be created
|
||||
* - addind order_id to cipf_order_id meta field
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
delete_user_meta($user_id, $meta_order_id);
|
||||
add_user_meta($user_id, $meta_order_id, $order_id);
|
||||
set_acf_order_id_CIPF($order_id, $user_id);
|
||||
|
||||
/*
|
||||
* create a meta field to check states of payements on prof author page :
|
||||
@@ -60,7 +58,7 @@ function update_user_pre_order_CIPF($message) {
|
||||
* - 'nothing' -> output nothing on author page
|
||||
*
|
||||
*/
|
||||
update_field($acf_payment_status['_name'], $acf_payment_status['started'], $acf_id);
|
||||
set_payment_started_CIPF($user_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,13 +69,14 @@ function update_user_pre_order_CIPF($message) {
|
||||
*
|
||||
*/
|
||||
function update_user_post_capture_CIPF($message) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
|
||||
$order_id = $message->id;
|
||||
$user_id = get_current_user_id();
|
||||
$status = null;
|
||||
if (is_object($message) && isset($message->status))
|
||||
if (is_object($message) && isset($message->status)) {
|
||||
$status = $message->status;
|
||||
}
|
||||
|
||||
/*
|
||||
* capture status : https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
|
||||
@@ -95,17 +94,22 @@ function update_user_post_capture_CIPF($message) {
|
||||
* -> it is at least necessary to find the user who did the purchase
|
||||
*
|
||||
*/
|
||||
// find the user containing the order_id and delete this order_id
|
||||
$user_id_to_update = find_user_with_order_id_CIPF($user_id, $order_id);
|
||||
if ($user_id_to_update === false)
|
||||
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
|
||||
validate_payment_for_user_CIPF($user_id_to_update, $order_id);
|
||||
}
|
||||
else if ($status === 'PENDING') {
|
||||
// i don't know what to do yet, maybe make more checks and output a message to contact diego ?
|
||||
// https://developer.paypal.com/docs/api/orders/v2/#definition-capture_status_details
|
||||
/*
|
||||
* PayPal capture status: https://developer.paypal.com/docs/api/orders/v2/#definition-order_status
|
||||
* - COMPLETED: Payment captured successfully
|
||||
* - PENDING: Payment authorized, awaiting capture (valid for some payment methods)
|
||||
* - DECLINED: Payment was declined
|
||||
* - PARTIALLY_REFUNDED: Order partially refunded
|
||||
* - REFUNDED: Order fully refunded
|
||||
* - FAILED: Order failed
|
||||
*/
|
||||
if ($status === 'COMPLETED' || $status === 'PENDING') {
|
||||
// proceed to validate payment for user (both COMPLETED and PENDING are successful)
|
||||
success_payment_for_user_CIPF($user_id_to_update, $order_id);
|
||||
}
|
||||
else {
|
||||
failure_payment_for_user_CIPF($user_id_to_update, $order_id, $status);
|
||||
@@ -127,193 +131,75 @@ function update_user_post_capture_CIPF($message) {
|
||||
*
|
||||
*/
|
||||
function failure_payment_for_user_CIPF($user_id, $order_id, $status) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
|
||||
$acf_card_state = PLGNTLS_class::ACF_CARD_STATE;
|
||||
$acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION;
|
||||
$card_duration = PLGNTLS_class::CARD_VALIDITY_TIME;
|
||||
$prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
|
||||
$acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE;
|
||||
$meta_order_id = PLGNTLS_class::META_ORDER_ID;
|
||||
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);
|
||||
|
||||
/*
|
||||
* remove the order_id from user meta
|
||||
* if payment was only for card change
|
||||
*
|
||||
*/
|
||||
delete_user_meta($user_id, $meta_order_id, $order_id);
|
||||
|
||||
if (is_acf_prof_change_card_CIPF($user_id)) {
|
||||
reset_acf_prof_change_card_CIPF($user_id);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* change payement status to failed
|
||||
* - 'started' -> at order creation
|
||||
* - 'success' -> at capture success (on author page, it means success, then mark it 'nothing')
|
||||
* - 'failure' -> at capture failure (on author page, it means failure, then mark it 'nothing')
|
||||
* - 'nothing' -> output nothing on author page
|
||||
* else
|
||||
*
|
||||
*/
|
||||
update_field($acf_payment_status['_name'], $acf_payment_status['failure'], $acf_id);
|
||||
|
||||
|
||||
/*
|
||||
* other changes on user :
|
||||
* - pofil is inactive
|
||||
*
|
||||
*/
|
||||
update_field($prof_is_activ['_name'], $prof_is_activ['inactiv'], $acf_id);
|
||||
set_account_to_pay_CIPF($user_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* things to do when a payment is a success
|
||||
*
|
||||
*/
|
||||
function validate_payment_for_user_CIPF($user_id, $order_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
|
||||
$acf_card_state = PLGNTLS_class::ACF_CARD_STATE;
|
||||
$acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION;
|
||||
$acf_card_number = PLGNTLS_class::ACF_CARD_NUMBER;
|
||||
$card_duration = PLGNTLS_class::CARD_VALIDITY_TIME;
|
||||
$prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
|
||||
$acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE;
|
||||
$meta_order_id = PLGNTLS_class::META_ORDER_ID;
|
||||
/*
|
||||
$acf_cgv = PLGNTLS_class::ACF_PROF_CGV;
|
||||
$acf_payement = PLGNTLS_class::ACF_CARD_PAYMENT_METHOD;
|
||||
$acf_delivery = PLGNTLS_class::ACF_CARD_PRICE_DELIVERY;
|
||||
$acf_price = PLGNTLS_class::ACF_CARD_PRICE_CHOICE;
|
||||
*/
|
||||
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);
|
||||
|
||||
/*
|
||||
* remove the order_id from user meta
|
||||
* if payment was only for card change
|
||||
*
|
||||
*/
|
||||
delete_user_meta($user_id, $meta_order_id, $order_id);
|
||||
|
||||
/*
|
||||
* acf uses 'Y-m-d H:i:s' format : https://www.advancedcustomfields.com/resources/date-time-picker/
|
||||
*
|
||||
*/
|
||||
$acf_date_format = 'Y-m-d H:i:s';
|
||||
$acf_id = 'user_'.$user_id;
|
||||
|
||||
$date_now = date_create('today');
|
||||
|
||||
/*
|
||||
* get current date limit
|
||||
* if no date, use now
|
||||
* if paste date, use now
|
||||
*
|
||||
*/
|
||||
$current_date_limit_object = get_field_object($acf_card_expiration['_name'], $acf_id);
|
||||
|
||||
if ($current_date_limit_object === false) {
|
||||
$current_date_limit = $date_now;
|
||||
}
|
||||
else if (empty($current_date_limit_object['value'])) {
|
||||
$current_date_limit = $date_now;
|
||||
}
|
||||
else
|
||||
{
|
||||
$current_date_limit_string = $current_date_limit_object['value'];
|
||||
$current_format_field = $current_date_limit_object['return_format'];
|
||||
// compare 2 dates : https://stackoverflow.com/q/8722806/9497573
|
||||
// also I dont use strtotime to compare 2 ints,
|
||||
// because i don't know if it will fail one day (2000 bug alike)
|
||||
$current_date_limit = date_create_from_format($current_format_field, $current_date_limit_string);
|
||||
$date_diff = date_diff($date_now, $current_date_limit);
|
||||
$date_is_in_past = $date_diff->format('%R%a') < 0;
|
||||
|
||||
if ($date_is_in_past)
|
||||
$current_date_limit = $date_now;
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* update date limit validity to add 1 year
|
||||
* else
|
||||
* order is important for some
|
||||
* -> first update date, then the rest
|
||||
*
|
||||
*/
|
||||
$date_plus_one_year = $current_date_limit->add(date_interval_create_from_date_string('+'.$card_duration));
|
||||
update_field($acf_card_expiration['_name'], $date_plus_one_year->format($acf_date_format), $acf_id);
|
||||
update_card_date_expiration_CIPF($user_id);
|
||||
|
||||
/*
|
||||
* - if card status is command, create card id
|
||||
* - make card status to renewal
|
||||
*/
|
||||
$card_status = get_field($acf_card_state['_name'], $acf_id);
|
||||
if ($card_status === $acf_card_state['new']) {
|
||||
$card_id = $date_now->format('Ymd') . $user_id;
|
||||
error_log("-------");
|
||||
error_log("card_id");
|
||||
error_log($card_id);
|
||||
update_field($acf_card_number['_name'], $card_id, $acf_id);
|
||||
if (is_card_new_CIPF($user_id)) {
|
||||
set_card_number_CIPF($user_id);
|
||||
set_card_renew_CIPF($user_id);
|
||||
}
|
||||
update_field($acf_card_state['_name'], $acf_card_state['renew'], $acf_id);
|
||||
|
||||
/*
|
||||
* change user :
|
||||
* - profile is active
|
||||
* - card state is renewal
|
||||
* - payement status is success
|
||||
*
|
||||
*/
|
||||
update_field($prof_is_activ['_name'], $prof_is_activ['activ'], $acf_id);
|
||||
update_field($acf_payment_status['_name'], $acf_payment_status['success'], $acf_id);
|
||||
|
||||
/*
|
||||
* reset some fields for the form to buy the card
|
||||
* - cgv
|
||||
* - paiement
|
||||
* - livraison
|
||||
* - tarif
|
||||
*
|
||||
* could make sense to put it here,
|
||||
* but actually it needs to be put at begining of form
|
||||
*
|
||||
update_field($acf_cgv['_name'] , array(""), 'user_'.$user_id);
|
||||
update_field($acf_payement['_name'], array(""), 'user_'.$user_id);
|
||||
update_field($acf_delivery['_name'], array(""), 'user_'.$user_id);
|
||||
update_field($acf_price['_name'] , array(""), 'user_'.$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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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 schedule_delete_orderid_CIPF($user_id, $order_id)
|
||||
{
|
||||
$delay = time() + MINUTE_IN_SECONDS;
|
||||
wp_schedule_single_event($delay, 'orderid_deletion_event_CIPF', 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 delete_order_id_later_CIPF($user_id, $order_id)
|
||||
{
|
||||
delete_user_meta($user_id, 'cipf_order_id', $order_id);
|
||||
}
|
||||
add_action('orderid_deletion_event_CIPF', 'delete_order_id_later_CIPF', 5, 2);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @return mixed num - user_id
|
||||
@@ -321,11 +207,11 @@ add_action('orderid_deletion_event_CIPF', 'delete_order_id_later_CIPF', 5, 2);
|
||||
*
|
||||
*/
|
||||
function find_user_with_order_id_CIPF($current_user_id, $order_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$meta_order_id = PLGNTLS_class::META_ORDER_ID;
|
||||
$role_prof = PLGNTLS_class::ROLE_PROF;
|
||||
Plgntls::debug_infos();
|
||||
$acf_order_id = Cipf::ACF_CARD_ORDER_ID;
|
||||
$role_prof = Cipf::ROLE_PROF;
|
||||
|
||||
$user_metas = get_user_meta($current_user_id, $meta_order_id, false);
|
||||
$user_metas = get_user_meta($current_user_id, $acf_order_id['_name'], false);
|
||||
if (in_array($order_id, $user_metas)) {
|
||||
return $current_user_id;
|
||||
}
|
||||
@@ -336,42 +222,17 @@ function find_user_with_order_id_CIPF($current_user_id, $order_id) {
|
||||
* https://developer.wordpress.org/reference/classes/WP_User_Query/prepare_query/
|
||||
*
|
||||
*/
|
||||
$users = get_users(array(
|
||||
$user = get_users(array(
|
||||
'role' => $role_prof,
|
||||
'meta_key' => $meta_order_id,
|
||||
'meta_key' => $acf_order_id,
|
||||
'meta_value' => $order_id,
|
||||
'fields' => 'ID',
|
||||
));
|
||||
if (count($users) > 1)
|
||||
if (count($user) > 1) {
|
||||
throw new HttpException('multiple users with same order_id', 502);
|
||||
else if (count($users) === 1)
|
||||
return reset($users);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return mixed num - user_id
|
||||
* bool false - if no match found
|
||||
*
|
||||
*/
|
||||
function delete_order_id_on_success_CIPF($current_user_id, $order_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$meta_order_id = PLGNTLS_class::META_ORDER_ID;
|
||||
|
||||
$del_ret = delete_user_meta($current_user_id, $meta_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, $meta_order_id, $order_id);
|
||||
if ($del_ret === true)
|
||||
return $user_id;
|
||||
}
|
||||
else if (count($user) === 1) {
|
||||
return reset($user);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -10,6 +10,31 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -17,18 +42,20 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
function check_can_pay_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$acf_card_payment_method = PLGNTLS_class::ACF_CARD_PAYMENT_METHOD;
|
||||
$acf_card_price_choice = PLGNTLS_class::ACF_CARD_PRICE_CHOICE;
|
||||
$acf_card_price_delivery = PLGNTLS_class::ACF_CARD_PRICE_DELIVERY;
|
||||
$acf_card_price_total = PLGNTLS_class::ACF_CARD_PRICE_TOTAL;
|
||||
$acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION;
|
||||
$card_renew_period = PLGNTLS_class::CARD_RENEW_PERIOD;
|
||||
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
|
||||
*
|
||||
@@ -38,16 +65,24 @@ function check_can_pay_CIPF() {
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* 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 = (int)get_field($acf_card_price_choice['_name'], $acf_id);
|
||||
$livraison = (int)get_field($acf_card_price_delivery['_name'], $acf_id);
|
||||
$price = $tarif + $livraison;
|
||||
$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
|
||||
@@ -61,6 +96,16 @@ function check_can_pay_CIPF() {
|
||||
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
|
||||
|
||||
@@ -1,134 +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 handle_prof_is_activ_CIPF($author_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
|
||||
$slug_wait_activation = PLGNTLS_class::SLUG_PROF_INACTIV;
|
||||
|
||||
$acf_id = 'user_' . $author_id;
|
||||
|
||||
/*
|
||||
* if prof is activ, do nothing more
|
||||
*
|
||||
*/
|
||||
$is_activ = get_field($acf_prof_is_activ['_name'], $acf_id);
|
||||
if ($is_activ === $acf_prof_is_activ['activ'])
|
||||
return;
|
||||
|
||||
|
||||
/*
|
||||
* else if prof inactiv
|
||||
* if is admin or other allowed roles, see the page anyway
|
||||
* no need to handle allowed roles, it's already
|
||||
* taken care by author_restriction.php
|
||||
*
|
||||
*/
|
||||
$user_id = get_current_user_id();
|
||||
if ($user_id !== $author_id)
|
||||
return;
|
||||
|
||||
|
||||
/*
|
||||
* if prof is activ
|
||||
* redirect to waiting page
|
||||
*
|
||||
*/
|
||||
$redirection_prof_inactiv = home_url() . '/' . $slug_wait_activation;
|
||||
|
||||
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
|
||||
nocache_headers();
|
||||
wp_redirect($redirection_prof_inactiv, 301);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* check acf field payment_status
|
||||
* if field value is 'success'
|
||||
* - show block 'failure'
|
||||
* - and update field to 'nothing', so it will not show next time
|
||||
* if field value is 'failure'
|
||||
* - show bloc success
|
||||
* - and update field to 'nothing', so it will not show next time
|
||||
* if field value is 'nothing'
|
||||
* - do nothing (keep blocs hidden)
|
||||
* if field value is 'started'
|
||||
* - do nothing (keep blocs hidden)
|
||||
*
|
||||
* .cipf_prof_paiement_message -> on row, added display none in page css
|
||||
* #cipf_prof_paiement_reussi -> on row
|
||||
* #cipf_prof_paiement_echoue -> on row
|
||||
*
|
||||
*/
|
||||
function show_prof_paiement_messages_CIPF($user_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
|
||||
$acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE;
|
||||
|
||||
$acf_id = 'user_' . $user_id;
|
||||
|
||||
/*
|
||||
* if prof is inactive, do nothing more
|
||||
*
|
||||
*/
|
||||
$is_activ = get_field($acf_prof_is_activ['_name'], $acf_id);
|
||||
if (is_null($is_activ))
|
||||
return;
|
||||
if (empty($is_activ))
|
||||
return;
|
||||
if ($is_activ === $acf_prof_is_activ['activ'])
|
||||
return;
|
||||
|
||||
$cipf_prof_payement = new PLGNTLS_class();
|
||||
|
||||
$payement_status = get_field($acf_payment_status['_name'], $acf_id);
|
||||
if ($payement_status === $acf_payment_status['success']) {
|
||||
$cipf_prof_payement->add_to_front(array(
|
||||
array( 'css' => '.cipf_prof_paiement_message#cipf_prof_paiement_reussi {display: block;}' )
|
||||
));
|
||||
}
|
||||
else if ($payement_status === $acf_payment_status['failure']) {
|
||||
$cipf_prof_payement->add_to_front(array(
|
||||
array( 'css' => '.cipf_prof_paiement_message#cipf_prof_paiement_echoue {display: block;}' )
|
||||
));
|
||||
}
|
||||
|
||||
update_field($acf_payment_status['_name'], $acf_payment_status['nothing'], $acf_id);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* series of check to do before printing a prof author page
|
||||
*
|
||||
*/
|
||||
function check_prof_page_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
|
||||
// is an author page
|
||||
if (!is_author())
|
||||
return;
|
||||
|
||||
// the way to find the id of the author of an author_page
|
||||
$author_id = get_queried_object_id();
|
||||
|
||||
handle_prof_is_activ_CIPF($author_id);
|
||||
|
||||
show_prof_paiement_messages_CIPF($author_id);
|
||||
|
||||
}
|
||||
add_action('template_redirect', 'check_prof_page_CIPF', 11);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
128
plugins/cipf_plugin/php/profs_form_commande.php
Normal file
128
plugins/cipf_plugin/php/profs_form_commande.php
Normal 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');
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
230
plugins/cipf_plugin/php/profs_handle_states.php
Normal file
230
plugins/cipf_plugin/php/profs_handle_states.php
Normal 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');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
155
plugins/cipf_plugin/php/profs_profil.php
Normal file
155
plugins/cipf_plugin/php/profs_profil.php
Normal 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);
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,127 +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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* redirect users to profil
|
||||
* if prof -> author page
|
||||
* if partenaire -> post page || home page
|
||||
*/
|
||||
function redirection_profil_page_CIPF(){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$role_prof = PLGNTLS_class::ROLE_PROF;
|
||||
$role_partner = PLGNTLS_class::ROLE_PARTNER;
|
||||
|
||||
$base_url = home_url();
|
||||
$current_user_id = get_current_user_id();
|
||||
|
||||
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
|
||||
nocache_headers();
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
wp_redirect($base_url, 301);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (current_user_can($role_prof)) {
|
||||
$user_page = get_author_posts_url($current_user_id);
|
||||
wp_redirect($user_page, 301);
|
||||
exit;
|
||||
}
|
||||
else if (current_user_can($role_partner)) {
|
||||
$args = array(
|
||||
'post_type' => 'post',
|
||||
'author' => $current_user_id,
|
||||
'posts_per_page' => 1,
|
||||
);
|
||||
$posts = get_posts($args);
|
||||
if (empty($posts))
|
||||
$redirect_url = $base_url;
|
||||
else {
|
||||
$query = reset($posts);
|
||||
$post_id = $query->ID;
|
||||
$redirect_url = get_permalink($query->ID);
|
||||
}
|
||||
wp_redirect($redirect_url, 301);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
wp_redirect($base_url, 301);
|
||||
exit;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* redirects when someone reaches the page with slug defined in SLUG_PAGE_REDIRECTION
|
||||
*
|
||||
*/
|
||||
function redirection_page_CIPF(){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
|
||||
if (!is_page($slug_page_redirection))
|
||||
return;
|
||||
|
||||
redirection_profil_page_CIPF();
|
||||
}
|
||||
add_action('template_redirect', 'redirection_page_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* redirects when someone reaches the page with query ?QUERY_REDIRECTION_PROFIL
|
||||
*
|
||||
*/
|
||||
function redirection_query_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$query_redirection = PLGNTLS_class::QUERY_REDIRECTION_PROFIL;
|
||||
|
||||
// Check if the request contains ?QUERY_REDIRECTION_PROFIL
|
||||
if(isset($_GET[$query_redirection])) {
|
||||
redirection_profil_page_CIPF();
|
||||
}
|
||||
}
|
||||
add_action('init', 'redirection_query_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* DOES NOT WORK so far
|
||||
* because to use is_user_logged_in() in redirection_profil_page_CIPF
|
||||
* the request should include the X-WP-Nonce header, but it does not
|
||||
* redirects when someone enter the url or redirection
|
||||
* /wp-json/cipf_plugin/api/v1/redirection_cipf
|
||||
*
|
||||
function endpoint_for_redirection_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
$base_rest_route = PLGNTLS_class::URL_BASE_REST_ROUTE;
|
||||
|
||||
register_rest_route($base_rest_route, '/' . $slug_page_redirection, array(
|
||||
'methods' => 'GET',
|
||||
'callback' => 'redirection_profil_page_CIPF',
|
||||
));
|
||||
};
|
||||
add_action('rest_api_init', 'endpoint_for_redirection_CIPF');
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* at registration, add role 'partenaire' when page url has path 'creation-du-compte-partenaire'
|
||||
*
|
||||
*/
|
||||
function add_partenaires_CIPF($customer_data){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$role_partner = PLGNTLS_class::ROLE_PARTNER;
|
||||
error_log("----");
|
||||
error_log("in add_partenaires");
|
||||
error_log("_POST");
|
||||
error_log(json_encode($_POST));
|
||||
error_log("_SERVER");
|
||||
error_log(json_encode($_SERVER));
|
||||
|
||||
$current_url = $_SERVER['HTTP_REFERER']; // not reliable to use referer, TODO: find another solution
|
||||
$path_brut = parse_url($current_url, PHP_URL_PATH);
|
||||
$path = trim($path_brut, '/');
|
||||
if ($path === 'creation-du-compte-partenaire')
|
||||
$customer_data['role'] = $role_partner;
|
||||
return $customer_data;
|
||||
}
|
||||
add_filter( 'xoo_el_register_new_customer_data', 'add_partenaires_CIPF', 10, 1 );
|
||||
/*
|
||||
|
||||
in add_partenaires
|
||||
_POST
|
||||
{
|
||||
"xoo_el_reg_username":"tistilarde",
|
||||
"xoo_el_reg_email":"tistilarde@gufum.com",
|
||||
"xoo_el_reg_pass":"pouetpouet",
|
||||
"_xoo_el_form":"register",
|
||||
"xoo_el_redirect":"\/creation-du-compte-partenaire\/",
|
||||
"action":"xoo_el_form_action",
|
||||
"display":"popup"
|
||||
}
|
||||
|
||||
_SERVER
|
||||
{
|
||||
"SERVER_SOFTWARE":"nginx\/1.20.2",
|
||||
"REQUEST_URI":"\/wp-admin\/admin-ajax.php",
|
||||
"USER":"www-data",
|
||||
"HOME":"\/home\/www-data",
|
||||
"HTTP_SEC_FETCH_SITE":"same-origin",
|
||||
"HTTP_SEC_FETCH_MODE":"cors",
|
||||
"HTTP_SEC_FETCH_DEST":"empty",
|
||||
"HTTP_COOKIE":"wordpress_test_cookie=WP%20Cookie%20check; wp-postpass_351da2be51e3820c1ef099eec9d2e669=%24P%24BjEiJgHo.cgrpONdnfmxwpIYzraFCP.; mjx.menu=renderer%3ANativeMML%26%3Bsemantics%3Atrue%26%3Bcontext%3ABrowser%26%3Bzoom%3ANone",
|
||||
"HTTP_REFERER":"https:\/\/local-cipf-plugin.com\/creation-du-compte-partenaire\/",
|
||||
"HTTP_CONNECTION":"keep-alive",
|
||||
"HTTP_SEC_GPC":"1",
|
||||
"HTTP_DNT":"1",
|
||||
"HTTP_ORIGIN":"https:\/\/local-cipf-plugin.com",
|
||||
"HTTP_CONTENT_LENGTH":"211",
|
||||
"HTTP_X_REQUESTED_WITH":"XMLHttpRequest",
|
||||
"HTTP_CONTENT_TYPE":"application\/x-www-form-urlencoded; charset=UTF-8",
|
||||
"HTTP_ACCEPT_ENCODING":"gzip, deflate, br",
|
||||
"HTTP_ACCEPT_LANGUAGE":"en-US,en;q=0.5",
|
||||
"HTTP_ACCEPT":"*\/*",
|
||||
"HTTP_USER_AGENT":"Mozilla\/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko\/20100101 Firefox\/123.0",
|
||||
"HTTP_HOST":"local-cipf-plugin.com",
|
||||
"REDIRECT_STATUS":"200",
|
||||
"SERVER_NAME":"local-cipf-plugin.com",
|
||||
"SERVER_PORT":"443",
|
||||
"SERVER_ADDR":"172.20.0.4",
|
||||
"REMOTE_PORT":"58976",
|
||||
"REMOTE_ADDR":"172.20.0.1",
|
||||
"GATEWAY_INTERFACE":"CGI\/1.1",
|
||||
"HTTPS":"on",
|
||||
"REQUEST_SCHEME":"https",
|
||||
"SERVER_PROTOCOL":"HTTP\/1.1",
|
||||
"DOCUMENT_ROOT":"\/var\/www\/html",
|
||||
"DOCUMENT_URI":"\/wp-admin\/admin-ajax.php",
|
||||
"SCRIPT_NAME":"\/wp-admin\/admin-ajax.php",
|
||||
"CONTENT_LENGTH":"211",
|
||||
"CONTENT_TYPE":"application\/x-www-form-urlencoded; charset=UTF-8",
|
||||
"REQUEST_METHOD":"POST",
|
||||
"QUERY_STRING":"",
|
||||
"SCRIPT_FILENAME":"\/var\/www\/html\/wp-admin\/admin-ajax.php",
|
||||
"FCGI_ROLE":"RESPONDER",
|
||||
"PHP_SELF":"\/wp-admin\/admin-ajax.php",
|
||||
"REQUEST_TIME_FLOAT":1710328883.257681,
|
||||
"REQUEST_TIME":1710328883
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,125 +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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* on renew page :
|
||||
* - check restrictions
|
||||
* - change some acf fields (if access granted)
|
||||
*
|
||||
* prevent users to fill the renew form if :
|
||||
* - they are not prof and logged in,
|
||||
* - and if their card is not in renewable state
|
||||
* - except admins and editor
|
||||
*
|
||||
*/
|
||||
function renew_page_restrictions_CIPF(){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD;
|
||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
$role_prof = PLGNTLS_class::ROLE_PROF;
|
||||
$role_fipf = PLGNTLS_class::ROLE_FIPF;
|
||||
$role_admin = PLGNTLS_class::ROLE_ADMIN;
|
||||
|
||||
$base_url = home_url();
|
||||
|
||||
wp_reset_query();
|
||||
|
||||
if (!is_page('commande'))
|
||||
return;
|
||||
|
||||
/*
|
||||
* is it good ?
|
||||
* -> dont' redirect if user not logged in, because new users need to acces this page
|
||||
*
|
||||
if (!is_user_logged_in()) {
|
||||
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
|
||||
nocache_headers();
|
||||
wp_redirect($base_url, 301);
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
|
||||
$current_user_id = get_current_user_id();
|
||||
$current_user = wp_get_current_user();
|
||||
$acf_id = 'user_'.$current_user_id;
|
||||
|
||||
|
||||
/*
|
||||
* check multiple user roles
|
||||
* https://developer.wordpress.org/reference/functions/current_user_can/#div-comment-4083
|
||||
*
|
||||
$allowed_roles = array($role_admin, $role_fipf, $role_prof);
|
||||
if (!array_intersect($allowed_roles, $current_user->roles))
|
||||
return;
|
||||
*/
|
||||
|
||||
/*
|
||||
* if prof, check card state
|
||||
* if cannot renew, redirect
|
||||
*
|
||||
if (current_user_can($role_prof)) {
|
||||
$can_renew = get_field($acf_prof_can_renew['_name'], $acf_id);
|
||||
if ($can_renew === false) {
|
||||
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
|
||||
nocache_headers();
|
||||
$redirect_url = home_url() . '/' . $slug_page_redirection;
|
||||
wp_redirect($redirect_url, 301);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
add_action('template_redirect', 'renew_page_restrictions_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* on the renew card page for prof
|
||||
* output the right message, depending of the status of the card
|
||||
* 'renouveler' or 'commander'
|
||||
*
|
||||
* #cipf_prof_carte_commande -> default display: block;
|
||||
* #cipf_prof_carte_renouvellement -> default display: none;
|
||||
*
|
||||
*/
|
||||
function renew_page_filter_message_CIPF(){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD;
|
||||
$acf_card_state = PLGNTLS_class::ACF_CARD_STATE;
|
||||
|
||||
if (!is_page($slug_renew_card))
|
||||
return;
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$acf_id = 'user_'.$user_id;
|
||||
|
||||
$cipf_renew = new PLGNTLS_class();
|
||||
|
||||
$card_state = get_field($acf_card_state['_name'], $acf_id);
|
||||
|
||||
if ($card_state === 'Renouvellement') {
|
||||
$cipf_renew->add_to_front(array(
|
||||
array( 'css' => 'div#cipf_prof_carte_renouvellement {display: block;}' ),
|
||||
array( 'css' => 'div#cipf_prof_carte_commande {display: none;}' ),
|
||||
));
|
||||
}
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'renew_page_filter_message_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,49 +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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* NOT USEFUL ANYMORE :
|
||||
* it was to fix pbms in formbuilder with calculation field
|
||||
* but I made 2 better fixes (css and js)
|
||||
*
|
||||
* reset some fields for the form to buy the card
|
||||
* - cgv
|
||||
* - paiement
|
||||
* - livraison
|
||||
* - tarif
|
||||
* this action is called after redirection hook
|
||||
*
|
||||
*/
|
||||
function reset_some_fields_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD;
|
||||
$acf_cgv = PLGNTLS_class::ACF_PROF_CGV;
|
||||
$acf_payement = PLGNTLS_class::ACF_CARD_PAYMENT_METHOD;
|
||||
$acf_delivery = PLGNTLS_class::ACF_CARD_PRICE_DELIVERY;
|
||||
$acf_price = PLGNTLS_class::ACF_CARD_PRICE_CHOICE;
|
||||
|
||||
if (!is_page($slug_renew_card))
|
||||
return;
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
update_field($acf_cgv['_name'] , array(""), 'user_'.$user_id);
|
||||
update_field($acf_payement['_name'], array(""), 'user_'.$user_id);
|
||||
update_field($acf_delivery['_name'], array(""), 'user_'.$user_id);
|
||||
update_field($acf_price['_name'] , array(""), 'user_'.$user_id);
|
||||
}
|
||||
add_action('wp', 'reset_some_fields_CIPF');
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,170 +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::root_path() . 'php/format_user_infos.php');
|
||||
|
||||
|
||||
|
||||
function extract_if_array_size_one_CIPF($value) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
if (is_array($value) && count($value) === 1)
|
||||
return reset($value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
function merge_two_arrays_CIPF($array1, $array2) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$new_array = $array1;
|
||||
foreach ($array2 as $key2 => $value2) {
|
||||
$value = extract_if_array_size_one_CIPF($value2);
|
||||
// if key was not in first array, add the new element to it
|
||||
if (!isset($new_array[$key2])) {
|
||||
$new_array[$key2] = $value2;
|
||||
continue;
|
||||
}
|
||||
// if key was in first array, add both in an array
|
||||
$value1 = extract_if_array_size_one_CIPF($new_array[$key2]);
|
||||
if (empty($value1))
|
||||
$new_array[$key2] = $value2;
|
||||
else if (empty($value2))
|
||||
$new_array[$key2] = $value1;
|
||||
else {
|
||||
$new_value = array($value1, $value2);
|
||||
$new_array[$key] = $new_value;
|
||||
}
|
||||
}
|
||||
return $new_array;
|
||||
}
|
||||
|
||||
|
||||
function output_list_front_CIPF($array, $current_user, $user_id) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$output = '<ul>';
|
||||
foreach ($array as $key => $value) {
|
||||
if (str_starts_with($key, '_'))
|
||||
continue ;
|
||||
$value = format_user_info_CIPF($key, $current_user, $user_id);
|
||||
$output .= '<li>';
|
||||
$output .= '<span>';
|
||||
$output .= $key;
|
||||
$output .= ' : ';
|
||||
$output .= $value;
|
||||
$output .= '</span>';
|
||||
$output .= '</li>';
|
||||
}
|
||||
$output .= '</ul>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* shortcode to write user info of post author
|
||||
* 0 or 1 argument, usage :
|
||||
* - [cipf_user_info] -> list of all availables infos
|
||||
* - [cipf_user_info user_email] -> display the email
|
||||
* - [cipf_user_info user_email user_login] -> display the email
|
||||
* - [cipf_user_info user_email author='logged_in'] -> display the email of the connected user
|
||||
* - [cipf_user_info user_email author='post_creator'] -> display the email of the creator of the page/post
|
||||
*
|
||||
*/
|
||||
function current_user_infos_CIPF($atts) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
if (!is_user_logged_in())
|
||||
return ;
|
||||
|
||||
|
||||
/*
|
||||
* choose the default id target : logged in user, or post creator ?
|
||||
*
|
||||
$author_is = 'logged_in'; // logged in user
|
||||
*/
|
||||
$author_is = 'post_creator'; // creator of post (also for author pages)
|
||||
|
||||
|
||||
/*
|
||||
* has parameter 'author' ?
|
||||
* if yes, removes it from $atts
|
||||
*
|
||||
*/
|
||||
if (is_array($atts)) {
|
||||
if (isset($atts['author'])) {
|
||||
$author_is = $atts['author'];
|
||||
unset($atts['author']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* should output all or a specific parameter ?
|
||||
*
|
||||
*/
|
||||
$output_all = false;
|
||||
if (empty($atts))
|
||||
$output_all = true;
|
||||
else if (count($atts) === 0)
|
||||
$output_all = true;
|
||||
|
||||
|
||||
/*
|
||||
* get author id outside loop and outside singular page : https://wordpress.stackexchange.com/q/65548
|
||||
*
|
||||
*/
|
||||
if ($author_is === 'logged_in') {
|
||||
$current_user = wp_get_current_user();
|
||||
$user_id = get_current_user_id();
|
||||
}
|
||||
else {
|
||||
if (is_author()) {
|
||||
$user_id = get_queried_object_id();
|
||||
}
|
||||
else if (in_the_loop()) {
|
||||
$user_id = get_the_author_meta('ID');
|
||||
}
|
||||
else if (is_singular()) {
|
||||
$user_id = get_queried_object()->post_author;
|
||||
}
|
||||
else {
|
||||
global $wp_query;
|
||||
if (!empty($wp_query->posts))
|
||||
$user_id = $wp_query->posts[0]->post_author;
|
||||
}
|
||||
//$current_user = new WP_User($user_id);
|
||||
$current_user = get_user_by('id', $user_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* output all the available parameters (for help)
|
||||
*
|
||||
*/
|
||||
if ($output_all) {
|
||||
$user_properties = (array) get_userdata($user_id)->data;
|
||||
$user_metas = get_user_meta($user_id);
|
||||
$user_infos = merge_two_arrays_CIPF($user_metas, $user_properties);
|
||||
return output_list_front_CIPF($user_infos, $current_user, $user_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* real purpose of this shortcode :
|
||||
* only return the first argument (that is not 'author')
|
||||
*
|
||||
*/
|
||||
if (is_array($atts))
|
||||
$query = $atts[0];
|
||||
else if (is_string($atts))
|
||||
$query = $atts;
|
||||
else
|
||||
return '';
|
||||
// $output = $current_user->$query;
|
||||
return format_user_info_CIPF($query, $current_user, $user_id);
|
||||
}
|
||||
add_shortcode('cipf_user_info', 'current_user_infos_CIPF');
|
||||
|
||||
|
||||
?>
|
||||
@@ -12,7 +12,7 @@ if (!defined('ABSPATH')) {
|
||||
https://stackify.com/how-to-log-to-console-in-php/
|
||||
*/
|
||||
function console_log(...$outputs) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
Plgntls::debug_infos();
|
||||
if (CIPF_CONSOLE_OFF)
|
||||
return;
|
||||
foreach($outputs as $output)
|
||||
1404
plugins/cipf_plugin/plgntls_class.php
Normal file
1404
plugins/cipf_plugin/plgntls_class.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,573 +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 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', //
|
||||
* 'style1_css' => 'path/to/style2.css', // -> depends on style1.css
|
||||
* 'http://my_url1.com', //
|
||||
* 'script1_js' => '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
|
||||
{
|
||||
/*
|
||||
* 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'=>'PDF', 'post'=>'Fabrication']; // 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
|
||||
|
||||
// META
|
||||
const META_PAYEMENT_STATUS = 'cipf_payement_status';
|
||||
const META_ORDER_ID = 'cipf_order_id';
|
||||
|
||||
// SLUG & URL & QUERY
|
||||
const SLUG_PROF_INACTIV = 'validation-en-cours';
|
||||
const SLUG_RENEW_CARD = 'commande';
|
||||
const SLUG_PAGE_REDIRECTION = 'redirection_cipf';
|
||||
// const SLUG_PAYPAL_REDIRECTION_SUCCESS = self::SLUG_PAGE_REDIRECTION;
|
||||
// const SLUG_PAYPAL_REDIRECTION_FAILURE = self::SLUG_PAGE_REDIRECTION;
|
||||
const SLUG_PAYPAL_REDIRECTION_SUCCESS = '?'.self::QUERY_REDIRECTION_PROFIL;
|
||||
const SLUG_PAYPAL_REDIRECTION_FAILURE = '?'.self::QUERY_REDIRECTION_PROFIL;
|
||||
const URL_BASE_REST_ROUTE = 'cipf_plugin/api/v1'; // for routes, in php/paypal/routes.php && php/admin_modif_prof.php
|
||||
const QUERY_REDIRECTION_PROFIL = 'redirection_cipf';
|
||||
const QUERY_ADMIN_VALIDATE_PROF = 'admin_activate_prof_cipf'; // for admin_modif_prof.php
|
||||
|
||||
// PAYPAL
|
||||
const PAYPAL_CLIENT_ID = "AfcmwxIXlG2ZxaMdjazX57I70BXz__aEqNWaTnqfSCI34a0V7nMbytswx7EViUjlpHs7opyrRwaH9YLl";
|
||||
const PAYPAL_CLIENT_SECRET = "EGunIhGRjPvn0Z8wXO0JsdhET30OStTAH_IyRsmhimEN23_qiRSFD-ql4tvnulKJw6TitZ-vU-ytc4A-";
|
||||
const PAYPAL_API_BASE_URL = "https://api-m.sandbox.paypal.com";
|
||||
const PAYPAL_MESSAGE_SUCCESS = '`paiement reussi`';
|
||||
const PAYPAL_MESSAGE_FAILURE = '`paiement raté`';
|
||||
|
||||
// ROLES
|
||||
const ROLE_PROF = 'professeur__professeure';
|
||||
const ROLE_PARTNER = 'partenaire';
|
||||
const ROLE_FIPF = 'fipf';
|
||||
const ROLE_ADMIN = 'administrator';
|
||||
|
||||
// OTHER
|
||||
const CARD_RENEW_PERIOD = 31; // int : number of days before expiration when renew card start to be possible
|
||||
const CARD_VALIDITY_TIME = '1 year'; // string : time of validity of the card (ex: '1 month' or '1 year' or '60 days')
|
||||
const USER_INFO_DATE_FORMAT = 'd/m/Y'; // for user_infos.php (date format : https://www.php.net/manual/fr/datetime.format.php)
|
||||
const ADMIN_VALIDATE_PROF_FIELD = 'admin_activate_prof_cipf'; // for admin_modif_prof.php
|
||||
|
||||
|
||||
|
||||
private static $_DEBUG_INFOS = true;
|
||||
private static $_plugin_dir_path;
|
||||
private static $_plugin_name;
|
||||
private static $_file_dir_path;
|
||||
private static $_file_name;
|
||||
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() {
|
||||
if (!isset(self::$_plugin_name, self::$_file_name, self::$_file_dir_path, self::$_plugin_dir_path))
|
||||
self::set_root_dir();
|
||||
$this->_prefix = "PLGNTLS";
|
||||
$this->_first_script = null;
|
||||
$this->_first_style = null;
|
||||
$this->_js_dependencies = array();
|
||||
$this->_css_dependencies = array();
|
||||
$this->_scripts_attributes = array();
|
||||
}
|
||||
|
||||
/*
|
||||
* ex:
|
||||
* /home/www-data/cipf_plugin/php/test/test2/test3/test.php
|
||||
* _plugin_dir_path /home/www-data
|
||||
* _plugin_name cipf_plugin
|
||||
* _file_dir_path php/test/test2/test3
|
||||
* _file_name test.php
|
||||
* _root_path /home/www-data/cipf_plugin/
|
||||
*
|
||||
* /home/www-data/cipf_plugin/test.php
|
||||
* _plugin_dir_path /home/www-data
|
||||
* _plugin_name cipf_plugin
|
||||
* _file_dir_path ''
|
||||
* _file_name test.php
|
||||
* _root_path /home/www-data/cipf_plugin/
|
||||
*
|
||||
*/
|
||||
private static function set_root_dir() {
|
||||
if (isset(self::$_plugin_name, self::$_file_name, self::$_file_dir_path, self::$_plugin_dir_path))
|
||||
return ;
|
||||
/*
|
||||
* it uses exploded_path_path by removing data from the array
|
||||
* so order is important !
|
||||
* plugin_name / path / to / file.php
|
||||
* exploded [plugin_name, path, to, file.php]
|
||||
* plugin_name plugin_name [path, to, file.php]
|
||||
* file_name [path, to] file.php
|
||||
* file_dir_name path / to
|
||||
*/
|
||||
$exploded_plugin_path = explode('/', plugin_basename( __FILE__ ));
|
||||
|
||||
self::$_plugin_name = array_shift($exploded_plugin_path);
|
||||
self::$_file_name = array_pop($exploded_plugin_path);
|
||||
self::$_file_dir_path = implode('/', $exploded_plugin_path);
|
||||
|
||||
self::$_plugin_dir_path = str_replace('/'.plugin_basename(__DIR__).'/', '', plugin_dir_path(__FILE__));
|
||||
self::$_root_path = self::$_plugin_dir_path.'/'.self::$_plugin_name.'/';
|
||||
self::$_root_url = plugins_url(self::$_plugin_name.'/');
|
||||
}
|
||||
public static function root_path() {
|
||||
if (!isset(self::$_plugin_name, self::$_file_name, self::$_file_dir_path, self::$_plugin_dir_path))
|
||||
self::set_root_dir();
|
||||
return(self::$_root_path);
|
||||
}
|
||||
public static function root_url() {
|
||||
if (!isset(self::$_plugin_name, self::$_file_name, self::$_file_dir_path, self::$_plugin_dir_path))
|
||||
self::set_root_dir();
|
||||
return(self::$_root_url);
|
||||
}
|
||||
|
||||
/*
|
||||
* for debug purposes
|
||||
*/
|
||||
public static function debug_infos() {
|
||||
if (self::$_DEBUG_INFOS === false)
|
||||
return;
|
||||
$trace = debug_backtrace();
|
||||
$function = $trace[1]['function'];
|
||||
$file = $trace[0]['file'];
|
||||
$line = $trace[0]['line'];
|
||||
error_log("-debug: function '".$function."' (in ".$file.", line ".$line .')');
|
||||
}
|
||||
|
||||
|
||||
public function add_to_front($srcs_arr = array(), $vars = array()) {
|
||||
/*
|
||||
* event if the function is called with no srcs
|
||||
* add fetch, because it can be used just for that
|
||||
*/
|
||||
$this->add_fetch($srcs_arr, $vars);
|
||||
$this->add_default_css($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(self::$_file_dir_path."/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);
|
||||
}
|
||||
|
||||
private function add_default_css(&$srcs_arr, &$vars) {
|
||||
// add default css file at beginning of style list
|
||||
array_unshift($srcs_arr, self::$_file_dir_path."/plgntls_default.css");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @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->root_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 || empty($handle))
|
||||
$handle = $this->_first_script;
|
||||
wp_add_inline_script($handle, $src->src, 'before');
|
||||
}
|
||||
private function add_inline_style($src) {
|
||||
$handle = $src->depends;
|
||||
if ($handle === null || empty($handle))
|
||||
$handle = $this->_first_style;
|
||||
wp_add_inline_style($handle, $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
|
||||
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->root_url().$src->src;
|
||||
$src->path = $this->root_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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,4 +0,0 @@
|
||||
/*
|
||||
* this css file will be automatically added to front by PLGNTLS_class
|
||||
* no need to write any style here, but you can if you want
|
||||
*/
|
||||
@@ -1,24 +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;
|
||||
}
|
||||
|
||||
1
plugins/custer
Submodule
1
plugins/custer
Submodule
Submodule plugins/custer added at b551112094
1
plugins/fbpatch
Submodule
1
plugins/fbpatch
Submodule
Submodule plugins/fbpatch added at 551dd7eee4
1
plugins/xtxpatch
Submodule
1
plugins/xtxpatch
Submodule
Submodule plugins/xtxpatch added at e8ee5c898d
2
private
2
private
Submodule private updated: a86a33b46e...d68983ea9b
273
todo.md
Normal file
273
todo.md
Normal file
@@ -0,0 +1,273 @@
|
||||
## TODO :
|
||||
---
|
||||
|
||||
### DEV
|
||||
- [/] `0...` formbuilder mise a jour automatique ?
|
||||
- [/] `0...` regarder où mettre les infos de debug dans le fichier wp-config pour eviter qu'elles soient ecrasees a la mise a jour
|
||||
- [/] `0...` user info shortcodes : inverser fonctinnement par defaut 'author' ou 'logged-in'
|
||||
- [/] `0...` user info shortcodes : pbm apostrophe backskash
|
||||
- [/] `0...` meilleur gestion des champs acf et de leur valeur, tout mettre en constantes dans class
|
||||
- [/] `0...` create menu for custer, that we can hide with an action on the plugin list
|
||||
- [/] `0...` cipf plugin empeche validation de certains forms ?
|
||||
- [/] `0...` ne pas continuer sur les anchors (pas besoin de modifier la page en tant qu'admin)
|
||||
- [/] `0...` pourquoi la page de redirection ne marche pas ? -> mauvais hook
|
||||
- [/] `0...` noter dans le code tous les endroits oú je fais appel a du css ecrit du coté de fabien, pour info pour le futur (dans l'ideal, je devrais tout faire dans le plugin) -> finalement je les ai changé
|
||||
- [/] `0...` nouvelle installation creer des bugs : pas tres grave, il suffit de desactiver et reactiver nimporte quel plugin
|
||||
- [/] `0...` creer champ recherche __image_profil_url__ -> acf renvoit deja l'url
|
||||
- [/] `0...` schedule events
|
||||
- [/] `0...` acf fields history -> `history`
|
||||
- [/] `0...` j'ai cree un job cron daily
|
||||
- [/] `0...` ajouté une tache cron dans infomaniak
|
||||
- [/] `0...` ajouté une info dans wp-config.php : `define( 'DISABLE_WP_CRON', true );`
|
||||
- [/] `0...` ajouté adresse ip du server pour maintenance infomaniak: 83.166.138.108 (trouvee avec la commande `hostname -I`)
|
||||
- [/] `0...` resolu le pbm des dates : il faut bien penser a regler le site en francais, et mettre le format acf sur 'l d F Y' (L minuscule) (d: 01, ou alors j: 1)
|
||||
### INSCRIPTION/CONNECTION
|
||||
- [/] `0...` front end
|
||||
- [/] `0...` par roles
|
||||
- [/] `0...` autovalidation mail (profs)
|
||||
- [/] `0...` validation admin (partners)
|
||||
- [/] `0...` redirection
|
||||
- [/] `0...` gerer le cas d'adresse email existante
|
||||
- [/] `0...` front end
|
||||
- [/] `0...` redirection
|
||||
- [/] `0...` apres connexion : cacher bouton se connecter : 'conditional menus'
|
||||
- [/] `0...` quand on change le mdp depuis le form front, ca marche avec la connexion via le formulaire de connexion de de formbuilder, mais pas avec celle de wp (attendre que fabien confirme le pbm)
|
||||
- [/] `0...` affichage de l'oeil avec form builder parfois bug -> on n'utilise plus form builder pour ca
|
||||
- [/] `0...` redirection (regarder ce que divi permet de faire)
|
||||
- [/] `0...` changer mdp
|
||||
- [/] `0...` popup login - lien email creation de mdp
|
||||
- [/] `0...` popup login - attribuer role
|
||||
- [/] `0...` option mdp oublié
|
||||
- [/] `0...` popup login n'apparait pas sur chrome
|
||||
- [/] `0...` plugin xootix : trouver un meilleur moyen d'identifier que c'est un partenaire qui s'inscrit (redirection methode bloque les autres redirections, c'est relou)
|
||||
- [/] `0...` login avec xootix : champs password avec 'autocomplete=new-password' -> safari croit que c'est un nouveau mot de passe a creer -> g ecrit a plugin
|
||||
- [/] `0...` cacher le champ 'remember me'
|
||||
- [/] `0...` verifier que tous les liens fonctionnent (warning les liens pour les mots de passe oublies)
|
||||
### ADMIN
|
||||
- [/] `0...` admin et editor doivent avoir acces aux fiches profs
|
||||
- [/] `0...` pourquoi la validation de la carte depuis fipf foncitonne meme quand le champs n'est pas relié ?
|
||||
- [/] `0...` montrer barre admin pour la fipf
|
||||
- [/] `0...` page prof vue par admin : lien telechargement photo
|
||||
- [/] `0...` compte secretaria doit pouvoir modifier fiches partenaires
|
||||
- [/] `0...` fipf regarde profil prof : ne voit pas le bouton pour valider le virement
|
||||
- [/] `0...` gestion listes mdp offres partenaires -> cr en option
|
||||
- [/] `0...` gestion listes mdp inscription carte -> geré a la main par diego (avec le champs observation)
|
||||
- [/] `0...` admin et editor redirection emmene pas sur la bonne page
|
||||
- [/] `0...` faire des options de recherches plus poussees pour le compte FIPF pour les profs
|
||||
- [/] `0...` cacher infos admin fipf : Options personnelles, À propos du compte, Mots de passe d’application, et Login/Signup
|
||||
- [/] `0...` ecrire mode emplois custer queries
|
||||
- [/] `0...` ajout class `.hide_for_fipfrole_cipf` pour les champs acf a cacher pour la fipf
|
||||
- [/] `0...` ajout class `.hide_title_for_fipfrole_cipf` pour cacher le titre du groupe de champ (a rajouter sur n'importe quel champ du groupe)
|
||||
- [/] `0...` ajout class `.hide_group_for_fipfrole_cipf` pour cacher tout le groupe de champ (a rajouter sur n'importe quel champ du groupe)
|
||||
- [/] `0...` j'ai ajouté class `.textarea_full_width` sur historique
|
||||
- [/] `0...` pour acf field 'historique' faire gaffe a cocher 'new lines'>'no formatting'
|
||||
- [/] `0...` ajout de class css `readonly_acf`
|
||||
### FRONT END
|
||||
- [/] `0...` champs pre-remplis
|
||||
- [/] `0...` editer champs
|
||||
- [/] `0...` editions form multistep pbm ac images qui doivent revalider
|
||||
- [/] `0...` dans les pages on ne peut pas montrer le champ email -> pourquoi ? que faire ?
|
||||
- [/] `0...` what is honeypot captcha field ?
|
||||
- [/] `0...` formbuilder emails notification et confirmation pbm
|
||||
- [/] `0...` footer en bas de page
|
||||
- [/] `0...` footer avec espace blanc en bas https://cipf.lejourdesprofs.org/inscription/
|
||||
- [/] `0...` footer en bas de page pour page 404 (page non trouvee de members)
|
||||
- [/] `0...` creer un shortcode pour recuperer les noms et prenoms de la personne connectee, comme pour lemail
|
||||
- [/] `0...` form builder multiple modals don't work
|
||||
- [/] `0...` plusieurs modals
|
||||
- [/] `0...` creer carte en pdf : 'e2pdf' champs textes (fabien)
|
||||
- [/] `0...` creer carte en pdf : 'e2pdf' champs images
|
||||
- [/] `0...` empecher ouvrir pdf a chargement page
|
||||
- [/] `0...` afficher le nom et le prénom : au lieu que le menu s'appel 'nom prenom', qu'ils s'appel 'hugo lamy' -> plus besoin
|
||||
- [/] `0...` (abandonné) modal form builder - labels disparus
|
||||
- [/] `0...` (abandonné) modal form builder - css cassé
|
||||
- [/] `0...` (abandonné) modal form builder - icone de fermeture non modifiee
|
||||
- [/] `0...` redirection dont' work
|
||||
- [/] `0...` cacher flash page
|
||||
- [/] `0...` quand fabien utilise les champs acf du calcul, meme a d'autres endroits, il a besoin du text, pas du nombre, donc voir une solution
|
||||
- [/] `0...` verifier que le mappage des champs acf pour le calcul fonctionnent bien -> pas avec 0 en value (et apostrophe ?)
|
||||
- [/] `0...` avant validation formulaire, revoir tous les choix
|
||||
- [/] `0...` `cipf_user_info` : si pas la ressource, affiche actuellement 'false' (justificatif), afficher 'non' ? ou 'vide' ?
|
||||
- [/] `0...` images upload : trouver lien site pour modifier photo en ligne
|
||||
- [/] `0...` images upload : site exterieur ? https://www.img2go.com/fr/recadrer-image
|
||||
- [/] `0...` images upload : redimensionner images crop -> on oublie
|
||||
- [/] `0...` affichage aleatoire partenaires
|
||||
- [/] `0...` champs textarea : resize none `https://www.w3schools.com/cssref/css3_pr_resize.php`
|
||||
- [/] `0...` pbm affichage responsive hauteur de la barre menu
|
||||
- [/] `0...` simplifier text editeur wysiwyg
|
||||
- [/] `0...` creation roles par default : prof ? partenaire ? -> prof
|
||||
- [/] `0...` voir avec fabien le css des menus
|
||||
- [/] `0...` restrictions pages profs
|
||||
- [/] `0...` restrictions pages partenaires
|
||||
- [/] `0...` `$$etat_carte$$` et `$$livraison$$` reste en l'état dans le mail alors que `$$paiement$$` (par exemple) donne le bon résultat
|
||||
- [/] `0...` css carte prof responsive mobile
|
||||
- [/] `0...` pbm addresse email d'envois
|
||||
- [/] `0...` supprimer images dans media a suppression compte
|
||||
- [/] `0...` voir le pbm des conditions avec divi
|
||||
- [/] `0...` personnes non admin qui essayent d'acceder a l'admin -> rediriger vers page accueil (au lieu de voir message 'interdit d'acces')
|
||||
- [/] `0...` pbm : prof telecharger justificatif activite professionnelle : formats jpeg (jpEg) non acceptés (mais jpg oui)
|
||||
### PROFS
|
||||
- [/] `0...` creation prof, champ mdp ne bloque pas en cas d'erreur (trop court ou pas identiques) (~ mis a derniere etape)
|
||||
- [/] `0...` message mauvais mdp n'apparait pas a l'etape finale (~ mis a derniere etape)
|
||||
- [/] `0...` prof ne peut pas voir sa page -> acces interdit
|
||||
- [/] `0...` menu prof -> la procédure de déconnexion
|
||||
- [/] `0...` menu prof -> faire le lien vers le compte
|
||||
- [/] `0...` remetre les champs de formulaire de la derniere etape a zero (accepter conditions utilisation, etc...)
|
||||
- [/] `0...` e2pdf -> afficher image
|
||||
- [/] `0...` sur page commender carte, si pas connecté, forcer popup connexion/inscription
|
||||
- [/] `0...` page achat carte : afficher le bon message 'commander' ou 'renouveler'
|
||||
- [/] `0...` pbm calcul champs formulaire
|
||||
- [/] `0...` apres paiement, condition message reussite/echec
|
||||
- [/] `0...` champs formulaires pas remis a zero, pourquoi ? et aussi remettre a zero le champ 10/15 (total 5 champs (+ virement))
|
||||
- [/] `0...` bloc virement pour admin et editor, pas vu par profs
|
||||
- [/] `0...` condition pour voir page prof : si choix paiement par viremenet, tant que virement pas recu (case non cochee par diego) alors pas possible de voir la page -> redirection vers page 'votre compte n'est pas encore validé'
|
||||
- [/] `0...` sur page prof : condition afficher bouton 'renouveler'/'non disponible' -> plus besoin
|
||||
- [/] `0...` resset cgv champe dans form prof
|
||||
- [/] `0...` au calcul du prix dans paypal, prendre la bonne valeur meme si acf return est en label ou array
|
||||
- [/] `0...` pbm prof form don't validate change in livraison
|
||||
- [/] `0...` peut-etre verifier a ouverture de page profil si virement en attente invalide mais date valide -> passer en attente valide
|
||||
- [/] `0...` ajouter !important sur les css des etapes pour surpasser d'autres css qui forcent un display pas none
|
||||
- [/] `0...` page commander carte n'affiche pas renouveler carte
|
||||
- [/] `0...` la mise a jour des etapes est toute cassee, apres paiement
|
||||
- [/] `0...` faire gaffe bouton front valider virement : ne pas valider si pas de virement en cours
|
||||
- [/] `0...` creation prof -> redirection commande
|
||||
- [/] `0...` bouton front valider virement
|
||||
- [/] `0...` ne pas calculer les prix, laisser formbuilder le faire
|
||||
- [/] `0...` afficher les messages en fonction des etapes
|
||||
- [/] `0...` some fields in form prof are not set second time or already set first time
|
||||
- [/] `0...` empecher personnes deconnectees d'acceder a la page de commande
|
||||
- [/] `0...` prof visite son profil : verifications sur les virements ? -> trop lourd de faire toutes les verifs a chaque fois
|
||||
- [/] `0...` validation virement -> mettre a jour la date
|
||||
- [/] `0...` Quand je renouvelle ma carte -> 0 ou 5 euros est décoché et quand je coche le bouton de validation disparaît
|
||||
- [/] `0...` chez fabien, message 'paiement reussi/echoue' ne s'affiche pas
|
||||
- [/] `0...` condition pour voir page prof : si premier paiement raté ? -> finalement, uniquement si nouveau
|
||||
- [/] `0...` quand carte a expiree, changer champ date avec 'carte a renouveler' et couleur rose #ed009e
|
||||
- [/] `0...` quand carte a expiree, changer champ 'telecharger' avec 'renouveler'
|
||||
- [/] `0...` pour admin, gerer bouton 'activer compte' (inactif en attente de virement)
|
||||
- [/] `0...` champ acf mettre a jour a l'achat et lors de rappels : carte pas valide -> etat 'commander'
|
||||
- [/] `0...` penser a remettre champ acf 'compte actif' a zero a expiration de la carte
|
||||
- [/] `0...` creer numero des cartes (yyyymmddx-A) A: carte generees sur le site / cartes imprimees lui-meme
|
||||
- [/] `0...` dans formulaire prof achat carte, pourquoi le champ de livraison est remis a zero ?
|
||||
- [/] `0...` sur page prof, vue par admin/editor : afficher lien du fichier certificat, au lieu de son numero
|
||||
- [/] `0...` en attente de virement : si ancienne carte deja cree et encore valide, ne pas bloquer acces au compte
|
||||
- [/] `0...` changer date de validite uniquement apres virement validé, pas avant
|
||||
- [/] `0...` page prof si paiement en cours : pourquoi refaire passer a aucun ?
|
||||
- [/] `0...` bouton suppresion de compte -> faire en sorte qu'il supprime le compte :p -> finalement non, gestion par admin
|
||||
- [/] `0...` redirection sur la page du prof n'a pas lieu depuis "creer un compte" depuis le bouton "mon espace" de la page d'accueil
|
||||
- [/] `0...` prof a cree carte et veut faire virement, mais il est redirigé vers formulaire quand il va sur son compte
|
||||
- [/] `0...` resumé des options de formulaire avant validation
|
||||
- [/] `0...` page 'compte en attente de validation' -> rediriger vers compte si actif
|
||||
- [/] `0...` messages payements reussi ou echouer n'apparaissent plus
|
||||
- [/] `0...` calculs prix pour paypal, bien prendre la valeur, pas le libellé, meme si on a reglé le retour sur libellé
|
||||
- [/] `0...` la carte n'a pas de numéro
|
||||
- [/] `0...` pour les cartes offertes (50 cartes par ex) : un code a usage unique ? -> ct une option
|
||||
- [/] `0...` pas de message d'erreur si prof modifie son email par une adress existante
|
||||
- [/] `0...` que faire en cas de virement : valider status virement dès validation formulaire ? si la personne n'a finalement pas envoyé son virement, et qu'elle se dit qu'elle va plutot payer par paypal ? si elle a envoyé son virement, qu'il n'est pas encore validé, est-ce qu'elle peut payer par paypal ? est-ce qu'elle risque de se tromper ?
|
||||
- [/] `0...` paiement par virement du prof, fipf valide la carte : creer numero, ajouter 1 an, changer etat 'commande'->'renouvellement'
|
||||
- [/] `0...` page profil prof, faire le check si la carte n'est pas expiree (le check si la carte est expiree fonctionne deja)
|
||||
- [/] `0...` page profil prof, faire le check si la carte est expiree mais en attente de virement
|
||||
- [/] `0...` apres validation premier form, mais avant paiement, la page front affiche 'renouveller' au lieu de acheter
|
||||
- [/] `0...` profs roles peuvent lirent les articles privés et autre
|
||||
### PARTENAIRES
|
||||
- [/] `0...` virer image a suppression post
|
||||
- [/] `0...` editer offres
|
||||
- [/] `0...` affiche offre en fonction valeur de champs acf
|
||||
- [/] `0...` css : pbm photo plusieurs offres partenaire (grid ? float ?)
|
||||
- [/] `0...` css : menus droite partenaire : centrer dans la colonne
|
||||
- [/] `0...` grid text vers le haut
|
||||
- [/] `0...` text toute la largeur si pas d'image
|
||||
- [/] `0...` creer css pour cacher champs de connexion des profs (nom et prenom) -> plus besoin
|
||||
- [/] `0...` creer une redirection vers la page partenaire quand on valide le formulaire
|
||||
- [/] `0...` menu partenaire -> faire un lien vers sa page
|
||||
- [/] `0...` css image partenaires - occuper toute la largeur
|
||||
- [/] `0...` css image partenaires - garder format 16/9
|
||||
- [/] `0...` css image partenaires - pour cipf-prtnr-img * et post title img
|
||||
- [/] `0...` a la creation d'un compte partenaire, creer automatiquement sa page avec son adress email ? -> finalement non, plutot rediriger vers formulaire de creation de page
|
||||
- [/] `0...` find right role at creation account, without referer
|
||||
- [/] `0...` si page partenaire n'existe pas, rediriger sur la page creation de page
|
||||
- [/] `0...` shortcode user infos trouve pas author sur page partenaire
|
||||
- [/] `0...` verifier si identification partenaire avec options fonctionne quand plusieurs connexions - non, trouver une autre methode
|
||||
- [/] `0...` inscription partenaire role
|
||||
- [/] `0...` email a validation de formulaire de creation de page ne contient pas l'url du partenaire
|
||||
- [/] `0...` empecher les autres utilisateurs de voir le bouton de modificaiton de sa page partenaire
|
||||
- [/] `0...` verifier les acces a la modification de page partenaire : pour l'instant tous les partenaires voient le bouton, et seuls les auteurs et les admins peuvent modifier, mais les admins ne devraient pas pouvoir modifier
|
||||
- [/] `0...` sur page partenaire, offres, faire css pour simuler fonctionnement masquer/afficher (parce que les conditions divi perdent la memoire)
|
||||
- [/] `0...` trouver une autre solution que `HTTP_REFERER` pour creer le role partenaire -> la redirection ?
|
||||
- [/] `0...` ajouter option offre a duree determinee
|
||||
- [/] `0...` css white-space: break-space des offres -> finalement acf gere ca
|
||||
- [/] `0...` creer un mot cle special pour les emails pour creer un lien vers la page partenaire pour diego, similaires a __author_page__
|
||||
- [/] `0...` voir comment cacher bouton modification pages partenaire sauf pour creator et admin et fipf (hook ? css ?)
|
||||
- [/] `0...` voir comment empecher les gens d'acceder a la page de modificaiton des offres partenaires, sauf creator et admin et fipf
|
||||
- [/] `0...` montrer la barre d'admin pour la fipf et les admins
|
||||
- [/] `0...` empecher role fipf de supprimer les admins
|
||||
- [/] `0...` sur page partenaire, si aucune offre, afficher un message (un bloc html preparé par fabien), et passer la page en brouillon pour qu'elle n'apparaisse plus sur la liste des partenaires
|
||||
- [/] `0...` btn url à masquer si vide (fabien m'a ecrit ca, je ne suis pas sur de ce que ca veut dire, peut-etre un bouton sur la page partenaire ?)
|
||||
- [/] `0...` empecher d'acceder a la page de creation de formulaire, uniquement celle de modification
|
||||
- [/] `0...` un bouton publier ou ne pas publier ma page ? -> ajouter un bouton sous le bouton modifier la page, relié a un champs acf radio 'publier'/'masquer' -> toogle l'etat
|
||||
- [/] `0...` partenaire, boutons publier / masquer : creer une class pour montrer un seul des deux
|
||||
- [/] `0...` partenaire logo pbm
|
||||
- [/] `0...` pbm redirection apres page partner changee en brouillon (url avec post id)
|
||||
- [/] `0...` tous les partenaires peuvent voir les pages des autres partenaires en brouillon
|
||||
### EMAILS
|
||||
- [/] `0...` filtrer email formbuilder $$field$$
|
||||
- [/] `0...` email, faire que diego puisse clicker sur un lien quand un prof fait un changement, qui l'emmene vers la profil du prof -> ajouter url de la page author du prof dans le shortcode user infos
|
||||
- [/] `0...` some variables in email dont expand well (numbers ?)
|
||||
- [/] `0...` filter email user info : si page author, diviFB ne retrouve pas l'id pour le prof, donc chercher le miens
|
||||
- [/] `0...` filtrer les mails : dates ne s'affichent pas en dd/mm/yyyy (en tout cas pas toujours)
|
||||
- [/] `0...` virer le mail de creation de mdp a creation de compte
|
||||
- [/] `0...` emails envoyés depuis compte admin modifiant prof : les champs $$field$$ montrent la personne connectee, pas le prof -> finamelement les admins ne modifient pas les profs depuis le front
|
||||
- [/] `0...` xootix pbm email en cas de reinitialisation du mdp : pas de liens
|
||||
- [/] `0...` faire lien email pour que diego puisse voir la page partenaire ou prof qui a ete modifiee
|
||||
- [/] `0...` pouvoir personnaliser les mails de inscription de xootix
|
||||
- [/] `0...` email creation compte pour modifier mdp : manque le lien, et de toute maniere l'email est inutil -> possible d'empecher de l'envoyer ?
|
||||
- [/] `0...` xootix pbm email liens : s'ils ne le resolvent pas, faire un filtre sur wp email
|
||||
- [/] `0...` enlever liste de mail dans les mails smtp : This message is from a mailing list
|
||||
- [/] `0...` pouvoir personnaliser les mails de oublie de xootix
|
||||
- [/] `0...` cacher 'se souvenir de moi' sur la creation/inscription des comptes
|
||||
- [/] `0...` pbm addresse email d'envois
|
||||
- [/] `0...` form-builder change les urls des emails, c'est chelou -> en fait c'est brevo (sendinblue) qui fait ca, mais pourquoi, et comment l'eviter ?
|
||||
- [/] `0...` profs : validation payment prof, envoyer email
|
||||
- [/] `0...` profs : validation virement prof, envoyer email
|
||||
- [/] `0...` changer l'adresse d'envois des emails
|
||||
- [/] `0...` permettre d'afficher l'image de profil dans un email avec la balise <img>
|
||||
- [/] `0...` emails, changer 'le compte' par 'la carte' pour expiration, et changer l'ordre
|
||||
- [/] `0...` rajouter un email a diego en cas de problem de paiement
|
||||
- [/] `0...` creation un groupe de champs acf prof/partner pour les emails
|
||||
- [/] `0...` j'ai desactivé l'option qui force les 'emails from' dans wp-mail-smtp
|
||||
- [/] `0...` j'ai ajouté un email qui peut s'envoyer a chaque fois que ce job tourne, pour alerte
|
||||
- [/] `0...` changé contenu dans acf emails reminders pour ajouter chaque offres
|
||||
### PAYMENT
|
||||
- [/] `0...` mettre en place paiement paypal securise
|
||||
- [/] `0...` valider paiement par prof
|
||||
- [/] `0...` mettre a jour infos paiement et carte
|
||||
- [/] `0...` - paiement : pbm mise en place date premier paiement
|
||||
- [/] `0...` recuperer champs acf de somme totale `somme_a_regler`
|
||||
- [/] `0...` date ajoute plusieurs annees
|
||||
- [/] `0...` bloquer renouvellement de payement avant xx temps de la date d'echeance (ex: 30 jours)
|
||||
- [/] `0...` redirection vers page ma carte, avec selector :active pour activer le message reussi ou raté
|
||||
- [/] `0...` erreur dans le calcul du prix
|
||||
- [/] `0...` tester paypal avec compte diego
|
||||
- [/] `0...` condition fenetre moyens de paiements paypal ou virement
|
||||
- [/] `0...` tester avec compte live
|
||||
- [/] `0...` gerer les redirections
|
||||
- [/] `0...` tester les differents formats de dates de acf
|
||||
- [/] `0...` paiements : gerer les erreurs de mon code qui n'invalident pas les paiements
|
||||
- [/] `0...` mieux gerer les cas d'erreur
|
||||
- [/] `0...` paypal: notification payment reussi ou raté, ajouter numero de transaction -> `order_id`
|
||||
- [/] `0...` bouton renouveller carte a 5€ -> ajouter bouton avec lien `/paiement/?prof_card_change=true` + css `.cipf_display_changer_carte`
|
||||
### MENU
|
||||
- [/] `0...` text payement reussi ou raté : ajouter texte dans menu ? garder le systeme des backticks ?
|
||||
- [/] `0...` paypal : entrer les infos du compte
|
||||
### SCHEDULE EVENTS
|
||||
- [ ] `..2.` payments : supprimer order-id trop vieux
|
||||
- [ ] `..2.` partners : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
|
||||
- [ ] `..2.` partners : la gestion des offres à échéance
|
||||
- [ ] `..2.` payments : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte
|
||||
- [ ] `..2.` payments : schedule event pour supprimer les codes
|
||||
- [ ] `..2.` payments : schedule event pour desactiver la carte
|
||||
- [ ] `..2.` payments : faire rappels emails
|
||||
### NEWSLETTER
|
||||
- [ ] `..2.` voir comment implementer ca
|
||||
- [ ] `..2.` comment savoir si une offre est nouvelle
|
||||
- [ ] `..2.` comment gerer si un partenaire a plusieurs nouvelles offres
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user