Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript BBPress & WordPress mess of code

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #238070
    Anonymous
    Inactive

    Hello,
    For one of my projects, I wanted to hide the BBPress reply and new topic forms in a slide out. For example,
    Create Topic button=Open new topic form.
    Reply button=Open reply form.

    With this comes 2 issues.
    1. I can no longer edit posts, all I get is an undefined error.
    2. I cannot create topics in forums that don’t have topics because the Create Topic button does not show up.

    I have included my code below.

    Code in footer.php just after the </body> tag.
    &lt;!--Custom BBPress reply button*/--&gt;&lt;script type="text/javascript"&gt; jQuery(document).ready(function($){ $('.forums.bbp-replies').prev('.custom-reply-button').remove(); $('.bbp-reply-form').css('display','block'); $('.bbp-reply-form').append('&lt;a class="cancel-reply" href="#"&gt;Cancel&lt;/&gt;'); $('.bbp-reply-form').css('display','none'); $('.cancel-reply').click(function(e){ e.preventDefault(); $('.bbp-reply-form').css('display','none'); $('.custom-reply-button').css('display','inline-block'); }); $('.forums.bbp-replies').prev('.custom-newtopic-button').remove(); $('.bbp-topic-form').css('display','block'); $('.bbp-topic-form').append('&lt;a class="cancel-reply" href="#"&gt;Cancel&lt;/&gt;'); $('.bbp-topic-form').css('display','none'); $('.cancel-reply').click(function(e){ e.preventDefault(); $('.bbp-topic-form').css('display','none'); $('.custom-newtopic-button').css('display','inline-block'); }); });&lt;/script&gt;

    Code in functions.php.
    `/<em>Add reply form slide out on BBPress</em>/
    function show_form_on_click() {
    $classes = get_body_class();
    if (in_array('single-forum',$classes)) { ?>

    <script type="text/javascript">
    jQuery( document ).ready(function() {
    jQuery( '<div class="custom-newtopic-button">Create Topic</div>' ).insertAfter( '.bbp-pagination' );
    jQuery('.custom-newtopic-button').click(function(){
    jQuery('.custom-newtopic-button').hide();
    });
    jQuery('.custom-newtopic-button').click(function(){
    jQuery('.bbp-topic-form').show();
    });
    });
    </script>

    <pre><code><?php } elseif(in_array('single-topic',$classes)) { ?>
    <script type="text/javascript">
    jQuery( document ).ready(function() {
    jQuery( '<div class="custom-reply-button">Reply</div>' ).insertAfter( '.bbp-pagination' );
    jQuery('.custom-reply-button, .d4p-bbt-quote-link').click(function(){
    jQuery('.custom-reply-button').hide();
    });
    jQuery('.custom-reply-button, .d4p-bbt-quote-link').click(function(){
    jQuery('.bbp-reply-form').show();
    });
    });
    </script>
    <?php }
    </code></pre>

    }
    add_action( 'wp_footer', 'show_form_on_click' );`

    Code in CSS file.
    .bbp-topic-form,
    .bbp-reply-form {
    display: none;
    }

    Thanks for any help you are able to provide. :)

    #238105
    Anonymous
    Inactive

    Any help over here?

    Thanks.

    #240349
    Anonymous
    Inactive

    Hello,
    This issue has been resolved after discovering some code in a mu-plugin that was throwing this error.

    Thanks.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.