The usage of the PHP class is only recommended for advanced users given that the procedure may require some customization depending on the site and the CMS utilized. Also, keep in mind that JavaScript is required to visualize the banner and cookie policy.
This class allows you to scan a page in PHP and run the automatic blocking of scripts mentioned in this document. You can access the class via direct download or Packagist.
Here is an example of the PHP class integration:
<?php
function iubenda_system( $html, $type = 'page' ) {
if ( empty( $html ) )
return;
require_once( 'iubenda.class.php' );
// separator
if ( ! iubendaParser::consent_given() && ! iubendaParser::bot_detected() ) {
$iubenda = new iubendaParser( $html, array( 'type' => in_array( $type, array( 'page', 'faster' ), true ) ? $type : 'page' ) );
$html = $iubenda->parse();
}
// finished
return $html;
}
The iubenda_system method verifies if the page visitor consents to the use of cookies. If this is the case, the script returns the HTML provided as a parameter without taking any action such as parsing/replacing.
Simply copy your method into the PHP document and then call it with the following syntax iubenda_system("contenutohtml"); that will return the code.
<!--IUB-COOKIE-BLOCK-START--> and <!--IUB-COOKIE-BLOCK-END-->
iframe that contain defined src
scripts that contain defined src
These operations take place in accordance with the rules explained in this guide. We suggest that you consult the posts relating to the alteration of script, img and iframe tags.
Please note that at the moment the Privacy Controls and Cookie Solution is optimized to comply with very strict Italian implementation regulations (this can only improve compliance in other jurisdictions).
To use the iubenda PHP class on Magento or PrestaShop you simply need to access the Magento/PrestaShop CMS file folder and follow the instructions below:
index.php;require __DIR__ . "/iubenda.class.php"; after the first line;simple_html_dom.php file which you can download here or using the button below;iubenda.cookies.js containing your Privacy Controls and Cookie Solution code.