WordPress.org

Ready to get started?Download WordPress

Forums

Editable Comments
issue with timezone offset (2 posts)

  1. graymerica
    Member
    Posted 3 years ago #

    To get this to work I had to update the timezone from wordpress options. The time zone of my server and the one set in WP are not the same.

    I put the following in my functions.php to avoid editing the plugin code.

    date_default_timezone_set(get_option('timezone_string'));

    Andrew

    http://wordpress.org/extend/plugins/editable-comments/

  2. FolioVision
    Member
    Posted 3 years ago #

    Hello graymerica,

    nice find. I had the same problem. But the above wasn't working.

    I had to use a more difficult way how to obtain current time respecting the WP time zone. I also had to switch the timezone from UTC-5 to "New York", date_default_timezone_set wasn't working with just UTC-5.

    function dateValid($date,$type){
      $date = mysql2date('U',$date,false);
    
      /// Addition
      $tz = get_option('timezone_string');
      date_default_timezone_set( $tz );
      $datetime = new DateTime( date('Y-m-d H:i:s') );
      $offset = $datetime->getOffset();
      $time = $datetime->format('U');
      $time = (int)$time + (int)$offset;
      //echo '<!-- COMMENT: '.$date.' server: '.$time.' -->';
      date_default_timezone_set('UTC');
      //echo ($date-$time);
      /// End of addition
    
      $editablecomments = get_option('editable-comments');
      if($type == 'edit')
        $minutes = $editablecomments['minutes'];
      if($type == 'delete')
        $minutes = $editablecomments['deleteminutes'];
      ///  Modification
      //if($date >= time() - $minutes * 60)
      if($date >= $time - $minutes * 60)
      ///
        return true;
    
      return false;
    }

    Other than that, the "Comment updated" message is not showing up in the Thesis. And it also could be more secure. If you post a comment, everybody from the same IP will be able to edit it, it should probably check the WP commenting cookie at least.

    Thanks,
    Martin

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic