Home › Forums › JavaScript › BBPress & WordPress mess of code
- This topic is empty.
-
AuthorPosts
-
February 15, 2016 at 3:18 pm #238070
Anonymous
InactiveHello,
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.
<!--Custom BBPress reply button*/--><script type="text/javascript"> jQuery(document).ready(function($){ $('.forums.bbp-replies').prev('.custom-reply-button').remove(); $('.bbp-reply-form').css('display','block'); $('.bbp-reply-form').append('<a class="cancel-reply" href="#">Cancel</>'); $('.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('<a class="cancel-reply" href="#">Cancel</>'); $('.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'); }); });</script>
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. :)
February 16, 2016 at 4:05 pm #238105Anonymous
InactiveAny help over here?
Thanks.
April 9, 2016 at 3:56 pm #240349Anonymous
InactiveHello,
This issue has been resolved after discovering some code in a mu-plugin that was throwing this error.Thanks.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.