function _xlii_smt_load() { if (!is_admin()) { include_once 'guifactory/xlii_guifactory.php'; // Implement tracking code $settings = _xlii_smt_ga_options(); if ($settings['enabled'] && $settings['code']) { echo '<script type="text/javascript">' . stripslashes($settings['code']) . '</script>'; } // Add filter if plugin is enabled for this page if (xlii_smt_is_enabled() && count($buttons = xlii_smt_get_buttons('default'))) { add_filter('the_content', 'xlii_smt_display'); add_filter('the_excerpt', 'xlii_smt_display'); } } }
/** RENDER ------------------------------------------------------------------------------------------------------------------------------------------------ * Convert the object to a string. * * @return string */ public function render() { if (!isset(self::$_queue[$this->getType()])) { $settings = _xlii_smt_ga_options(); $this->_enqueueResources($settings['tracking']); self::$_queue[$this->getType()] = true; } if (count(self::$_queue) == 1) { // Enqueue styling and smt wp_enqueue_style('xlii_smt_front'); wp_enqueue_script('xlii_smt_front'); // Append tracking script if ($settings['tracking']) { wp_enqueue_script('xlii_smt_tracking'); } } return '<span class = "xlii-smt-button ' . $this->getType() . '">' . $this->_render() . '</span>'; }
function xlii_smt_adminpage_ga() { if (isset($_POST['save'])) { xlii_smt_adminprocess_ga(); } $settings = _xlii_smt_ga_options(); if (!$settings['code']) { $settings['code'] = "var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'XX-XXXXXXXX-X']);\n _gaq.push(['_trackPageview']);\n\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();"; } ?> <form action="<?php echo esc_attr($_SERVER['REQUEST_URI']); ?> " method="post"> <div class="wrap"> <?php screen_icon(); ?> <h2><?php _e('Social Media Tracker'); ?> </h2> <?php _xlii_smt_notify(); _xlii_smt_navigation(); ?> <div id = "xlii-admin" class = "analytics"> <?php echo '<div class = "form"> <div class = "row">' . XLII_GUIFactory::textarea(array('label' => __('Analytics code'), 'name' => 'code', 'value' => $settings['code'], 'style' => 'width:600px;height:250px;')) . '</div> <div class = "row">' . XLII_GUIFactory::checkbox(array('label' => __('Track button interaction'), 'value' => $settings['tracking'], 'name' => 'tracking')) . ' <p class = "description">' . __('You can check this box if you\'d like to track the interaction with the social media buttons.') . '</p> </div> <div class = "row">' . XLII_GUIFactory::checkbox(array('label' => __('Append code to website'), 'value' => $settings['enabled'], 'name' => 'enabled')) . ' <p class = "description">' . __('In order to work propperly the Social Media Tracking plugin requires a valid Google Analytics code to be implemented on your website. In case you didn\'t implemented this code already our plugin can do it for you, the only thing you have to do is to') . ' <label for = "enabled" class = "link">click here</label> ' . __('and replace XX-XXXXXXXX-X in the sample by your own code.') . ' </p> <p class = "description"> <span style = "margin-top:-10px;">' . __('Your tracking code can be found in your Google Analytics panel.') . '</span> <img src = "' . XLII_SMT_BASE . 'media/gacode.png" alt = "Tracking code" title = "Tracking code" style = "vertical-align:baseline;" /> </p> </div> ' . XLII_GUIFactory::submit(array('label' => __('Save state'), 'name' => 'save')) . ' </div>'; ?> </div> </div> </form> <?php }