diff --git a/includes/settings.php b/includes/settings.php old mode 100644 new mode 100755 diff --git a/includes/shortcodes.php b/includes/shortcodes.php new file mode 100644 index 0000000..3fae635 --- /dev/null +++ b/includes/shortcodes.php @@ -0,0 +1,19 @@ +post_type , $selected_type)){ if ( !empty($options['wppv_api_text_field_1']) ) { $stored_ip_addresses = get_post_meta(get_the_ID(),'view_ip',true); - } - - $new_viewed_count = 0; - if($stored_ip_addresses) - { - if(sizeof($stored_ip_addresses)) + if($stored_ip_addresses) { - $current_ip = $this->get_ip_address(); - if(!in_array($current_ip, $stored_ip_addresses)) + if(count($stored_ip_addresses)) { - $meta_key = 'entry_views'; - $view_post_meta = get_post_meta(get_the_ID(), $meta_key, true); - $new_viewed_count = $view_post_meta + 1; - update_post_meta(get_the_ID(), $meta_key, $new_viewed_count); - $stored_ip_addresses[] = $current_ip; - update_post_meta(get_the_ID(),'view_ip',$stored_ip_addresses); + $current_ip = $this->get_ip_address(); + if(!in_array($current_ip, $stored_ip_addresses)) + { + $meta_key = 'entry_views'; + $view_post_meta = get_post_meta(get_the_ID(), $meta_key, true); + $new_viewed_count = intval($view_post_meta) + 1; + update_post_meta(get_the_ID(), $meta_key, $new_viewed_count); + $stored_ip_addresses[] = $current_ip; + update_post_meta(get_the_ID(),'view_ip',$stored_ip_addresses); + } } } - } - - else { + } else { $meta_key = 'entry_views'; $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; + $new_viewed_count = intval($view_post_meta) + 1; update_post_meta(get_the_ID(), $meta_key, $new_viewed_count); - $ip_arr[] = $this->get_ip_address(); - update_post_meta(get_the_ID(),'view_ip',$ip_arr); } }