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)); }
<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>'; } }