8
plugin_path=`wp plugin path --path=$wp_install_path`
9
piwik_settings_path=$plugin_path/wp-piwik/classes/WP_Piwik_Settings.php
10
piwik_logger_path=$plugin_path/wp-piwik/classes/WP_Piwik_Logger_Dummy.php
12
wp_content_repo=`config-get wp-content`
13
piwik_url=`relation-get url`
14
piwik_token=`relation-get token`
16
if [ -z "$piwik_url" -o -z "$piwik_token" ]; then
17
echo "url and token not set yet"
22
if wp plugin --path=$wp_install_path | grep wp-piwik; then
23
juju-log "wp-piwik found, skipping installation"
25
if [ -n "$wp_content_repo" ]; then
26
juju-log "The wp-content is versioned. Please install wp-piwik plugin before continuing"
29
wp plugin install wp-piwik --path=$wp_install_path --activate
32
# FIXME: Find a way for, when executing this piece of code, the configuration
33
# is is not just saved, but the tracking is added to piwik. This happens when
34
# clicking the "Save" button at the plugin settings page.
38
/** Absolute path to the WordPress directory. */
39
if ( !defined('ABSPATH') )
40
define('ABSPATH', '$wp_install_path' . '/');
42
/** Pull in the config information */
43
require_once(ABSPATH . 'wp-load.php');
44
/** Load the piwik settings and logger files */
45
require_once('$piwik_settings_path');
46
require_once('$piwik_logger_path');
48
\$l = new WP_Piwik_Logger_Dummy('juju_dummy');
49
\$s = new WP_Piwik_Settings(\$l);
51
\$s->setGlobalOption('piwik_token', '$piwik_token');
52
\$s->setOption('piwik_token', '$piwik_token');
53
\$s->setGlobalOption('piwik_url', '$piwik_url');
54
\$s->setOption('piwik_url', '$piwik_url');
55
\$s->setGlobalOption('add_tracking_code', true);
56
\$s->setOption('add_tracking_code', true);