Skip to:
Content

bbPress.org

Changeset 6432


Ignore:
Timestamp:
05/26/2017 09:46:51 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Trash: Introduce bbp_get_trash_days() helper function.

This will allow the trashability of an object type to be short-circuited, around the EMPTY_TRASH_DAYS constant.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r6415 r6432  
    193193
    194194    return apply_filters( 'bbp_past_edit_lock', (bool) $retval, $cur_time, $lock_time, $post_date_gmt );
     195}
     196
     197/**
     198 * Get number of days something should remain trashed for before it is cleaned
     199 * up by WordPress Cron. If set to 0, items will skip trash and be deleted
     200 * immediately.
     201 *
     202 * @since 2.6.0 bbPress (r6424)
     203 *
     204 * @param string $context Provide context for additional filtering
     205 * @return int Number of days items remain in trash
     206 */
     207function bbp_get_trash_days( $context = 'forum' ) {
     208
     209    // Sanitize the context
     210    $context = sanitize_key( $context );
     211
     212    // Check the WordPress constant
     213    $days    = defined( 'EMPTY_TRASH_DAYS' )
     214        ? (int) EMPTY_TRASH_DAYS
     215        : 30;
     216
     217    // Filter & return
     218    return (int) apply_filters( 'bbp_get_trash_days', $days, $context );
    195219}
    196220
Note: See TracChangeset for help on using the changeset viewer.