Exemplo n.º 1
0
 public static function hour($all = false)
 {
     DigitalPointBetterAnalytics_Model_Widget::getStatsWidgetData();
     if (get_transient('ba_exp_live') || date('G', current_time('timestamp')) == 0) {
         $betterAnalyticsOptions = get_option('better_analytics');
         if ($profile = DigitalPointBetterAnalytics_Helper_Reporting::getInstance()->getProfileByProfileId($betterAnalyticsOptions['api']['profile'])) {
             DigitalPointBetterAnalytics_Model_Experiments::getAllExperiments($profile['accountId'], $profile['webPropertyId'], $profile['id']);
         }
     }
     // This really should be a core WordPress function (deleting expired transients), but w/e...
     global $wpdb;
     if (!$all) {
         $time = time();
     } else {
         $time = time() + 86400 * 365;
     }
     $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n                WHERE a.option_name LIKE %s\n                AND a.option_name NOT LIKE %s\n                AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n                AND b.option_value < %d";
     $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_ba_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', $time));
 }
Exemplo n.º 2
0
 public function experiment_override_theme($option)
 {
     if ($this->experimentId === null) {
         if ($experimentsLive = get_transient('ba_exp_live')) {
             if (!empty($experimentsLive['theme'])) {
                 if (isset($_COOKIE[$experimentsLive['theme']['id']])) {
                     $this->experimentId = $experimentsLive['theme']['id'];
                     $this->experimentVariation = absint($_COOKIE[$this->experimentId]);
                 } elseif (DigitalPointBetterAnalytics_Model_Experiments::runExperiment($experimentsLive['theme']['coverage'])) {
                     $this->experimentId = $experimentsLive['theme']['id'];
                     $this->experimentVariation = DigitalPointBetterAnalytics_Model_Experiments::pickVariation($experimentsLive['theme']['variations']);
                     setcookie($this->experimentId, $this->experimentVariation, time() + DAY_IN_SECONDS * 180, '/');
                 }
                 if ($this->experimentVariation > 0) {
                     $this->experimentTheme = $experimentsLive['theme']['variations'][$this->experimentVariation]['theme'];
                     return $this->experimentTheme;
                 }
             }
         }
     } elseif ($this->experimentTheme !== null) {
         return $this->experimentTheme;
     }
     return $option;
 }
Exemplo n.º 3
0
 protected function column_status($item)
 {
     echo DigitalPointBetterAnalytics_Model_Experiments::getStatusNameByCode($item['status']);
 }
Exemplo n.º 4
0
				<h2>' . esc_html__('Experiments', 'better-analytics') . ' <a href="' . add_query_arg(array('action' => 'create_edit'), esc_url(menu_page_url('better-analytics_experiments', false))) . '" class="add-new-h2">' . esc_html__('Add New', 'better-analytics') . '</a>' . '</h2>

		<form method="post" action="' . esc_url(menu_page_url('better-analytics_experiments', false)) . '">
			<input type="hidden" name="page" value="better-analytics_experiments"/>';
        echo $noticeAtTop;
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'activate') {
            /* translators: %1$s = <strong>, %2$s = </strong> */
            echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(esc_html__('Experiment %1$sactivated%2$s.'), '<strong>', '</strong>') . '</p></div>';
        } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'activate-selected') {
            /* translators: %1$s = <strong>, %2$s = </strong> */
            echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(esc_html__('Selected experiments %1$sactivated%2$s.'), '<strong>', '</strong>') . '</p></div>';
        } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'deactivate') {
            /* translators: %1$s = <strong>, %2$s = </strong> */
            echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(esc_html__('Experiment %1$sdeactivated%2$s.'), '<strong>', '</strong>') . '</p></div>';
        } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'deactivate-selected') {
            /* translators: %1$s = <strong>, %2$s = </strong> */
            echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(esc_html__('Selected experiments %1$sdeactivated%2$s.'), '<strong>', '</strong>') . '</p></div>';
        }
        global $totals;
        $experiments = $totals = array();
        if ($profile = $reportingClass->getProfileByProfileId($betterAnalyticsOptions['api']['profile'])) {
            $experiments = DigitalPointBetterAnalytics_Model_Experiments::getAllExperiments($profile['accountId'], $profile['webPropertyId'], $profile['id']);
            $totals = DigitalPointBetterAnalytics_Model_Reporting::getExperimentTotals($experiments);
        }
        $goalTable = new DigitalPointBetterAnalytics_Formatting_ExperimentTable(array('plural' => 'experiments', 'experiments' => $experiments));
        $goalTable->prepare_items();
        $goalTable->views();
        $goalTable->display();
        echo '</form></div>';
    }
}
Exemplo n.º 5
0
 protected function column_status($item)
 {
     echo DigitalPointBetterAnalytics_Model_Experiments::getStatusNameByCode($item['status']) . ($item['status'] == 'DRAFT' ? '<a href="' . wp_nonce_url(add_query_arg(array('id' => $item['id'], 'action' => 'start'), $this->_getCurrentUrl()), 'start-experiment') . '" class="button button-primary confirm-prompt" data-confirm="' . esc_attr__('Are you sure you want to start this experiment?', 'better-analytics') . '">' . esc_html__('Start', 'better-analytics') . '</a>' : ($item['status'] == 'RUNNING' ? '<a href="' . wp_nonce_url(add_query_arg(array('id' => $item['id'], 'action' => 'end'), $this->_getCurrentUrl()), 'end-experiment') . '" class="button button-primary confirm-prompt" data-confirm="' . esc_attr__('Are you sure you want to permanently end this experiment?  There is no undo/restart.', 'better-analytics') . '">' . esc_html__('End', 'better-analytics') . '</a>' : ''));
 }