Пример #1
0
 /**
  * Funzione per esecuzione codice google+ follow con 
  * creazione codice HTML sia per shortcode che per widget
  *
  * @return string
  */
 function getPlusFollowCode($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
     $DEFAULT_SIZE = 'medium';
     $DEFAULT_ANNOTATION = 'bubble';
     $DEFAULT_REL = 'none';
     $DEFAULT_FLOAT = 'none';
     $DEFAULT_ALIGN = 'none';
     $DEFAULT_POSITION = 'outside';
     // Estrazione dei valori specificati nello shortcode, i valori ritornati
     // sono contenuti nei nomi di variabili corrispondenti alla chiave
     extract(shortcode_atts(array('url' => '', 'size' => '', 'width' => '', 'annotation' => '', 'float' => '', 'align' => '', 'text' => '', 'img' => '', 'rel' => '', 'position' => '', 'margintop' => '', 'marginright' => '', 'marginbottom' => '', 'marginleft' => '', 'marginunit' => '', 'action' => ''), $atts));
     // Elimino spazi aggiunti di troppo ed esegui la trasformazione in
     // stringa minuscolo per il controllo di valori speciali come "auto"
     $url = trim($url);
     $text = trim($text);
     $img = trim($img);
     $width = strtolower(trim($width));
     $size = strtolower(trim($size));
     $annotation = strtolower(trim($annotation));
     $float = strtolower(trim($float));
     $align = strtolower(trim($align));
     $rel = strtolower(trim($rel));
     $position = strtolower(trim($position));
     $margintop = strtolower(trim($margintop));
     $marginright = strtolower(trim($marginright));
     $marginbottom = strtolower(trim($marginbottom));
     $marginleft = strtolower(trim($marginleft));
     $marginunit = strtolower(trim($marginunit));
     // Imposto i valori di default nel caso siano specificati dei valori
     // che non appartengono al range dei valori accettati
     if (!in_array($size, array('small', 'medium', 'large'))) {
         $size = $DEFAULT_SIZE;
     }
     if (!in_array($annotation, array('inline', 'bubble', 'vertical-bubble', 'none'))) {
         $annotation = $DEFAULT_ANNOTATION;
     }
     if (!in_array($float, array('none', 'left', 'right'))) {
         $float = $DEFAULT_FLOAT;
     }
     if (!in_array($align, array('none', 'left', 'right', 'center'))) {
         $align = $DEFAULT_ALIGN;
     }
     if (!in_array($rel, array('author', 'publisher'))) {
         $rel = $DEFAULT_REL;
     }
     if (!in_array($position, array('top', 'center', 'bottom', 'outside'))) {
         $position = $DEFAULT_POSITION;
     }
     // Lettura opzioni generali per impostazione dei dati di default
     $options = $this->getOptions();
     // Imposto i valori di default nel caso siano specificati dei valori
     // che non appartengono al range dei valori accettati
     if ($url == '') {
         $url = 'https://plus.google.com/' . $options['plus_page'];
     }
     if ($url == '') {
         $url = 'https://plus.google.com/' . $options['plus_profile'];
     }
     if ($url == '') {
         $url = 'https://plus.google.com/' . '117259631219963935481';
         $rel = '';
     }
     if ($url == '') {
         $url = 'https://plus.google.com/' . '106189723444098348646';
         $rel = '';
     }
     // 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);
     // Preparazione codice HTML per il badge di google plus
     $HTML = '<div class="g-follow"';
     $HTML .= ' data-href="' . $url . '"';
     $HTML .= ' data-annotation="' . $annotation . '"';
     if ($size == 'small') {
         $HTML .= ' data-height="15"';
     }
     if ($size == 'medium') {
         $HTML .= ' data-height="20"';
     }
     if ($size == 'large') {
         $HTML .= ' data-height="24"';
     }
     if ($width != '') {
         $HTML .= ' data-width="' . $width . '"';
     }
     if ($align == 'right') {
         $HTML .= ' data-align="right"';
     }
     if ($rel == 'author') {
         $HTML .= ' data-rel="author"';
     }
     if ($rel == 'publisher') {
         $HTML .= ' data-rel="publisher"';
     }
     $HTML .= '></div>';
     $HTML = SZGoogleCommonButton::getButton(array('html' => $HTML, 'text' => $text, 'image' => $img, 'content' => $content, 'float' => $float, 'align' => $align, 'position' => $position, 'margintop' => $margintop, 'marginright' => $marginright, 'marginbottom' => $marginbottom, 'marginleft' => $marginleft, 'marginunit' => $marginunit, 'class' => 'sz-google-follow'));
     // 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;
 }
 /**
  * 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('type' => '', 'width' => '', 'topic' => '', 'float' => '', 'align' => '', 'text' => '', 'img' => '', 'position' => '', 'profile' => '', 'email' => '', 'logged' => '', 'guest' => '', 'margintop' => '', 'marginright' => '', 'marginbottom' => '', 'marginleft' => '', 'marginunit' => '', 'class' => '', 'action' => ''), $atts));
     // Loading options for the configuration variables
     // containing the default values ​​for shortcodes and widgets
     $options = (object) $this->getModuleOptions('SZGoogleModuleHangouts');
     // I delete spaces added and execute the transformation in string
     // lowercase for the control of special values ​​such as "auto"
     $text = trim($text);
     $img = trim($img);
     $class = trim($class);
     $topic = htmlspecialchars(trim($topic), ENT_QUOTES);
     $type = strtolower(trim($type));
     $width = strtolower(trim($width));
     $align = strtolower(trim($align));
     $float = strtolower(trim($float));
     $position = strtolower(trim($position));
     $profile = strtolower(trim($profile));
     $email = strtolower(trim($email));
     $logged = strtolower(trim($logged));
     $guest = strtolower(trim($guest));
     $margintop = strtolower(trim($margintop));
     $marginright = strtolower(trim($marginright));
     $marginbottom = strtolower(trim($marginbottom));
     $marginleft = strtolower(trim($marginleft));
     $marginunit = strtolower(trim($marginunit));
     // Conversione dei valori specificati direttamete nei parametri con
     // i valori usati per la memorizzazione dei valori di default
     if ($logged == 'yes' or $logged == 'y') {
         $logged = '1';
     }
     if ($guest == 'yes' or $guest == 'y') {
         $guest = '1';
     }
     if ($logged == 'no' or $logged == 'n') {
         $logged = '0';
     }
     if ($guest == 'no' or $guest == 'n') {
         $guest = '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 ($logged == '') {
         $logged = $options->hangouts_start_logged;
     }
     if ($guest == '') {
         $guest = $options->hangouts_start_guest;
     }
     if (!in_array($logged, $YESNO)) {
         $logged = $options->hangouts_start_logged;
     }
     if (!in_array($guest, $YESNO)) {
         $guest = $options->hangouts_start_guest;
     }
     // Controllo se devo saltare elaborazione per opzioni che riguardano
     // il controllo su utente loggato o utente guest. Ritorno NULL.
     if (!current_user_can('manage_options')) {
         if (current_user_can('read') and $logged != '1') {
             return NULL;
         }
         if (!current_user_can('read') and $guest != '1') {
             return NULL;
         }
     }
     // Imposto i valori di default nel caso siano specificati dei valori
     // che non appartengono al range dei valori accettati
     if (!in_array($type, array('normal', 'onair', 'party', 'moderate'))) {
         $type = 'normal';
     }
     if (!in_array($float, array('none', 'left', 'right'))) {
         $float = 'none';
     }
     if (!in_array($align, array('none', 'left', 'right', 'center'))) {
         $align = 'none';
     }
     if (!in_array($position, array('top', 'center', 'bottom', 'outside'))) {
         $position = 'outside';
     }
     if ($class == '') {
         $class = 'sz-google-hangouts-button';
     }
     if (!is_numeric($width) and $width != 'auto') {
         $width = '';
     }
     // Controllo la dimensione del widget e controllo formale dei valori numerici
     // se trovo qualche incongruenza applico i valori di default prestabiliti
     if ($width == '') {
         $width = "'+w+'";
     }
     if ($width == 'auto') {
         $width = "'+w+'";
     }
     $uniqueID = 'sz-google-hangouts-' . md5(uniqid(), false);
     // 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 w=document.getElementById('" . $uniqueID . "').offsetWidth;";
     $HTML .= "var h='<'+'";
     $HTML .= 'div class="g-hangout"';
     $HTML .= ' data-render="createhangout"';
     $HTML .= ' data-hangout_type="' . $type . '"';
     $HTML .= ' data-widget_size="' . $width . '"';
     if ($topic != '') {
         $HTML .= ' data-topic="' . $topic . '"';
     }
     // Check field for email or profile to prepare the html
     // code and allow invitations specified in options
     $invite = array();
     $profili = explode(',', $profile);
     $indirizzi = explode(',', $email);
     if (is_array($profili) and !empty($profili)) {
         foreach ($profili as $key => $value) {
             $invite[] = "{id:\\'" . $value . "\\',invite_type:\\'PROFILE\\'}";
         }
     }
     // Check field for email or profile to prepare the html
     // code and allow invitations specified in options
     if (is_array($indirizzi) and !empty($indirizzi)) {
         foreach ($indirizzi as $key => $value) {
             $invite[] = "{id:\\'" . $value . "\\',invite_type:\\'EMAIL\\'}";
         }
     }
     if (!empty($invite)) {
         $HTML .= ' data-invites="[' . implode(',', $invite) . ']"';
     }
     // Close code javascript for the creation of the
     // required component. In this way the load is delayed
     $HTML .= "></'+'div'+'>';";
     $HTML .= "document.write(h);";
     $HTML .= '</script>';
     // Creazione codice HTML con funzione di wrapping comune a tutti i bottoni in maniera
     // da essere utilizzati anche come dei piccoli badge con immagine e posizionamento
     $HTML = SZGoogleCommonButton::getButton(array('html' => $HTML, 'text' => $text, 'image' => $img, 'content' => $content, 'float' => $float, 'align' => $align, 'position' => $position, 'margintop' => $margintop, 'marginright' => $marginright, 'marginbottom' => $marginbottom, 'marginleft' => $marginleft, 'marginunit' => $marginunit, 'class' => $class, 'uniqueID' => $uniqueID));
     // Aggiunta del codice javascript per il rendering dei widget, questo codice
     // viene aggiungo anche dalla sidebar però viene inserito una sola volta
     add_action('SZ_FOOT_BODY', array($this->getModuleObject('SZGoogleModuleHangouts'), 'setJavascriptPlatform'));
     // Return from the function with the whole string containing
     // the HTML code for inserting the code in the page
     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('url' => '', 'filename' => '', 'sitename' => '', 'text' => '', 'img' => '', 'position' => '', 'align' => '', 'margintop' => '', 'marginright' => '', 'marginbottom' => '', 'marginleft' => '', 'marginunit' => '', 'action' => ''), $atts));
     $DEFAULT_ALIGN = 'none';
     $DEFAULT_POSITION = 'outside';
     // I delete spaces added and execute the transformation in string
     // lowercase for the control of special values ​​such as "auto"
     $url = trim($url);
     $filename = trim($filename);
     $sitename = trim($sitename);
     $text = trim($text);
     $img = trim($img);
     $position = strtolower(trim($position));
     $align = strtolower(trim($align));
     $margintop = strtolower(trim($margintop));
     $marginright = strtolower(trim($marginright));
     $marginbottom = strtolower(trim($marginbottom));
     $marginleft = strtolower(trim($marginleft));
     $marginunit = strtolower(trim($marginunit));
     // Se non specifico un URL valido per la creazione del bottone
     // esco dalla funzione e ritorno una stringa vuota
     if (empty($url)) {
         return '';
     }
     // Imposto i valori di default nel caso siano specificati dei valori
     // che non appartengono al range dei valori accettati
     if (!in_array($align, array('none', 'left', 'right', 'center'))) {
         $align = $DEFAULT_ALIGN;
     }
     if (!in_array($position, array('top', 'center', 'bottom', 'outside'))) {
         $position = $DEFAULT_POSITION;
     }
     if (empty($sitename)) {
         $sitename = get_bloginfo('name');
     }
     if (empty($sitename)) {
         $sitename = 'Website';
     }
     if (empty($filename)) {
         $filename = basename($url);
     }
     // Calcolo il nome host attuale di wordpress in maniera da preparare
     // la stringa per la sostituzione sonlo se link è sullo stesso dominio
     $URLBlog = home_url('/');
     $URLBlog = parse_url($URLBlog);
     if (isset($URLBlog['host'])) {
         $url = preg_replace('#^https?://' . $URLBlog['host'] . '#', '', $url);
     }
     // Creazione codice HTML per embed code da inserire nella pagina wordpress
     $HTML = '<div class="g-savetodrive"';
     $HTML .= ' data-src="' . $url . '"';
     $HTML .= ' data-filename="' . $filename . '"';
     $HTML .= ' data-sitename="' . $sitename . '"';
     $HTML .= '></div>';
     $HTML = SZGoogleCommonButton::getButton(array('html' => $HTML, 'text' => $text, 'image' => $img, 'content' => $content, 'align' => $align, 'position' => $position, 'margintop' => $margintop, 'marginright' => $marginright, 'marginbottom' => $marginbottom, 'marginleft' => $marginleft, 'marginunit' => $marginunit, 'class' => 'sz-google-savetodrive'));
     // Aggiunta del codice javascript per il rendering dei widget, questo codice
     // viene aggiungo anche dalla sidebar però viene inserito una sola volta
     $this->getModuleObject('SZGoogleModuleDrive')->addCodeJavascriptFooter();
     // Return from the function with the whole string containing
     // the HTML code for inserting the code in the page
     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('type' => '', 'width' => '', 'topic' => '', 'float' => '', 'align' => '', 'text' => '', 'img' => '', 'position' => '', 'margintop' => '', 'marginright' => '', 'marginbottom' => '', 'marginleft' => '', 'marginunit' => '', 'class' => '', 'action' => ''), $atts));
     // Elimino spazi aggiunti di troppo ed eseguo la trasformazione in
     // stringa minuscolo per il controllo di valori speciali come "auto"
     $text = trim($text);
     $img = trim($img);
     $class = trim($class);
     $topic = htmlspecialchars(trim($topic), ENT_QUOTES);
     $type = strtolower(trim($type));
     $width = strtolower(trim($width));
     $align = strtolower(trim($align));
     $float = strtolower(trim($float));
     $position = strtolower(trim($position));
     $margintop = strtolower(trim($margintop));
     $marginright = strtolower(trim($marginright));
     $marginbottom = strtolower(trim($marginbottom));
     $marginleft = strtolower(trim($marginleft));
     $marginunit = strtolower(trim($marginunit));
     // Imposto i valori di default nel caso siano specificati dei valori
     // che non appartengono al range dei valori accettati
     if (!in_array($type, array('normal', 'onair', 'party', 'moderate'))) {
         $type = 'normal';
     }
     if (!in_array($float, array('none', 'left', 'right'))) {
         $float = 'none';
     }
     if (!in_array($align, array('none', 'left', 'right', 'center'))) {
         $align = 'none';
     }
     if (!in_array($position, array('top', 'center', 'bottom', 'outside'))) {
         $position = 'outside';
     }
     if ($class == '') {
         $class = 'sz-google-hangouts-button';
     }
     if (!is_numeric($width) and $width != 'auto') {
         $width = '';
     }
     // Controllo la dimensione del widget e controllo formale dei valori numerici
     // se trovo qualche incongruenza applico i valori di default prestabiliti
     if ($width == '') {
         $width = "'+w+'";
     }
     if ($width == 'auto') {
         $width = "'+w+'";
     }
     $uniqueID = 'sz-google-hangouts-' . md5(uniqid(), false);
     // 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 w=document.getElementById('" . $uniqueID . "').offsetWidth;";
     $HTML .= "var h='<'+'";
     $HTML .= 'div class="g-hangout"';
     $HTML .= ' data-render="createhangout"';
     $HTML .= ' data-hangout_type="' . $type . '"';
     $HTML .= ' data-widget_size="' . $width . '"';
     if ($topic != '') {
         $HTML .= ' data-topic="' . $topic . '"';
     }
     $HTML .= "></'+'div'+'>';";
     $HTML .= "document.write(h);";
     $HTML .= '</script>';
     // Creazione codice HTML con funzione di wrapping comune a tutti i bottoni in maniera
     // da essere utilizzati anche come dei piccoli badge con immagine e posizionamento
     $HTML = SZGoogleCommonButton::getButton(array('html' => $HTML, 'text' => $text, 'image' => $img, 'content' => $content, 'float' => $float, 'align' => $align, 'position' => $position, 'margintop' => $margintop, 'marginright' => $marginright, 'marginbottom' => $marginbottom, 'marginleft' => $marginleft, 'marginunit' => $marginunit, 'class' => $class, 'uniqueID' => $uniqueID));
     // Aggiunta del codice javascript per il rendering dei widget, questo codice
     // viene aggiungo anche dalla sidebar però viene inserito una sola volta
     add_action('SZ_FOOT', array($this->getModuleObject('SZGoogleModuleHangouts'), 'setJavascriptPlatform'));
     // Ritorno per la funzione con tutta la stringa contenente
     // il codice HTML per l'inserimento del codice nella pagina
     return $HTML;
 }