示例#1
0
/**
 * Are replies threaded
 *
 * @since 2.4.0 bbPress (r4944)
 *
 * @param bool $default Optional. Default value true
 * @uses apply_filters() Calls 'bbp_thread_replies' with the calculated value and
 *                        the thread replies depth
 * @uses get_option() To get thread replies option
 * @return bool Are replies threaded?
 */
function bbp_thread_replies()
{
    $depth = bbp_thread_replies_depth();
    $allow = bbp_allow_threaded_replies();
    $retval = (bool) ($depth >= 2 && true === $allow);
    return (bool) apply_filters('bbp_thread_replies', $retval, $depth, $allow);
}
示例#2
0
/**
 * Hierarchical reply maximum depth level setting field
 *
 * Replies will be threaded if depth is 2 or greater
 *
 * @since 2.4.0 bbPress (r4944)
 *
 * @uses apply_filters() Calls 'bbp_thread_replies_depth_max' to set a
 *                        maximum displayed level
 * @uses selected() To display the selected attribute
 */
function bbp_admin_setting_callback_thread_replies_depth()
{
    // Set maximum depth for dropdown
    $max_depth = (int) apply_filters('bbp_thread_replies_depth_max', 10);
    $current_depth = bbp_thread_replies_depth();
    // Start an output buffer for the select dropdown
    ob_start();
    ?>

	</label>
	<label for="_bbp_thread_replies_depth">
		<select name="_bbp_thread_replies_depth" id="_bbp_thread_replies_depth" <?php 
    bbp_maybe_admin_setting_disabled('_bbp_thread_replies_depth');
    ?>
>
		<?php 
    for ($i = 2; $i <= $max_depth; $i++) {
        ?>

			<option value="<?php 
        echo esc_attr($i);
        ?>
" <?php 
        selected($i, $current_depth);
        ?>
><?php 
        echo esc_html($i);
        ?>
</option>

		<?php 
    }
    ?>
		</select>

	<?php 
    $select = ob_get_clean();
    ?>

	<label for="_bbp_allow_threaded_replies">
		<input name="_bbp_allow_threaded_replies" id="_bbp_allow_threaded_replies" type="checkbox" value="1" <?php 
    checked('1', bbp_allow_threaded_replies(false));
    bbp_maybe_admin_setting_disabled('_bbp_allow_threaded_replies');
    ?>
 />
		<?php 
    printf(esc_html__('Enable threaded (nested) replies %s levels deep', 'bbpress'), $select);
    ?>
	</label>

<?php 
}