Skip to:
Content

bbPress.org


Ignore:
Timestamp:
10/10/2011 05:01:21 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Introduce functions for topic/reply per-page settings, to prevent divide by zero errors if setting is saved as '0' string.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/bbp-includes/bbp-topic-functions.php

    r3506 r3540  
    28782878}
    28792879
     2880/** Settings ******************************************************************/
     2881
     2882/**
     2883 * Return the topics per page setting
     2884 *
     2885 * @since bbPress (r3540)
     2886 *
     2887 * @uses get_option() To get the setting
     2888 * @uses apply_filters() To allow the return value to be manipulated
     2889 * @return int
     2890 */
     2891function bbp_get_topics_per_page() {
     2892
     2893    // The default per setting
     2894    $default = 15;
     2895
     2896    // Get database option and cast as integer
     2897    $per = $retval = (int) get_option( '_bbp_topics_per_page', $default );
     2898
     2899    // If return val is empty, set it to default
     2900    if ( empty( $retval ) )
     2901        $retval = $default;
     2902
     2903    // Filter and return
     2904    return (int) apply_filters( 'bbp_get_topics_per_page', $retval, $per );
     2905}
     2906
     2907/**
     2908 * Return the topics per RSS page setting
     2909 *
     2910 * @since bbPress (r3540)
     2911 *
     2912 * @uses get_option() To get the setting
     2913 * @uses apply_filters() To allow the return value to be manipulated
     2914 * @return int
     2915 */
     2916function bbp_get_topics_per_rss_page() {
     2917
     2918    // The default per setting
     2919    $default = 25;
     2920
     2921    // Get database option and cast as integer
     2922    $per = $retval = (int) get_option( '_bbp_topics_per_rss_page', $default );
     2923
     2924    // If return val is empty, set it to default
     2925    if ( empty( $retval ) )
     2926        $retval = $default;
     2927
     2928    // Filter and return
     2929    return (int) apply_filters( 'bbp_get_topics_per_rss_page', $retval, $per );
     2930}
     2931
    28802932/** Feeds *********************************************************************/
    28812933
Note: See TracChangeset for help on using the changeset viewer.