Page Visit Counter - Version 4.2

Version Description

  • 06-06-2018 =
  • minor bug fixed.
Download this release

Release Info

Developer dots
Plugin Icon 128x128 Page Visit Counter
Version 4.2
Comparing to
See all releases

Code changes from version 4.1 to 4.2

README.txt CHANGED
@@ -4,7 +4,7 @@ Plugin URI: http://multidots.com/
4
  Author: Multidots
5
  Author URI: http://multidots.com/
6
  Contributors: dots, ketuchetan, chiragpatel, jitendrabanjara1991
7
- Stable tag: 4.1
8
  Tags: page counter,page visit, post counter, post visit, wordpress post view, wordpress page view, page visit graph, post visit graph,
9
  Requires at least: 2.1
10
  Tested up to: 4.9.6
@@ -115,6 +115,9 @@ Automatic updates should work great for you. As always, though, we recommend ba
115
 
116
  == Changelog ==
117
 
 
 
 
118
  = 4.1 - 31-05-2018 =
119
  * minor bug fixed.
120
 
4
  Author: Multidots
5
  Author URI: http://multidots.com/
6
  Contributors: dots, ketuchetan, chiragpatel, jitendrabanjara1991
7
+ Stable tag: 4.2
8
  Tags: page counter,page visit, post counter, post visit, wordpress post view, wordpress page view, page visit graph, post visit graph,
9
  Requires at least: 2.1
10
  Tested up to: 4.9.6
115
 
116
  == Changelog ==
117
 
118
+ = 4.2 - 06-06-2018 =
119
+ * minor bug fixed.
120
+
121
  = 4.1 - 31-05-2018 =
122
  * minor bug fixed.
123
 
admin/class-page-visit-counter-admin.php CHANGED
@@ -162,17 +162,18 @@ class page_visit_counter_Admin
162
  } else {
163
  wp_localize_script('one', 'get_post_option', array('optionsarray' => ''));
164
  }
165
-
166
  $fetchSelecetedIpAddress = get_option('ipaddress_visit');
167
  if (!empty($fetchSelecetedIpAddress) || $fetchSelecetedIpAddress != "") {
168
  $optionsIpAddress = !empty($fetchSelecetedIpAddress) ? $fetchSelecetedIpAddress : json_encode(array());
169
  if (!empty($optionsIpAddress) || $optionsIpAddress != "") {
170
  wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => $optionsIpAddress));
171
  } else {
172
- wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => 'test12'));
173
  }
174
- } else {
175
- wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => 'test122'));
 
176
  }
177
 
178
  $fetchSelecetedUserId = get_option('userlist_visit');
@@ -355,7 +356,7 @@ class page_visit_counter_Admin
355
  </div>
356
  </div>
357
  <?php
358
- }
359
 
360
  /**
361
  * Remove the Extra flate rate menu in dashboard
@@ -887,11 +888,11 @@ class page_visit_counter_Admin
887
  <td>
888
  <select id="post_type" data-placeholder=" <?php echo esc_html__('Add Page/Post Type', 'page-visit-counter'); ?>" name="post_ty[]" multiple="true" class="chosen-select-post category-select chosen-rtl validate_field1">
889
  <option value=""></option>
890
- <?php
891
  if (isset($post_types) && !empty($post_types)) {
892
  foreach ($post_types as $cpost) {
893
  if ($cpost != "attachment" && $cpost != "revision" && $cpost != "nav_menu_item" && $cpost != "product_variation" && $cpost != "shop_order" && $cpost != "shop_order_refund" && $cpost != "shop_coupon" && $cpost != "shop_webhook" && $cpost != "scheduled-action" && $cpost != "shop_subscription" && $cpost != "wpcf7_contact_form" && $cpost != "mc4wp-form") { ?>
894
- <option value="<?php echo esc_attr($cpost); ?>"><?php echo esc_attr($cpost); ?></option><?php
895
  }
896
  }
897
  } ?>
@@ -907,12 +908,9 @@ class page_visit_counter_Admin
907
  <select id="ip_address" data-placeholder=" <?php echo esc_html__('Add IP Address in comma seprated', 'page-visit-counter'); ?>" name="ip-basic[]" multiple="true" class="chosen-select-ip category-select chosen-rtl validate_field1">
908
  <option value=""></option><?php
909
  $get_option_value_ip = json_decode(get_option('ipaddress_visit'));
910
- echo '<pre>';
911
- print_r($get_option_value_ip);
912
- echo '</pre>';
913
  if (isset($get_option_value_ip) && !empty($get_option_value_ip)) {
914
  foreach ($get_option_value_ip as $ip) { ?>
915
- <option value="<?php echo esc_attr($ip); ?>"><?php echo esc_attr($ip); ?></option><?php
916
  }
917
  } ?>
918
  </select>
@@ -930,8 +928,8 @@ class page_visit_counter_Admin
930
  $resultSetsArr = $wpdb->get_results($query);
931
  if (isset($resultSetsArr) && !empty($resultSetsArr)) {
932
  foreach ($resultSetsArr as $value) { ?>
933
- <option value="<?php echo esc_attr($value->ID); ?>"><?php echo esc_attr($value->user_email); ?></option>
934
- <?php
935
  }
936
  } ?>
937
  </select>
@@ -1410,7 +1408,7 @@ class page_visit_counter_Admin
1410
  $enable_page_count_day_wise = get_post_meta($post_id, "enable_page_count_day_wise", true);
1411
 
1412
  $table_name = $wpdb->prefix . "page_visit";
1413
-
1414
  $get_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $post_id);
1415
  $pageCount = $wpdb->get_results($get_qry);
1416
 
@@ -1524,12 +1522,12 @@ class page_visit_counter_Admin
1524
  $table_name = $wpdb->prefix . "page_visit_history";
1525
 
1526
  $pageId = $_REQUEST['page_id'];
1527
-
1528
  $countQuery_qry = $wpdb->prepare('SELECT COUNT(`page_id`) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageId);
1529
  $result = $wpdb->get_results($countQuery_qry);
1530
 
1531
  if ((int)$result[0]->total > 0) {
1532
-
1533
  $queryTopBrowser = $wpdb->prepare('SELECT COUNT(`page_id`) as total, `browser_full_name` as browser FROM ' . $table_name . ' WHERE page_id=%d GROUP BY `browser_full_name`', $pageId);
1534
 
1535
  $topBrowserArr = $wpdb->get_results($queryTopBrowser);
@@ -1546,7 +1544,7 @@ class page_visit_counter_Admin
1546
 
1547
  $queryTopIpAddressLimit = '10';
1548
  $queryTopIpAddress = $wpdb->prepare('SELECT COUNT( `page_id` ) AS total, `ipaddress` AS ipaddress FROM ' . $table_name . ' WHERE page_id=%d GROUP BY `ipaddress` ORDER BY total DESC LIMIT %d', $pageId, $queryTopIpAddressLimit);
1549
-
1550
  $topIpArr = $wpdb->get_results($queryTopIpAddress);
1551
 
1552
  $topIpStringArr = array();
@@ -1557,7 +1555,7 @@ class page_visit_counter_Admin
1557
  $topIpStringArr["$topIp->ipaddress"] = (int)$topIp->total;
1558
  }
1559
  }
1560
-
1561
  $queryTopReferer = "SELECT COUNT(`page_id`) as total,SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE(REPLACE(LOWER(`http_referer`), 'https://', ''), 'http://', ''), '/', 1), '?', 1) AS domain FROM $table_name WHERe `page_id` = $pageId AND `http_referer` != '' GROUP BY `http_referer` ORDER BY total DESC LIMIT 10";
1562
  // echo "CALL ".$queryTopReferer;
1563
  // exit();
@@ -1606,7 +1604,7 @@ class page_visit_counter_Admin
1606
  }
1607
  unset($topMonthlyArr);
1608
  }
1609
-
1610
  $queryYearlyReportLimit = '10';
1611
  $queryYearlyReport = $wpdb->prepare('SELECT SUM( `page_id` ) AS total, YEAR( `date` ) AS year FROM ' . $table_name . ' WHERE page_id=%d GROUP BY YEAR( `date` ) ORDER BY YEAR( `date` ) DESC LIMIT %d', $pageId, $queryYearlyReportLimit);
1612
 
@@ -1705,7 +1703,7 @@ class My_Widget extends WP_Widget
1705
  if (!empty($title)) {
1706
  $html .= $before_title . $title . $after_title;
1707
  }
1708
-
1709
  $count_visit_limit = '5';
1710
  $count_visit = $wpdb->prepare('SELECT page_id,id,SUM(page_visit) as c from' . $table_name . ' group by page_id order by c DESC limit %d', $count_visit_limit);
1711
  $count_visit = $wpdb->get_results($count_visit);
162
  } else {
163
  wp_localize_script('one', 'get_post_option', array('optionsarray' => ''));
164
  }
165
+
166
  $fetchSelecetedIpAddress = get_option('ipaddress_visit');
167
  if (!empty($fetchSelecetedIpAddress) || $fetchSelecetedIpAddress != "") {
168
  $optionsIpAddress = !empty($fetchSelecetedIpAddress) ? $fetchSelecetedIpAddress : json_encode(array());
169
  if (!empty($optionsIpAddress) || $optionsIpAddress != "") {
170
  wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => $optionsIpAddress));
171
  } else {
172
+ wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => ["126"] ));
173
  }
174
+ }
175
+ else {
176
+ wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => ["127"] ));
177
  }
178
 
179
  $fetchSelecetedUserId = get_option('userlist_visit');
356
  </div>
357
  </div>
358
  <?php
359
+ }
360
 
361
  /**
362
  * Remove the Extra flate rate menu in dashboard
888
  <td>
889
  <select id="post_type" data-placeholder=" <?php echo esc_html__('Add Page/Post Type', 'page-visit-counter'); ?>" name="post_ty[]" multiple="true" class="chosen-select-post category-select chosen-rtl validate_field1">
890
  <option value=""></option>
891
+ <?php
892
  if (isset($post_types) && !empty($post_types)) {
893
  foreach ($post_types as $cpost) {
894
  if ($cpost != "attachment" && $cpost != "revision" && $cpost != "nav_menu_item" && $cpost != "product_variation" && $cpost != "shop_order" && $cpost != "shop_order_refund" && $cpost != "shop_coupon" && $cpost != "shop_webhook" && $cpost != "scheduled-action" && $cpost != "shop_subscription" && $cpost != "wpcf7_contact_form" && $cpost != "mc4wp-form") { ?>
895
+ <option value="<?php echo $cpost; ?>"><?php echo $cpost; ?></option><?php
896
  }
897
  }
898
  } ?>
908
  <select id="ip_address" data-placeholder=" <?php echo esc_html__('Add IP Address in comma seprated', 'page-visit-counter'); ?>" name="ip-basic[]" multiple="true" class="chosen-select-ip category-select chosen-rtl validate_field1">
909
  <option value=""></option><?php
910
  $get_option_value_ip = json_decode(get_option('ipaddress_visit'));
 
 
 
911
  if (isset($get_option_value_ip) && !empty($get_option_value_ip)) {
912
  foreach ($get_option_value_ip as $ip) { ?>
913
+ <option value="<?php echo $ip; ?>"><?php echo $ip; ?></option><?php
914
  }
915
  } ?>
916
  </select>
928
  $resultSetsArr = $wpdb->get_results($query);
929
  if (isset($resultSetsArr) && !empty($resultSetsArr)) {
930
  foreach ($resultSetsArr as $value) { ?>
931
+ <option value="<?php echo esc_attr($value->ID); ?>"><?php echo $value->user_email; ?></option>
932
+ <?php
933
  }
934
  } ?>
935
  </select>
1408
  $enable_page_count_day_wise = get_post_meta($post_id, "enable_page_count_day_wise", true);
1409
 
1410
  $table_name = $wpdb->prefix . "page_visit";
1411
+
1412
  $get_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $post_id);
1413
  $pageCount = $wpdb->get_results($get_qry);
1414
 
1522
  $table_name = $wpdb->prefix . "page_visit_history";
1523
 
1524
  $pageId = $_REQUEST['page_id'];
1525
+
1526
  $countQuery_qry = $wpdb->prepare('SELECT COUNT(`page_id`) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageId);
1527
  $result = $wpdb->get_results($countQuery_qry);
1528
 
1529
  if ((int)$result[0]->total > 0) {
1530
+
1531
  $queryTopBrowser = $wpdb->prepare('SELECT COUNT(`page_id`) as total, `browser_full_name` as browser FROM ' . $table_name . ' WHERE page_id=%d GROUP BY `browser_full_name`', $pageId);
1532
 
1533
  $topBrowserArr = $wpdb->get_results($queryTopBrowser);
1544
 
1545
  $queryTopIpAddressLimit = '10';
1546
  $queryTopIpAddress = $wpdb->prepare('SELECT COUNT( `page_id` ) AS total, `ipaddress` AS ipaddress FROM ' . $table_name . ' WHERE page_id=%d GROUP BY `ipaddress` ORDER BY total DESC LIMIT %d', $pageId, $queryTopIpAddressLimit);
1547
+
1548
  $topIpArr = $wpdb->get_results($queryTopIpAddress);
1549
 
1550
  $topIpStringArr = array();
1555
  $topIpStringArr["$topIp->ipaddress"] = (int)$topIp->total;
1556
  }
1557
  }
1558
+
1559
  $queryTopReferer = "SELECT COUNT(`page_id`) as total,SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE(REPLACE(LOWER(`http_referer`), 'https://', ''), 'http://', ''), '/', 1), '?', 1) AS domain FROM $table_name WHERe `page_id` = $pageId AND `http_referer` != '' GROUP BY `http_referer` ORDER BY total DESC LIMIT 10";
1560
  // echo "CALL ".$queryTopReferer;
1561
  // exit();
1604
  }
1605
  unset($topMonthlyArr);
1606
  }
1607
+
1608
  $queryYearlyReportLimit = '10';
1609
  $queryYearlyReport = $wpdb->prepare('SELECT SUM( `page_id` ) AS total, YEAR( `date` ) AS year FROM ' . $table_name . ' WHERE page_id=%d GROUP BY YEAR( `date` ) ORDER BY YEAR( `date` ) DESC LIMIT %d', $pageId, $queryYearlyReportLimit);
1610
 
1703
  if (!empty($title)) {
1704
  $html .= $before_title . $title . $after_title;
1705
  }
1706
+
1707
  $count_visit_limit = '5';
1708
  $count_visit = $wpdb->prepare('SELECT page_id,id,SUM(page_visit) as c from' . $table_name . ' group by page_id order by c DESC limit %d', $count_visit_limit);
1709
  $count_visit = $wpdb->get_results($count_visit);
page_visit_counter.php CHANGED
@@ -7,7 +7,7 @@
7
  * Plugin URI: http://www.multidots.com/
8
  * Description: This plugin will count the total visits of your sites pages.
9
  * Author: Multidots
10
- * Version: 4.1
11
  * Author URI: http://www.multidots.com/
12
  */
13
  // If this file is called directly, abort.
7
  * Plugin URI: http://www.multidots.com/
8
  * Description: This plugin will count the total visits of your sites pages.
9
  * Author: Multidots
10
+ * Version: 4.2
11
  * Author URI: http://www.multidots.com/
12
  */
13
  // If this file is called directly, abort.
public/class-page-visit-counter-public.php CHANGED
@@ -25,555 +25,559 @@ if ( !defined( 'ABSPATH' ) ) {
25
  */
26
  class page_visit_counter_Public {
27
 
28
- /**
29
- * The ID of this plugin.
30
- *
31
- * @since 1.0.0
32
- * @access private
33
- * @var string $plugin_name The ID of this plugin.
34
- */
35
- private $plugin_name;
36
-
37
- /**
38
- * The version of this plugin.
39
- *
40
- * @since 1.0.0
41
- * @access private
42
- * @var string $version The current version of this plugin.
43
- */
44
- private $version;
45
-
46
- /**
47
- * Initialize the class and set its properties.
48
- *
49
- * @since 1.0.0
50
- * @param string $plugin_name The name of this plugin.
51
- * @param string $version The version of this plugin.
52
- */
53
- public function __construct( $plugin_name, $version ) {
54
-
55
- $this->plugin_name = $plugin_name;
56
- $this->version = $version;
57
-
58
- }
59
- /**
60
- * Register the stylesheets for the admin area.
61
- *
62
- * @since 1.0.0
63
- */
64
- public function enqueue_styles() {
65
- global $wp;
66
-
67
- wp_enqueue_style('counter-style', plugin_dir_url( __FILE__ ) . 'css/counter-style.css');
68
-
69
- }
70
- /**
71
- * Register the JavaScript for the admin area.
72
- *
73
- * @since 1.0.0
74
- */
75
- public function enqueue_scripts() {
76
- global $wp;
77
- wp_enqueue_script('one', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), $this->version, false );
78
- $current_url = home_url( $wp->request );
79
- wp_localize_script( 'one', 'pagevisit', array(
80
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
81
- 'pageurl' => $current_url,
82
- ) );
83
-
84
- }
85
-
86
- /**
87
- * action use in call header
88
- * Insert_page_visit_counter function use insert the page data
89
- * pageid,Currentdate,Ipaddress,pagecount add in database.
90
- */
91
-
92
- public function insert_page_visit_counter() {
93
- global $wpdb, $wp, $post, $wp_query;
94
-
95
- $flag = 0;
96
- // Check the site running on HTTPS. If the site running on HTTPS then we are removing S from HTTPS
97
- if (is_ssl()) {
98
- $actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
99
- if (strpos($actual_link,'wp-admin') !== false) {
100
- $page = 0;
101
- $flag = 1;
102
- } else {
103
- $page = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',esc_url($actual_link)));
104
- }
105
- } else {
106
- $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
107
- if (strpos($actual_link,'wp-admin') !== false) {
108
- $page = 0;
109
- $flag = 1;
110
- } else {
111
- $page = url_to_postid( esc_url($actual_link) );
112
- }
113
- }
114
- $pageID = $page;
115
- if( in_array( 'woocommerce/woocommerce.php',apply_filters('active_plugins',get_option('active_plugins'))) ) {
116
- if( is_shop() ){
117
- $page = (int) get_option( 'woocommerce_shop_page_id' );
118
- }
119
- if ( is_cart() ) {
120
- $page = (int) get_option( 'woocommerce_cart_page_id' );
121
- }
122
- if( is_checkout() ){
123
- $page = (int) get_option( 'woocommerce_checkout_page_id' );
124
-
125
- }
126
- }
127
-
128
-
129
- if ($flag == 0) {
130
-
131
- if ($page == 0) {
132
- $page = get_the_ID();
133
- if ($page == 0) {
134
- $current_url = home_url( $wp->request );
135
- if (is_ssl()) {
136
- $page = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',$current_url));
137
- } else {
138
- $page = url_to_postid( $current_url );
139
- }
140
- if ($page == 0) {
141
- $queried_object = get_queried_object();
142
-
143
- if ( $queried_object ) {
144
- $post_id = $queried_object->ID;
145
- $page = $post_id;
146
- }
147
- }
148
- }
149
- }
150
- }
151
-
152
- if ($page != 0) {
153
-
154
-
155
- $table_name = $wpdb->prefix."page_visit";
156
- $table_name_history = $wpdb->prefix . "page_visit_history";
157
- $last_date = '';
158
- $page_contet = get_post( $page );
159
-
160
- $currentdate= date("Y-m-d");
161
- $ipaddress = $_SERVER['REMOTE_ADDR'];
162
-
163
- $fetchSelecetedPostTypes = get_option('wfap_post_type');
164
- if ($fetchSelecetedPostTypes == '' || $fetchSelecetedPostTypes == null) {
165
- $post_types = get_post_types();
166
- $postArr = array();
167
- if (isset($post_types) && !empty($post_types)) {
168
- foreach ($post_types as $cpost) {
169
- if($cpost != "attachment" && $cpost != "revision" && $cpost != "nav_menu_item" && $cpost != "product_variation" && $cpost != "shop_order" && $cpost != "shop_order_refund" && $cpost != "shop_coupon" && $cpost != "shop_webhook" && $cpost != "scheduled-action" && $cpost != "shop_subscription"&& $cpost != "wpcf7_contact_form"&& $cpost != "mc4wp-form") {
170
- $postArr[] = $cpost;
171
- }
172
- }
173
- }
174
-
175
- delete_option('wfap_post_type');
176
- if (isset($postArr) && $postArr != null) {
177
- update_option('wfap_post_type',json_encode(array_values($postArr)));
178
- }
179
- $fetchSelecetedPostTypes = get_option('wfap_post_type');
180
- }
181
-
182
- $postTypeSelectedDecodeArr = !empty( $fetchSelecetedPostTypes ) ? $fetchSelecetedPostTypes : json_encode( array() );
183
-
184
-
185
- $fetchSelecetedIpAddress = get_option('ipaddress_visit');
186
- $optionsIpAddressDecodedArr = !empty( $fetchSelecetedIpAddress ) ? $fetchSelecetedIpAddress : json_encode( array() );
187
-
188
-
189
- $fetchSelecetedUserId = get_option('userlist_visit');
190
- $optionsUserIdDecodedArr = !empty( $fetchSelecetedUserId ) ? $fetchSelecetedUserId : json_encode( array() );
191
-
192
- $pageCount_limit = intval(1);
193
- $pageCount_qry = $wpdb->prepare('SELECT * FROM ' . $table_name . ' WHERE page_id=%d AND ipaddress=%s AND date=%s LIMIT %d', $page, $ipaddress, $currentdate, $pageCount_limit);
194
- $pageCount = $wpdb->get_results($pageCount_qry);
195
-
196
- $getPageSetting = get_post_meta($page,'enable_page_count',true);
197
-
198
- $u_agent = $_SERVER['HTTP_USER_AGENT'];
199
-
200
- $bname = 'Unknown';
201
- $platform = 'Unknown';
202
- $version= "";
203
- $ub= "";
204
-
205
- //First get the platform?
206
- if (preg_match('/linux/i', $u_agent)) {
207
- $platform = 'linux';
208
- }
209
- elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
210
- $platform = 'mac';
211
- }
212
- elseif (preg_match('/windows|win32/i', $u_agent)) {
213
- $platform = 'windows';
214
- }
215
-
216
- // Next get the name of the useragent yes seperately and for good reason
217
- if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent))
218
- {
219
- $bname = 'Internet Explorer';
220
- $ub = "MSIE";
221
- }
222
- elseif(preg_match('/Firefox/i',$u_agent))
223
- {
224
- $bname = 'Mozilla Firefox';
225
- $ub = "Firefox";
226
- }
227
- elseif(preg_match('/Chrome/i',$u_agent))
228
- {
229
- $bname = 'Google Chrome';
230
- $ub = "Chrome";
231
- }
232
- elseif(preg_match('/Safari/i',$u_agent))
233
- {
234
- $bname = 'Apple Safari';
235
- $ub = "Safari";
236
- }
237
- elseif(preg_match('/Opera/i',$u_agent))
238
- {
239
- $bname = 'Opera';
240
- $ub = "Opera";
241
- }
242
- elseif(preg_match('/Netscape/i',$u_agent))
243
- {
244
- $bname = 'Netscape';
245
- $ub = "Netscape";
246
- }
247
-
248
-
249
- // finally get the correct version number
250
- $known = array('Version', $ub, 'other');
251
- $pattern = '#(?<browser>' . join('|', $known) .
252
- ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
253
- if (!preg_match_all($pattern, $u_agent, $matches)) {
254
- // we have no matching number just continue
255
- }
256
-
257
- // see how many we have
258
- $i = count($matches['browser']);
259
- if ($i != 1) {
260
- //we will have two since we are not using 'other' argument yet
261
- //see if version is before or after the name
262
- if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
263
- $version= $matches['version'][0];
264
- }
265
- else {
266
- $version= isset($matches['version'][1]) ? $matches['version'][1] : null;;
267
- }
268
- }
269
- else {
270
- $version= isset($matches['version'][0]) ? $matches['version'][0] : null;;
271
- }
272
-
273
- // check if we have a number
274
- if ($version==null || $version=="") {$version="?";}
275
-
276
- $http_referer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] :'';
277
-
278
- // old version plugin
279
- if ($fetchSelecetedPostTypes != '') {
280
-
281
- $postTypeSelectedEncodeArr = json_decode($postTypeSelectedDecodeArr);
282
- $getPageSetting = get_post_meta($page,'enable_page_count',true);
283
-
284
- // Check current page/post type exist in settings page array
285
- if (in_array($page_contet->post_type,$postTypeSelectedEncodeArr)) {
286
-
287
- // Check current page/post metabox settings is blank OR selected value is yes
288
- if ($getPageSetting == '' || $getPageSetting == 'yes') {
289
-
290
- // Check IP Address set in settings page if yes
291
- if (isset($fetchSelecetedIpAddress) && !empty($fetchSelecetedIpAddress)) {
292
-
293
- $optionsIpAddressEncodeArr = json_decode($optionsIpAddressDecodedArr);
294
- // Check IP Address not listed in settings page then go ahed
295
- if (!in_array($ipaddress,$optionsIpAddressEncodeArr)) {
296
-
297
- // Check users set in settings page if yes
298
- if (isset($fetchSelecetedUserId) && !empty($fetchSelecetedUserId)) {
299
-
300
- $optionsUserIdEncodeArr = json_decode($optionsUserIdDecodedArr);
301
- $user_id = get_current_user_id();
302
-
303
- // Check user not listed in settings page then go ahed
304
- if (!in_array($user_id,$optionsUserIdEncodeArr)) {
305
-
306
- if (isset($pageCount) && !empty($pageCount)) {
307
- $existingtotal = (int) $pageCount[0]->page_visit;
308
- $totalFinal = $existingtotal + 1;
309
- $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
310
- $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
311
- } else {
312
- $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
313
- $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
314
- }
315
- }
316
- } else {
317
- if (isset($pageCount) && !empty($pageCount)) {
318
- $existingtotal = (int) $pageCount[0]->page_visit;
319
- $totalFinal = $existingtotal + 1;
320
- $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
321
- $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
322
- } else {
323
- $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
324
- $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
325
- }
326
- }
327
- }
328
- } else {
329
- // Check users set in settings page if yes
330
- if (isset($fetchSelecetedUserId) && !empty($fetchSelecetedUserId)) {
331
-
332
- $optionsUserIdEncodeArr = json_decode($optionsUserIdDecodedArr);
333
- $user_id = get_current_user_id();
334
-
335
- // Check user not listed in settings page then go ahed
336
- if (!in_array($user_id,$optionsUserIdEncodeArr)) {
337
-
338
- if (isset($pageCount) && !empty($pageCount)) {
339
- $existingtotal = (int) $pageCount[0]->page_visit;
340
- $totalFinal = $existingtotal + 1;
341
- $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
342
- $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
343
- } else {
344
- $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
345
- $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
346
- }
347
- }
348
- } else {
349
- if (isset($pageCount) && !empty($pageCount)) {
350
- $existingtotal = (int) $pageCount[0]->page_visit;
351
- $totalFinal = $existingtotal + 1;
352
- $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
353
- $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
354
- } else {
355
- $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
356
- $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
357
- }
358
- }
359
- }
360
- }
361
- }
362
- }
363
- }
364
-
365
- }
366
-
367
- public function display_page_visit_counter_ajax() {
368
- global $wpdb, $wp, $post;
369
-
370
- $pageurl = sanitize_text_field(wp_unslash($_POST['pageurl']));
371
-
372
- if (is_ssl()) {
373
- $pageID = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',$pageurl));
374
- } else {
375
- $pageID = url_to_postid( $pageurl );
376
- }
377
-
378
- if (strpos($pageurl,'/shop') !== false && $pageID == 0 ) {
379
- $pageID = (int) get_option( 'woocommerce_shop_page_id' );
380
- }
381
-
382
- $post = get_post($pageID);
383
-
384
- $fetchSelecetedPostTypes = get_option('wfap_post_type');
385
-
386
- $table_name = $wpdb->prefix."page_visit";
387
-
388
- $pageCount_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageID);
389
- $pageCount = $wpdb->get_results($pageCount_qry);
390
-
391
- $table_name_history = $wpdb->prefix."page_visit_history";
392
-
393
- $pageCountToday_qry = $wpdb->prepare('SELECT COUNT(page_id) as total FROM ' . $table_name_history . ' WHERE page_id=%d AND DATE(`date`) = CURDATE()', $pageID);
394
- $pageCountToday = $wpdb->get_results($pageCountToday_qry);
395
-
396
- $total = (int) $pageCount[0]->total;
397
-
398
- $totalToday = (int) $pageCountToday[0]->total;
399
-
400
- $temp = array();
401
-
402
- $temp['today'] = $totalToday;
403
- $temp['total'] = $total;
404
-
405
- echo json_encode($temp);
406
-
407
- die();
408
-
409
- }
410
-
411
- public function insert_page_visit_counter_total_block_shop_page($content) {
412
- global $wpdb, $wp, $post;
413
-
414
- if (is_ssl()) {
415
- $actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
416
- $pageID = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',$actual_link));
417
- } else {
418
- $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
419
- $pageID = url_to_postid( $actual_link );
420
- }
421
-
422
- if (($_SERVER['REQUEST_URI'] == '/shop/' || strpos($_SERVER['REQUEST_URI'], '/shop/') !== false ) && $pageID == 0) {
423
- $pageID = (int) get_option( 'woocommerce_shop_page_id' );
424
- }
425
-
426
- if ($pageID != 0) {
427
- $post = get_post($pageID);
428
-
429
- $fetchSelecetedPostTypes = get_option('wfap_post_type');
430
-
431
- $text_color_page_visit = get_option('text_color_page_visit');
432
-
433
- if (isset($text_color_page_visit) && $text_color_page_visit != null) {
434
- $text_color_page_visit = 'style="color: '.$text_color_page_visit.';"';
435
- } else {
436
- $text_color_page_visit = 'style="color: #000000;"';
437
- }
438
-
439
- $enableToday = '';
440
- $enableToday = get_post_meta($pageID,'enable_page_count_day_wise',true);
441
-
442
- $table_name = $wpdb->prefix."page_visit";
443
- $table_name_history = $wpdb->prefix."page_visit_history";
444
-
445
- $pageCount_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageID);
446
- $pageCount = $wpdb->get_results($pageCount_qry);
447
-
448
- $pageCountToday_qry = $wpdb->prepare('SELECT COUNT(page_id) as total FROM ' . $table_name_history . ' WHERE page_id=%d AND DATE(`date`) = CURDATE()', $pageID);
449
- $pageCountToday = $wpdb->get_results($pageCountToday_qry);
450
-
451
- $total = (int) $pageCount[0]->total;
452
- $totalToday = (int) $pageCountToday[0]->total;
453
-
454
-
455
- $html = '';
456
- $hide_show_option = get_option('counter_hide_show_front_vew');
457
- if( $hide_show_option == 'on' ){
458
- if(!is_feed() && !is_home()) {
459
- if ($fetchSelecetedPostTypes == '' || $fetchSelecetedPostTypes == null) {
460
- if ('yes' === $enableToday || '' === $enableToday) {
461
- $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.esc_attr($text_color_page_visit).'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits,','page-visit-counter').'<span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor_today">'.esc_attr($totalToday).'</span>'.__('visits today','page-visit-counter').'</p>';
462
- } else {
463
- $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.esc_attr($text_color_page_visit).'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits.','page-visit-counter').'</p>';
464
- }
465
- } else {
466
- $postTypeSelectedEncodeArr = json_decode($fetchSelecetedPostTypes);
467
- if (in_array($post->post_type,$postTypeSelectedEncodeArr)) {
468
- $innerSettings = get_post_meta($pageID,'enable_page_count',true);
469
- if ($innerSettings == '' || $innerSettings == 'yes') {
470
- if ('yes' === $enableToday || '' === $enableToday) {
471
- $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.esc_attr($text_color_page_visit).'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits,','page-visit-counter').'<span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor_today">'.esc_attr($totalToday).'</span>'.__('visits today','page-visit-counter').'</p>';
472
- } else {
473
- $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.esc_attr($text_color_page_visit).'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits.','page-visit-counter').'</p>';
474
- }
475
- }
476
- }
477
- }
478
- }
479
- }
480
-
481
- echo $content.' '.$html; // WPCS: XSS OK.
482
- } else {
483
- echo $content; // WPCS: XSS OK.
484
- }
485
-
486
- }
487
-
488
- public function insert_page_visit_counter_total_block($content) {
489
- global $wpdb, $wp, $post;
490
-
491
- if (is_ssl()) {
492
- $actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
493
- $pageID = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',esc_url($actual_link)));
494
- } else {
495
- $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
496
- $pageID = url_to_postid( esc_url($actual_link) );
497
- }
498
-
499
- if (($_SERVER['REQUEST_URI'] == '/shop/' || strpos($_SERVER['REQUEST_URI'], '/shop/') !== false ) && $pageID == 0) {
500
- $pageID = (int) get_option( 'woocommerce_shop_page_id' );
501
- }
502
-
503
- if ($pageID != 0) {
504
- $post = get_post($pageID);
505
-
506
- $fetchSelecetedPostTypes = get_option('wfap_post_type');
507
-
508
- $text_color_page_visit = get_option('text_color_page_visit');
509
-
510
- if (isset($text_color_page_visit) && $text_color_page_visit != null) {
511
- $text_color_page_visit = 'style="color: '.esc_attr($text_color_page_visit).';"';
512
- } else {
513
- $text_color_page_visit = 'style="color: #000000;"';
514
- }
515
-
516
- $enableToday = '';
517
- $enableToday = get_post_meta($pageID,'enable_page_count_day_wise',true);
518
-
519
- $table_name = $wpdb->prefix."page_visit";
520
- $table_name_history = $wpdb->prefix."page_visit_history";
521
-
522
- $pageCount_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageID);
523
- $pageCount = $wpdb->get_results($pageCount_qry);
524
-
525
- $pageCountToday_qry = $wpdb->prepare('SELECT COUNT(page_id) as total FROM ' . $table_name_history . ' WHERE page_id=%d AND DATE(`date`) = CURDATE()', $pageID);
526
- $pageCountToday = $wpdb->get_results($pageCountToday_qry);
527
-
528
- $total = (int) $pageCount[0]->total;
529
- $totalToday = (int) $pageCountToday[0]->total;
530
-
531
- $html = '';
532
- $hide_show_option = get_option('counter_hide_show_front_vew');
533
- if( $hide_show_option == 'on' ){
534
- if(!is_feed() && !is_home()) {
535
- if ($fetchSelecetedPostTypes == '' || $fetchSelecetedPostTypes == null) {
536
- if ('yes' === $enableToday || '' === $enableToday) {
537
- $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.esc_attr($text_color_page_visit).'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits,','page-visit-counter').'<span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor_today">'.esc_attr($totalToday).'</span>'.__('visits today','page-visit-counter').'</p>';
538
- } else {
539
- $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.esc_attr($text_color_page_visit).'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits.','page-visit-counter').'</p>';
540
- }
541
- } else {
542
- $postTypeSelectedEncodeArr = json_decode($fetchSelecetedPostTypes);
543
- if (in_array($post->post_type,$postTypeSelectedEncodeArr)) {
544
- $innerSettings = get_post_meta($pageID,'enable_page_count',true);
545
- if ($innerSettings == '' || $innerSettings == 'yes') {
546
- if ('yes' === $enableToday || '' === $enableToday) {
547
- $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.esc_attr($text_color_page_visit).'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits,','page-visit-counter').'<span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor_today">'.esc_attr($totalToday).'</span>'.__('visits today','page-visit-counter').'</p>';
548
- } else {
549
- $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.esc_attr($text_color_page_visit).'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits.','page-visit-counter').'</p>';
550
- }
551
- }
552
- }
553
- }
554
- }
555
- }
556
- $get_no_of_days = get_option('no_of_days_to_display');
557
- if ($get_no_of_days == '') {
558
- $get_no_of_days = 6;
559
- } else {
560
- $get_no_of_days = (int) $get_no_of_days + 1;
561
- }
562
- $query = "SELECT `page_id`, COUNT(`page_id`) as count,`date` FROM wp_page_visit_history Where DATE(`lastdate`) > DATE_SUB(CURDATE(), INTERVAL $get_no_of_days DAY) AND DATE(`lastdate`) < CURDATE() AND `page_id` = $pageID GROUP BY `lastdate`";
563
- return $content.' '.$html;
564
- } else {
565
- return $content;
566
- }
567
-
568
- }
569
-
570
-
571
- /**
572
- * BN code added
573
- */
574
-
575
- function paypal_bn_code_filter($paypal_args) {
576
- $paypal_args['bn'] = 'Multidots_SP';
577
- return $paypal_args;
578
- }
 
 
 
 
579
  }
25
  */
26
  class page_visit_counter_Public {
27
 
28
+ /**
29
+ * The ID of this plugin.
30
+ *
31
+ * @since 1.0.0
32
+ * @access private
33
+ * @var string $plugin_name The ID of this plugin.
34
+ */
35
+ private $plugin_name;
36
+
37
+ /**
38
+ * The version of this plugin.
39
+ *
40
+ * @since 1.0.0
41
+ * @access private
42
+ * @var string $version The current version of this plugin.
43
+ */
44
+ private $version;
45
+
46
+ /**
47
+ * Initialize the class and set its properties.
48
+ *
49
+ * @since 1.0.0
50
+ * @param string $plugin_name The name of this plugin.
51
+ * @param string $version The version of this plugin.
52
+ */
53
+ public function __construct( $plugin_name, $version ) {
54
+
55
+ $this->plugin_name = $plugin_name;
56
+ $this->version = $version;
57
+
58
+ }
59
+ /**
60
+ * Register the stylesheets for the admin area.
61
+ *
62
+ * @since 1.0.0
63
+ */
64
+ public function enqueue_styles() {
65
+ global $wp;
66
+
67
+ wp_enqueue_style('counter-style', plugin_dir_url( __FILE__ ) . 'css/counter-style.css');
68
+
69
+ }
70
+ /**
71
+ * Register the JavaScript for the admin area.
72
+ *
73
+ * @since 1.0.0
74
+ */
75
+ public function enqueue_scripts() {
76
+ global $wp;
77
+ wp_enqueue_script('one', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), $this->version, false );
78
+ $current_url = home_url( $wp->request );
79
+ wp_localize_script( 'one', 'pagevisit', array(
80
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
81
+ 'pageurl' => $current_url,
82
+ ) );
83
+
84
+ }
85
+
86
+ /**
87
+ * action use in call header
88
+ * Insert_page_visit_counter function use insert the page data
89
+ * pageid,Currentdate,Ipaddress,pagecount add in database.
90
+ */
91
+
92
+ public function insert_page_visit_counter() {
93
+ global $wpdb, $wp, $post, $wp_query;
94
+
95
+ $flag = 0;
96
+ // Check the site running on HTTPS. If the site running on HTTPS then we are removing S from HTTPS
97
+ if (is_ssl()) {
98
+ $actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
99
+ if (strpos($actual_link,'wp-admin') !== false) {
100
+ $page = 0;
101
+ $flag = 1;
102
+ } else {
103
+ $page = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',esc_url($actual_link)));
104
+ }
105
+ } else {
106
+ $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
107
+ if (strpos($actual_link,'wp-admin') !== false) {
108
+ $page = 0;
109
+ $flag = 1;
110
+ } else {
111
+ $page = url_to_postid( esc_url($actual_link) );
112
+ }
113
+ }
114
+ $pageID = $page;
115
+ if( in_array( 'woocommerce/woocommerce.php',apply_filters('active_plugins',get_option('active_plugins'))) ) {
116
+ if( is_shop() ){
117
+ $page = (int) get_option( 'woocommerce_shop_page_id' );
118
+ }
119
+ if ( is_cart() ) {
120
+ $page = (int) get_option( 'woocommerce_cart_page_id' );
121
+ }
122
+ if( is_checkout() ){
123
+ $page = (int) get_option( 'woocommerce_checkout_page_id' );
124
+
125
+ }
126
+ }
127
+
128
+
129
+ if ($flag == 0) {
130
+
131
+ if ($page == 0) {
132
+ $page = get_the_ID();
133
+ if ($page == 0) {
134
+ $current_url = home_url( $wp->request );
135
+ if (is_ssl()) {
136
+ $page = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',$current_url));
137
+ } else {
138
+ $page = url_to_postid( $current_url );
139
+ }
140
+ if ($page == 0) {
141
+ $queried_object = get_queried_object();
142
+
143
+ if ( $queried_object ) {
144
+ $post_id = $queried_object->ID;
145
+ $page = $post_id;
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ if ($page != 0) {
153
+
154
+
155
+ $table_name = $wpdb->prefix."page_visit";
156
+ $table_name_history = $wpdb->prefix . "page_visit_history";
157
+ $last_date = '';
158
+ $page_contet = get_post( $page );
159
+
160
+ $currentdate= date("Y-m-d");
161
+ $ipaddress = $_SERVER['REMOTE_ADDR'];
162
+
163
+ $fetchSelecetedPostTypes = get_option('wfap_post_type');
164
+ if ($fetchSelecetedPostTypes == '' || $fetchSelecetedPostTypes == null) {
165
+ $post_types = get_post_types();
166
+ $postArr = array();
167
+ if (isset($post_types) && !empty($post_types)) {
168
+ foreach ($post_types as $cpost) {
169
+ if($cpost != "attachment" && $cpost != "revision" && $cpost != "nav_menu_item" && $cpost != "product_variation" && $cpost != "shop_order" && $cpost != "shop_order_refund" && $cpost != "shop_coupon" && $cpost != "shop_webhook" && $cpost != "scheduled-action" && $cpost != "shop_subscription"&& $cpost != "wpcf7_contact_form"&& $cpost != "mc4wp-form") {
170
+ $postArr[] = $cpost;
171
+ }
172
+ }
173
+ }
174
+
175
+ delete_option('wfap_post_type');
176
+ if (isset($postArr) && $postArr != null) {
177
+ update_option('wfap_post_type',json_encode(array_values($postArr)));
178
+ }
179
+ $fetchSelecetedPostTypes = get_option('wfap_post_type');
180
+ }
181
+
182
+ $postTypeSelectedDecodeArr = !empty( $fetchSelecetedPostTypes ) ? $fetchSelecetedPostTypes : json_encode( array() );
183
+
184
+
185
+ $fetchSelecetedIpAddress = get_option('ipaddress_visit');
186
+ $optionsIpAddressDecodedArr = !empty( $fetchSelecetedIpAddress ) ? $fetchSelecetedIpAddress : json_encode( array() );
187
+
188
+
189
+ $fetchSelecetedUserId = get_option('userlist_visit');
190
+ $optionsUserIdDecodedArr = !empty( $fetchSelecetedUserId ) ? $fetchSelecetedUserId : json_encode( array() );
191
+
192
+ $pageCount_limit = intval(1);
193
+ $pageCount_qry = $wpdb->prepare('SELECT * FROM ' . $table_name . ' WHERE page_id=%d AND ipaddress=%s AND date=%s LIMIT %d', $page, $ipaddress, $currentdate, $pageCount_limit);
194
+ $pageCount = $wpdb->get_results($pageCount_qry);
195
+
196
+ $getPageSetting = get_post_meta($page,'enable_page_count',true);
197
+
198
+ $u_agent = $_SERVER['HTTP_USER_AGENT'];
199
+
200
+ $bname = 'Unknown';
201
+ $platform = 'Unknown';
202
+ $version= "";
203
+ $ub= "";
204
+
205
+ //First get the platform?
206
+ if (preg_match('/linux/i', $u_agent)) {
207
+ $platform = 'linux';
208
+ }
209
+ elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
210
+ $platform = 'mac';
211
+ }
212
+ elseif (preg_match('/windows|win32/i', $u_agent)) {
213
+ $platform = 'windows';
214
+ }
215
+
216
+ // Next get the name of the useragent yes seperately and for good reason
217
+ if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent))
218
+ {
219
+ $bname = 'Internet Explorer';
220
+ $ub = "MSIE";
221
+ }
222
+ elseif(preg_match('/Firefox/i',$u_agent))
223
+ {
224
+ $bname = 'Mozilla Firefox';
225
+ $ub = "Firefox";
226
+ }
227
+ elseif(preg_match('/Chrome/i',$u_agent))
228
+ {
229
+ $bname = 'Google Chrome';
230
+ $ub = "Chrome";
231
+ }
232
+ elseif(preg_match('/Safari/i',$u_agent))
233
+ {
234
+ $bname = 'Apple Safari';
235
+ $ub = "Safari";
236
+ }
237
+ elseif(preg_match('/Opera/i',$u_agent))
238
+ {
239
+ $bname = 'Opera';
240
+ $ub = "Opera";
241
+ }
242
+ elseif(preg_match('/Netscape/i',$u_agent))
243
+ {
244
+ $bname = 'Netscape';
245
+ $ub = "Netscape";
246
+ }
247
+
248
+
249
+ // finally get the correct version number
250
+ $known = array('Version', $ub, 'other');
251
+ $pattern = '#(?<browser>' . join('|', $known) .
252
+ ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
253
+ if (!preg_match_all($pattern, $u_agent, $matches)) {
254
+ // we have no matching number just continue
255
+ }
256
+
257
+ // see how many we have
258
+ $i = count($matches['browser']);
259
+ if ($i != 1) {
260
+ //we will have two since we are not using 'other' argument yet
261
+ //see if version is before or after the name
262
+ if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
263
+ $version= $matches['version'][0];
264
+ }
265
+ else {
266
+ $version= isset($matches['version'][1]) ? $matches['version'][1] : null;;
267
+ }
268
+ }
269
+ else {
270
+ $version= isset($matches['version'][0]) ? $matches['version'][0] : null;;
271
+ }
272
+
273
+ // check if we have a number
274
+ if ($version==null || $version=="") {$version="?";}
275
+
276
+ $http_referer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] :'';
277
+
278
+ // old version plugin
279
+ if ($fetchSelecetedPostTypes != '') {
280
+
281
+ $postTypeSelectedEncodeArr = json_decode($postTypeSelectedDecodeArr);
282
+ $getPageSetting = get_post_meta($page,'enable_page_count',true);
283
+
284
+ // Check current page/post type exist in settings page array
285
+ if (in_array($page_contet->post_type,$postTypeSelectedEncodeArr)) {
286
+
287
+ // Check current page/post metabox settings is blank OR selected value is yes
288
+ if ($getPageSetting == '' || $getPageSetting == 'yes') {
289
+
290
+ // Check IP Address set in settings page if yes
291
+ if (isset($fetchSelecetedIpAddress) && !empty($fetchSelecetedIpAddress)) {
292
+
293
+ $optionsIpAddressEncodeArr = json_decode($optionsIpAddressDecodedArr);
294
+ // Check IP Address not listed in settings page then go ahed
295
+ if (!in_array($ipaddress,$optionsIpAddressEncodeArr)) {
296
+
297
+ // Check users set in settings page if yes
298
+ if (isset($fetchSelecetedUserId) && !empty($fetchSelecetedUserId)) {
299
+
300
+ $optionsUserIdEncodeArr = json_decode($optionsUserIdDecodedArr);
301
+ $user_id = get_current_user_id();
302
+
303
+ // Check user not listed in settings page then go ahed
304
+ if (!in_array($user_id,$optionsUserIdEncodeArr)) {
305
+
306
+ if (isset($pageCount) && !empty($pageCount)) {
307
+ $existingtotal = (int) $pageCount[0]->page_visit;
308
+ $totalFinal = $existingtotal + 1;
309
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
310
+ $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
311
+ } else {
312
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
313
+ $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
314
+ }
315
+ }
316
+ } else {
317
+ if (isset($pageCount) && !empty($pageCount)) {
318
+ $existingtotal = (int) $pageCount[0]->page_visit;
319
+ $totalFinal = $existingtotal + 1;
320
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
321
+ $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
322
+ } else {
323
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
324
+ $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
325
+ }
326
+ }
327
+ }
328
+ } else {
329
+ // Check users set in settings page if yes
330
+ if (isset($fetchSelecetedUserId) && !empty($fetchSelecetedUserId)) {
331
+
332
+ $optionsUserIdEncodeArr = json_decode($optionsUserIdDecodedArr);
333
+ $user_id = get_current_user_id();
334
+
335
+ // Check user not listed in settings page then go ahed
336
+ if (!in_array($user_id,$optionsUserIdEncodeArr)) {
337
+
338
+ if (isset($pageCount) && !empty($pageCount)) {
339
+ $existingtotal = (int) $pageCount[0]->page_visit;
340
+ $totalFinal = $existingtotal + 1;
341
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
342
+ $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
343
+ } else {
344
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
345
+ $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
346
+ }
347
+ }
348
+ } else {
349
+ if (isset($pageCount) && !empty($pageCount)) {
350
+ $existingtotal = (int) $pageCount[0]->page_visit;
351
+ $totalFinal = $existingtotal + 1;
352
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
353
+ $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
354
+ } else {
355
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
356
+ $insert_Query_history = $wpdb->query("INSERT into $table_name_history (`page_id`, `date`, `lastdate`, `ipaddress`, `browser_full_name`, `browser_short_name`, `browser_version`, `os`, `http_referer`) VALUES($page,NOW(),NOW(),'$ipaddress','$bname','$ub','$version','$platform','$http_referer')");
357
+ }
358
+ }
359
+ }
360
+ }
361
+ }
362
+ }
363
+ }
364
+
365
+ }
366
+
367
+ public function display_page_visit_counter_ajax() {
368
+ global $wpdb, $wp, $post;
369
+
370
+ $pageurl = sanitize_text_field(wp_unslash($_POST['pageurl']));
371
+
372
+ if (is_ssl()) {
373
+ $pageID = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',$pageurl));
374
+ } else {
375
+ $pageID = url_to_postid( $pageurl );
376
+ }
377
+
378
+ if (strpos($pageurl,'/shop') !== false && $pageID == 0 ) {
379
+ $pageID = (int) get_option( 'woocommerce_shop_page_id' );
380
+ }
381
+
382
+ $post = get_post($pageID);
383
+
384
+ $fetchSelecetedPostTypes = get_option('wfap_post_type');
385
+
386
+ $table_name = $wpdb->prefix."page_visit";
387
+
388
+ $pageCount_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageID);
389
+ $pageCount = $wpdb->get_results($pageCount_qry);
390
+
391
+ $table_name_history = $wpdb->prefix."page_visit_history";
392
+
393
+ $pageCountToday_qry = $wpdb->prepare('SELECT COUNT(page_id) as total FROM ' . $table_name_history . ' WHERE page_id=%d AND DATE(`date`) = CURDATE()', $pageID);
394
+ $pageCountToday = $wpdb->get_results($pageCountToday_qry);
395
+
396
+ $total = (int) $pageCount[0]->total;
397
+
398
+ $totalToday = (int) $pageCountToday[0]->total;
399
+
400
+ $temp = array();
401
+
402
+ $temp['today'] = $totalToday;
403
+ $temp['total'] = $total;
404
+
405
+ echo json_encode($temp);
406
+
407
+ die();
408
+
409
+ }
410
+
411
+ public function insert_page_visit_counter_total_block_shop_page($content) {
412
+ global $wpdb, $wp, $post;
413
+
414
+ if (is_ssl()) {
415
+ $actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
416
+ $pageID = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',$actual_link));
417
+ } else {
418
+ $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
419
+ $pageID = url_to_postid( $actual_link );
420
+ }
421
+
422
+ if (($_SERVER['REQUEST_URI'] == '/shop/' || strpos($_SERVER['REQUEST_URI'], '/shop/') !== false ) && $pageID == 0) {
423
+ $pageID = (int) get_option( 'woocommerce_shop_page_id' );
424
+ }
425
+
426
+ if ($pageID != 0) {
427
+ $post = get_post($pageID);
428
+
429
+ $fetchSelecetedPostTypes = get_option('wfap_post_type');
430
+
431
+ $text_color_page_visit = get_option('text_color_page_visit');
432
+
433
+ if (isset($text_color_page_visit) && $text_color_page_visit != null) {
434
+ $text_color_page_visit = 'style="color: '.$text_color_page_visit.';"';
435
+ } else {
436
+ $text_color_page_visit = 'style="color: #000000;"';
437
+ }
438
+
439
+ $enableToday = '';
440
+ $enableToday = get_post_meta($pageID,'enable_page_count_day_wise',true);
441
+
442
+ $table_name = $wpdb->prefix."page_visit";
443
+ $table_name_history = $wpdb->prefix."page_visit_history";
444
+
445
+ $pageCount_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageID);
446
+ $pageCount = $wpdb->get_results($pageCount_qry);
447
+
448
+ $pageCountToday_qry = $wpdb->prepare('SELECT COUNT(page_id) as total FROM ' . $table_name_history . ' WHERE page_id=%d AND DATE(`date`) = CURDATE()', $pageID);
449
+ $pageCountToday = $wpdb->get_results($pageCountToday_qry);
450
+
451
+ $total = (int) $pageCount[0]->total;
452
+ $totalToday = (int) $pageCountToday[0]->total;
453
+
454
+
455
+ $html = '';
456
+ $hide_show_option = get_option('counter_hide_show_front_vew');
457
+ if( $hide_show_option == 'on' ){
458
+ if(!is_feed() && !is_home()) {
459
+ if ($fetchSelecetedPostTypes == '' || $fetchSelecetedPostTypes == null) {
460
+ if ('yes' === $enableToday || '' === $enableToday) {
461
+ $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.$text_color_page_visit.'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits,','page-visit-counter').'<span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor_today">'.esc_attr($totalToday).'</span>'.__('visits today','page-visit-counter').'</p>';
462
+ } else {
463
+ $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.$text_color_page_visit.'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits.','page-visit-counter').'</p>';
464
+ }
465
+ } else {
466
+ $postTypeSelectedEncodeArr = json_decode($fetchSelecetedPostTypes);
467
+ if (in_array($post->post_type,$postTypeSelectedEncodeArr)) {
468
+ $innerSettings = get_post_meta($pageID,'enable_page_count',true);
469
+ if ($innerSettings == '' || $innerSettings == 'yes') {
470
+ if ('yes' === $enableToday || '' === $enableToday) {
471
+ $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.$text_color_page_visit.'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits,','page-visit-counter').'<span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor_today">'.esc_attr($totalToday).'</span>'.__('visits today','page-visit-counter').'</p>';
472
+ } else {
473
+ $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.$text_color_page_visit.'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits.','page-visit-counter').'</p>';
474
+ }
475
+ }
476
+ }
477
+ }
478
+ }
479
+ }
480
+
481
+ echo $content.' '.$html; // WPCS: XSS OK.
482
+ } else {
483
+ echo $content; // WPCS: XSS OK.
484
+ }
485
+
486
+ }
487
+
488
+ public function insert_page_visit_counter_total_block($content) {
489
+ global $wpdb, $wp, $post;
490
+
491
+ if (is_ssl()) {
492
+ $actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
493
+ $pageID = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',esc_url($actual_link)));
494
+ } else {
495
+ $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
496
+ $pageID = url_to_postid( esc_url($actual_link) );
497
+ }
498
+
499
+ if (($_SERVER['REQUEST_URI'] == '/shop/' || strpos($_SERVER['REQUEST_URI'], '/shop/') !== false ) && $pageID == 0) {
500
+ $pageID = (int) get_option( 'woocommerce_shop_page_id' );
501
+ }
502
+
503
+ if ($pageID != 0) {
504
+ $post = get_post($pageID);
505
+
506
+ $fetchSelecetedPostTypes = get_option('wfap_post_type');
507
+
508
+ $text_color_page_visit = get_option('text_color_page_visit');
509
+
510
+ if (isset($text_color_page_visit) && $text_color_page_visit != null) {
511
+ $text_color_page_visit1 = 'style="color: '.esc_attr($text_color_page_visit).';"';
512
+
513
+ // echo esc_attr($text_color_page_visit1);
514
+ // sanitize_text_field(wp_unslash($text_color_page_visit));
515
+ } else {
516
+ $text_color_page_visit1 = 'style="color: #000000;"';
517
+ // sanitize_text_field(wp_unslash($text_color_page_visit));
518
+ }
519
+
520
+ $enableToday = '';
521
+ $enableToday = get_post_meta($pageID,'enable_page_count_day_wise',true);
522
+
523
+ $table_name = $wpdb->prefix."page_visit";
524
+ $table_name_history = $wpdb->prefix."page_visit_history";
525
+
526
+ $pageCount_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageID);
527
+ $pageCount = $wpdb->get_results($pageCount_qry);
528
+
529
+ $pageCountToday_qry = $wpdb->prepare('SELECT COUNT(page_id) as total FROM ' . $table_name_history . ' WHERE page_id=%d AND DATE(`date`) = CURDATE()', $pageID);
530
+ $pageCountToday = $wpdb->get_results($pageCountToday_qry);
531
+
532
+ $total = (int) $pageCount[0]->total;
533
+ $totalToday = (int) $pageCountToday[0]->total;
534
+
535
+ $html = '';
536
+ $hide_show_option = get_option('counter_hide_show_front_vew');
537
+ if( $hide_show_option == 'on' ){
538
+ if(!is_feed() && !is_home()) {
539
+ if ($fetchSelecetedPostTypes == '' || $fetchSelecetedPostTypes == null) {
540
+ if ('yes' === $enableToday || '' === $enableToday) {
541
+ $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.$text_color_page_visit1.'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits,','page-visit-counter').'<span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor_today">'.esc_attr($totalToday).'</span>'.__('visits today','page-visit-counter').'</p>';
542
+ } else {
543
+ $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.$text_color_page_visit1.'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits.','page-visit-counter').'</p>';
544
+ }
545
+ } else {
546
+ $postTypeSelectedEncodeArr = json_decode($fetchSelecetedPostTypes);
547
+ if (in_array($post->post_type,$postTypeSelectedEncodeArr)) {
548
+ $innerSettings = get_post_meta($pageID,'enable_page_count',true);
549
+ if ($innerSettings == '' || $innerSettings == 'yes') {
550
+ if ('yes' === $enableToday || '' === $enableToday) {
551
+ $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.$text_color_page_visit1.'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits,','page-visit-counter').'<span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor_today">'.esc_attr($totalToday).'</span>'.__('visits today','page-visit-counter').'</p>';
552
+ } else {
553
+ $html .= '<p id="default-loop-page-visit-counter" class="page-visit-counter-block" '.$text_color_page_visit1.'><img src="'.esc_url(plugins_url('images/1456175371_vector_65_14.png', dirname(__FILE__) )).'" /><span style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor">'.esc_attr($total).'</span>'.__('total visits.','page-visit-counter').'</p>';
554
+ }
555
+ }
556
+ }
557
+ }
558
+ }
559
+ }
560
+ $get_no_of_days = get_option('no_of_days_to_display');
561
+ if ($get_no_of_days == '') {
562
+ $get_no_of_days = 6;
563
+ } else {
564
+ $get_no_of_days = (int) $get_no_of_days + 1;
565
+ }
566
+ $query = "SELECT `page_id`, COUNT(`page_id`) as count,`date` FROM wp_page_visit_history Where DATE(`lastdate`) > DATE_SUB(CURDATE(), INTERVAL $get_no_of_days DAY) AND DATE(`lastdate`) < CURDATE() AND `page_id` = $pageID GROUP BY `lastdate`";
567
+ return $content.' '.$html;
568
+ } else {
569
+ return $content;
570
+ }
571
+
572
+ }
573
+
574
+
575
+ /**
576
+ * BN code added
577
+ */
578
+
579
+ function paypal_bn_code_filter($paypal_args) {
580
+ $paypal_args['bn'] = 'Multidots_SP';
581
+ return $paypal_args;
582
+ }
583
  }