Skip to:
Content

bbPress.org


Ignore:
Timestamp:
10/12/2018 05:07:51 PM (6 years ago)
Author:
johnjamesjacoby
Message:

Edit Locking Improvements:

  • Refactor to avoid doing unnecessary computations
  • Invert default return value from false to true, requiring time to pass validation as opposed to assuming
  • Improve obviousness of math computations for easier debuggability
  • Update variables passed into the end return filter
  • Add 6 unit tests for before/on/after, plus support for "0" as infinite
  • Fix bug causing "0" values to return the opposite value
  • Ensure only gmt/utc values are compared
  • Add optional flag to use WordPress time instead
  • Improve inline and function documentation

Fixes #3222. Props wpdennis.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/settings.php

    r6834 r6869  
    661661    </label>
    662662    <label for="_bbp_edit_lock">
    663         <input name="_bbp_edit_lock" id="_bbp_edit_lock" type="number" min="0" step="1" value="<?php bbp_form_option( '_bbp_edit_lock', '0' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_edit_lock' ); ?> />
     663        <input name="_bbp_edit_lock" id="_bbp_edit_lock" type="number" min="0" step="1" value="<?php bbp_form_option( '_bbp_edit_lock', '5' ); ?>" class="small-text"<?php bbp_maybe_admin_setting_disabled( '_bbp_edit_lock' ); ?> />
    664664
    665665    <?php $select = ob_get_clean(); ?>
     
    19451945     * @param string $option
    19461946     * @param string $default
    1947      * @param bool $slug
     1947     * @param bool   $is_slug
     1948     *
     1949     * @return mixed
    19481950     */
    1949     function bbp_get_form_option( $option, $default = '', $slug = false ) {
     1951    function bbp_get_form_option( $option, $default = '', $is_slug = false ) {
    19501952
    19511953        // Get the option and sanitize it
     
    19531955
    19541956        // Slug?
    1955         if ( true === $slug ) {
     1957        if ( true === $is_slug ) {
    19561958            $value = esc_attr( apply_filters( 'editable_slug', $value ) );
    19571959
     
    19671969
    19681970        // Filter & return
    1969         return apply_filters( 'bbp_get_form_option', $value, $option );
     1971        return apply_filters( 'bbp_get_form_option', $value, $option, $default, $is_slug );
    19701972    }
    19711973
Note: See TracChangeset for help on using the changeset viewer.