Skip to content

Commit

Permalink
Merge pull request #7 from vanpariyar/developer
Browse files Browse the repository at this point in the history
Developer
  • Loading branch information
Antontokarchuk0302 committed Mar 31, 2020
2 parents 8172c62 + 7ec809b commit 3b33608
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions wp-post-views.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* Description: WP Post Views.
* Version: 1.0
* Requires at least: 5.0
* Requires PHP: 7.0
* Requires PHP: 5.0
* Author: Ronak J Vanpariya
* Author URI: https://example.com
* Author URI: https://vanpariyar.github.io
* Text Domain: wp-post-views
* License: GPL v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Expand Down Expand Up @@ -122,7 +122,7 @@ public function validate_ip($ip) {

public function counter(){
global $post;
$stored_ip_addresses = '';
$stored_ip_addresses = 0;
$options = get_option( 'wppv_api_settings' );
$selected_type = array();
isset($options['wppv_api_post_checkbox_1']) ? $selected_type = $options['wppv_api_post_checkbox_1'] : '';
Expand Down Expand Up @@ -151,7 +151,10 @@ public function counter(){

else {
$meta_key = 'entry_views';
$view_post_meta = get_post_meta(get_the_ID(), $meta_key, true);
$view_post_meta = get_post_meta(get_the_ID(), $meta_key, true);
if( ! is_int($view_post_meta) ){
$view_post_meta = 0;
}
$new_viewed_count = $view_post_meta + 1;
update_post_meta(get_the_ID(), $meta_key, $new_viewed_count);
$ip_arr[] = $this->get_ip_address();
Expand Down

0 comments on commit 3b33608

Please sign in to comment.