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
a779923b
Commit
a779923b
authored
Apr 09, 2019
by
Vadim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 2.4
Опция Периодичность обновления счетчиков online-посетителей
parent
85473d5c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
57 deletions
+20
-57
bg_az-counter.php
bg_az-counter.php
+3
-54
options.php
inc/options.php
+16
-2
counter.js
js/counter.js
+1
-1
No files found.
bg_az-counter.php
View file @
a779923b
...
...
@@ -3,7 +3,7 @@
Plugin Name: Bg Az-Counter
Plugin URI: https://bogaiskov.ru
Description: Подсчет количества посещений страниц на базе stat.azbyka.ru
Version: 2.
3.2
Version: 2.
4
Author: VBog
Author URI: https://bogaiskov.ru
License: GPL2
...
...
@@ -37,7 +37,7 @@
if
(
!
defined
(
'ABSPATH'
)
)
{
die
(
'Sorry, you are not allowed to access this page directly.'
);
}
define
(
'BG_COUNTER_VERSION'
,
'2.
3.2
'
);
define
(
'BG_COUNTER_VERSION'
,
'2.
4
'
);
define
(
'BG_COUNTER_LOG'
,
dirname
(
__FILE__
)
.
'/bg_counter.log'
);
define
(
'BG_COUNTER_STAT_COUNTERS'
,
'https://stat.azbyka.ru/counters'
);
...
...
@@ -106,6 +106,7 @@ function bg_counter_enqueue_frontend_scripts () {
'scoreurl'
=>
BG_COUNTER_STAT_SCORE
,
// Всегда 'https://stat.azbyka.ru/item-score'
'websocket'
=>
BG_COUNTER_REALTIME_VIEW
,
// Всегда 'wss://stat.azbyka.ru/realtime-view'
'updatesocket'
=>
BG_COUNTER_REALTIME_UPDATES
,
// Всегда 'wss://stat.azbyka.ru/updates'
'updatetime'
=>
(
int
)
$option
[
'update'
],
// Время обновление счетчиков онлайн-посетителей
'project'
=>
$project
,
// Имя текущего проекта, например, '/propovedi'
'type'
=>
$type
,
// Пока только 'post' или пусто
'ID'
=>
$postID
,
// ID поста
...
...
@@ -140,55 +141,3 @@ function bg_counter_deinstall() {
include_once
(
"inc/counter.php"
);
// Запускаем голосование
include_once
(
"inc/rating.php"
);
/*****************************************************************************************
Этот блок позволяет найти на сайте посты-ссылки,
по наличию произвольного поля 'link'
Шорт-код [find_meta_link] выводит на экран список таких постов
с ссылкой на страницу его редактирования
******************************************************************************************/
// Регистрируем шорт-код find_meta_link
add_shortcode
(
'find_meta_link'
,
'find_meta_link_shortcode'
);
// [find_meta_link]
function
find_meta_link_shortcode
(
$atts
)
{
// Список типов записей имеющих страницу во форонте
$post_types
=
get_post_types
(
[
'publicly_queryable'
=>
1
]
);
$post_types
[
'page'
]
=
'page'
;
// встроенный тип не имеет publicly_queryable
unset
(
$post_types
[
'attachment'
]
);
// удалим attachment
$true_query
=
new
WP_Query
(
$true_args
);
// задаем нужные нам критерии выборки данных из БД
$args
=
array
(
'posts_per_page'
=>
-
1
,
'post_type'
=>
$post_types
,
'meta_query'
=>
array
(
array
(
'key'
=>
'link'
)
)
);
$query
=
new
WP_Query
(
$args
);
// Цикл
if
(
$query
->
have_posts
()
)
{
$quote
.=
'<ol>'
;
while
(
$query
->
have_posts
()
)
{
$query
->
the_post
();
$quote
.=
'<li><a href="'
.
site_url
()
.
'/wp-admin/post.php?post='
.
get_the_ID
()
.
'&action=edit">'
.
get_the_title
()
.
'</a></li>'
;
}
}
$quote
.=
'</ol>'
;
// Возвращаем оригинальные данные поста. Сбрасываем $post.
wp_reset_postdata
();
return
"
{
$quote
}
"
;
}
inc/options.php
View file @
a779923b
...
...
@@ -4,7 +4,7 @@
*******************************************************************************************/
// Начальные значения
add_option
(
'bg_counter_options'
,
array
(
'period'
=>
DAY_IN_SECONDS
,
'views'
=>
1
,
'now'
=>
1
,
'rate'
=>
1
,
'title'
=>
''
,
'author'
=>
''
,
'debug'
=>
0
,
'archive'
=>
0
,
'pvc'
=>
0
,
'wppp'
=>
0
,
'wppm'
=>
0
,
'bgar'
=>
0
));
add_option
(
'bg_counter_options'
,
array
(
'period'
=>
DAY_IN_SECONDS
,
'
update'
=>
3000
,
'
views'
=>
1
,
'now'
=>
1
,
'rate'
=>
1
,
'title'
=>
''
,
'author'
=>
''
,
'debug'
=>
0
,
'archive'
=>
0
,
'pvc'
=>
0
,
'wppp'
=>
0
,
'wppm'
=>
0
,
'bgar'
=>
0
));
add_option
(
'bg_pvc_loaded'
,
''
);
add_option
(
'bg_wppp_loaded'
,
''
);
add_option
(
'bg_wppm_loaded'
,
''
);
...
...
@@ -14,6 +14,10 @@ if (!isset($val['period'])) {
$val
[
'period'
]
=
DAY_IN_SECONDS
;
update_option
(
'bg_counter_period'
,
$val
[
'period'
]
);
}
if
(
!
isset
(
$val
[
'update'
]))
{
$val
[
'update'
]
=
3000
;
update_option
(
'bg_counter_period'
,
$val
[
'update'
]
);
}
if
(
!
isset
(
$val
[
'views'
]))
{
$val
[
'views'
]
=
0
;
}
...
...
@@ -188,6 +192,7 @@ function bg_counter_settings(){
// параметры: $id, $title, $callback, $page, $section, $args
add_settings_field
(
'bg_counter_period'
,
'Периодичность обработки данных'
,
'fill_bg_counter_period'
,
'bg_counter_page'
,
'section_1'
);
add_settings_field
(
'bg_counter_update'
,
'Периодичность обновления счетчиков online-посетителей'
,
'fill_bg_counter_update'
,
'bg_counter_page'
,
'section_1'
);
add_settings_field
(
'bg_counter_views'
,
'Просмотров всего'
,
'fill_bg_counter_views'
,
'bg_counter_page'
,
'section_1'
);
add_settings_field
(
'bg_counter_now'
,
'Просматривают сейчас'
,
'fill_bg_counter_now'
,
'bg_counter_page'
,
'section_1'
);
add_settings_field
(
'bg_counter_rate'
,
'Оценка пользователями'
,
'fill_bg_counter_rate'
,
'bg_counter_page'
,
'section_1'
);
...
...
@@ -202,7 +207,7 @@ function bg_counter_settings(){
}
## Заполняем опцию 1
## Заполняем опцию 1
a
function
fill_bg_counter_period
(){
$val
=
get_option
(
'bg_counter_options'
);
$val
=
$val
?
$val
[
'period'
]
:
DAY_IN_SECONDS
;
...
...
@@ -219,6 +224,15 @@ function fill_bg_counter_period(){
<?php
}
## Заполняем опцию 1b
function
fill_bg_counter_update
(){
$val
=
get_option
(
'bg_counter_options'
);
$val
=
$val
[
'update'
];
?>
<input
type=
"number"
name=
"bg_counter_options[update]"
value=
"
<?php
echo
esc_attr
(
$val
)
?>
"
step=
"100"
min=
"500"
/>
мсек.
<?php
}
## Заполняем опцию 2a
function
fill_bg_counter_views
(){
$val
=
get_option
(
'bg_counter_options'
);
...
...
js/counter.js
View file @
a779923b
...
...
@@ -62,7 +62,7 @@ jQuery( document ).ready(function() {
});
var
json
=
JSON
.
stringify
(
data
);
var
request
=
bg_counter
.
updatesocket
;
var
request
=
bg_counter
.
updatesocket
+
(
bg_counter
.
updatetime
?(
'?time='
+
bg_counter
.
updatetime
):
''
)
;
// Создаем сокет
var
updatesocket
=
new
ReconnectingWebSocket
(
request
);
// Отправляем данные, как только сокет будет подключен
...
...
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