PHP code example of ramphor / post-views

1. Go to this page and download the library: Download ramphor/post-views library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ramphor / post-views example snippets


$userHandler = new UserHandler(true);
$userHandler->setRemoteIP(wordland_get_real_ip_address());
$userHandler->setUserId(get_current_user_id());
$userHandler->setExpireTime(1 * 24 * 60 * 60); // 1 day

$cookieHandler = new CookieHandler();
$cookieHandler->setExpireTime(30 * 24 * 60 * 60); // 30 days

$this->viewCounter = new PostViewCounter(PostTypes::get());
$this->viewCounter->addHandle($cookieHandler);
$this->viewCounter->addHandle($userHandler);

$this->viewCounter->count();