o->data['google_id'] ) || ( $this->o->data['google_id'] == '' ) ) { return; } add_action( 'wp_loaded', array( $this, 'wp_loaded' ) ); } /** * This method will check if showing google tracking code is applicable */ public function wp_loaded() { global $current_user; /* if we are in admin panel and we hide google code for admins then let's get out of here */ if ( is_admin() && isset( $this->o->data['hide-in_admin_panel'] ) && ( $this->o->data['hide-in_admin_panel'] ) ) { return; } /* if current user is logged in and we want to hide google code for logged users... you know what to do */ if ( ( $current_user->ID != 0 ) && isset( $this->o->data['hide-for_logged_users'] ) && $this->o->data['hide-for_logged_users'] ) { return; } /* So, we may add google tracking code, let's find out where... */ if ( isset( $this->o->data['move-to_footer'] ) && $this->o->data['move-to_footer'] ) { /* in the footer */ if ( is_admin() ) { /* footer in admin area */ add_action( 'admin_footer', array( $this, 'print_code' ), 9999 ); } else { /* footer on common page */ add_action( 'wp_footer', array( $this, 'print_code' ), 9999 ); } } else { /* in the head section */ if ( is_admin() ) { /* head section in admin area */ add_action( 'admin_head', array( $this, 'print_code' ), 9999 ); } else { /* head section on common page */ add_action( 'wp_head', array( $this, 'print_code' ), 9999 ); } } } /** * This method is responsible for printing google analytics tracking code */ public function print_code() { if ( isset( $this->o->data['use_hooks'] ) && ( $this->o->data['use_hooks'] ) ) { $use_hooks = true; } else { $use_hooks = false; } if ( isset( $this->o->data['add-plugin_info'] ) && ( $this->o->data['add-plugin_info'] ) ) { $add_info = true; } else { $add_info = false; } if ( $use_hooks ) { do_action( 'pp_google_analytics_head_before' ); } $c = ''; if ( $add_info ) { $c.= '' . PHP_EOL; } $c.= " " . PHP_EOL; if ( $use_hooks ) { $c = apply_filters( 'pp_google_analytics_head_output', $c ); } echo $c; if ( $use_hooks ) { do_action( 'pp_google_analytics_head_after' ); } } /** * This method will hook into admin_notices action, if there is no Google ID code. */ public function id_admin_notice() { if ( !isset( $this->o->data['google_id'] ) || ( $this->o->data['google_id'] == '' ) ) { add_action( 'admin_notices', array( $this, 'admin_notices' ) ); } } /** * This method will show notice about empty google id slot */ public function admin_notices() { global $pagenow; /** * Show notice everywhere in the admin panel, except our own settings page. */ if ( ( $pagenow != 'options-general.php' ) || ( ( $pagenow == 'options-general.php' ) && !isset( $_GET['page'] ) ) || ( isset( $_GET['page'] ) && ( $_GET['page'] != OPTION_SLUG ) ) ) { echo '
'; printf( __( 'Please remember to setup Google Tracking ID in order to use Google Analytics Head plugin!', 'analytics-head' ), 'options-general.php?page=' . OPTION_SLUG ); echo '