Page Visit Counter - Version 4.0.6

Version Description

  • 27-04-2018 =
  • minor bug fixed.
Download this release

Release Info

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

Code changes from version 4.0.5 to 4.0.6

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.0.5
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.4
@@ -114,6 +114,10 @@ It is compatible from 2.1 to 4.7 WordPress version.
114
  Automatic updates should work great for you. As always, though, we recommend backing up your site prior to making any updates just to be sure nothing goes wrong.
115
 
116
  == Changelog ==
 
 
 
 
117
  = 4.0.5 - 11-04-2018 =
118
  * Solved issue of view reports.
119
  * minor bug fixing.
4
  Author: Multidots
5
  Author URI: http://multidots.com/
6
  Contributors: dots, ketuchetan, chiragpatel, jitendrabanjara1991
7
+ Stable tag: 4.0.6
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.4
114
  Automatic updates should work great for you. As always, though, we recommend backing up your site prior to making any updates just to be sure nothing goes wrong.
115
 
116
  == Changelog ==
117
+
118
+ = 4.0.6 - 27-04-2018 =
119
+ * minor bug fixed.
120
+
121
  = 4.0.5 - 11-04-2018 =
122
  * Solved issue of view reports.
123
  * minor bug fixing.
admin/class-page-visit-counter-admin.php CHANGED
@@ -19,264 +19,273 @@
19
  * @subpackage page-visit-counter/admin
20
  * @author Multidots <wordpress@multidots.com>
21
  */
22
- class page_visit_counter_Admin {
23
-
24
- /**
25
- * The ID of this plugin.
26
- *
27
- * @since 1.0.0
28
- * @access private
29
- * @var string $plugin_name The ID of this plugin.
30
- */
31
- private $plugin_name;
32
-
33
- /**
34
- * The version of this plugin.
35
- *
36
- * @since 1.0.0
37
- * @access private
38
- * @var string $version The current version of this plugin.
39
- */
40
- private $version;
41
-
42
- /**
43
- * Initialize the class and set its properties.
44
- *
45
- * @since 1.0.0
46
- *
47
- * @param string $plugin_name The name of this plugin.
48
- * @param string $version The version of this plugin.
49
- */
50
- public function __construct( $plugin_name, $version ) {
51
-
52
- $this->plugin_name = $plugin_name;
53
- $this->version = $version;
54
-
55
- }
56
-
57
- /**
58
- * Register the stylesheets for the admin area.
59
- *
60
- * @since 1.0.0
61
- */
62
-
63
- public function enqueue_styles() {
64
-
65
- /**
66
- * This function is provided for demonstration purposes only.
67
- *
68
- * An instance of this class should be passed to the run() function
69
- * defined in Woo_Extra_Flat_Rate_Loader as all of the hooks are defined
70
- * in that particular class.
71
- *
72
- * The Woo_Extra_Flat_Rate_Loader will then create the relationship
73
- * between the defined hooks and the functions defined in this
74
- * class.
75
- */
76
-
77
- //wp_enqueue_style("jquery-ui-tabs");
78
-
79
- wp_enqueue_style( 'custom-style', plugin_dir_url( __FILE__ ) . 'css/style.css' );
80
- wp_enqueue_style( 'datatable-style', plugin_dir_url( __FILE__ ) . 'css/jquery.dataTables.css' );
81
- wp_enqueue_style( 'jquery-style', plugin_dir_url( __FILE__ ) . 'css/jquery-ui.css' );
82
- wp_enqueue_style( 'chosen-style', plugin_dir_url( __FILE__ ) . 'css/chosen.css' );
83
- //wp_enqueue_style('fancy-box-style', plugin_dir_url( __FILE__ ) . 'css/jquery.fancybox-1.3.4.css');
84
- wp_enqueue_style( 'color-box-style', plugin_dir_url( __FILE__ ) . 'css/colorbox.css' );
85
- //wp_enqueue_style('color-picker', plugin_dir_url( __FILE__ ) . 'css/color-picker.min.css');
86
- wp_enqueue_style( 'wp-color-picker' );
87
- wp_enqueue_style( 'wp-pointer' );
88
- }
89
-
90
- /**
91
- * Register the JavaScript for the admin area.
92
- *
93
- * @since 1.0.0
94
- */
95
- public function enqueue_scripts() {
96
-
97
- /**
98
- * This function is provided for demonstration purposes only.
99
- *
100
- * An instance of this class should be passed to the run() function
101
- * defined in Woo_Extra_Flat_Rate_Loader as all of the hooks are defined
102
- * in that particular class.
103
- *
104
- * The Woo_Extra_Flat_Rate_Loader will then create the relationship
105
- * between the defined hooks and the functions defined in this
106
- * class.
107
- */
108
-
109
- wp_enqueue_script( 'jquery-ui-core' );
110
- wp_enqueue_script( 'jquery-ui-tabs' );
111
- wp_enqueue_script( 'jquery-ui-datepicker' );
112
- //wp_deregister_style( 'wp-jquery-ui-dialog' );
113
- //wp_enqueue_script( 'wp-jquery-ui-dialog' );
114
- wp_enqueue_script( 'jquery-ui-dialog' );
115
-
116
- //enqueue script for notice pointer
117
- wp_enqueue_script( 'wp-pointer' );
 
 
 
 
118
 
119
  // if ( ! empty( $_GET['page'] ) && $_GET['page'] != '' && $_GET['page'] == 'page-visit-counter-about' ) {
120
  // wp_enqueue_script( 'one', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), $this->version, false );
121
  // }
122
- if (isset($_GET['page'])) {
123
- if ( !empty( $_GET['page'] ) && $_GET['page'] != '' || ($_GET['page'] == 'page_visit_settings ' || $_GET['page'] == 'page-visit-counter-about' || $_GET['page'] == 'page_visit_counter') ) {
124
- wp_enqueue_script( 'one', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), $this->version, false );
125
- }
126
- }
127
- wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/jquery.dataTables.min.js', array( 'jquery' ), $this->version, false );
128
-
129
- //wp_enqueue_script('google-chart', 'https://www.gstatic.com/charts/loader.js', array( 'jquery' ), $this->version);
130
-
131
- wp_enqueue_script( 'chosen-jquery', plugin_dir_url( __FILE__ ) . 'js/chosen.jquery.js', array( 'jquery' ), $this->version, false );
132
- wp_enqueue_script( 'chosen-proto', plugin_dir_url( __FILE__ ) . 'js/chosen.proto.js', array( 'jquery' ), $this->version, false );
133
- wp_enqueue_script( 'color-box', plugin_dir_url( __FILE__ ) . 'js/jquery.colorbox.js', array( 'jquery' ), $this->version, false );
134
-
135
- wp_enqueue_script( 'iris', admin_url( 'js/iris.min.js' ), array(
136
- 'jquery-ui-draggable',
137
- 'jquery-ui-slider',
138
- 'jquery-touch-punch'
139
- ), false, 1 );
140
- wp_enqueue_script( 'wp-color-picker', admin_url( 'js/color-picker.min.js' ), array( 'iris' ), false, 1 );
141
-
142
- $colorpicker_l10n = array(
143
- 'clear' => __( 'Clear' ),
144
- 'defaultString' => __( 'Default' ),
145
- 'pick' => __( 'Select Color' )
146
- );
147
- if (!empty($colorpicker_l10n) || $colorpicker_l10n != "") {
148
- wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n );
149
- } else {
150
- wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', '' );
151
- }
152
-
153
- wp_localize_script( 'one', 'pagevisit', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
154
-
155
- $fetchSelecetedPostTypes = get_option( 'wfap_post_type' );
156
- if (!empty($fetchSelecetedPostTypes) || $fetchSelecetedPostTypes != "") {
157
- $options = ! empty( $fetchSelecetedPostTypes ) ? $fetchSelecetedPostTypes : json_encode( array() );
158
- if (!empty($options) || $options != "") {
159
- wp_localize_script( 'one', 'get_post_option', array( 'optionsarray' => $options ) );
160
- } else{
161
- wp_localize_script( 'one', 'get_post_option', array( 'optionsarray' => '' ) );
162
- }
163
- } else {
164
- wp_localize_script( 'one', 'get_post_option', array( 'optionsarray' => '' ) );
165
- }
166
-
167
- $fetchSelecetedIpAddress = get_option( 'ipaddress_visit' );
168
- if (!empty($fetchSelecetedIpAddress) || $fetchSelecetedIpAddress != "") {
169
- $optionsIpAddress = ! empty( $fetchSelecetedIpAddress ) ? $fetchSelecetedIpAddress : json_encode( array() );
170
- if (!empty($optionsIpAddress) || $optionsIpAddress != "") {
171
- wp_localize_script( 'one', 'get_ip_option', array( 'ipaddressarray' => $optionsIpAddress ) );
172
- } else{
173
- wp_localize_script( 'one', 'get_ip_option', array( 'ipaddressarray' => '' ) );
174
- }
175
- } else {
176
- wp_localize_script( 'one', 'get_ip_option', array( 'ipaddressarray' => '' ) );
177
- }
178
-
179
- $fetchSelecetedUserId = get_option( 'userlist_visit' );
180
- if (!empty($fetchSelecetedUserId) || $fetchSelecetedUserId != "") {
181
- $optionsUserId = ! empty( $fetchSelecetedUserId ) ? $fetchSelecetedUserId : json_encode( array() );
182
- if (!empty($optionsUserId) || $optionsUserId != "") {
183
- wp_localize_script( 'one', 'get_user_option', array( 'usersarray' => $optionsUserId ) );
184
- } else{
185
- wp_localize_script( 'one', 'get_user_option', array( 'usersarray' => '' ) );
186
- }
187
- } else {
188
- wp_localize_script( 'one', 'get_user_option', array( 'usersarray' => '' ) );
189
- }
190
-
191
- }
192
-
193
-
194
- public function welcome_page_visit_counter_screen_do_activation_redirect() {
195
- // if no activation redirect
196
- if ( ! get_transient( '_welcome_screen_page_visitor_activation_redirect_data' ) ) {
197
- return;
198
- }
199
-
200
- // Delete the redirect transient
201
- delete_transient( '_welcome_screen_page_visitor_activation_redirect_data' );
202
-
203
- // if activating from network, or bulk
204
- if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
205
- return;
206
- }
207
- // Redirect to extra cost welcome page
208
- wp_safe_redirect( add_query_arg( array( 'page' => 'page-visit-counter-about&tab=about' ), admin_url( 'index.php' ) ) );
209
- }
210
-
211
- public function welcome_pages_screen_page_visit_counter() {
212
- add_dashboard_page(
213
- 'Page Visit counter Dashboard', 'Page Visit counter Dashboard', 'read', 'page-visit-counter-about', array(
214
- &$this,
215
- 'welcome_screen_content_page_visit_counter'
216
- )
217
- );
218
- }
219
-
220
- public function admin_css() {
221
- wp_enqueue_style( $this->plugin_name . 'welcome-page', plugin_dir_url( __FILE__ ) . 'css/style.css', array(), $this->version, 'all' );
222
- }
223
-
224
- public function welcome_screen_content_page_visit_counter() {
225
- ?>
 
 
 
 
226
  <div class="wrap about-wrap">
227
- <h1 style="font-size: 2.1em;"><?php printf( __( 'Welcome to Page Visit Counter', 'page-visit-counter' ) ); ?></h1>
228
 
229
  <div class="about-text woocommerce-about-text">
230
- <?php
231
- $message = '';
232
- printf( __( '%s This plugin will count the total visits of your sites pages.', 'page-visit-counter' ), $message, $this->version );
233
- ?>
234
  <img class="version_logo_img"
235
- src="<?php echo plugin_dir_url( __FILE__ ) . 'images/page_visit_counter.png'; ?>">
236
  </div>
237
 
238
- <?php
239
- $setting_tabs_wc = apply_filters( 'page_visit_counter_setting_tab', array(
240
- "about" => "Overview",
241
- "other_plugins" => "Checkout our other plugins"
242
- ) );
243
- $current_tab_wc = ( isset( $_GET['tab'] ) ) ? $_GET['tab'] : 'general';
244
- $aboutpage = isset( $_GET['page'] )
245
- ?>
246
  <h2 id="woo-extra-cost-tab-wrapper" class="nav-tab-wrapper">
247
- <?php
248
- foreach ( $setting_tabs_wc as $name => $label ) {
249
- echo '<a href="' . home_url( 'wp-admin/index.php?page=page-visit-counter-about&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab_wc == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
250
- }
251
- ?>
252
  </h2>
253
 
254
- <?php
255
- foreach ( $setting_tabs_wc as $setting_tabkey_wc => $setting_tabvalue ) {
256
- switch ( $setting_tabkey_wc ) {
257
- case $current_tab_wc:
258
- do_action( 'page_visit_counter_' . $current_tab_wc );
259
- break;
260
- }
261
- }
262
- ?>
263
  <hr/>
264
  <div class="return-to-dashboard">
265
- <a href="<?php echo home_url( '/wp-admin/admin.php?page=page_visit_settings' ); ?>"><?php _e( 'Go to Page Visit Counter Settings', 'page-visit-counter' ); ?></a>
266
  </div>
267
  </div>
268
- <?php
269
- }
270
-
271
- /**
272
- * Extra flate rate overview welcome page content function
273
- *
274
- */
275
- public function page_visit_counter_about() {
276
- //do_action('my_own');
277
- $current_user = wp_get_current_user();
278
-
279
- ?>
 
280
  <div class="changelog">
281
 
282
  </br>
@@ -298,7 +307,7 @@ class page_visit_counter_Admin {
298
  <div class="changelog about-integrations">
299
  <div class="wc-feature feature-section col three-col">
300
  <div>
301
- <p class="page_visit_overview"><?php _e( 'This Plugin use for front side post and pages counter. After activation of plugin it will automatically add page counts on bottom of all pages. So, that all visitors can see page counts for entire site pages. Plugin provide search by page title and search by page published date facilities. Settings are required for page counter. Plugin provide to select specific post type to include in post /pages counter. Plugin also provide to exclude specific IP/s and specific register user to exude from post/pages counter.', 'page-visit-counter' ); ?></p>
302
  <p class="page_visit_overview"><strong>Page Counter Settings: </strong></p>
303
  <div class="Page_Counter_Settings_Content_ul">
304
  <ul>
@@ -354,129 +363,136 @@ class page_visit_counter_Admin {
354
  </div>
355
  </div>
356
  </div>
357
- <?php
358
- if ( ! get_option( 'pvcp_plugin_notice_shown' ) ) {
359
- echo '<div id="pvcp_dialog" title="Basic dialog"> <p> Subscribe for latest plugin update and get notified when we update our plugin and launch new products for free! </p> <p><input type="text" id="txt_user_sub_pvcp" class="regular-text" name="txt_user_sub_pvcp" value="' . $current_user->user_email . '"></p></div>';
360
- }
361
- }
362
-
363
- /**
364
- * Extra flate rate other plugin welcome page content function
365
- *
366
- */
367
- public function page_visit_counter_other_plugins() {
368
- global $wpdb;
369
- $url = 'http://www.multidots.com/store/wp-content/themes/business-hub-child/API/checkout_other_plugin.php';
370
- $response = wp_remote_post( $url, array(
371
- 'method' => 'POST',
372
- 'timeout' => 45,
373
- 'redirection' => 5,
374
- 'httpversion' => '1.0',
375
- 'blocking' => true,
376
- 'headers' => array(),
377
- 'body' => array( 'plugin' => 'advance-flat-rate-shipping-method-for-woocommerce' ),
378
- 'cookies' => array()
379
- ) );
380
-
381
- $response_new = array();
382
- $response_new = json_decode( $response['body'] );
383
- $get_other_plugin = maybe_unserialize( $response_new );
384
-
385
- $paid_arr = array();
386
- ?>
 
387
 
388
  <div class="plug-containter">
389
  <div class="paid_plugin">
390
  <h3>Paid Plugins</h3>
391
- <?php foreach ( $get_other_plugin as $key => $val ) {
392
- if ( $val['plugindesc'] == 'paid' ) { ?>
 
393
 
394
 
395
- <div class="contain-section">
396
- <div class="contain-img"><img src="<?php echo $val['pluginimage']; ?>"></div>
397
- <div class="contain-title"><a target="_blank"
398
- href="<?php echo $val['pluginurl']; ?>"><?php echo $key; ?></a>
 
399
  </div>
400
- </div>
401
 
402
 
403
- <?php } else {
404
 
405
- $paid_arry[ $key ]['plugindesc'] = $val['plugindesc'];
406
- $paid_arry[ $key ]['pluginimage'] = $val['pluginimage'];
407
- $paid_arry[ $key ]['pluginurl'] = $val['pluginurl'];
408
- $paid_arry[ $key ]['pluginname'] = $val['pluginname'];
409
 
410
- ?>
411
 
412
 
413
- <?php }
414
- } ?>
 
 
415
  </div>
416
- <?php if ( isset( $paid_arry ) && ! empty( $paid_arry ) ) { ?>
417
  <div class="free_plugin">
418
  <h3>Free Plugins</h3>
419
- <?php foreach ( $paid_arry as $key => $val ) { ?>
420
  <div class="contain-section">
421
  <div class="contain-img"><img src="<?php echo $val['pluginimage']; ?>"></div>
422
  <div class="contain-title"><a target="_blank"
423
  href="<?php echo $val['pluginurl']; ?>"><?php echo $key; ?></a>
424
  </div>
425
  </div>
426
- <?php }
427
- } ?>
428
  </div>
429
 
430
  </div>
431
 
432
- <?php
433
- }
434
-
435
- /**
436
- * Remove the Extra flate rate menu in dashboard
437
- *
438
- */
439
- public function welcome_screen_remove_menus() {
440
- remove_submenu_page( 'index.php', 'page-visit-counter-about' );
441
- }
442
-
443
- /**
444
- * admin menu page fnction
445
- * add menu in admin menubar.
446
- *
447
- */
448
- public function page_visit_counter_menu() {
449
- add_menu_page( __( 'Page-Visit-Counter', 'page-visit-counter' ), __( 'PageVisitCounter', 'page-visit-counter' ), 'manage_options', 'page_visit_counter', 'extra_page_visit_function_custom', plugins_url( 'page-visit-counter/admin/images/icon.png' ) );
450
- add_submenu_page( 'page_visit_counter', __( 'Counter-Settings', 'page-visit-counter' ), __( 'Settings', 'page-visit-counter' ), 'manage_options', 'page_visit_settings', 'custom_page_visit_settings' );
451
- /**
452
- * extra_page_visit_function_custom use the menu callback function
453
- * $name pass the arguments
454
- */
455
- function extra_page_visit_function_custom( $name ) {
456
- global $wpdb;
457
-
458
- if ( ! class_exists( 'WP_List_Table' ) ) {
459
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
460
- }
461
-
462
- require plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-tt-pvc-list-table.php';
463
-
464
- // Create an instance of our package class.
465
- $test_list_table = new TT_Example_List_Table();
466
- // Fetch, prepare, sort, and filter our data.
467
- $test_list_table->prepare_items();
468
-
469
- $table_name = $wpdb->prefix . "page_visit";
470
- ?>
 
 
 
471
 
472
 
473
  <div class="main-page-visit set_pvc_containter">
474
  <div class="page-title">
475
- <h1><?php echo __( 'Page Visit Counter', 'page-visit-counter' ); ?></h1>
476
  </div>
477
 
478
- <?php
479
- if ( isset( $_REQUEST['id'] ) && ! empty( $_REQUEST['id'] ) ) { ?>
480
  <style type="text/css">
481
  .tabs div#chartContainer-main {
482
  float: left;
@@ -823,19 +839,19 @@ class page_visit_counter_Admin {
823
 
824
 
825
  </script>
826
- <?php
827
- } else { ?>
828
  <form id="movies-filter" method="get">
829
- <?php
830
- $test_list_table->search_box( __( 'Search' ), 'page-visit-counter' );
831
- foreach ( $_GET as $key => $value ) { // http://stackoverflow.com/a/8763624/1287812
832
- if ( 's' !== $key ) // don't include the search query
833
- {
834
- echo( "<input type='hidden' name='$key' value='$value' />" );
835
- }
836
- }
837
- $test_list_table->display();
838
- ?>
839
  </form>
840
 
841
  <!-- Twitter -->
@@ -872,42 +888,43 @@ class page_visit_counter_Admin {
872
  })();
873
  </script>
874
 
875
- <?php
876
- } ?>
877
 
878
  </div>
879
 
880
- <?php
881
- }
882
-
883
- /**
884
- * function use to page settings
885
- * $args is pass the arguments
886
- */
887
- function custom_page_visit_settings( $args ) {
888
-
889
- global $wpdb;
890
- $current_user = wp_get_current_user();
891
- // Get all the registered post type
892
- $post_types = get_post_types();
893
-
894
- // Get all the post type selected in settings page
895
- $post_list = array();
896
- $post = json_decode( get_option( 'wfap_post_type' ) );
897
- $post_list = $post;
898
-
899
- $text_color_page_visit = get_option( 'text_color_page_visit' );
900
- if ( isset( $text_color_page_visit ) && $text_color_page_visit != null ) {
901
- $text_color_page_visit = $text_color_page_visit;
902
- } else {
903
- $text_color_page_visit = '#000000';
904
- }
905
-
906
- if ( ! get_option( 'pvcp_plugin_notice_shown' ) ) {
907
- echo '<div id="pvcp_dialog" title="Basic dialog"> <p> Subscribe for latest plugin update and get notified when we update our plugin and launch new products for free! </p> <p><input type="text" id="txt_user_sub_pvcp" class="regular-text" name="txt_user_sub_pvcp" value="' . $current_user->user_email . '"></p></div>';
908
- }
909
-
910
- ?>
 
911
  <div class="main-page-visit-settings">
912
  <div class="page-title-settings">
913
  <form id="pvc_plugin_form_id" method="post" action="<?php echo get_admin_url(); ?>admin-post.php"
@@ -916,35 +933,35 @@ class page_visit_counter_Admin {
916
  <input type="hidden" name="action" value="submit_form_pvc"/>
917
  <input id="action_which" type="hidden" name="action-which" value="add"/>
918
  <div class="set_pvc_containter set_plugin_descriptions">
919
- <h3><?php echo __( 'Page Counter Settings', 'page-visit-counter' ); ?></h3>
920
- <p><?php echo __( 'Page Visit Counter plugin use for front side post and pages counter. After activation of plugin it will automatically add page counts on bottom of all pages. So, that all visitors can see page counts for entire site pages.', 'page-visit-counter' ); ?></p>
921
  <ul style="list-style-type: disc;padding: 3px 2px 2px 34px;">
922
  <li>
923
- <p><?php echo __( 'Specific page vise reports like Top browsers, Top 10 IP address, Top referer, weekly report and Monthly report using chart.', 'page-visit-counter' ); ?></p>
924
  </li>
925
  <li>
926
- <p><?php echo __( 'Search facility: search pages by title and search page by its created date.', 'page-visit-counter' ); ?></p>
927
  </li>
928
  <li>
929
- <p><?php echo __( 'Sharing facility: share specific page on Facebook, Twitter and Google Plus.', 'page-visit-counter' ); ?></p>
930
  </li>
931
  </ul>
932
  </div>
933
 
934
  <div class="set_pvc_containter set_plugin_descriptions_shortcode">
935
  <fieldset>
936
- <legend><?php echo __( 'Short Code', 'page-visit-counter' ); ?></legend>
937
- <p><?php echo __( 'There are two shortcodes that you can use to manually add page view count to any content on admin or post/page template created by your theme or plugin thats create it\'s own display content in page/post.', 'page-visit-counter' ); ?></p>
938
- <p><?php echo __( 'Use this shortcode to add admin side content on page/post:', 'page-visit-counter' ); ?>
939
- <b><?php echo __( htmlspecialchars( '[page_visit_counter_md id="<page_id/post_id>"]' ), 'page-visit-counter' ); ?></b>
940
  </p>
941
- <p><?php echo __( 'Use this shortcode to display total sites visit to add admin side content on page/post:', 'page-visit-counter' ); ?>
942
- <b><?php echo __( htmlspecialchars( '[page_visit_counter_md_total_sites_visit backgroundcolor="#ff0000" countboxcolor="#000000" fontcolor="#FFFFFF" bordercolor="#ff0000"]' ), 'page-visit-counter' ); ?></b>
943
  </p>
944
- <p><?php echo __( 'Use this shortcode to add page/post template (.php) file of your own template:', 'page-visit-counter' ); ?>
945
  <b> <?php echo "&lt;?php echo do_shortcode('[page_visit_counter_md id='page_id/post_id']');?&gt;" ?></b>
946
  </p>
947
- <p><?php echo __( 'Use this shortcode to display total sites visit to add page/post template (.php) file of your own template:', 'page-visit-counter' ); ?>
948
  <br><b> &lt;?php echo do_shortcode('[page_visit_counter_md_total_sites_visit
949
  backgroundcolor='#ff0000' countboxcolor='#000000' fontcolor='#FFFFFF'
950
  bordercolor='#ff0000']');?&gt; </b></p>
@@ -953,111 +970,111 @@ class page_visit_counter_Admin {
953
 
954
  <div class="set_pvc_containter set_plugin_descriptions">
955
  <fieldset>
956
- <legend><?php echo __( 'Basic Configuration settings', 'page-visit-counter' ); ?></legend>
957
- <?php
958
- $get_option_value = json_decode( get_option( 'page_count_settings' ) );
959
- $input_values = isset( $get_option_value[1] ) ? $get_option_value[1] : array();
960
- $select_values = isset( $get_option_value[0] ) ? $get_option_value[0] : array();
961
- ?>
962
  <table border="0" cellpadding="10" cellspacing="0">
963
  <tbody>
964
  <tr>
965
  <th scope="row"><label
966
- for="blogname"><?php echo __( 'Post Type', 'page-visit-counter' ); ?></label>
967
  </th>
968
  <td>
969
  <select id="post_type"
970
- data-placeholder=" <?php echo __( 'Add Page/Post Type', 'page-visit-counter' ); ?>"
971
  name="post_ty[]" multiple="true"
972
  class="chosen-select-post category-select chosen-rtl validate_field1">
973
  <option value=""></option><?php
974
- if ( isset( $post_types ) && ! empty( $post_types ) ) {
975
- foreach ( $post_types as $cpost ) {
976
- 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" ) { ?>
977
  <option
978
  value="<?php echo $cpost; ?>"><?php echo $cpost; ?></option><?php
979
- }
980
- }
981
- } ?>
982
  </select>
983
- <p><?php echo __( '(Select post types for which post views will be counted.)', 'page-visit-counter' ); ?></p>
984
  <!--<p>(<b><?php //echo __('Note: To start the count of the page/post please select the Cpt (custom post type), page or post from above select box. If you not select any one then it will not start to count.', 'page-visit-counter'); ?></b>)</p>-->
985
  </td>
986
  </tr>
987
 
988
  <tr class="ipaddress">
989
  <th scope="row"><label
990
- for="blogname"><?php echo __( 'Exclude IPs (Ip Address)', 'page-visit-counter' ); ?></label>
991
  </th>
992
  <td>
993
  <select id="ip_address"
994
- data-placeholder=" <?php echo __( 'Add IP Address in comma seprated', 'page-visit-counter' ); ?>"
995
  name="ip-basic[]" multiple="true"
996
  class="chosen-select-ip category-select chosen-rtl validate_field1">
997
  <option value=""></option><?php
998
- $get_option_value_ip = json_decode( get_option( 'ipaddress_visit' ) );
999
- if ( isset( $get_option_value_ip ) && ! empty( $get_option_value_ip ) ) {
1000
- foreach ( $get_option_value_ip as $ip ) { ?>
1001
  <option
1002
  value="<?php echo $ip; ?>"><?php echo $ip; ?></option><?php
1003
- }
1004
- } ?>
1005
  </select>
1006
- <p><?php echo __( '(Enter the IP addresses to be excluded from post views count.)', 'page-visit-counter' ); ?></p>
1007
  </td>
1008
  </tr>
1009
 
1010
  <tr class="users">
1011
  <th scope="row"><label
1012
- for="blogname"><?php echo __( 'Exclude Users', 'page-visit-counter' ); ?></label>
1013
  </th>
1014
  <td>
1015
  <select id="users_list"
1016
- data-placeholder="<?php echo __( 'Select Registerd Users', 'page-visit-counter' ); ?>"
1017
  name="user-basic[]" multiple="true"
1018
  class="chosen-select category-select chosen-rtl validate_field1">
1019
  <option value=""></option><?php
1020
- $query = "SELECT * FROM $wpdb->users";
1021
- $resultSetsArr = $wpdb->get_results( $query );
1022
- if ( isset( $resultSetsArr ) && ! empty( $resultSetsArr ) ) {
1023
- foreach ( $resultSetsArr as $value ) { ?>
1024
  <option
1025
  value="<?php echo $value->ID; ?>"><?php echo $value->user_email; ?></option><?php
1026
- }
1027
- } ?>
1028
  </select>
1029
- <p><?php echo __( '(Select the users to be excluded from post views count.)', 'page-visit-counter' ); ?></p>
1030
  </td>
1031
  </tr>
1032
 
1033
  <tr class="hidefront">
1034
  <th scope="row"><label
1035
- for="blogname"><?php echo __( 'Show front view counter', 'page-visit-counter' ); ?></label>
1036
  </th>
1037
- <?php
1038
- $hide_show_option = get_option( 'counter_hide_show_front_vew' );
1039
- if ( $hide_show_option == 'on' ) {
1040
- $cheked = 'checked';
1041
- } else {
1042
- $cheked = '';
1043
- } ?>
1044
  <td class="information">
1045
  <input type="checkbox" name="hidefrontview"
1046
- id="hide_front_view" <?php echo $cheked; ?>><?php echo __( 'Check the box if you want to display counter view on front end.', 'page-visit-counter' ); ?>
1047
  </td>
1048
  </tr>
1049
 
1050
  <tr class="hidefront" style="display:none;">
1051
  <th scope="row"><label
1052
- for="blogname"><?php echo __( 'Last How many days count you want to display on front end.', 'page-visit-counter' ); ?></label>
1053
  </th>
1054
  <td class="information">
1055
- <?php
1056
- $get_no_of_days = get_option( 'no_of_days_to_display' );
1057
- if ( $get_no_of_days == '' ) {
1058
- $get_no_of_days = '';
1059
- }
1060
- ?>
1061
  <input type="text" name="no_of_days_to_display" id="no_of_days_to_display"
1062
  value="<?php echo $get_no_of_days; ?>">
1063
  </td>
@@ -1065,7 +1082,7 @@ class page_visit_counter_Admin {
1065
 
1066
  <tr class="">
1067
  <th scope="row"><label
1068
- for="blogname"><?php echo __( 'Choose color for the front end view', 'page-visit-counter' ); ?></label>
1069
  </th>
1070
  <td class="information">
1071
  <input id="text_color_page_visit" type="text" name="textcolor"
@@ -1079,542 +1096,553 @@ class page_visit_counter_Admin {
1079
  </div>
1080
  <p class="submit">
1081
  <input type="submit" name="submit" class="button button-primary"
1082
- value="<?php echo __( 'Save Changes', 'page-visit-counter' ); ?>">
1083
  <input type="submit" id="pvc_reset_settings"
1084
- value="<?php echo __( 'Reset all settings', 'page-visit-counter' ); ?>"
1085
  class="button button-primary">
1086
  <input type="submit" id="pvc_reset_counter"
1087
- value="<?php echo __( 'Reset all pages counts & report ', 'page-visit-counter' ); ?>"
1088
  class="button button-primary">
1089
  </p>
1090
  </form>
1091
  </div>
1092
  </div>
1093
- <?php
1094
- }
1095
- }
1096
-
1097
-
1098
- public function wp_add_plugin_userfn() {
1099
- $email_id = ( isset( $_POST["email_id"] ) && ! empty( $_POST["email_id"] ) ) ? $_POST["email_id"] : '';
1100
- $log_url = ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
1101
- $cur_date = date( 'Y-m-d' );
1102
- $request_url = 'https://store.multidots.com/wp-content/themes/business-hub-child/API/wp-add-plugin-users.php';
1103
- if ( ! empty( $email_id ) ) {
1104
- $response_args = array(
1105
- 'method' => 'POST',
1106
- 'timeout' => 45,
1107
- 'redirection' => 5,
1108
- 'httpversion' => '1.0',
1109
- 'blocking' => true,
1110
- 'headers' => array(),
1111
- 'body' => array(
1112
- 'user' => array(
1113
- 'plugin_id' => '6',
1114
- 'user_email' => $email_id,
1115
- 'plugin_site' => $log_url,
1116
- 'status' => 1,
1117
- 'activation_date' => $cur_date
1118
- )
1119
- ),
1120
- 'cookies' => array()
1121
- );
1122
- $request_response = wp_remote_post( $request_url, $response_args );
1123
- if ( ! is_wp_error( $request_response ) ) {
1124
- update_option( 'pvcp_plugin_notice_shown', 'true' );
1125
- }
1126
- }
1127
- wp_die();
1128
- }
1129
-
1130
-
1131
- /**
1132
- * function create dashboad widget.
1133
- * view most visited page in dashboard.
1134
- *
1135
- */
1136
- function my_custom_dashboard_widgets() {
1137
- global $wp_meta_boxes;
1138
- wp_add_dashboard_widget( 'custom_help_widget', __( 'Most Visited Page', 'page-visit-counter' ), 'custom_dashboard_help' );
1139
- function custom_dashboard_help() {
1140
- global $wpdb;
1141
- $table_name = $wpdb->prefix . "page_visit";
1142
- $html = '';
1143
- $count_visit = $wpdb->get_results( "SELECT page_id,id,SUM(page_visit) as c from $table_name group by page_id order by c DESC limit 5" );
1144
- $html .= '<div class="main_custom_dashboard_visit_page">';
1145
- if ( ! empty( $count_visit ) && isset( $count_visit ) ) {
1146
- $html .= '<table border="0" cellpadding="5" cellspacing="10">';
1147
- $html .= '<tr>';
1148
- $html .= '<th>' . __( 'Page id', 'page-visit-counter' ) . '</th>';
1149
- $html .= '<th>' . __( 'Page Name', 'page-visit-counter' ) . '</th>';
1150
- $html .= '<th>' . __( 'Total Count', 'page-visit-counter' ) . '</th>';
1151
- $html .= '</tr>';
1152
-
1153
- foreach ( $count_visit as $visitpage ) {
1154
- $page = get_post( $visitpage->page_id );
1155
- $html .= '<tr>';
1156
- $html .= '<td>' . $page->ID . '</td>';
1157
- $html .= '<td><a href="' . get_admin_url() . 'post.php?post=' . $page->ID . '&action=edit">' . __( $page->post_title, 'page-visit-counter' ) . '</a></td>';
1158
- $html .= '<td>' . $visitpage->c . '</td>';
1159
- $html .= '</tr>';
1160
- }
1161
- $html .= '</table>';
1162
- } else {
1163
- $html .= 'No Page Found.';
1164
- }
1165
- $html .= '</div>';
1166
- echo $html;
1167
- }
1168
- }
1169
-
1170
- /**
1171
- * this function use to page settings submit callback function
1172
- * add option by option table
1173
- * add page count option and duration.
1174
- */
1175
- public function add_page_count_option() {
1176
- global $wpdb;
1177
-
1178
- $page_count_option = array();
1179
-
1180
- $getformsumbitaction = ! empty( $_POST['action'] ) ? $_POST['action'] : '';
1181
- $getformactiontype = ! empty( $_POST['action-which'] ) ? $_POST['action-which'] : '';
1182
-
1183
- if ( ! empty( $getformsumbitaction ) && $getformsumbitaction == 'submit_form_pvc' && ! empty( $getformactiontype ) && $getformactiontype == 'add' ) {
1184
-
1185
- $type = isset( $_POST['post_ty'] ) ? $_POST['post_ty'] : array();
1186
- $ipAddress = isset( $_POST['ip-basic'] ) ? $_POST['ip-basic'] : array();
1187
- $userList = isset( $_POST['user-basic'] ) ? $_POST['user-basic'] : array();
1188
- $hidefrontview = isset( $_POST['hidefrontview'] ) ? $_POST['hidefrontview'] : '';
1189
- $text_color_page_visit = isset( $_POST['textcolor'] ) ? $_POST['textcolor'] : '';
1190
-
1191
- $twitter_url_page_visit = isset( $_POST['twitter_url_page_visit'] ) ? $_POST['twitter_url_page_visit'] : '';
1192
- $gplus_url_page_visit = isset( $_POST['gplus_url_page_visit'] ) ? $_POST['gplus_url_page_visit'] : '';
1193
- $fb_url_page_visit = isset( $_POST['fb_url_page_visit'] ) ? $_POST['fb_url_page_visit'] : '';
1194
- $no_of_days_to_display = isset( $_POST['no_of_days_to_display'] ) ? $_POST['no_of_days_to_display'] : '';
1195
-
1196
- delete_option( 'wfap_post_type' );
1197
- if ( isset( $type ) && $type != null ) {
1198
- update_option( 'wfap_post_type', json_encode( array_values( $type ) ) );
1199
- }
1200
-
1201
- delete_option( 'ipaddress_visit' );
1202
- if ( isset( $ipAddress ) && $ipAddress != null ) {
1203
- update_option( 'ipaddress_visit', json_encode( array_values( $ipAddress ) ) );
1204
- }
1205
-
1206
- delete_option( 'userlist_visit' );
1207
- if ( isset( $userList ) && $userList != null ) {
1208
- update_option( 'userlist_visit', json_encode( array_values( $userList ) ) );
1209
- }
1210
-
1211
- if ( isset( $hidefrontview ) && $hidefrontview != null ) {
1212
- update_option( 'counter_hide_show_front_vew', $hidefrontview );
1213
- } else {
1214
- update_option( 'counter_hide_show_front_vew', '' );
1215
- }
1216
-
1217
- if ( isset( $no_of_days_to_display ) && $no_of_days_to_display != null ) {
1218
- update_option( 'no_of_days_to_display', $no_of_days_to_display );
1219
- } else {
1220
- update_option( 'no_of_days_to_display', '' );
1221
- }
1222
-
1223
- if ( isset( $text_color_page_visit ) && $text_color_page_visit != null ) {
1224
- update_option( 'text_color_page_visit', $text_color_page_visit );
1225
- }
1226
-
1227
- if ( isset( $twitter_url_page_visit ) && $twitter_url_page_visit != null ) {
1228
- update_option( 'twitter_url_page_visit', $twitter_url_page_visit );
1229
- }
1230
-
1231
- if ( isset( $gplus_url_page_visit ) && $gplus_url_page_visit != null ) {
1232
- update_option( 'gplus_url_page_visit', $gplus_url_page_visit );
1233
- }
1234
-
1235
- if ( isset( $fb_url_page_visit ) && $fb_url_page_visit != null ) {
1236
- update_option( 'fb_url_page_visit', $fb_url_page_visit );
1237
- }
1238
- } else if ( ! empty( $getformsumbitaction ) && $getformsumbitaction == 'submit_form_pvc' && ! empty( $getformactiontype ) && $getformactiontype == 'reset' ) {
1239
- delete_option( 'wfap_post_type' );
1240
- delete_option( 'ipaddress_visit' );
1241
- delete_option( 'userlist_visit' );
1242
- update_option( 'no_of_days_to_display', '' );
1243
- update_option( 'counter_hide_show_front_vew', '' );
1244
- update_option( 'text_color_page_visit', '' );
1245
- update_option( 'twitter_url_page_visit', '' );
1246
- update_option( 'gplus_url_page_visit', '' );
1247
- update_option( 'fb_url_page_visit', '' );
1248
- } else if ( ! empty( $getformsumbitaction ) && $getformsumbitaction == 'submit_form_pvc' && ! empty( $getformactiontype ) && $getformactiontype == 'resetcount' ) {
1249
-
1250
- $table_name = $wpdb->prefix . "page_visit";
1251
-
1252
- $query = "TRUNCATE TABLE $table_name";
1253
- $wpdb->query( $query );
1254
-
1255
- $table_name = $wpdb->prefix . "page_visit_history";
1256
- $query = "TRUNCATE TABLE $table_name";
1257
- $wpdb->query( $query );
1258
- }
1259
-
1260
- wp_safe_redirect( site_url( "/wp-admin/admin.php?page=page_visit_settings" ) );
1261
- exit();
1262
-
1263
- //die();
1264
- }
1265
-
1266
- /**
1267
- * select_input_page_value use in ajax callback function
1268
- * handle the date and page title on change event.
1269
- */
1270
- public function select_input_page_value() {
1271
- global $wpdb;
1272
- $table_name = $wpdb->prefix . "page_visit";
1273
- $table_post = $wpdb->prefix . "posts";
1274
- $html = '';
1275
- $page_title = isset( $_POST['page_name'] ) ? $_POST['page_name'] : '';
1276
- $page_date = isset( $_POST['page_date'] ) ? $_POST['page_date'] : '';
1277
- $string = '';
1278
- if ( $page_date == '' && $page_title == '' ) {
1279
- $html .= '<table id="example" class="display" cellpadding="0" cellspacing="0">
 
 
 
 
 
1280
  <thead>
1281
  <tr>
1282
- <th width="10%">' . __( 'No', 'page-visit-counter' ) . '</th>
1283
- <th width="10%">' . __( 'Page ID', 'page-visit-counter' ) . '</th>
1284
- <th>' . __( 'Page Title', 'page-visit-counter' ) . '</th>
1285
- <th width="20%">' . __( 'Total Count', 'page-visit-counter' ) . '</th>
1286
- <th width="20%">' . __( 'Share', 'page-visit-counter' ) . '</th>
1287
- <th width="10%">' . __( 'Report', 'page-visit-counter' ) . '</th>
1288
  </tr>
1289
  </thead>
1290
  <tbody>';
1291
- $postperpage = - 1;
1292
- $post_types = get_post_types();
1293
- $posts_array = array();
1294
- if ( isset( $post_types ) && ! empty( $post_types ) ) {
1295
- foreach ( $post_types as $cpost ) {
1296
- 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" ) {
1297
- $args = array(
1298
- 'post_type' => "$cpost",
1299
- 'post_status' => 'publish',
1300
- 'order' => 'ASC',
1301
- 'posts_per_page' => $postperpage,
1302
- );
1303
- $posts_array[] = get_posts( $args );
1304
- }
1305
- }
1306
- }
1307
- $counter = 0;
1308
- foreach ( $posts_array as $result ) {
1309
- foreach ( $result as $results ) {
1310
- $counter = $counter + 1;
1311
- $html .= '<tr>';
1312
- $html .= '<td>' . $counter . '</td>';
1313
- $html .= '<td>' . $results->ID . '</td>';
1314
- $html .= '<td><a href="' . get_admin_url() . 'post.php?post=' . $results->ID . '&action=edit">' . __( $results->post_title, 'page-visit-counter' ) . '</a></td>';
1315
- $count_visit = $wpdb->get_results( "SELECT SUM(page_visit) as page_visit from $table_name where page_id ='" . $results->ID . "'" );
1316
- $count = 0;
1317
- foreach ( $count_visit as $countval ) {
1318
- $count = $count + 1;
1319
- }
1320
- if ( $count_visit[0]->page_visit == '' ) {
1321
- $countC = 0;
1322
- } else {
1323
- $countC = $count_visit[0]->page_visit;
1324
- }
1325
- $html .= '<td>' . $countC . '</td>';
1326
-
1327
- $site_title = get_bloginfo( 'name' );
1328
- $page_social_content = $results->post_title . ' - Total Visits ' . $countC . ' - ' . $site_title;
1329
-
1330
- $html .= '<td>
1331
- <a target="_blank" style="margin-right: 5px;" href="https://www.facebook.com/sharer/sharer.php?u=' . esc_url( get_permalink( $results->ID ) ) . '"><img src="' . plugins_url( 'images/Facebook.png', dirname( __FILE__ ) ) . '" /></a>
1332
- <a target="_blank" style="margin-right: 5px;" href="https://twitter.com/intent/tweet?text=' . $page_social_content . '&url=' . esc_url( get_permalink( $results->ID ) ) . '"><img src="' . plugins_url( 'images/twitter.png', dirname( __FILE__ ) ) . '" /></a>
1333
- <a target="_blank" href="https://plus.google.com/share?url=' . esc_url( get_permalink( $results->ID ) ) . '"><img src="' . plugins_url( 'images/Google_Plus.png', dirname( __FILE__ ) ) . '" /></a></td>';
1334
- $html .= '<td><a href="' . site_url() . '/wp-admin/admin.php?page=page_visit_counter&id=' . $results->ID . '" title="' . __( $results->post_title, 'page-visit-counter' ) . '" class="" id="' . $results->ID . '">' . __( 'View Report', 'page-visit-counter' ) . '</a></td>';
1335
- $html .= '</tr>';
1336
- }
1337
- }
1338
- $html .= '</tbody>
1339
  <tfoot><tr>
1340
- <th width="10%">' . __( 'No', 'page-visit-counter' ) . '</th>
1341
- <th width="10%">' . __( 'Page ID', 'page-visit-counter' ) . '</th>
1342
- <th>' . __( 'Page Title', 'page-visit-counter' ) . '</th>
1343
- <th width="20%">' . __( 'Total Count', 'page-visit-counter' ) . '</th>
1344
- <th width="20%">' . __( 'Share', 'page-visit-counter' ) . '</th>
1345
- <th width="10%">' . __( 'Report', 'page-visit-counter' ) . '</th>
1346
  </tr></tfoot></table>';
1347
- echo $html;
1348
- } else {
1349
- if ( $page_title != '' ) {
1350
- if ( $page_date ) {
1351
- $string .= "wposts.post_title LIKE '$page_title%' AND ";
1352
- } else {
1353
- $string .= "wposts.post_title LIKE '$page_title%' ";
1354
- }
1355
- }
1356
- if ( $page_date != '' ) {
1357
- if ( $page_title ) {
1358
- $string .= "$table_name.date = '" . $page_date . "' AND";
1359
- } else {
1360
- $string .= "$table_name.date = '" . $page_date . "'";
1361
- }
1362
- }
1363
- $clean = rtrim( $string, " AND " );
1364
- $querySet = "SELECT DISTINCT wposts.* FROM $table_post wposts INNER JOIN $table_name ON (wposts.ID = $table_name.page_id) WHERE $clean";
1365
- $dataquery = $wpdb->get_results( $querySet );
1366
- if ( empty( $dataquery ) || $dataquery == '' ) {
1367
- $QUERY = "SELECT * from $table_post where post_title LIKE '$page_title%' AND post_status='publish'";
1368
- $notvisit = $wpdb->get_results( $QUERY );
1369
- $html .= '<table id="example" class="display" cellpadding="0" cellspacing="0">
1370
  <thead>
1371
  <tr>
1372
- <th width="10%">' . __( 'No', 'page-visit-counter' ) . '</th>
1373
- <th width="10%">' . __( 'Page ID', 'page-visit-counter' ) . '</th>
1374
- <th>' . __( 'Page Title', 'page-visit-counter' ) . '</th>
1375
- <th width="20%">' . __( 'Total Count', 'page-visit-counter' ) . '</th>
1376
- <th width="20%">' . __( 'Share', 'page-visit-counter' ) . '</th>
1377
- <th width="10%">' . __( 'Report', 'page-visit-counter' ) . '</th>
1378
  </tr></thead><tbody>';
1379
- $counter = 0;
1380
- foreach ( $notvisit as $results ) {
1381
- $counter = $counter + 1;
1382
- $html .= '<tr>';
1383
- $html .= '<td>' . $counter . '</td>';
1384
- $html .= '<td>' . $results->ID . '</td>';
1385
- $html .= '<td><a href="' . get_admin_url() . 'post.php?post=' . $results->ID . '&action=edit">' . __( $results->post_title, 'page-visit-counter' ) . '</a></td>';
1386
- $html .= '<td> 0 </td>';
1387
- $site_title = get_bloginfo( 'name' );
1388
- $page_social_content = $results->post_title . ' - Total Visits 0 - ' . $site_title;
1389
-
1390
- $html .= '<td>
1391
- <a target="_blank" style="margin-right: 5px;" href="https://www.facebook.com/sharer/sharer.php?u=' . esc_url( get_permalink( $results->ID ) ) . '"><img src="' . plugins_url( 'images/Facebook.png', dirname( __FILE__ ) ) . '" /></a>
1392
- <a target="_blank" style="margin-right: 5px;" href="https://twitter.com/intent/tweet?text=' . $page_social_content . '&url=' . esc_url( get_permalink( $results->ID ) ) . '"><img src="' . plugins_url( 'images/twitter.png', dirname( __FILE__ ) ) . '" /></a>
1393
- <a target="_blank" href="https://plus.google.com/share?url=' . esc_url( get_permalink( $results->ID ) ) . '"><img src="' . plugins_url( 'images/Google_Plus.png', dirname( __FILE__ ) ) . '" /></a></td>';
1394
- $html .= '<td><a href="' . site_url() . '/wp-admin/admin.php?page=page_visit_counter&id=' . $results->ID . '" title="' . __( $results->post_title, 'page-visit-counter' ) . '" class="" id="' . $results->ID . '">' . __( 'View Report', 'page-visit-counter' ) . '</a></td>';
1395
- $html .= '</tr>';
1396
- }
1397
- $html .= '</tbody><tfoot>
1398
  <tr>
1399
- <th width="10%">' . __( 'No', 'page-visit-counter' ) . '</th>
1400
- <th width="10%">' . __( 'Page ID', 'page-visit-counter' ) . '</th>
1401
- <th>' . __( 'Page Title', 'page-visit-counter' ) . '</th>
1402
- <th width="20%">' . __( 'Total Count', 'page-visit-counter' ) . '</th>
1403
- <th width="20%">' . __( 'Share', 'page-visit-counter' ) . '</th>
1404
- <th width="10%">' . __( 'Report', 'page-visit-counter' ) . '</th>
1405
  </tr></tfoot></table>';
1406
- echo $html;
1407
- } else if ( $dataquery != '' ) {
1408
- $html .= '<table id="example" class="display" cellpadding="0" cellspacing="0">
1409
  <thead>
1410
  <tr>
1411
- <th width="10%">' . __( 'No', 'page-visit-counter' ) . '</th>
1412
- <th width="10%">' . __( 'Page ID', 'page-visit-counter' ) . '</th>
1413
- <th>' . __( 'Page Title', 'page-visit-counter' ) . '</th>
1414
- <th width="20%">' . __( 'Total Count', 'page-visit-counter' ) . '</th>
1415
- <th width="20%">' . __( 'Share', 'page-visit-counter' ) . '</th>
1416
- <th width="10%">' . __( 'Report', 'page-visit-counter' ) . '</th>
1417
  </tr></thead><tbody>';
1418
- $counter = 0;
1419
- foreach ( $dataquery as $results ) {
1420
- $counter = $counter + 1;
1421
- $html .= '<tr>';
1422
- $html .= '<td>' . $counter . '</td>';
1423
- $html .= '<td>' . $results->ID . '</td>';
1424
- $html .= '<td><a href="' . get_admin_url() . 'post.php?post=' . $results->ID . '&action=edit">' . __( $results->post_title, 'page-visit-counter' ) . '</a></td>';
1425
- $str = '';
1426
- if ( $page_title != '' ) {
1427
- if ( $page_date != '' ) {
1428
- $str .= "page_id ='" . $results->ID . "' AND ";
1429
- } else {
1430
- $str .= "page_id ='" . $results->ID . "'";
1431
- }
1432
- }
1433
-
1434
- if ( $page_date != '' ) {
1435
- if ( $page_title != '' ) {
1436
- $str .= "date ='" . $page_date . "' AND ";
1437
- } else {
1438
- $str .= "date ='" . $page_date . "' ";
1439
- }
1440
- }
1441
- $remove = rtrim( $str, " AND " );
1442
- if ( $page_date != '' && $page_title != '' ) {
1443
- $count_visit = $wpdb->get_results( "SELECT * from $table_name where $remove" );
1444
- } elseif ( $page_title != '' ) {
1445
- $count_visit = $wpdb->get_results( "SELECT SUM(page_visit) as page_visit from $table_name where $remove" );
1446
- } elseif ( $page_date != '' ) {
1447
- $count_visit = $wpdb->get_results( "SELECT * from $table_name where page_id=$results->ID AND $remove" );
1448
- }
1449
- if ( $count_visit[0]->page_visit == '' ) {
1450
- $countC = 0;
1451
- } else {
1452
- $countC = $count_visit[0]->page_visit;
1453
- }
1454
-
1455
- $html .= '<td>' . $countC . '</td>';
1456
-
1457
- $site_title = get_bloginfo( 'name' );
1458
- $page_social_content = $results->post_title . ' - Total Visits ' . $countC . ' - ' . $site_title;
1459
-
1460
- $html .= '<td>
1461
- <a target="_blank" style="margin-right: 5px;" href="https://www.facebook.com/sharer/sharer.php?u=' . esc_url( get_permalink( $results->ID ) ) . '"><img src="' . plugins_url( 'images/Facebook.png', dirname( __FILE__ ) ) . '" /></a>
1462
- <a target="_blank" style="margin-right: 5px;" href="https://twitter.com/intent/tweet?text=' . $page_social_content . '&url=' . esc_url( get_permalink( $results->ID ) ) . '"><img src="' . plugins_url( 'images/twitter.png', dirname( __FILE__ ) ) . '" /></a>
1463
- <a target="_blank" href="https://plus.google.com/share?url=' . esc_url( get_permalink( $results->ID ) ) . '"><img src="' . plugins_url( 'images/Google_Plus.png', dirname( __FILE__ ) ) . '" /></a></td>';
1464
- $html .= '<td><a href="' . site_url() . '/wp-admin/admin.php?page=page_visit_counter&id=' . $results->ID . '" title="' . __( $results->post_title, 'page-visit-counter' ) . '" class="" id="' . $results->ID . '">' . __( 'View Report', 'page-visit-counter' ) . '</a></td>';
1465
-
1466
- $html .= '</tr>';
1467
- }
1468
- $html .= '</tbody><tfoot>
1469
  <tr>
1470
- <th width="10%">' . __( 'No', 'page-visit-counter' ) . '</th>
1471
- <th width="10%">' . __( 'Page ID', 'page-visit-counter' ) . '</th>
1472
- <th>' . __( 'Page Title', 'page-visit-counter' ) . '</th>
1473
- <th width="20%">' . __( 'Total Count', 'page-visit-counter' ) . '</th>
1474
- <th width="20%">' . __( 'Share', 'page-visit-counter' ) . '</th>
1475
- <th width="10%">' . __( 'Report', 'page-visit-counter' ) . '</th>
1476
  </tr></tfoot</table>';
1477
- echo $html;
1478
- }
1479
- }
1480
- die();
1481
- }
1482
-
1483
- public function add_custom_meta_box_page_visit() {
1484
- global $wpdb;
1485
-
1486
- $fetchSelecetedPostTypes = json_decode( get_option( 'wfap_post_type' ) );
1487
- if ( isset( $fetchSelecetedPostTypes ) && ! empty( $fetchSelecetedPostTypes ) ) {
1488
- $i = 0;
1489
- foreach ( $fetchSelecetedPostTypes as $postsingle ) {
1490
- add_meta_box( "header-meta-box-page-visit-$i", "Page Visit Counter", "custom_meta_box_markup_page_visit", "$postsingle", "side", "high", null );
1491
- $i ++;
1492
- }
1493
- } else {
1494
- $i = 0;
1495
- // Get all the registered post type
1496
- $post_types = get_post_types();
1497
- foreach ( $post_types as $cpost ) {
1498
- 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" ) {
1499
- add_meta_box( "header-meta-box-page-visit-$i", "Page Visit Counter", "custom_meta_box_markup_page_visit", "$cpost", "side", "high", null );
1500
- $i ++;
1501
- }
1502
- }
1503
- }
1504
-
1505
- function add_new_selected_post_columns( $columns ) {
1506
-
1507
- return array_merge( $columns,
1508
- array( 'page_visit_count' => __( 'Total Visits', 'page-visit-counter' ) ) );
1509
-
1510
-
1511
- }
1512
-
1513
- function custom_columns_add_page_visit_count( $column, $post_id ) {
1514
- global $wpdb, $wp;
1515
- if ( $column == 'page_visit_count' ) {
1516
- $table_name = $wpdb->prefix . "page_visit";
1517
- $pageCount = $wpdb->get_results( "SELECT SUM(page_visit) as total FROM $table_name WHERE `page_id` = $post_id" );
1518
- $total = (int) $pageCount[0]->total;
1519
- echo $total;
1520
- }
1521
- }
1522
-
1523
- function custom_meta_box_markup_page_visit( $object ) {
1524
- global $wp, $wpdb;
1525
-
1526
- $post_id = get_the_ID();
1527
- $enable_page_count = get_post_meta( $post_id, "enable_page_count", true );
1528
- $enable_page_count_day_wise = get_post_meta( $post_id, "enable_page_count_day_wise", true );
1529
-
1530
- $table_name = $wpdb->prefix . "page_visit";
1531
-
1532
- $pageCount = $wpdb->get_results( "SELECT SUM(page_visit) as total FROM $table_name WHERE `page_id` = $post_id" );
1533
-
1534
- $total = (int) $pageCount[0]->total;
1535
- ?>
 
 
 
 
1536
  <input name="pageidvisit" type="hidden" value="<?php echo $post_id; ?>">
1537
- <p><?php echo __( 'Do you want to enable page visits count for this page?', 'page-visit-counter' ); ?></p>
1538
  <p>
1539
- <?php if ( $enable_page_count == '' ) { ?>
1540
  <input type="radio" checked="checked" name="autoupdate_page_visit" id="autoupdate_page1"
1541
- value="yes"><?php echo __( 'Yes', 'page-visit-counter' ); ?>
1542
  <input type="radio" name="autoupdate_page_visit" id="autoupdate_page2"
1543
- value="no"><?php echo __( 'No', 'page-visit-counter' ); ?>
1544
- <?php } else { ?>
1545
- <input type="radio" <?php if ( $enable_page_count == 'yes' ) { ?> checked="checked" <?php } ?>
1546
  name="autoupdate_page_visit" id="autoupdate_page1" value="yes"> Yes
1547
- <input type="radio" <?php if ( $enable_page_count == 'no' ) { ?> checked="checked" <?php } ?>
1548
  name="autoupdate_page_visit" id="autoupdate_page2" value="no">No<?php
1549
- } ?>
1550
  </p>
1551
- <p><?php echo __( 'Do you want to display today page visits count for this page?', 'page-visit-counter' ); ?></p>
1552
  <p>
1553
- <?php if ( $enable_page_count_day_wise == '' ) { ?>
1554
  <input type="radio" checked="checked" name="autoupdate_page_visit_day_wise"
1555
- id="autoupdate_page1_day_wise" value="yes"><?php echo __( 'Yes', 'page-visit-counter' ); ?>
1556
  <input type="radio" name="autoupdate_page_visit_day_wise" id="autoupdate_page2_day_wise"
1557
- value="no"><?php echo __( 'No', 'page-visit-counter' ); ?>
1558
- <?php } else { ?>
1559
- <input type="radio" <?php if ( $enable_page_count_day_wise == 'yes' ) { ?> checked="checked" <?php } ?>
1560
  name="autoupdate_page_visit_day_wise" id="autoupdate_page1_day_wise" value="yes"> Yes
1561
- <input type="radio" <?php if ( $enable_page_count_day_wise == 'no' ) { ?> checked="checked" <?php } ?>
1562
  name="autoupdate_page_visit_day_wise" id="autoupdate_page2_day_wise" value="no">No<?php
1563
- } ?>
1564
  </p>
1565
- <p><?php echo __( 'Do you want to reset all visits count for this page?', 'page-visit-counter' ); ?></p>
1566
  <p>
1567
  <input type="radio" name="page_visit_reset" id="page_visit_reset_yes"
1568
- value="yes"><?php echo __( 'Yes', 'page-visit-counter' ); ?>
1569
  <input type="radio" checked="checked" name="page_visit_reset" id="page_visit_reset_yes"
1570
- value="no"><?php echo __( 'No', 'page-visit-counter' ); ?>
1571
  </p>
1572
- <p><?php echo __( 'Total visits:', 'page-visit-counter' ); ?><?php echo $total; ?></p>
1573
- <?php
1574
- }
1575
- }
1576
 
1577
 
1578
- function save_custom_meta_box_page_visit( $post_id ) {
1579
- global $wp, $wpdb, $post;
 
1580
 
1581
- if ( ! current_user_can( "edit_post", $post_id ) ) {
1582
- return $post_id;
1583
- }
1584
 
1585
- if ( defined( "DOING_AUTOSAVE" ) && DOING_AUTOSAVE ) {
1586
- return $post_id;
1587
- }
1588
 
1589
- if ( isset( $_POST["autoupdate_page_visit"] ) ) {
1590
- update_post_meta( $post_id, "enable_page_count", $_POST["autoupdate_page_visit"] );
1591
- }
1592
 
1593
- if ( isset( $_POST["autoupdate_page_visit_day_wise"] ) ) {
1594
- update_post_meta( $post_id, "enable_page_count_day_wise", $_POST["autoupdate_page_visit_day_wise"] );
1595
- }
1596
 
1597
- if ( isset( $_POST["page_visit_reset"] ) && 'yes' === $_POST["page_visit_reset"] ) {
1598
- $table_name = $wpdb->prefix . "page_visit";
1599
 
1600
- $query = "DELETE FROM $table_name WHERE `page_id` = $post_id";
1601
 
1602
- $pageCount = $wpdb->query( $query );
1603
 
1604
- $table_name = $wpdb->prefix . "page_visit_history";
1605
- $query = "DELETE FROM $table_name WHERE `page_id` = $post_id";
1606
- $wpdb->query( $query );
1607
- }
1608
 
1609
- }
1610
 
1611
 
1612
- function check_page_visit_history_table_exisit() {
1613
- global $wpdb, $wp;
 
1614
 
1615
- $table_name = $wpdb->prefix . "page_visit_history";
1616
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) != $table_name ) {
1617
- $sql = "CREATE TABLE $table_name (
1618
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
1619
  page_id int(11) NOT NULL,
1620
  date date NOT NULL,
@@ -1627,143 +1655,145 @@ class page_visit_counter_Admin {
1627
  http_referer varchar(255) NOT NULL,
1628
  PRIMARY KEY (id)
1629
  );";
1630
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1631
- dbDelta( $sql );
1632
- //add_option( 'contact_db_version', $contact_db_version );
1633
- }
1634
 
1635
- }
1636
 
1637
- function get_page_visit_record_report() {
1638
- global $wpdb;
 
1639
 
1640
- $table_name = $wpdb->prefix . "page_visit_history";
1641
 
1642
- $pageId = $_REQUEST['page_id'];
1643
 
1644
- $countQuery = "SELECT COUNT(`page_id`) as total FROM $table_name WHERE `page_id` = $pageId";
1645
- $result = $wpdb->get_results( $countQuery );
1646
 
1647
- if ( (int) $result[0]->total > 0 ) {
1648
 
1649
- $queryTopBrowser = "SELECT COUNT(`page_id`) as total, `browser_full_name` as browser FROM $table_name WHERE `page_id` = $pageId GROUP BY `browser_full_name`";
1650
 
1651
- $topBrowserArr = $wpdb->get_results( $queryTopBrowser );
1652
 
1653
- $topBrowserStringArr = array();
1654
 
1655
 
1656
- $topBrowserStringArr['Browsers'] = 'Total Visits';
1657
- if ( (int) $result[0]->total > 0 ) {
1658
- foreach ( $topBrowserArr as $topBrowser ) {
1659
- $topBrowserStringArr[ $topBrowser->browser ] = (int) $topBrowser->total;
1660
- }
1661
- }
1662
 
1663
- //$queryTopIpAddress = "SELECT COUNT( `page_id` ) AS total, `ipaddress` AS ipaddress FROM $table_name WHERE `page_id` =$pageId GROUP BY `ipaddress` ORDER BY total DESC LIMIT 10";
1664
- $queryTopIpAddress = "SELECT COUNT( `page_id` ) AS total, `ipaddress` AS ipaddress FROM $table_name WHERE `page_id` =$pageId AND date > DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY `ipaddress` ORDER BY total DESC LIMIT 10";
1665
 
1666
- $topIpArr = $wpdb->get_results( $queryTopIpAddress );
1667
 
1668
- $topIpStringArr = array();
1669
 
1670
- $topIpStringArr["IP Address"] = 'Total Visits';
1671
- if ( (int) $result[0]->total > 0 ) {
1672
- foreach ( $topIpArr as $topIp ) {
1673
- $topIpStringArr["$topIp->ipaddress"] = (int) $topIp->total;
1674
- }
1675
- }
1676
 
1677
- $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";
1678
 
1679
- $topRefererArr = $wpdb->get_results( $queryTopReferer );
1680
 
1681
- $topRefererStringArr = array();
1682
 
1683
- $topRefererStringArr["Domain"] = 'Total Visits';
1684
- if ( (int) $result[0]->total > 0 ) {
1685
- foreach ( $topRefererArr as $topReferer ) {
1686
- if ( ! array_key_exists( "$topReferer->domain", $topRefererStringArr ) ) {
1687
- $topRefererStringArr["$topReferer->domain"] = (int) $topReferer->total;
1688
- } else {
1689
- $val = (int) $topRefererStringArr["$topReferer->domain"];
1690
- $topRefererStringArr["$topReferer->domain"] = $val + (int) $topReferer->total;
1691
- }
1692
- }
1693
- unset( $topRefererArr );
1694
- }
1695
 
1696
- $custom_page_visit_history_datatbase_table_name = $wpdb->prefix . "page_visit_history";
1697
- //$queryWeeklyReport = "SELECT SUM(page_id) AS total,DATE_ADD(date, INTERVAL(0-WEEKDAY(date)) DAY) as Week_Start_Date,DATE_ADD(date, INTERVAL(6-WEEKDAY(date)) DAY) as week_end_date,YEARWEEK( DATE, 1 ) AS YearAndWeek FROM $table_name WHERE page_id = $pageId GROUP BY YEARWEEK(date,1) ORDER BY YearAndWeek DESC LIMIT 5";
1698
- $queryWeeklyReport = "SELECT SUM(page_id) AS total,DATE_ADD(date, INTERVAL(0-WEEKDAY(date)) DAY) as Week_Start_Date,DATE_ADD(date, INTERVAL(6-WEEKDAY(date)) DAY) as week_end_date,YEARWEEK( DATE, 1 ) AS YearAndWeek, YEAR(DATE) as year, WEEK( DATE,1 ) as week FROM $custom_page_visit_history_datatbase_table_name WHERE page_id = 1 GROUP BY YEARWEEK(date,1) ORDER BY YearAndWeek DESC LIMIT 5";
1699
 
1700
- $topWeeklyArr = $wpdb->get_results( $queryWeeklyReport );
1701
 
1702
- $topWeeklyStringArr = array();
1703
 
1704
- $topWeeklyStringArr["Week Year"] = 'Total Visits';
1705
- if ( (int) $result[0]->total > 0 ) {
1706
- foreach ( array_reverse( $topWeeklyArr ) as $topWeekly ) {
1707
- $topWeeklyStringArr["$topWeekly->year - $topWeekly->week"] = (int) $topWeekly->total;
1708
- }
1709
- unset( $topWeeklyArr );
1710
- }
1711
 
1712
- $queryMonthlyReport = "SELECT SUM( `page_id` ) AS total, DATE_FORMAT(`date`,'%M %Y') AS month FROM `$table_name` WHERE `page_id` =$pageId AND YEAR( `date` ) = YEAR( CURDATE( ) ) GROUP BY MONTH( `date` ) ORDER BY MONTH( `date` ) ASC LIMIT 5";
1713
 
1714
- $topMonthlyArr = $wpdb->get_results( $queryMonthlyReport );
1715
 
1716
- $topMonthlyStringArr = array();
1717
 
1718
- $topMonthlyStringArr["Month"] = "Total Visits";
1719
- if ( (int) $result[0]->total > 0 ) {
1720
- foreach ( $topMonthlyArr as $topMonthly ) {
1721
- $topMonthlyStringArr["$topMonthly->month"] = (int) $topMonthly->total;
1722
- }
1723
- unset( $topMonthlyArr );
1724
- }
1725
 
1726
- $queryYearlyReport = "SELECT SUM( `page_id` ) AS total, YEAR( `date` ) AS year FROM `$table_name` WHERE `page_id` =$pageId GROUP BY YEAR( `date` ) ORDER BY YEAR( `date` ) DESC LIMIT 10";
1727
 
1728
- $topYearlyArr = $wpdb->get_results( $queryYearlyReport );
1729
 
1730
- $topYearlyStringArr = array();
1731
 
1732
- foreach ( $topYearlyArr as $topYearly ) {
1733
- $topYearlyStringArr["$topYearly->year"] = $topYearly->total;
1734
- }
1735
- unset( $topYearlyArr );
1736
 
1737
- $resultsArr = array();
1738
 
1739
- $resultsArr['topBrowserString'] = $topBrowserStringArr;
1740
- $resultsArr['topIpString'] = $topIpStringArr;
1741
- $resultsArr['topRefererString'] = $topRefererStringArr;
1742
- $resultsArr['topWeeklyString'] = $topWeeklyStringArr;
1743
- $resultsArr['topMonthlyString'] = $topMonthlyStringArr;
1744
- $resultsArr['topYearlyString'] = $topYearlyStringArr;
1745
 
1746
- echo json_encode( $resultsArr );
1747
- unset( $resultsArr );
1748
- //print_r($topBrowserStringArr);
1749
- } else {
1750
- echo json_encode( 'novisit' );
1751
- }
1752
 
1753
- die();
1754
- }
1755
 
1756
 
1757
- public function custom_admin_pointers_footer() {
1758
- $admin_pointers = custom_admin_pointers();
1759
- ?>
 
1760
  <script type="text/javascript">
1761
  /* <![CDATA[ */
1762
  (function ($) {
1763
- <?php
1764
- foreach ( $admin_pointers as $pointer => $array ) {
1765
- if ( $array['active'] ) {
1766
- ?>
1767
  $('<?php echo $array['anchor_id']; ?>').pointer({
1768
  content: '<?php echo $array['content']; ?>',
1769
  position: {
@@ -1777,21 +1807,21 @@ class page_visit_counter_Admin {
1777
  });
1778
  }
1779
  }).pointer('open');
1780
- <?php
1781
- }
1782
- }
1783
- ?>
1784
  })(jQuery);
1785
  /* ]]> */
1786
  </script>
1787
- <?php
1788
- }
1789
 
1790
 
1791
- /**
1792
- * Function For display pointer in admin side
1793
- *
1794
- */
1795
 
1796
 
1797
  }
@@ -1801,70 +1831,76 @@ class page_visit_counter_Admin {
1801
  * widget provide Most visited page.
1802
  *
1803
  */
1804
- class My_Widget extends WP_Widget {
1805
- public function __construct() {
1806
- $widget_ops = array( 'classname' => 'My_Widget', 'description' => 'Most Visited Pages' );
1807
- parent::__construct( 'My_Widget', 'Recent Most Visit page', $widget_ops );
1808
- }
1809
-
1810
- function widget( $args, $instance ) {
1811
- global $wpdb;
1812
- $table_name = $wpdb->prefix . "page_visit";
1813
- $html = '';
1814
- extract( $args, EXTR_SKIP );
1815
- $title = empty( $instance['title'] ) ? ' ' : apply_filters( 'widget_title', $instance['title'] );
1816
- $html .= ( isset( $before_widget ) ? $before_widget : '' );
1817
- if ( ! empty( $title ) ) {
1818
- $html .= $before_title . $title . $after_title;
1819
- }
1820
- $count_visit = $wpdb->get_results( "SELECT page_id,id,SUM(page_visit) as c from $table_name group by page_id order by c DESC limit 5" );
1821
- foreach ( $count_visit as $visitpage ) {
1822
- $page = get_post( $visitpage->page_id );
1823
- $html .= '<h6 style="font-size: 14px;font-weight: normal;line-height: 14px;">' . $page->post_title . '</h6>';
1824
- $html .= "<br>";
1825
- }
1826
- $html .= ( isset( $after_widget ) ? $after_widget : '' );
1827
- echo $html;
1828
- }
1829
-
1830
- public function form( $instance ) {
1831
- $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
1832
- $title = $instance['title'];
1833
- $html = '';
1834
- $html .= '<p> <label for="' . $this->get_field_id( "title" ) . '">Title:
1835
- <input class="widefat" id="' . $this->get_field_id( "title" ) . '"
1836
- name="' . $this->get_field_name( "title" ) . '" type="text"
1837
- value="' . attribute_escape( $title ) . '" /></label></p>';
1838
- echo $html;
1839
- }
1840
-
1841
- function update( $new_instance, $old_instance ) {
1842
- $instance = $old_instance;
1843
- $instance['title'] = $new_instance['title'];
1844
-
1845
- return $instance;
1846
- }
 
 
 
 
 
1847
  }
1848
 
1849
- add_action( 'widgets_init', create_function( '', 'return register_widget("My_Widget");' ) );
1850
 
1851
- function custom_admin_pointers() {
 
1852
 
1853
- $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
1854
- $version = '1_0'; // replace all periods in 1.0 with an underscore
1855
- $prefix = 'custom_admin_pointers' . $version . '_';
1856
 
1857
- $new_pointer_content = '<h3>' . __( 'Page Visit Counter' ) . '</h3>';
1858
- $new_pointer_content .= '<p>' . __( 'This plugin will count the total visits of your sites pages.' ) . '</p>';
1859
 
1860
- return array(
1861
- $prefix . 'page_visit_counter_notice_view' => array(
1862
- 'content' => $new_pointer_content,
1863
- 'anchor_id' => '#toplevel_page_page_visit_counter',
1864
- 'edge' => 'left',
1865
- 'align' => 'left',
1866
- 'active' => ( ! in_array( $prefix . 'page_visit_counter_notice_view', $dismissed ) )
1867
- )
1868
- );
1869
 
1870
  }
19
  * @subpackage page-visit-counter/admin
20
  * @author Multidots <wordpress@multidots.com>
21
  */
22
+ class page_visit_counter_Admin
23
+ {
24
+
25
+ /**
26
+ * The ID of this plugin.
27
+ *
28
+ * @since 1.0.0
29
+ * @access private
30
+ * @var string $plugin_name The ID of this plugin.
31
+ */
32
+ private $plugin_name;
33
+
34
+ /**
35
+ * The version of this plugin.
36
+ *
37
+ * @since 1.0.0
38
+ * @access private
39
+ * @var string $version The current version of this plugin.
40
+ */
41
+ private $version;
42
+
43
+ /**
44
+ * Initialize the class and set its properties.
45
+ *
46
+ * @since 1.0.0
47
+ *
48
+ * @param string $plugin_name The name of this plugin.
49
+ * @param string $version The version of this plugin.
50
+ */
51
+ public function __construct($plugin_name, $version)
52
+ {
53
+
54
+ $this->plugin_name = $plugin_name;
55
+ $this->version = $version;
56
+
57
+ }
58
+
59
+ /**
60
+ * Register the stylesheets for the admin area.
61
+ *
62
+ * @since 1.0.0
63
+ */
64
+
65
+ public function enqueue_styles()
66
+ {
67
+
68
+ /**
69
+ * This function is provided for demonstration purposes only.
70
+ *
71
+ * An instance of this class should be passed to the run() function
72
+ * defined in Woo_Extra_Flat_Rate_Loader as all of the hooks are defined
73
+ * in that particular class.
74
+ *
75
+ * The Woo_Extra_Flat_Rate_Loader will then create the relationship
76
+ * between the defined hooks and the functions defined in this
77
+ * class.
78
+ */
79
+
80
+ //wp_enqueue_style("jquery-ui-tabs");
81
+
82
+ wp_enqueue_style('custom-style', plugin_dir_url(__FILE__) . 'css/style.css');
83
+ wp_enqueue_style('datatable-style', plugin_dir_url(__FILE__) . 'css/jquery.dataTables.css');
84
+ wp_enqueue_style('jquery-style', plugin_dir_url(__FILE__) . 'css/jquery-ui.css');
85
+ wp_enqueue_style('chosen-style', plugin_dir_url(__FILE__) . 'css/chosen.css');
86
+ //wp_enqueue_style('fancy-box-style', plugin_dir_url( __FILE__ ) . 'css/jquery.fancybox-1.3.4.css');
87
+ wp_enqueue_style('color-box-style', plugin_dir_url(__FILE__) . 'css/colorbox.css');
88
+ //wp_enqueue_style('color-picker', plugin_dir_url( __FILE__ ) . 'css/color-picker.min.css');
89
+ wp_enqueue_style('wp-color-picker');
90
+ wp_enqueue_style('wp-pointer');
91
+ }
92
+
93
+ /**
94
+ * Register the JavaScript for the admin area.
95
+ *
96
+ * @since 1.0.0
97
+ */
98
+ public function enqueue_scripts()
99
+ {
100
+
101
+ /**
102
+ * This function is provided for demonstration purposes only.
103
+ *
104
+ * An instance of this class should be passed to the run() function
105
+ * defined in Woo_Extra_Flat_Rate_Loader as all of the hooks are defined
106
+ * in that particular class.
107
+ *
108
+ * The Woo_Extra_Flat_Rate_Loader will then create the relationship
109
+ * between the defined hooks and the functions defined in this
110
+ * class.
111
+ */
112
+
113
+ wp_enqueue_script('jquery-ui-core');
114
+ wp_enqueue_script('jquery-ui-tabs');
115
+ wp_enqueue_script('jquery-ui-datepicker');
116
+ //wp_deregister_style( 'wp-jquery-ui-dialog' );
117
+ //wp_enqueue_script( 'wp-jquery-ui-dialog' );
118
+ wp_enqueue_script('jquery-ui-dialog');
119
+
120
+ //enqueue script for notice pointer
121
+ wp_enqueue_script('wp-pointer');
122
 
123
  // if ( ! empty( $_GET['page'] ) && $_GET['page'] != '' && $_GET['page'] == 'page-visit-counter-about' ) {
124
  // wp_enqueue_script( 'one', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), $this->version, false );
125
  // }
126
+ if (isset($_GET['page'])) {
127
+ if (!empty($_GET['page']) && $_GET['page'] != '' || ($_GET['page'] == 'page_visit_settings ' || $_GET['page'] == 'page-visit-counter-about' || $_GET['page'] == 'page_visit_counter')) {
128
+ wp_enqueue_script('one', plugin_dir_url(__FILE__) . 'js/custom.js', array('jquery'), $this->version, false);
129
+ }
130
+ }
131
+ wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/jquery.dataTables.min.js', array('jquery'), $this->version, false);
132
+
133
+ //wp_enqueue_script('google-chart', 'https://www.gstatic.com/charts/loader.js', array( 'jquery' ), $this->version);
134
+
135
+ wp_enqueue_script('chosen-jquery', plugin_dir_url(__FILE__) . 'js/chosen.jquery.js', array('jquery'), $this->version, false);
136
+ wp_enqueue_script('chosen-proto', plugin_dir_url(__FILE__) . 'js/chosen.proto.js', array('jquery'), $this->version, false);
137
+ wp_enqueue_script('color-box', plugin_dir_url(__FILE__) . 'js/jquery.colorbox.js', array('jquery'), $this->version, false);
138
+
139
+ wp_enqueue_script('iris', admin_url('js/iris.min.js'), array(
140
+ 'jquery-ui-draggable',
141
+ 'jquery-ui-slider',
142
+ 'jquery-touch-punch'
143
+ ), false, 1);
144
+ wp_enqueue_script('wp-color-picker', admin_url('js/color-picker.min.js'), array('iris'), false, 1);
145
+
146
+ $colorpicker_l10n = array(
147
+ 'clear' => __('Clear'),
148
+ 'defaultString' => __('Default'),
149
+ 'pick' => __('Select Color')
150
+ );
151
+ if (!empty($colorpicker_l10n) || $colorpicker_l10n != "") {
152
+ wp_localize_script('wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n);
153
+ } else {
154
+ wp_localize_script('wp-color-picker', 'wpColorPickerL10n', '');
155
+ }
156
+
157
+ wp_localize_script('one', 'pagevisit', array('ajaxurl' => admin_url('admin-ajax.php')));
158
+
159
+ $fetchSelecetedPostTypes = get_option('wfap_post_type');
160
+ if (!empty($fetchSelecetedPostTypes) || $fetchSelecetedPostTypes != "") {
161
+ $options = !empty($fetchSelecetedPostTypes) ? $fetchSelecetedPostTypes : json_encode(array());
162
+ if (!empty($options) || $options != "") {
163
+ wp_localize_script('one', 'get_post_option', array('optionsarray' => $options));
164
+ } else {
165
+ wp_localize_script('one', 'get_post_option', array('optionsarray' => ''));
166
+ }
167
+ } else {
168
+ wp_localize_script('one', 'get_post_option', array('optionsarray' => ''));
169
+ }
170
+
171
+ $fetchSelecetedIpAddress = get_option('ipaddress_visit');
172
+ if (!empty($fetchSelecetedIpAddress) || $fetchSelecetedIpAddress != "") {
173
+ $optionsIpAddress = !empty($fetchSelecetedIpAddress) ? $fetchSelecetedIpAddress : json_encode(array());
174
+ if (!empty($optionsIpAddress) || $optionsIpAddress != "") {
175
+ wp_localize_script('one', 'get_ip_option', array('ipaddressarray' => $optionsIpAddress));
176
+ } else {
177
+ wp_localize_script('one', 'get_ip_option', array('ipaddressarray' => ''));
178
+ }
179
+ } else {
180
+ wp_localize_script('one', 'get_ip_option', array('ipaddressarray' => ''));
181
+ }
182
+
183
+ $fetchSelecetedUserId = get_option('userlist_visit');
184
+ if (!empty($fetchSelecetedUserId) || $fetchSelecetedUserId != "") {
185
+ $optionsUserId = !empty($fetchSelecetedUserId) ? $fetchSelecetedUserId : json_encode(array());
186
+ if (!empty($optionsUserId) || $optionsUserId != "") {
187
+ wp_localize_script('one', 'get_user_option', array('usersarray' => $optionsUserId));
188
+ } else {
189
+ wp_localize_script('one', 'get_user_option', array('usersarray' => ''));
190
+ }
191
+ } else {
192
+ wp_localize_script('one', 'get_user_option', array('usersarray' => ''));
193
+ }
194
+
195
+ }
196
+
197
+
198
+ public function welcome_page_visit_counter_screen_do_activation_redirect()
199
+ {
200
+ // if no activation redirect
201
+ if (!get_transient('_welcome_screen_page_visitor_activation_redirect_data')) {
202
+ return;
203
+ }
204
+
205
+ // Delete the redirect transient
206
+ delete_transient('_welcome_screen_page_visitor_activation_redirect_data');
207
+
208
+ // if activating from network, or bulk
209
+ if (is_network_admin() || isset($_GET['activate-multi'])) {
210
+ return;
211
+ }
212
+ // Redirect to extra cost welcome page
213
+ wp_safe_redirect(add_query_arg(array('page' => 'page-visit-counter-about&tab=about'), admin_url('index.php')));
214
+ }
215
+
216
+ public function welcome_pages_screen_page_visit_counter()
217
+ {
218
+ add_dashboard_page(
219
+ 'Page Visit counter Dashboard', 'Page Visit counter Dashboard', 'read', 'page-visit-counter-about', array(
220
+ &$this,
221
+ 'welcome_screen_content_page_visit_counter'
222
+ )
223
+ );
224
+ }
225
+
226
+ public function admin_css()
227
+ {
228
+ wp_enqueue_style($this->plugin_name . 'welcome-page', plugin_dir_url(__FILE__) . 'css/style.css', array(), $this->version, 'all');
229
+ }
230
+
231
+ public function welcome_screen_content_page_visit_counter()
232
+ {
233
+ ?>
234
  <div class="wrap about-wrap">
235
+ <h1 style="font-size: 2.1em;"><?php printf(__('Welcome to Page Visit Counter', 'page-visit-counter')); ?></h1>
236
 
237
  <div class="about-text woocommerce-about-text">
238
+ <?php
239
+ $message = '';
240
+ printf(__('%s This plugin will count the total visits of your sites pages.', 'page-visit-counter'), $message, $this->version);
241
+ ?>
242
  <img class="version_logo_img"
243
+ src="<?php echo plugin_dir_url(__FILE__) . 'images/page_visit_counter.png'; ?>">
244
  </div>
245
 
246
+ <?php
247
+ $setting_tabs_wc = apply_filters('page_visit_counter_setting_tab', array(
248
+ "about" => "Overview",
249
+ "other_plugins" => "Checkout our other plugins"
250
+ ));
251
+ $current_tab_wc = (isset($_GET['tab'])) ? $_GET['tab'] : 'general';
252
+ $aboutpage = isset($_GET['page'])
253
+ ?>
254
  <h2 id="woo-extra-cost-tab-wrapper" class="nav-tab-wrapper">
255
+ <?php
256
+ foreach ($setting_tabs_wc as $name => $label) {
257
+ echo '<a href="' . home_url('wp-admin/index.php?page=page-visit-counter-about&tab=' . $name) . '" class="nav-tab ' . ($current_tab_wc == $name ? 'nav-tab-active' : '') . '">' . $label . '</a>';
258
+ }
259
+ ?>
260
  </h2>
261
 
262
+ <?php
263
+ foreach ($setting_tabs_wc as $setting_tabkey_wc => $setting_tabvalue) {
264
+ switch ($setting_tabkey_wc) {
265
+ case $current_tab_wc:
266
+ do_action('page_visit_counter_' . $current_tab_wc);
267
+ break;
268
+ }
269
+ }
270
+ ?>
271
  <hr/>
272
  <div class="return-to-dashboard">
273
+ <a href="<?php echo home_url('/wp-admin/admin.php?page=page_visit_settings'); ?>"><?php _e('Go to Page Visit Counter Settings', 'page-visit-counter'); ?></a>
274
  </div>
275
  </div>
276
+ <?php
277
+ }
278
+
279
+ /**
280
+ * Extra flate rate overview welcome page content function
281
+ *
282
+ */
283
+ public function page_visit_counter_about()
284
+ {
285
+ //do_action('my_own');
286
+ $current_user = wp_get_current_user();
287
+
288
+ ?>
289
  <div class="changelog">
290
 
291
  </br>
307
  <div class="changelog about-integrations">
308
  <div class="wc-feature feature-section col three-col">
309
  <div>
310
+ <p class="page_visit_overview"><?php _e('This Plugin use for front side post and pages counter. After activation of plugin it will automatically add page counts on bottom of all pages. So, that all visitors can see page counts for entire site pages. Plugin provide search by page title and search by page published date facilities. Settings are required for page counter. Plugin provide to select specific post type to include in post /pages counter. Plugin also provide to exclude specific IP/s and specific register user to exude from post/pages counter.', 'page-visit-counter'); ?></p>
311
  <p class="page_visit_overview"><strong>Page Counter Settings: </strong></p>
312
  <div class="Page_Counter_Settings_Content_ul">
313
  <ul>
363
  </div>
364
  </div>
365
  </div>
366
+ <?php
367
+ if (!get_option('pvcp_plugin_notice_shown')) {
368
+ echo '<div id="pvcp_dialog" title="Basic dialog"> <p> Subscribe for latest plugin update and get notified when we update our plugin and launch new products for free! </p> <p><input type="text" id="txt_user_sub_pvcp" class="regular-text" name="txt_user_sub_pvcp" value="' . $current_user->user_email . '"></p></div>';
369
+ }
370
+ }
371
+
372
+ /**
373
+ * Extra flate rate other plugin welcome page content function
374
+ *
375
+ */
376
+ public function page_visit_counter_other_plugins()
377
+ {
378
+ global $wpdb;
379
+ $url = 'https://store.multidots.com/wp-content/themes/business-hub-child/API/checkout_other_plugin.php';
380
+ $response = wp_remote_post($url, array(
381
+ 'method' => 'POST',
382
+ 'timeout' => 45,
383
+ 'redirection' => 5,
384
+ 'httpversion' => '1.0',
385
+ 'blocking' => true,
386
+ 'headers' => array(),
387
+ 'body' => array('plugin' => 'advance-flat-rate-shipping-method-for-woocommerce'),
388
+ 'cookies' => array()
389
+ ));
390
+
391
+ $response_new = array();
392
+ $response_new = json_decode($response['body']);
393
+ $get_other_plugin = maybe_unserialize($response_new);
394
+
395
+ $paid_arr = array();
396
+ ?>
397
 
398
  <div class="plug-containter">
399
  <div class="paid_plugin">
400
  <h3>Paid Plugins</h3>
401
+ <?php if (!empty($get_other_plugin) || $get_other_plugin != '') { ?>
402
+ <?php foreach ($get_other_plugin as $key => $val) {
403
+ if ($val['plugindesc'] == 'paid') { ?>
404
 
405
 
406
+ <div class="contain-section">
407
+ <div class="contain-img"><img src="<?php echo $val['pluginimage']; ?>"></div>
408
+ <div class="contain-title"><a target="_blank"
409
+ href="<?php echo $val['pluginurl']; ?>"><?php echo $key; ?></a>
410
+ </div>
411
  </div>
 
412
 
413
 
414
+ <?php } else {
415
 
416
+ $paid_arry[$key]['plugindesc'] = $val['plugindesc'];
417
+ $paid_arry[$key]['pluginimage'] = $val['pluginimage'];
418
+ $paid_arry[$key]['pluginurl'] = $val['pluginurl'];
419
+ $paid_arry[$key]['pluginname'] = $val['pluginname'];
420
 
421
+ ?>
422
 
423
 
424
+ <?php }
425
+ }
426
+ }
427
+ ?>
428
  </div>
429
+ <?php if (isset($paid_arry) && !empty($paid_arry)) { ?>
430
  <div class="free_plugin">
431
  <h3>Free Plugins</h3>
432
+ <?php foreach ($paid_arry as $key => $val) { ?>
433
  <div class="contain-section">
434
  <div class="contain-img"><img src="<?php echo $val['pluginimage']; ?>"></div>
435
  <div class="contain-title"><a target="_blank"
436
  href="<?php echo $val['pluginurl']; ?>"><?php echo $key; ?></a>
437
  </div>
438
  </div>
439
+ <?php }
440
+ } ?>
441
  </div>
442
 
443
  </div>
444
 
445
+ <?php
446
+ }
447
+
448
+ /**
449
+ * Remove the Extra flate rate menu in dashboard
450
+ *
451
+ */
452
+ public function welcome_screen_remove_menus()
453
+ {
454
+ remove_submenu_page('index.php', 'page-visit-counter-about');
455
+ }
456
+
457
+ /**
458
+ * admin menu page fnction
459
+ * add menu in admin menubar.
460
+ *
461
+ */
462
+ public function page_visit_counter_menu()
463
+ {
464
+ add_menu_page(__('Page-Visit-Counter', 'page-visit-counter'), __('PageVisitCounter', 'page-visit-counter'), 'manage_options', 'page_visit_counter', 'extra_page_visit_function_custom', plugins_url('page-visit-counter/admin/images/icon.png'));
465
+ add_submenu_page('page_visit_counter', __('Counter-Settings', 'page-visit-counter'), __('Settings', 'page-visit-counter'), 'manage_options', 'page_visit_settings', 'custom_page_visit_settings');
466
+ /**
467
+ * extra_page_visit_function_custom use the menu callback function
468
+ * $name pass the arguments
469
+ */
470
+ function extra_page_visit_function_custom($name)
471
+ {
472
+ global $wpdb;
473
+
474
+ if (!class_exists('WP_List_Table')) {
475
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
476
+ }
477
+
478
+ require plugin_dir_path(dirname(__FILE__)) . 'includes/class-tt-pvc-list-table.php';
479
+
480
+ // Create an instance of our package class.
481
+ $test_list_table = new TT_Example_List_Table();
482
+ // Fetch, prepare, sort, and filter our data.
483
+ $test_list_table->prepare_items();
484
+
485
+ $table_name = $wpdb->prefix . "page_visit";
486
+ ?>
487
 
488
 
489
  <div class="main-page-visit set_pvc_containter">
490
  <div class="page-title">
491
+ <h1><?php echo __('Page Visit Counter', 'page-visit-counter'); ?></h1>
492
  </div>
493
 
494
+ <?php
495
+ if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { ?>
496
  <style type="text/css">
497
  .tabs div#chartContainer-main {
498
  float: left;
839
 
840
 
841
  </script>
842
+ <?php
843
+ } else { ?>
844
  <form id="movies-filter" method="get">
845
+ <?php
846
+ $test_list_table->search_box(__('Search'), 'page-visit-counter');
847
+ foreach ($_GET as $key => $value) { // http://stackoverflow.com/a/8763624/1287812
848
+ if ('s' !== $key) // don't include the search query
849
+ {
850
+ echo("<input type='hidden' name='$key' value='$value' />");
851
+ }
852
+ }
853
+ $test_list_table->display();
854
+ ?>
855
  </form>
856
 
857
  <!-- Twitter -->
888
  })();
889
  </script>
890
 
891
+ <?php
892
+ } ?>
893
 
894
  </div>
895
 
896
+ <?php
897
+ }
898
+
899
+ /**
900
+ * function use to page settings
901
+ * $args is pass the arguments
902
+ */
903
+ function custom_page_visit_settings($args)
904
+ {
905
+
906
+ global $wpdb;
907
+ $current_user = wp_get_current_user();
908
+ // Get all the registered post type
909
+ $post_types = get_post_types();
910
+
911
+ // Get all the post type selected in settings page
912
+ $post_list = array();
913
+ $post = json_decode(get_option('wfap_post_type'));
914
+ $post_list = $post;
915
+
916
+ $text_color_page_visit = get_option('text_color_page_visit');
917
+ if (isset($text_color_page_visit) && $text_color_page_visit != null) {
918
+ $text_color_page_visit = $text_color_page_visit;
919
+ } else {
920
+ $text_color_page_visit = '#000000';
921
+ }
922
+
923
+ if (!get_option('pvcp_plugin_notice_shown')) {
924
+ echo '<div id="pvcp_dialog" title="Basic dialog"> <p> Subscribe for latest plugin update and get notified when we update our plugin and launch new products for free! </p> <p><input type="text" id="txt_user_sub_pvcp" class="regular-text" name="txt_user_sub_pvcp" value="' . $current_user->user_email . '"></p></div>';
925
+ }
926
+
927
+ ?>
928
  <div class="main-page-visit-settings">
929
  <div class="page-title-settings">
930
  <form id="pvc_plugin_form_id" method="post" action="<?php echo get_admin_url(); ?>admin-post.php"
933
  <input type="hidden" name="action" value="submit_form_pvc"/>
934
  <input id="action_which" type="hidden" name="action-which" value="add"/>
935
  <div class="set_pvc_containter set_plugin_descriptions">
936
+ <h3><?php echo __('Page Counter Settings', 'page-visit-counter'); ?></h3>
937
+ <p><?php echo __('Page Visit Counter plugin use for front side post and pages counter. After activation of plugin it will automatically add page counts on bottom of all pages. So, that all visitors can see page counts for entire site pages.', 'page-visit-counter'); ?></p>
938
  <ul style="list-style-type: disc;padding: 3px 2px 2px 34px;">
939
  <li>
940
+ <p><?php echo __('Specific page vise reports like Top browsers, Top 10 IP address, Top referer, weekly report and Monthly report using chart.', 'page-visit-counter'); ?></p>
941
  </li>
942
  <li>
943
+ <p><?php echo __('Search facility: search pages by title and search page by its created date.', 'page-visit-counter'); ?></p>
944
  </li>
945
  <li>
946
+ <p><?php echo __('Sharing facility: share specific page on Facebook, Twitter and Google Plus.', 'page-visit-counter'); ?></p>
947
  </li>
948
  </ul>
949
  </div>
950
 
951
  <div class="set_pvc_containter set_plugin_descriptions_shortcode">
952
  <fieldset>
953
+ <legend><?php echo __('Short Code', 'page-visit-counter'); ?></legend>
954
+ <p><?php echo __('There are two shortcodes that you can use to manually add page view count to any content on admin or post/page template created by your theme or plugin thats create it\'s own display content in page/post.', 'page-visit-counter'); ?></p>
955
+ <p><?php echo __('Use this shortcode to add admin side content on page/post:', 'page-visit-counter'); ?>
956
+ <b><?php echo __(htmlspecialchars('[page_visit_counter_md id="<page_id/post_id>"]'), 'page-visit-counter'); ?></b>
957
  </p>
958
+ <p><?php echo __('Use this shortcode to display total sites visit to add admin side content on page/post:', 'page-visit-counter'); ?>
959
+ <b><?php echo __(htmlspecialchars('[page_visit_counter_md_total_sites_visit backgroundcolor="#ff0000" countboxcolor="#000000" fontcolor="#FFFFFF" bordercolor="#ff0000"]'), 'page-visit-counter'); ?></b>
960
  </p>
961
+ <p><?php echo __('Use this shortcode to add page/post template (.php) file of your own template:', 'page-visit-counter'); ?>
962
  <b> <?php echo "&lt;?php echo do_shortcode('[page_visit_counter_md id='page_id/post_id']');?&gt;" ?></b>
963
  </p>
964
+ <p><?php echo __('Use this shortcode to display total sites visit to add page/post template (.php) file of your own template:', 'page-visit-counter'); ?>
965
  <br><b> &lt;?php echo do_shortcode('[page_visit_counter_md_total_sites_visit
966
  backgroundcolor='#ff0000' countboxcolor='#000000' fontcolor='#FFFFFF'
967
  bordercolor='#ff0000']');?&gt; </b></p>
970
 
971
  <div class="set_pvc_containter set_plugin_descriptions">
972
  <fieldset>
973
+ <legend><?php echo __('Basic Configuration settings', 'page-visit-counter'); ?></legend>
974
+ <?php
975
+ $get_option_value = json_decode(get_option('page_count_settings'));
976
+ $input_values = isset($get_option_value[1]) ? $get_option_value[1] : array();
977
+ $select_values = isset($get_option_value[0]) ? $get_option_value[0] : array();
978
+ ?>
979
  <table border="0" cellpadding="10" cellspacing="0">
980
  <tbody>
981
  <tr>
982
  <th scope="row"><label
983
+ for="blogname"><?php echo __('Post Type', 'page-visit-counter'); ?></label>
984
  </th>
985
  <td>
986
  <select id="post_type"
987
+ data-placeholder=" <?php echo __('Add Page/Post Type', 'page-visit-counter'); ?>"
988
  name="post_ty[]" multiple="true"
989
  class="chosen-select-post category-select chosen-rtl validate_field1">
990
  <option value=""></option><?php
991
+ if (isset($post_types) && !empty($post_types)) {
992
+ foreach ($post_types as $cpost) {
993
+ 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") { ?>
994
  <option
995
  value="<?php echo $cpost; ?>"><?php echo $cpost; ?></option><?php
996
+ }
997
+ }
998
+ } ?>
999
  </select>
1000
+ <p><?php echo __('(Select post types for which post views will be counted.)', 'page-visit-counter'); ?></p>
1001
  <!--<p>(<b><?php //echo __('Note: To start the count of the page/post please select the Cpt (custom post type), page or post from above select box. If you not select any one then it will not start to count.', 'page-visit-counter'); ?></b>)</p>-->
1002
  </td>
1003
  </tr>
1004
 
1005
  <tr class="ipaddress">
1006
  <th scope="row"><label
1007
+ for="blogname"><?php echo __('Exclude IPs (Ip Address)', 'page-visit-counter'); ?></label>
1008
  </th>
1009
  <td>
1010
  <select id="ip_address"
1011
+ data-placeholder=" <?php echo __('Add IP Address in comma seprated', 'page-visit-counter'); ?>"
1012
  name="ip-basic[]" multiple="true"
1013
  class="chosen-select-ip category-select chosen-rtl validate_field1">
1014
  <option value=""></option><?php
1015
+ $get_option_value_ip = json_decode(get_option('ipaddress_visit'));
1016
+ if (isset($get_option_value_ip) && !empty($get_option_value_ip)) {
1017
+ foreach ($get_option_value_ip as $ip) { ?>
1018
  <option
1019
  value="<?php echo $ip; ?>"><?php echo $ip; ?></option><?php
1020
+ }
1021
+ } ?>
1022
  </select>
1023
+ <p><?php echo __('(Enter the IP addresses to be excluded from post views count.)', 'page-visit-counter'); ?></p>
1024
  </td>
1025
  </tr>
1026
 
1027
  <tr class="users">
1028
  <th scope="row"><label
1029
+ for="blogname"><?php echo __('Exclude Users', 'page-visit-counter'); ?></label>
1030
  </th>
1031
  <td>
1032
  <select id="users_list"
1033
+ data-placeholder="<?php echo __('Select Registerd Users', 'page-visit-counter'); ?>"
1034
  name="user-basic[]" multiple="true"
1035
  class="chosen-select category-select chosen-rtl validate_field1">
1036
  <option value=""></option><?php
1037
+ $query = "SELECT * FROM $wpdb->users";
1038
+ $resultSetsArr = $wpdb->get_results($query);
1039
+ if (isset($resultSetsArr) && !empty($resultSetsArr)) {
1040
+ foreach ($resultSetsArr as $value) { ?>
1041
  <option
1042
  value="<?php echo $value->ID; ?>"><?php echo $value->user_email; ?></option><?php
1043
+ }
1044
+ } ?>
1045
  </select>
1046
+ <p><?php echo __('(Select the users to be excluded from post views count.)', 'page-visit-counter'); ?></p>
1047
  </td>
1048
  </tr>
1049
 
1050
  <tr class="hidefront">
1051
  <th scope="row"><label
1052
+ for="blogname"><?php echo __('Show front view counter', 'page-visit-counter'); ?></label>
1053
  </th>
1054
+ <?php
1055
+ $hide_show_option = get_option('counter_hide_show_front_vew');
1056
+ if ($hide_show_option == 'on') {
1057
+ $cheked = 'checked';
1058
+ } else {
1059
+ $cheked = '';
1060
+ } ?>
1061
  <td class="information">
1062
  <input type="checkbox" name="hidefrontview"
1063
+ id="hide_front_view" <?php echo $cheked; ?>><?php echo __('Check the box if you want to display counter view on front end.', 'page-visit-counter'); ?>
1064
  </td>
1065
  </tr>
1066
 
1067
  <tr class="hidefront" style="display:none;">
1068
  <th scope="row"><label
1069
+ for="blogname"><?php echo __('Last How many days count you want to display on front end.', 'page-visit-counter'); ?></label>
1070
  </th>
1071
  <td class="information">
1072
+ <?php
1073
+ $get_no_of_days = get_option('no_of_days_to_display');
1074
+ if ($get_no_of_days == '') {
1075
+ $get_no_of_days = '';
1076
+ }
1077
+ ?>
1078
  <input type="text" name="no_of_days_to_display" id="no_of_days_to_display"
1079
  value="<?php echo $get_no_of_days; ?>">
1080
  </td>
1082
 
1083
  <tr class="">
1084
  <th scope="row"><label
1085
+ for="blogname"><?php echo __('Choose color for the front end view', 'page-visit-counter'); ?></label>
1086
  </th>
1087
  <td class="information">
1088
  <input id="text_color_page_visit" type="text" name="textcolor"
1096
  </div>
1097
  <p class="submit">
1098
  <input type="submit" name="submit" class="button button-primary"
1099
+ value="<?php echo __('Save Changes', 'page-visit-counter'); ?>">
1100
  <input type="submit" id="pvc_reset_settings"
1101
+ value="<?php echo __('Reset all settings', 'page-visit-counter'); ?>"
1102
  class="button button-primary">
1103
  <input type="submit" id="pvc_reset_counter"
1104
+ value="<?php echo __('Reset all pages counts & report ', 'page-visit-counter'); ?>"
1105
  class="button button-primary">
1106
  </p>
1107
  </form>
1108
  </div>
1109
  </div>
1110
+ <?php
1111
+ }
1112
+ }
1113
+
1114
+
1115
+ public function wp_add_plugin_userfn()
1116
+ {
1117
+ $email_id = (isset($_POST["email_id"]) && !empty($_POST["email_id"])) ? $_POST["email_id"] : '';
1118
+ $log_url = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
1119
+ $cur_date = date('Y-m-d');
1120
+ $request_url = 'https://store.multidots.com/wp-content/themes/business-hub-child/API/wp-add-plugin-users.php';
1121
+ if (!empty($email_id)) {
1122
+ $response_args = array(
1123
+ 'method' => 'POST',
1124
+ 'timeout' => 45,
1125
+ 'redirection' => 5,
1126
+ 'httpversion' => '1.0',
1127
+ 'blocking' => true,
1128
+ 'headers' => array(),
1129
+ 'body' => array(
1130
+ 'user' => array(
1131
+ 'plugin_id' => '6',
1132
+ 'user_email' => $email_id,
1133
+ 'plugin_site' => $log_url,
1134
+ 'status' => 1,
1135
+ 'activation_date' => $cur_date
1136
+ )
1137
+ ),
1138
+ 'cookies' => array()
1139
+ );
1140
+ $request_response = wp_remote_post($request_url, $response_args);
1141
+ if (!is_wp_error($request_response)) {
1142
+ update_option('pvcp_plugin_notice_shown', 'true');
1143
+ }
1144
+ }
1145
+ wp_die();
1146
+ }
1147
+
1148
+
1149
+ /**
1150
+ * function create dashboad widget.
1151
+ * view most visited page in dashboard.
1152
+ *
1153
+ */
1154
+ function my_custom_dashboard_widgets()
1155
+ {
1156
+ global $wp_meta_boxes;
1157
+ wp_add_dashboard_widget('custom_help_widget', __('Most Visited Page', 'page-visit-counter'), 'custom_dashboard_help');
1158
+ function custom_dashboard_help()
1159
+ {
1160
+ global $wpdb;
1161
+ $table_name = $wpdb->prefix . "page_visit";
1162
+ $html = '';
1163
+ $count_visit = $wpdb->get_results("SELECT page_id,id,SUM(page_visit) as c from $table_name group by page_id order by c DESC limit 5");
1164
+ $html .= '<div class="main_custom_dashboard_visit_page">';
1165
+ if (!empty($count_visit) && isset($count_visit)) {
1166
+ $html .= '<table border="0" cellpadding="5" cellspacing="10">';
1167
+ $html .= '<tr>';
1168
+ $html .= '<th>' . __('Page id', 'page-visit-counter') . '</th>';
1169
+ $html .= '<th>' . __('Page Name', 'page-visit-counter') . '</th>';
1170
+ $html .= '<th>' . __('Total Count', 'page-visit-counter') . '</th>';
1171
+ $html .= '</tr>';
1172
+
1173
+ foreach ($count_visit as $visitpage) {
1174
+ $page = get_post($visitpage->page_id);
1175
+ $html .= '<tr>';
1176
+ $html .= '<td>' . $page->ID . '</td>';
1177
+ $html .= '<td><a href="' . get_admin_url() . 'post.php?post=' . $page->ID . '&action=edit">' . __($page->post_title, 'page-visit-counter') . '</a></td>';
1178
+ $html .= '<td>' . $visitpage->c . '</td>';
1179
+ $html .= '</tr>';
1180
+ }
1181
+ $html .= '</table>';
1182
+ } else {
1183
+ $html .= 'No Page Found.';
1184
+ }
1185
+ $html .= '</div>';
1186
+ echo $html;
1187
+ }
1188
+ }
1189
+
1190
+ /**
1191
+ * this function use to page settings submit callback function
1192
+ * add option by option table
1193
+ * add page count option and duration.
1194
+ */
1195
+ public function add_page_count_option()
1196
+ {
1197
+ global $wpdb;
1198
+
1199
+ $page_count_option = array();
1200
+
1201
+ $getformsumbitaction = !empty($_POST['action']) ? $_POST['action'] : '';
1202
+ $getformactiontype = !empty($_POST['action-which']) ? $_POST['action-which'] : '';
1203
+
1204
+ if (!empty($getformsumbitaction) && $getformsumbitaction == 'submit_form_pvc' && !empty($getformactiontype) && $getformactiontype == 'add') {
1205
+
1206
+ $type = isset($_POST['post_ty']) ? $_POST['post_ty'] : array();
1207
+ $ipAddress = isset($_POST['ip-basic']) ? $_POST['ip-basic'] : array();
1208
+ $userList = isset($_POST['user-basic']) ? $_POST['user-basic'] : array();
1209
+ $hidefrontview = isset($_POST['hidefrontview']) ? $_POST['hidefrontview'] : '';
1210
+ $text_color_page_visit = isset($_POST['textcolor']) ? $_POST['textcolor'] : '';
1211
+
1212
+ $twitter_url_page_visit = isset($_POST['twitter_url_page_visit']) ? $_POST['twitter_url_page_visit'] : '';
1213
+ $gplus_url_page_visit = isset($_POST['gplus_url_page_visit']) ? $_POST['gplus_url_page_visit'] : '';
1214
+ $fb_url_page_visit = isset($_POST['fb_url_page_visit']) ? $_POST['fb_url_page_visit'] : '';
1215
+ $no_of_days_to_display = isset($_POST['no_of_days_to_display']) ? $_POST['no_of_days_to_display'] : '';
1216
+
1217
+ delete_option('wfap_post_type');
1218
+ if (isset($type) && $type != null) {
1219
+ update_option('wfap_post_type', json_encode(array_values($type)));
1220
+ }
1221
+
1222
+ delete_option('ipaddress_visit');
1223
+ if (isset($ipAddress) && $ipAddress != null) {
1224
+ update_option('ipaddress_visit', json_encode(array_values($ipAddress)));
1225
+ }
1226
+
1227
+ delete_option('userlist_visit');
1228
+ if (isset($userList) && $userList != null) {
1229
+ update_option('userlist_visit', json_encode(array_values($userList)));
1230
+ }
1231
+
1232
+ if (isset($hidefrontview) && $hidefrontview != null) {
1233
+ update_option('counter_hide_show_front_vew', $hidefrontview);
1234
+ } else {
1235
+ update_option('counter_hide_show_front_vew', '');
1236
+ }
1237
+
1238
+ if (isset($no_of_days_to_display) && $no_of_days_to_display != null) {
1239
+ update_option('no_of_days_to_display', $no_of_days_to_display);
1240
+ } else {
1241
+ update_option('no_of_days_to_display', '');
1242
+ }
1243
+
1244
+ if (isset($text_color_page_visit) && $text_color_page_visit != null) {
1245
+ update_option('text_color_page_visit', $text_color_page_visit);
1246
+ }
1247
+
1248
+ if (isset($twitter_url_page_visit) && $twitter_url_page_visit != null) {
1249
+ update_option('twitter_url_page_visit', $twitter_url_page_visit);
1250
+ }
1251
+
1252
+ if (isset($gplus_url_page_visit) && $gplus_url_page_visit != null) {
1253
+ update_option('gplus_url_page_visit', $gplus_url_page_visit);
1254
+ }
1255
+
1256
+ if (isset($fb_url_page_visit) && $fb_url_page_visit != null) {
1257
+ update_option('fb_url_page_visit', $fb_url_page_visit);
1258
+ }
1259
+ } else if (!empty($getformsumbitaction) && $getformsumbitaction == 'submit_form_pvc' && !empty($getformactiontype) && $getformactiontype == 'reset') {
1260
+ delete_option('wfap_post_type');
1261
+ delete_option('ipaddress_visit');
1262
+ delete_option('userlist_visit');
1263
+ update_option('no_of_days_to_display', '');
1264
+ update_option('counter_hide_show_front_vew', '');
1265
+ update_option('text_color_page_visit', '');
1266
+ update_option('twitter_url_page_visit', '');
1267
+ update_option('gplus_url_page_visit', '');
1268
+ update_option('fb_url_page_visit', '');
1269
+ } else if (!empty($getformsumbitaction) && $getformsumbitaction == 'submit_form_pvc' && !empty($getformactiontype) && $getformactiontype == 'resetcount') {
1270
+
1271
+ $table_name = $wpdb->prefix . "page_visit";
1272
+
1273
+ $query = "TRUNCATE TABLE $table_name";
1274
+ $wpdb->query($query);
1275
+
1276
+ $table_name = $wpdb->prefix . "page_visit_history";
1277
+ $query = "TRUNCATE TABLE $table_name";
1278
+ $wpdb->query($query);
1279
+ }
1280
+
1281
+ wp_safe_redirect(site_url("/wp-admin/admin.php?page=page_visit_settings"));
1282
+ exit();
1283
+
1284
+ //die();
1285
+ }
1286
+
1287
+ /**
1288
+ * select_input_page_value use in ajax callback function
1289
+ * handle the date and page title on change event.
1290
+ */
1291
+ public function select_input_page_value()
1292
+ {
1293
+ global $wpdb;
1294
+ $table_name = $wpdb->prefix . "page_visit";
1295
+ $table_post = $wpdb->prefix . "posts";
1296
+ $html = '';
1297
+ $page_title = isset($_POST['page_name']) ? $_POST['page_name'] : '';
1298
+ $page_date = isset($_POST['page_date']) ? $_POST['page_date'] : '';
1299
+ $string = '';
1300
+ if ($page_date == '' && $page_title == '') {
1301
+ $html .= '<table id="example" class="display" cellpadding="0" cellspacing="0">
1302
  <thead>
1303
  <tr>
1304
+ <th width="10%">' . __('No', 'page-visit-counter') . '</th>
1305
+ <th width="10%">' . __('Page ID', 'page-visit-counter') . '</th>
1306
+ <th>' . __('Page Title', 'page-visit-counter') . '</th>
1307
+ <th width="20%">' . __('Total Count', 'page-visit-counter') . '</th>
1308
+ <th width="20%">' . __('Share', 'page-visit-counter') . '</th>
1309
+ <th width="10%">' . __('Report', 'page-visit-counter') . '</th>
1310
  </tr>
1311
  </thead>
1312
  <tbody>';
1313
+ $postperpage = -1;
1314
+ $post_types = get_post_types();
1315
+ $posts_array = array();
1316
+ if (isset($post_types) && !empty($post_types)) {
1317
+ foreach ($post_types as $cpost) {
1318
+ 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") {
1319
+ $args = array(
1320
+ 'post_type' => "$cpost",
1321
+ 'post_status' => 'publish',
1322
+ 'order' => 'ASC',
1323
+ 'posts_per_page' => $postperpage,
1324
+ );
1325
+ $posts_array[] = get_posts($args);
1326
+ }
1327
+ }
1328
+ }
1329
+ $counter = 0;
1330
+ foreach ($posts_array as $result) {
1331
+ foreach ($result as $results) {
1332
+ $counter = $counter + 1;
1333
+ $html .= '<tr>';
1334
+ $html .= '<td>' . $counter . '</td>';
1335
+ $html .= '<td>' . $results->ID . '</td>';
1336
+ $html .= '<td><a href="' . get_admin_url() . 'post.php?post=' . $results->ID . '&action=edit">' . __($results->post_title, 'page-visit-counter') . '</a></td>';
1337
+ $count_visit = $wpdb->get_results("SELECT SUM(page_visit) as page_visit from $table_name where page_id ='" . $results->ID . "'");
1338
+ $count = 0;
1339
+ foreach ($count_visit as $countval) {
1340
+ $count = $count + 1;
1341
+ }
1342
+ if ($count_visit[0]->page_visit == '') {
1343
+ $countC = 0;
1344
+ } else {
1345
+ $countC = $count_visit[0]->page_visit;
1346
+ }
1347
+ $html .= '<td>' . $countC . '</td>';
1348
+
1349
+ $site_title = get_bloginfo('name');
1350
+ $page_social_content = $results->post_title . ' - Total Visits ' . $countC . ' - ' . $site_title;
1351
+
1352
+ $html .= '<td>
1353
+ <a target="_blank" style="margin-right: 5px;" href="https://www.facebook.com/sharer/sharer.php?u=' . esc_url(get_permalink($results->ID)) . '"><img src="' . plugins_url('images/Facebook.png', dirname(__FILE__)) . '" /></a>
1354
+ <a target="_blank" style="margin-right: 5px;" href="https://twitter.com/intent/tweet?text=' . $page_social_content . '&url=' . esc_url(get_permalink($results->ID)) . '"><img src="' . plugins_url('images/twitter.png', dirname(__FILE__)) . '" /></a>
1355
+ <a target="_blank" href="https://plus.google.com/share?url=' . esc_url(get_permalink($results->ID)) . '"><img src="' . plugins_url('images/Google_Plus.png', dirname(__FILE__)) . '" /></a></td>';
1356
+ $html .= '<td><a href="' . site_url() . '/wp-admin/admin.php?page=page_visit_counter&id=' . $results->ID . '" title="' . __($results->post_title, 'page-visit-counter') . '" class="" id="' . $results->ID . '">' . __('View Report', 'page-visit-counter') . '</a></td>';
1357
+ $html .= '</tr>';
1358
+ }
1359
+ }
1360
+ $html .= '</tbody>
1361
  <tfoot><tr>
1362
+ <th width="10%">' . __('No', 'page-visit-counter') . '</th>
1363
+ <th width="10%">' . __('Page ID', 'page-visit-counter') . '</th>
1364
+ <th>' . __('Page Title', 'page-visit-counter') . '</th>
1365
+ <th width="20%">' . __('Total Count', 'page-visit-counter') . '</th>
1366
+ <th width="20%">' . __('Share', 'page-visit-counter') . '</th>
1367
+ <th width="10%">' . __('Report', 'page-visit-counter') . '</th>
1368
  </tr></tfoot></table>';
1369
+ echo $html;
1370
+ } else {
1371
+ if ($page_title != '') {
1372
+ if ($page_date) {
1373
+ $string .= "wposts.post_title LIKE '$page_title%' AND ";
1374
+ } else {
1375
+ $string .= "wposts.post_title LIKE '$page_title%' ";
1376
+ }
1377
+ }
1378
+ if ($page_date != '') {
1379
+ if ($page_title) {
1380
+ $string .= "$table_name.date = '" . $page_date . "' AND";
1381
+ } else {
1382
+ $string .= "$table_name.date = '" . $page_date . "'";
1383
+ }
1384
+ }
1385
+ $clean = rtrim($string, " AND ");
1386
+ $querySet = "SELECT DISTINCT wposts.* FROM $table_post wposts INNER JOIN $table_name ON (wposts.ID = $table_name.page_id) WHERE $clean";
1387
+ $dataquery = $wpdb->get_results($querySet);
1388
+ if (empty($dataquery) || $dataquery == '') {
1389
+ $QUERY = "SELECT * from $table_post where post_title LIKE '$page_title%' AND post_status='publish'";
1390
+ $notvisit = $wpdb->get_results($QUERY);
1391
+ $html .= '<table id="example" class="display" cellpadding="0" cellspacing="0">
1392
  <thead>
1393
  <tr>
1394
+ <th width="10%">' . __('No', 'page-visit-counter') . '</th>
1395
+ <th width="10%">' . __('Page ID', 'page-visit-counter') . '</th>
1396
+ <th>' . __('Page Title', 'page-visit-counter') . '</th>
1397
+ <th width="20%">' . __('Total Count', 'page-visit-counter') . '</th>
1398
+ <th width="20%">' . __('Share', 'page-visit-counter') . '</th>
1399
+ <th width="10%">' . __('Report', 'page-visit-counter') . '</th>
1400
  </tr></thead><tbody>';
1401
+ $counter = 0;
1402
+ foreach ($notvisit as $results) {
1403
+ $counter = $counter + 1;
1404
+ $html .= '<tr>';
1405
+ $html .= '<td>' . $counter . '</td>';
1406
+ $html .= '<td>' . $results->ID . '</td>';
1407
+ $html .= '<td><a href="' . get_admin_url() . 'post.php?post=' . $results->ID . '&action=edit">' . __($results->post_title, 'page-visit-counter') . '</a></td>';
1408
+ $html .= '<td> 0 </td>';
1409
+ $site_title = get_bloginfo('name');
1410
+ $page_social_content = $results->post_title . ' - Total Visits 0 - ' . $site_title;
1411
+
1412
+ $html .= '<td>
1413
+ <a target="_blank" style="margin-right: 5px;" href="https://www.facebook.com/sharer/sharer.php?u=' . esc_url(get_permalink($results->ID)) . '"><img src="' . plugins_url('images/Facebook.png', dirname(__FILE__)) . '" /></a>
1414
+ <a target="_blank" style="margin-right: 5px;" href="https://twitter.com/intent/tweet?text=' . $page_social_content . '&url=' . esc_url(get_permalink($results->ID)) . '"><img src="' . plugins_url('images/twitter.png', dirname(__FILE__)) . '" /></a>
1415
+ <a target="_blank" href="https://plus.google.com/share?url=' . esc_url(get_permalink($results->ID)) . '"><img src="' . plugins_url('images/Google_Plus.png', dirname(__FILE__)) . '" /></a></td>';
1416
+ $html .= '<td><a href="' . site_url() . '/wp-admin/admin.php?page=page_visit_counter&id=' . $results->ID . '" title="' . __($results->post_title, 'page-visit-counter') . '" class="" id="' . $results->ID . '">' . __('View Report', 'page-visit-counter') . '</a></td>';
1417
+ $html .= '</tr>';
1418
+ }
1419
+ $html .= '</tbody><tfoot>
1420
  <tr>
1421
+ <th width="10%">' . __('No', 'page-visit-counter') . '</th>
1422
+ <th width="10%">' . __('Page ID', 'page-visit-counter') . '</th>
1423
+ <th>' . __('Page Title', 'page-visit-counter') . '</th>
1424
+ <th width="20%">' . __('Total Count', 'page-visit-counter') . '</th>
1425
+ <th width="20%">' . __('Share', 'page-visit-counter') . '</th>
1426
+ <th width="10%">' . __('Report', 'page-visit-counter') . '</th>
1427
  </tr></tfoot></table>';
1428
+ echo $html;
1429
+ } else if ($dataquery != '') {
1430
+ $html .= '<table id="example" class="display" cellpadding="0" cellspacing="0">
1431
  <thead>
1432
  <tr>
1433
+ <th width="10%">' . __('No', 'page-visit-counter') . '</th>
1434
+ <th width="10%">' . __('Page ID', 'page-visit-counter') . '</th>
1435
+ <th>' . __('Page Title', 'page-visit-counter') . '</th>
1436
+ <th width="20%">' . __('Total Count', 'page-visit-counter') . '</th>
1437
+ <th width="20%">' . __('Share', 'page-visit-counter') . '</th>
1438
+ <th width="10%">' . __('Report', 'page-visit-counter') . '</th>
1439
  </tr></thead><tbody>';
1440
+ $counter = 0;
1441
+ foreach ($dataquery as $results) {
1442
+ $counter = $counter + 1;
1443
+ $html .= '<tr>';
1444
+ $html .= '<td>' . $counter . '</td>';
1445
+ $html .= '<td>' . $results->ID . '</td>';
1446
+ $html .= '<td><a href="' . get_admin_url() . 'post.php?post=' . $results->ID . '&action=edit">' . __($results->post_title, 'page-visit-counter') . '</a></td>';
1447
+ $str = '';
1448
+ if ($page_title != '') {
1449
+ if ($page_date != '') {
1450
+ $str .= "page_id ='" . $results->ID . "' AND ";
1451
+ } else {
1452
+ $str .= "page_id ='" . $results->ID . "'";
1453
+ }
1454
+ }
1455
+
1456
+ if ($page_date != '') {
1457
+ if ($page_title != '') {
1458
+ $str .= "date ='" . $page_date . "' AND ";
1459
+ } else {
1460
+ $str .= "date ='" . $page_date . "' ";
1461
+ }
1462
+ }
1463
+ $remove = rtrim($str, " AND ");
1464
+ if ($page_date != '' && $page_title != '') {
1465
+ $count_visit = $wpdb->get_results("SELECT * from $table_name where $remove");
1466
+ } elseif ($page_title != '') {
1467
+ $count_visit = $wpdb->get_results("SELECT SUM(page_visit) as page_visit from $table_name where $remove");
1468
+ } elseif ($page_date != '') {
1469
+ $count_visit = $wpdb->get_results("SELECT * from $table_name where page_id=$results->ID AND $remove");
1470
+ }
1471
+ if ($count_visit[0]->page_visit == '') {
1472
+ $countC = 0;
1473
+ } else {
1474
+ $countC = $count_visit[0]->page_visit;
1475
+ }
1476
+
1477
+ $html .= '<td>' . $countC . '</td>';
1478
+
1479
+ $site_title = get_bloginfo('name');
1480
+ $page_social_content = $results->post_title . ' - Total Visits ' . $countC . ' - ' . $site_title;
1481
+
1482
+ $html .= '<td>
1483
+ <a target="_blank" style="margin-right: 5px;" href="https://www.facebook.com/sharer/sharer.php?u=' . esc_url(get_permalink($results->ID)) . '"><img src="' . plugins_url('images/Facebook.png', dirname(__FILE__)) . '" /></a>
1484
+ <a target="_blank" style="margin-right: 5px;" href="https://twitter.com/intent/tweet?text=' . $page_social_content . '&url=' . esc_url(get_permalink($results->ID)) . '"><img src="' . plugins_url('images/twitter.png', dirname(__FILE__)) . '" /></a>
1485
+ <a target="_blank" href="https://plus.google.com/share?url=' . esc_url(get_permalink($results->ID)) . '"><img src="' . plugins_url('images/Google_Plus.png', dirname(__FILE__)) . '" /></a></td>';
1486
+ $html .= '<td><a href="' . site_url() . '/wp-admin/admin.php?page=page_visit_counter&id=' . $results->ID . '" title="' . __($results->post_title, 'page-visit-counter') . '" class="" id="' . $results->ID . '">' . __('View Report', 'page-visit-counter') . '</a></td>';
1487
+
1488
+ $html .= '</tr>';
1489
+ }
1490
+ $html .= '</tbody><tfoot>
1491
  <tr>
1492
+ <th width="10%">' . __('No', 'page-visit-counter') . '</th>
1493
+ <th width="10%">' . __('Page ID', 'page-visit-counter') . '</th>
1494
+ <th>' . __('Page Title', 'page-visit-counter') . '</th>
1495
+ <th width="20%">' . __('Total Count', 'page-visit-counter') . '</th>
1496
+ <th width="20%">' . __('Share', 'page-visit-counter') . '</th>
1497
+ <th width="10%">' . __('Report', 'page-visit-counter') . '</th>
1498
  </tr></tfoot</table>';
1499
+ echo $html;
1500
+ }
1501
+ }
1502
+ die();
1503
+ }
1504
+
1505
+ public function add_custom_meta_box_page_visit()
1506
+ {
1507
+ global $wpdb;
1508
+
1509
+ $fetchSelecetedPostTypes = json_decode(get_option('wfap_post_type'));
1510
+ if (isset($fetchSelecetedPostTypes) && !empty($fetchSelecetedPostTypes)) {
1511
+ $i = 0;
1512
+ foreach ($fetchSelecetedPostTypes as $postsingle) {
1513
+ add_meta_box("header-meta-box-page-visit-$i", "Page Visit Counter", "custom_meta_box_markup_page_visit", "$postsingle", "side", "high", null);
1514
+ $i++;
1515
+ }
1516
+ } else {
1517
+ $i = 0;
1518
+ // Get all the registered post type
1519
+ $post_types = get_post_types();
1520
+ foreach ($post_types as $cpost) {
1521
+ 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") {
1522
+ add_meta_box("header-meta-box-page-visit-$i", "Page Visit Counter", "custom_meta_box_markup_page_visit", "$cpost", "side", "high", null);
1523
+ $i++;
1524
+ }
1525
+ }
1526
+ }
1527
+
1528
+ function add_new_selected_post_columns($columns)
1529
+ {
1530
+
1531
+ return array_merge($columns,
1532
+ array('page_visit_count' => __('Total Visits', 'page-visit-counter')));
1533
+
1534
+
1535
+ }
1536
+
1537
+ function custom_columns_add_page_visit_count($column, $post_id)
1538
+ {
1539
+ global $wpdb, $wp;
1540
+ if ($column == 'page_visit_count') {
1541
+ $table_name = $wpdb->prefix . "page_visit";
1542
+ $pageCount = $wpdb->get_results("SELECT SUM(page_visit) as total FROM $table_name WHERE `page_id` = $post_id");
1543
+ $total = (int)$pageCount[0]->total;
1544
+ echo $total;
1545
+ }
1546
+ }
1547
+
1548
+ function custom_meta_box_markup_page_visit($object)
1549
+ {
1550
+ global $wp, $wpdb;
1551
+
1552
+ $post_id = get_the_ID();
1553
+ $enable_page_count = get_post_meta($post_id, "enable_page_count", true);
1554
+ $enable_page_count_day_wise = get_post_meta($post_id, "enable_page_count_day_wise", true);
1555
+
1556
+ $table_name = $wpdb->prefix . "page_visit";
1557
+
1558
+ $pageCount = $wpdb->get_results("SELECT SUM(page_visit) as total FROM $table_name WHERE `page_id` = $post_id");
1559
+
1560
+ $total = (int)$pageCount[0]->total;
1561
+ ?>
1562
  <input name="pageidvisit" type="hidden" value="<?php echo $post_id; ?>">
1563
+ <p><?php echo __('Do you want to enable page visits count for this page?', 'page-visit-counter'); ?></p>
1564
  <p>
1565
+ <?php if ($enable_page_count == '') { ?>
1566
  <input type="radio" checked="checked" name="autoupdate_page_visit" id="autoupdate_page1"
1567
+ value="yes"><?php echo __('Yes', 'page-visit-counter'); ?>
1568
  <input type="radio" name="autoupdate_page_visit" id="autoupdate_page2"
1569
+ value="no"><?php echo __('No', 'page-visit-counter'); ?>
1570
+ <?php } else { ?>
1571
+ <input type="radio" <?php if ($enable_page_count == 'yes') { ?> checked="checked" <?php } ?>
1572
  name="autoupdate_page_visit" id="autoupdate_page1" value="yes"> Yes
1573
+ <input type="radio" <?php if ($enable_page_count == 'no') { ?> checked="checked" <?php } ?>
1574
  name="autoupdate_page_visit" id="autoupdate_page2" value="no">No<?php
1575
+ } ?>
1576
  </p>
1577
+ <p><?php echo __('Do you want to display today page visits count for this page?', 'page-visit-counter'); ?></p>
1578
  <p>
1579
+ <?php if ($enable_page_count_day_wise == '') { ?>
1580
  <input type="radio" checked="checked" name="autoupdate_page_visit_day_wise"
1581
+ id="autoupdate_page1_day_wise" value="yes"><?php echo __('Yes', 'page-visit-counter'); ?>
1582
  <input type="radio" name="autoupdate_page_visit_day_wise" id="autoupdate_page2_day_wise"
1583
+ value="no"><?php echo __('No', 'page-visit-counter'); ?>
1584
+ <?php } else { ?>
1585
+ <input type="radio" <?php if ($enable_page_count_day_wise == 'yes') { ?> checked="checked" <?php } ?>
1586
  name="autoupdate_page_visit_day_wise" id="autoupdate_page1_day_wise" value="yes"> Yes
1587
+ <input type="radio" <?php if ($enable_page_count_day_wise == 'no') { ?> checked="checked" <?php } ?>
1588
  name="autoupdate_page_visit_day_wise" id="autoupdate_page2_day_wise" value="no">No<?php
1589
+ } ?>
1590
  </p>
1591
+ <p><?php echo __('Do you want to reset all visits count for this page?', 'page-visit-counter'); ?></p>
1592
  <p>
1593
  <input type="radio" name="page_visit_reset" id="page_visit_reset_yes"
1594
+ value="yes"><?php echo __('Yes', 'page-visit-counter'); ?>
1595
  <input type="radio" checked="checked" name="page_visit_reset" id="page_visit_reset_yes"
1596
+ value="no"><?php echo __('No', 'page-visit-counter'); ?>
1597
  </p>
1598
+ <p><?php echo __('Total visits:', 'page-visit-counter'); ?><?php echo $total; ?></p>
1599
+ <?php
1600
+ }
1601
+ }
1602
 
1603
 
1604
+ function save_custom_meta_box_page_visit($post_id)
1605
+ {
1606
+ global $wp, $wpdb, $post;
1607
 
1608
+ if (!current_user_can("edit_post", $post_id)) {
1609
+ return $post_id;
1610
+ }
1611
 
1612
+ if (defined("DOING_AUTOSAVE") && DOING_AUTOSAVE) {
1613
+ return $post_id;
1614
+ }
1615
 
1616
+ if (isset($_POST["autoupdate_page_visit"])) {
1617
+ update_post_meta($post_id, "enable_page_count", $_POST["autoupdate_page_visit"]);
1618
+ }
1619
 
1620
+ if (isset($_POST["autoupdate_page_visit_day_wise"])) {
1621
+ update_post_meta($post_id, "enable_page_count_day_wise", $_POST["autoupdate_page_visit_day_wise"]);
1622
+ }
1623
 
1624
+ if (isset($_POST["page_visit_reset"]) && 'yes' === $_POST["page_visit_reset"]) {
1625
+ $table_name = $wpdb->prefix . "page_visit";
1626
 
1627
+ $query = "DELETE FROM $table_name WHERE `page_id` = $post_id";
1628
 
1629
+ $pageCount = $wpdb->query($query);
1630
 
1631
+ $table_name = $wpdb->prefix . "page_visit_history";
1632
+ $query = "DELETE FROM $table_name WHERE `page_id` = $post_id";
1633
+ $wpdb->query($query);
1634
+ }
1635
 
1636
+ }
1637
 
1638
 
1639
+ function check_page_visit_history_table_exisit()
1640
+ {
1641
+ global $wpdb, $wp;
1642
 
1643
+ $table_name = $wpdb->prefix . "page_visit_history";
1644
+ if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1645
+ $sql = "CREATE TABLE $table_name (
1646
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
1647
  page_id int(11) NOT NULL,
1648
  date date NOT NULL,
1655
  http_referer varchar(255) NOT NULL,
1656
  PRIMARY KEY (id)
1657
  );";
1658
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
1659
+ dbDelta($sql);
1660
+ //add_option( 'contact_db_version', $contact_db_version );
1661
+ }
1662
 
1663
+ }
1664
 
1665
+ function get_page_visit_record_report()
1666
+ {
1667
+ global $wpdb;
1668
 
1669
+ $table_name = $wpdb->prefix . "page_visit_history";
1670
 
1671
+ $pageId = $_REQUEST['page_id'];
1672
 
1673
+ $countQuery = "SELECT COUNT(`page_id`) as total FROM $table_name WHERE `page_id` = $pageId";
1674
+ $result = $wpdb->get_results($countQuery);
1675
 
1676
+ if ((int)$result[0]->total > 0) {
1677
 
1678
+ $queryTopBrowser = "SELECT COUNT(`page_id`) as total, `browser_full_name` as browser FROM $table_name WHERE `page_id` = $pageId GROUP BY `browser_full_name`";
1679
 
1680
+ $topBrowserArr = $wpdb->get_results($queryTopBrowser);
1681
 
1682
+ $topBrowserStringArr = array();
1683
 
1684
 
1685
+ $topBrowserStringArr['Browsers'] = 'Total Visits';
1686
+ if ((int)$result[0]->total > 0) {
1687
+ foreach ($topBrowserArr as $topBrowser) {
1688
+ $topBrowserStringArr[$topBrowser->browser] = (int)$topBrowser->total;
1689
+ }
1690
+ }
1691
 
1692
+ //$queryTopIpAddress = "SELECT COUNT( `page_id` ) AS total, `ipaddress` AS ipaddress FROM $table_name WHERE `page_id` =$pageId GROUP BY `ipaddress` ORDER BY total DESC LIMIT 10";
1693
+ $queryTopIpAddress = "SELECT COUNT( `page_id` ) AS total, `ipaddress` AS ipaddress FROM $table_name WHERE `page_id` =$pageId AND date > DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY `ipaddress` ORDER BY total DESC LIMIT 10";
1694
 
1695
+ $topIpArr = $wpdb->get_results($queryTopIpAddress);
1696
 
1697
+ $topIpStringArr = array();
1698
 
1699
+ $topIpStringArr["IP Address"] = 'Total Visits';
1700
+ if ((int)$result[0]->total > 0) {
1701
+ foreach ($topIpArr as $topIp) {
1702
+ $topIpStringArr["$topIp->ipaddress"] = (int)$topIp->total;
1703
+ }
1704
+ }
1705
 
1706
+ $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";
1707
 
1708
+ $topRefererArr = $wpdb->get_results($queryTopReferer);
1709
 
1710
+ $topRefererStringArr = array();
1711
 
1712
+ $topRefererStringArr["Domain"] = 'Total Visits';
1713
+ if ((int)$result[0]->total > 0) {
1714
+ foreach ($topRefererArr as $topReferer) {
1715
+ if (!array_key_exists("$topReferer->domain", $topRefererStringArr)) {
1716
+ $topRefererStringArr["$topReferer->domain"] = (int)$topReferer->total;
1717
+ } else {
1718
+ $val = (int)$topRefererStringArr["$topReferer->domain"];
1719
+ $topRefererStringArr["$topReferer->domain"] = $val + (int)$topReferer->total;
1720
+ }
1721
+ }
1722
+ unset($topRefererArr);
1723
+ }
1724
 
1725
+ $custom_page_visit_history_datatbase_table_name = $wpdb->prefix . "page_visit_history";
1726
+ //$queryWeeklyReport = "SELECT SUM(page_id) AS total,DATE_ADD(date, INTERVAL(0-WEEKDAY(date)) DAY) as Week_Start_Date,DATE_ADD(date, INTERVAL(6-WEEKDAY(date)) DAY) as week_end_date,YEARWEEK( DATE, 1 ) AS YearAndWeek FROM $table_name WHERE page_id = $pageId GROUP BY YEARWEEK(date,1) ORDER BY YearAndWeek DESC LIMIT 5";
1727
+ $queryWeeklyReport = "SELECT SUM(page_id) AS total,DATE_ADD(date, INTERVAL(0-WEEKDAY(date)) DAY) as Week_Start_Date,DATE_ADD(date, INTERVAL(6-WEEKDAY(date)) DAY) as week_end_date,YEARWEEK( DATE, 1 ) AS YearAndWeek, YEAR(DATE) as year, WEEK( DATE,1 ) as week FROM $custom_page_visit_history_datatbase_table_name WHERE page_id = 1 GROUP BY YEARWEEK(date,1) ORDER BY YearAndWeek DESC LIMIT 5";
1728
 
1729
+ $topWeeklyArr = $wpdb->get_results($queryWeeklyReport);
1730
 
1731
+ $topWeeklyStringArr = array();
1732
 
1733
+ $topWeeklyStringArr["Week Year"] = 'Total Visits';
1734
+ if ((int)$result[0]->total > 0) {
1735
+ foreach (array_reverse($topWeeklyArr) as $topWeekly) {
1736
+ $topWeeklyStringArr["$topWeekly->year - $topWeekly->week"] = (int)$topWeekly->total;
1737
+ }
1738
+ unset($topWeeklyArr);
1739
+ }
1740
 
1741
+ $queryMonthlyReport = "SELECT SUM( `page_id` ) AS total, DATE_FORMAT(`date`,'%M %Y') AS month FROM `$table_name` WHERE `page_id` =$pageId AND YEAR( `date` ) = YEAR( CURDATE( ) ) GROUP BY MONTH( `date` ) ORDER BY MONTH( `date` ) ASC LIMIT 5";
1742
 
1743
+ $topMonthlyArr = $wpdb->get_results($queryMonthlyReport);
1744
 
1745
+ $topMonthlyStringArr = array();
1746
 
1747
+ $topMonthlyStringArr["Month"] = "Total Visits";
1748
+ if ((int)$result[0]->total > 0) {
1749
+ foreach ($topMonthlyArr as $topMonthly) {
1750
+ $topMonthlyStringArr["$topMonthly->month"] = (int)$topMonthly->total;
1751
+ }
1752
+ unset($topMonthlyArr);
1753
+ }
1754
 
1755
+ $queryYearlyReport = "SELECT SUM( `page_id` ) AS total, YEAR( `date` ) AS year FROM `$table_name` WHERE `page_id` =$pageId GROUP BY YEAR( `date` ) ORDER BY YEAR( `date` ) DESC LIMIT 10";
1756
 
1757
+ $topYearlyArr = $wpdb->get_results($queryYearlyReport);
1758
 
1759
+ $topYearlyStringArr = array();
1760
 
1761
+ foreach ($topYearlyArr as $topYearly) {
1762
+ $topYearlyStringArr["$topYearly->year"] = $topYearly->total;
1763
+ }
1764
+ unset($topYearlyArr);
1765
 
1766
+ $resultsArr = array();
1767
 
1768
+ $resultsArr['topBrowserString'] = $topBrowserStringArr;
1769
+ $resultsArr['topIpString'] = $topIpStringArr;
1770
+ $resultsArr['topRefererString'] = $topRefererStringArr;
1771
+ $resultsArr['topWeeklyString'] = $topWeeklyStringArr;
1772
+ $resultsArr['topMonthlyString'] = $topMonthlyStringArr;
1773
+ $resultsArr['topYearlyString'] = $topYearlyStringArr;
1774
 
1775
+ echo json_encode($resultsArr);
1776
+ unset($resultsArr);
1777
+ //print_r($topBrowserStringArr);
1778
+ } else {
1779
+ echo json_encode('novisit');
1780
+ }
1781
 
1782
+ die();
1783
+ }
1784
 
1785
 
1786
+ public function custom_admin_pointers_footer()
1787
+ {
1788
+ $admin_pointers = custom_admin_pointers();
1789
+ ?>
1790
  <script type="text/javascript">
1791
  /* <![CDATA[ */
1792
  (function ($) {
1793
+ <?php
1794
+ foreach ( $admin_pointers as $pointer => $array ) {
1795
+ if ( $array['active'] ) {
1796
+ ?>
1797
  $('<?php echo $array['anchor_id']; ?>').pointer({
1798
  content: '<?php echo $array['content']; ?>',
1799
  position: {
1807
  });
1808
  }
1809
  }).pointer('open');
1810
+ <?php
1811
+ }
1812
+ }
1813
+ ?>
1814
  })(jQuery);
1815
  /* ]]> */
1816
  </script>
1817
+ <?php
1818
+ }
1819
 
1820
 
1821
+ /**
1822
+ * Function For display pointer in admin side
1823
+ *
1824
+ */
1825
 
1826
 
1827
  }
1831
  * widget provide Most visited page.
1832
  *
1833
  */
1834
+ class My_Widget extends WP_Widget
1835
+ {
1836
+ public function __construct()
1837
+ {
1838
+ $widget_ops = array('classname' => 'My_Widget', 'description' => 'Most Visited Pages');
1839
+ parent::__construct('My_Widget', 'Recent Most Visit page', $widget_ops);
1840
+ }
1841
+
1842
+ function widget($args, $instance)
1843
+ {
1844
+ global $wpdb;
1845
+ $table_name = $wpdb->prefix . "page_visit";
1846
+ $html = '';
1847
+ extract($args, EXTR_SKIP);
1848
+ $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
1849
+ $html .= (isset($before_widget) ? $before_widget : '');
1850
+ if (!empty($title)) {
1851
+ $html .= $before_title . $title . $after_title;
1852
+ }
1853
+ $count_visit = $wpdb->get_results("SELECT page_id,id,SUM(page_visit) as c from $table_name group by page_id order by c DESC limit 5");
1854
+ foreach ($count_visit as $visitpage) {
1855
+ $page = get_post($visitpage->page_id);
1856
+ $html .= '<h6 style="font-size: 14px;font-weight: normal;line-height: 14px;">' . $page->post_title . '</h6>';
1857
+ $html .= "<br>";
1858
+ }
1859
+ $html .= (isset($after_widget) ? $after_widget : '');
1860
+ echo $html;
1861
+ }
1862
+
1863
+ public function form($instance)
1864
+ {
1865
+ $instance = wp_parse_args((array)$instance, array('title' => ''));
1866
+ $title = $instance['title'];
1867
+ $html = '';
1868
+ $html .= '<p> <label for="' . $this->get_field_id("title") . '">Title:
1869
+ <input class="widefat" id="' . $this->get_field_id("title") . '"
1870
+ name="' . $this->get_field_name("title") . '" type="text"
1871
+ value="' . attribute_escape($title) . '" /></label></p>';
1872
+ echo $html;
1873
+ }
1874
+
1875
+ function update($new_instance, $old_instance)
1876
+ {
1877
+ $instance = $old_instance;
1878
+ $instance['title'] = $new_instance['title'];
1879
+
1880
+ return $instance;
1881
+ }
1882
  }
1883
 
1884
+ add_action('widgets_init', create_function('', 'return register_widget("My_Widget");'));
1885
 
1886
+ function custom_admin_pointers()
1887
+ {
1888
 
1889
+ $dismissed = explode(',', (string)get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
1890
+ $version = '1_0'; // replace all periods in 1.0 with an underscore
1891
+ $prefix = 'custom_admin_pointers' . $version . '_';
1892
 
1893
+ $new_pointer_content = '<h3>' . __('Page Visit Counter') . '</h3>';
1894
+ $new_pointer_content .= '<p>' . __('This plugin will count the total visits of your sites pages.') . '</p>';
1895
 
1896
+ return array(
1897
+ $prefix . 'page_visit_counter_notice_view' => array(
1898
+ 'content' => $new_pointer_content,
1899
+ 'anchor_id' => '#toplevel_page_page_visit_counter',
1900
+ 'edge' => 'left',
1901
+ 'align' => 'left',
1902
+ 'active' => (!in_array($prefix . 'page_visit_counter_notice_view', $dismissed))
1903
+ )
1904
+ );
1905
 
1906
  }
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.0.5
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.0.6
11
  * Author URI: http://www.multidots.com/
12
  */
13
  // If this file is called directly, abort.