Commit c44f8fc1 authored by Vadim's avatar Vadim

Version 2.7.4

* Добавлены в виджеты пользовательские типы записей
parent 7a7e7cb0
...@@ -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.7.3 Version: 2.7.4
Author: VBog Author: VBog
Author URI: https://bogaiskov.ru Author URI: https://bogaiskov.ru
License: GPL2 License: GPL2
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,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.7.3'); define('BG_COUNTER_VERSION', '2.7.4');
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');
......
...@@ -260,11 +260,20 @@ function bg_counter_top_posts_shortcode( $atts ) { ...@@ -260,11 +260,20 @@ function bg_counter_top_posts_shortcode( $atts ) {
function bg_counter_number_format ($num) { function bg_counter_number_format ($num) {
$num = floatval ($num); $num = floatval ($num);
if ($num > 1000000000.0) { if ($num > 1000000000.0) {
$num = round($num/1000000000.0, 1)." млрд."; if ($num > 10000000000.0)
$num = round($num/1000000000.0, 0)." млрд.";
else
$num = round($num/1000000000.0, 1)." млрд.";
} elseif ($num > 1000000.0) { } elseif ($num > 1000000.0) {
$num = round($num/1000000.0, 1)." млн."; if ($num > 10000000.0)
$num = round($num/1000000.0, 0)." млн.";
else
$num = round($num/1000000.0, 1)." млн.";
} elseif ($num > 10000.0) { } elseif ($num > 10000.0) {
$num = round($num/1000.0, 1)." тыс."; if ($num > 100000.0)
$num = round($num/1000.0, 0)." тыс.";
else
$num = round($num/1000.0, 1)." тыс.";
} else { } else {
$num = number_format($num, 0, ',', ' '); $num = number_format($num, 0, ',', ' ');
} }
......
...@@ -96,6 +96,13 @@ class bg_counter_OnlineNowWidget extends WP_Widget { ...@@ -96,6 +96,13 @@ class bg_counter_OnlineNowWidget extends WP_Widget {
if ( ! empty( $title ) ) if ( ! empty( $title ) )
echo $args['before_title'] . $title . $args['after_title']; echo $args['before_title'] . $title . $args['after_title'];
$post_types_count = 0;
$post_types = get_post_types( [ 'publicly_queryable'=>1 ] );
unset( $post_types['attachment'] ); // удалим attachment
foreach ( $post_types as $post_type ) {
$post_types_count += wp_count_posts($post_type)->publish;
}
?> ?>
<div class="widget-item"> <div class="widget-item">
...@@ -103,7 +110,7 @@ class bg_counter_OnlineNowWidget extends WP_Widget { ...@@ -103,7 +110,7 @@ class bg_counter_OnlineNowWidget extends WP_Widget {
<span class="bg-az-counter"> <span class="bg-az-counter">
<p><?php echo $subtitle1; ?>: <span class="bg-az-counter-now"></span> <?php echo $unit1; ?></p> <p><?php echo $subtitle1; ?>: <span class="bg-az-counter-now"></span> <?php echo $unit1; ?></p>
<p><?php echo $subtitle2; ?>: <span class="bg-az-counter-views"></span></p> <p><?php echo $subtitle2; ?>: <span class="bg-az-counter-views"></span></p>
<p><?php echo $subtitle3; ?>: <span class="bg-az-counter-posts"><?php echo wp_count_posts()->publish; ?></span></p> <p><?php echo $subtitle3; ?>: <span class="bg-az-counter-posts"><?php echo $post_types_count; ?></span></p>
</span> </span>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment