| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | // |
|---|
| 4 | // Open Web Analytics - An Open Source Web Analytics Framework |
|---|
| 5 | // |
|---|
| 6 | // Copyright 2006 Peter Adams. All rights reserved. |
|---|
| 7 | // |
|---|
| 8 | // Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html |
|---|
| 9 | // |
|---|
| 10 | // Unless required by applicable law or agreed to in writing, software |
|---|
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 13 | // See the License for the specific language governing permissions and |
|---|
| 14 | // limitations under the License. |
|---|
| 15 | // |
|---|
| 16 | // $Id$ |
|---|
| 17 | // |
|---|
| 18 | |
|---|
| 19 | require_once(OWA_BASE_CLASSES_DIR.'owa_caller.php'); |
|---|
| 20 | |
|---|
| 21 | /** |
|---|
| 22 | * Wordpress Caller class |
|---|
| 23 | * |
|---|
| 24 | * @author Peter Adams <peter@openwebanalytics.com> |
|---|
| 25 | * @copyright Copyright © 2006 Peter Adams <peter@openwebanalytics.com> |
|---|
| 26 | * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 |
|---|
| 27 | * @category owa |
|---|
| 28 | * @package owa |
|---|
| 29 | * @version $Revision$ |
|---|
| 30 | * @since owa 1.0.0 |
|---|
| 31 | */ |
|---|
| 32 | class owa_wp extends owa_caller { |
|---|
| 33 | |
|---|
| 34 | /** |
|---|
| 35 | * Constructor |
|---|
| 36 | * |
|---|
| 37 | * @return owa_wp |
|---|
| 38 | */ |
|---|
| 39 | function owa_wp($config = null) { |
|---|
| 40 | |
|---|
| 41 | // needed because some of worpresses templates output prior to plugins being called |
|---|
| 42 | // which breaks OWA redirects. |
|---|
| 43 | ob_start(); |
|---|
| 44 | |
|---|
| 45 | $this->owa_caller($config); |
|---|
| 46 | |
|---|
| 47 | return; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | function __construct($config = null) { |
|---|
| 51 | ob_start(); |
|---|
| 52 | return parent::__construct($config); |
|---|
| 53 | |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | function add_link_tracking($link) { |
|---|
| 58 | |
|---|
| 59 | // check for presence of '?' which is not present under URL rewrite conditions |
|---|
| 60 | |
|---|
| 61 | if ($this->config['track_feed_links'] == true): |
|---|
| 62 | |
|---|
| 63 | if (strpos($link, "?") === false): |
|---|
| 64 | // add the '?' if not found |
|---|
| 65 | $link .= '?'; |
|---|
| 66 | endif; |
|---|
| 67 | |
|---|
| 68 | // setup link template |
|---|
| 69 | $link_template = "%s&%s=%s&%s=%s"; |
|---|
| 70 | |
|---|
| 71 | return sprintf($link_template, |
|---|
| 72 | $link, |
|---|
| 73 | $this->config['ns'].$this->config['source_param'], |
|---|
| 74 | 'feed', |
|---|
| 75 | $this->config['ns'].$this->config['feed_subscription_param'], |
|---|
| 76 | $_GET[$this->config['ns'].$this->config['feed_subscription_param']]); |
|---|
| 77 | else: |
|---|
| 78 | return; |
|---|
| 79 | endif; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | /** |
|---|
| 83 | * Wordpress filter method. Adds tracking to feed links. |
|---|
| 84 | * |
|---|
| 85 | * @var string the feed link |
|---|
| 86 | * @return string link string with special tracking id |
|---|
| 87 | */ |
|---|
| 88 | function add_feed_tracking($binfo) { |
|---|
| 89 | |
|---|
| 90 | if ($this->config['track_feed_links'] == true): |
|---|
| 91 | $guid = crc32(getmypid().microtime()); |
|---|
| 92 | |
|---|
| 93 | return $binfo."&".$this->config['ns'].$this->config['feed_subscription_param']."=".$guid; |
|---|
| 94 | else: |
|---|
| 95 | return; |
|---|
| 96 | endif; |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | /** |
|---|
| 100 | * Convienence function for logging comments. |
|---|
| 101 | * |
|---|
| 102 | * @return boolean |
|---|
| 103 | */ |
|---|
| 104 | function logComment() { |
|---|
| 105 | |
|---|
| 106 | return $this->logEvent('base.processEvent',array('event' => 'base.new_comment')); |
|---|
| 107 | |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | ?> |
|---|