/** * Init function for the settings of GA */ public function init_settings() { $this->options = $this->get_options(); $this->api = Yoast_Api_Libs::load_api_libraries(array('google', 'googleanalytics')); $dashboards = Yoast_GA_Dashboards::get_instance(); // Listener for reconnecting with google analytics $this->google_analytics_listener(); if (is_null($this->get_tracking_code()) && $this->show_admin_warning()) { add_action('admin_notices', array('Yoast_Google_Analytics_Notice', 'config_warning')); } // Check if something has went wrong with GA-api calls $has_tracking_code = !is_null($this->get_tracking_code()) && empty($this->options['manual_ua_code_field']); if ($has_tracking_code && $this->show_admin_dashboard_warning()) { Yoast_Google_Analytics::get_instance()->check_for_ga_issues(); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->handle_ga_post_request($dashboards); } /** * Show the notifications if we have one */ $this->show_notification('ga_notifications'); // Load the Google Analytics Dashboards functionality $dashboards->init_dashboards($this->get_current_profile()); }
/** * This hook runs on the shutdown to fetch data from GA */ private function init_shutdown_hook() { $this->api = Yoast_Api_Libs::load_api_libraries(array('oauth', 'googleanalytics')); // Hook the WP cron event add_action('wp', array($this, 'setup_wp_cron_aggregate')); // Hook our function to the WP cron event the fetch data daily add_action('yst_ga_aggregate_data', array($this, 'aggregate_data')); // Check if the WP cron did run on time if (isset($_GET['page']) && ($_GET['page'] === 'yst_ga_dashboard' || $_GET['page'] === 'yst_ga_settings')) { add_action('shutdown', array($this, 'check_api_call_hook')); } }
/** * Init function for the settings of GA */ public function init_settings() { $this->options = $this->get_options(); $this->api = Yoast_Api_Libs::load_api_libraries(array('google', 'googleanalytics')); $dashboards = Yoast_GA_Dashboards::get_instance(); // Listener for reconnecting with google analytics $this->google_analytics_listener(); if (is_null($this->get_tracking_code()) && $this->show_admin_warning()) { add_action('admin_notices', array('Yoast_Google_Analytics_Notice', 'config_warning')); } // Check if something has went wrong with GA-api calls $has_tracking_code = !is_null($this->get_tracking_code()) && empty($this->options['manual_ua_code_field']); if ($has_tracking_code && $this->show_admin_dashboard_warning()) { Yoast_Google_Analytics::get_instance()->check_for_ga_issues(); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!function_exists('wp_verify_nonce')) { require_once ABSPATH . 'wp-includes/pluggable.php'; } if (isset($_POST['ga-form-settings']) && wp_verify_nonce($_POST['yoast_ga_nonce'], 'save_settings')) { if (!isset($_POST['ignore_users'])) { $_POST['ignore_users'] = array(); } $dashboards_disabled = Yoast_GA_Settings::get_instance()->dashboards_disabled(); if ($dashboards_disabled == false && isset($_POST['dashboards_disabled'])) { $dashboards->reset_dashboards_data(); } // Post submitted and verified with our nonce $this->save_settings($_POST); } } /** * Show the notifications if we have one */ $this->show_notification('ga_notifications'); // Load the Google Analytics Dashboards functionality $dashboards->init_dashboards($this->get_current_profile()); }
/** * Init function for the settings of GA */ public function init_settings() { $this->options = $this->get_options(); $this->api = Yoast_Api_Libs::load_api_libraries(array('google', 'googleanalytics')); // Listener for reconnecting with google analytics $this->google_analytics_listener(); if (is_null($this->get_tracking_code()) && $this->show_admin_warning()) { add_action('admin_notices', array($this, 'config_warning')); } $last_run = get_option('yst_ga_last_wp_run'); if ($last_run === false || Yoast_GA_Utils::hours_between(strtotime($last_run), time()) >= 48) { // Show error, something went wrong if (!is_null($this->get_tracking_code()) && empty($this->options['manual_ua_code_field']) && $this->show_admin_dashboard_warning()) { add_action('admin_notices', array($this, 'warning_fetching_data')); } } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!function_exists('wp_verify_nonce')) { require_once ABSPATH . 'wp-includes/pluggable.php'; } if (isset($_POST['ga-form-settings']) && wp_verify_nonce($_POST['yoast_ga_nonce'], 'save_settings')) { if (!isset($_POST['ignore_users'])) { $_POST['ignore_users'] = array(); } // Post submitted and verified with our nonce $this->save_settings($_POST); } } /** * Show the notifications if we have one */ $this->show_notification('ga_notifications'); // Load the Google Analytics Dashboards functionality $dashboards = Yoast_GA_Dashboards::get_instance(); $dashboards->init_dashboards($this->get_current_profile()); }
/** * Count the result of activated API libs */ public function test_get_api_libs() { $total_active = count(Yoast_Api_Libs::get_api_libs()); $this->assertEquals($this->loaded_api_libs, 1); }
/** * Init function when the plugin is loaded */ public function init_ga() { new Yoast_GA_Admin_Menu($this); add_filter('plugin_action_links_' . plugin_basename(GAWP_FILE), array($this, 'add_action_links')); $this->api = Yoast_Api_Libs::load_api_libraries(array('oauth')); }
/** * Construct on the dashboards class for GA */ public function __construct() { $this->api = Yoast_Api_Libs::load_api_libraries(array('oauth')); }