/** * The actual text for the JS snippet because drupal doesn't seem to be * able to add JS from template like Wordpress does... * Using heredocs for now * * @return string JS block for shareaholic code */ private static function js_snippet() { $api_key = ShareaholicUtilities::get_option('api_key'); $js_url = ShareaholicUtilities::asset_url('pub/shareaholic.js'); $page_config = ShareaholicPublicJS::get_page_config(); $js_snippet = <<<DOC <script type='text/javascript' data-cfasync='false'> //<![CDATA[ (function() { var shr = document.createElement('script'); shr.setAttribute('data-cfasync', 'false'); shr.src = '{$js_url}'; shr.type = 'text/javascript'; shr.async = 'true'; shr.onload = shr.onreadystatechange = function() { var rs = this.readyState; if (rs && rs != 'complete' && rs != 'loaded') return; var site_id = '{$api_key}'; var page_config = {$page_config}; try { Shareaholic.init(site_id, page_config); } catch (e) {} }; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(shr, s); })(); //]]> </script> DOC; return $js_snippet; }
/** * The actual text for the JS snippet because drupal doesn't seem to be * able to add JS from template like Wordpress does... * Using heredocs for now * * @return string JS block for shareaholic code */ private static function js_snippet() { $api_key = ShareaholicUtilities::get_option('api_key'); $js_url = ShareaholicUtilities::asset_url('pub/shareaholic.js'); $base_settings = json_encode(ShareaholicPublicJS::get_base_settings()); $overrides = ShareaholicPublicJS::get_overrides(); $js_snippet = <<<DOC <script type='text/javascript' data-cfasync='false'> //<![CDATA[ _SHR_SETTINGS = {$base_settings}; //]]> </script> <script type='text/javascript' src='{$js_url}' data-shr-siteid='{$api_key}' data-cfasync='false' async='async' {$overrides}> </script> DOC; return $js_snippet; }
/** * Inserts the necessary css and js assets * for the Shareaholic Admin Pages * */ public static function include_css_js_assets() { $module_path = drupal_get_path('module', 'shareaholic'); drupal_add_css('//fonts.googleapis.com/css?family=Open+Sans:400,300,700', array('type' => 'external', 'group' => CSS_DEFAULT)); drupal_add_css($module_path . '/assets/css/bootstrap.css', array('group' => CSS_DEFAULT)); drupal_add_css($module_path . '/assets/css/bootstrap-responsive.css', array('group' => CSS_DEFAULT)); drupal_add_css($module_path . '/assets/css/reveal.css', array('group' => CSS_DEFAULT)); drupal_add_css($module_path . '/assets/css/main.css', array('group' => CSS_DEFAULT)); drupal_add_js(ShareaholicUtilities::asset_url('pub/utilities.js'), array('type' => 'external', 'group' => JS_DEFAULT)); drupal_add_js(ShareaholicUtilities::asset_url('pub/shareaholic_sdk.js'), array('type' => 'external', 'group' => JS_DEFAULT)); drupal_add_js($module_path . '/assets/js/jquery_custom.js', array('group' => JS_DEFAULT)); drupal_add_js($module_path . '/assets/js/jquery_ui_custom.js', array('group' => JS_DEFAULT)); drupal_add_js($module_path . '/assets/js/jquery.reveal.modified.js', array('group' => JS_DEFAULT)); drupal_add_js($module_path . '/assets/js/bootstrap.js', array('group' => JS_DEFAULT)); drupal_add_js($module_path . '/assets/js/main.js', array('group' => JS_DEFAULT)); }
<!-- This site is powered by Shareaholic - https://shareaholic.com --> <script type='text/javascript' data-cfasync='false'> //<![CDATA[ _SHR_SETTINGS = <?php echo json_encode($base_settings); ?> ; (function() { var shr = document.createElement('script'); shr.setAttribute('data-cfasync', 'false'); shr.src = '<?php echo ShareaholicUtilities::asset_url('assets/pub/shareaholic.js'); ?> '; shr.type = 'text/javascript'; shr.async = 'true'; <?php echo $overrides; ?> shr.onload = shr.onreadystatechange = function() { var rs = this.readyState; if (rs && rs != 'complete' && rs != 'loaded') return; var site_id = '<?php echo $api_key; ?> '; try { Shareaholic.init(site_id); } catch (e) {} }; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(shr, s);
<script type="text/javascript" data-sorendpoint="<?php echo Shareaholic::URL; ?> " data-sorassetbase="<?php echo ShareaholicUtilities::asset_url('assets'); ?> " src="<?php echo ShareaholicUtilities::asset_url('assets/headerWidget.js'); ?> "> </script> <link href="<?php echo ShareaholicUtilities::asset_url('assets/header.css'); ?> " media="all" rel="stylesheet" type="text/css"> <!-- Start Header Template --> <div class="new-design flat-layout wordpress-admin" style="display:none;"> <header class="header-section js-header"> <div class="header"> <a href= "https://shareaholic.com" class="logo"></a> <nav class="header-nav"> </nav> <ul class="user-nav js-logged-out" style="display:none;"> <div class="hiring"> <a href="https://shareaholic.com/careers?utm_source=univ_header_wp_plugin&utm_medium=link&utm_campaign=careers" target="_blank">We're Hiring</a> </div> <li><a href="#" class="btn dark-green js-action-signup">Sign Up Free</a></li>