To briefly state my background I am not a web developer, but an electrical engineer.
The key question I have is where to put the PHP library in the file tree so the code embedded into the webpage can access it. To those in the know this must be trivial, but I cannot find any information about this online.
Here is the library: https://github.com/PlayerNguyen/OptEco/tree/master/web_integration/api
Here is what goes in the webpage: https://github.com/PlayerNguyen/OptEco/blob/master/web_integration/example_top.php
Here is the file tree:
The best way would be to create a custom plugin for your site. Take a look at the plugin handbook to get started
https://developer.wordpress.org/plugins/
In the plugin, you can just put the libraries in a folder, and include them in your main plugin code. Your plugin can then do one of these
- Register a shortcode
- Create a custom template tag, which would be just a function that outputs your content, and can be used in any other php file in your site.
- Create a block for the new block editor
Technically it’s possible to just put this in your theme, but it’s advised to put any custom code like this in a plugin for better maintenance, and ease of changing themes in the future.