bbp_past_edit_lock( string $datetime = '', boolean $utc = true )
Check a date against the length of time something can be edited.
Description Description
It is recommended to leave $utc set to true and to work with UTC/GMT dates. Turning this off will use the WordPress offset which is likely undesirable.
Parameters Parameters
- $datetime
-
(Optional) Gets run through strtotime()
Default value: ''
- $utc
-
(Optional) Is the timestamp in UTC?
Default value: true
Return Return
(bool) True by default, if date is past, or editing is disabled.
Source Source
File: includes/common/functions.php
function bbp_past_edit_lock( $datetime = '', $utc = true ) { // Default value $retval = true; // Check if date and editing is allowed if ( bbp_allow_content_edit() ) { // Get number of minutes to allow editing for $minutes = bbp_get_edit_lock(); // 0 minutes means forever, so can never be past edit-lock time if ( 0 === $minutes ) { $retval = false; // Checking against a specific datetime } elseif ( ! empty( $datetime ) ) { // Period of time $lockable = "+{$minutes} minutes"; if ( true === $utc ) { $lockable .= " UTC"; } // Now $cur_time = current_time( 'timestamp', $utc ); // Get the duration in seconds $duration = strtotime( $lockable ) - $cur_time; // Diff the times down to seconds $lock_time = strtotime( $lockable, $cur_time ); $past_time = strtotime( $datetime, $cur_time ); $diff_time = ( $lock_time - $past_time ) - $duration; // Check if less than lock time if ( $diff_time < $duration ) { $retval = false; } } } // Filter & return return (bool) apply_filters( 'bbp_past_edit_lock', $retval, $datetime, $utc ); }
Changelog Changelog
Version | Description |
---|---|
2.6.0 | bbPress (r6868) Inverted some logic and added unit tests |
2.0.0 | Introduced. |