Skip to content

Commit

Permalink
Merge pull request #6 from simplereach/p7
Browse files Browse the repository at this point in the history
give force http option to publishers
  • Loading branch information
Andre Malan committed Mar 17, 2014
2 parents 2f89394 + 364839d commit dffbe8e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Plugin Name: SimpleReach Analytics
Plugin URI: https://github.com/simplereach/sranalytics_wordpress
Requires at least: 2.7
Tested up to: 3.8.1
Stable tag: 0.0.6
Stable tag: 0.0.7

SimpleReach Analytics finds trending articles and gives publishers deep insights into their social traffic.

Expand All @@ -20,6 +20,9 @@ SimpleReach Analytics finds trending articles and gives publishers deep insights

== Changelog ==

= 0.0.7 =
* Added ability for all https urls to be sent as http

= 0.0.6 =
* Fixed bug that caused authors not to be tracked in older versions of WordPress
* Updated copy and layout for settings screen
Expand Down
11 changes: 10 additions & 1 deletion sranalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Author URI: https://www.simplereach.com
*/

define('SRANALYTICS_PLUGIN_VERSION', '0.0.6');
define('SRANALYTICS_PLUGIN_VERSION', '0.0.7');
define('SRANALYTICS_PLUGIN_URL', PLugin_dir_url(__FILE__));
define('SRANALYTICS_PLUGIN_SUPPORT_EMAIL', '[email protected]');

Expand Down Expand Up @@ -36,6 +36,9 @@ function sranalytics_insert_js()
$sranalytics_show_everywhere_string = get_option('sranalytics_show_everywhere');
$sranalytics_show_everywhere = ($sranalytics_show_everywhere_string === 'true');

$sranalytics_force_http_string = get_option('sranalytics_force_http');
$sranalytics_force_http = ($sranalytics_force_http_string === 'true');

$sranalytics_disable_iframe_loading_string = get_option('sranalytics_disable_iframe_loading');
$sranalytics_disable_iframe_loading = ($sranalytics_disable_iframe_loading_string === 'true');

Expand Down Expand Up @@ -82,6 +85,12 @@ function sranalytics_insert_js()
$published_date = $post->post_date_gmt;
$canonical_url = addslashes(get_permalink($post->ID));

//force https to http if option is checked
if($sranalytics_force_http){
$pattern = '/^https:\/\//';
$canonical_url = preg_replace( $pattern , "http://" , $canonical_url);
}

// Show the tags if we are on a tag/author/category page and we are supposed to
if ((is_category() or is_author() or is_tag()) and ($sranalytics_show_on_tac_pages or $sranalytics_show_everywhere)) {
$sranalytics_show_beacon = true;
Expand Down
14 changes: 13 additions & 1 deletion sranalytics_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
if (update_option('sranalytics_show_everywhere', $sranalytics_show_everywhere)) {
$message = 'Settings updated';
}

$sranalytics_force_http = (!empty($_POST['sranalytics_force_http'])) ? $_POST['sranalytics_force_http'] : '';
if (update_option('sranalytics_force_http', $sranalytics_force_http)) {
$message = 'Settings updated';
}
$sranalytics_disable_iframe_loading = (!empty($_POST['sranalytics_disable_iframe_loading'])) ? $_POST['sranalytics_disable_iframe_loading'] : '';
if (update_option('sranalytics_disable_iframe_loading', $sranalytics_disable_iframe_loading)) {
$message = 'Settings updated';
Expand Down Expand Up @@ -55,6 +58,11 @@
$sranalytics_show_on_wp_pages = false;
}

$sranalytics_force_http_string = get_option('sranalytics_force_http');
$sranalytics_force_http = ($sranalytics_force_http_string == "true");
if (empty($sranalytics_force_http)) {
$sranalytics_force_http = false;
}
$sranalytics_disable_iframe_loading_string = get_option('sranalytics_disable_iframe_loading');
$sranalytics_disable_iframe_loading = ($sranalytics_disable_iframe_loading_string === 'true');
if (empty($sranalytics_show_on_wp_pages)) {
Expand Down Expand Up @@ -125,6 +133,10 @@
<input type="checkbox" id='sranalytics_show_everywhere' name="sranalytics_show_everywhere" value="true" <?php if ($sranalytics_show_everywhere) { print 'CHECKED=CHECKED'; } ?> />
<label for='sranalytics_show_everywhere'>Track everything, including the home page (includes WordPress, author, category, tag, and search results pages)</label>
</li>
<li>
<input type="checkbox" id='sranalytics_force_http' name="sranalytics_force_http" value="true" <?php if ($sranalytics_force_http) { print 'CHECKED=CHECKED'; } ?> />
<label for='sranalytics_force_http'>Send urls as HTTP. If your site uses a combination of both HTTP and HTTPS, enable this option.</label>
</li>
<li><input class='button-primary' type="submit" name="Submit" value="<?php _e('Save', 'sranalytics'); ?>" /></li>
</ul>
</div>
Expand Down

0 comments on commit dffbe8e

Please sign in to comment.