config->options; // Get current options if ( isset( $_REQUEST['options']['aiwp_hidden'] ) && isset( $_REQUEST['options'] ) && ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) && 'Reset' != $who ) { $new_options = $aiwp->config->validate_data( $_REQUEST['options'] ); if ( 'tracking' == $who ) { $options['ga_anonymize_ip'] = 0; $options['ga_optout'] = 0; $options['ga_event_tracking'] = 0; $options['ga_enhanced_links'] = 0; $options['ga_event_precision'] = 0; $options['ga_event_bouncerate'] = 0; $options['ga_crossdomain_tracking'] = 0; $options['ga_aff_tracking'] = 0; $options['ga_hash_tracking'] = 0; $options['ga_formsubmit_tracking'] = 0; $options['ga_force_ssl'] = 0; $options['ga_pagescrolldepth_tracking'] = 0; $options['ga_samesite'] = ''; $options['tm_pagescrolldepth_tracking'] = 0; $options['tm_optout'] = 0; $options['amp_tracking_analytics'] = 0; $options['amp_tracking_clientidapi'] = 0; $options['amp_tracking_tagmanager'] = 0; $options['optimize_pagehiding'] = 0; $options['optimize_tracking'] = 0; $options['trackingcode_infooter'] = 0; if ( isset( $_REQUEST['options']['ga_tracking_code'] ) ) { $new_options['ga_tracking_code'] = trim( $new_options['ga_tracking_code'], "\t" ); } if ( empty( $new_options['track_exclude'] ) ) { $new_options['track_exclude'] = array(); } } elseif ( 'backend' == $who ) { $options['switch_profile'] = 0; $options['backend_item_reports'] = 0; $options['dashboard_widget'] = 0; if ( empty( $new_options['access_back'] ) ) { $new_options['access_back'][] = 'administrator'; } } elseif ( 'frontend' == $who ) { $options['frontend_item_reports'] = 0; if ( empty( $new_options['access_front'] ) ) { $new_options['access_front'][] = 'administrator'; } } elseif ( 'general' == $who ) { $options['user_api'] = 0; } elseif ( 'network' == $who ) { $options['user_api'] = 0; $options['network_mode'] = 0; $options['superadmin_tracking'] = 0; $network_settings = true; } $options = array_merge( $options, $new_options ); $aiwp->config->options = $options; $aiwp->config->set_plugin_options( $network_settings ); } return $options; } private static function navigation_tabs( $tabs ) { echo ''; } private static function html_form_begin( $text, $action, $message ) { ?>
" . esc_html( $text ) . ""; ?> array( 'class' => array(), 'id' => array() ), 'p' => array(), 'a' => array( 'href' => array() ) ) ); ?>
>
> "; if ( $title ) echo "

" . esc_html( $title ) . "

";?>

" . __( "Settings saved.", 'analytics-insights' ) . "

"; if ( ! ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) ) { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } ?>
role_names as $role => $name ) : ?>

" . __( "Settings saved.", 'analytics-insights' ) . "

"; if ( ! ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) ) { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } ?>
role_names as $role => $name ) : ?>

" . __( "Settings saved.", 'analytics-insights' ) . "

"; if ( ! ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) ) { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } if ( 'ga4tracking' == $options['tracking_type'] ) { $tabs = array( 'basic' => __( "Basic Settings", 'analytics-insights' ), 'events' => __( "Events Tracking", 'analytics-insights' ), 'custom' => __( "Custom Definitions", 'analytics-insights' ), 'exclude' => __( "Exclude Tracking", 'analytics-insights' ), 'advanced' => __( "Advanced Settings", 'analytics-insights' ), 'integration' => __( "Integration", 'analytics-insights' ) ); } else if ( 'tagmanager' == $options['tracking_type'] ) { $tabs = array( 'basic' => __( "Basic Settings", 'analytics-insights' ), 'tmdatalayervars' => __( "DataLayer Variables", 'analytics-insights' ), 'exclude' => __( "Exclude Tracking", 'analytics-insights' ), 'tmadvanced' => __( "Advanced Settings", 'analytics-insights' ), 'tmintegration' => __( "Integration", 'analytics-insights' ) ); } else { $tabs = array( 'basic' => __( "Basic Settings", 'analytics-insights' ) ); } ?>
config->options['webstream_jail'] ) : ?> config->options['ga4_webstreams_list'], $aiwp->config->options['webstream_jail'] ); ?>
" . __( "Stream ID:", 'analytics-insights' ) . "\t" . esc_html( $webstream_info[1] ) . "
" . __( "Stream URL:", 'analytics-insights' ) . "\t" . esc_html( $webstream_info[2] ) . "
" . __( "Measurement ID:", 'analytics-insights' ) . "\t" . esc_html( $webstream_info[3] ) . "
" . __( "Time Zone:", 'analytics-insights' ) . "\t" . esc_html( $webstream_info[5] );?>
%
role_names as $role => $name ) : ?>
config->options ); $options = self::update_options( 'frontend' ); ?> __( "Errors & Details", 'analytics-insights' ), 'config' => __( "Plugin Settings", 'analytics-insights' ), 'sysinfo' => __( "System", 'analytics-insights' ) ); ?>
' . __("Count: ", 'analytics-insights') . '' . (int)$errors_count;?>
' . __("Ajax Error Code: ", 'analytics-insights') . '' . esc_html( $error_ajax );?>
' . __("API Error Code: ", 'analytics-insights') . '' . esc_html( $error_code );?>
' . __("API Error Reason: ", 'analytics-insights') . '' . "\n" . esc_html( $error_reason );?>
' . __("API Error Details: ", 'analytics-insights') . '' . "\n" . esc_html( $error_details );?>


'. esc_html( $sampling['date'] ) . '' );?>
'. esc_html( $sampling['percent'] ) . '' );?>
'. esc_html( $sampling['sessions'] ) . '' ); ?>




%1$s %2$s

', __( 'Loading the required libraries. If this results in a blank screen or a fatal error, try this solution:', 'analytics-insights' ), __( 'Library conflicts between WordPress plugins', 'analytics-insights' ) ); if ( null === $aiwp->gapi_controller ) { $aiwp->gapi_controller = new AIWP_GAPI_Controller(); } echo ''; if ( isset( $_REQUEST['aiwp_access_code'] ) || isset( $_REQUEST['code'] ) ){ if ( isset( $_REQUEST['state'] ) && wp_verify_nonce( $_REQUEST['state'], 'aiwp_state' ) ) { if ( isset( $_REQUEST['code'] ) ){ $aiwp_access_code = sanitize_text_field( $_REQUEST['code'] ); } else { $aiwp_access_code = sanitize_text_field( $_REQUEST['aiwp_access_code'] ); } AIWP_Tools::delete_cache( 'api_errors' ); AIWP_Tools::delete_cache( 'ajax_errors' ); $token = $aiwp->gapi_controller->authenticate( $aiwp_access_code ); $aiwp->config->options['token'] = $token; $aiwp->config->set_plugin_options(); $options = self::update_options( 'general' ); $message = "

" . __( "Plugin authorization succeeded.", 'analytics-insights' ) . "

"; if ( $aiwp->config->options['token'] ) { $webstreams = $aiwp->gapi_controller->refresh_profiles_ga4(); if ( is_array( $webstreams ) && ! empty( $webstreams ) ) { $aiwp->config->options['ga4_webstreams_list'] = $webstreams; if ( ! $aiwp->config->options['webstream_jail'] ) { $property = AIWP_Tools::guess_default_domain( $webstreams, 2 ); $aiwp->config->options['webstream_jail'] = $property; } $aiwp->config->set_plugin_options(); $options = self::update_options( 'general' ); } } } } if ( isset( $_REQUEST['Clear'] ) ) { if ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) { AIWP_Tools::clear_cache(); $message = "

" . __( "Cleared Cache.", 'analytics-insights' ) . "

"; } else { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } if ( isset( $_REQUEST['Reset'] ) ) { if ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) { $aiwp->gapi_controller->reset_token( true, true ); AIWP_Tools::clear_cache(); $message = "

" . __( "Token Reseted and Revoked.", 'analytics-insights' ) . "

"; $options = self::update_options( 'Reset' ); } else { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } if ( isset( $_REQUEST['Reset_Err'] ) ) { if ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) { AIWP_Tools::delete_cache( 'api_errors' ); AIWP_Tools::delete_cache( 'ajax_errors' ); $message = "

" . __( "All errors reseted.", 'analytics-insights' ) . "

"; } else { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } if ( isset( $_REQUEST['options']['aiwp_hidden'] ) && ! isset( $_REQUEST['Clear'] ) && ! isset( $_REQUEST['Reset'] ) && ! isset( $_REQUEST['Reset_Err'] ) ) { $message = "

" . __( "Settings saved.", 'analytics-insights' ) . "

"; if ( ! ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) ) { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } if ( isset( $_REQUEST['Hide'] ) ) { if ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) { $message = "

" . __( "All other domains/properties were removed.", 'analytics-insights' ) . "

"; $lock_property = AIWP_Tools::get_selected_profile( $aiwp->config->options['ga4_webstreams_list'], $aiwp->config->options['webstream_jail'] ); if ( empty( $lock_property ) ) { $aiwp->config->options['ga4_webstreams_list'] = ''; } else { $aiwp->config->options['ga4_webstreams_list'] = array( $lock_property ); } $options = self::update_options( 'general' ); } else { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } ?> config->options['ga4_webstreams_list'] ) ) : ?>
%2$s', 'https://deconf.com/how-to-add-google-analytics-to-wordpress-easy-way/?utm_source=aiwp_config&utm_medium=link&utm_content=authorization-tutorial&utm_campaign=aiwp', __("step-by-step tutorial", 'analytics-insights')));?>
onchange="this.form.submit()" />
config->options['ga4_webstreams_list'], $aiwp->config->options['webstream_jail'] ); ?>
" . __( "Stream ID:", 'analytics-insights' ) . "\t" . esc_html( $webstream_info[1] ) . "
" . __( "Stream URL:", 'analytics-insights' ) . "\t" . esc_html( $webstream_info[2] ) . "
" . __( "Measurement ID:", 'analytics-insights' ) . "\t" . esc_html( $webstream_info[3] ) . "
" . __( "Time Zone:", 'analytics-insights' ) . "\t" . esc_html( $webstream_info[5] );?>
 
 
1 ) ): ?> " />
gapi_controller->createAuthUrl();?>

' . __( 'Loading the required libraries. If this results in a blank screen or a fatal error, try this solution:', 'analytics-insights' ) . ' Library conflicts between WordPress plugins

'; if ( null === $aiwp->gapi_controller ) { $aiwp->gapi_controller = new AIWP_GAPI_Controller(); } echo ''; if ( isset( $_REQUEST['aiwp_access_code'] ) || isset( $_REQUEST['code'] ) ){ if ( isset( $_REQUEST['state'] ) && wp_verify_nonce( $_REQUEST['state'], 'aiwp_state' ) ) { if ( isset( $_REQUEST['code'] ) ){ $aiwp_access_code = sanitize_text_field( $_REQUEST['code'] ); } else { $aiwp_access_code = sanitize_text_field( $_REQUEST['aiwp_access_code'] ); } $aiwp_access_code = sanitize_text_field( $_REQUEST['aiwp_access_code'] ); $token = $aiwp->gapi_controller->authenticate( $aiwp_access_code ); $aiwp->config->options['token'] = $token; $aiwp->config->set_plugin_options( true ); $options = self::update_options( 'network' ); $message = "

" . __( "Plugin authorization succeeded.", 'analytics-insights' ) . "

"; if ( is_multisite() ) { // Cleanup errors on the entire network foreach ( AIWP_Tools::get_sites( array( 'number' => apply_filters( 'aiwp_sites_limit', 100 ) ) ) as $blog ) { switch_to_blog( $blog['blog_id'] ); AIWP_Tools::delete_cache( 'api_errors' ); AIWP_Tools::delete_cache( 'ajax_errors' ); restore_current_blog(); } } else { AIWP_Tools::delete_cache( 'api_errors' ); AIWP_Tools::delete_cache( 'ajax_errors' ); } if ( $aiwp->config->options['token'] ) { $webstreams = $aiwp->gapi_controller->refresh_profiles_ga4(); if ( is_array( $webstreams ) && ! empty( $webstreams ) ) { $aiwp->config->options['ga4_webstreams_list'] = $webstreams; if ( isset( $aiwp->config->options['webstream_jail'] ) && ! $aiwp->config->options['webstream_jail'] ) { // $property = AIWP_Tools::guess_default_domain( $webstreams, 2 ); // $aiwp->config->options['webstream_jail'] = $property; } $aiwp->config->set_plugin_options( true ); $options = self::update_options( 'network' ); } } } } if ( isset( $_REQUEST['Refresh'] ) ) { if ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) { $aiwp->config->options['ga4_webstreams_list'] = array(); $message = "

" . __( "Properties refreshed.", 'analytics-insights' ) . "

"; $options = self::update_options( 'network' ); if ( $aiwp->config->options['token'] ) { if ( ! empty( $aiwp->config->options['ga4_webstreams_list'] ) ) { $webstreams = $aiwp->config->options['ga4_webstreams_list']; } else { $webstreams = $aiwp->gapi_controller->refresh_profiles_ga4(); } if ( $webstreams ) { $aiwp->config->options['ga4_webstreams_list'] = $webstreams; if ( isset( $aiwp->config->options['webstream_jail'] ) && ! $aiwp->config->options['webstream_jail'] ) { // $property = AIWP_Tools::guess_default_domain( $webstreams, 2 ); // $aiwp->config->options['webstream_jail'] = $property; } $aiwp->config->set_plugin_options( true ); $options = self::update_options( 'network' ); } } } else { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } if ( isset( $_REQUEST['Clear'] ) ) { if ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) { AIWP_Tools::clear_cache(); $message = "

" . __( "Cleared Cache.", 'analytics-insights' ) . "

"; } else { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } if ( isset( $_REQUEST['Reset'] ) ) { if ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) { $aiwp->gapi_controller->reset_token( true, true ); AIWP_Tools::clear_cache(); $message = "

" . __( "Token Reseted and Revoked.", 'analytics-insights' ) . "

"; $options = self::update_options( 'Reset' ); } else { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } if ( isset( $_REQUEST['options']['aiwp_hidden'] ) && ! isset( $_REQUEST['Clear'] ) && ! isset( $_REQUEST['Reset'] ) && ! isset( $_REQUEST['Refresh'] ) ) { $message = "

" . __( "Settings saved.", 'analytics-insights' ) . "

"; if ( ! ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) ) { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } if ( isset( $_REQUEST['Hide'] ) ) { if ( isset( $_REQUEST['aiwp_security'] ) && wp_verify_nonce( $_REQUEST['aiwp_security'], 'aiwp_form' ) ) { $message = "

" . __( "All other domains/properties were removed.", 'analytics-insights' ) . "

"; $lock_property = AIWP_Tools::get_selected_profile( $aiwp->config->options['ga4_webstreams_list'], $aiwp->config->options['webstream_jail'] ); if ( empty( $lock_property ) ) { $aiwp->config->options['ga4_webstreams_list'] = array(); } else { $aiwp->config->options['ga4_webstreams_list'] = array( $lock_property ); } $options = self::update_options( 'network' ); } else { $message = "

" . __( "You do not have sufficient permissions to access this page.", 'analytics-insights' ) . "

"; } } ?> apply_filters( 'aiwp_sites_limit', 100 ) ) ) as $blog ) : ?>
%2$s', 'https://deconf.com/how-to-add-google-analytics-to-wordpress-easy-way/?utm_source=aiwp_config&utm_medium=link&utm_content=authorizarion-screen&utm_campaign=aiwp', __("step-by-step tutorial", 'analytics-insights')));?>
onchange="this.form.submit()" />
gapi_controller->createAuthUrl();?>