/**
* Options is an array that contains
* size - either 16 or 32.  Defaults to 16
* services - comma sepperated list of services
* preferred - number of Prefered services to be displayed after listed services
* more - bool to show or not show the more icon at the end
*
* @param $options array
*/
function addthis_custom_toolbox($options, $url, $title)
{
    $identifier = addthis_get_identifier($url, $title);
    $outerClasses = 'addthis_toolbox addthis_default_style';
    if (isset($options['size']) && $options['size'] == '32') {
        $outerClasses .= ' addthis_32x32_style';
    }
    if (isset($options['type']) && $options['type'] != 'custom_string') {
        $button = '<div class="' . $outerClasses . '" ' . $identifier . ' >';
        if (isset($options['addthis_options']) && $options['addthis_options'] != "") {
            $addthis_options = split(',', $options['addthis_options']);
            foreach ($addthis_options as $option) {
                $option = trim($option);
                if ($option != 'more') {
                    $button .= '<a class="addthis_button_' . $option . '"></a>';
                }
            }
        } else {
            if (isset($options['services'])) {
                $services = explode(',', $options['services']);
                foreach ($services as $service) {
                    $service = trim($service);
                    if ($service == 'more' || $service == 'compact') {
                        if (isset($options['type']) && $options['type'] != 'fb_tw_p1_sc') {
                            $button .= '<a class="addthis_button_compact"></a>';
                        }
                    } else {
                        if ($service == 'counter') {
                            if (isset($options['type']) && $options['type'] == 'fb_tw_p1_sc') {
                                $button .= '<a class="addthis_counter addthis_pill_style"></a>';
                            } else {
                                $button .= '<a class="addthis_counter addthis_bubble_style"></a>';
                            }
                        } else {
                            if ($service == 'google_plusone') {
                                $button .= '<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>';
                            } else {
                                $button .= '<a class="addthis_button_' . strtolower($service) . '"></a>';
                            }
                        }
                    }
                }
            }
        }
        if (isset($options['preferred']) && is_numeric($options['preferred'])) {
            for ($a = 1; $a <= $options['preferred']; $a++) {
                $button .= '<a class="addthis_button_preferred_' . $a . '"></a>';
            }
        }
        if (isset($options['more']) && $options['more'] == true) {
            $button .= '<a class="addthis_button_compact"></a>';
        }
        if (isset($options['counter']) && $options['counter'] != "" && $options['counter'] !== false) {
            if ($options['counter'] === true) {
                //no style was specified
                $button .= '<a class="addthis_counter"></a>';
            } else {
                //a specific style was specified such as pill_style or bubble_style
                $button .= '<a class="addthis_counter addthis_' . $options['counter'] . '"></a>';
            }
        }
        $button .= '</div>';
    }
    return $button;
}
 /**
  * Appends AddThis button to post content.
  */
 function addthis_social_widget($content, $onSidebar = false, $url = null, $title = null)
 {
     addthis_set_addthis_settings();
     global $addthis_settings;
     global $addThisConfigs;
     global $cmsConnector;
     // add nothing to RSS feed or search results; control adding to static/archive/category pages
     if (!$onSidebar) {
         if ($addthis_settings['sidebar_only'] || is_feed() || is_search() || is_home() || is_page() || is_archive() || is_category()) {
             return $content;
         }
     }
     $pub = urlencode($addThisConfigs->getUsableProfileId());
     $link = !is_null($url) ? $url : ($onSidebar ? get_bloginfo('url') : get_permalink());
     $title = !is_null($title) ? $title : ($onSidebar ? get_bloginfo('title') : the_title('', '', false));
     $content .= '
         <!-- AddThis Button BEGIN -->
         <script data-cfasync="false" type="text/javascript">' . "\n//<!--\n" . "var addthis_product = '" . $cmsConnector->getProductVersion() . "';\n";
     if (strlen($addthis_settings['customization'])) {
         $content .= $addthis_settings['customization'] . "\n";
     }
     if ($addthis_settings['menu_type'] === 'dropdown') {
         $content .= '
             </script>
                 <div class="addthis_container">
                     <a
                         href="//www.addthis.com/bookmark.php?v=' . $atversion . '&amp;username='******'"
                         class="addthis_button"
                         ' . addthis_get_identifier($link, $title) . '
                     >
             ';
         $content .= ($addthis_settings['language'] == '' ? '' : addthis_get_button_img()) . '</a><script data-cfasync="false" type="text/javascript" src="//s7.addthis.com/js/' . $atversion . '/addthis_widget.js#username='******'"></script></div>';
     } else {
         if ($addthis_settings['menu_type'] === 'toolbox') {
             $content .= "\n//-->\n</script>\n";
             $content .= '
             <div
                 class="addthis_container addthis_toolbox addthis_default_style"
                 ' . addthis_get_identifier($link, $title) . '
             >
                 <a
                     href="//www.addthis.com/bookmark.php?v=' . $atversion . '&amp;username=$pub"
                     class="addthis_button_compact">
                     Share
                 </a>
                 <span class="addthis_separator">|</span>
                 <script data-cfasync="false" type="text/javascript" src="//s7.addthis.com/js/' . $atversion . '/addthis_widget.js#username='******'">
                 </script>
             </div>';
         } else {
             $link = urlencode($link);
             $title = urlencode($title);
             $content .= '//-->
             </script>
             <div class="addthis_container">
             <a
                 href="//www.addthis.com/bookmark.php?v=' . $atversion . '&amp;username=$pub"
                 onclick="window.open(\'//www.addthis.com/bookmark.php?v=' . $atversion . '&amp;username='******'&amp;url=' . $link . '&amp;title=' . $title . '\', \'ext_addthis\', \'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no\'); return false;"
                 title="Bookmark using any bookmark manager!"
                 target="_blank"
             >
         ';
             $content .= addthis_get_button_img() . '</a></div>';
         }
     }
     $content .= "\n<!-- AddThis Button END -->";
     return $content;
 }
Ejemplo n.º 3
0
/**
* Options is an array that contains
* size - either 16 or 32.  Defaults to 16
* services - comma sepperated list of services
* preferred - number of Prefered services to be displayed after listed services
* more - bool to show or not show the more icon at the end
*
* @param $options array
*/
function addthis_custom_toolbox($options, $url, $title)
{
    $identifier = addthis_get_identifier($url, $title);
    $outerClasses = 'addthis_toolbox addthis_default_style';
    if (isset($options['size']) && $options['size'] == '32') {
        $outerClasses .= ' addthis_32x32_style';
    }
    $button = '<div class="' . $outerClasses . '" ' . $identifier . ' >';
    if (isset($options['services'])) {
        $services = explode(',', $options['services']);
        foreach ($services as $service) {
            $service = trim($service);
            if ($service == 'more') {
                $button .= '<a class="addthis_button_compact"></a>';
            } else {
                $button .= '<a class="addthis_button_' . strtolower($service) . '"></a>';
            }
        }
    }
    if (isset($options['preferred']) && is_numeric($options['preferred'])) {
        for ($a = 1; $a <= $options['preferred']; $a++) {
            $button .= '<a class="addthis_button_preferred_' . $a . '"></a>';
        }
    }
    if (isset($options['more']) && $options['more'] == true) {
        $button .= '<a class="addthis_button_compact"></a>';
    }
    $button .= '</div>';
    return $button;
}