Function Reference: geodir_detail_page_google_analytics

Summary

Outputs the google analytics section on details page.

Description

Outputs the google analytics html if the current logged in user owns the post.

Global Values

$post
(WP_Post|null) (required) The current post, if available.

Default: None

Package

GeoDirectory

Change Log

Since: 1.0.0

Actions

‘geodir_before_google_analytics’ [Line: 531]

‘geodir_after_google_analytics’ [Line: 1064]

Filters

‘geodir_google_analytics_refresh_time’ [Line: 541]

‘geodir_google_analytic_html’ [Line: 1074]

Source File

geodir_detail_page_google_analytics() is located in geodirectory_hooks_actions.php [Line: 512]

Source Code

function geodir_detail_page_google_analytics()
{
    global $post,$preview;
    if($preview){return '';}
    $package_info = array();
    $package_info = geodir_post_package_info($package_info, $post);

    $id = trim(get_option('geodir_ga_account_id'));

    if (!$id) {
        return; //if no Google Analytics ID then bail.
    }

    ob_start(); // Start buffering;
    /**
     * This is called before the edit post link html in the function geodir_detail_page_google_analytics()
     *
     * @since 1.0.0
     */
    do_action('geodir_before_google_analytics');
    
    $refresh_time = get_option('geodir_ga_refresh_time', 5);
    /**
     * Filter the time interval to check & refresh new users results.
     *
     * @since 1.5.9
     *
     * @param int $refresh_time Time interval to check & refresh new users results.
     */
    $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
    $refresh_time = absint($refresh_time * 1000);
    
    $hide_refresh = get_option('geodir_ga_auto_refresh');
    
    $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
    if (get_option('geodir_ga_stats') && is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
        $page_url = urlencode($_SERVER['REQUEST_URI']);
        ?>
        
        
        
        
        
        

    ' . $content_html . '
'; if ((int)get_option('geodir_disable_google_analytics_section') != 1) { /** * Filter the geodir_edit_post_link() function content. * * @param string $content_html The output html of the geodir_edit_post_link() function. */ echo $content_html = apply_filters('geodir_google_analytic_html', $content_html); } }