• Resolved tapiohuuhaa

    (@tapiohuuhaa)


    https://wordpress.stackexchange.com/questions/305472/how-to-add-code-in-the-content-area-in-a-wordpress-theme/326407#326407

    That works with normal pages, but not in bbPress forum area. I think if there is some possibility to add some new code to bbp style pack in order to get fixed code to the bottom of the bbPress content.

    I have worked with a CMS. It does have XCLASS and hooks.
    The main idea is that without modifying the original code you can replace (using XCLASS) or add (using hooks) you own code by creating your own plugin. I have done XCLASSes and some hooks.

    The original code has XCLASS or hook reference.
    XCLASS is bad idea because the whole code must rewrite.

    Hook support would be excellent. Using Code Snippet you could add the code, which relates with hooks.

    A hook in order add code after the main content would be nice.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    https://www.sanaristikkofoorumi.net/wordpress/forums/topic/suomen-kuvalehti-36-2018/

    you can see the idea – instead of repeating some text in signature I added some text after breadcrumbs.

    I did this bad way:
    if (!empty ($bsp_breadcrumb[‘repeat’] )) {
    add_action( ‘bbp_template_after_forums_index’ , ‘bsp_add_breadcrumb_bottom’);
    add_action( ‘bbp_template_after_single_forum’ , ‘bsp_add_breadcrumb_bottom’);
    add_action( ‘bbp_template_after_single_topic’ , ‘bsp_add_breadcrumb_bottom’);
    }

    function bsp_add_breadcrumb () {
    bbp_breadcrumb();

    }

    function bsp_add_breadcrumb_bottom () {
    $mytext=’my own text here’;
    $result = bbp_breadcrumb().$mytext;
    echo $result;

    }

    Plugin Author Robin W

    (@robin-w)

    bbpress has several hooks

    there are

    do_action( 'bbp_theme_before_reply_content' ); 
    	
    do_action( 'bbp_theme_after_reply_content' ); 
    
    and
    
    return apply_filters( 'bbp_get_reply_content', $content, $reply_id );

    The equivalent to your example would be

    add_filter( 'bbp_get_reply_content', 'change_the_content' )
    function change_the_content($content) {
       $content = $content . "your additional content";
       return $content;
    }
    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    I put the last as a code snippet using the Code Snippets plugin but it didn’t do anything.

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Sorry that did something. It added text after individual
    comment like a signature.

    Something similar just after or before the bottom breadcrumb would be nice.

    Plugin Author Robin W

    (@robin-w)

    ok, really nit sure what your issue is. you stated in order to get fixed code to the bottom of the bbPress content.

    If you want it after the breadcrumb, then nothing wrong with the way you have done it if it works

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Seems that we misunderstood each others.

    I mean by ppPress content all bbPress-related content.

    If that is just not now possible, I propose if you could in future some way to add content after forum listing (forums page) or after the post form (all pages, which has the post form).

    That could be used simple form but for advanced users also using the Code Snippets plugin. That however needs some knowledge about PHP encoding.
    Simple form does need just HTML-knowledge, if HTML has been added.

    The idea of some text after the post form or bottom breadcrumbs is to give some generic information especially about registration and advances of registration (like I have done in Finnish). With CSS that information can also easily hide from people, who have logged in.

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Could you add hooks:

    bbp_get_topic_content_after
    bbp_get_reply_content_after
    bbp_get_forum_content_after

    I can’t redefine
    bbp_get_topic_content
    bbp_get_reply_content
    +
    (lycky guess) bbp_get_forum_content

    Maybe someone else would be interested those also.
    If I remember correct, hooks needs just
    function bbp_get_topic_content(){

    if(is_set(‘bbp_get_topic_content_after’) {
    $content=$content.bbp_get_forum_content_after($content);
    }

    }

    It is almost ten years when I last time made as part-time developer PHP-encoding and I might remember incorrect.
    I have made pluging for Typo3 CMS, which uses XCLASSes and HOOKS.

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Typo3 has long references for hooks and XCLASSes, but using Code Snippet long references are not necessary. Long references might be needed, if the added functions are in separate plugins. But in WordPress this can be done easier with Code Snippet plugin.

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    In XCLASS I could redefine certain functions.
    Normally I can’t redefine functions.
    I don’t remember, if there is possibility in some kind “delete” existing function and rewrite it.
    If that is possibile I could do all necessary changes using Code Snippet just “deleting” existing function and redefine it.

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    failed

    runkit_function_remove (’bsp_add_breadcrumb’);
    function bsp_add_breadcrumb () {…

    get:
    Cannot redeclare bsp_add_breadcrumb() (previously declared in /home/sanarist/public_html/wordpress/wp-content/plugins/bbp-style-pack/includes/functions.php:2116)

    Plugin Author Robin W

    (@robin-w)

    1. runkit_function_remove (’bsp_add_breadcrumb’); yes that would fail unless you running php on your own server and want to alter cire functionality, and you run it on the initiation of php across the whole server. It is not designed for user use.

    2. You don’t need to remove my function, that function is already a function running on a filter

    just put this in code snippets

    add_action( ‘bbp_template_after_forums_index’ , ‘tap_add_breadcrumb’);
    add_action( ‘bbp_template_after_single_forum’ , ‘tap_add_breadcrumb’);
    add_action( ‘bbp_template_after_single_topic’ , ‘tap_add_breadcrumb’);

    function tap_add_breadcrumb () {
    your code here
    }

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    OK. Works. Now I don’t need to alter your code in every new update.
    Thank’s.

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    Is there any corresponding method for adding something to the top of these pages.

    I tried just a lucky guess, which was wrong:

    $bottom1=’Sivun loppuun‘;
    $bottom2=’Sivun loppuun‘;
    add_action( ‘bbp_template_before_forums_index’ , $bottom1);
    add_action( ‘bbp_template_before_single_forum’ , $bottom2);
    add_action( ‘bbp_template_before_single_topic’ , $bottom2);

    BTW. My answer in the first mention page was deleted.
    It was quite the same as in the beginning of this topic except these sentences:

    The code seems to have syntax error but after fixing it works ok. I used Code Snippet plugin in order to test it.

    Plugin Author Robin W

    (@robin-w)

    if you are adding the same, then

    add_action( ‘bbp_template_before_forums_index’ , ‘tap_add_breadcrumb’);
    add_action( ‘bbp_template_before_single_forum’ , ‘tap_add_breadcrumb’);
    add_action( ‘bbp_template_before_single_topic’ , ‘tap_add_breadcrumb’); 

    The first part (eg bbp_template_before_forums_index) says where, the last part ‘tap_add_breadcrumb’ says what

    If you want different then

    add_action( ‘bbp_template_before_forums_index’ , ‘tap_add_breadcrumb2’);
    add_action( ‘bbp_template_before_single_forum’ , ‘tap_add_breadcrumb2’);
    add_action( ‘bbp_template_before_single_topic’ , ‘tap_add_breadcrumb2’); 
    
    function tap_add_breadcrumb2 () {
    your different code here
    }
Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘New content to the bottom of the page’ is closed to new replies.