/** * For the use of singleton pattern. Create instance of itself and return his instance * * @return Yoast_GA_Dasboards_Graph */ public static function get_instance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; }
if (!Yoast_Google_Analytics::get_instance()->has_refresh_token()) { echo '<div class="ga-promote"><p>'; echo sprintf(__('Because we\'ve switched to a newer version of the Google Analytics API, you\'ll need to re-authenticate with Google Analytics. We\'re sorry for the inconvenience. You can %sre-authenticate your Google Analytics profile here%s.', 'google-analytics-for-wordpress'), '<a href=" ' . admin_url('admin.php?page=yst_ga_settings#top#general') . '">', '</a>'); echo '</p></div>'; } else { ?> <div class="ga-form ga-form-input"> <label class="ga-form ga-form-checkbox-label ga-form-label-left"><?php echo __('Select a dimension', 'google-analytics-for-wordpress'); ?> </label> </div> <select data-rel='toggle_dimensions' id="toggle_dimensions" style="width: 350px"></select> <?php Yoast_GA_Dashboards_Display::get_instance()->display('dimensions'); } } } else { echo '<div class="ga-promote"><p>'; echo sprintf(__('You have not yet finished setting up Google Analytics for Wordpress by Yoast. Please %sadd your Analytics profile here%s to enable tracking.', 'google-analytics-for-wordpress'), '<a href=" ' . admin_url('admin.php?page=yst_ga_settings#top#general') . '">', '</a>'); echo '</p></div>'; } ?> </div> <div id="customdimensions" class="wpseotab gatab"> <?php do_action('yst_ga_custom_dimension_add-dashboards-tab'); ?> </div>
/** * Adding dashboards for front-end * * By hook as filter: $dashboards = apply_filters( 'ga_extend_dashboards', $dashboards); * * @param array $dashboards * * @return mixed */ public function extend_dashboards($dashboards) { // Initialize the dashboard graphs Yoast_GA_Dashboards_Display::get_instance()->add_dashboards($dashboards); return $dashboards; }