Plugin Directory

Changeset 1689914


Ignore:
Timestamp:
07/03/2017 04:55:54 PM (9 years ago)
Author:
inviul
Message:

Updated to v1.1

Location:
commentsafe/trunk
Files:
104 added
2 edited

Legend:

Unmodified
Added
Removed
  • commentsafe/trunk/comment-safe.php

    r1679656 r1689914  
    3030
    3131        add_filter( 'comment_form_defaults', array($this,'get_timers') );
     32
     33        add_action( 'comment_form_logged_in_after', array($this, 'init_timer_client_side') );
     34        add_action( 'comment_form_after_fields', array($this, 'init_timer_client_side') );
     35        add_filter( 'preprocess_comment', array($this, 'verify_timer_after_comment') );
     36    }
     37
     38
     39    public function init_timer_client_side() {
     40        echo "<input type='hidden' name='_wpcar_init_timer' value='".base64_encode($this->get_reading_time()."|".time())."'>";
     41    }
     42
     43    public function verify_timer_after_comment( $commentdata ) {
     44        $timer = explode("|", base64_decode($_POST['_wpcar_init_timer']));
     45        $time_to_comment = $timer[0];
     46        $page_loaded_at = $timer[1];
     47        if((time() - $page_loaded_at) < $time_to_comment) {
     48            wp_die( __( 'Error: Please read the article before you comment.' ) );
     49        }
     50        return $commentdata;
    3251    }
    3352
  • commentsafe/trunk/readme.txt

    r1684755 r1689914  
    99Requires at least: 3.1
    1010Tested up to: 4.8
    11 Version: 1.0
     11Version: 1.1
    1212
    1313
Note: See TracChangeset for help on using the changeset viewer.