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
d6cfc0b9
Commit
d6cfc0b9
authored
Apr 06, 2019
by
Vadim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 2.2.1
1. Опция Оценки пользователей 2. Readme
parent
bd9c416c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
39 deletions
+47
-39
README.md
README.md
+0
-0
bg_az-counter.php
bg_az-counter.php
+2
-2
counter.php
inc/counter.php
+9
-5
options.php
inc/options.php
+36
-32
No files found.
README.md
View file @
d6cfc0b9
This diff is collapsed.
Click to expand it.
bg_az-counter.php
View file @
d6cfc0b9
...
@@ -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.2
Version: 2.2
.1
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.2'
);
define
(
'BG_COUNTER_VERSION'
,
'2.2
.1
'
);
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'
);
...
...
inc/counter.php
View file @
d6cfc0b9
...
@@ -143,8 +143,9 @@ function setAllCounts ($request) {
...
@@ -143,8 +143,9 @@ function setAllCounts ($request) {
Отображает разметку текста для отображения кол-ва просмотров
Отображает разметку текста для отображения кол-ва просмотров
и кол-ва читающих пост пользователей
и кол-ва читающих пост пользователей
******************************************************************************************/
******************************************************************************************/
function
bg_az_counter_views
(
$type
=
null
,
$id
=
null
,
$now
=
null
)
{
function
bg_az_counter_views
(
$type
=
null
,
$id
=
null
,
$now
=
null
,
$rate
=
null
)
{
global
$project
;
global
$project
;
$option
=
get_option
(
'bg_counter_options'
);
if
(
is_single
()
||
is_page
())
{
if
(
is_single
()
||
is_page
())
{
if
(
is_null
(
$id
))
{
if
(
is_null
(
$id
))
{
...
@@ -156,9 +157,11 @@ function bg_az_counter_views ($type=null, $id=null, $now=null) {
...
@@ -156,9 +157,11 @@ function bg_az_counter_views ($type=null, $id=null, $now=null) {
}
}
}
}
if
(
is_null
(
$now
))
{
if
(
is_null
(
$now
))
{
$option
=
get_option
(
'bg_counter_options'
);
$now
=
$option
[
'now'
];
$now
=
$option
[
'now'
];
}
}
if
(
is_null
(
$rate
))
{
$rate
=
$option
[
'rate'
];
}
$link
=
get_permalink
(
$id
);
$link
=
get_permalink
(
$id
);
// Получить имя проекта по ссылке
// Получить имя проекта по ссылке
if
(
wp_parse_url
(
$link
,
PHP_URL_HOST
)
==
'azbyka.ru'
)
{
if
(
wp_parse_url
(
$link
,
PHP_URL_HOST
)
==
'azbyka.ru'
)
{
...
@@ -178,7 +181,7 @@ function bg_az_counter_views ($type=null, $id=null, $now=null) {
...
@@ -178,7 +181,7 @@ function bg_az_counter_views ($type=null, $id=null, $now=null) {
$views
=
'<i title="Просмотры страницы" class="fa fa-eye"></i> <span class="bg-az-counter-views"></span>'
;
$views
=
'<i title="Просмотры страницы" class="fa fa-eye"></i> <span class="bg-az-counter-views"></span>'
;
$users
=
' <i title="Сейчас читают страницу" class="fa fa-user-o"></i> <span class="bg-az-counter-now"></span>'
;
$users
=
' <i title="Сейчас читают страницу" class="fa fa-user-o"></i> <span class="bg-az-counter-now"></span>'
;
$score
=
' <i title="Оценка пользователей" class="fa fa-star-o"></i> <span class="bg-az-counter-score"></span>'
;
$score
=
' <i title="Оценка пользователей" class="fa fa-star-o"></i> <span class="bg-az-counter-score"></span>'
;
$quote
=
'<span class="bg-az-counter" data-type="'
.
$type
.
'" data-ID="'
.
$id
.
'">'
.
$views
.
(
$now
?
$users
:
''
)
.
$score
.
'</span>'
;
$quote
=
'<span class="bg-az-counter" data-type="'
.
$type
.
'" data-ID="'
.
$id
.
'">'
.
$views
.
(
$now
?
$users
:
''
)
.
(
$rate
?
$score
:
''
)
.
'</span>'
;
return
$quote
;
return
$quote
;
}
else
return
""
;
}
else
return
""
;
}
}
...
@@ -199,9 +202,10 @@ function bg_counter_shortcode( $atts ) {
...
@@ -199,9 +202,10 @@ function bg_counter_shortcode( $atts ) {
extract
(
shortcode_atts
(
array
(
extract
(
shortcode_atts
(
array
(
'type'
=>
null
,
'type'
=>
null
,
'id'
=>
null
,
'id'
=>
null
,
'now'
=>
null
'now'
=>
null
,
'rate'
=>
null
),
$atts
)
);
),
$atts
)
);
$quote
=
bg_az_counter_views
(
$type
,
$id
,
$now
);
$quote
=
bg_az_counter_views
(
$type
,
$id
,
$now
,
$rate
);
return
"
{
$quote
}
"
;
return
"
{
$quote
}
"
;
}
}
...
...
inc/options.php
View file @
d6cfc0b9
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*******************************************************************************************/
*******************************************************************************************/
// Начальные значения
// Начальные значения
add_option
(
'bg_counter_options'
,
array
(
'period'
=>
DAY_IN_SECONDS
,
'now'
=>
0
,
'title'
=>
''
,
'author'
=>
''
,
'debug'
=>
0
,
'archive'
=>
0
,
'pvc'
=>
0
,
'wppp'
=>
0
,
'wppm'
=>
0
,
'bgar'
=>
0
));
add_option
(
'bg_counter_options'
,
array
(
'period'
=>
DAY_IN_SECONDS
,
'now'
=>
0
,
'
rate'
=>
1
,
'
title'
=>
''
,
'author'
=>
''
,
'debug'
=>
0
,
'archive'
=>
0
,
'pvc'
=>
0
,
'wppp'
=>
0
,
'wppm'
=>
0
,
'bgar'
=>
0
));
add_option
(
'bg_pvc_loaded'
,
''
);
add_option
(
'bg_pvc_loaded'
,
''
);
add_option
(
'bg_wppp_loaded'
,
''
);
add_option
(
'bg_wppp_loaded'
,
''
);
add_option
(
'bg_wppm_loaded'
,
''
);
add_option
(
'bg_wppm_loaded'
,
''
);
...
@@ -17,6 +17,9 @@ if (!isset($val['period'])) {
...
@@ -17,6 +17,9 @@ if (!isset($val['period'])) {
if
(
!
isset
(
$val
[
'now'
]))
{
if
(
!
isset
(
$val
[
'now'
]))
{
$val
[
'now'
]
=
0
;
$val
[
'now'
]
=
0
;
}
}
if
(
!
isset
(
$val
[
'rate'
]))
{
$val
[
'rate'
]
=
1
;
}
if
(
!
isset
(
$val
[
'title'
]))
{
if
(
!
isset
(
$val
[
'title'
]))
{
$val
[
'title'
]
=
""
;
$val
[
'title'
]
=
""
;
}
}
...
@@ -148,6 +151,21 @@ function bg_counter_options_page_output(){
...
@@ -148,6 +151,21 @@ function bg_counter_options_page_output(){
?>
?>
</form>
</form>
</div>
</div>
<script>
// Блокируем изменение всх опций, кроме этой
function
blockInputs
(
el
)
{
if
(
jQuery
(
el
).
prop
(
'checked'
))
{
jQuery
(
'select'
).
prop
(
'disabled'
,
true
);
jQuery
(
'input:text'
).
prop
(
'disabled'
,
true
);
jQuery
(
'input:checkbox'
).
prop
(
'disabled'
,
true
);
}
else
{
jQuery
(
'select'
).
prop
(
'disabled'
,
false
);
jQuery
(
'input:text'
).
prop
(
'disabled'
,
false
);
jQuery
(
'input:checkbox'
).
prop
(
'disabled'
,
false
);
}
jQuery
(
el
).
prop
(
'disabled'
,
false
);
}
</script>
<?php
<?php
}
}
}
}
...
@@ -168,6 +186,7 @@ function bg_counter_settings(){
...
@@ -168,6 +186,7 @@ function bg_counter_settings(){
// параметры: $id, $title, $callback, $page, $section, $args
// параметры: $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_period'
,
'Периодичность обработки данных'
,
'fill_bg_counter_period'
,
'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_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'
);
add_settings_field
(
'bg_counter_title'
,
'Общее название в сниппете по умолчанию'
,
'fill_bg_counter_title'
,
'bg_counter_page'
,
'section_1'
);
add_settings_field
(
'bg_counter_title'
,
'Общее название в сниппете по умолчанию'
,
'fill_bg_counter_title'
,
'bg_counter_page'
,
'section_1'
);
add_settings_field
(
'bg_counter_author'
,
'Общее имя автора в сниппете по умолчанию'
,
'fill_bg_counter_author'
,
'bg_counter_page'
,
'section_1'
);
add_settings_field
(
'bg_counter_author'
,
'Общее имя автора в сниппете по умолчанию'
,
'fill_bg_counter_author'
,
'bg_counter_page'
,
'section_1'
);
add_settings_field
(
'bg_counter_debug'
,
'Включить отладку'
,
'fill_bg_counter_debug'
,
'bg_counter_page'
,
'section_1'
);
add_settings_field
(
'bg_counter_debug'
,
'Включить отладку'
,
'fill_bg_counter_debug'
,
'bg_counter_page'
,
'section_1'
);
...
@@ -205,6 +224,15 @@ function fill_bg_counter_now(){
...
@@ -205,6 +224,15 @@ function fill_bg_counter_now(){
<?php
<?php
}
}
## Заполняем опцию 2a
function
fill_bg_counter_rate
(){
$val
=
get_option
(
'bg_counter_options'
);
$val
=
$val
?
$val
[
'rate'
]
:
null
;
?>
<label><input
type=
"checkbox"
name=
"bg_counter_options[rate]"
value=
"1"
<?php
checked
(
1
,
$val
);
?>
/>
(отображать оценку пользователями данной записи)
</label>
<?php
}
## Заполняем опцию 3
## Заполняем опцию 3
function
fill_bg_counter_title
(){
function
fill_bg_counter_title
(){
$val
=
get_option
(
'bg_counter_options'
);
$val
=
get_option
(
'bg_counter_options'
);
...
@@ -239,7 +267,7 @@ function fill_bg_counter_sendArchive(){
...
@@ -239,7 +267,7 @@ function fill_bg_counter_sendArchive(){
// Всегда предлагать сохранить не отмеченный
// Всегда предлагать сохранить не отмеченный
?>
?>
<label><input
type=
"checkbox"
name=
"bg_counter_options[archive]"
value=
"1"
/>
отметьте и нажмите кнопку «Сохранить изменения»
</label>
<label><input
type=
"checkbox"
name=
"bg_counter_options[archive]"
value=
"1"
onchange=
'blockInputs(this);'
/>
отметьте и нажмите кнопку «Сохранить изменения»
</label>
<?php
<?php
}
}
## Заполняем опцию 7
## Заполняем опцию 7
...
@@ -257,7 +285,7 @@ function fill_bg_counter_pvc(){
...
@@ -257,7 +285,7 @@ function fill_bg_counter_pvc(){
}
else
{
}
else
{
// Всегда предлагать сохранить не отмеченный
// Всегда предлагать сохранить не отмеченный
?>
?>
<label><input
type=
"checkbox"
name=
"bg_counter_options[pvc]"
value=
"1"
/>
отметьте и нажмите кнопку «Сохранить изменения»
</label>
<label><input
type=
"checkbox"
name=
"bg_counter_options[pvc]"
value=
"1"
onchange=
'blockInputs(this);'
/>
отметьте и нажмите кнопку «Сохранить изменения»
</label>
<?php
<?php
}
}
}
}
...
@@ -277,7 +305,7 @@ function fill_bg_counter_wppp(){
...
@@ -277,7 +305,7 @@ function fill_bg_counter_wppp(){
}
else
{
}
else
{
// Всегда предлагать сохранить не отмеченный
// Всегда предлагать сохранить не отмеченный
?>
?>
<label><input
type=
"checkbox"
name=
"bg_counter_options[wppp]"
value=
"1"
/>
отметьте и нажмите кнопку «Сохранить изменения»
</label>
<label><input
type=
"checkbox"
name=
"bg_counter_options[wppp]"
value=
"1"
onchange=
'blockInputs(this);'
/>
отметьте и нажмите кнопку «Сохранить изменения»
</label>
<?php
<?php
}
}
}
}
...
@@ -292,7 +320,7 @@ function fill_bg_counter_wppm(){
...
@@ -292,7 +320,7 @@ function fill_bg_counter_wppm(){
}
else
{
}
else
{
// Всегда предлагать сохранить не отмеченный
// Всегда предлагать сохранить не отмеченный
?>
?>
<label><input
type=
"checkbox"
name=
"bg_counter_options[wppm]"
value=
"1"
/>
отметьте и нажмите кнопку «Сохранить изменения»
</label>
<label><input
type=
"checkbox"
name=
"bg_counter_options[wppm]"
value=
"1"
onchange=
'blockInputs(this);'
/>
отметьте и нажмите кнопку «Сохранить изменения»
</label>
<?php
<?php
}
}
}
}
...
@@ -307,7 +335,7 @@ function fill_bg_counter_bgar(){
...
@@ -307,7 +335,7 @@ function fill_bg_counter_bgar(){
}
else
{
}
else
{
// Всегда предлагать сохранить не отмеченный
// Всегда предлагать сохранить не отмеченный
?>
?>
<label><input
type=
"checkbox"
name=
"bg_counter_options[bgar]"
value=
"1"
/>
отметьте и нажмите кнопку «Сохранить изменения»
</label>
<label><input
type=
"checkbox"
name=
"bg_counter_options[bgar]"
value=
"1"
onchange=
'blockInputs(this);'
/>
отметьте и нажмите кнопку «Сохранить изменения»
</label>
<?php
<?php
}
}
}
}
...
@@ -316,34 +344,10 @@ function fill_bg_counter_bgar(){
...
@@ -316,34 +344,10 @@ function fill_bg_counter_bgar(){
function
bg_counter_sanitize_callback
(
$options
){
function
bg_counter_sanitize_callback
(
$options
){
// очищаем
// очищаем
foreach
(
$options
as
$name
=>
&
$val
){
foreach
(
$options
as
$name
=>
&
$val
){
if
(
$name
==
'period'
)
$val
=
intval
(
$val
);
if
(
$name
==
'now'
)
$val
=
intval
(
$val
);
if
(
$name
==
'title'
)
if
(
$name
==
'title'
||
$name
==
'author'
)
$val
=
strip_tags
(
$val
);
if
(
$name
==
'author'
)
$val
=
strip_tags
(
$val
);
$val
=
strip_tags
(
$val
);
else
if
(
$name
==
'debug'
)
$val
=
intval
(
$val
);
if
(
$name
==
'archive'
)
$val
=
intval
(
$val
);
if
(
$name
==
'pvc'
)
$val
=
intval
(
$val
);
if
(
$name
==
'wppp'
)
$val
=
intval
(
$val
);
if
(
$name
==
'wppm'
)
$val
=
intval
(
$val
);
if
(
$name
==
'bgar'
)
$val
=
intval
(
$val
);
$val
=
intval
(
$val
);
}
}
return
$options
;
return
$options
;
...
...
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