Skip to:
Content
Pages
Categories
Search
Top
Bottom

customizing bbpress admin links


  • Robkk
    Participant

    @robkk

    ok i just need help with creating a function

    if i could use <?php echo bbp_get_topic_reply_link(); ?> to call the topic reply link

    how could i make a function thats

    if post type is topic echo bbp_topic_reply_link else echo bbp-reply-to-link

    and another function that is if keymaster or mod echo trash topic , trash reply etc.

    my goal with this is to call each admin link individually and make only 2 or 3 to be visible
    (reply,edit,maybe quote link from gd bbpress tools)

    while the others are inside of a dropdown menu with an icon to show the menu
    kind of like twitter where it shows other options in the more button on tweets

    if you guys could help me find another way to call the bbpress admin links instead of
    <?php echo bbp_get_name_of_link(); ?>

Viewing 25 replies - 1 through 25 (of 32 total)

  • Robin W
    Moderator

    @robin-w

    In essence if I understand it you want to change the

    reply/edit/merge/trash/close/trash/reply links that come up with a topic or reply so that only some show, and others are in a dropdown list.

    is that correct?

    if so then

    my goal with this is to call each admin link individually and make only 2 or 3 to be visible
    (reply,edit,maybe quote link from gd bbpress tools)

    simply requires you to filter for those you want to display

    open up

    bbpress/includes/replies/template.php

    and you’ll see the admin links function line starting at line 1811

    On lines 1840 to 1848 you’ll see the default links are added.

    So lets create a function to just have the first two

    you’ll see a filter in line 1841 (‘apply_filters’) and we can hook to that

    so

    //change admin links displayed
    function change_admin_links ($r) {
    $r['links'] = apply_filters( 'rw_reply_admin_links', array(
    				'edit'  => bbp_get_reply_edit_link ( $r ),
    				'move'  => bbp_get_reply_move_link ( $r )
    			), $r['id'] );
    return $r['links'] ;
    }
    add_filter ('bbp_reply_admin_links', 'change_admin_links' ) ;
    
    

    just leaves us with edit and move.

    This also gives you the ability to add a new link, with say your dropdown list.

    You’ll also see that this function checks if it is a topic on line 1825, and you’ll need to similarly create a function for that – I’ll leave you to work that one out.

    Come back if you need more help, and when you crack this, can you post the finished code to this site so we can see what it looks like.


    Robkk
    Participant

    @robkk

    you want to change the

    links that come up with a topic or reply so that only some show, and others are in a dropdown list.

    is that correct?

    yes

    This also gives you the ability to add a new link

    yeah i added the topic favorite link to see if it worked and it did with the ajax too
    and also a mark topic as read from the bbpress go to first unread plugin

    You’ll also see that this function checks if it is a topic on line 1825

    i used this as a filter for the topic admin links

    //change admin links displayed
    function change_topic_admin_links ($r) {
    $r['links'] = apply_filters( 'rw_topic_admin_links', array(
    				'edit'  => bbp_get_topic_edit_link ( $r ),
    				'reply'  => bbp_get_topic_reply_link ( $r )
    				
    			), $r['id'] );
    return $r['links'] ;
    }
    add_filter ('bbp_topic_admin_links', 'change_topic_admin_links' ) ;

    i tried using this function to post a single admin link for a topic
    and also just by replacing return with echo
    but i cant seem to get that to work

    if ( bbp_is_topic( $r['id'] ) ) {
    			return bbp_get_name_of_link();
    		}
    
    		if ( !bbp_is_reply( $r['id'] ) ) {
    			return bbp_get_name_of_link() ;
    		}

    Robin W
    Moderator

    @robin-w

    great, glad you’ve got most of it working.

    ok, on that last bit

    tried using this function to post a single admin link for a topic
    and also just by replacing return with echo
    but I cant seem to get that to work

    Can you explain a bit more about what you’re trying to do and where?


    Robkk
    Participant

    @robkk

    @robin-w i couldnt get the if ( bbp_is_topic function working

    i wanted to test out if i could do this , took code from this

    http://codepen.io/JFarrow/pen/IuwGa

    <div class="dropdown" id="dropdown">
    				<input type="checkbox" id="drop1" />
            <label for="drop1" class="dropdown_button">Topic Tools</label>
            <ul class="dropdown_content">
                <li class="active"></li>
                  <li> <?php echo bbp_get_reply_to_link(); ?></li>
                  <li><?php if ( bbp_is_topic( $r['id'] ) ) {
    echo bbp_get_topic_reply_link(); ?></li>
                  <li><?php if ( bbp_is_topic( $r['id'] ) ) {
    return bbp_get_topic_reply_link(); ?></li>
            </ul>
            
        </div>

    then make a dropdown menu from that i guess , but im just swinging the dark not really getting a exactly great way of doing what i want to achieve.

    plus i might have to go to a jquery menu template like this

    http://codepen.io/Jeplaa/pen/IzAvx

    because the css menus arent working on all replies.


    Robin W
    Moderator

    @robin-w

    where are you putting this code – is it in a bbpress template?


    Robkk
    Participant

    @robkk

    oh yeah in loop-single-reply i have my admin links on the very bottom of the template and i have this code right above it


    Robin W
    Moderator

    @robin-w

    try changing

    bbp_is_topic( $r['id'])

    to

    bbp_is_topic()

    the template already knows what the id is


    Robkk
    Participant

    @robkk

    <?php if ( bbp_is_topic() ) 
    echo bbp_get_topic_reply_link(); ?>
    <?php if ( bbp_is_topic() ) 
    return bbp_get_topic_reply_link(); ?>

    these dont show an error but it wont show the link


    Robin W
    Moderator

    @robin-w

    sorry I’m getting confused

    aren’t you using

    bbp_topic_admin_links

    and then filtering this to just display bbp_get_topic_reply_link
    ????


    Robkk
    Participant

    @robkk

    @robin-w (hope this doesnt confuse you anymore)

    i have done that already

    i added the filter to my functions.php to leave the reply links on both topic and replies

    now im trying to make a drop-down menu with the rest of the other links on both topic and replies , right by the admin links by adding an html menu with the rest of the other links(trash, split, spam, etc.)

    when creating a menu i use echo bbp-get-name-of-link between li that is between a ul which makes a menu in html , and this shows each other admin link in a dropdown menu

    however i want the topic admin links to be on topics and the reply admin links to be on replies each in their own dropdown menu

    and if i use these two functions in loop-single-reply (where i am building my menu)

    -this is an example- if i use topic_reply_link and reply_tp_link it would be the same

    `<?php echo bbp_get_topic_edit_link(); ?>

    <?php echo bbp_get_reply_edit_link(); ?>`

    there will be 1 edit link in the topic (topic_edit_link) , and two edit links in the reply (topic_edit_link and reply_edit_link)

    so i have to fix the two edit links on replies when creating a dropdown menu

    or find a way to make a dropdown menu using a function so that it will show two different dropdown menus for the topic and the reply


    Robkk
    Participant

    @robkk

    this is the best i got it right now, but you can also see what i was trying to go for


    Robin W
    Moderator

    @robin-w

    thanks for posting that and I haven’t got bored with this subject, just V busy elsewhere !!

    I’ll try and come back and help when I get some time to properly digest !! :-)


    Robkk
    Participant

    @robkk

    OK great


    Robin W
    Moderator

    @robin-w

    ok, my brain is now mush, but I am still hooked.

    Can you post you solution so far, then I’ll put it in my test site

    So I need to know

    what code you put in your functions file

    what code you have in loop single reply (and starting where!)

    any other code you have, and where you’ve put it

    I’ll then have a play !


    Robkk
    Participant

    @robkk

    I can’t post any code right now I’m on my cell , I’ll do it tomorrow , but its not really much though I just made a menu in HTML and put the admin links in each list .

    The only problem I have is just making the specific admin links show up on their specific post type.

    I can tell you other ideas I have thought to place the menu of links besides HTML but that might confuse you more.


    Robin W
    Moderator

    @robin-w

    no problems, just want to see what you’ve done and if I can help further


    Robkk
    Participant

    @robkk

    ok i havent gone too much far into this as you may think though

    but you can try it as it is now to test it out

    these are both in my functions.php in my child theme
    im just showing the reply link on both topics and replies, i have gd bbpress tools so there is also a quote link

    //change admin links displayed
    function change_admin_links ($r) {
    $r['links'] = apply_filters( 'rw_reply_admin_links', array(
    				'reply'  => bbp_get_reply_to_link ( $r )
    				
    			), $r['id'] );
    return $r['links'] ;
    }
    add_filter ('bbp_reply_admin_links', 'change_admin_links' ) ;
    
    //change admin links displayed
    function change_topic_admin_links ($r) {
    $r['links'] = apply_filters( 'rw_topic_admin_links', array(
    				'reply'  => bbp_get_topic_reply_link ( $r )
    				
    			), $r['id'] );
    return $r['links'] ;
    }
    add_filter ('bbp_topic_admin_links', 'change_topic_admin_links' ) ;

    I have this in my loop-single-reply.php at the bottom ,

    i havent added all the admin links, plus this doesnt work on replies it only works on the topic , i need to use a jquery on click function instead of all css dropdown menu

    <div class="dropdown" id="dropdown">
    				<input type="checkbox" id="drop1" />
            <label for="drop1" class="dropdown_button">Topic Tools</label>
            <ul class="dropdown_content">
                <li class="active"></li>
                  <li> <?php echo bbp_get_reply_edit_link(); ?></li>
                  <li><?php echo bbp_get_reply_spam_link(); ?></li>
                  <li><?php echo bbp_get_reply_move_link(); ?></li>
            </ul>
            
        </div>

    here is all my custom css , i have this in my themes custom css plugin

    .dropdown {
        display: inline-block;
        margin: 0px 10px;
        position: relative;
      float:right;
    }
    
    .dropdown .dropdown_button {
        cursor: pointer;
        width: auto;
        display: inline-block;
        padding: 2px 10px;
        border: 1px solid #AAA;
        border-radius: 0px;
        font-weight: bold;
        color: #222;
        line-height: 16px;
        text-decoration: none !important;
        background: none repeat scroll 0% 0% #FFF;
    }
    
    .dropdown input[type="checkbox"]:checked + .dropdown_button {
        border-width: 1px;
        border-style: solid;
        color: #222;
        background: #FFF;
    }
    
    .dropdown input[type="checkbox"] + .dropdown_button .arrow {
        display: inline-block;
        width: 0px;
        height: 0px;
        border-top: 5px solid #6B7FA7;
        border-right: 5px solid transparent;
        border-left: 5px solid transparent;
    }
    
    .dropdown input[type="checkbox"]:checked + .dropdown_button .arrow { border-color: white transparent transparent transparent }
    
    .dropdown .dropdown_content {
        position: absolute;
        border: 1px solid #777;
        padding: 0px;
        background: white;
        margin: 0;
        display: none;
    }
    
    .dropdown .dropdown_content li {
        list-style: none outside none;
        margin-left: 0px;
        line-height: 16px;
        border-top: 1px solid #FFF;
        border-bottom: 1px solid #FFF;
        margin-top: 2px;
        margin-bottom: 2px;
        width: 86px;
    }
    
    .dropdown .dropdown_content li:hover {
        background: #999;
      color:#222;
    }
    
    .dropdown .dropdown_content li a {
        display: block;
        padding: 2px 15px;
        color: #222;
        text-decoration: none !important;
        white-space: nowrap;
        background: #ffffff;
        border-bottom: 1px solid #999;
    }
    
    .dropdown .dropdown_content li:hover a {
        color: #222;
        text-decoration: none !important;
      background:#999;
    }
    
    .dropdown input[type="checkbox"]:checked ~ .dropdown_content { display: block }
    
    .dropdown input[type="checkbox"] { display: none }

    Robin W
    Moderator

    @robin-w

    I’ve loaded all that, my display is slightly different, but that will be styling.

    When I click any ‘topic tools’ it’s just the first topic that displays, and this does so in a stacked fashion, so I can only see the first tool.

    However, I played a bit with the loop single reply, and would the following help?

    <div class="dropdown" id="dropdown">
    				<input type="checkbox" id="drop1" />
            <label for="drop1" class="dropdown_button">Topic Tools</label>
    		<?php if (bbp_is_topic(bbp_get_reply_id()) ) { ?>
    		<ul class="dropdown_content">
                <li class="active"></li>
                  <li> <?php echo bbp_get_reply_edit_link(); ?></li>
                  <li><?php echo bbp_get_reply_spam_link(); ?></li>
                  <li><?php echo bbp_get_reply_move_link(); ?></li>
            </ul>
    		<?php } ?>
    		<?php if (bbp_is_reply(bbp_get_reply_id()) ) { ?>
    		<ul class="dropdown_content">
             <li class="active"></li>
    			<li><?php echo bbp_get_reply_spam_link(); ?></li>
                 <li><?php echo bbp_get_reply_move_link(); ?></li>
             </ul>
    		<?php } ?>
            
        </div>

    basically it adds if-topic and if reply choices


    Robkk
    Participant

    @robkk

    basically it adds if-topic and if reply choices

    thank you for this!!! now it displays the right links on the right post type

    When I click any ‘topic tools’ it’s just the first topic that displays

    it works on only the first post type per page for some reason , so the first reply on the second page would also have the ‘topic tools’

    and like i said before i have to probably make a jquery version of this instead of css so it could work on all the posts

    there is still some bugs right now like if i put <?php echo bbp_get_topic_sticky_link(); ?>
    it doesnt work

    also i only named it topic tools cause it was the first thing i thought about , it could be named options or whatever , this dropdown menu is intended to work on all posts.


    Robin W
    Moderator

    @robin-w

    keep going, it’s fun seeing what you are doing !!


    Robkk
    Participant

    @robkk

    posting this here so i dont forget
    if you want to see where i am at , this is basically it

    1 [x] admin links show up in a dropdown menu

    2 [/] admin links work while in the dropdown menu

    3 [] admin links work on every post

    4 [x] different admin links show up depending on post type

    5 [] admin links hover over all objects and is not hidden if all the way right

    6 [x] dropdown menu show links to all users

    7 [] add report content link and ignore user link on reply admin links

    8 [/] and mark as read, report content , ignore user, favorite , and subscribe links to topic admin links

    *2 make topic sticky link and supersticky link do not show up using echo_name_of_link
    *3 only works on first reply
    *5 sidebar covers dropdown menu if floated right by sidebar
    *7 just an enhancement (0/2)
    *8 just an enhancement (3/5)


    Robkk
    Participant

    @robkk

    i got the topic sticky link to show using <?php echo bbp_get_topic_stick_link(); ?>

    i got it the code between the li but it shows both the sticky and supersticky link

    @robin-w is there any arguments that i could use to display 1 link at a time

    all the code that talks about the sticky link is in the 2717 in template.php in includes/topics

    i have a feeling that i could do something with this code on 2774 but idk

    	// Combine the HTML into 1 string
    		$retval = $r['link_before'] . $stick_display . $super_display . $r['link_after'];
    
    		return apply_filters( 'bbp_get_topic_stick_link', $retval, $r );
    	}

    Robkk
    Participant

    @robkk

    1 [x] admin links show up in a dropdown menu

    2 [x] admin links work while in the dropdown menu

    3 [x] admin links work on every post

    4 [x] different admin links show up depending on post type

    5 [x] admin links hover over all objects and is not hidden if all the way right

    6 [x] dropdown menu show links to all users

    7 [/] add report content link and ignore user link on reply admin links

    8 [/] and mark as read, report content , ignore user, favorite , and subscribe links to topic admin links

    *2 cant single out stick , and (to front) to where its on 2 different li
    *3 Fixed with different css code
    *5 used z-index
    *7 only ignore user is left (1/2)
    *8 only ignore user is left (4/5)

    will post code when i fix some css positioning for original bbpress layout


    Robin W
    Moderator

    @robin-w

    greta – glad you’re continuing to get there :-)


    Robkk
    Participant

    @robkk

    what ya talking bout Wilson?

    Greta?? i aint no women!!

    what ya talking bout Wilson??

    jokes aside , yeah but there is some new bug now that i got to fix , if i can think of a better way to explain it better i will post the problem on here

Viewing 25 replies - 1 through 25 (of 32 total)

You must be logged in to reply to this topic.