Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bg-az-counter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
azbyka_bg
bg-az-counter
Commits
08da5495
Commit
08da5495
authored
Apr 14, 2019
by
Vadim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 2.5
Разрешены типы : 'post', 'category', 'tag', 'index' для счетчиков учета посещения страниц и посетителей online. Для рейтинга - только 'post'.
parent
3b31c134
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
26 deletions
+61
-26
bg_az-counter.php
bg_az-counter.php
+15
-6
counter.php
inc/counter.php
+35
-8
rating.php
inc/rating.php
+11
-12
No files found.
bg_az-counter.php
View file @
08da5495
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
Plugin Name: Bg Az-Counter
Plugin Name: Bg Az-Counter
Plugin URI: https://bogaiskov.ru
Plugin URI: https://bogaiskov.ru
Description: Подсчет количества посещений страниц на базе stat.azbyka.ru
Description: Подсчет количества посещений страниц на базе stat.azbyka.ru
Version: 2.
4.12
Version: 2.
5
Author: VBog
Author: VBog
Author URI: https://bogaiskov.ru
Author URI: https://bogaiskov.ru
License: GPL2
License: GPL2
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
if
(
!
defined
(
'ABSPATH'
)
)
{
if
(
!
defined
(
'ABSPATH'
)
)
{
die
(
'Sorry, you are not allowed to access this page directly.'
);
die
(
'Sorry, you are not allowed to access this page directly.'
);
}
}
define
(
'BG_COUNTER_VERSION'
,
'2.4.
12
'
);
define
(
'BG_COUNTER_VERSION'
,
'2.4.
33
'
);
define
(
'BG_COUNTER_LOG'
,
dirname
(
__FILE__
)
.
'/bg_counter.log'
);
define
(
'BG_COUNTER_LOG'
,
dirname
(
__FILE__
)
.
'/bg_counter.log'
);
define
(
'BG_COUNTER_STAT_COUNTERS'
,
'https://stat.azbyka.ru/counters'
);
define
(
'BG_COUNTER_STAT_COUNTERS'
,
'https://stat.azbyka.ru/counters'
);
...
@@ -87,14 +87,23 @@ function bg_counter_enqueue_frontend_scripts () {
...
@@ -87,14 +87,23 @@ function bg_counter_enqueue_frontend_scripts () {
global
$project
;
global
$project
;
$option
=
get_option
(
'bg_counter_options'
);
$option
=
get_option
(
'bg_counter_options'
);
$
post
ID
=
''
;
$
the
ID
=
''
;
$type
=
''
;
$type
=
''
;
if
(
is_single
()
||
is_page
())
{
// Только записи и страницы
if
(
is_single
()
||
is_page
())
{
// Только записи и страницы
$post
=
get_post
();
$post
=
get_post
();
if
(
$post
->
post_status
==
'publish'
)
{
// Только опубликованные
if
(
$post
->
post_status
==
'publish'
)
{
// Только опубликованные
$
post
ID
=
$post
->
ID
;
$
the
ID
=
$post
->
ID
;
$type
=
'post'
;
$type
=
'post'
;
}
}
}
elseif
(
is_category
())
{
$theID
=
get_query_var
(
'cat'
);
$type
=
'category'
;
}
elseif
(
is_tag
())
{
$theID
=
get_query_var
(
'tag_id'
);
$type
=
'tag'
;
}
elseif
(
is_home
())
{
$theID
=
1
;
$type
=
'index'
;
}
}
wp_enqueue_script
(
'bg_counter_websocket'
,
plugins_url
(
'js/reconnecting-websocket.min.js'
,
__FILE__
),
false
,
BG_COUNTER_VERSION
,
true
);
wp_enqueue_script
(
'bg_counter_websocket'
,
plugins_url
(
'js/reconnecting-websocket.min.js'
,
__FILE__
),
false
,
BG_COUNTER_VERSION
,
true
);
wp_enqueue_script
(
'bg_counter_rating'
,
plugins_url
(
'js/rating.js'
,
__FILE__
),
false
,
BG_COUNTER_VERSION
,
true
);
wp_enqueue_script
(
'bg_counter_rating'
,
plugins_url
(
'js/rating.js'
,
__FILE__
),
false
,
BG_COUNTER_VERSION
,
true
);
...
@@ -108,8 +117,8 @@ function bg_counter_enqueue_frontend_scripts () {
...
@@ -108,8 +117,8 @@ function bg_counter_enqueue_frontend_scripts () {
'updatesocket'
=>
BG_COUNTER_REALTIME_UPDATES
,
// Всегда 'wss://stat.azbyka.ru/updates'
'updatesocket'
=>
BG_COUNTER_REALTIME_UPDATES
,
// Всегда 'wss://stat.azbyka.ru/updates'
'updatetime'
=>
(
int
)
$option
[
'update'
],
// Время обновление счетчиков онлайн-посетителей
'updatetime'
=>
(
int
)
$option
[
'update'
],
// Время обновление счетчиков онлайн-посетителей
'project'
=>
$project
,
// Имя текущего проекта, например, '/propovedi'
'project'
=>
$project
,
// Имя текущего проекта, например, '/propovedi'
'type'
=>
$type
,
//
Пока только 'post
' или пусто
'type'
=>
$type
,
//
Тип объекта 'post', 'category', 'tag', 'index
' или пусто
'ID'
=>
$
postID
,
// ID пос
та
'ID'
=>
$
theID
,
// ID объек
та
'votes5'
=>
'голосов'
,
'votes5'
=>
'голосов'
,
'votes2'
=>
'голоcа'
,
'votes2'
=>
'голоcа'
,
'vote1'
=>
'голос'
,
'vote1'
=>
'голос'
,
...
...
inc/counter.php
View file @
08da5495
...
@@ -147,14 +147,39 @@ function bg_az_counter_views ($type=null, $id=null, $now=null, $rate=null, $view
...
@@ -147,14 +147,39 @@ function bg_az_counter_views ($type=null, $id=null, $now=null, $rate=null, $view
global
$project
;
global
$project
;
$option
=
get_option
(
'bg_counter_options'
);
$option
=
get_option
(
'bg_counter_options'
);
if
(
is_single
()
||
is_page
())
{
if
(
is_null
(
$type
))
{
if
(
is_null
(
$id
))
{
if
(
is_single
()
||
is_page
())
{
// Только записи и страницы
if
(
!
isset
(
$post
))
$post
=
get_post
();
$post
=
get_post
();
$id
=
$post
->
ID
;
if
(
$post
->
post_status
==
'publish'
)
{
// Только опубликованные
}
$id
=
$post
->
ID
;
if
(
is_null
(
$type
))
{
$type
=
'post'
;
$type
=
'post'
;
}
else
return
false
;
}
}
elseif
(
is_category
())
{
$id
=
get_query_var
(
'cat'
);
$type
=
'category'
;
}
elseif
(
is_tag
())
{
$id
=
get_query_var
(
'tag_id'
);
$type
=
'tag'
;
}
elseif
(
is_home
())
{
$id
=
1
;
$type
=
'index'
;
}
else
return
false
;
}
if
(
is_null
(
$id
))
{
if
(
$type
==
'post'
)
{
// Только записи и страницы
$post
=
get_post
();
if
(
$post
->
post_status
==
'publish'
)
{
// Только опубликованные
$id
=
$post
->
ID
;
}
else
return
false
;
}
elseif
(
$type
==
'category'
)
{
$cat
=
get_the_category
();
$id
=
$cat
->
cat_ID
;
}
elseif
(
$type
==
'tag'
)
{
$tags
=
get_the_tags
();
$id
=
$tags
->
term_id
;
}
elseif
(
$type
==
'index'
)
{
$id
=
1
;
}
else
return
false
;
}
}
if
(
is_null
(
$views
))
{
if
(
is_null
(
$views
))
{
$views
=
$option
[
'views'
];
$views
=
$option
[
'views'
];
...
@@ -165,6 +190,8 @@ function bg_az_counter_views ($type=null, $id=null, $now=null, $rate=null, $view
...
@@ -165,6 +190,8 @@ function bg_az_counter_views ($type=null, $id=null, $now=null, $rate=null, $view
if
(
is_null
(
$rate
))
{
if
(
is_null
(
$rate
))
{
$rate
=
$option
[
'rate'
];
$rate
=
$option
[
'rate'
];
}
}
if
(
$type
!=
'post'
)
$rate
=
null
;
if
(
$id
)
{
if
(
$id
)
{
$link
=
get_permalink
(
$id
);
$link
=
get_permalink
(
$id
);
// Получить имя проекта по ссылке
// Получить имя проекта по ссылке
...
...
inc/rating.php
View file @
08da5495
...
@@ -35,18 +35,17 @@ GET /item-score/project/test/author/1
...
@@ -35,18 +35,17 @@ GET /item-score/project/test/author/1
function
bg_az_counter_rating
(
$type
,
$id
)
{
function
bg_az_counter_rating
(
$type
,
$id
)
{
global
$project
;
global
$project
;
if
(
!
$id
)
return
false
;
if
(
!
get_the_ID
())
return
false
;
if
(
$type
==
'post'
)
{
// Список типов записей имеющих страницу во фронте
// Список типов записей имеющих страницу во форонте
$post_types
=
get_post_types
(
[
'publicly_queryable'
=>
1
]
);
$post_types
=
get_post_types
(
[
'publicly_queryable'
=>
1
]
);
$post_types
[
'page'
]
=
'page'
;
// встроенный тип не имеет publicly_queryable
$post_types
[
'page'
]
=
'page'
;
// встроенный тип не имеет publicly_queryable
unset
(
$post_types
[
'attachment'
]
);
// удалим attachment
unset
(
$post_types
[
'attachment'
]
);
// удалим attachment
$the_type
=
get_post_type
(
$id
);
$type
=
get_post_type
();
if
(
!
in_array
(
$the_type
,
$post_types
))
return
false
;
if
(
!
in_array
(
$type
,
$post_types
))
return
false
;
if
(
get_post_status
(
$id
)
!=
'publish'
)
return
false
;
}
else
return
false
;
if
(
get_post_status
()
!=
'publish'
)
return
false
;
$option
=
get_option
(
'bg_counter_options'
);
$option
=
get_option
(
'bg_counter_options'
);
if
(
$option
[
'title'
])
$page_title
=
$option
[
'title'
];
if
(
$option
[
'title'
])
$page_title
=
$option
[
'title'
];
else
$page_title
=
get_the_title
(
$id
);
else
$page_title
=
get_the_title
(
$id
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment