Coder Social home page Coder Social logo

pressjitsu / pageviews Goto Github PK

View Code? Open in Web Editor NEW
27.0 7.0 8.0 537 KB

A simple and lightweight pageviews counter for your WordPress posts and pages.

Home Page: https://pageviews.io

License: GNU General Public License v3.0

JavaScript 5.70% PHP 82.54% Shell 11.76%
analytics tracking wordpress pageview counter

pageviews's Introduction

Pageviews for WordPress

Pageviews is a simple and lightweight views counter for your WordPress posts and pages. It is based on JavaScript and is compatible with all caching plugins, proxies and complex setups. Pageviews works with a hosted processing service, and performs extremely well under high-traffic and on sites with large amounts of content.

Check out Pageviews.io for more information.

Installation

Extract the archive contents into your wp-content/plugins/pageviews directory and activate the Pageviews plugin through the WordPress plugin management interface or WP-CLI. After activating, your website will start counting and displaying your pageviews immediately.

Customization

By default, the number of views is displayed at the end of each post with a little bar-graph icon. Some WordPress themes with explicit support for the Pageviews plugin may display the counts differently to match the look and feel of the theme and its icon set.

To change the default behavior you'll need to declare support for the Pageviews plugin in your theme's functions.php file in the after_setup_theme action:

add_action( 'after_setup_theme', function() {
    add_theme_support( 'pageviews' );
});

This will disable the default behavior of appending the views count to the end of each post, giving you the freedom to display the counts with a simple pageviews action anywhere in your theme's template files (within the loop of course):

Views: <?php do_action( 'pageviews' ); ?>

The action will result in a special placeholder in the HTML, which when rendered, will be filled with the actual views count. If you'd like to retrieve the placeholder markup instead of rendering it directly, you may use the get_placeholder method like this:

if ( is_callable( array( 'Pageviews', 'get_placeholder' ) ) ) {
	$placeholder = Pageviews::get_placeholder( $post->ID );
	echo 'Views: ' . $placeholder;
}

The placeholder container class name is pageviews-placeholder which can be used for any necessary CSS positioning and styling.

Support

Feature requests, questions, bug reports and pull requests are always welcome. If you need help integrating this plugin into your theme, or migrating your existing counts from other plugins or services, such as Jetpack, Google Analytics, etc., please feel free to reach out to us by e-mail at [email protected].

pageviews's People

Contributors

pj-dave avatar soulseekah 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pageviews's Issues

Increase counting x2 automatically

Hi,

Could you please advise how to automatically increase counting x2 automatically. For Example on 3 time refreshing of website counter=counter+2

Thanks

safari browser

the number of views in the safari browser is not displayed. What could be the reason?

Rounding numbers & unit

Hello @pressjitsu!

I’d like to know if there is a simple way to modify pageviews.js in order to change how numbers are displayed. Ideally I’d like to have the number divided by 1000 and then add a K to it. For example, if I have 50,000 views I’d like to transform it to 50k.
Any ideas what I’d have to modify in the .js ? I’m well aware that this would be lost after an update of course, hence I'm asking here, because if it's complicated this would be a nice feature to add :)

Get views by post ID

Hi @pressjitsu
Thanks for the great plugin. It's works very well.

Have some questions about plugin:

  1. Do you plan implement action to display the page / post views by post id (outside of the loop)?
  2. And it would be great to have the ability to sync page views with your server locally( maybe once a week), to have access to the local variables for tasks, such as sorting posts by number of post views. Or maybe you have some ideas how to implement it?

Скрипты плагина не поддаются минимизации и конкатенации кешируюшими плагинами

Так как подключение скриптов у вас реализовано на хуке wp_footer, то большинство кеширующих плагинов не могут минимизировать и приклеить к другим скриптам ваш pageviews.js. И нет возвожности убрать ?v= из пути.

Тут либо вешать все на стандартный хук wp_enqueue_script либо класть с плагином минимизированную версию скрипта и подключать pageviews.js или pageviews.min.js в зависимости от SCRIPT_DEBUG.

Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR)

Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR)
VM281:1 Failed to load https://pv.pjtsu.com/v1/get/359,47: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 500.
2pv.pjtsu.com/v1/get/359,47,45,43:1 Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR)
localhost/:1 Failed to load https://pv.pjtsu.com/v1/get/359,47,45,43: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 500.

Hello. I used your plugin and today i got those error. What happened? What i should do?

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.