From cf0ecb26a0c3bf175b848b245562e474e7678e41 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Sat, 1 Jun 2019 00:17:57 +0200 Subject: [PATCH] reader count with options menu --- liquet/functions.php | 17 +++++++++++++---- liquet/loop-utils.php | 26 +++++++++++++++++++++++--- liquet/singular.php | 3 ++- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/liquet/functions.php b/liquet/functions.php index 4f1122d..f8d7357 100644 --- a/liquet/functions.php +++ b/liquet/functions.php @@ -16,7 +16,7 @@ add_action( 'wp_enqueue_scripts', function () { add_action( 'admin_init', function () { - add_settings_section( 'section', 'All Settings', null, 'theme-options' ); + add_settings_section( 'section-link', 'Links', null, 'theme-options' ); global $links; foreach ( $links as $link ) { @@ -24,11 +24,19 @@ add_action( 'admin_init', function () { $id = $link . '_url'; add_settings_field( $id, ucfirst( $link ) . ' Url', function () use ( $id ) { ?> - + + @@ -36,7 +44,8 @@ function theme_settings_page() { ?>

Theme Panel

diff --git a/liquet/loop-utils.php b/liquet/loop-utils.php index 2aba05d..24f8e4a 100644 --- a/liquet/loop-utils.php +++ b/liquet/loop-utils.php @@ -16,8 +16,28 @@ function getDates() { $modified = get_the_modified_date( ( $modified_year == $created_year ? 'F j' : null ) ); return [ - 'created' => $created, - 'modified' => $modified, - 'different' => $created != $modified, + 'created' => $created, + 'modified' => $modified, + 'different' => $created != $modified, ]; +} + +function getCurrentPageViews() { + if ( ! is_single() ) { + return null; + } + + $total = (int) do_shortcode( '[wpstatistics stat=pagevisits time=total]' ); + $min = (int) get_option( 'view_min' ); + + if ( $total < $min ) { + return null; + } + + $approximated = round( $total / 1000, 1 ); + ?> +
+ ~k readers +
+
-
+
~ min +