File: /var/www/html/insiders/wp-load/wp-content/plugins/breadly/lib/post-views/post-views.php
<?php
/* -----------------------------------------------------------------------------
* Load Plugin Adapter
* -------------------------------------------------------------------------- */
add_action( 'init', 'gtm_init_post_views' );
if ( ! function_exists( 'gtm_init_post_views' ) ) {
function gtm_init_post_views() {
defined( 'GTM_POST_VIEWS_IS_ACTIVE' ) || define( 'GTM_POST_VIEWS_IS_ACTIVE', defined( 'WPP_VERSION' ) );
}
}
if ( ! function_exists( 'gtm_get_post_views' ) ) {
function gtm_get_post_views( $post_id = '' ) {
$views = null; // Initial
if ( empty( $post_id ) ) {
$post_id = get_the_id();
}
// Get post view from Wordpress Popular Posts plugin
if ( function_exists( 'wpp_get_views' ) ) {
$views = intval( wpp_get_views( $post_id, 'all', false ) );
}
// Reset views if not a positive integer
if ( ! ( $views >= 0 ) ) {
$views = 0;
}
return apply_filters( 'gtm_get_post_views', $views, $post_id );
}
}
/* -----------------------------------------------------------------------------
* Post Views Forgery
* -------------------------------------------------------------------------- */
add_filter( 'gtm_get_post_views', 'gtm_post_views_forgery', 10, 1 );
if ( ! function_exists( 'gtm_post_views_forgery' ) ) {
function gtm_post_views_forgery( $post_views ) {
$post_views_forgery = get_option( 'gtm_post_views_forgery', 0 );
return intval( $post_views ) + intval( $post_views_forgery );
}
}