diff --git a/.wordpress-org/banner-1544x500.jpg b/.wordpress-org/banner-1544x500.jpg new file mode 100644 index 0000000..6d8c447 Binary files /dev/null and b/.wordpress-org/banner-1544x500.jpg differ diff --git a/.wordpress-org/banner-722-250.jpg b/.wordpress-org/banner-722-250.jpg new file mode 100644 index 0000000..89f2932 Binary files /dev/null and b/.wordpress-org/banner-722-250.jpg differ diff --git a/.wordpress-org/icon-128x128.jpg b/.wordpress-org/icon-128x128.jpg new file mode 100644 index 0000000..a40d3d7 Binary files /dev/null and b/.wordpress-org/icon-128x128.jpg differ diff --git a/.wordpress-org/icon-256x256.jpg b/.wordpress-org/icon-256x256.jpg new file mode 100644 index 0000000..ccbe986 Binary files /dev/null and b/.wordpress-org/icon-256x256.jpg differ diff --git a/README.md b/README.md index 134415b..7167b05 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ The official plugin for integrating Open Web Analytics with WordPress based web ## Features - - Track all public web pages - Track WordPress admin interface pages - Track internal WordPress actions (New Post, Page Edit, comment, etc.) diff --git a/README.txt b/README.txt index a92b8a0..fc7f319 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -=== Open Web Analytics for WordPress === +=== Open Web Analytics for WordPress === Contributors: padams Donate link: http://paypal.me/openwebanalytics @@ -13,7 +13,7 @@ The official plugin for integrating Open Web Analytics with WordPress based web == Description == -Open Web Analytics is an open source alternative to commercial tools such as Google Analytics. Stay in control of the data you collect about the use of your website or app. This plugin does NOT install an instance of OWA server. It requires that you have admin access to a running instance of OWA. +Open Web Analytics is an open source alternative to commercial tools such as Google Analytics. Stay in control of the data you collect about the users of your website or app. This plugin does NOT install an instance of OWA server. It requires that you have admin access to a running instance of OWA. = FEATURES = diff --git a/owa-plugin.php b/owa-plugin.php index 60bfd7d..d366c29 100644 --- a/owa-plugin.php +++ b/owa-plugin.php @@ -64,6 +64,8 @@ class owa_wp_plugin extends module { // SDK singleton var $owaSdk = ''; + var $adminMsgs = []; + /** * Constructor * @@ -162,18 +164,27 @@ function _init() { add_action('wpmu_new_blog', array($this, 'createTrackedSiteForNewBlog'), 10, 6); // remove this if uneeded - if ( false ) { + if ( ! $this->isOwaReadyToTrack() ) { - add_action('admin_notices', array($this, 'showNag') ); - } + $this->adminMsgs[] = ['Open Web Analytics requires a valid API Key, Endpoint, and Site ID before tracking can begin.', 'notice-warning']; + + } + + add_action('admin_notices', array( $this, 'showNag') ); } } - function showNag() { + function showNag( $msg ) { - echo '

'. 'Open Web Analytics updates are required before tracking can continue. Please update now!

'; + if ( $this->adminMsgs ) { + + foreach ( $this->adminMsgs as $msg ) { + + _e( sprintf( '

%s

', esc_attr( $msg[1] ), $msg[0] ) ); + } + } } @@ -387,6 +398,21 @@ function cmdsToString() { return $out; } + function isOwaReadyToTrack() { + + + if ( $this->getOption( 'owaEndpoint' ) && $this->getOption( 'apiKey' ) && $this->getOption('siteId') ) { + + return true; + } + + } + + function makeOwaInstanceValidationHash() { + + + } + // init the OWA SDK function initOwaSdk() { @@ -763,27 +789,24 @@ function trackCommentEditAction( $new_status, $old_status, $comment ) { } // Tracks feed requests - // @todo this needs reworking + function trackFeedRequest() { - if ( is_feed() ) { - - $owa = $this->getOwaTrackerInstance(); - - if( $owa->getSetting( 'base', 'log_feedreaders') ) { + if ( is_feed() && $this->getOption( 'trackFeeds') ) { - self::debug('Tracking WordPress feed request'); + self::debug('Tracking WordPress feed request'); + + $owa = $this->getOwaTrackerInstance(); - $event = $owa->makeEvent(); - // set event type - $event->setEventType( 'base.feed_request' ); - // determine and set the type of feed - $event->set( 'feed_format', get_query_var( 'feed' ) ); - $event->set( 'feed_subscription_id', get_query_var( 'owa_sid' ) ); - //$event->set( 'feed_subscription_id', $_GET['owa_sid'] ); - // track - $owa->trackEvent( $event ); - } + $event = $owa->makeEvent(); + // set event type + $event->setEventType( 'base.feed_request' ); + // determine and set the type of feed + $event->set( 'feed_format', get_query_var( 'feed' ) ); + $event->set( 'feed_subscription_id', get_query_var( 'owa_sid' ) ); + //$event->set( 'feed_subscription_id', $_GET['owa_sid'] ); + // track + $owa->trackEvent( $event ); } } @@ -843,7 +866,7 @@ public function registerOptions() { 'title' => 'Website ID', 'page_name' => 'owa-wordpress', 'section' => 'general', - 'description' => 'Select the ID of the website you want to track. (must have a valid API key and endpoint)', + 'description' => 'Select the ID of the website you want to track. New tracked websites can be added via the OWA admin interface.', 'label_for' => 'Tracked website ID', 'length' => 90, 'error_message' => '', @@ -882,7 +905,7 @@ public function registerOptions() { 'trackFeeds' => array( - 'default_value' => true, + 'default_value' => false, 'field' => array( 'type' => 'boolean', 'title' => 'Track Feed Requests', @@ -1080,7 +1103,20 @@ function pageController( $params = array() ) { $url = $this->getOption('owaEndpoint'); // insert link to OWA endpoint - echo sprintf('
View OWA Dashboard', $url); + + if ( ! current_user_can( 'manage_options' ) ) { + + wp_die(__( 'You do not have sufficient permissions to access this page!' ) ); + } + + echo '
'; + echo '

'; + echo sprintf('

%s

', 'Analytics' ); + echo 'Click the link below to view analytics in your OWA instance.'; + + echo sprintf('
Launch your OWA Dashboard', $url); + + echo '
'; } /**