Find file
Fetching contributors…
Cannot retrieve contributors at this time
99 lines (69 sloc) 2.89 KB
<?php
/*
Plugin Name: Simple Spinnakr
Plugin URI: http://omaruddin.com/2012/05/03/simple-spinnakr-wordpress-plugin/
Description: A simple plugin to add Spinnakr integration code on your pages. You simply enter your ID and apply. Sprinkle more JS codes for deeper integrations.
Version: 1.0
Author: Omar Uddin
Author URI: http://omaruddin.com/
*/
?>
<?php
add_action('admin_menu', 'spinnakr_menu') ;
function spinnakr_menu() {
add_options_page('Simple Spinnakr', 'Spinnakr Settings', 'administrator', __FILE__, 'spinnakr_settings') ;
add_action( 'admin_init', 'spinnakr_register_mysettings') ;
}
function spinnakr_register_mysettings() {
register_setting('spinnakr-settings-group', 'spinnakr_site_id') ;
}
function spinnakr_settings() {
?>
<div class="wrap">
<h2><?php _e('Simple Spinnakr', 'simple_spinnakr') ; ?></h2>
<p>
<?php
_e('Simple Spinnakr allows you to easilly add your Spinnakr Project analytics tracking code on all your pages.', 'simple_spinnakr') ;
echo '<br/>' ;
_e('Just go to your Spinnakr <a href="http://spinnakr.com/">management console</a>, find your Site ID, add your ID below and hit save.', 'simple_spinnakr') ;
echo '<br/>' ;
_e('If you have any page level caching turned on, be sure to clear the cache across the entire site!', 'simple_spinnakr') ;
echo '<br/><br/>' ;
_e('That\'s all, you\'re ready to go.', 'simple_spinnakr') ;
?>
</p>
<form method="post" action="options.php" id="spinnakr_form">
<?php settings_fields('spinnakr-settings-group'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row" style="width: 300px; text-align:right;"><?php _e('Spinnakr Project ID', 'simple_spinnakr') ; ?></th>
<td>
<input type="text" size="80" name="spinnakr_site_id" value="<?php echo get_option('spinnakr_site_id'); ?>">
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Settings') ?>" />
</p>
</form>
<p>
<?php
_e('Get your own Spinnakr account now - <a href="http://spinnakr.com/">http://spinnakr.com/</a>', 'simple_spinnakr') ;
echo '<br/><br/>' ;
_e('If you need any support go to the plugin homepage and contact me !', 'simple_spinnakr') ;
echo '<br/><br/>' ;
echo '<a href="http://omaruddin.com/2012/05/03/simple-spinnakr/" target="_blank"></a>' ;
echo '<br/><br/>' ;
?>
</p>
</div>
<?php
}
add_action('wp_footer', 'spinnakr_function');
function spinnakr_function() {
if ( !is_user_logged_in() && get_option('spinnakr_site_id')!="") { ?>
<script>var _spinnakr_site_id="<?php echo get_option('spinnakr_site_id'); ?>";(function(d,t,a){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g[a]=a;g.src='//s5.spn.ee/js/so.js';s.parentNode.insertBefore(g,s)}(document,'script','async'))</script>
<?php
}
}
?>