Git Product home page Git Product logo

post-views-counter's People

Contributors

avandepitte avatar bartoszarendt avatar damienwhaley avatar dependabot[bot] avatar obache avatar psielicki avatar yudinikita avatar zytzagoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

post-views-counter's Issues

PVC adds css code to header, with no option to turn off

This is CSS output added on each page:

		<style>
			#wp-admin-bar-pvc-post-views .pvc-graph-container { padding-top: 6px; padding-bottom: 6px; position: relative; display: block; height: 100%; box-sizing: border-box; }
			#wp-admin-bar-pvc-post-views .pvc-line-graph {
				display: inline-block;
				width: 1px;
				margin-right: 1px;
				background-color: #ccc;
				vertical-align: baseline;
			}
			#wp-admin-bar-pvc-post-views .pvc-line-graph:hover { background-color: #eee; }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-0 { height: 1% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-1 { height: 5% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-2 { height: 10% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-3 { height: 15% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-4 { height: 20% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-5 { height: 25% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-6 { height: 30% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-7 { height: 35% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-8 { height: 40% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-9 { height: 45% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-10 { height: 50% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-11 { height: 55% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-12 { height: 60% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-13 { height: 65% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-14 { height: 70% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-15 { height: 75% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-16 { height: 80% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-17 { height: 85% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-18 { height: 90% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-19 { height: 95% }
			#wp-admin-bar-pvc-post-views .pvc-line-graph-20 { height: 100% }
		</style>

Followed this guide: https://dfactory.eu/support/topic/exclude-stylesheet-when-not-displaying-counter-on-front-end/#post-36689

add_filter( 'pvc_enqueue_styles', '__return_false' );

It removes dashicons and frontend css file, but mentioned above inline css is still output on the page.

Include posts with not views in query

Hi,

I use your plugin with WP_Query, and when I use 'orderby' => 'post_views' , it only show posts with views OR posts featured (?)

Can we also show posts with 0 views ?

Fatal error: Uncaught ArgumentCountError: strtr() expects at least 2 arguments, 1 given in /wp-content/plugins/post-views-counter/includes/class-counter.php:795

Stack Trace :

1. strtr()/wp-content/plugins/post-views-counter/includes/class-counter.php:795
2. Post_Views_Counter_Counter->encrypt_ip()/wp-content/plugins/post-views-counter/includes/class-counter.php:117
3. Post_Views_Counter_Counter->check_post()/wp-content/plugins/post-views-counter/includes/class-counter.php:258
4. Post_Views_Counter_Counter->check_post_rest_api()/wp-includes/rest-api/class-wp-rest-server.php:1140
5. WP_REST_Server->respond_to_request()/wp-includes/rest-api/class-wp-rest-server.php:987
6. WP_REST_Server->dispatch()/wp-includes/rest-api/class-wp-rest-server.php:414
7. WP_REST_Server->serve_request()/wp-includes/rest-api.php:370
8. rest_api_loaded()/wp-includes/class-wp-hook.php:303
9. WP_Hook->apply_filters()/wp-includes/class-wp-hook.php:327
10. WP_Hook->do_action()/wp-includes/plugin.php:518
11. do_action_ref_array()/wp-includes/class-wp.php:388
12. WP->parse_request()/wp-includes/class-wp.php:750
13. WP->main()/wp-includes/functions.php:1291
14. wp()/wp-blog-header.php:16
15. require('...')/index.php:17
16. {main}
thrown in /wp-content/plugins/post-views-counter/includes/class-counter.php on line 795

PHP Version : 8.0.6
Plugin Version : 1.3.10

Also, I noticed that view counts are stopped since this update.

Bad bulk edit implementation

If in includes/columns.php line 273 you write absint( $count ); for the bulk edit input, when save it, all selected post receive the first parsed post value. You must keep the input empty to populate the data whit the jQuery script.

Counter doesn't check cookie before count (FastAJAX mode)

Hello,
I use FastAJAX mode for counting views, and set count interval to 24 hours.
I found a strange problem, everytime I refresh the page, the post views will count once.

In includes/counter.php
check_cookie() will be triggered by plugins_loaded actoin and check_post($id) will run after it receive a AJAX request

I did a small test (give each Post_Views_Counter_Counter a random id),
it seem like these two function run on different class instances, so when check_post($id) run, it always can't access cookie data.

I'm not sure if it is the key to cause this problem, now I simply fix this problem by adding one line $this->check_cookie(); to check_post($id), force it initialize cookie first.

Rest API

I'm working on a Headless CMS with a plugin integration of Post View Counter, there is a way to expose the number of views to GraphQL requests?

Exclude Visitors

The bbPress Forum roles are not shown as options to exclude visitors.

Increase views if attachment embedded within content

Hi,

Thanks for the great plugin! I have an issue where I'd like to increase the views of embedded media within my post content.

I'm using the pvc_view_post function to increase the view count but it's increasing the views every time I refresh the page content. How do I increase the view only once so it behaves the same way as viewing the attachment directly and only increases the view once (so multiple refreshes don't keep increasing the view count).

Thanks!

Views flushing from cache not working after `PVC 1.3.1`

@psielicki @bartoszarendt

I've recently updated from 1.3.1 to 1.3.4 and after a while noticed all page views have been lost in the mean time. I didn't change any settings or behaviors after the update. After a closer look on the source code, it looks like some refactor was being conducted and as far as I could understand it wasn't completed but actually released.

This commit looks like where it all changed as you can see it will call a db_prepare_insert and then db_commit_insert instead of the former db_insert.

Below you can check the actual method code with the important INSERT query commented:

private function db_commit_insert() {
if ( empty( $this->db_insert_values ) )
return false;
global $wpdb;
// $result = $wpdb->query( "
// INSERT INTO " . $wpdb->prefix . "post_views (id, type, period, count)
// VALUES " . $this->db_insert_values . "
// ON DUPLICATE KEY UPDATE count = count + VALUES(count)"
// );
$this->db_insert_values = '';
// return $result;
}

I'm not sure why it is commented or how did this get to a release without working and specially because it has been a long while it has happened and no one eventually noticed I am curious if there is actually a different way to do it after that release that I didn't catch.

P.S. Reverting to PVC 1.3.1 got it back working.

For the record, I am using WP 5.7 with nginx 1.18.0 and PHP 7.4.16.

Below a screenshot of relevant configuration screen:
Screen Shot 2021-04-15 at 2 53 58 PM

Please let me know if I can provide any further information and be helpful on improving this great plugin!

Keep Rocking!

How do I make the database smaller?

How do I make the database smaller?
And does this option Reset Data Interval, if I use it, will it clean the database without affecting the statistics?
I want to use it with Post Pay Counter
Will the Reset Data Interval option affect the data with this addition?

high load problem

Hi, you have a very cool plugin, but I have a buggy site for high traffic (4000 people per minute for example), I use counting in RAM, and I add information about views on the crown every 3 minutes, I think the problem is related to the fact, that counting views is through admin-ajax.php, because connecting this script draws a lot of dependencies of WordPress, can you add your own script for counting in order not to drag all the dependencies of WordPress, then this process would be easier? can you advise something? Thanks

Object Cache Redis?

Hi, will the counter with the Redis work? with memcached work fine, but I plan to switch to redis=) thanks for reply

Url wrong when get order from wp-admin edit page

default
I deploy wordpress in docker which network is internal with 192.168.100.10. but the plugin should not assume that outter network can access it.
The right way is to read the Settings from wordpress to get the public url as below:
21

I'm so sorry that I can't fix it for you.

Uncaught TypeError

I got this error in my console log

Uncaught TypeError: Cannot read properties of null (reading 'classList')
    at Object.init (/app/plugins/cookie-…nt.js?ver=2.1.5:372)
    at /app/plugins/cookie-…nt.js?ver=2.1.5:455

Occurs on front.js line 372

More strict option to set counts interval

Currently option to set counts interval uses the cookie to manage counts interval. This is good for most of the sites, I guess. But I'm working on a site where we need to be very strict about this.

Now user can just open an incognito browser window and hit that URL. And they can bypass the counts interval thing easily.

Maybe we can add a new table where we can log user details (user_id, IP, user agent, browser etc) and before counting visit just check if that user's hit is already counted in the interval.

Also, to keep the log table small, we can set a wp cron to clear up old entries.

Unable to edit Post View on Gutenberg

It was working fine with the classic editor of WordPress. When I have installed Gutenberg editor, it stopped showing the option for edit post view.

Admin cannot change the post view number after installing Gutenberg plugin.

Kindly update the plugin.

Your cron takes over other cron jobs

I tried to add this issue to your support forum but it failed twice, so doing it here.

Your plugin adds a cron schedule which already exists in Wordpress default, namely the daily schedule, as explained here.

By registering this, it overtakes the default "daily" schedule so now the name of your cron schedule appears on places where it's not expected (or wanted). This can be see this screenshot.

Adrotate is now linked to your cron as is the custom plugin with sd prefix. And there are more (outside of screenshot).

It is my opinion you don't need to add this daily schedule because it already exists. I have found 4 possible solutions to avoid this. 3 are on the plugin side and 1 is on the user side.

  1. Remove your cron schedule and add use daily for the cron job that uses it (there is only 1).
  2. Place the adding of the cron_schedule in an IF statement. Something like this (this code doesn't work, but gives an idea of what I mean):
    if ( ! array_key_exists( 'daily', wp_cron_schedules() ) ) {
        // add your schedule
    }
    
  3. Change the interval of your cron schedule to 86401 (1 second higher). This will stop the intereference with the default schedule.
  4. Add a filter which unregisters your cron schedule and registers a new one with the same name but with a 86401 interval, see code below (tested and works).
    public function change_cron_time_intervals( $schedules ) {
    
        unset( $schedules['post_views_counter_interval'] );
        $schedules['post_views_counter_interval'] = array(
            'interval'   => 86401,
            'display'    => __( 'Post Views Counter reset daily counts interval', 'post-views-counter' )
        );
    
        return $schedules;
    }
    

PHP Function for pageviews?

Hi,

Awesome code! Thanks!

I was wondering, do you have a PHP function available to retrieve the pageviews for a specific post ID in PHP? So I can integrate your plugin with other plugins?

And if yes, how can I best test your plugin is active?

Looking forward to your reply. Thanks!

Feature Request -> Sync with Google Analytics?

I've found this plugin really helpful. Thanks for making this awesome plugin. I've got a question for this plugin for integrating GA.

Or is there already tutorial or guide for this?

Thanks.

Document cookie banner integration

Hi.

I was implementing new third party cookie banner integration to our wordpress blog and after searching through the source code, I noticed I can easily integrate it with your plugin, however it is documented only in your other repo about function cn_cookies_accepted. Could you please include this possible integration into this readme as well?

Thank you

Add to Rest API

Can we add number of view to REST API
wp-json/wp/v2/posts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.