Version Description
- 21-12-2018 =
- compatible with WordPress 5.0.x
Download this release
Release Info
Developer | dots |
Plugin | Page Visit Counter |
Version | 4.9 |
Comparing to | |
See all releases |
Code changes from version 4.8 to 4.9
- README.txt +10 -2
- admin/class-page-visit-counter-admin.php +240 -264
- admin/css/style.css +1 -0
- admin/js/save_page_view.js +20 -0
- includes/class-page-visit-counter.php +30 -27
- page_visit_counter.php +139 -125
- public/class-page-visit-counter-public.php +1 -1
README.txt
CHANGED
@@ -4,10 +4,10 @@ Plugin URI: http://multidots.com/
|
|
4 |
Author: Multidots
|
5 |
Author URI: http://multidots.com/
|
6 |
Contributors: dots, ketuchetan, chiragpatel, jitendrabanjara1991, thedotstore
|
7 |
-
Stable tag: 4.
|
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:
|
11 |
Donate link:
|
12 |
Copyright: (c) 2014-2016 Multidots Solutions PVT LTD (info@multidots.com)
|
13 |
License: GPLv3 or later
|
@@ -42,6 +42,11 @@ In this option you can see all pages listing within Page ID, Page Title and Tota
|
|
42 |
2. After Activation of plugin it will display page count in all pages at bottom of your site. If you do not want to display or you want to exclude particular post type from page views count then at that time you exclude particular post type in "Post type" setting of page counter.
|
43 |
3. If you want that pages visit/hits from Specific IP not include in page counter then you can add that Specific id to "Exclude IPs (Ip Address)" on setting of page counter and then page request comes from that Specific IP is not included in page visit counter.
|
44 |
4. If you want that specific hits/visits of pages comes from register users of your site that is not include in page counter then you can add name of that Specific register user of your site on "Exclude Users" and then page request comes from that Specific register user is not included in page visit counter.
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
= Localization: =
|
47 |
* Croation
|
@@ -115,6 +120,9 @@ Automatic updates should work great for you. As always, though, we recommend ba
|
|
115 |
|
116 |
== Changelog ==
|
117 |
|
|
|
|
|
|
|
118 |
= 4.8 - 13-11-2018 =
|
119 |
* compatible with php 7.2.0 version.
|
120 |
|
4 |
Author: Multidots
|
5 |
Author URI: http://multidots.com/
|
6 |
Contributors: dots, ketuchetan, chiragpatel, jitendrabanjara1991, thedotstore
|
7 |
+
Stable tag: 4.9
|
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: 5.0.2
|
11 |
Donate link:
|
12 |
Copyright: (c) 2014-2016 Multidots Solutions PVT LTD (info@multidots.com)
|
13 |
License: GPLv3 or later
|
42 |
2. After Activation of plugin it will display page count in all pages at bottom of your site. If you do not want to display or you want to exclude particular post type from page views count then at that time you exclude particular post type in "Post type" setting of page counter.
|
43 |
3. If you want that pages visit/hits from Specific IP not include in page counter then you can add that Specific id to "Exclude IPs (Ip Address)" on setting of page counter and then page request comes from that Specific IP is not included in page visit counter.
|
44 |
4. If you want that specific hits/visits of pages comes from register users of your site that is not include in page counter then you can add name of that Specific register user of your site on "Exclude Users" and then page request comes from that Specific register user is not included in page visit counter.
|
45 |
+
5. 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.
|
46 |
+
1. Use this shortcode to add admin side content on page/post: [page_visit_counter_md id="<page_id/post_id>"]
|
47 |
+
2. Use this shortcode to display total sites visit to add admin side content on page/post: [page_visit_counter_md_total_sites_visit backgroundcolor="#ff0000" countboxcolor="#000000" fontcolor="#FFFFFF" bordercolor="#ff0000"]
|
48 |
+
3. Use this shortcode to add page/post template (.php) file of your own template: `<?php echo do_shortcode('[page_visit_counter_md id='page_id/post_id']');?>`
|
49 |
+
4. Use this shortcode to display total sites visit to add page/post template (.php) file of your own template: `<?php echo do_shortcode('[page_visit_counter_md_total_sites_visit backgroundcolor='#ff0000' countboxcolor='#000000' fontcolor='#FFFFFF' bordercolor='#ff0000']');?>`
|
50 |
|
51 |
= Localization: =
|
52 |
* Croation
|
120 |
|
121 |
== Changelog ==
|
122 |
|
123 |
+
= 4.9 - 21-12-2018 =
|
124 |
+
* compatible with WordPress 5.0.x
|
125 |
+
|
126 |
= 4.8 - 13-11-2018 =
|
127 |
* compatible with php 7.2.0 version.
|
128 |
|
admin/class-page-visit-counter-admin.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
// If this file is called directly, abort.
|
3 |
-
if (
|
4 |
exit;
|
5 |
}
|
6 |
/**
|
@@ -23,8 +23,7 @@ if ( !defined( 'ABSPATH' ) ) {
|
|
23 |
* @subpackage page-visit-counter/admin
|
24 |
* @author Multidots <wordpress@multidots.com>
|
25 |
*/
|
26 |
-
class page_visit_counter_Admin
|
27 |
-
{
|
28 |
|
29 |
/**
|
30 |
* The ID of this plugin.
|
@@ -52,12 +51,10 @@ class page_visit_counter_Admin
|
|
52 |
* @param string $plugin_name The name of this plugin.
|
53 |
* @param string $version The version of this plugin.
|
54 |
*/
|
55 |
-
public function __construct($plugin_name, $version)
|
56 |
-
{
|
57 |
|
58 |
$this->plugin_name = $plugin_name;
|
59 |
$this->version = $version;
|
60 |
-
|
61 |
}
|
62 |
|
63 |
/**
|
@@ -65,9 +62,7 @@ class page_visit_counter_Admin
|
|
65 |
*
|
66 |
* @since 1.0.0
|
67 |
*/
|
68 |
-
|
69 |
-
public function enqueue_styles()
|
70 |
-
{
|
71 |
|
72 |
/**
|
73 |
* This function is provided for demonstration purposes only.
|
@@ -80,7 +75,6 @@ class page_visit_counter_Admin
|
|
80 |
* between the defined hooks and the functions defined in this
|
81 |
* class.
|
82 |
*/
|
83 |
-
|
84 |
//wp_enqueue_style("jquery-ui-tabs");
|
85 |
|
86 |
wp_enqueue_style('custom-style', plugin_dir_url(__FILE__) . 'css/style.css');
|
@@ -97,8 +91,7 @@ class page_visit_counter_Admin
|
|
97 |
*
|
98 |
* @since 1.0.0
|
99 |
*/
|
100 |
-
public function enqueue_scripts()
|
101 |
-
{
|
102 |
|
103 |
/**
|
104 |
* This function is provided for demonstration purposes only.
|
@@ -111,7 +104,7 @@ class page_visit_counter_Admin
|
|
111 |
* between the defined hooks and the functions defined in this
|
112 |
* class.
|
113 |
*/
|
114 |
-
|
115 |
wp_enqueue_script('jquery-ui-core');
|
116 |
wp_enqueue_script('jquery-ui-tabs');
|
117 |
wp_enqueue_script('jquery-ui-datepicker');
|
@@ -125,17 +118,17 @@ class page_visit_counter_Admin
|
|
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 |
}
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
133 |
|
134 |
wp_enqueue_script('iris', admin_url('js/iris.min.js'), array(
|
135 |
'jquery-ui-draggable',
|
136 |
'jquery-ui-slider',
|
137 |
'jquery-touch-punch'
|
138 |
-
|
139 |
wp_enqueue_script('wp-color-picker', admin_url('js/color-picker.min.js'), array('iris'), false, 1);
|
140 |
|
141 |
$colorpicker_l10n = array(
|
@@ -152,6 +145,9 @@ class page_visit_counter_Admin
|
|
152 |
|
153 |
wp_localize_script('one', 'pagevisit', array('ajaxurl' => admin_url('admin-ajax.php')));
|
154 |
}
|
|
|
|
|
|
|
155 |
|
156 |
$fetchSelecetedPostTypes = get_option('wfap_post_type');
|
157 |
if (!empty($fetchSelecetedPostTypes) || $fetchSelecetedPostTypes != "") {
|
@@ -171,11 +167,10 @@ class page_visit_counter_Admin
|
|
171 |
if (!empty($optionsIpAddress) || $optionsIpAddress != "") {
|
172 |
wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => $optionsIpAddress));
|
173 |
} else {
|
174 |
-
wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => ["126"]
|
175 |
}
|
176 |
-
}
|
177 |
-
|
178 |
-
wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => ["127"] ));
|
179 |
}
|
180 |
|
181 |
$fetchSelecetedUserId = get_option('userlist_visit');
|
@@ -189,12 +184,9 @@ class page_visit_counter_Admin
|
|
189 |
} else {
|
190 |
wp_localize_script('one', 'get_user_option', array('usersarray' => ''));
|
191 |
}
|
192 |
-
|
193 |
}
|
194 |
|
195 |
-
|
196 |
-
public function welcome_page_visit_counter_screen_do_activation_redirect()
|
197 |
-
{
|
198 |
// if no activation redirect
|
199 |
if (!get_transient('_welcome_screen_page_visitor_activation_redirect_data')) {
|
200 |
return;
|
@@ -211,23 +203,20 @@ class page_visit_counter_Admin
|
|
211 |
wp_safe_redirect(add_query_arg(array('page' => 'page-visit-counter-about&tab=about'), admin_url('index.php')));
|
212 |
}
|
213 |
|
214 |
-
public function welcome_pages_screen_page_visit_counter()
|
215 |
-
{
|
216 |
add_dashboard_page(
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
);
|
222 |
}
|
223 |
|
224 |
-
public function admin_css()
|
225 |
-
{
|
226 |
wp_enqueue_style($this->plugin_name . 'welcome-page', plugin_dir_url(__FILE__) . 'css/style.css', array(), $this->version, 'all');
|
227 |
}
|
228 |
|
229 |
-
public function welcome_screen_content_page_visit_counter()
|
230 |
-
{
|
231 |
?>
|
232 |
<div class="wrap about-wrap">
|
233 |
<h1 style="font-size: 2.1em;"><?php printf(esc_html__('Welcome to Page Visit Counter', 'page-visit-counter')); ?></h1>
|
@@ -276,8 +265,7 @@ class page_visit_counter_Admin
|
|
276 |
* Extra flate rate overview welcome page content function
|
277 |
*
|
278 |
*/
|
279 |
-
public function page_visit_counter_about()
|
280 |
-
{
|
281 |
//do_action('my_own');
|
282 |
$current_user = wp_get_current_user();
|
283 |
?>
|
@@ -302,51 +290,51 @@ class page_visit_counter_Admin
|
|
302 |
<div class="wc-feature feature-section col three-col">
|
303 |
<div>
|
304 |
<p class="page_visit_overview"><?php esc_html_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>
|
305 |
-
<p class="page_visit_overview"><strong><?php esc_html_e('Page Counter Settings:', 'page-visit-counter')
|
306 |
<div class="Page_Counter_Settings_Content_ul">
|
307 |
<ul>
|
308 |
-
<li><?php esc_html_e("In these options you can do different setting for page visit counter.", 'page-visit-counter')
|
309 |
<li><?php esc_html_e("Short Code: There are two shortcuts that you can use to manually add page view count
|
310 |
to any content on admin or post/page template created by your theme or plugin that's
|
311 |
-
creating its own display content in a page / post.", 'page-visit-counter')
|
312 |
</li>
|
313 |
<li><?php esc_html_e("Post Type: You can select the post type from the drop down menu for which post views
|
314 |
will be counted. If you leave blank on post type, then all pages or all past type
|
315 |
-
posts will be counted.", 'page-visit-counter')
|
316 |
</li>
|
317 |
<li><?php esc_html_e("Exclude IPs (Ip Address): Enter the IP addresses which you want to be excluded from
|
318 |
-
post views count.", 'page-visit-counter')
|
319 |
</li>
|
320 |
<li><?php esc_html_e("Exclude Users: Select users from your project/system to be excluded from post view
|
321 |
-
count.", 'page-visit-counter')
|
322 |
</li>
|
323 |
<li><?php esc_html_e("Show front view counter: Check the box if you want to display counter view on front
|
324 |
-
end.", 'page-visit-counter')
|
325 |
</li>
|
326 |
<li><?php esc_html_e("Choose color for the front end view: select color from color picker to choose the
|
327 |
-
color for display visit pages text on front side as well as in the shortcode.", 'page-visit-counter')
|
328 |
</li>
|
329 |
</ul>
|
330 |
</div>
|
331 |
|
332 |
-
<p class="page_visit_overview"><strong><?php esc_html_e("Page Counter Settings:", 'page-visit-counter')
|
333 |
|
334 |
<p class="page_visit_overview"><?php _e("In this option you can see all pages listing within Page ID, Page
|
335 |
Title and Total Count. It will display all pages of your site. If you excluded particular
|
336 |
post type from page visit counter then also it will display that post type, posts pages on
|
337 |
table but it will not count those pages and 'total count' will be '0' for excluded post
|
338 |
-
type, post pages.</p>", 'page-visit-counter')
|
339 |
|
340 |
<div class="Page_Counter_Settings_Content_ul">
|
341 |
<ul>
|
342 |
<li><?php esc_html_e('Search facility: This provides you the extra facility to search pages by title and
|
343 |
-
search page by its crated date.', 'page-visit-counter')
|
344 |
</li>
|
345 |
<li><?php esc_html_e('Sharing facility: This provides you to share specific page on Facebook, Twitter and
|
346 |
-
Google Plus.', 'page-visit-counter')
|
347 |
</li>
|
348 |
<li><?php esc_html_e('Reports: This provides you the specific page vise reports like Top browsers, Top 10
|
349 |
-
IP address, Top referer, weekly report and Monthly report using chart.', 'page-visit-counter')
|
350 |
</li>
|
351 |
</ul>
|
352 |
</div>
|
@@ -364,8 +352,7 @@ class page_visit_counter_Admin
|
|
364 |
* Remove the Extra flate rate menu in dashboard
|
365 |
*
|
366 |
*/
|
367 |
-
public function welcome_screen_remove_menus()
|
368 |
-
{
|
369 |
remove_submenu_page('index.php', 'page-visit-counter-about');
|
370 |
}
|
371 |
|
@@ -374,16 +361,15 @@ class page_visit_counter_Admin
|
|
374 |
* add menu in admin menubar.
|
375 |
*
|
376 |
*/
|
377 |
-
public function page_visit_counter_menu()
|
378 |
-
{
|
379 |
add_menu_page(esc_html__('Page-Visit-Counter', 'page-visit-counter'), esc_html__('PageVisitCounter', 'page-visit-counter'), 'manage_options', 'page_visit_counter', 'extra_page_visit_function_custom', plugins_url('page-visit-counter/admin/images/icon.png'));
|
380 |
add_submenu_page('page_visit_counter', esc_html__('Counter-Settings', 'page-visit-counter'), esc_html__('Settings', 'page-visit-counter'), 'manage_options', 'page_visit_settings', 'custom_page_visit_settings');
|
|
|
381 |
/**
|
382 |
* extra_page_visit_function_custom use the menu callback function
|
383 |
* $name pass the arguments
|
384 |
*/
|
385 |
-
function extra_page_visit_function_custom($name)
|
386 |
-
{
|
387 |
global $wpdb;
|
388 |
|
389 |
if (!class_exists('WP_List_Table')) {
|
@@ -406,8 +392,7 @@ class page_visit_counter_Admin
|
|
406 |
<h1><?php echo esc_html__('Page Visit Counter', 'page-visit-counter'); ?></h1>
|
407 |
</div>
|
408 |
|
409 |
-
<?php
|
410 |
-
if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { ?>
|
411 |
<style type="text/css">
|
412 |
.tabs div#chartContainer-main {
|
413 |
float: left;
|
@@ -434,7 +419,7 @@ class page_visit_counter_Admin
|
|
434 |
width: 50%;
|
435 |
}
|
436 |
</style>
|
437 |
-
<div class="back"><h5><a class="button button-primary" href="<?php echo esc_url(home_url('/wp-admin/admin.php?page=page_visit_counter'))
|
438 |
<div style="">
|
439 |
<div id="page-vist-fancybox" class="page-counter-fancybox">
|
440 |
<div id="tabs">
|
@@ -718,9 +703,9 @@ class page_visit_counter_Admin
|
|
718 |
//jQuery( "#tabs" ).tabs();
|
719 |
|
720 |
|
721 |
-
// setTimeout(function(){
|
722 |
-
// jQuery('body #ui-id-1').trigger('click');
|
723 |
-
// },500);
|
724 |
|
725 |
jQuery("#chartContainer").html('No Visitor Found.');
|
726 |
jQuery("#chartContainer1").html('No Visitor Found.');
|
@@ -747,14 +732,13 @@ class page_visit_counter_Admin
|
|
747 |
|
748 |
|
749 |
</script>
|
750 |
-
<?php
|
751 |
-
|
752 |
<form id="movies-filter" method="post">
|
753 |
<?php
|
754 |
-
$test_list_table->search_box('Search','');
|
755 |
foreach ($_POST as $key => $value) {
|
756 |
-
if ('s' !== $key) // don't include the search query
|
757 |
-
{
|
758 |
// echo("<input type='hidden' name='".esc_attr($key)."' value='".esc_attr($value)."' />");
|
759 |
echo("<input type='hidden' name='$key' value='$value' />");
|
760 |
}
|
@@ -766,7 +750,7 @@ class page_visit_counter_Admin
|
|
766 |
<!-- Twitter -->
|
767 |
<script>!function (d, s, id) {
|
768 |
var js, fjs = d.getElementsByTagName(s)[0],
|
769 |
-
|
770 |
if (!d.getElementById(id)) {
|
771 |
js = d.createElement(s);
|
772 |
js.id = id;
|
@@ -778,7 +762,8 @@ class page_visit_counter_Admin
|
|
778 |
<!-- Facebook -->
|
779 |
<script>(function (d, s, id) {
|
780 |
var js, fjs = d.getElementsByTagName(s)[0];
|
781 |
-
if (d.getElementById(id))
|
|
|
782 |
js = d.createElement(s);
|
783 |
js.id = id;
|
784 |
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
|
@@ -797,8 +782,8 @@ class page_visit_counter_Admin
|
|
797 |
})();
|
798 |
</script>
|
799 |
|
800 |
-
|
801 |
-
|
802 |
|
803 |
</div>
|
804 |
|
@@ -809,8 +794,7 @@ class page_visit_counter_Admin
|
|
809 |
* function use to page settings
|
810 |
* $args is pass the arguments
|
811 |
*/
|
812 |
-
function custom_page_visit_settings($args)
|
813 |
-
{
|
814 |
|
815 |
global $wpdb;
|
816 |
$current_user = wp_get_current_user();
|
@@ -830,7 +814,7 @@ class page_visit_counter_Admin
|
|
830 |
?>
|
831 |
<div class="main-page-visit-settings">
|
832 |
<div class="page-title-settings">
|
833 |
-
<form id="pvc_plugin_form_id" method="post" action="<?php echo esc_url(get_admin_url() .'admin-post.php'); ?>" enctype="multipart/form-data" novalidate="novalidate">
|
834 |
<?php wp_nonce_field(basename(__FILE__), 'pvc_setting'); ?>
|
835 |
<input type="hidden" name="action" value="submit_form_pvc"/>
|
836 |
<input id="action_which" type="hidden" name="action-which" value="add"/>
|
@@ -864,9 +848,7 @@ class page_visit_counter_Admin
|
|
864 |
<b> <?php echo "<?php echo do_shortcode('[page_visit_counter_md id='page_id/post_id']');?>" ?></b>
|
865 |
</p>
|
866 |
<p><?php echo esc_html__('Use this shortcode to display total sites visit to add page/post template (.php) file of your own template:', 'page-visit-counter'); ?>
|
867 |
-
<br><b> <?php echo do_shortcode('[page_visit_counter_md_total_sites_visit
|
868 |
-
backgroundcolor='#ff0000' countboxcolor='#000000' fontcolor='#FFFFFF'
|
869 |
-
bordercolor='#ff0000']');?> </b></p>
|
870 |
</fieldset>
|
871 |
</div>
|
872 |
|
@@ -880,97 +862,104 @@ class page_visit_counter_Admin
|
|
880 |
?>
|
881 |
<table border="0" cellpadding="10" cellspacing="0">
|
882 |
<tbody>
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
|
|
|
|
894 |
}
|
895 |
}
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
|
|
|
|
912 |
}
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
|
|
|
|
931 |
}
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
<?php
|
942 |
-
$hide_show_option = get_option('counter_hide_show_front_vew');
|
943 |
-
if ($hide_show_option == 'on') {
|
944 |
-
$cheked = 'checked';
|
945 |
-
} else {
|
946 |
-
$cheked = '';
|
947 |
-
} ?>
|
948 |
-
<td class="information">
|
949 |
-
<input type="checkbox" name="hidefrontview" id="hide_front_view" <?php echo esc_attr($cheked); ?>><?php echo esc_html__('Check the box if you want to display counter view on front end.', 'page-visit-counter'); ?>
|
950 |
-
</td>
|
951 |
-
</tr>
|
952 |
-
|
953 |
-
<tr class="hidefront" style="display:none;">
|
954 |
-
<th scope="row"><label for="blogname"><?php echo esc_html__('Last How many days count you want to display on front end.', 'page-visit-counter'); ?></label>
|
955 |
-
</th>
|
956 |
-
<td class="information">
|
957 |
<?php
|
958 |
-
$
|
959 |
-
if ($
|
960 |
-
$
|
|
|
|
|
961 |
}
|
962 |
?>
|
963 |
-
<
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
<
|
969 |
-
|
970 |
-
|
971 |
-
<
|
972 |
-
|
973 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
974 |
</tbody>
|
975 |
</table>
|
976 |
</fieldset>
|
@@ -985,6 +974,7 @@ class page_visit_counter_Admin
|
|
985 |
</div>
|
986 |
<?php
|
987 |
}
|
|
|
988 |
}
|
989 |
|
990 |
/**
|
@@ -992,12 +982,11 @@ class page_visit_counter_Admin
|
|
992 |
* view most visited page in dashboard.
|
993 |
*
|
994 |
*/
|
995 |
-
function my_custom_dashboard_widgets()
|
996 |
-
{
|
997 |
global $wp_meta_boxes;
|
998 |
wp_add_dashboard_widget('custom_help_widget', esc_html__('Most Visited Page', 'page-visit-counter'), 'custom_dashboard_help');
|
999 |
-
|
1000 |
-
{
|
1001 |
global $wpdb;
|
1002 |
$table_name = $wpdb->prefix . "page_visit";
|
1003 |
$html = '';
|
@@ -1018,7 +1007,7 @@ class page_visit_counter_Admin
|
|
1018 |
$html .= '<tr>';
|
1019 |
$html .= '<td>' . esc_attr($page->ID) . '</td>';
|
1020 |
$edit_url = get_admin_url() . 'post.php?post=' . esc_attr($page->ID) . '&action=edit';
|
1021 |
-
$html .= '<td><a href="' . esc_url($edit_url).'">' . esc_html($page->post_title) . '</a></td>';
|
1022 |
$html .= '<td>' . esc_attr($visitpage->c) . '</td>';
|
1023 |
$html .= '</tr>';
|
1024 |
}
|
@@ -1029,6 +1018,7 @@ class page_visit_counter_Admin
|
|
1029 |
$html .= '</div>';
|
1030 |
echo $html;
|
1031 |
}
|
|
|
1032 |
}
|
1033 |
|
1034 |
/**
|
@@ -1036,8 +1026,7 @@ class page_visit_counter_Admin
|
|
1036 |
* add option by option table
|
1037 |
* add page count option and duration.
|
1038 |
*/
|
1039 |
-
public function add_page_count_option()
|
1040 |
-
{
|
1041 |
global $wpdb;
|
1042 |
|
1043 |
$page_count_option = array();
|
@@ -1135,8 +1124,7 @@ class page_visit_counter_Admin
|
|
1135 |
* select_input_page_value use in ajax callback function
|
1136 |
* handle the date and page title on change event.
|
1137 |
*/
|
1138 |
-
public function select_input_page_value()
|
1139 |
-
{
|
1140 |
global $wpdb;
|
1141 |
$table_name = $wpdb->prefix . "page_visit";
|
1142 |
$table_post = $wpdb->prefix . "posts";
|
@@ -1334,7 +1322,7 @@ class page_visit_counter_Admin
|
|
1334 |
<a target="_blank" style="margin-right: 5px;" href="https://www.facebook.com/sharer/sharer.php?u=' . esc_url(get_permalink($results->ID)) . '"><img src="' . esc_url(plugins_url('images/Facebook.png', dirname(__FILE__))) . '" /></a>
|
1335 |
<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="' . esc_url(plugins_url('images/twitter.png', dirname(__FILE__))) . '" /></a>
|
1336 |
<a target="_blank" href="https://plus.google.com/share?url=' . esc_url(get_permalink($results->ID)) . '"><img src="' . esc_url(plugins_url('images/Google_Plus.png', dirname(__FILE__))) . '" /></a></td>';
|
1337 |
-
$html .= '<td><a href="' . esc_url(home_url('/wp-admin/admin.php?page=page_visit_counter&id=' . $results->ID)). '" title="' . wp_kses_post($results->post_title) . '" class="" id="' . esc_attr($results->ID) . '">' . esc_html__('View Report', 'page-visit-counter') . '</a></td>';
|
1338 |
|
1339 |
$html .= '</tr>';
|
1340 |
}
|
@@ -1353,8 +1341,7 @@ class page_visit_counter_Admin
|
|
1353 |
die();
|
1354 |
}
|
1355 |
|
1356 |
-
public function add_custom_meta_box_page_visit()
|
1357 |
-
{
|
1358 |
global $wpdb;
|
1359 |
|
1360 |
$fetchSelecetedPostTypes = json_decode(get_option('wfap_post_type'));
|
@@ -1376,29 +1363,22 @@ class page_visit_counter_Admin
|
|
1376 |
}
|
1377 |
}
|
1378 |
|
1379 |
-
function add_new_selected_post_columns($columns)
|
1380 |
-
|
1381 |
-
|
1382 |
-
return array_merge($columns,
|
1383 |
-
array('page_visit_count' => esc_html__('Total Visits', 'page-visit-counter')));
|
1384 |
-
|
1385 |
-
|
1386 |
}
|
1387 |
|
1388 |
-
function custom_columns_add_page_visit_count($column, $post_id)
|
1389 |
-
{
|
1390 |
global $wpdb, $wp;
|
1391 |
if ($column == 'page_visit_count') {
|
1392 |
$table_name = $wpdb->prefix . "page_visit";
|
1393 |
$get_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $post_id);
|
1394 |
$pageCount = $wpdb->get_results($get_qry);
|
1395 |
-
$total = (int)$pageCount[0]->total;
|
1396 |
echo $total;
|
1397 |
}
|
1398 |
}
|
1399 |
|
1400 |
-
function custom_meta_box_markup_page_visit($object)
|
1401 |
-
{
|
1402 |
global $wp, $wpdb;
|
1403 |
|
1404 |
$post_id = get_the_ID();
|
@@ -1410,7 +1390,7 @@ class page_visit_counter_Admin
|
|
1410 |
$get_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $post_id);
|
1411 |
$pageCount = $wpdb->get_results($get_qry);
|
1412 |
|
1413 |
-
$total = (int)$pageCount[0]->total;
|
1414 |
?>
|
1415 |
<input name="pageidvisit" type="hidden" value="<?php echo $post_id; ?>">
|
1416 |
<p><?php echo esc_html__('Do you want to enable page visits count for this page?', 'page-visit-counter'); ?></p>
|
@@ -1420,12 +1400,12 @@ class page_visit_counter_Admin
|
|
1420 |
value="yes"><?php echo esc_html__('Yes', 'page-visit-counter'); ?>
|
1421 |
<input type="radio" name="autoupdate_page_visit" id="autoupdate_page2"
|
1422 |
value="no"><?php echo esc_html__('No', 'page-visit-counter'); ?>
|
1423 |
-
|
1424 |
<input type="radio" <?php if ($enable_page_count == 'yes') { ?> checked="checked" <?php } ?>
|
1425 |
name="autoupdate_page_visit" id="autoupdate_page1" value="yes"> <?php echo esc_html__('Yes', 'page-visit-counter'); ?>
|
1426 |
<input type="radio" <?php if ($enable_page_count == 'no') { ?> checked="checked" <?php } ?>
|
1427 |
-
name="autoupdate_page_visit" id="autoupdate_page2" value="no"> <?php echo esc_html__('No', 'page-visit-counter'); ?><?php
|
1428 |
-
|
1429 |
</p>
|
1430 |
<p><?php echo esc_html__('Do you want to display today page visits count for this page?', 'page-visit-counter'); ?></p>
|
1431 |
<p>
|
@@ -1436,8 +1416,8 @@ class page_visit_counter_Admin
|
|
1436 |
<input type="radio" <?php if ($enable_page_count_day_wise == 'yes') { ?> checked="checked" <?php } ?>
|
1437 |
name="autoupdate_page_visit_day_wise" id="autoupdate_page1_day_wise" value="yes"> <?php echo esc_html__('Yes', 'page-visit-counter'); ?>
|
1438 |
<input type="radio" <?php if ($enable_page_count_day_wise == 'no') { ?> checked="checked" <?php } ?>
|
1439 |
-
name="autoupdate_page_visit_day_wise" id="autoupdate_page2_day_wise" value="no"><?php echo esc_html__('No', 'page-visit-counter'); ?><?php
|
1440 |
-
|
1441 |
</p>
|
1442 |
<p><?php echo esc_html__('Do you want to reset all visits count for this page?', 'page-visit-counter'); ?></p>
|
1443 |
<p>
|
@@ -1446,14 +1426,16 @@ class page_visit_counter_Admin
|
|
1446 |
<input type="radio" checked="checked" name="page_visit_reset" id="page_visit_reset_yes"
|
1447 |
value="no"><?php echo esc_html__('No', 'page-visit-counter'); ?>
|
1448 |
</p>
|
1449 |
-
<p
|
|
|
|
|
|
|
1450 |
<?php
|
1451 |
}
|
1452 |
-
}
|
1453 |
|
|
|
1454 |
|
1455 |
-
function save_custom_meta_box_page_visit($post_id)
|
1456 |
-
{
|
1457 |
global $wp, $wpdb, $post;
|
1458 |
|
1459 |
if (!current_user_can("edit_post", $post_id)) {
|
@@ -1483,12 +1465,20 @@ class page_visit_counter_Admin
|
|
1483 |
$query = "DELETE FROM $table_name WHERE `page_id` = $post_id";
|
1484 |
$wpdb->query($query);
|
1485 |
}
|
1486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1487 |
}
|
1488 |
|
1489 |
-
|
1490 |
-
function check_page_visit_history_table_exisit()
|
1491 |
-
{
|
1492 |
global $wpdb, $wp;
|
1493 |
|
1494 |
$table_name = $wpdb->prefix . "page_visit_history";
|
@@ -1510,11 +1500,9 @@ class page_visit_counter_Admin
|
|
1510 |
dbDelta($sql);
|
1511 |
//add_option( 'contact_db_version', $contact_db_version );
|
1512 |
}
|
1513 |
-
|
1514 |
}
|
1515 |
|
1516 |
-
function get_page_visit_record_report()
|
1517 |
-
{
|
1518 |
global $wpdb;
|
1519 |
|
1520 |
$table_name = $wpdb->prefix . "page_visit_history";
|
@@ -1524,7 +1512,7 @@ class page_visit_counter_Admin
|
|
1524 |
$countQuery_qry = $wpdb->prepare('SELECT COUNT(`page_id`) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageId);
|
1525 |
$result = $wpdb->get_results($countQuery_qry);
|
1526 |
|
1527 |
-
if ((int)$result[0]->total > 0) {
|
1528 |
|
1529 |
$queryTopBrowser = $wpdb->prepare('SELECT COUNT(`page_id`) as total, `browser_full_name` as browser FROM ' . $table_name . ' WHERE page_id=%d GROUP BY `browser_full_name`', $pageId);
|
1530 |
|
@@ -1534,9 +1522,9 @@ class page_visit_counter_Admin
|
|
1534 |
|
1535 |
|
1536 |
$topBrowserStringArr['Browsers'] = 'Total Visits';
|
1537 |
-
if ((int)$result[0]->total > 0) {
|
1538 |
foreach ($topBrowserArr as $topBrowser) {
|
1539 |
-
$topBrowserStringArr[$topBrowser->browser] = (int)$topBrowser->total;
|
1540 |
}
|
1541 |
}
|
1542 |
|
@@ -1548,27 +1536,26 @@ class page_visit_counter_Admin
|
|
1548 |
$topIpStringArr = array();
|
1549 |
|
1550 |
$topIpStringArr["IP Address"] = 'Total Visits';
|
1551 |
-
if ((int)$result[0]->total > 0) {
|
1552 |
foreach ($topIpArr as $topIp) {
|
1553 |
-
$topIpStringArr["$topIp->ipaddress"] = (int)$topIp->total;
|
1554 |
}
|
1555 |
}
|
1556 |
|
1557 |
-
$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
|
1558 |
-
|
1559 |
-
// exit();
|
1560 |
$topRefererArr = $wpdb->get_results($queryTopReferer);
|
1561 |
|
1562 |
$topRefererStringArr = array();
|
1563 |
|
1564 |
$topRefererStringArr["Domain"] = 'Total Visits';
|
1565 |
-
if ((int)$result[0]->total > 0) {
|
1566 |
foreach ($topRefererArr as $topReferer) {
|
1567 |
if (!array_key_exists("$topReferer->domain", $topRefererStringArr)) {
|
1568 |
-
$topRefererStringArr["$topReferer->domain"] = (int)$topReferer->total;
|
1569 |
} else {
|
1570 |
-
$val = (int)$topRefererStringArr["$topReferer->domain"];
|
1571 |
-
$topRefererStringArr["$topReferer->domain"] = $val + (int)$topReferer->total;
|
1572 |
}
|
1573 |
}
|
1574 |
unset($topRefererArr);
|
@@ -1577,15 +1564,14 @@ class page_visit_counter_Admin
|
|
1577 |
$custom_page_visit_history_datatbase_table_name = $wpdb->prefix . "page_visit_history";
|
1578 |
$queryWeeklyReport = "SELECT COUNT(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 yeargroup, WEEK( DATE,1 ) as week FROM $custom_page_visit_history_datatbase_table_name WHERE page_id = $pageId GROUP BY Week_Start_Date,week_end_date,YearAndWeek,yeargroup,week ORDER BY YearAndWeek DESC LIMIT 5";
|
1579 |
|
1580 |
-
//echo $queryWeeklyReport;
|
1581 |
$topWeeklyArr = $wpdb->get_results($queryWeeklyReport);
|
1582 |
|
1583 |
$topWeeklyStringArr = array();
|
1584 |
|
1585 |
$topWeeklyStringArr["Week Year"] = 'Total Visits';
|
1586 |
-
if ((int)$result[0]->total > 0) {
|
1587 |
foreach (array_reverse($topWeeklyArr) as $topWeekly) {
|
1588 |
-
$topWeeklyStringArr["$topWeekly->yeargroup - $topWeekly->week"] = (int)$topWeekly->total;
|
1589 |
}
|
1590 |
unset($topWeeklyArr);
|
1591 |
}
|
@@ -1596,9 +1582,9 @@ class page_visit_counter_Admin
|
|
1596 |
$topMonthlyStringArr = array();
|
1597 |
|
1598 |
$topMonthlyStringArr["Month"] = "Total Visits";
|
1599 |
-
if ((int)$result[0]->total > 0) {
|
1600 |
foreach ($topMonthlyArr as $topMonthly) {
|
1601 |
-
$topMonthlyStringArr["$topMonthly->month"] = (int)$topMonthly->total;
|
1602 |
}
|
1603 |
unset($topMonthlyArr);
|
1604 |
}
|
@@ -1633,48 +1619,43 @@ class page_visit_counter_Admin
|
|
1633 |
die();
|
1634 |
}
|
1635 |
|
1636 |
-
|
1637 |
-
public function custom_admin_pointers_footer()
|
1638 |
-
{
|
1639 |
$admin_pointers = custom_admin_pointers();
|
1640 |
?>
|
1641 |
<script type="text/javascript">
|
1642 |
/* <![CDATA[ */
|
1643 |
(function ($) {
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
?>
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
<?php
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
})(jQuery);
|
1666 |
/* ]]> */
|
1667 |
</script>
|
1668 |
<?php
|
1669 |
}
|
1670 |
|
1671 |
-
|
1672 |
/**
|
1673 |
* Function For display pointer in admin side
|
1674 |
*
|
1675 |
*/
|
1676 |
-
|
1677 |
-
|
1678 |
}
|
1679 |
|
1680 |
/**
|
@@ -1682,16 +1663,14 @@ class page_visit_counter_Admin
|
|
1682 |
* widget provide Most visited page.
|
1683 |
*
|
1684 |
*/
|
1685 |
-
class My_Widget extends WP_Widget
|
1686 |
-
|
1687 |
-
public function __construct()
|
1688 |
-
{
|
1689 |
$widget_ops = array('classname' => 'My_Widget', 'description' => 'Most Visited Pages');
|
1690 |
parent::__construct('My_Widget', 'Recent Most Visit page', $widget_ops);
|
1691 |
}
|
1692 |
|
1693 |
-
function widget($args, $instance)
|
1694 |
-
{
|
1695 |
global $wpdb;
|
1696 |
$table_name = $wpdb->prefix . "page_visit";
|
1697 |
$html = '';
|
@@ -1714,9 +1693,8 @@ class My_Widget extends WP_Widget
|
|
1714 |
echo $html;
|
1715 |
}
|
1716 |
|
1717 |
-
public function form($instance)
|
1718 |
-
|
1719 |
-
$instance = wp_parse_args((array)$instance, array('title' => ''));
|
1720 |
$title = $instance['title'];
|
1721 |
$html = '';
|
1722 |
$html .= '<p> <label for="' . esc_attr($this->get_field_id("title")) . '">Title:
|
@@ -1726,25 +1704,24 @@ class My_Widget extends WP_Widget
|
|
1726 |
echo $html;
|
1727 |
}
|
1728 |
|
1729 |
-
function update($new_instance, $old_instance)
|
1730 |
-
{
|
1731 |
$instance = $old_instance;
|
1732 |
$instance['title'] = $new_instance['title'];
|
1733 |
|
1734 |
return $instance;
|
1735 |
}
|
|
|
1736 |
}
|
1737 |
|
1738 |
-
function pvc_init_widget
|
1739 |
-
{
|
1740 |
return register_widget('My_Widget');
|
1741 |
}
|
1742 |
-
add_action ('widgets_init', 'pvc_init_widget');
|
1743 |
|
1744 |
-
|
1745 |
-
{
|
1746 |
|
1747 |
-
|
|
|
|
|
1748 |
$version = '1_0'; // replace all periods in 1.0 with an underscore
|
1749 |
$prefix = 'custom_admin_pointers' . $version . '_';
|
1750 |
|
@@ -1760,5 +1737,4 @@ function custom_admin_pointers()
|
|
1760 |
'active' => (!in_array($prefix . 'page_visit_counter_notice_view', $dismissed))
|
1761 |
)
|
1762 |
);
|
1763 |
-
|
1764 |
-
}
|
1 |
<?php
|
2 |
// If this file is called directly, abort.
|
3 |
+
if (!defined('ABSPATH')) {
|
4 |
exit;
|
5 |
}
|
6 |
/**
|
23 |
* @subpackage page-visit-counter/admin
|
24 |
* @author Multidots <wordpress@multidots.com>
|
25 |
*/
|
26 |
+
class page_visit_counter_Admin {
|
|
|
27 |
|
28 |
/**
|
29 |
* The ID of this plugin.
|
51 |
* @param string $plugin_name The name of this plugin.
|
52 |
* @param string $version The version of this plugin.
|
53 |
*/
|
54 |
+
public function __construct($plugin_name, $version) {
|
|
|
55 |
|
56 |
$this->plugin_name = $plugin_name;
|
57 |
$this->version = $version;
|
|
|
58 |
}
|
59 |
|
60 |
/**
|
62 |
*
|
63 |
* @since 1.0.0
|
64 |
*/
|
65 |
+
public function enqueue_styles() {
|
|
|
|
|
66 |
|
67 |
/**
|
68 |
* This function is provided for demonstration purposes only.
|
75 |
* between the defined hooks and the functions defined in this
|
76 |
* class.
|
77 |
*/
|
|
|
78 |
//wp_enqueue_style("jquery-ui-tabs");
|
79 |
|
80 |
wp_enqueue_style('custom-style', plugin_dir_url(__FILE__) . 'css/style.css');
|
91 |
*
|
92 |
* @since 1.0.0
|
93 |
*/
|
94 |
+
public function enqueue_scripts() {
|
|
|
95 |
|
96 |
/**
|
97 |
* This function is provided for demonstration purposes only.
|
104 |
* between the defined hooks and the functions defined in this
|
105 |
* class.
|
106 |
*/
|
107 |
+
global $post;
|
108 |
wp_enqueue_script('jquery-ui-core');
|
109 |
wp_enqueue_script('jquery-ui-tabs');
|
110 |
wp_enqueue_script('jquery-ui-datepicker');
|
118 |
}
|
119 |
|
120 |
wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/jquery.dataTables.min.js', array('jquery'), $this->version, false);
|
|
|
121 |
}
|
122 |
+
wp_enqueue_script('save-page-view', plugin_dir_url(__FILE__) . 'js/save_page_view.js', array('jquery'), $this->version, false);
|
123 |
+
wp_enqueue_script('chosen-jquery', plugin_dir_url(__FILE__) . 'js/chosen.jquery.js', array('jquery'), $this->version, false);
|
124 |
+
wp_enqueue_script('chosen-proto', plugin_dir_url(__FILE__) . 'js/chosen.proto.js', array('jquery'), $this->version, false);
|
125 |
+
wp_enqueue_script('color-box', plugin_dir_url(__FILE__) . 'js/jquery.colorbox.js', array('jquery'), $this->version, false);
|
126 |
|
127 |
wp_enqueue_script('iris', admin_url('js/iris.min.js'), array(
|
128 |
'jquery-ui-draggable',
|
129 |
'jquery-ui-slider',
|
130 |
'jquery-touch-punch'
|
131 |
+
), false, 1);
|
132 |
wp_enqueue_script('wp-color-picker', admin_url('js/color-picker.min.js'), array('iris'), false, 1);
|
133 |
|
134 |
$colorpicker_l10n = array(
|
145 |
|
146 |
wp_localize_script('one', 'pagevisit', array('ajaxurl' => admin_url('admin-ajax.php')));
|
147 |
}
|
148 |
+
wp_localize_script( 'save-page-view', 'pagevisit', array(
|
149 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
150 |
+
) );
|
151 |
|
152 |
$fetchSelecetedPostTypes = get_option('wfap_post_type');
|
153 |
if (!empty($fetchSelecetedPostTypes) || $fetchSelecetedPostTypes != "") {
|
167 |
if (!empty($optionsIpAddress) || $optionsIpAddress != "") {
|
168 |
wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => $optionsIpAddress));
|
169 |
} else {
|
170 |
+
wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => ["126"]));
|
171 |
}
|
172 |
+
} else {
|
173 |
+
wp_localize_script('one', 'get_ip_option_arr', array('ipaddressarrayIP' => ["127"]));
|
|
|
174 |
}
|
175 |
|
176 |
$fetchSelecetedUserId = get_option('userlist_visit');
|
184 |
} else {
|
185 |
wp_localize_script('one', 'get_user_option', array('usersarray' => ''));
|
186 |
}
|
|
|
187 |
}
|
188 |
|
189 |
+
public function welcome_page_visit_counter_screen_do_activation_redirect() {
|
|
|
|
|
190 |
// if no activation redirect
|
191 |
if (!get_transient('_welcome_screen_page_visitor_activation_redirect_data')) {
|
192 |
return;
|
203 |
wp_safe_redirect(add_query_arg(array('page' => 'page-visit-counter-about&tab=about'), admin_url('index.php')));
|
204 |
}
|
205 |
|
206 |
+
public function welcome_pages_screen_page_visit_counter() {
|
|
|
207 |
add_dashboard_page(
|
208 |
+
'Page Visit counter Dashboard', 'Page Visit counter Dashboard', 'read', 'page-visit-counter-about', array(
|
209 |
+
&$this,
|
210 |
+
'welcome_screen_content_page_visit_counter'
|
211 |
+
)
|
212 |
);
|
213 |
}
|
214 |
|
215 |
+
public function admin_css() {
|
|
|
216 |
wp_enqueue_style($this->plugin_name . 'welcome-page', plugin_dir_url(__FILE__) . 'css/style.css', array(), $this->version, 'all');
|
217 |
}
|
218 |
|
219 |
+
public function welcome_screen_content_page_visit_counter() {
|
|
|
220 |
?>
|
221 |
<div class="wrap about-wrap">
|
222 |
<h1 style="font-size: 2.1em;"><?php printf(esc_html__('Welcome to Page Visit Counter', 'page-visit-counter')); ?></h1>
|
265 |
* Extra flate rate overview welcome page content function
|
266 |
*
|
267 |
*/
|
268 |
+
public function page_visit_counter_about() {
|
|
|
269 |
//do_action('my_own');
|
270 |
$current_user = wp_get_current_user();
|
271 |
?>
|
290 |
<div class="wc-feature feature-section col three-col">
|
291 |
<div>
|
292 |
<p class="page_visit_overview"><?php esc_html_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>
|
293 |
+
<p class="page_visit_overview"><strong><?php esc_html_e('Page Counter Settings:', 'page-visit-counter'); ?> </strong></p>
|
294 |
<div class="Page_Counter_Settings_Content_ul">
|
295 |
<ul>
|
296 |
+
<li><?php esc_html_e("In these options you can do different setting for page visit counter.", 'page-visit-counter'); ?></li>
|
297 |
<li><?php esc_html_e("Short Code: There are two shortcuts that you can use to manually add page view count
|
298 |
to any content on admin or post/page template created by your theme or plugin that's
|
299 |
+
creating its own display content in a page / post.", 'page-visit-counter'); ?>
|
300 |
</li>
|
301 |
<li><?php esc_html_e("Post Type: You can select the post type from the drop down menu for which post views
|
302 |
will be counted. If you leave blank on post type, then all pages or all past type
|
303 |
+
posts will be counted.", 'page-visit-counter'); ?>
|
304 |
</li>
|
305 |
<li><?php esc_html_e("Exclude IPs (Ip Address): Enter the IP addresses which you want to be excluded from
|
306 |
+
post views count.", 'page-visit-counter'); ?>
|
307 |
</li>
|
308 |
<li><?php esc_html_e("Exclude Users: Select users from your project/system to be excluded from post view
|
309 |
+
count.", 'page-visit-counter'); ?>
|
310 |
</li>
|
311 |
<li><?php esc_html_e("Show front view counter: Check the box if you want to display counter view on front
|
312 |
+
end.", 'page-visit-counter'); ?>
|
313 |
</li>
|
314 |
<li><?php esc_html_e("Choose color for the front end view: select color from color picker to choose the
|
315 |
+
color for display visit pages text on front side as well as in the shortcode.", 'page-visit-counter'); ?>
|
316 |
</li>
|
317 |
</ul>
|
318 |
</div>
|
319 |
|
320 |
+
<p class="page_visit_overview"><strong><?php esc_html_e("Page Counter Settings:", 'page-visit-counter'); ?> </strong></p>
|
321 |
|
322 |
<p class="page_visit_overview"><?php _e("In this option you can see all pages listing within Page ID, Page
|
323 |
Title and Total Count. It will display all pages of your site. If you excluded particular
|
324 |
post type from page visit counter then also it will display that post type, posts pages on
|
325 |
table but it will not count those pages and 'total count' will be '0' for excluded post
|
326 |
+
type, post pages.</p>", 'page-visit-counter'); ?>
|
327 |
|
328 |
<div class="Page_Counter_Settings_Content_ul">
|
329 |
<ul>
|
330 |
<li><?php esc_html_e('Search facility: This provides you the extra facility to search pages by title and
|
331 |
+
search page by its crated date.', 'page-visit-counter'); ?>
|
332 |
</li>
|
333 |
<li><?php esc_html_e('Sharing facility: This provides you to share specific page on Facebook, Twitter and
|
334 |
+
Google Plus.', 'page-visit-counter'); ?>
|
335 |
</li>
|
336 |
<li><?php esc_html_e('Reports: This provides you the specific page vise reports like Top browsers, Top 10
|
337 |
+
IP address, Top referer, weekly report and Monthly report using chart.', 'page-visit-counter'); ?>
|
338 |
</li>
|
339 |
</ul>
|
340 |
</div>
|
352 |
* Remove the Extra flate rate menu in dashboard
|
353 |
*
|
354 |
*/
|
355 |
+
public function welcome_screen_remove_menus() {
|
|
|
356 |
remove_submenu_page('index.php', 'page-visit-counter-about');
|
357 |
}
|
358 |
|
361 |
* add menu in admin menubar.
|
362 |
*
|
363 |
*/
|
364 |
+
public function page_visit_counter_menu() {
|
|
|
365 |
add_menu_page(esc_html__('Page-Visit-Counter', 'page-visit-counter'), esc_html__('PageVisitCounter', 'page-visit-counter'), 'manage_options', 'page_visit_counter', 'extra_page_visit_function_custom', plugins_url('page-visit-counter/admin/images/icon.png'));
|
366 |
add_submenu_page('page_visit_counter', esc_html__('Counter-Settings', 'page-visit-counter'), esc_html__('Settings', 'page-visit-counter'), 'manage_options', 'page_visit_settings', 'custom_page_visit_settings');
|
367 |
+
|
368 |
/**
|
369 |
* extra_page_visit_function_custom use the menu callback function
|
370 |
* $name pass the arguments
|
371 |
*/
|
372 |
+
function extra_page_visit_function_custom($name) {
|
|
|
373 |
global $wpdb;
|
374 |
|
375 |
if (!class_exists('WP_List_Table')) {
|
392 |
<h1><?php echo esc_html__('Page Visit Counter', 'page-visit-counter'); ?></h1>
|
393 |
</div>
|
394 |
|
395 |
+
<?php if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { ?>
|
|
|
396 |
<style type="text/css">
|
397 |
.tabs div#chartContainer-main {
|
398 |
float: left;
|
419 |
width: 50%;
|
420 |
}
|
421 |
</style>
|
422 |
+
<div class="back"><h5><a class="button button-primary" href="<?php echo esc_url(home_url('/wp-admin/admin.php?page=page_visit_counter')); ?>">←<?php echo esc_html_e('Back to list', 'page-visit-counter'); ?></a></h5></div>
|
423 |
<div style="">
|
424 |
<div id="page-vist-fancybox" class="page-counter-fancybox">
|
425 |
<div id="tabs">
|
703 |
//jQuery( "#tabs" ).tabs();
|
704 |
|
705 |
|
706 |
+
// setTimeout(function(){
|
707 |
+
// jQuery('body #ui-id-1').trigger('click');
|
708 |
+
// },500);
|
709 |
|
710 |
jQuery("#chartContainer").html('No Visitor Found.');
|
711 |
jQuery("#chartContainer1").html('No Visitor Found.');
|
732 |
|
733 |
|
734 |
</script>
|
735 |
+
<?php } else {
|
736 |
+
?>
|
737 |
<form id="movies-filter" method="post">
|
738 |
<?php
|
739 |
+
$test_list_table->search_box('Search', '');
|
740 |
foreach ($_POST as $key => $value) {
|
741 |
+
if ('s' !== $key) { // don't include the search query
|
|
|
742 |
// echo("<input type='hidden' name='".esc_attr($key)."' value='".esc_attr($value)."' />");
|
743 |
echo("<input type='hidden' name='$key' value='$value' />");
|
744 |
}
|
750 |
<!-- Twitter -->
|
751 |
<script>!function (d, s, id) {
|
752 |
var js, fjs = d.getElementsByTagName(s)[0],
|
753 |
+
p = /^http:/.test(d.location) ? 'http' : 'https';
|
754 |
if (!d.getElementById(id)) {
|
755 |
js = d.createElement(s);
|
756 |
js.id = id;
|
762 |
<!-- Facebook -->
|
763 |
<script>(function (d, s, id) {
|
764 |
var js, fjs = d.getElementsByTagName(s)[0];
|
765 |
+
if (d.getElementById(id))
|
766 |
+
return;
|
767 |
js = d.createElement(s);
|
768 |
js.id = id;
|
769 |
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
|
782 |
})();
|
783 |
</script>
|
784 |
|
785 |
+
<?php }
|
786 |
+
?>
|
787 |
|
788 |
</div>
|
789 |
|
794 |
* function use to page settings
|
795 |
* $args is pass the arguments
|
796 |
*/
|
797 |
+
function custom_page_visit_settings($args) {
|
|
|
798 |
|
799 |
global $wpdb;
|
800 |
$current_user = wp_get_current_user();
|
814 |
?>
|
815 |
<div class="main-page-visit-settings">
|
816 |
<div class="page-title-settings">
|
817 |
+
<form id="pvc_plugin_form_id" method="post" action="<?php echo esc_url(get_admin_url() . 'admin-post.php'); ?>" enctype="multipart/form-data" novalidate="novalidate">
|
818 |
<?php wp_nonce_field(basename(__FILE__), 'pvc_setting'); ?>
|
819 |
<input type="hidden" name="action" value="submit_form_pvc"/>
|
820 |
<input id="action_which" type="hidden" name="action-which" value="add"/>
|
848 |
<b> <?php echo "<?php echo do_shortcode('[page_visit_counter_md id='page_id/post_id']');?>" ?></b>
|
849 |
</p>
|
850 |
<p><?php echo esc_html__('Use this shortcode to display total sites visit to add page/post template (.php) file of your own template:', 'page-visit-counter'); ?>
|
851 |
+
<br><b> <?php echo "<?php echo do_shortcode('[page_visit_counter_md_total_sites_visit backgroundcolor='#ff0000' countboxcolor='#000000' fontcolor='#FFFFFF' bordercolor='#ff0000']');?>" ?></b></p>
|
|
|
|
|
852 |
</fieldset>
|
853 |
</div>
|
854 |
|
862 |
?>
|
863 |
<table border="0" cellpadding="10" cellspacing="0">
|
864 |
<tbody>
|
865 |
+
<tr>
|
866 |
+
<th scope="row"><label for="blogname"><?php echo esc_html__('Post Type', 'page-visit-counter'); ?></label>
|
867 |
+
</th>
|
868 |
+
<td>
|
869 |
+
<select id="post_type" data-placeholder=" <?php echo esc_html__('Add Page/Post Type', 'page-visit-counter'); ?>" name="post_ty[]" multiple="true" class="chosen-select-post category-select chosen-rtl validate_field1">
|
870 |
+
<option value=""></option>
|
871 |
+
<?php
|
872 |
+
if (isset($post_types) && !empty($post_types)) {
|
873 |
+
foreach ($post_types as $cpost) {
|
874 |
+
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") {
|
875 |
+
?>
|
876 |
+
<option value="<?php echo $cpost; ?>"><?php echo $cpost; ?></option><?php
|
877 |
+
}
|
878 |
}
|
879 |
}
|
880 |
+
?>
|
881 |
+
</select>
|
882 |
+
<p><?php echo esc_html__('(Select post types for which post views will be counted.)', 'page-visit-counter'); ?></p>
|
883 |
+
</td>
|
884 |
+
</tr>
|
885 |
+
|
886 |
+
<tr class="ipaddress">
|
887 |
+
<th scope="row"><label for="blogname"><?php echo esc_html__('Exclude IPs (Ip Address)', 'page-visit-counter'); ?></label>
|
888 |
+
</th>
|
889 |
+
<td>
|
890 |
+
<select id="ip_address" data-placeholder=" <?php echo esc_html__('Add IP Address in comma seprated', 'page-visit-counter'); ?>" name="ip-basic[]" multiple="true" class="chosen-select-ip category-select chosen-rtl validate_field1">
|
891 |
+
<option value=""></option><?php
|
892 |
+
$get_option_value_ip = json_decode(get_option('ipaddress_visit'));
|
893 |
+
if (isset($get_option_value_ip) && !empty($get_option_value_ip)) {
|
894 |
+
foreach ($get_option_value_ip as $ip) {
|
895 |
+
?>
|
896 |
+
<option value="<?php echo $ip; ?>"><?php echo $ip; ?></option><?php
|
897 |
+
}
|
898 |
}
|
899 |
+
?>
|
900 |
+
</select>
|
901 |
+
<p><?php echo esc_html__('(Enter the IP addresses to be excluded from post views count.)', 'page-visit-counter'); ?></p>
|
902 |
+
</td>
|
903 |
+
</tr>
|
904 |
+
|
905 |
+
<tr class="users">
|
906 |
+
<th scope="row"><label for="blogname"><?php echo esc_html__('Exclude Users', 'page-visit-counter'); ?></label>
|
907 |
+
</th>
|
908 |
+
<td>
|
909 |
+
<select id="users_list" data-placeholder="<?php echo esc_html__('Select Registerd Users', 'page-visit-counter'); ?>" name="user-basic[]" multiple="true" class="chosen-select category-select chosen-rtl validate_field1">
|
910 |
+
<option value=""></option><?php
|
911 |
+
$query = "SELECT * FROM $wpdb->users";
|
912 |
+
$resultSetsArr = $wpdb->get_results($query);
|
913 |
+
if (isset($resultSetsArr) && !empty($resultSetsArr)) {
|
914 |
+
foreach ($resultSetsArr as $value) {
|
915 |
+
?>
|
916 |
+
<option value="<?php echo esc_attr($value->ID); ?>"><?php echo $value->user_email; ?></option>
|
917 |
+
<?php
|
918 |
+
}
|
919 |
}
|
920 |
+
?>
|
921 |
+
</select>
|
922 |
+
<p><?php echo esc_html__('(Select the users to be excluded from post views count.)', 'page-visit-counter'); ?></p>
|
923 |
+
</td>
|
924 |
+
</tr>
|
925 |
+
|
926 |
+
<tr class="hidefront">
|
927 |
+
<th scope="row"><label for="blogname"><?php echo esc_html__('Show front view counter', 'page-visit-counter'); ?></label>
|
928 |
+
</th>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
929 |
<?php
|
930 |
+
$hide_show_option = get_option('counter_hide_show_front_vew');
|
931 |
+
if ($hide_show_option == 'on') {
|
932 |
+
$cheked = 'checked';
|
933 |
+
} else {
|
934 |
+
$cheked = '';
|
935 |
}
|
936 |
?>
|
937 |
+
<td class="information">
|
938 |
+
<input type="checkbox" name="hidefrontview" id="hide_front_view" <?php echo esc_attr($cheked); ?>><?php echo esc_html__('Check the box if you want to display counter view on front end.', 'page-visit-counter'); ?>
|
939 |
+
</td>
|
940 |
+
</tr>
|
941 |
+
|
942 |
+
<tr class="hidefront" style="display:none;">
|
943 |
+
<th scope="row"><label for="blogname"><?php echo esc_html__('Last How many days count you want to display on front end.', 'page-visit-counter'); ?></label>
|
944 |
+
</th>
|
945 |
+
<td class="information">
|
946 |
+
<?php
|
947 |
+
$get_no_of_days = get_option('no_of_days_to_display');
|
948 |
+
if ($get_no_of_days == '') {
|
949 |
+
$get_no_of_days = '';
|
950 |
+
}
|
951 |
+
?>
|
952 |
+
<input type="text" name="no_of_days_to_display" id="no_of_days_to_display" value="<?php echo esc_attr($get_no_of_days); ?>">
|
953 |
+
</td>
|
954 |
+
</tr>
|
955 |
+
|
956 |
+
<tr class="">
|
957 |
+
<th scope="row"><label for="blogname"><?php echo esc_html__('Choose color for the front end view', 'page-visit-counter'); ?></label>
|
958 |
+
</th>
|
959 |
+
<td class="information">
|
960 |
+
<input id="text_color_page_visit" type="text" name="textcolor" value="<?php echo esc_attr($text_color_page_visit); ?>" class="my-color-field" data-default-color="<?php echo esc_attr($text_color_page_visit); ?>"/>
|
961 |
+
</td>
|
962 |
+
</tr>
|
963 |
</tbody>
|
964 |
</table>
|
965 |
</fieldset>
|
974 |
</div>
|
975 |
<?php
|
976 |
}
|
977 |
+
|
978 |
}
|
979 |
|
980 |
/**
|
982 |
* view most visited page in dashboard.
|
983 |
*
|
984 |
*/
|
985 |
+
function my_custom_dashboard_widgets() {
|
|
|
986 |
global $wp_meta_boxes;
|
987 |
wp_add_dashboard_widget('custom_help_widget', esc_html__('Most Visited Page', 'page-visit-counter'), 'custom_dashboard_help');
|
988 |
+
|
989 |
+
function custom_dashboard_help() {
|
990 |
global $wpdb;
|
991 |
$table_name = $wpdb->prefix . "page_visit";
|
992 |
$html = '';
|
1007 |
$html .= '<tr>';
|
1008 |
$html .= '<td>' . esc_attr($page->ID) . '</td>';
|
1009 |
$edit_url = get_admin_url() . 'post.php?post=' . esc_attr($page->ID) . '&action=edit';
|
1010 |
+
$html .= '<td><a href="' . esc_url($edit_url) . '">' . esc_html($page->post_title) . '</a></td>';
|
1011 |
$html .= '<td>' . esc_attr($visitpage->c) . '</td>';
|
1012 |
$html .= '</tr>';
|
1013 |
}
|
1018 |
$html .= '</div>';
|
1019 |
echo $html;
|
1020 |
}
|
1021 |
+
|
1022 |
}
|
1023 |
|
1024 |
/**
|
1026 |
* add option by option table
|
1027 |
* add page count option and duration.
|
1028 |
*/
|
1029 |
+
public function add_page_count_option() {
|
|
|
1030 |
global $wpdb;
|
1031 |
|
1032 |
$page_count_option = array();
|
1124 |
* select_input_page_value use in ajax callback function
|
1125 |
* handle the date and page title on change event.
|
1126 |
*/
|
1127 |
+
public function select_input_page_value() {
|
|
|
1128 |
global $wpdb;
|
1129 |
$table_name = $wpdb->prefix . "page_visit";
|
1130 |
$table_post = $wpdb->prefix . "posts";
|
1322 |
<a target="_blank" style="margin-right: 5px;" href="https://www.facebook.com/sharer/sharer.php?u=' . esc_url(get_permalink($results->ID)) . '"><img src="' . esc_url(plugins_url('images/Facebook.png', dirname(__FILE__))) . '" /></a>
|
1323 |
<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="' . esc_url(plugins_url('images/twitter.png', dirname(__FILE__))) . '" /></a>
|
1324 |
<a target="_blank" href="https://plus.google.com/share?url=' . esc_url(get_permalink($results->ID)) . '"><img src="' . esc_url(plugins_url('images/Google_Plus.png', dirname(__FILE__))) . '" /></a></td>';
|
1325 |
+
$html .= '<td><a href="' . esc_url(home_url('/wp-admin/admin.php?page=page_visit_counter&id=' . $results->ID)) . '" title="' . wp_kses_post($results->post_title) . '" class="" id="' . esc_attr($results->ID) . '">' . esc_html__('View Report', 'page-visit-counter') . '</a></td>';
|
1326 |
|
1327 |
$html .= '</tr>';
|
1328 |
}
|
1341 |
die();
|
1342 |
}
|
1343 |
|
1344 |
+
public function add_custom_meta_box_page_visit() {
|
|
|
1345 |
global $wpdb;
|
1346 |
|
1347 |
$fetchSelecetedPostTypes = json_decode(get_option('wfap_post_type'));
|
1363 |
}
|
1364 |
}
|
1365 |
|
1366 |
+
function add_new_selected_post_columns($columns) {
|
1367 |
+
return array_merge($columns, array('page_visit_count' => esc_html__('Total Visits', 'page-visit-counter')));
|
|
|
|
|
|
|
|
|
|
|
1368 |
}
|
1369 |
|
1370 |
+
function custom_columns_add_page_visit_count($column, $post_id) {
|
|
|
1371 |
global $wpdb, $wp;
|
1372 |
if ($column == 'page_visit_count') {
|
1373 |
$table_name = $wpdb->prefix . "page_visit";
|
1374 |
$get_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $post_id);
|
1375 |
$pageCount = $wpdb->get_results($get_qry);
|
1376 |
+
$total = (int) $pageCount[0]->total;
|
1377 |
echo $total;
|
1378 |
}
|
1379 |
}
|
1380 |
|
1381 |
+
function custom_meta_box_markup_page_visit($object) {
|
|
|
1382 |
global $wp, $wpdb;
|
1383 |
|
1384 |
$post_id = get_the_ID();
|
1390 |
$get_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $post_id);
|
1391 |
$pageCount = $wpdb->get_results($get_qry);
|
1392 |
|
1393 |
+
$total = (int) $pageCount[0]->total;
|
1394 |
?>
|
1395 |
<input name="pageidvisit" type="hidden" value="<?php echo $post_id; ?>">
|
1396 |
<p><?php echo esc_html__('Do you want to enable page visits count for this page?', 'page-visit-counter'); ?></p>
|
1400 |
value="yes"><?php echo esc_html__('Yes', 'page-visit-counter'); ?>
|
1401 |
<input type="radio" name="autoupdate_page_visit" id="autoupdate_page2"
|
1402 |
value="no"><?php echo esc_html__('No', 'page-visit-counter'); ?>
|
1403 |
+
<?php } else { ?>
|
1404 |
<input type="radio" <?php if ($enable_page_count == 'yes') { ?> checked="checked" <?php } ?>
|
1405 |
name="autoupdate_page_visit" id="autoupdate_page1" value="yes"> <?php echo esc_html__('Yes', 'page-visit-counter'); ?>
|
1406 |
<input type="radio" <?php if ($enable_page_count == 'no') { ?> checked="checked" <?php } ?>
|
1407 |
+
name="autoupdate_page_visit" id="autoupdate_page2" value="no"> <?php echo esc_html__('No', 'page-visit-counter'); ?><?php }
|
1408 |
+
?>
|
1409 |
</p>
|
1410 |
<p><?php echo esc_html__('Do you want to display today page visits count for this page?', 'page-visit-counter'); ?></p>
|
1411 |
<p>
|
1416 |
<input type="radio" <?php if ($enable_page_count_day_wise == 'yes') { ?> checked="checked" <?php } ?>
|
1417 |
name="autoupdate_page_visit_day_wise" id="autoupdate_page1_day_wise" value="yes"> <?php echo esc_html__('Yes', 'page-visit-counter'); ?>
|
1418 |
<input type="radio" <?php if ($enable_page_count_day_wise == 'no') { ?> checked="checked" <?php } ?>
|
1419 |
+
name="autoupdate_page_visit_day_wise" id="autoupdate_page2_day_wise" value="no"><?php echo esc_html__('No', 'page-visit-counter'); ?><?php }
|
1420 |
+
?>
|
1421 |
</p>
|
1422 |
<p><?php echo esc_html__('Do you want to reset all visits count for this page?', 'page-visit-counter'); ?></p>
|
1423 |
<p>
|
1426 |
<input type="radio" checked="checked" name="page_visit_reset" id="page_visit_reset_yes"
|
1427 |
value="no"><?php echo esc_html__('No', 'page-visit-counter'); ?>
|
1428 |
</p>
|
1429 |
+
<p id="total_page_visits_after_update">
|
1430 |
+
<?php echo esc_html__('Total visits:', 'page-visit-counter'); ?>
|
1431 |
+
<span><?php echo esc_attr($total); ?></span>
|
1432 |
+
</p>
|
1433 |
<?php
|
1434 |
}
|
|
|
1435 |
|
1436 |
+
}
|
1437 |
|
1438 |
+
function save_custom_meta_box_page_visit($post_id) {
|
|
|
1439 |
global $wp, $wpdb, $post;
|
1440 |
|
1441 |
if (!current_user_can("edit_post", $post_id)) {
|
1465 |
$query = "DELETE FROM $table_name WHERE `page_id` = $post_id";
|
1466 |
$wpdb->query($query);
|
1467 |
}
|
1468 |
+
}
|
1469 |
+
|
1470 |
+
public function get_visit_page_result_after_update_admin() {
|
1471 |
+
global $wpdb, $post;
|
1472 |
+
$table_name = $wpdb->prefix . "page_visit";
|
1473 |
+
$page_id = !empty(sanitize_text_field(wp_unslash($_POST['page_id']))) ? sanitize_text_field(wp_unslash($_POST['page_id'])) : '';
|
1474 |
+
$get_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $page_id);
|
1475 |
+
$pageCount = $wpdb->get_row($get_qry);
|
1476 |
+
$total = (int) $pageCount->total;
|
1477 |
+
echo $total;
|
1478 |
+
wp_die();
|
1479 |
}
|
1480 |
|
1481 |
+
function check_page_visit_history_table_exisit() {
|
|
|
|
|
1482 |
global $wpdb, $wp;
|
1483 |
|
1484 |
$table_name = $wpdb->prefix . "page_visit_history";
|
1500 |
dbDelta($sql);
|
1501 |
//add_option( 'contact_db_version', $contact_db_version );
|
1502 |
}
|
|
|
1503 |
}
|
1504 |
|
1505 |
+
function get_page_visit_record_report() {
|
|
|
1506 |
global $wpdb;
|
1507 |
|
1508 |
$table_name = $wpdb->prefix . "page_visit_history";
|
1512 |
$countQuery_qry = $wpdb->prepare('SELECT COUNT(`page_id`) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageId);
|
1513 |
$result = $wpdb->get_results($countQuery_qry);
|
1514 |
|
1515 |
+
if ((int) $result[0]->total > 0) {
|
1516 |
|
1517 |
$queryTopBrowser = $wpdb->prepare('SELECT COUNT(`page_id`) as total, `browser_full_name` as browser FROM ' . $table_name . ' WHERE page_id=%d GROUP BY `browser_full_name`', $pageId);
|
1518 |
|
1522 |
|
1523 |
|
1524 |
$topBrowserStringArr['Browsers'] = 'Total Visits';
|
1525 |
+
if ((int) $result[0]->total > 0) {
|
1526 |
foreach ($topBrowserArr as $topBrowser) {
|
1527 |
+
$topBrowserStringArr[$topBrowser->browser] = (int) $topBrowser->total;
|
1528 |
}
|
1529 |
}
|
1530 |
|
1536 |
$topIpStringArr = array();
|
1537 |
|
1538 |
$topIpStringArr["IP Address"] = 'Total Visits';
|
1539 |
+
if ((int) $result[0]->total > 0) {
|
1540 |
foreach ($topIpArr as $topIp) {
|
1541 |
+
$topIpStringArr["$topIp->ipaddress"] = (int) $topIp->total;
|
1542 |
}
|
1543 |
}
|
1544 |
|
1545 |
+
$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";
|
1546 |
+
|
|
|
1547 |
$topRefererArr = $wpdb->get_results($queryTopReferer);
|
1548 |
|
1549 |
$topRefererStringArr = array();
|
1550 |
|
1551 |
$topRefererStringArr["Domain"] = 'Total Visits';
|
1552 |
+
if ((int) $result[0]->total > 0) {
|
1553 |
foreach ($topRefererArr as $topReferer) {
|
1554 |
if (!array_key_exists("$topReferer->domain", $topRefererStringArr)) {
|
1555 |
+
$topRefererStringArr["$topReferer->domain"] = (int) $topReferer->total;
|
1556 |
} else {
|
1557 |
+
$val = (int) $topRefererStringArr["$topReferer->domain"];
|
1558 |
+
$topRefererStringArr["$topReferer->domain"] = $val + (int) $topReferer->total;
|
1559 |
}
|
1560 |
}
|
1561 |
unset($topRefererArr);
|
1564 |
$custom_page_visit_history_datatbase_table_name = $wpdb->prefix . "page_visit_history";
|
1565 |
$queryWeeklyReport = "SELECT COUNT(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 yeargroup, WEEK( DATE,1 ) as week FROM $custom_page_visit_history_datatbase_table_name WHERE page_id = $pageId GROUP BY Week_Start_Date,week_end_date,YearAndWeek,yeargroup,week ORDER BY YearAndWeek DESC LIMIT 5";
|
1566 |
|
|
|
1567 |
$topWeeklyArr = $wpdb->get_results($queryWeeklyReport);
|
1568 |
|
1569 |
$topWeeklyStringArr = array();
|
1570 |
|
1571 |
$topWeeklyStringArr["Week Year"] = 'Total Visits';
|
1572 |
+
if ((int) $result[0]->total > 0) {
|
1573 |
foreach (array_reverse($topWeeklyArr) as $topWeekly) {
|
1574 |
+
$topWeeklyStringArr["$topWeekly->yeargroup - $topWeekly->week"] = (int) $topWeekly->total;
|
1575 |
}
|
1576 |
unset($topWeeklyArr);
|
1577 |
}
|
1582 |
$topMonthlyStringArr = array();
|
1583 |
|
1584 |
$topMonthlyStringArr["Month"] = "Total Visits";
|
1585 |
+
if ((int) $result[0]->total > 0) {
|
1586 |
foreach ($topMonthlyArr as $topMonthly) {
|
1587 |
+
$topMonthlyStringArr["$topMonthly->month"] = (int) $topMonthly->total;
|
1588 |
}
|
1589 |
unset($topMonthlyArr);
|
1590 |
}
|
1619 |
die();
|
1620 |
}
|
1621 |
|
1622 |
+
public function custom_admin_pointers_footer() {
|
|
|
|
|
1623 |
$admin_pointers = custom_admin_pointers();
|
1624 |
?>
|
1625 |
<script type="text/javascript">
|
1626 |
/* <![CDATA[ */
|
1627 |
(function ($) {
|
1628 |
+
<?php
|
1629 |
+
foreach ($admin_pointers as $pointer => $array) {
|
1630 |
+
if ($array['active']) {
|
1631 |
?>
|
1632 |
+
$('<?php echo $array['anchor_id']; ?>').pointer({
|
1633 |
+
content: '<?php echo $array['content']; ?>',
|
1634 |
+
position: {
|
1635 |
+
edge: '<?php echo $array['edge']; ?>',
|
1636 |
+
align: '<?php echo $array['align']; ?>'
|
1637 |
+
},
|
1638 |
+
close: function () {
|
1639 |
+
$.post(ajaxurl, {
|
1640 |
+
pointer: '<?php echo $pointer; ?>',
|
1641 |
+
action: 'dismiss-wp-pointer'
|
1642 |
+
});
|
1643 |
+
}
|
1644 |
+
}).pointer('open');
|
1645 |
<?php
|
1646 |
+
}
|
1647 |
+
}
|
1648 |
+
?>
|
1649 |
})(jQuery);
|
1650 |
/* ]]> */
|
1651 |
</script>
|
1652 |
<?php
|
1653 |
}
|
1654 |
|
|
|
1655 |
/**
|
1656 |
* Function For display pointer in admin side
|
1657 |
*
|
1658 |
*/
|
|
|
|
|
1659 |
}
|
1660 |
|
1661 |
/**
|
1663 |
* widget provide Most visited page.
|
1664 |
*
|
1665 |
*/
|
1666 |
+
class My_Widget extends WP_Widget {
|
1667 |
+
|
1668 |
+
public function __construct() {
|
|
|
1669 |
$widget_ops = array('classname' => 'My_Widget', 'description' => 'Most Visited Pages');
|
1670 |
parent::__construct('My_Widget', 'Recent Most Visit page', $widget_ops);
|
1671 |
}
|
1672 |
|
1673 |
+
function widget($args, $instance) {
|
|
|
1674 |
global $wpdb;
|
1675 |
$table_name = $wpdb->prefix . "page_visit";
|
1676 |
$html = '';
|
1693 |
echo $html;
|
1694 |
}
|
1695 |
|
1696 |
+
public function form($instance) {
|
1697 |
+
$instance = wp_parse_args((array) $instance, array('title' => ''));
|
|
|
1698 |
$title = $instance['title'];
|
1699 |
$html = '';
|
1700 |
$html .= '<p> <label for="' . esc_attr($this->get_field_id("title")) . '">Title:
|
1704 |
echo $html;
|
1705 |
}
|
1706 |
|
1707 |
+
function update($new_instance, $old_instance) {
|
|
|
1708 |
$instance = $old_instance;
|
1709 |
$instance['title'] = $new_instance['title'];
|
1710 |
|
1711 |
return $instance;
|
1712 |
}
|
1713 |
+
|
1714 |
}
|
1715 |
|
1716 |
+
function pvc_init_widget() {
|
|
|
1717 |
return register_widget('My_Widget');
|
1718 |
}
|
|
|
1719 |
|
1720 |
+
add_action('widgets_init', 'pvc_init_widget');
|
|
|
1721 |
|
1722 |
+
function custom_admin_pointers() {
|
1723 |
+
|
1724 |
+
$dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
|
1725 |
$version = '1_0'; // replace all periods in 1.0 with an underscore
|
1726 |
$prefix = 'custom_admin_pointers' . $version . '_';
|
1727 |
|
1737 |
'active' => (!in_array($prefix . 'page_visit_counter_notice_view', $dismissed))
|
1738 |
)
|
1739 |
);
|
1740 |
+
}
|
|
admin/css/style.css
CHANGED
@@ -129,6 +129,7 @@ p.welocme-page-content {
|
|
129 |
position: absolute;
|
130 |
right: 0;
|
131 |
top: 0;
|
|
|
132 |
}
|
133 |
.txt_location_own {
|
134 |
line-height: 1.4em;
|
129 |
position: absolute;
|
130 |
right: 0;
|
131 |
top: 0;
|
132 |
+
width: auto !important;
|
133 |
}
|
134 |
.txt_location_own {
|
135 |
line-height: 1.4em;
|
admin/js/save_page_view.js
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function ($) {
|
2 |
+
$(window).load(function () {
|
3 |
+
if ($('.edit-post-header .components-button').length) {
|
4 |
+
$('body').on('click', ".edit-post-header .components-button", function () {
|
5 |
+
var post_ID = jQuery('#post_ID').val();
|
6 |
+
$.ajax({
|
7 |
+
type: 'POST',
|
8 |
+
url: pagevisit.ajaxurl,
|
9 |
+
data: {
|
10 |
+
action: 'get_visit_page_result_after_update_admin',
|
11 |
+
page_id: post_ID
|
12 |
+
},
|
13 |
+
success: function (response) {
|
14 |
+
$('#total_page_visits_after_update span').html(response);
|
15 |
+
}
|
16 |
+
});
|
17 |
+
});
|
18 |
+
}
|
19 |
+
});
|
20 |
+
})(jQuery);
|
includes/class-page-visit-counter.php
CHANGED
@@ -152,40 +152,43 @@ class page_visit_counter {
|
|
152 |
|
153 |
$this->loader->add_action( 'save_post', $plugin_admin, 'save_custom_meta_box_page_visit' );
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
$this->loader->add_action( 'admin_post_nopriv_submit_form_pvc',$plugin_admin, 'add_page_count_option');
|
165 |
|
166 |
$this->loader->add_action( 'plugins_loaded', $plugin_admin, 'check_page_visit_history_table_exisit' );
|
167 |
|
168 |
add_action( 'wp_loaded', function ()
|
169 |
{
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
});
|
|
|
|
|
|
|
189 |
|
190 |
}
|
191 |
|
152 |
|
153 |
$this->loader->add_action( 'save_post', $plugin_admin, 'save_custom_meta_box_page_visit' );
|
154 |
|
155 |
+
$this->loader->add_action('admin_init', $plugin_admin, 'welcome_page_visit_counter_screen_do_activation_redirect');
|
156 |
+
//admin menu intilization hooks
|
157 |
+
$this->loader->add_action('admin_menu', $plugin_admin, 'welcome_pages_screen_page_visit_counter');
|
158 |
+
|
159 |
+
$this->loader->add_action('page_visit_counter_about', $plugin_admin, 'page_visit_counter_about');
|
160 |
+
|
161 |
+
$this->loader->add_action('admin_print_footer_scripts', $plugin_admin, 'custom_admin_pointers_footer');
|
162 |
+
|
163 |
+
$this->loader->add_action( 'admin_post_submit_form_pvc',$plugin_admin, 'add_page_count_option');
|
164 |
$this->loader->add_action( 'admin_post_nopriv_submit_form_pvc',$plugin_admin, 'add_page_count_option');
|
165 |
|
166 |
$this->loader->add_action( 'plugins_loaded', $plugin_admin, 'check_page_visit_history_table_exisit' );
|
167 |
|
168 |
add_action( 'wp_loaded', function ()
|
169 |
{
|
170 |
+
$fetchSelecetedPostTypes = json_decode(get_option('wfap_post_type'));
|
171 |
+
if (isset($fetchSelecetedPostTypes) && !empty($fetchSelecetedPostTypes)) {
|
172 |
+
foreach ($fetchSelecetedPostTypes as $postsingle) {
|
173 |
+
add_filter("manage_edit-".$postsingle."_columns", "add_new_selected_post_columns");
|
174 |
+
add_action("manage_".$postsingle."_posts_custom_column" , "custom_columns_add_page_visit_count",10,2);
|
175 |
+
}
|
176 |
+
} else {
|
177 |
+
// Get all the registered post type
|
178 |
+
global $wp_post_types;
|
179 |
+
$post_types = get_post_types();
|
180 |
+
|
181 |
+
foreach ($post_types as $cpost) {
|
182 |
+
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") {
|
183 |
+
add_filter("manage_edit-".$cpost."_columns", "add_new_selected_post_columns");
|
184 |
+
add_action("manage_".$cpost."_posts_custom_column" , "custom_columns_add_page_visit_count",2,2);
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
});
|
189 |
+
|
190 |
+
$this->loader->add_action( 'wp_ajax_get_visit_page_result_after_update_admin', $plugin_admin, 'get_visit_page_result_after_update_admin' );
|
191 |
+
$this->loader->add_action( 'wp_ajax_nopriv_get_visit_page_result_after_update_admin', $plugin_admin, 'get_visit_page_result_after_update_admin' );
|
192 |
|
193 |
}
|
194 |
|
page_visit_counter.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
<?php
|
|
|
2 |
/*
|
3 |
* @link http://www.multidots.com/
|
4 |
* @since 1.1
|
@@ -7,20 +8,34 @@
|
|
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.
|
11 |
* Author URI: http://www.multidots.com/
|
12 |
-
*/
|
13 |
// If this file is called directly, abort.
|
14 |
-
if (
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
|
|
17 |
/**
|
18 |
* The code that runs during plugin activation.
|
19 |
* This action is documented in includes/class-page-visit-counter-activator.php
|
20 |
*/
|
21 |
function activate_page_visit_counter() {
|
22 |
-
|
23 |
-
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -28,20 +43,21 @@ function activate_page_visit_counter() {
|
|
28 |
* This action is documented in includes/class-page-visit-counter-deactivator.php
|
29 |
*/
|
30 |
function deactivate_page_visit_counter() {
|
31 |
-
|
32 |
-
|
33 |
}
|
|
|
34 |
/**
|
35 |
* register hook for plugins activate and deactivate.
|
36 |
*/
|
37 |
-
register_activation_hook(
|
38 |
-
register_deactivation_hook(
|
39 |
|
40 |
/**
|
41 |
* The core plugin class that is used to define internationalization,
|
42 |
* admin-specific hooks, and public-facing site hooks.
|
43 |
*/
|
44 |
-
require plugin_dir_path(
|
45 |
|
46 |
/**
|
47 |
* Begins execution of the plugin.
|
@@ -54,130 +70,128 @@ require plugin_dir_path( __FILE__ ) . 'includes/class-page-visit-counter.php';
|
|
54 |
*/
|
55 |
function run_page_visit_counter() {
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
}
|
61 |
|
62 |
function display_page_total_count($atts) {
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
$pageID = (int) $atts['id'];
|
67 |
-
|
68 |
-
$html = '';
|
69 |
-
|
70 |
if ($pageID != '' && is_int($pageID)) {
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
} else {
|
107 |
-
|
108 |
}
|
109 |
-
|
110 |
-
|
111 |
-
//echo $pageID;
|
112 |
-
|
113 |
-
|
114 |
}
|
115 |
-
|
|
|
116 |
|
117 |
function page_visit_counter_md_total_sites_visit($atts) {
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
}
|
180 |
-
|
|
|
181 |
|
182 |
|
183 |
-
run_page_visit_counter();
|
1 |
+
<?php
|
2 |
+
|
3 |
/*
|
4 |
* @link http://www.multidots.com/
|
5 |
* @since 1.1
|
8 |
* Plugin URI: http://www.multidots.com/
|
9 |
* Description: This plugin will count the total visits of your sites pages.
|
10 |
* Author: Multidots
|
11 |
+
* Version: 4.9
|
12 |
* Author URI: http://www.multidots.com/
|
13 |
+
*/
|
14 |
// If this file is called directly, abort.
|
15 |
+
if (!defined('WPINC')) {
|
16 |
+
die;
|
17 |
+
}
|
18 |
+
|
19 |
+
if (!defined('PVC_PLUGIN_URL')) {
|
20 |
+
define('PVC_PLUGIN_URL', plugin_dir_url(__FILE__));
|
21 |
+
}
|
22 |
+
if (!defined('PVC_PLUGIN_DIR')) {
|
23 |
+
define('PVC_PLUGIN_DIR', dirname(__FILE__));
|
24 |
+
}
|
25 |
+
if (!defined('PVC_PLUGIN_DIR_PATH')) {
|
26 |
+
define('PVC_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__));
|
27 |
+
}
|
28 |
+
if (!defined('PVC_PLUGIN_BASENAME')) {
|
29 |
+
define('PVC_PLUGIN_BASENAME', plugin_basename(__FILE__));
|
30 |
}
|
31 |
+
|
32 |
/**
|
33 |
* The code that runs during plugin activation.
|
34 |
* This action is documented in includes/class-page-visit-counter-activator.php
|
35 |
*/
|
36 |
function activate_page_visit_counter() {
|
37 |
+
require_once plugin_dir_path(__FILE__) . 'includes/class-page-visit-counter-activator.php';
|
38 |
+
class_Page_Visit_Activator::activate();
|
39 |
}
|
40 |
|
41 |
/**
|
43 |
* This action is documented in includes/class-page-visit-counter-deactivator.php
|
44 |
*/
|
45 |
function deactivate_page_visit_counter() {
|
46 |
+
require_once plugin_dir_path(__FILE__) . 'includes/class-page-visit-counter-deactivator.php';
|
47 |
+
class_Page_visit_Deactivator::deactivate();
|
48 |
}
|
49 |
+
|
50 |
/**
|
51 |
* register hook for plugins activate and deactivate.
|
52 |
*/
|
53 |
+
register_activation_hook(__FILE__, 'activate_page_visit_counter');
|
54 |
+
register_deactivation_hook(__FILE__, 'deactivate_page_visit_counter');
|
55 |
|
56 |
/**
|
57 |
* The core plugin class that is used to define internationalization,
|
58 |
* admin-specific hooks, and public-facing site hooks.
|
59 |
*/
|
60 |
+
require plugin_dir_path(__FILE__) . 'includes/class-page-visit-counter.php';
|
61 |
|
62 |
/**
|
63 |
* Begins execution of the plugin.
|
70 |
*/
|
71 |
function run_page_visit_counter() {
|
72 |
|
73 |
+
$plugin = new page_visit_counter();
|
74 |
+
$plugin->run();
|
|
|
75 |
}
|
76 |
|
77 |
function display_page_total_count($atts) {
|
78 |
+
global $wpdb, $wp, $post;
|
79 |
+
|
80 |
+
|
81 |
+
$pageID = (int) $atts['id'];
|
82 |
+
|
83 |
+
$html = '';
|
84 |
|
|
|
|
|
|
|
|
|
85 |
if ($pageID != '' && is_int($pageID)) {
|
86 |
|
87 |
+
$post = get_post($pageID);
|
88 |
+
|
89 |
+
if (isset($post) && !empty($post) && $post != null) {
|
90 |
+
$fetchSelecetedPostTypes = get_option('wfap_post_type');
|
91 |
+
|
92 |
+
$table_name = $wpdb->prefix . "page_visit";
|
93 |
+
|
94 |
+
$pageCount_qry = $wpdb->prepare('SELECT SUM(page_visit) as total FROM ' . $table_name . ' WHERE page_id=%d', $pageID);
|
95 |
+
$pageCount = $wpdb->get_results($pageCount_qry);
|
96 |
+
|
97 |
+
$total = (int) $pageCount[0]->total;
|
98 |
+
|
99 |
+
$text_color_page_visit = get_option('text_color_page_visit');
|
100 |
+
|
101 |
+
if (isset($text_color_page_visit) && $text_color_page_visit != null) {
|
102 |
+
$text_color_page_visit = 'style="color: ' . $text_color_page_visit . ';"';
|
103 |
+
} else {
|
104 |
+
$text_color_page_visit = 'style="color: #000000;"';
|
105 |
+
}
|
106 |
+
|
107 |
+
if ($fetchSelecetedPostTypes == '' || $fetchSelecetedPostTypes == null) {
|
108 |
+
$html .= '<p id="page-visit-counter-shortcode-block" class="page-visit-counter-block" ' . esc_attr($text_color_page_visit) . '><img src="' . esc_url(PVC_PLUGIN_URL . 'images/1456175371_vector_65_14.png') . '" /><span id="shortcode_' . esc_attr($pageID) . '" style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor_shortcode">' . esc_attr($total) . '</span>' . __('total visits.', 'page-visit-counter') . '</p>';
|
109 |
+
} else {
|
110 |
+
$postTypeSelectedEncodeArr = json_decode($fetchSelecetedPostTypes);
|
111 |
+
if (in_array($post->post_type, $postTypeSelectedEncodeArr)) {
|
112 |
+
$innerSettings = get_post_meta($pageID, 'enable_page_count', true);
|
113 |
+
if ($innerSettings == '' || $innerSettings == 'yes') {
|
114 |
+
$html .= '<p id="page-visit-counter-shortcode-block" class="page-visit-counter-block" ' . esc_attr($text_color_page_visit) . '><img src="' . esc_url(PVC_PLUGIN_URL . 'images/1456175371_vector_65_14.png') . '" /><span id="shortcode_' . esc_attr($pageID) . '" style="margin-left: 5px;margin-right: 5px;" class="page_amount_visitor_shortcode">' . esc_attr($total) . '</span>' . __('total visits.', 'page-visit-counter') . '</p>';
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
} else {
|
119 |
+
$html .= __('Please enter the valid post or page id.', 'page-visit-counter');
|
120 |
+
}
|
121 |
} else {
|
122 |
+
$html .= __('Please enter the valid post or page id.', 'page-visit-counter');
|
123 |
}
|
124 |
+
|
125 |
+
return $html;
|
|
|
|
|
|
|
126 |
}
|
127 |
+
|
128 |
+
add_shortcode('page_visit_counter_md', 'display_page_total_count');
|
129 |
|
130 |
function page_visit_counter_md_total_sites_visit($atts) {
|
131 |
+
global $wpdb;
|
132 |
+
|
133 |
+
$backgroundcolor = trim($atts['backgroundcolor']);
|
134 |
+
|
135 |
+
if (isset($backgroundcolor) && !empty($backgroundcolor)) {
|
136 |
+
$backgroundcolor = $backgroundcolor;
|
137 |
+
} else {
|
138 |
+
$backgroundcolor = '#ff0000';
|
139 |
+
}
|
140 |
+
|
141 |
+
$countboxcolor = trim($atts['countboxcolor']);
|
142 |
+
if (isset($countboxcolor) && !empty($countboxcolor)) {
|
143 |
+
$countboxcolor = $countboxcolor;
|
144 |
+
} else {
|
145 |
+
$countboxcolor = '#000';
|
146 |
+
}
|
147 |
+
|
148 |
+
|
149 |
+
$fontcolor = trim($atts['fontcolor']);
|
150 |
+
if (isset($fontcolor) && !empty($fontcolor)) {
|
151 |
+
$fontcolor = $fontcolor;
|
152 |
+
} else {
|
153 |
+
$fontcolor = '#FFF';
|
154 |
+
}
|
155 |
+
|
156 |
+
$bordercolor = trim($atts['bordercolor']);
|
157 |
+
if (isset($bordercolor) && !empty($bordercolor)) {
|
158 |
+
$bordercolor = $bordercolor;
|
159 |
+
} else {
|
160 |
+
$fontcolor = '#ff0000';
|
161 |
+
}
|
162 |
+
|
163 |
+
$table_name = $wpdb->prefix . "page_visit_history";
|
164 |
+
|
165 |
+
$query = "SELECT COUNT(id) as total FROM $table_name";
|
166 |
+
$totalCountResult = $wpdb->get_results($query);
|
167 |
+
|
168 |
+
$totalCount = (int) $totalCountResult[0]->total;
|
169 |
+
|
170 |
+
$array = str_split($totalCount);
|
171 |
+
|
172 |
+
$text_color_page_visit = get_option('text_color_page_visit');
|
173 |
+
|
174 |
+
if (isset($text_color_page_visit) && $text_color_page_visit != null) {
|
175 |
+
$text_color_page_visit = 'style="color: ' . esc_attr($text_color_page_visit) . ';"';
|
176 |
+
} else {
|
177 |
+
$text_color_page_visit = 'style="color: #000000;"';
|
178 |
+
}
|
179 |
+
|
180 |
+
$totalVisitsHtml = '';
|
181 |
+
|
182 |
+
$totalVisitsHtml .= '<div class="md-pvc-total-reports">';
|
183 |
+
$totalVisitsHtml .= '<div class="md-pvc-total-reports-sub" style="background:' . esc_attr($backgroundcolor) . ';">';
|
184 |
+
foreach ($array as $number) {
|
185 |
+
$totalVisitsHtml .= '<span style="border: 1px solid; ' . esc_attr($bordercolor) . ';color:' . esc_attr($fontcolor) . ';background:' . esc_attr($countboxcolor) . ';">' . esc_attr($number) . '</span>';
|
186 |
+
}
|
187 |
+
$totalVisitsHtml .= '<span class="text" style="border: 1px solid; ' . esc_attr($bordercolor) . ';color:' . esc_attr($fontcolor) . ';background:' . esc_attr($countboxcolor) . ';">' . __('total sites visits.', 'page-visit-counter') . '</span>';
|
188 |
+
$totalVisitsHtml .= '</div>';
|
189 |
+
$totalVisitsHtml .= '</div>';
|
190 |
+
|
191 |
+
return $totalVisitsHtml;
|
192 |
}
|
193 |
+
|
194 |
+
add_shortcode('page_visit_counter_md_total_sites_visit', 'page_visit_counter_md_total_sites_visit');
|
195 |
|
196 |
|
197 |
+
run_page_visit_counter();
|
public/class-page-visit-counter-public.php
CHANGED
@@ -152,7 +152,7 @@ class page_visit_counter_Public {
|
|
152 |
}
|
153 |
}
|
154 |
|
155 |
-
|
156 |
|
157 |
|
158 |
$table_name = $wpdb->prefix . "page_visit";
|
152 |
}
|
153 |
}
|
154 |
|
155 |
+
if ( $page != 0 ) {
|
156 |
|
157 |
|
158 |
$table_name = $wpdb->prefix . "page_visit";
|