#3222 closed defect (bug) (fixed)
Allow editing forever does not work
Reported by: | wpdennis | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 2.6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | API - Moderation | Keywords: | commit |
Cc: |
Description
If _bbp_edit_lock is set to 0, to allow editing forever, it will lock immediately.
The function bbp_past_edit_lock() should return true, if editing is no longer possible and false if editing is still possible.
<?php // "0" minutes set, so allow forever if ( 0 === $minutes ) { $retval = true;
$retval should be false in this case.
And turning the logic around to start with $retval = true should be safer, too. If bbp_allow_content_edit() is false or the post date is empty, the return value will be the default value.
With the default value being false it means we are allowed to edit, which is not correct.
Shouldn't it look like this in the trunk:?
<?php function bbp_past_edit_lock( $post_date_gmt = '' ) { // Default value $retval = true; // Get number of minutes to allow editing for $minutes = (int) get_option( '_bbp_edit_lock', 5 ); // Now $cur_time = current_time( 'timestamp', true ); // Period of time $lockable = "+{$minutes} minutes"; // Add lockable time to post time $lock_time = strtotime( $lockable, strtotime( $post_date_gmt ) ); // Check if date and editing is allowed if ( ! empty( $post_date_gmt ) && bbp_allow_content_edit() ) { // "0" minutes set, so allow forever if ( 0 === $minutes ) { $retval = false; // Not "0" so compare } elseif ( $cur_time <= $lock_time ) { $retval = false; } } // Filter & return return (bool) apply_filters( 'bbp_past_edit_lock', $retval, $cur_time, $lock_time, $post_date_gmt ); }
In 6869: