/**
  * Function for checking authorization to add as
  * a primary filter to control user and password
  */
 function addAuthenticatorCheckCode($userobj, $username, $password)
 {
     // If option at the user level is off I go out from the procedure
     // without other controls on the verification code twice
     if (!isset($userobj->ID) or trim(get_user_option('sz_google_authenticator_enabled', $userobj->ID)) != '1') {
         return $userobj;
     }
     // Checking and setting variables and secret code entered
     // A profile is stored in the master and the other is passed by login
     if (empty($_POST['googleauthotp'])) {
         $authenticator = '';
     } else {
         $authenticator = trim($_POST['googleauthotp']);
     }
     $options = $this->getModuleOptions('SZGoogleModuleAuthenticator');
     $secrets = trim(get_user_option('sz_google_authenticator_secret', $userobj->ID));
     // Control code inserted into the login form
     // with those in the table of secret codes Emergency
     if ($options['authenticator_emergency_codes'] == '1') {
         $em = unserialize(trim(get_user_option('sz_google_authenticator_codes', $userobj->ID)));
         if (is_array($em) and isset($em[$authenticator]) and $em[$authenticator] == false) {
             $em[$authenticator] = time();
             update_user_option($userobj->ID, 'sz_google_authenticator_codes', serialize($em), true);
             return $userobj;
         }
     }
     // Control code inserted into the login form with
     // that calculated routine internal authenticator class
     if ($this->checkAuthenticatorCode($secrets, $authenticator, $options['authenticator_discrepancy']) === true) {
         return $userobj;
     } else {
         return new WP_Error('invalid_google_authenticator_password', SZGoogleCommon::getTranslate('<strong>ERROR</strong>: Authenticator code is incorrect.', 'sz-google'));
     }
 }
 /**
  * Add the input field that concerns the security code
  * is generated by the application of google recaptcha
  */
 function addCaptchaLoginForm()
 {
     $options = (object) $this->getModuleOptions('SZGoogleModuleRecaptcha');
     echo '<p><label for="recaptcha">' . SZGoogleCommon::getTranslate('reCAPTCHA', 'sz-google') . '<br/>';
     echo '<script src="https://www.google.com/recaptcha/api.js"></script>';
     echo '<div class="g-recaptcha" data-theme="' . $options->recaptcha_style_login . '" data-sitekey="' . $options->recaptcha_key_site . '"></div>';
     echo '<br/>';
 }
 /**
  * Funzione per il controllo di autorizzazione da aggiungere
  * come filtro principale al controllo di utente e password.
  *
  * @return void
  */
 function addAuthenticatorCheckCode($userobj, $username, $password)
 {
     // Se opzione a livello di utente è disattiva esco dalla procedura
     // senza fare ulteriori controlli sul codice di verifica doppio
     if (!isset($userobj->ID) or trim(get_user_option('sz_google_authenticator_enabled', $userobj->ID)) != '1') {
         return $userobj;
     }
     // Controllo e impostazione delle variabili secret e codice inserito.
     // Una é memorizzata in anagrafica profilo e l'altra viene passata da login
     if (empty($_POST['googleauthotp'])) {
         $authenticator = '';
     } else {
         $authenticator = trim($_POST['googleauthotp']);
     }
     $options = $this->getModuleOptions('SZGoogleModuleAuthenticator');
     $secrets = trim(get_user_option('sz_google_authenticator_secret', $userobj->ID));
     // Controllo il codice inserito nel form di login con quello
     // calcolato dalla routine interna della classe authenticator
     if ($this->checkAuthenticatorCode($secrets, $authenticator, $options['authenticator_discrepancy']) === true) {
         return $userobj;
     } else {
         return new WP_Error('invalid_google_authenticator_password', SZGoogleCommon::getTranslate('<strong>ERROR</strong>: Authenticator code is incorrect.', 'szgoogleadmin'));
     }
 }
 /**
  * The function that is normally invoked by hook
  * presents in add_action e add_filter in wordpress
  */
 function getMonitorCode($atts = array())
 {
     if (!is_array($atts)) {
         $atts = array();
     }
     // Loading options for the configuration variables
     // containing the default values ​​for shortcodes and widgets
     $options = (object) $this->getModuleOptions('SZGoogleModuleAnalytics');
     // Extraction of the values ​​specified in shortcode, returned values
     // ​​are contained in the variable names corresponding to the key
     extract(shortcode_atts(array('ga_type' => $options->ga_type, 'ga_uacode' => $options->ga_uacode, 'ga_position' => $options->ga_position, 'ga_compression' => $options->ga_compression, 'ga_enable_front' => $options->ga_enable_front, 'ga_enable_admin' => $options->ga_enable_admin, 'ga_enable_administrator' => $options->ga_enable_administrator, 'ga_enable_logged' => $options->ga_enable_logged, 'ga_enable_subdomain' => $options->ga_enable_subdomain, 'ga_enable_multiple' => $options->ga_enable_multiple, 'ga_enable_advertiser' => $options->ga_enable_advertiser, 'ga_enable_features' => $options->ga_enable_features, 'ga_enable_ip_none_cl' => $options->ga_enable_ip_none_cl, 'ga_enable_ip_none_ad' => $options->ga_enable_ip_none_ad, 'ga_enable_cl_proxy' => $options->ga_enable_cl_proxy, 'ga_enable_cl_proxy_url' => $options->ga_enable_cl_proxy_url, 'ga_enable_cl_proxy_adv' => $options->ga_enable_cl_proxy_adv, 'ga_enable_un_proxy' => $options->ga_enable_un_proxy, 'ga_enable_un_proxy_url' => $options->ga_enable_un_proxy_url), $atts));
     // I delete spaces added and execute the transformation in string
     // lowercase for the control of special values ​​such as "auto"
     $ga_uacode = trim($ga_uacode);
     $ga_enable_cl_proxy_url = trim($ga_enable_cl_proxy_url);
     $ga_enable_cl_proxy_adv = trim($ga_enable_cl_proxy_adv);
     $ga_enable_un_proxy_url = trim($ga_enable_un_proxy_url);
     $ga_type = strtolower(trim($ga_type));
     $ga_position = strtoupper(trim($ga_position));
     $ga_compression = strtolower(trim($ga_compression));
     $ga_enable_front = strtolower(trim($ga_enable_front));
     $ga_enable_admin = strtolower(trim($ga_enable_admin));
     $ga_enable_administrator = strtolower(trim($ga_enable_administrator));
     $ga_enable_logged = strtolower(trim($ga_enable_logged));
     $ga_enable_subdomain = strtolower(trim($ga_enable_subdomain));
     $ga_enable_multiple = strtolower(trim($ga_enable_multiple));
     $ga_enable_advertiser = strtolower(trim($ga_enable_advertiser));
     $ga_enable_features = strtolower(trim($ga_enable_features));
     $ga_enable_ip_none_cl = strtolower(trim($ga_enable_ip_none_cl));
     $ga_enable_ip_none_ad = strtolower(trim($ga_enable_ip_none_ad));
     $ga_enable_cl_proxy = strtolower(trim($ga_enable_cl_proxy));
     $ga_enable_un_proxy = strtolower(trim($ga_enable_un_proxy));
     // Conversion of the values ​​specified directly covered in the
     // parameters with the values ​​used for storing the default values
     if ($ga_compression == 'yes' or $ga_compression == 'y') {
         $ga_compression = '1';
     }
     if ($ga_enable_front == 'yes' or $ga_enable_front == 'y') {
         $ga_enable_front = '1';
     }
     if ($ga_enable_admin == 'yes' or $ga_enable_admin == 'y') {
         $ga_enable_admin = '1';
     }
     if ($ga_enable_administrator == 'yes' or $ga_enable_administrator == 'y') {
         $ga_enable_administrator = '1';
     }
     if ($ga_enable_logged == 'yes' or $ga_enable_logged == 'y') {
         $ga_enable_logged = '1';
     }
     if ($ga_enable_subdomain == 'yes' or $ga_enable_subdomain == 'y') {
         $ga_enable_subdomain = '1';
     }
     if ($ga_enable_multiple == 'yes' or $ga_enable_multiple == 'y') {
         $ga_enable_multiple = '1';
     }
     if ($ga_enable_advertiser == 'yes' or $ga_enable_advertiser == 'y') {
         $ga_enable_advertiser = '1';
     }
     if ($ga_enable_features == 'yes' or $ga_enable_features == 'y') {
         $ga_enable_features = '1';
     }
     if ($ga_enable_ip_none_cl == 'yes' or $ga_enable_ip_none_cl == 'y') {
         $ga_enable_ip_none_cl = '1';
     }
     if ($ga_enable_ip_none_ad == 'yes' or $ga_enable_ip_none_ad == 'y') {
         $ga_enable_ip_none_ad = '1';
     }
     if ($ga_enable_cl_proxy == 'yes' or $ga_enable_cl_proxy == 'y') {
         $ga_enable_cl_proxy = '1';
     }
     if ($ga_enable_un_proxy == 'yes' or $ga_enable_un_proxy == 'y') {
         $ga_enable_un_proxy = '1';
     }
     if ($ga_compression == 'no' or $ga_compression == 'n') {
         $ga_compression = '0';
     }
     if ($ga_enable_front == 'no' or $ga_enable_front == 'n') {
         $ga_enable_front = '0';
     }
     if ($ga_enable_admin == 'no' or $ga_enable_admin == 'n') {
         $ga_enable_admin = '0';
     }
     if ($ga_enable_administrator == 'no' or $ga_enable_administrator == 'n') {
         $ga_enable_administrator = '0';
     }
     if ($ga_enable_logged == 'no' or $ga_enable_logged == 'n') {
         $ga_enable_logged = '0';
     }
     if ($ga_enable_subdomain == 'no' or $ga_enable_subdomain == 'n') {
         $ga_enable_subdomain = '0';
     }
     if ($ga_enable_multiple == 'no' or $ga_enable_multiple == 'n') {
         $ga_enable_multiple = '0';
     }
     if ($ga_enable_advertiser == 'no' or $ga_enable_advertiser == 'n') {
         $ga_enable_advertiser = '0';
     }
     if ($ga_enable_features == 'no' or $ga_enable_features == 'n') {
         $ga_enable_features = '0';
     }
     if ($ga_enable_ip_none_cl == 'no' or $ga_enable_ip_none_cl == 'n') {
         $ga_enable_ip_none_cl = '0';
     }
     if ($ga_enable_ip_none_ad == 'no' or $ga_enable_ip_none_ad == 'n') {
         $ga_enable_ip_none_ad = '0';
     }
     if ($ga_enable_cl_proxy == 'no' or $ga_enable_cl_proxy == 'n') {
         $ga_enable_cl_proxy = '0';
     }
     if ($ga_enable_un_proxy == 'no' or $ga_enable_un_proxy == 'n') {
         $ga_enable_un_proxy = '0';
     }
     // Check if they are logged in as an administrator or registered
     // user and off loading the code if the options are disabled
     $ENDLINE = "\n";
     $USERACT = true;
     if (current_user_can('manage_options')) {
         if ($ga_enable_administrator == '0') {
             $USERACT = false;
         }
     } else {
         if (current_user_can('read') and $ga_enable_logged == '0') {
             $USERACT = false;
         }
     }
     // Check if they are in the backend or frontend and I enable code execution
     // only if the corresponding options have been activated in the configuration
     if (is_admin() and $ga_enable_admin == '0') {
         $USERACT = false;
     }
     if (!is_admin() and $ga_enable_front == '0') {
         $USERACT = false;
     }
     // If the code does not have to be activated based on the options passed
     // return a value of false and not elaborate the creation of monitoring
     if (!$USERACT or strlen($ga_uacode) <= 0) {
         return false;
     }
     // Conversion of the values ​​specified directly covered in the
     // parameters with the values ​​used for storing the default values
     if ($ga_position == '') {
         $ga_position = 'H';
     }
     if ($ga_uacode == '') {
         $ga_uacode = $this->getGAId();
     }
     if ($ga_compression == '1') {
         $ENDLINE = '';
     }
     if (!in_array($ga_type, array('classic', 'universal'))) {
         $ga_type = 'classic';
     }
     // Creating code for comments to be blocked
     // if proves active code generation GA
     $HTML = '';
     if ($ga_compression != '1' and $ga_position != 'F' and ($ga_type == 'universal' or $ga_type == 'classic')) {
         $HTML .= "\n";
         $HTML .= "<!-- GA tracking code with SZ-Google " . SZ_PLUGIN_GOOGLE_VERSION . " : activated mode " . strtoupper($ga_type) . "      -->\n";
         $HTML .= "<!-- ===================================================================== -->\n";
     }
     // Creating code google analytics UNIVERSAL be inserted on HTML page
     // which can be different according to google analytics classic or universal
     if ($ga_type == 'universal') {
         // Check if you have activated the function PROXY HTTP
         // to create a local demand that points to the original script
         if ($ga_enable_un_proxy == '1' and trim($ga_enable_un_proxy_url) != '') {
             $SCRIPTNAME = $ga_enable_un_proxy_url;
         } else {
             $SCRIPTNAME = "www.google-analytics.com/analytics.js";
         }
         $SCRIPTNAME = preg_replace('#^https?://#', '', $SCRIPTNAME);
         // Creation of HTML code to insert in the page WEB
         // for the result check placement options and compression
         $HTML .= '<script type="text/javascript">' . $ENDLINE;
         $HTML .= "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){" . $ENDLINE;
         $HTML .= "(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o)," . $ENDLINE;
         $HTML .= "m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)" . $ENDLINE;
         $HTML .= "})(window,document,'script','//{$SCRIPTNAME}','ga');" . $ENDLINE;
         $HTML .= "ga('create','" . trim($ga_uacode) . "','" . trim(SZGoogleCommon::getCurrentDomain()) . "');" . $ENDLINE;
         if ($ga_enable_features == '1') {
             $HTML .= "ga('require','displayfeatures');" . $ENDLINE;
         }
         if ($ga_enable_ip_none_ad == '1') {
             $HTML .= "ga('set','anonymizeIp',true);" . $ENDLINE;
         }
         $HTML .= "ga('send','pageview');" . $ENDLINE;
         $HTML .= "</script>" . $ENDLINE;
     }
     // Creating code google analytics CLASSIC be inserted on HTML page which
     // can be different according to google analytics classic or universal
     if ($ga_type == 'classic') {
         $HTML .= '<script type="text/javascript">' . $ENDLINE;
         $HTML .= "var _gaq = _gaq || [];" . $ENDLINE;
         $HTML .= "_gaq.push(['_setAccount','" . $ga_uacode . "']);" . $ENDLINE;
         // If option is activated multiple subdomains or add a new row
         // code containing the current displayed _setDomainName domino
         if ($ga_enable_subdomain == '1' or $ga_enable_multiple == '1') {
             $HTML .= "_gaq.push(['_setDomainName','" . trim(SZGoogleCommon::getCurrentDomain()) . "']);" . $ENDLINE;
         }
         // If multiple option is enabled add a new row with the code
         // javascript for google analytics with setup for _setAllowLinker
         if ($ga_enable_multiple == '1') {
             $HTML .= "_gaq.push(['_setAllowLinker',true]);" . $ENDLINE;
         }
         if ($ga_enable_ip_none_cl == '1') {
             $HTML .= "_gaq.push(['_gat._anonymizeIp']);" . $ENDLINE;
         }
         $HTML .= "_gaq.push(['_trackPageview']);" . $ENDLINE;
         $HTML .= "(function () {" . $ENDLINE;
         $HTML .= "var ga = document.createElement('script');" . $ENDLINE;
         $HTML .= "ga.type = 'text/javascript';" . $ENDLINE;
         $HTML .= "ga.async = true;" . $ENDLINE;
         // Check if you have activated the function PROXY HTTP
         // to create a local demand that points to the original script
         $SCRIPT_NOR = ".google-analytics.com/ga.js";
         $WWS = 'ssl';
         $WWW = 'www';
         $SCRIPT_ADV = "stats.g.doubleclick.net/dc.js";
         if ($ga_enable_cl_proxy == '1' and trim($ga_enable_cl_proxy_url) != '') {
             $SCRIPT_NOR = $ga_enable_cl_proxy_url;
             $WWS = '';
             $WWW = '';
             $SCRIPT_NOR = preg_replace('#^https?://#', '', $SCRIPT_NOR);
         }
         if ($ga_enable_cl_proxy == '1' and trim($ga_enable_cl_proxy_adv) != '') {
             $SCRIPT_ADV = $ga_enable_cl_proxy_adv;
             $SCRIPT_ADV = preg_replace('#^https?://#', '', $SCRIPT_ADV);
         }
         // Creation of HTML code to insert in the page WEB
         // for the result check placement options and compression
         if ($ga_enable_advertiser == '1') {
             $HTML .= "ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + '{$SCRIPT_ADV}';" . $ENDLINE;
         } else {
             $HTML .= "ga.src = ('https:' == document.location.protocol ? 'https://{$WWS}' : 'http://{$WWW}') + '{$SCRIPT_NOR}';" . $ENDLINE;
         }
         // Creation of HTML code to insert in the page WEB
         // for the result check placement options and compression
         $HTML .= "var s = document.getElementsByTagName('script')[0];" . $ENDLINE;
         $HTML .= "s.parentNode.insertBefore(ga, s);" . $ENDLINE;
         $HTML .= "})();" . $ENDLINE;
         $HTML .= "</script>" . $ENDLINE;
     }
     // Creating code for comments to be blocked
     // if proves active code generation GA
     if ($ga_compression != '1' and $ga_position != 'F' and ($ga_type == 'universal' or $ga_type == 'classic')) {
         $HTML .= "<!-- ===================================================================== -->\n\n";
     }
     return $HTML;
 }
 /**
  * Creating HTML code for the component called to
  * be used in common for both widgets and shortcode
  */
 function getHTMLCode($atts = array(), $content = null)
 {
     if (!is_array($atts)) {
         $atts = array();
     }
     // Extraction of the values ​​specified in shortcode, returned values
     // ​​are contained in the variable names corresponding to the key
     extract(shortcode_atts(array('calendar' => '', 'title' => '', 'mode' => '', 'weekstart' => '', 'language' => '', 'timezone' => '', 'width' => '', 'height' => '', 'showtitle' => '', 'shownavs' => '', 'showdate' => '', 'showprint' => '', 'showtabs' => '', 'showcalendars' => '', 'showtimezone' => '', 'action' => ''), $atts));
     // Loading options for the configuration variables
     // containing the default values ​​for shortcodes and widgets
     $options = (object) $this->getModuleOptions('SZGoogleModuleCalendar');
     // I delete spaces added and execute the transformation in string
     // lowercase for the control of special values ​​such as "auto"
     $calendar = trim($calendar);
     $title = trim($title);
     $action = trim($action);
     $language = trim($language);
     $timezone = trim($timezone);
     $mode = strtoupper(trim($mode));
     $weekstart = strtolower(trim($weekstart));
     $width = strtolower(trim($width));
     $height = strtolower(trim($height));
     $showtitle = strtolower(trim($showtitle));
     $shownavs = strtolower(trim($shownavs));
     $showdate = strtolower(trim($showdate));
     $showprint = strtolower(trim($showprint));
     $showtabs = strtolower(trim($showtabs));
     $showcalendars = strtolower(trim($showcalendars));
     $showtimezone = strtolower(trim($showtimezone));
     // Conversion of the values ​​specified directly covered in the
     // parameters with the values ​​used for storing default values
     if ($showtitle == 'yes' or $showtitle == 'y') {
         $showtitle = '1';
     }
     if ($shownavs == 'yes' or $shownavs == 'y') {
         $shownavs = '1';
     }
     if ($showdate == 'yes' or $showdate == 'y') {
         $showdate = '1';
     }
     if ($showprint == 'yes' or $showprint == 'y') {
         $showprint = '1';
     }
     if ($showtabs == 'yes' or $showtabs == 'y') {
         $showtabs = '1';
     }
     if ($showcalendars == 'yes' or $showcalendars == 'y') {
         $showcalendars = '1';
     }
     if ($showtimezone == 'yes' or $showtimezone == 'y') {
         $showtimezone = '1';
     }
     if ($showtitle == 'no' or $showtitle == 'n') {
         $showtitle = '0';
     }
     if ($shownavs == 'no' or $shownavs == 'n') {
         $shownavs = '0';
     }
     if ($showdate == 'no' or $showdate == 'n') {
         $showdate = '0';
     }
     if ($showprint == 'no' or $showprint == 'n') {
         $showprint = '0';
     }
     if ($showtabs == 'no' or $showtabs == 'n') {
         $showtabs = '0';
     }
     if ($showcalendars == 'no' or $showcalendars == 'n') {
         $showcalendars = '0';
     }
     if ($showtimezone == 'no' or $showtimezone == 'n') {
         $showtimezone = '0';
     }
     // If I could not assign any value to the instructions
     // above, put the default absolute and can be changed
     $YESNO = array('1', '0');
     if ($action == 'widget') {
         if ($calendar == '') {
             $calendar = $options->calendar_w_calendars;
         }
         if ($title == '') {
             $title = $options->calendar_w_title;
         }
         if ($width == '') {
             $width = $options->calendar_w_width;
         }
         if ($height == '') {
             $height = $options->calendar_w_height;
         }
         if (!in_array($showtitle, $YESNO)) {
             $showtitle = $options->calendar_w_show_title;
         }
         if (!in_array($shownavs, $YESNO)) {
             $shownavs = $options->calendar_w_show_navs;
         }
         if (!in_array($showdate, $YESNO)) {
             $showdate = $options->calendar_w_show_date;
         }
         if (!in_array($showprint, $YESNO)) {
             $showprint = $options->calendar_w_show_print;
         }
         if (!in_array($showtabs, $YESNO)) {
             $showtabs = $options->calendar_w_show_tabs;
         }
         if (!in_array($showcalendars, $YESNO)) {
             $showcalendars = $options->calendar_w_show_calendars;
         }
         if (!in_array($showtimezone, $YESNO)) {
             $showtimezone = $options->calendar_w_show_timezone;
         }
     } else {
         if ($calendar == '') {
             $calendar = $options->calendar_s_calendars;
         }
         if ($title == '') {
             $title = $options->calendar_s_title;
         }
         if ($width == '') {
             $width = $options->calendar_s_width;
         }
         if ($height == '') {
             $height = $options->calendar_s_height;
         }
         if (!in_array($showtitle, $YESNO)) {
             $showtitle = $options->calendar_s_show_title;
         }
         if (!in_array($shownavs, $YESNO)) {
             $shownavs = $options->calendar_s_show_navs;
         }
         if (!in_array($showdate, $YESNO)) {
             $showdate = $options->calendar_s_show_date;
         }
         if (!in_array($showprint, $YESNO)) {
             $showprint = $options->calendar_s_show_print;
         }
         if (!in_array($showtabs, $YESNO)) {
             $showtabs = $options->calendar_s_show_tabs;
         }
         if (!in_array($showcalendars, $YESNO)) {
             $showcalendars = $options->calendar_s_show_calendars;
         }
         if (!in_array($showtimezone, $YESNO)) {
             $showtimezone = $options->calendar_s_show_timezone;
         }
     }
     // Control the variable title if specified in the option
     // otherwise check the special value with language translation
     if ($calendar == '') {
         $calendar = $options->calendar_o_calendars;
     }
     if ($title == '') {
         $title = $options->calendar_o_title;
     }
     if ($mode == '') {
         $mode = $options->calendar_o_mode;
     }
     if ($weekstart == '') {
         $weekstart = $options->calendar_o_weekstart;
     }
     if ($language == '') {
         $language = $options->calendar_o_language;
     }
     if ($timezone == '') {
         $timezone = $options->calendar_o_timezone;
     }
     if (!in_array($weekstart, array('1', '2', '7'))) {
         $weekstart = '1';
     }
     // Calculating the variable of language translation to be applied
     // to embed the google calendar. Special value 99 for that wordpress
     if (!array_key_exists($language, SZGoogleCommon::getLanguages())) {
         $language = $options->calendar_o_language;
     }
     if (!array_key_exists($language, SZGoogleCommon::getLanguages())) {
         $language = '99';
     }
     if ($language == '99') {
         $language = substr(get_bloginfo('language'), 0, 2);
     }
     if (!array_key_exists($timezone, SZGoogleCommon::getTimeZone())) {
         $timezone = $options->calendar_o_timezone;
     }
     if (!array_key_exists($timezone, SZGoogleCommon::getTimeZone())) {
         $timezone = 'none';
     }
     // Checking the values ​​passed in arrays that specify the size of the widget
     // otherwise imposed on the value of the one specified in the options
     if (!ctype_digit($width) and $width != 'auto') {
         $width = 'auto';
     }
     if (!ctype_digit($height) and $height != 'auto') {
         $height = 'auto';
     }
     // Control the size of the widget and formal control of the numerical
     // values, if I find some inconsistency apply the default preset
     if ($width == '') {
         $width = "100%";
     }
     if ($width == 'auto') {
         $width = "100%";
     }
     if ($height == '') {
         $height = '400';
     }
     if ($height == 'auto') {
         $height = '400';
     }
     // Create array containing variables that are used
     // in the URL string reference to embed on iframe
     $URLarray = array();
     $URLarray[] = "hl=" . urlencode($language);
     $URLarray[] = "height=" . urlencode($height);
     if ($title != '') {
         $URLarray[] = 'title=' . urlencode($title);
     }
     if ($weekstart != '') {
         $URLarray[] = 'wkst=' . urlencode($weekstart);
     }
     if ($timezone != '') {
         $URLarray[] = 'ctz=' . urlencode($timezone);
     }
     if ($mode == 'AGENDA') {
         $URLarray[] = "mode=" . urlencode($mode);
     }
     if ($mode == 'WEEK') {
         $URLarray[] = "mode=" . urlencode($mode);
     }
     if ($showtitle != '1') {
         $URLarray[] = "showTitle=0";
     }
     if ($shownavs != '1') {
         $URLarray[] = "showNav=0";
     }
     if ($showdate != '1') {
         $URLarray[] = "showDate=0";
     }
     if ($showprint != '1') {
         $URLarray[] = "showPrint=0";
     }
     if ($showtabs != '1') {
         $URLarray[] = "showTabs=0";
     }
     if ($showcalendars != '1') {
         $URLarray[] = "showCalendars=0";
     }
     if ($showtimezone != '1') {
         $URLarray[] = "showTz=0";
     }
     // Creating array containing the names of the calendars to display
     // The names must be separated by a comma in the specific variable
     $CALarray = explode(',', $calendar);
     foreach ($CALarray as $key => $value) {
         if (trim($value) != '') {
             $URLarray[] = 'src=' . urlencode(trim($value));
         }
     }
     // Creating HTML embed code to add to the page wordpress
     // First prepare the code of a single button, and then call wrapping function
     $HTML = '<script type="text/javascript">';
     $HTML .= "var h='<'+'";
     $HTML .= 'iframe src="https://www.google.com/calendar/embed?' . implode("&amp;", $URLarray) . '" ';
     $HTML .= 'style="border-width:0" ';
     $HTML .= 'width="' . $width . '" ';
     $HTML .= 'height="' . $height . '" ';
     $HTML .= 'frameborder="0" scrolling="no"';
     $HTML .= "></'+'iframe'+'>';";
     $HTML .= "document.write(h);";
     $HTML .= '</script>';
     // Return from the function with the whole string containing
     // the HTML code for inserting the code in the page
     return $HTML;
 }
Example #6
0
 function get_plus_language()
 {
     $values = SZGoogleCommon::getLanguages();
     $this->moduleCommonFormSelect('sz_google_options_plus', 'plus_language', $values, 'medium', '');
     $this->moduleCommonFormDescription(__('specify the language code associated with your website, if you do not specify any value will be called the get_bloginfo(\'language\') and set the same language related to the theme of wordpress.', 'szgoogleadmin'));
 }
 /**
  * Creating HTML code for the component called to
  * be used in common for both widgets and shortcode
  */
 function getHTMLCode($atts = array(), $content = null)
 {
     if (!is_array($atts)) {
         $atts = array();
     }
     // Extraction of the values ​​specified in shortcode, returned values
     // ​​are contained in the variable names corresponding to the key
     extract(shortcode_atts(array('id' => '', 'responsive' => '', 'width' => '', 'height' => '', 'margintop' => '', 'marginright' => '', 'marginbottom' => '', 'marginleft' => '', 'marginunit' => '', 'autoplay' => '', 'loop' => '', 'fullscreen' => '', 'disablekeyboard' => '', 'theme' => '', 'cover' => '', 'delayed' => '', 'title' => '', 'analytics' => '', 'disableiframe' => '', 'disablerelated' => '', 'action' => ''), $atts));
     // Loading options for the configuration variables
     // containing the default values ​​for shortcodes and widgets
     $options = (object) $this->getModuleOptions('SZGoogleModuleYoutube');
     // I delete spaces added and execute the transformation in string
     // lowercase for the control of special values ​​such as "auto"
     $id = trim($id);
     $title = trim($title);
     $cover = trim($cover);
     $width = strtolower(trim($width));
     $height = strtolower(trim($height));
     $responsive = strtolower(trim($responsive));
     $margintop = strtolower(trim($margintop));
     $marginright = strtolower(trim($marginright));
     $marginbottom = strtolower(trim($marginbottom));
     $marginleft = strtolower(trim($marginleft));
     $marginunit = strtolower(trim($marginunit));
     $autoplay = strtolower(trim($autoplay));
     $loop = strtolower(trim($loop));
     $fullscreen = strtolower(trim($fullscreen));
     $disablekeyboard = strtolower(trim($disablekeyboard));
     $theme = strtolower(trim($theme));
     $delayed = strtolower(trim($delayed));
     $analytics = strtolower(trim($analytics));
     $disableiframe = strtolower(trim($disableiframe));
     $disablerelated = strtolower(trim($disablerelated));
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     if ($width == '') {
         $width = $options->youtube_width;
     }
     if ($height == '') {
         $height = $options->youtube_height;
     }
     if ($responsive == '') {
         $responsive = $options->youtube_responsive;
     }
     if ($margintop == '') {
         $margintop = $options->youtube_margin_top;
     }
     if ($marginright == '') {
         $marginright = $options->youtube_margin_right;
     }
     if ($marginbottom == '') {
         $marginbottom = $options->youtube_margin_bottom;
     }
     if ($marginleft == '') {
         $marginleft = $options->youtube_margin_left;
     }
     if ($marginunit == '') {
         $marginunit = $options->youtube_margin_unit;
     }
     if ($autoplay == '') {
         $autoplay = $options->youtube_autoplay;
     }
     if ($loop == '') {
         $loop = $options->youtube_loop;
     }
     if ($fullscreen == '') {
         $fullscreen = $options->youtube_fullscreen;
     }
     if ($disablekeyboard == '') {
         $disablekeyboard = $options->youtube_disablekeyboard;
     }
     if ($theme == '') {
         $theme = $options->youtube_theme;
     }
     if ($cover == '') {
         $cover = $options->youtube_cover;
     }
     if ($delayed == '') {
         $delayed = $options->youtube_delayed;
     }
     if ($analytics == '') {
         $analytics = $options->youtube_analytics;
     }
     if ($disableiframe == '') {
         $disableiframe = $options->youtube_disableiframe;
     }
     if ($disablerelated == '') {
         $disablerelated = $options->youtube_disablerelated;
     }
     // Conversione dei valori specificati direttamete nei parametri con
     // i valori usati per la memorizzazione dei valori di default
     if ($responsive == 'yes' or $responsive == 'y') {
         $responsive = '1';
     }
     if ($autoplay == 'yes' or $autoplay == 'y') {
         $autoplay = '1';
     }
     if ($loop == 'yes' or $loop == 'y') {
         $loop = '1';
     }
     if ($fullscreen == 'yes' or $fullscreen == 'y') {
         $fullscreen = '1';
     }
     if ($disablekeyboard == 'yes' or $disablekeyboard == 'y') {
         $disablekeyboard = '1';
     }
     if ($delayed == 'yes' or $delayed == 'y') {
         $delayed = '1';
     }
     if ($analytics == 'yes' or $analytics == 'y') {
         $analytics = '1';
     }
     if ($disableiframe == 'yes' or $disableiframe == 'y') {
         $disableiframe = '1';
     }
     if ($disablerelated == 'yes' or $disablerelated == 'y') {
         $disablerelated = '1';
     }
     if ($responsive == 'no' or $responsive == 'n') {
         $responsive = '0';
     }
     if ($autoplay == 'no' or $autoplay == 'n') {
         $autoplay = '0';
     }
     if ($loop == 'no' or $loop == 'n') {
         $loop = '0';
     }
     if ($fullscreen == 'no' or $fullscreen == 'n') {
         $fullscreen = '0';
     }
     if ($disablekeyboard == 'no' or $disablekeyboard == 'n') {
         $disablekeyboard = '0';
     }
     if ($delayed == 'no' or $delayed == 'n') {
         $delayed = '0';
     }
     if ($analytics == 'no' or $analytics == 'n') {
         $analytics = '0';
     }
     if ($disableiframe == 'no' or $disableiframe == 'n') {
         $disableiframe = '0';
     }
     if ($disablerelated == 'no' or $disablerelated == 'n') {
         $disablerelated = '0';
     }
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     $YESNO = array('1', '0');
     if (!in_array($responsive, $YESNO)) {
         $responsive = $options->youtube_responsive;
     }
     if (!in_array($autoplay, $YESNO)) {
         $autoplay = $options->youtube_autoplay;
     }
     if (!in_array($loop, $YESNO)) {
         $loop = $options->youtube_loop;
     }
     if (!in_array($fullscreen, $YESNO)) {
         $fullscreen = $options->youtube_fullscreen;
     }
     if (!in_array($disablekeyboard, $YESNO)) {
         $disablekeyboard = $options->youtube_disablekeyboard;
     }
     if (!in_array($delayed, $YESNO)) {
         $delayed = $options->youtube_delayed;
     }
     if (!in_array($analytics, $YESNO)) {
         $analytics = $options->youtube_analytics;
     }
     if (!in_array($disableiframe, $YESNO)) {
         $disableiframe = $options->youtube_disableiframe;
     }
     if (!in_array($disablerelated, $YESNO)) {
         $disablerelated = $options->youtube_disablerelated;
     }
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     if (!is_numeric($width)) {
         $width = $options->youtube_width;
     }
     if (!is_numeric($height)) {
         $height = $options->youtube_height;
     }
     if (!is_numeric($margintop)) {
         $margintop = $options->youtube_margin_top;
     }
     if (!is_numeric($marginbottom)) {
         $marginbottom = $options->youtube_margin_bottom;
     }
     if (!is_numeric($width)) {
         $width = '600';
     }
     if (!is_numeric($height)) {
         $height = '400';
     }
     if (!is_numeric($margintop)) {
         $margintop = '0';
     }
     if (!is_numeric($marginbottom)) {
         $marginbottom = '0';
     }
     if (!is_numeric($marginright) and strtolower(trim($marginright)) != 'auto') {
         $marginright = $options->youtube_margin_right;
     }
     if (!is_numeric($marginleft) and strtolower(trim($marginleft)) != 'auto') {
         $marginleft = $options->youtube_margin_left;
     }
     if (!is_numeric($marginright) and strtolower(trim($marginright)) != 'auto') {
         $marginright = '';
     }
     if (!is_numeric($marginleft) and strtolower(trim($marginleft)) != 'auto') {
         $marginleft = '';
     }
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     if (!in_array($marginunit, array('em', 'px'))) {
         $marginunit = $options->youtube_margin_unit;
     }
     if (!in_array($theme, array('dark', 'light'))) {
         $theme = $options->youtube_theme;
     }
     if (!in_array($marginunit, array('em', 'px'))) {
         $marginunit = 'em';
     }
     if (!in_array($theme, array('dark', 'light'))) {
         $theme = 'dark';
     }
     // Se ho impostato la modalità responsive la dimensione è sempre 100%
     // per occupare tutto lo spazio del contenitore genitore, stesso controllo per valore=0
     if ($responsive == '1' or $width == '0') {
         $CSS = 'width:100%;';
     } else {
         $CSS = 'width:' . $width . 'px;';
     }
     if ($responsive == '1') {
         $marginright = '0';
         $marginleft = '0';
     }
     if ($autoplay == '1') {
         $AUTOPLAY = '1';
     } else {
         $AUTOPLAY = '0';
     }
     if ($loop == '1') {
         $LOOP = '1';
     } else {
         $LOOP = '0';
     }
     if ($fullscreen == '1') {
         $FULLSCREEN = '1';
     } else {
         $FULLSCREEN = '0';
     }
     if ($disablekeyboard == '1') {
         $DISABLEKEYBOARD = '1';
     } else {
         $DISABLEKEYBOARD = '0';
     }
     // Creazione del codice CSS per la composizione dei margini
     // usando le opzioni specificate negli shortcode o nelle funzioni PHP
     $CSS .= $this->getModuleObject('SZGoogleModuleYoutube')->getStyleCSSfromMargins($margintop, $marginright, $marginbottom, $marginleft, $marginunit);
     // Se non ho trovato nessuna playlist ID durante l'analisi URL
     // preparo codice HTML per indicare errore di elaborazione funzione
     if ($id == '') {
         $HTML = '<div class="sz-youtube-main" style="' . $CSS . '">';
         $HTML .= '<div class="sz-youtube-warn" style="display:block;padding:1em 0;text-align:center;background-color:#e1e1e1;border:1px solid #b1b1b1;">';
         $HTML .= ucfirst(SZGoogleCommon::getTranslate('youtube playlist specified is not valid.'));
         $HTML .= '</div>';
         $HTML .= '</div>';
         return $HTML;
     }
     // Creazione identificativo univoco per riconoscere il codice embed
     // nel caso la funzioine venga richiamata più volte nella stessa pagina
     $unique = md5(uniqid(), false);
     $keyID = 'sz-youtube-' . $unique;
     // Creazione variabili per gestire le immagini di copertina e
     // la modalità di caricamento codice embed ritardato
     $ONCLICK = '';
     $CSSIMAGE_1 = 'display:block;';
     $CSSIMAGE_2 = 'display:block;';
     $COVERIMAGE = trim($cover);
     $COVERPLAYS = plugin_dir_url(SZ_PLUGIN_GOOGLE_MAIN) . 'frontend/files/images/youtube-play.png';
     // Creazione variabili per gestire le immagini di copertina e
     // la modalità di caricamento codice embed ritardato
     if (ctype_digit($COVERIMAGE)) {
         $COVERSRC = wp_get_attachment_image_src($COVERIMAGE, 'full');
         if (isset($COVERSRC[0])) {
             $COVERIMAGE = $COVERSRC[0];
         } else {
             $COVERIMAGE = 'local';
         }
     }
     if (strtolower($COVERIMAGE) == 'youtube' or strtolower($COVERIMAGE) == 'local') {
         $COVERIMAGE = plugin_dir_url(SZ_PLUGIN_GOOGLE_MAIN) . 'frontend/files/images/youtube-playlist.jpg';
     }
     // Creazione variabili per gestire le immagini di copertina e
     // la modalità di caricamento codice embed ritardato
     if ($delayed == '1') {
         $CSSIMAGE_1 .= 'cursor:pointer;';
         $CSSIMAGE_1 .= 'background-color:#f1f1f1;';
         $CSSIMAGE_1 .= 'background-image:url(' . $COVERIMAGE . ');';
         $CSSIMAGE_1 .= "background-repeat:no-repeat;";
         $CSSIMAGE_1 .= "background-position:center center;";
         $CSSIMAGE_1 .= "background-size:100% 100%;";
         $CSSIMAGE_2 .= 'background-image:url(' . $COVERPLAYS . ');';
         $CSSIMAGE_2 .= "background-repeat:no-repeat;";
         $CSSIMAGE_2 .= "background-position:center center;";
         $CSSIMAGE_2 .= "background-size:20% auto";
         $ONCLICK = ' onclick="javascript:onYouTubePlayerAPIReady_' . $unique . '();"';
         $AUTOPLAY = '1';
         $disableiframe = '1';
     }
     // SE ATTIVATA FUNZIONE PER STATISTICHE ANALYTICS DEVO FORZARE
     // ESECUZIONE DEL CODICE EMBED TRAMITE YOUTUBE API
     if ($analytics == '1') {
         $disableiframe = '1';
     }
     // Creazione variabile da usare per lo schema.org in caso di attivazione
     // opzione, vengono usate le specifiche di http://schema.org/VideoObject
     $EMBEDURL = 'https://www.youtube.com/embed/videoseries?list=' . $id;
     if ($disablerelated == '1') {
         $DISABLERELATED = '0';
     } else {
         $DISABLERELATED = '1';
     }
     // Creazione codice HTML con controllo inserimento schema.org, se il sistema
     // è abilitato vengono usate le specifiche di http://schema.org/VideoObject
     $HTML = '<div class="sz-youtube-main" style="' . $CSS . '">';
     // Creazione codice HTML per inserimento nella pagina, la tecnica usata
     // può essere la definizione di un IFRAME e la chiamata ad una funzione API
     $HTML .= '<div class="sz-youtube-play" style="' . $CSSIMAGE_1 . '"' . $ONCLICK . '>';
     if ($responsive == '1') {
         $HTML .= '<div class="sz-youtube-cont" ';
         $HTML .= 'style="';
         $HTML .= 'position:relative;';
         $HTML .= 'padding-bottom:56.25%;';
         $HTML .= 'height:0;';
         $HTML .= 'overflow:hidden;';
         $HTML .= $CSSIMAGE_2;
         $HTML .= '">';
     } else {
         $HTML .= '<div class="sz-youtube-cont" ';
         $HTML .= 'style="';
         $HTML .= 'position:relative;';
         $HTML .= 'height:' . $height . 'px;';
         $HTML .= $CSSIMAGE_2;
         $HTML .= '">';
     }
     // Creazione codice HTML per embed code, normalmente utilizzo IFRAME
     // ma se questo è stato disattivato specificatamente utilizzo javascript API
     if ($disableiframe == '1') {
         $HTML .= '<div class="sz-youtube-wrap" style="display:block;">';
         $HTML .= '<div class="sz-youtube-japi" id="' . $keyID . '" style="position:absolute;top:0;left:0;display:block;"></div>';
         $HTML .= '</div>';
         $object = $this->getModuleObject('SZGoogleModuleYoutube');
         $object->addYoutubeVideoAPI(array('unique' => $unique, 'keyID' => $keyID, 'playlist' => $id, 'autoplay' => $AUTOPLAY, 'loop' => $LOOP, 'fullscreen' => $FULLSCREEN, 'disablekeyboard' => $DISABLEKEYBOARD, 'theme' => $theme, 'cover' => $cover, 'delayed' => $delayed, 'analytics' => $analytics, 'disablerelated' => $DISABLERELATED));
         // Creazione codice HTML per embed code, normalmente utilizzo IFRAME
         // ma se questo è stato disattivato specificatamente utilizzo javascript API
     } else {
         $HTML .= '<div class="sz-youtube-wrap" id="' . $keyID . '" style="display:block;">';
         $HTML .= '<iframe ';
         $HTML .= 'src="' . $EMBEDURL;
         $HTML .= '&amp;wmode=opaque';
         $HTML .= '&amp;controls=1';
         $HTML .= '&amp;iv_load_policy=3';
         $HTML .= '&amp;autoplay=' . $AUTOPLAY;
         $HTML .= '&amp;loop=' . $LOOP;
         $HTML .= '&amp;fs=' . $FULLSCREEN;
         $HTML .= '&amp;disablekb=' . $DISABLEKEYBOARD;
         $HTML .= '&amp;rel=' . $DISABLERELATED;
         $HTML .= '&amp;theme=' . $theme;
         $HTML .= '" ';
         $HTML .= 'style="position:absolute;top:0;left:0;width:100%;height:100%;"';
         $HTML .= '>';
         $HTML .= '</iframe>';
         $HTML .= '</div>';
     }
     $HTML .= '</div>';
     $HTML .= '</div>';
     // Creazione blocco del titolo sotto il video youtube, la stringa
     // viene passata tramite il paramtero "title" dello shortcode.
     if ($title != '') {
         $HTML .= '<div class="sz-youtube-capt" ';
         $HTML .= 'style="background-color:#e8e8e8;padding:0.5em 1em;text-align:center;font-weight:bold;margin-top:5px;"';
         $HTML .= '>';
         $HTML .= $title;
         $HTML .= '</div>';
     }
     $HTML .= '</div>';
     // Return from the function with the whole string containing
     // the HTML code for inserting the code in the page
     return $HTML;
 }
 /**
  * Funzione per esecuzione codice youtube link con 
  * creazione codice HTML sia per shortcode che per widget
  *
  * @return string
  */
 function getYoutubeLinkCode($atts = array(), $content = null)
 {
     $options = $this->getOptions();
     // Estrazione dei valori specificati nello shortcode, i valori ritornati
     // sono contenuti nei nomi di variabili corrispondenti alla chiave
     if (!is_array($atts)) {
         $atts = array();
     }
     extract(shortcode_atts(array('channel' => '', 'subscription' => '', 'text' => '', 'action' => ''), $atts));
     // Elimino spazi aggiunti di troppo ed esegui la trasformazione in
     // stringa minuscolo per il controllo di valori speciali come "auto"
     $channel = trim($channel);
     $subscription = trim($subscription);
     $text = trim($text);
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     if ($channel == '') {
         $channel = $options['youtube_channel'];
     }
     if ($subscription == '') {
         $subscription = '1';
     }
     if ($text == '') {
         $text = SZGoogleCommon::getTranslate('channel youtube');
     }
     // Conversione dei valori specificati direttamete nei parametri con
     // i valori usati per la memorizzazione dei valori di default
     if ($subscription == 'yes' or $subscription == 'y') {
         $subscription = '1';
     }
     if ($subscription == 'no' or $subscription == 'n') {
         $subscription = '0';
     }
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     $YESNO = array('1', '0');
     if (!in_array($subscription, $YESNO)) {
         $subscription = '1';
     }
     // Verifico se canale è un nome o identificativo univoco
     // come ad esempio il canale wordpress italy+ UCJqiM61oRRvhTD5il2n56xg
     $channel_type = $this->youtubeCheckChannel($channel);
     if ($channel_type == 'ID') {
         $ytURL = 'http://www.youtube.com/channel/';
     } else {
         $ytURL = 'http://www.youtube.com/user/';
     }
     // Creazione codice HTML per embed code da inserire nella pagina wordpress
     if (empty($content)) {
         $HTML = '<a href="' . $ytURL . $channel . '?sub_confirmation=' . $subscription . '">';
         $HTML .= $text;
         $HTML .= '</a>';
     } else {
         $HTML = '<a href="' . $ytURL . $channel . '?sub_confirmation=' . $subscription . '">';
         $HTML .= $content;
         $HTML .= '</a>';
     }
     // Ritorno per la funzione con tutta la stringa contenente
     // il codice HTML per l'inserimento di un video youtube
     return $HTML;
 }
 /**
  * Definizione della funzione che viene normalmente richiamata
  * dagli hook presenti in add_action e add_filter di wordpress
  */
 function getMonitorCode($atts = array())
 {
     // Calcolo per opzioni di configurazione collegate al modulo
     // richiesto e specificate nel pannello di amministrazione
     $options = (object) $this->getModuleOptions('SZGoogleModuleAnalytics');
     // Estrazione dei valori specificati nello shortcode, i valori ritornati
     // sono contenuti nei nomi di variabili corrispondenti alla chiave
     if (!is_array($atts)) {
         $atts = array();
     }
     extract(shortcode_atts(array('ga_type' => $options->ga_type, 'ga_uacode' => $options->ga_uacode, 'ga_position' => $options->ga_position, 'ga_enable_front' => $options->ga_enable_front, 'ga_enable_admin' => $options->ga_enable_admin, 'ga_enable_administrator' => $options->ga_enable_administrator, 'ga_enable_logged' => $options->ga_enable_logged, 'ga_enable_subdomain' => $options->ga_enable_subdomain, 'ga_enable_multiple' => $options->ga_enable_multiple, 'ga_enable_advertiser' => $options->ga_enable_advertiser), $atts));
     // Elimino spazi aggiunti di troppo ed esegui la trasformazione in
     // stringa minuscolo per il controllo di valori speciali come "auto"
     $ga_uacode = trim($ga_uacode);
     $ga_type = strtolower(trim($ga_type));
     $ga_position = strtoupper(trim($ga_position));
     $ga_enable_front = strtolower(trim($ga_enable_front));
     $ga_enable_admin = strtolower(trim($ga_enable_admin));
     $ga_enable_administrator = strtolower(trim($ga_enable_administrator));
     $ga_enable_logged = strtolower(trim($ga_enable_logged));
     $ga_enable_subdomain = strtolower(trim($ga_enable_subdomain));
     $ga_enable_multiple = strtolower(trim($ga_enable_multiple));
     $ga_enable_advertiser = strtolower(trim($ga_enable_advertiser));
     // Conversione dei valori specificati direttamete nei parametri con
     // i valori usati per la memorizzazione dei valori di default
     if ($ga_enable_front == 'yes' or $ga_enable_front == 'y') {
         $ga_enable_front = '1';
     }
     if ($ga_enable_admin == 'yes' or $ga_enable_admin == 'y') {
         $ga_enable_admin = '1';
     }
     if ($ga_enable_administrator == 'yes' or $ga_enable_administrator == 'y') {
         $ga_enable_administrator = '1';
     }
     if ($ga_enable_logged == 'yes' or $ga_enable_logged == 'y') {
         $ga_enable_logged = '1';
     }
     if ($ga_enable_subdomain == 'yes' or $ga_enable_subdomain == 'y') {
         $ga_enable_subdomain = '1';
     }
     if ($ga_enable_multiple == 'yes' or $ga_enable_multiple == 'y') {
         $ga_enable_multiple = '1';
     }
     if ($ga_enable_advertiser == 'yes' or $ga_enable_advertiser == 'y') {
         $ga_enable_advertiser = '1';
     }
     if ($ga_enable_front == 'no' or $ga_enable_front == 'n') {
         $ga_enable_front = '1';
     }
     if ($ga_enable_admin == 'no' or $ga_enable_admin == 'n') {
         $ga_enable_admin = '1';
     }
     if ($ga_enable_administrator == 'no' or $ga_enable_administrator == 'n') {
         $ga_enable_administrator = '1';
     }
     if ($ga_enable_logged == 'no' or $ga_enable_logged == 'n') {
         $ga_enable_logged = '1';
     }
     if ($ga_enable_subdomain == 'no' or $ga_enable_subdomain == 'n') {
         $ga_enable_subdomain = '1';
     }
     if ($ga_enable_multiple == 'no' or $ga_enable_multiple == 'n') {
         $ga_enable_multiple = '1';
     }
     if ($ga_enable_advertiser == 'no' or $ga_enable_advertiser == 'n') {
         $ga_enable_advertiser = '1';
     }
     // Controllo se sono loggato come amministratore o utente registrato
     // e disattivo il caricamento del codice se le opzioni sono disattivate
     $useract = true;
     if (current_user_can('manage_options')) {
         if ($ga_enable_administrator == '0') {
             $useract = false;
         }
     } else {
         if (is_user_logged_in() and $ga_enable_logged == '0') {
             $useract = false;
         }
     }
     // Controllo se sono in backend o frontend e abilito l'esecuzione del codice
     // solo se le opzioni corrispondenti sono state attivate in configurazione
     if (is_admin() and $ga_enable_admin == '0') {
         $useract = false;
     }
     if (!is_admin() and $ga_enable_front == '0') {
         $useract = false;
     }
     // Se il codice non deve essere attivato in base alle opzioni passate
     // ritorno un valore di false e non elaboro la creazione del monitoraggio
     if (!$useract or strlen($ga_uacode) <= 0) {
         return false;
     }
     // Conversione dei valori specificati direttamete nei parametri con
     // i valori usati per la memorizzazione dei valori di default
     if ($ga_position == '') {
         $ga_position = 'H';
     }
     if ($ga_uacode == '') {
         $ga_uacode = $this->getGAId();
     }
     if (!in_array($ga_type, array('classic', 'universal'))) {
         $ga_type = 'classic';
     }
     // Creazione codice per i commenti di blocco nel caso
     // risultasse attiva la generazione del codice GA
     $HTML = '';
     if ($ga_position != 'F' and ($ga_type == 'universal' or $ga_type == 'classic')) {
         $HTML .= "\n";
         $HTML .= "<!-- GA tracking code with SZ-Google " . SZ_PLUGIN_GOOGLE_VERSION . " : activated mode " . strtoupper($ga_type) . "      -->\n";
         $HTML .= "<!-- ===================================================================== -->\n";
     }
     // Creazione codice di google analytics UNIVERSAL da inserire su pagina HTML
     // che può essere differente in base a google classic o universal analytics
     if ($ga_type == 'universal') {
         $HTML .= '<script>' . "\n";
         $HTML .= "  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){" . "\n";
         $HTML .= "  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o)," . "\n";
         $HTML .= "  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)" . "\n";
         $HTML .= "  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');" . "\n\n";
         $HTML .= "  ga('create', '" . trim($ga_uacode) . "', '" . trim(SZGoogleCommon::getCurrentDomain()) . "');" . "\n";
         $HTML .= "  ga('send', 'pageview');" . "\n";
         $HTML .= "</script>" . "\n";
     }
     // Creazione codice di google analytics CLASSIC da inserire su pagina HTML
     // che può essere differente in base a google classic o universal analytics
     if ($ga_type == 'classic') {
         $HTML .= '<script type="text/javascript">//<![CDATA[' . "\n";
         $HTML .= "var _gaq = _gaq || [];" . "\n";
         $HTML .= "_gaq.push(['_setAccount','" . $ga_uacode . "']);" . "\n";
         // Se opzione subdomains o multiple risulta attivata aggiungo una nuova riga
         // di codice contenente il _setDomainName del domino corrente visualizzato
         if ($ga_enable_subdomain == '1' or $ga_enable_multiple == '1') {
             $HTML .= "_gaq.push(['_setDomainName','" . trim(SZGoogleCommon::getCurrentDomain()) . "']);" . "\n";
         }
         // Se opzione multiple risulta attivata aggiungo una nuova riga con il codice
         // javascript di google analytics con l'impostazione di _setAllowLinker
         if ($ga_enable_multiple == '1') {
             $HTML .= "_gaq.push(['_setAllowLinker',true]);" . "\n";
         }
         $HTML .= "_gaq.push(['_trackPageview']);" . "\n";
         $HTML .= "(function () {" . "\n";
         $HTML .= "var ga = document.createElement('script');" . "\n";
         $HTML .= "ga.type = 'text/javascript';" . "\n";
         $HTML .= "ga.async = true;" . "\n";
         if ($ga_enable_advertiser == '1') {
             $HTML .= "ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';" . "\n";
         } else {
             $HTML .= "ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';" . "\n";
         }
         $HTML .= "var s = document.getElementsByTagName('script')[0];" . "\n";
         $HTML .= "s.parentNode.insertBefore(ga, s);" . "\n";
         $HTML .= "})();" . "\n";
         $HTML .= "//]]></script>" . "\n";
     }
     // Creazione codice per i commenti di blocco nel caso
     // risultasse attiva la generazione del codice GA
     if ($ga_position != 'F' and ($ga_type == 'universal' or $ga_type == 'classic')) {
         $HTML .= "<!-- ===================================================================== -->\n\n";
     }
     return $HTML;
 }
 function callback_calendar_o_timezone()
 {
     $values = SZGoogleCommon::getTimeZone();
     $this->moduleCommonFormSelect('sz_google_options_calendar', 'calendar_o_timezone', $values, 'medium', '');
     $this->moduleCommonFormDescription(__('this field specifies the time zone to be used by default by the calendar that will be inserted into the page wordpress. If you do not specify any value, google will automatically calculate the time zone based on its configuration.', 'sz-google'));
 }
 function action()
 {
     // Execution flush rules for rewrite custom,
     // If the plugin adds new options to rewrite
     SZGoogleCommon::rewriteFlushRules();
 }
 /**
  * Creazione codice HTML per il componente richiamato che
  * deve essere usato in comune sia per widget che shortcode
  *
  * @return string
  */
 function getHTMLCode($atts = array(), $content = null)
 {
     if (!is_array($atts)) {
         $atts = array();
     }
     // Estrazione dei valori specificati nello shortcode, i valori ritornati
     // sono contenuti nei nomi di variabili corrispondenti alla chiave
     extract(shortcode_atts(array('calendars' => '', 'title' => '', 'mode' => '', 'weekstart' => '', 'language' => '', 'timezone' => '', 'width' => '', 'height' => '', 'showtitle' => '', 'shownavs' => '', 'showdate' => '', 'showprint' => '', 'showtabs' => '', 'showcalendars' => '', 'showtimezone' => '', 'action' => ''), $atts));
     // Caricamento opzioni per le variabili di configurazione che
     // contengono i valori di default per shortcode e widgets
     $options = (object) $this->getModuleOptions('SZGoogleModuleCalendar');
     // Elimino spazi aggiunti di troppo ed eseguo la trasformazione in
     // stringa minuscolo per il controllo di valori speciali come "auto"
     $calendars = trim($calendars);
     $title = trim($title);
     $action = trim($action);
     $language = trim($language);
     $timezone = trim($timezone);
     $mode = strtoupper(trim($mode));
     $weekstart = strtolower(trim($weekstart));
     $width = strtolower(trim($width));
     $height = strtolower(trim($height));
     $showtitle = strtolower(trim($showtitle));
     $shownavs = strtolower(trim($shownavs));
     $showdate = strtolower(trim($showdate));
     $showprint = strtolower(trim($showprint));
     $showtabs = strtolower(trim($showtabs));
     $showcalendars = strtolower(trim($showcalendars));
     $showtimezone = strtolower(trim($showtimezone));
     // Conversione dei valori specificati direttamete nei parametri con
     // i valori usati per la memorizzazione dei valori di default
     if ($showtitle == 'yes' or $showtitle == 'y') {
         $showtitle = '1';
     }
     if ($shownavs == 'yes' or $shownavs == 'y') {
         $shownavs = '1';
     }
     if ($showdate == 'yes' or $showdate == 'y') {
         $showdate = '1';
     }
     if ($showprint == 'yes' or $showprint == 'y') {
         $showprint = '1';
     }
     if ($showtabs == 'yes' or $showtabs == 'y') {
         $showtabs = '1';
     }
     if ($showcalendars == 'yes' or $showcalendars == 'y') {
         $showcalendars = '1';
     }
     if ($showtimezone == 'yes' or $showtimezone == 'y') {
         $showtimezone = '1';
     }
     if ($showtitle == 'no' or $showtitle == 'n') {
         $showtitle = '0';
     }
     if ($shownavs == 'no' or $shownavs == 'n') {
         $shownavs = '0';
     }
     if ($showdate == 'no' or $showdate == 'n') {
         $showdate = '0';
     }
     if ($showprint == 'no' or $showprint == 'n') {
         $showprint = '0';
     }
     if ($showtabs == 'no' or $showtabs == 'n') {
         $showtabs = '0';
     }
     if ($showcalendars == 'no' or $showcalendars == 'n') {
         $showcalendars = '0';
     }
     if ($showtimezone == 'no' or $showtimezone == 'n') {
         $showtimezone = '0';
     }
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     $YESNO = array('1', '0');
     if ($action == 'widget') {
         if ($calendars == '') {
             $calendars = $options->calendar_w_calendars;
         }
         if ($title == '') {
             $title = $options->calendar_w_title;
         }
         if ($width == '') {
             $width = $options->calendar_w_width;
         }
         if ($height == '') {
             $height = $options->calendar_w_height;
         }
         if (!in_array($showtitle, $YESNO)) {
             $showtitle = $options->calendar_w_show_title;
         }
         if (!in_array($shownavs, $YESNO)) {
             $shownavs = $options->calendar_w_show_navs;
         }
         if (!in_array($showdate, $YESNO)) {
             $showdate = $options->calendar_w_show_date;
         }
         if (!in_array($showprint, $YESNO)) {
             $showprint = $options->calendar_w_show_print;
         }
         if (!in_array($showtabs, $YESNO)) {
             $showtabs = $options->calendar_w_show_tabs;
         }
         if (!in_array($showcalendars, $YESNO)) {
             $showcalendars = $options->calendar_w_show_calendars;
         }
         if (!in_array($showtimezone, $YESNO)) {
             $showtimezone = $options->calendar_w_show_timezone;
         }
     } else {
         if ($calendars == '') {
             $calendars = $options->calendar_s_calendars;
         }
         if ($title == '') {
             $title = $options->calendar_s_title;
         }
         if ($width == '') {
             $width = $options->calendar_s_width;
         }
         if ($height == '') {
             $height = $options->calendar_s_height;
         }
         if (!in_array($showtitle, $YESNO)) {
             $showtitle = $options->calendar_s_show_title;
         }
         if (!in_array($shownavs, $YESNO)) {
             $shownavs = $options->calendar_s_show_navs;
         }
         if (!in_array($showdate, $YESNO)) {
             $showdate = $options->calendar_s_show_date;
         }
         if (!in_array($showprint, $YESNO)) {
             $showprint = $options->calendar_s_show_print;
         }
         if (!in_array($showtabs, $YESNO)) {
             $showtabs = $options->calendar_s_show_tabs;
         }
         if (!in_array($showcalendars, $YESNO)) {
             $showcalendars = $options->calendar_s_show_calendars;
         }
         if (!in_array($showtimezone, $YESNO)) {
             $showtimezone = $options->calendar_s_show_timezone;
         }
     }
     // Controllo la variabile titolo se specificata nella opzione
     // in caso contrario assegno il valore speciale con traduzione in lingua
     if ($calendars == '') {
         $calendars = $options->calendar_o_calendars;
     }
     if ($title == '') {
         $title = $options->calendar_o_title;
     }
     if ($mode == '') {
         $mode = $options->calendar_o_mode;
     }
     if ($weekstart == '') {
         $weekstart = $options->calendar_o_weekstart;
     }
     if ($language == '') {
         $language = $options->calendar_o_language;
     }
     if ($timezone == '') {
         $timezone = $options->calendar_o_timezone;
     }
     if (!in_array($weekstart, array('1', '2', '7'))) {
         $weekstart = '1';
     }
     // Calcolo la variabile della lingua di traduzione da applicare al codice
     // embed del calendario di google. Valore speciale 99 per quella wordpress.
     if (!array_key_exists($language, SZGoogleCommon::getLanguages())) {
         $language = $options->calendar_o_language;
     }
     if (!array_key_exists($language, SZGoogleCommon::getLanguages())) {
         $language = '99';
     }
     if ($language == '99') {
         $language = substr(get_bloginfo('language'), 0, 2);
     }
     if (!array_key_exists($timezone, SZGoogleCommon::getTimeZone())) {
         $timezone = $options->calendar_o_timezone;
     }
     if (!array_key_exists($timezone, SZGoogleCommon::getTimeZone())) {
         $timezone = 'none';
     }
     // Controllo i valori passati in array che specificano la dimensione del widget
     // in caso contrario imposto il valore su quello specificato nelle opzioni
     if (!ctype_digit($width) and $width != 'auto') {
         $width = 'auto';
     }
     if (!ctype_digit($height) and $height != 'auto') {
         $height = 'auto';
     }
     // Controllo la dimensione del widget e controllo formale dei valori numerici
     // se trovo qualche incongruenza applico i valori di default prestabiliti
     if ($width == '') {
         $width = "100%";
     }
     if ($width == 'auto') {
         $width = "100%";
     }
     if ($height == '') {
         $height = '400';
     }
     if ($height == 'auto') {
         $height = '400';
     }
     // Creazione array contenente le variabili che devono essere usate
     // nella stringa URL di riferimento al codice embed su iframe
     $URLarray = array();
     $URLarray[] = "hl=" . urlencode($language);
     $URLarray[] = "height=" . urlencode($height);
     if ($title != '') {
         $URLarray[] = 'title=' . urlencode($title);
     }
     if ($weekstart != '') {
         $URLarray[] = 'wkst=' . urlencode($weekstart);
     }
     if ($timezone != '') {
         $URLarray[] = 'ctz=' . urlencode($timezone);
     }
     if ($mode == 'AGENDA') {
         $URLarray[] = "mode=" . urlencode($mode);
     }
     if ($mode == 'WEEK') {
         $URLarray[] = "mode=" . urlencode($mode);
     }
     if ($showtitle != '1') {
         $URLarray[] = "showTitle=0";
     }
     if ($shownavs != '1') {
         $URLarray[] = "showNav=0";
     }
     if ($showdate != '1') {
         $URLarray[] = "showDate=0";
     }
     if ($showprint != '1') {
         $URLarray[] = "showPrint=0";
     }
     if ($showtabs != '1') {
         $URLarray[] = "showTabs=0";
     }
     if ($showcalendars != '1') {
         $URLarray[] = "showCalendars=0";
     }
     if ($showtimezone != '1') {
         $URLarray[] = "showTz=0";
     }
     // Creazione array contenente i nomi dei calendari da visualizzare.
     // I nomi devono essere divisi da una virgola nella variabile specifica.
     $CALarray = explode(',', $calendars);
     foreach ($CALarray as $key => $value) {
         if (trim($value) != '') {
             $URLarray[] = 'src=' . urlencode(trim($value));
         }
     }
     // Creazione codice HTML per embed code da inserire nella pagina wordpress
     // prima praparo il codice del bottone singolo e poi chiamo funzione di wrapping
     $HTML = '<script type="text/javascript">';
     $HTML .= "var h='<'+'";
     $HTML .= 'iframe src="https://www.google.com/calendar/embed?' . implode("&amp;", $URLarray) . '" ';
     $HTML .= 'style="border-width:0" ';
     $HTML .= 'width="' . $width . '" ';
     $HTML .= 'height="' . $height . '" ';
     $HTML .= 'frameborder="0" scrolling="no"';
     $HTML .= "></'+'iframe'+'>';";
     $HTML .= "document.write(h);";
     $HTML .= '</script>';
     // Ritorno per la funzione con tutta la stringa contenente
     // il codice HTML per l'inserimento del codice nella pagina
     return $HTML;
 }
 function action()
 {
     // Esecuzione flush rules per regole di rewrite personalizzate nel
     // caso in cui il plugin aggiunga delle nuove opzioni di rewrite.
     SZGoogleCommon::rewriteFlushRules();
 }
 /**
  * Creating HTML code for the component called to
  * be used in common for both widgets and shortcode
  */
 function getHTMLCode($atts = array(), $content = null)
 {
     if (!is_array($atts)) {
         $atts = array();
     }
     // Extraction of the values ​​specified in shortcode, returned values
     // ​​are contained in the variable names corresponding to the key
     extract(shortcode_atts(array('channel' => '', 'subscription' => '', 'text' => '', 'image' => '', 'newtab' => ''), $atts));
     // Loading options for the configuration variables
     // containing the default values ​​for shortcodes and widgets
     $options = (object) $this->getModuleOptions('SZGoogleModuleYoutube');
     // I delete spaces added and execute the transformation in string
     // lowercase for the control of special values ​​such as "auto"
     $channel = trim($channel);
     $subscription = trim($subscription);
     $text = trim($text);
     $image = trim($image);
     $newtab = trim($newtab);
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     if ($channel == '') {
         $channel = $options->youtube_channel;
     }
     if ($subscription == '') {
         $subscription = '1';
     }
     if ($newtab == '') {
         $newtab = '0';
     }
     if ($text == '') {
         $text = SZGoogleCommon::getTranslate('channel youtube');
     }
     // Conversione dei valori specificati direttamete nei parametri con
     // i valori usati per la memorizzazione dei valori di default
     if ($newtab == 'yes' or $newtab == 'y') {
         $newtab = '1';
     }
     if ($newtab == 'no' or $newtab == 'n') {
         $newtab = '0';
     }
     if ($subscription == 'yes' or $subscription == 'y') {
         $subscription = '1';
     }
     if ($subscription == 'no' or $subscription == 'n') {
         $subscription = '0';
     }
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     $YESNO = array('1', '0');
     if (!in_array($newtab, $YESNO)) {
         $newtab = '1';
     }
     if (!in_array($subscription, $YESNO)) {
         $subscription = '1';
     }
     // Verifico se canale è un nome o identificativo univoco
     // come ad esempio il canale wordpress italy+ UCJqiM61oRRvhTD5il2n56xg
     $type = $this->getModuleObject('SZGoogleModuleYoutube')->youtubeCheckChannel($channel);
     if ($type == 'ID') {
         $ytURL = 'http://www.youtube.com/channel/';
     } else {
         $ytURL = 'http://www.youtube.com/user/';
     }
     // Creazione HREF per il canale youtube con il controllo
     // per aggiungere il parametro che riguarda la sottoscrizione
     if ($newtab == '0') {
         $NEWTAB = '';
     } else {
         $NEWTAB = ' target="_blank"';
     }
     if ($subscription == '0') {
         $HREF = '<a href="' . $ytURL . $channel . '"' . $NEWTAB . '>';
     } else {
         $HREF = '<a href="' . $ytURL . $channel . '?sub_confirmation=' . $subscription . '"' . $NEWTAB . '>';
     }
     // Se viene indicata un'immagine vado sostituire la stringa text
     // inmaniera da dare priorità all'immagine rispetto al testo
     if ($image != '') {
         $text = '<img src="' . $image . '" alt=""/>';
     }
     // Creazione codice HTML per embed code da inserire nella pagina wordpress
     // Se esiste il contenuto tra lo shortcode o prendo i valori delle opzioni
     if (empty($content)) {
         $HTML = $HREF . $text . '</a>';
     } else {
         $HTML = $HREF . $content . '</a>';
     }
     // Return from the function with the whole string containing
     // the HTML code for inserting the code in the page
     return $HTML;
 }
echo $ID_timezone;
?>
"><?php 
echo ucfirst(__('timezone', 'szgoogleadmin'));
?>
:</label></td>
	<td colspan="2" class="sz-cell-vals">
		<select class="widefat" id="<?php 
echo $ID_timezone;
?>
" name="<?php 
echo $NAME_timezone;
?>
">
<?php 
foreach (SZGoogleCommon::getTimeZone() as $key => $value) {
    ?>
			<option value="<?php 
    echo $key;
    ?>
" <?php 
    echo selected($key, $VALUE_timezone);
    ?>
><?php 
    echo $value;
    ?>
</option>
<?php 
}
?>
		</select>
 function get_translate_language()
 {
     $values = SZGoogleCommon::getLanguages();
     $this->moduleCommonFormSelect('sz_google_options_translate', 'translate_language', $values, 'medium', '');
     $this->moduleCommonFormDescription(__('specify the language associated with your website, if you do not specify any value will be called get_bloginfo(\'language\') and set the same language related to the theme of wordpress. Supported languages ​​http://translate.google.com/about/.', 'szgoogleadmin'));
 }
Example #17
0
 /**
  * Funzione per esecuzione codice google+ comments con 
  * creazione codice HTML sia per shortcode che per widget
  *
  * @return string
  */
 function getPlusCommentsCode($atts = array(), $content = null)
 {
     if (!is_array($atts)) {
         $atts = array();
     }
     // Estrazione dei valori specificati nello shortcode, i valori ritornati
     // sono contenuti nei nomi di variabili corrispondenti alla chiave
     extract(shortcode_atts(array('url' => '', 'id' => '', 'width' => '', 'align' => '', 'title' => '', 'class0' => '', 'class1' => '', 'class2' => '', 'element' => '', 'action' => ''), $atts));
     // Elimino spazi aggiunti di troppo ed esegui la trasformazione in
     // stringa minuscolo per il controllo di valori speciali come "auto"
     $options = $this->getOptions();
     $uniqueID = 'sz-google-comments-' . md5(uniqid(), false);
     $url = trim($url);
     $title = trim($title);
     $class0 = trim($class0);
     $class1 = trim($class1);
     $class2 = trim($class2);
     $element = trim($element);
     $width = strtolower(trim($width));
     $align = strtolower(trim($align));
     // Controllo opzione per dimensione fissa da applicare se esiste
     // un valore specificato e il parametro width non è stato specificato.
     if (!is_numeric($width) and $width != 'auto') {
         $width = '';
     }
     if ($width == '') {
         $width = $options['plus_comments_fixed_size'];
     }
     if ($width == '') {
         $width = 'auto';
     }
     if (!is_numeric($width) and $width != 'auto') {
         $width = '';
     }
     // Controllo opzione per dimensione fissa da applicare se esiste
     // un valore specificato e il parametro width non è stato specificato.
     if ($width == '') {
         $width = "'+w+'";
     }
     if ($width == 'auto') {
         $width = "'+w+'";
     }
     // Se non specifico un URL fisso imposto il permalink attuale
     if ($url == '') {
         $url = get_permalink();
     }
     // Elimino dal path i riferimenti aggiunti ai link di navigazione e
     // riporto il link originale di google plus, senza /u/0/b etc etc
     $url = $this->getCanonicalURL($url);
     // Controllo il valore del titolo per i commenti di google plus
     // ignoro il parametro se il componente appartiene ad un widget
     if ($action == 'template') {
         if (empty($title)) {
             $title = trim($options['plus_comments_title']);
         }
         if (empty($title)) {
             $title = '<h3>{title}</h3>';
         }
         $title = str_ireplace('{title}', ucfirst(SZGoogleCommon::getTranslate('leave a Reply')), $title);
     }
     // Controllo i valori delle classi eventuali da aggiungere ai wrapper
     // del codice HTML generato e controllo eventuale ID di divisione
     if (!empty($id)) {
         $id = 'id="' . $id . '" ';
     }
     if (!empty($class0)) {
         $class0 = ' ' . $class0;
     }
     if (!empty($class1)) {
         $class1 = ' ' . $class1;
     }
     if (!empty($class2)) {
         $class2 = ' ' . $class2;
     }
     // Creazione codice HTML per embed code da inserire nella pagina wordpress
     // Questo codice deve essere usato sia dallo shortcode, dal widget e dalla funzione
     $HTML = '<div ' . $id . 'class="sz-google-comments' . $class0 . $class1 . '">';
     if (!empty($title)) {
         $HTML .= $title;
     }
     $HTML .= '<div class="sz-google-comments-wrap' . $class2 . '">';
     $HTML .= '<div class="sz-google-comments-iframe" id="' . $uniqueID . '" style="display:block;';
     if ($align == 'left') {
         $HTML .= 'text-align:left;';
     }
     if ($align == 'center') {
         $HTML .= 'text-align:center;';
     }
     if ($align == 'right') {
         $HTML .= 'text-align:right;';
     }
     $HTML .= '">';
     // Cambio identificativo del componente HTML si cui bisogna
     // calcolare la dimensione se viene specificato "element"
     if ($element != '') {
         $uniqueID = $element;
     }
     // Codice javascript per inserire il codice HTML che
     // identifica il contenitore dei commenti di google plus
     $HTML .= '<script type="text/javascript">';
     $HTML .= "var w=document.getElementById('" . $uniqueID . "').offsetWidth;";
     $HTML .= "var h='<'+'";
     $HTML .= 'div class="g-comments"';
     $HTML .= ' data-href="' . $url . '"';
     $HTML .= ' data-width="' . $width . '"';
     $HTML .= ' data-height="50"';
     $HTML .= ' data-first_party_property="BLOGGER"';
     $HTML .= ' data-view_type="FILTERED_POSTMOD"';
     $HTML .= "></'+'div'+'>';";
     $HTML .= "document.write(h);";
     $HTML .= '</script>';
     $HTML .= '</div>';
     $HTML .= '</div>';
     $HTML .= '</div>';
     // Aggiunta del codice javascript per il rendering dei widget, questo codice
     // viene aggiungo anche dalla sidebar però viene inserito una sola volta
     $this->addCodeJavascriptFooter();
     // Ritorno per la funzione con tutta la stringa contenente
     // il codice HTML per l'inserimento del codice nella pagina
     return $HTML;
 }
 /**
  * Creazione codice HTML per il componente richiamato che
  * deve essere usato in comune sia per widget che shortcode
  *
  * @return string
  */
 function getHTMLCode($atts = array(), $content = null)
 {
     if (!is_array($atts)) {
         $atts = array();
     }
     // Estrazione dei valori specificati nello shortcode, i valori ritornati
     // sono contenuti nei nomi di variabili corrispondenti alla chiave
     extract(shortcode_atts(array('url' => '', 'responsive' => '', 'width' => '', 'height' => '', 'margintop' => '', 'marginright' => '', 'marginbottom' => '', 'marginleft' => '', 'marginunit' => '', 'autoplay' => '', 'loop' => '', 'fullscreen' => '', 'disablekeyboard' => '', 'theme' => '', 'cover' => '', 'delayed' => '', 'title' => '', 'disableiframe' => '', 'analytics' => '', 'start' => '', 'end' => '', 'schemaorg' => '', 'name' => '', 'description' => '', 'duration' => '', 'disablerelated' => '', 'action' => ''), $atts));
     // Caricamento opzioni per le variabili di configurazione che
     // contengono i valori di default per shortcode e widgets
     $options = (object) $this->getModuleOptions('SZGoogleModuleYoutube');
     // Elimino spazi aggiunti di troppo ed esegui la trasformazione in
     // stringa minuscolo per il controllo di valori speciali come "auto"
     $url = trim($url);
     $title = trim($title);
     $cover = trim($cover);
     $name = trim($name);
     $description = trim($description);
     $duration = trim($duration);
     $responsive = strtolower(trim($responsive));
     $margintop = strtolower(trim($margintop));
     $marginright = strtolower(trim($marginright));
     $marginbottom = strtolower(trim($marginbottom));
     $marginleft = strtolower(trim($marginleft));
     $marginunit = strtolower(trim($marginunit));
     $autoplay = strtolower(trim($autoplay));
     $loop = strtolower(trim($loop));
     $fullscreen = strtolower(trim($fullscreen));
     $disablekeyboard = strtolower(trim($disablekeyboard));
     $theme = strtolower(trim($theme));
     $disableiframe = strtolower(trim($disableiframe));
     $analytics = strtolower(trim($analytics));
     $delayed = strtolower(trim($delayed));
     $start = strtolower(trim($start));
     $end = strtolower(trim($end));
     $schemaorg = strtolower(trim($schemaorg));
     $disablerelated = strtolower(trim($disablerelated));
     // Controllo le caratteristiche del link per creare URL del
     // sorgente iframe da utilizzare nel codice embed e cambio schema se necessario
     $frame = false;
     $vidID = false;
     $links = html_entity_decode($url);
     $datas = parse_url($links);
     // Controllo se il parsing URL contiene elementi necessari
     // Controllo se il link riporta uno schema conosciuto
     if (isset($datas['scheme']) and isset($datas['host'])) {
         if ($datas['scheme'] == 'http' or $datas['scheme'] == 'https') {
             // Se host contiene il nome classico allora il codice del video si trova
             // su variabile (v) specificata su stringa URL e quindi eseguo il parsing
             if ($datas['host'] == 'www.youtube.com') {
                 parse_str(parse_url($links, PHP_URL_QUERY), $argom);
                 if (isset($argom['v'])) {
                     $vidID = trim($argom['v']);
                 }
             }
             // Se host è con codice short prendo le 11 cifre significative che
             // contengono il codice univoco del video youtube
             if ($datas['host'] == 'youtu.be') {
                 if (strlen($paths) >= 11) {
                     $vidID = substr($paths, 1, 11);
                 }
             }
             // Se ho indicato di usare sempre https forzo il protocollo URL
             // anche se su stringa originale viene specificato un valore diverso
             if ($options->youtube_force_ssl == '1') {
                 $datas['scheme'] = 'https';
             }
         }
     }
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     if ($responsive == '') {
         $responsive = $options->youtube_responsive;
     }
     if ($width == '') {
         $width = $options->youtube_width;
     }
     if ($height == '') {
         $height = $options->youtube_height;
     }
     if ($margintop == '') {
         $margintop = $options->youtube_margin_top;
     }
     if ($marginright == '') {
         $marginright = $options->youtube_margin_right;
     }
     if ($marginbottom == '') {
         $marginbottom = $options->youtube_margin_bottom;
     }
     if ($marginleft == '') {
         $marginleft = $options->youtube_margin_left;
     }
     if ($marginunit == '') {
         $marginunit = $options->youtube_margin_unit;
     }
     if ($autoplay == '') {
         $autoplay = $options->youtube_autoplay;
     }
     if ($loop == '') {
         $loop = $options->youtube_loop;
     }
     if ($fullscreen == '') {
         $fullscreen = $options->youtube_fullscreen;
     }
     if ($disablekeyboard == '') {
         $disablekeyboard = $options->youtube_disablekeyboard;
     }
     if ($theme == '') {
         $theme = $options->youtube_theme;
     }
     if ($cover == '') {
         $cover = $options->youtube_cover;
     }
     if ($disableiframe == '') {
         $disableiframe = $options->youtube_disableiframe;
     }
     if ($analytics == '') {
         $analytics = $options->youtube_analytics;
     }
     if ($delayed == '') {
         $delayed = $options->youtube_delayed;
     }
     if ($schemaorg == '') {
         $schemaorg = $options->youtube_schemaorg;
     }
     if ($disablerelated == '') {
         $disablerelated = $options->youtube_disablerelated;
     }
     // Conversione dei valori specificati direttamete nei parametri con
     // i valori usati per la memorizzazione dei valori di default
     if ($responsive == 'yes' or $responsive == 'y') {
         $responsive = '1';
     }
     if ($autoplay == 'yes' or $autoplay == 'y') {
         $autoplay = '1';
     }
     if ($loop == 'yes' or $loop == 'y') {
         $loop = '1';
     }
     if ($fullscreen == 'yes' or $fullscreen == 'y') {
         $fullscreen = '1';
     }
     if ($disablekeyboard == 'yes' or $disablekeyboard == 'y') {
         $disablekeyboard = '1';
     }
     if ($disableiframe == 'yes' or $disableiframe == 'y') {
         $disableiframe = '1';
     }
     if ($analytics == 'yes' or $analytics == 'y') {
         $analytics = '1';
     }
     if ($delayed == 'yes' or $delayed == 'y') {
         $delayed = '1';
     }
     if ($schemaorg == 'yes' or $schemaorg == 'y') {
         $schemaorg = '1';
     }
     if ($disablerelated == 'yes' or $disablerelated == 'y') {
         $disablerelated = '1';
     }
     if ($responsive == 'no' or $responsive == 'n') {
         $responsive = '0';
     }
     if ($autoplay == 'no' or $autoplay == 'n') {
         $autoplay = '0';
     }
     if ($loop == 'no' or $loop == 'n') {
         $loop = '0';
     }
     if ($fullscreen == 'no' or $fullscreen == 'n') {
         $fullscreen = '0';
     }
     if ($disablekeyboard == 'no' or $disablekeyboard == 'n') {
         $disablekeyboard = '0';
     }
     if ($disableiframe == 'no' or $disableiframe == 'n') {
         $disableiframe = '0';
     }
     if ($analytics == 'no' or $analytics == 'n') {
         $analytics = '0';
     }
     if ($delayed == 'no' or $delayed == 'n') {
         $delayed = '0';
     }
     if ($schemaorg == 'no' or $schemaorg == 'n') {
         $schemaorg = '0';
     }
     if ($disablerelated == 'no' or $disablerelated == 'n') {
         $disablerelated = '0';
     }
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     $YESNO = array('1', '0');
     if (!in_array($responsive, $YESNO)) {
         $responsive = $options->youtube_responsive;
     }
     if (!in_array($autoplay, $YESNO)) {
         $autoplay = $options->youtube_autoplay;
     }
     if (!in_array($loop, $YESNO)) {
         $loop = $options->youtube_loop;
     }
     if (!in_array($fullscreen, $YESNO)) {
         $fullscreen = $options->youtube_fullscreen;
     }
     if (!in_array($disablekeyboard, $YESNO)) {
         $disablekeyboard = $options->youtube_disablekeyboard;
     }
     if (!in_array($disableiframe, $YESNO)) {
         $disableiframe = $options->youtube_disableiframe;
     }
     if (!in_array($analytics, $YESNO)) {
         $analytics = $options->youtube_analytics;
     }
     if (!in_array($delayed, $YESNO)) {
         $delayed = $options->youtube_delayed;
     }
     if (!in_array($schemaorg, $YESNO)) {
         $schemaorg = $options->youtube_schemaorg;
     }
     if (!in_array($disablerelated, $YESNO)) {
         $disablerelated = $options->youtube_disablerelated;
     }
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     if (!is_numeric($width)) {
         $width = $options->youtube_width;
     }
     if (!is_numeric($height)) {
         $height = $options->youtube_height;
     }
     if (!is_numeric($margintop)) {
         $margintop = $options->youtube_margin_top;
     }
     if (!is_numeric($marginbottom)) {
         $marginbottom = $options->youtube_margin_bottom;
     }
     if (!is_numeric($width)) {
         $width = '600';
     }
     if (!is_numeric($height)) {
         $height = '400';
     }
     if (!is_numeric($margintop)) {
         $margintop = '0';
     }
     if (!is_numeric($marginbottom)) {
         $marginbottom = '0';
     }
     if (!is_numeric($marginright) and strtolower(trim($marginright)) != 'auto') {
         $marginright = $options->youtube_margin_right;
     }
     if (!is_numeric($marginleft) and strtolower(trim($marginleft)) != 'auto') {
         $marginleft = $options->youtube_margin_left;
     }
     if (!is_numeric($marginright) and strtolower(trim($marginright)) != 'auto') {
         $marginright = '';
     }
     if (!is_numeric($marginleft) and strtolower(trim($marginleft)) != 'auto') {
         $marginleft = '';
     }
     // Se non sono riuscito ad assegnare nessun valore con le istruzioni
     // precedenti metto dei default assoluti che possono essere cambiati
     if (!in_array($marginunit, array('em', 'px'))) {
         $marginunit = $options->youtube_margin_unit;
     }
     if (!in_array($theme, array('dark', 'light'))) {
         $theme = $options->youtube_theme;
     }
     if (!in_array($marginunit, array('em', 'px'))) {
         $marginunit = 'em';
     }
     if (!in_array($theme, array('dark', 'light'))) {
         $theme = 'dark';
     }
     if (!ctype_digit($start)) {
         $start = '';
     }
     if (!ctype_digit($end)) {
         $end = '';
     }
     // Se ho impostato la modalità responsive la dimensione è sempre 100%
     // per occupare tutto lo spazio del contenitore genitore, stesso controllo per valore=0
     if ($responsive == '1' or $width == '0') {
         $CSS = 'width:100%;';
     } else {
         $CSS = 'width:' . $width . 'px;';
     }
     if ($responsive == '1') {
         $marginright = '0';
         $marginleft = '0';
     }
     if ($autoplay == '1') {
         $AUTOPLAY = '1';
     } else {
         $AUTOPLAY = '0';
     }
     if ($loop == '1') {
         $LOOP = '1';
     } else {
         $LOOP = '0';
     }
     if ($fullscreen == '1') {
         $FULLSCREEN = '1';
     } else {
         $FULLSCREEN = '0';
     }
     if ($disablekeyboard == '1') {
         $DISABLEKEYBOARD = '1';
     } else {
         $DISABLEKEYBOARD = '0';
     }
     // Creazione del codice CSS per la composizione dei margini
     // usando le opzioni specificate negli shortcode o nelle funzioni PHP
     $CSS .= $this->getModuleObject('SZGoogleModuleYoutube')->getStyleCSSfromMargins($margintop, $marginright, $marginbottom, $marginleft, $marginunit);
     // Se non ho trovato nessun video ID durante l'analisi URL
     // preparo codice HTML per indicare errore di elaborazione funzione
     if ($vidID === false) {
         $HTML = '<div class="sz-youtube-main" style="' . $CSS . '">';
         $HTML .= '<div class="sz-youtube-warn" style="display:block;padding:1em 0;text-align:center;background-color:#e1e1e1;border:1px solid #b1b1b1;">';
         $HTML .= ucfirst(SZGoogleCommon::getTranslate('youtube URL string specified is not valid.'));
         $HTML .= '</div>';
         $HTML .= '</div>';
         return $HTML;
     }
     // Creazione identificativo univoco per riconoscere il codice embed
     // nel caso la funzioine venga richiamata più volte nella stessa pagina
     $unique = md5(uniqid(), false);
     $keyID = 'sz-youtube-' . $unique;
     // Creazione variabili per gestire le immagini di copertina e
     // la modalità di caricamento codice embed ritardato
     $ONCLICK = '';
     $CSSIMAGE_1 = 'display:block;';
     $CSSIMAGE_2 = 'display:block;';
     $COVERIMAGE = trim($cover);
     $COVERPLAYS = plugin_dir_url(SZ_PLUGIN_GOOGLE_MAIN) . 'frontend/files/images/youtube-play.png';
     // Creazione variabili per gestire le immagini di copertina e
     // la modalità di caricamento codice embed ritardato
     if (ctype_digit($COVERIMAGE)) {
         $COVERSRC = wp_get_attachment_image_src($COVERIMAGE, 'full');
         if (isset($COVERSRC[0])) {
             $COVERIMAGE = $COVERSRC[0];
         } else {
             $COVERIMAGE = 'local';
         }
     }
     if (strtolower($COVERIMAGE) == 'youtube') {
         $image = $datas['scheme'] . '://img.youtube.com/vi/';
         $COVERIMAGE = $image . $vidID . '/hqdefault.jpg';
     }
     if (strtolower($COVERIMAGE) == 'local') {
         $COVERIMAGE = plugin_dir_url(SZ_PLUGIN_GOOGLE_MAIN) . 'frontend/files/images/youtube-cover.jpg';
     }
     // Creazione variabili per gestire le immagini di copertina e
     // la modalità di caricamento codice embed ritardato
     if ($delayed == '1') {
         $CSSIMAGE_1 .= 'cursor:pointer;';
         $CSSIMAGE_1 .= 'background-color:#f1f1f1;';
         $CSSIMAGE_1 .= 'background-image:url(' . $COVERIMAGE . ');';
         $CSSIMAGE_1 .= "background-repeat:no-repeat;";
         $CSSIMAGE_1 .= "background-position:center center;";
         $CSSIMAGE_1 .= "background-size:100% 100%;";
         $CSSIMAGE_2 .= 'background-image:url(' . $COVERPLAYS . ');';
         $CSSIMAGE_2 .= "background-repeat:no-repeat;";
         $CSSIMAGE_2 .= "background-position:center center;";
         $CSSIMAGE_2 .= "background-size:20% auto";
         $ONCLICK = ' onclick="javascript:onYouTubePlayerAPIReady_' . $unique . '();"';
         $AUTOPLAY = '1';
         $disableiframe = '1';
     }
     // SE ATTIVATA FUNZIONE PER STATISTICHE ANALYTICS DEVO FORZARE
     // ESECUZIONE DEL CODICE EMBED TRAMITE YOUTUBE API
     if ($analytics == '1') {
         $disableiframe = '1';
     }
     // Creazione variabile da usare per lo schema.org in caso di attivazione
     // opzione, vengono usate le specifiche di http://schema.org/VideoObject
     $EMBEDURL = $datas['scheme'] . '://www.youtube.com/embed/' . $vidID . '?v=' . $vidID;
     $THUMBNAILURL = $datas['scheme'] . '://img.youtube.com/vi/' . $vidID . '/hqdefault.jpg';
     if ($name == '') {
         $NAME = esc_html(ucfirst(SZGoogleCommon::getTranslate('youtube video')));
     } else {
         $NAME = esc_html($name);
     }
     if ($description != '') {
         $DESCRIPTION = esc_html($description);
     } else {
         $DESCRIPTION = esc_html($title);
     }
     if ($disablerelated == '1') {
         $DISABLERELATED = '0';
     } else {
         $DISABLERELATED = '1';
     }
     // Creazione codice HTML per inserimento nella pagina, la tecnica usata
     // può essere la definizione di un IFRAME e la chiamata ad una funzione API
     $HTML = '';
     // Creazione codice HTML con controllo inserimento schema.org, se il sistema
     // è abilitato vengono usate le specifiche di http://schema.org/VideoObject
     if ($schemaorg == '1') {
         $HTML .= '<div class="sz-youtube-main" style="' . $CSS . '" itemprop="video" itemscope itemtype="http://schema.org/VideoObject">';
         if ($NAME != '') {
             $HTML .= '<meta itemprop="name" content="' . $NAME . '">';
         }
         if ($DESCRIPTION != '') {
             $HTML .= '<meta itemprop="description" content="' . $DESCRIPTION . '">';
         }
         if ($duration != '') {
             $HTML .= '<meta itemprop="duration" content="' . $duration . '">';
         }
         $HTML .= '<meta itemprop="embedURL" content="' . $EMBEDURL . '">';
         $HTML .= '<meta itemprop="thumbnailUrl" content="' . $THUMBNAILURL . '">';
     } else {
         $HTML .= '<div class="sz-youtube-main" style="' . $CSS . '">';
     }
     // Creazione codice HTML per inserimento nella pagina, la tecnica usata
     // può essere la definizione di un IFRAME e la chiamata ad una funzione API
     $HTML .= '<div class="sz-youtube-play" style="' . $CSSIMAGE_1 . '"' . $ONCLICK . '>';
     if ($responsive == '1') {
         $HTML .= '<div class="sz-youtube-cont" ';
         $HTML .= 'style="';
         $HTML .= 'position:relative;';
         $HTML .= 'padding-bottom:56.25%;';
         $HTML .= 'height:0;';
         $HTML .= 'overflow:hidden;';
         $HTML .= $CSSIMAGE_2;
         $HTML .= '">';
     } else {
         $HTML .= '<div class="sz-youtube-cont" ';
         $HTML .= 'style="';
         $HTML .= 'position:relative;';
         $HTML .= 'height:' . $height . 'px;';
         $HTML .= $CSSIMAGE_2;
         $HTML .= '">';
     }
     // Creazione codice HTML per embed code, normalmente utilizzo IFRAME
     // ma se questo è stato disattivato specificatamente utilizzo javascript API
     if ($disableiframe == '1') {
         $HTML .= '<div class="sz-youtube-wrap" style="display:block;">';
         $HTML .= '<div class="sz-youtube-japi" id="' . $keyID . '" style="position:absolute;top:0;left:0;display:block;"></div>';
         $HTML .= '</div>';
         $object = $this->getModuleObject('SZGoogleModuleYoutube');
         $object->addYoutubeVideoAPI(array('unique' => $unique, 'keyID' => $keyID, 'video' => $vidID, 'autoplay' => $AUTOPLAY, 'loop' => $LOOP, 'fullscreen' => $FULLSCREEN, 'disablekeyboard' => $DISABLEKEYBOARD, 'theme' => $theme, 'cover' => $cover, 'analytics' => $analytics, 'delayed' => $delayed, 'start' => $start, 'end' => $end, 'schemaorg' => $schemaorg, 'name' => $name, 'description' => $description, 'disablerelated' => $DISABLERELATED));
         // Creazione codice HTML per embed code, normalmente utilizzo IFRAME
         // ma se questo è stato disattivato specificatamente utilizzo javascript API
     } else {
         $HTML .= '<div class="sz-youtube-wrap" id="' . $keyID . '" style="display:block;">';
         $HTML .= '<iframe ';
         $HTML .= 'src="' . $EMBEDURL;
         $HTML .= '&amp;wmode=opaque';
         $HTML .= '&amp;controls=1';
         $HTML .= '&amp;iv_load_policy=3';
         $HTML .= '&amp;autoplay=' . $AUTOPLAY;
         $HTML .= '&amp;loop=' . $LOOP;
         $HTML .= '&amp;fs=' . $FULLSCREEN;
         $HTML .= '&amp;rel=' . $DISABLERELATED;
         $HTML .= '&amp;disablekb=' . $DISABLEKEYBOARD;
         $HTML .= '&amp;theme=' . $theme;
         if ($start != '') {
             $HTML .= '&amp;start=' . $start;
         }
         if ($end != '') {
             $HTML .= '&amp;end=' . $end;
         }
         $HTML .= '" ';
         $HTML .= 'style="position:absolute;top:0;left:0;width:100%;height:100%;"';
         $HTML .= '>';
         $HTML .= '</iframe>';
         $HTML .= '</div>';
     }
     $HTML .= '</div>';
     $HTML .= '</div>';
     // Creazione blocco del titolo sotto il video youtube, la stringa
     // viene passata tramite il paramtero "title" dello shortcode.
     if ($title != '') {
         $HTML .= '<div class="sz-youtube-capt" ';
         $HTML .= 'style="background-color:#e8e8e8;padding:0.5em 1em;text-align:center;font-weight:bold;margin-top:5px;"';
         $HTML .= '>';
         $HTML .= $title;
         $HTML .= '</div>';
     }
     $HTML .= '</div>';
     // Ritorno per la funzione con tutta la stringa contenente
     // il codice HTML per l'inserimento di un video youtube
     return $HTML;
 }