From f7dc798f1edb6df9c2662f19cd8057a99a399dfd Mon Sep 17 00:00:00 2001 From: filesite Date: Mon, 6 May 2024 08:21:24 +0000 Subject: [PATCH] add ga code support --- conf/app.php | 3 +++ plugins/Html.php | 20 ++++++++++++++++++++ themes/beauty/views/layout/main.php | 1 + themes/googleimage/views/layout/main.php | 1 + themes/manual/views/layout/main.php | 1 + themes/tajian/views/layout/index.php | 1 + themes/tajian/views/layout/main.php | 1 + themes/videoblog/views/layout/main.php | 1 + themes/webdirectory/views/layout/main.php | 1 + views/layout/error.php | 9 +++++++-- views/layout/main.php | 9 +++++++-- 11 files changed, 44 insertions(+), 4 deletions(-) diff --git a/conf/app.php b/conf/app.php index 9ab6d76..5878962 100644 --- a/conf/app.php +++ b/conf/app.php @@ -127,6 +127,9 @@ $configs = array( 'service_3rd_api_key' => '你的密钥', 'sms_code_cache_time' => 600, //短信验证码缓存时长,单位:秒 + //Google Analytics MEASUREMENT ID + 'GA_MEASUREMENT_ID' => 'G-09MWT3Z9R0', + ); //自定义配置支持 diff --git a/plugins/Html.php b/plugins/Html.php index ee2b1fe..36eefa9 100644 --- a/plugins/Html.php +++ b/plugins/Html.php @@ -73,4 +73,24 @@ Class Html { return $sorted; } + //生成GA统计代码 + public static function getGACode() { + $msid = !empty(FSC::$app['config']['GA_MEASUREMENT_ID']) ? FSC::$app['config']['GA_MEASUREMENT_ID'] : ''; + if (empty($msid)) {return '';} + + $gacode = << + + +eof; + + return $gacode; + } + } diff --git a/themes/beauty/views/layout/main.php b/themes/beauty/views/layout/main.php index 9ae238c..ff0df17 100644 --- a/themes/beauty/views/layout/main.php +++ b/themes/beauty/views/layout/main.php @@ -91,5 +91,6 @@ eof; + \ No newline at end of file diff --git a/themes/googleimage/views/layout/main.php b/themes/googleimage/views/layout/main.php index 3702b2e..a6dd83b 100644 --- a/themes/googleimage/views/layout/main.php +++ b/themes/googleimage/views/layout/main.php @@ -113,5 +113,6 @@ eof; + diff --git a/themes/manual/views/layout/main.php b/themes/manual/views/layout/main.php index 326067a..f4a7786 100644 --- a/themes/manual/views/layout/main.php +++ b/themes/manual/views/layout/main.php @@ -42,5 +42,6 @@ include_once $viewFile; + diff --git a/themes/tajian/views/layout/index.php b/themes/tajian/views/layout/index.php index 6a59bab..0ebac68 100644 --- a/themes/tajian/views/layout/index.php +++ b/themes/tajian/views/layout/index.php @@ -52,5 +52,6 @@ if (!empty($viewFile) && file_exists($viewFile)) { + diff --git a/themes/tajian/views/layout/main.php b/themes/tajian/views/layout/main.php index 1dbf198..fe6a639 100644 --- a/themes/tajian/views/layout/main.php +++ b/themes/tajian/views/layout/main.php @@ -148,5 +148,6 @@ eof; + diff --git a/themes/videoblog/views/layout/main.php b/themes/videoblog/views/layout/main.php index 08a8bd2..b913894 100644 --- a/themes/videoblog/views/layout/main.php +++ b/themes/videoblog/views/layout/main.php @@ -74,5 +74,6 @@ eof; + diff --git a/themes/webdirectory/views/layout/main.php b/themes/webdirectory/views/layout/main.php index d7b31f2..a5ce584 100644 --- a/themes/webdirectory/views/layout/main.php +++ b/themes/webdirectory/views/layout/main.php @@ -67,5 +67,6 @@ eof; + diff --git a/views/layout/error.php b/views/layout/error.php index 5122a1d..211fe01 100644 --- a/views/layout/error.php +++ b/views/layout/error.php @@ -1,4 +1,8 @@ - + <?php echo $errors['title']; ?> @@ -14,5 +18,6 @@ h1{color:#FF0000}

Exception :

+ - + \ No newline at end of file diff --git a/views/layout/main.php b/views/layout/main.php index 84bd2ad..4136bac 100644 --- a/views/layout/main.php +++ b/views/layout/main.php @@ -1,4 +1,8 @@ - + @@ -22,5 +26,6 @@ include_once $viewFile; + - + \ No newline at end of file