_ck_ (@_ck_)

Forum Replies Created

Viewing 25 replies - 1,101 through 1,125 (of 2,186 total)

  • _ck_
    Participant

    @_ck_

    Upon further examination, function bb_rating_init() { may need further modifications under bbPress 1.0

    Unfortunately I am unfamiliar with what to do with that query under 1.0 so mdawaffe may have to do it.

    Just a complete guess, you can try changing line #94:

    $query_args = array( 'meta_key' => 'avg_rating', 'order_by' => '0 + tm.meta_value' );

    to

    $query_args = array('object_type'=>'bb_topic', 'meta_key' => 'avg_rating', 'order_by' => '0 + tm.meta_value' );


    _ck_
    Participant

    @_ck_

    Try replacing this line #205

    if ( $topics = (array) $bbdb->get_col("SELECT topic_id FROM $bbdb->topicmeta WHERE meta_key = 'rating'") ) :

    with this one for 1.0 compatibility:

    if ( $topics = (array) $bbdb->get_col("SELECT object_id as topic_id FROM $bbdb->meta WHERE object_type='bb_topic' AND meta_key='rating'") ) :

    and use the admin menu to do a recount of ratings.


    _ck_
    Participant

    @_ck_

    You can work around this problem by doing a scan of the $forums global before entering the main loop and checking the “rank” or “type” of forum for each listing.

    In fact you can replace the loop entirely with your own routine, as long as you global $forum you can set the $forum to any which one you want and the internal functions will still work.

    So essentially do a pre-loop through the forums, build your own array of how you’d like the output, and then do the main loop to output the forums in the order/design that you’d like. Just be sure to set $forum to the current forum you are working with before calling any of the forum functions.

    ps. You *can* access

    $bb_forums_loop->first_child
    $bb_forums_loop->last_child
    $bb_forums_loop->bb_root

    if you wish. Just do a global $bb_forums_loop; outside of the loop, then inside the loop they are available to you.


    _ck_
    Participant

    @_ck_

    Actually, the way categories are done in bbPress is in part done for backward plugin compatibility with 0.9 (which will likely be around quite awhile, at least a year, due to it’s performance over 1.0)

    And the way it works is just fine too – just because you don’t immediately see the solution you want to breakdown the categories before or after the loop, doesn’t mean it’s not there. bbPress 1.0 truly does understand that a forum is a parent of another and if it’s a category holder for it – the data is just not presented outside of loop form because no-one has needed/asked for it yet. Very easy to write a plugin to present the forum data any way you’d like, and using a single carefully crafted mysql query, you can literally walk the reverse chain of post->topic->forum->category.

    If you want forums broken down into categories with say three categories and three tables, either write a plugin or do it in the template to build a new array of $forums[1], $forums[2] etc. But don’t change the original way bbPress works to return $forums as all the forums or it will break existing plugins.

    These kinds of feature growing pains were also present in WordPress, I can assure you – I’ve been using WP since 1.5 and I really long for the good old days of 2.0-2.1. The problem is that big leaps tend to break big things, or make them overly complex. WordPress 2.7 is a perfect example of things going very, very wrong with care towards backward compatibility and massive feature bloat, even worse than the 2.3 cookies and tags changes.

    bbPress 1.0 is getting more things right from the start than WordPress did – cookies, tags, object cache, are all the more advanced methods right off and will save some headaches for plugin developers down the road (not so much for us 0.9 plugin developers).

    Everyone has a different view of what’s missing in bbPress – from my standpoint the two biggest problems are 1. search sucks (so does WordPress’s after half a decade still) and 2. the ability to move posts between topics really needs to be done in the core asap so plugins know how to deal with moving targets.

    ps. it’s “her” plugins not “his” ;-)

    pps. you should be impressed how easy it was to make the topic/forum row affected instead of the title in Unread Posts – I can’t think of any other software that would be so easy. Hidden Forums is another example of the power of bbPress’s filter design.

    In reply to: reCAPTCHA for bbPress

    _ck_
    Participant

    @_ck_

    Just out of curiosity, what happens if recaptcha.net is down or gets hit by a ddos attack? Do thousands of sites that rely on them suddenly stop being able to register people?

    I need to upgrade my Human Test so it doesn’t rely on sessions and then it should be even more useful for a completely local solution.


    _ck_
    Participant

    @_ck_

    User rights is stored in usermeta not the main user tables.

    You were actually the keymaster, not the admin, which is higher.

    If you are user #1, try my fix admin access plugin to fix it.

    https://bbpress.org/plugins/topic/fix-admin-access/

    In reply to: reCAPTCHA for bbPress

    _ck_
    Participant

    @_ck_

    dchest don’t worry about the double submission, mdawaffe will figure it out when he gets a chance to check the requests (he does it about once a week)

    You don’t have to post the whole readme in there. In fact anything you put there is only seen by mdawaffe and then it gets replaced automatically when you upload a readme.txt file.

    update: well that was fast, he just added you to the svn


    _ck_
    Participant

    @_ck_

    You could easily turn this into a more standardized script by starting the code with require('./bb-load.php'); to load the bbPress code and check user authorization, and then if (!bb_current_user_can(administrate)) {exit;}

    The mysql_query( would become $bbdb->query( and you’d have to do a global $bbdb; once at the top too. Just for completeness you might want to look at some of the functions in bb-do-counts.php in bb-admin.

    Actually it would be fairly easy to turn it into a full blown plugin for the admin menu.


    _ck_
    Participant

    @_ck_

    It might be possible to create the MediaWiki cookie from the bbPress side and visa versa.

    From the mediawiki side, you could do something as simple as

    require('./bb-load.php');
    wp_set_auth_cookie( (int) $user_id,0 );

    Which will create the bbPress cookie. Where $user_id is the user’s bbPress id. Since you are using the same user table, it should be available?


    _ck_
    Participant

    @_ck_

    You want Forum Categories.

    It’s built in on 1.0

    If you are using 0.9 you need this plugin:

    https://bbpress.org/plugins/topic/forum-is-category/


    _ck_
    Participant

    @_ck_

    Unfortunately there’s little bbPress documentation right for developers. It’s very much like WordPress however, just different hooks (do_action, do_filter).

    There’s no official list of functions but some people have generated xrefs for it, example:

    http://phpxref.ftwr.co.uk/bbpress/nav.html?index.html

    (unofficial)

    I keep a database reference here:

    http://bbshowcase.org/reference/

    but it’s a little out of date for 1.0 alpha

    To upload your plugin into the extend area, first you have to request a “slot” under Extend->add your plugin

    https://bbpress.org/plugins/requests/

    Then you’ll get an email when it’s approved in a few days (mdawaffe is distracted these days, it can take 1-5 days on average) Then you need to learn how to use SVN to upload your files into the system.

    The steps are the same as for WordPress and here’s a good guide:

    http://www.binarymoon.co.uk/2008/01/wordpress-plugin-subversion-guide/

    only the svn url is different

    https://plugins-svn.bbpress.org/


    _ck_
    Participant

    @_ck_

    By the way, I have no idea how many characters there are in the alphabets you are trying to order, but if the number is not too crazy, in theory you could make a string of the alphabetical character order you want (single characters in a row) and then write your own sort routine to sort based on the example string you give it. The sort won’t be as fast as the built in ones in PHP but you’ll get the order you want.

    If the problem is just different languages getting mixed up, what you could do is break up the tag array into multiple arrays of the different languages sets, sort each language, and then build a resulting array of appending one language array to the other, instead of sorting/mixing them together.

    I do some fancy things with the hot tag list too and what I do is cache the final result to disk instead of generating it each and every time. When a new tag is added I just delete the cache and have it regenerate. Depending on how slow your sort is, you could use that approach, but first see if you can get the sort working.


    _ck_
    Participant

    @_ck_

    Any guide that is for WordPress plugins should work for bbPress, it’s just that bbPress’s “hooks” (do_action, do_filter) will be named differently.

    bbPress is unfortunately too young to have decent documentation yet. WordPress itself didn’t really “take off” until 2.0 beta came out.

    This is essentially the plugin framework you need:

    <?php
    /*
    Plugin Name: My Tag Sort
    */
    remove_filter('sort_tag_heat_map', 'bb_sort_tag_heat_map');
    add_filter('sort_tag_heat_map', 'my_sort_tag_heat_map');

    function my_sort_tag_heat_map( &$tag_counts ) {
    // put your replacement code here
    }
    ?>

    Save it as my-tag-sort.php, put it into the bbpress/my-plugins folder, activate and you’re in business (well after you figure out the sort method).

    Typically you’d have to do a return $tag_counts; at the end of a filter but that & on the &$tag_counts means it’s “passed by refererence” which is a fancy way of using the original array directly without making a copy, so the original is changed at the source when you modify it. It’s a much faster way to move large amounts of info around.


    _ck_
    Participant

    @_ck_

    bbPress uses the same concept as WordPress with add_filter and add_action so there are many guides out there as to how it works.

    Essentially it’s a “hook” that allows you to intercept the process or results. The first part of the add_action/add_filter is the process name or trigger, the second part the the name of the function you want to process at that moment.

    If there are existing filters/actions in place you can unhook them with remove_action or remove_filter.


    _ck_
    Participant

    @_ck_

    WordPress allows you to make links, go to manage->links under your control panel. Make the link /forums/ if that’s the path to your forums.

    There are also wordpress plugins to make menu bars, optionally you could use that and put a few primary site links in there, including one to your forums.

    Technically if you wanted to place a link more prominently under your pages section, you could actually create a page for the forums and then use the rewriterules in your .htaccess to redirect the user to the actual forums.


    _ck_
    Participant

    @_ck_

    It should work with both 0.9 and 1.0, what kind of trouble were you having?

    MediaWiki is tricky indeed. I looked at installing it for a minute and gave up another minute later.


    _ck_
    Participant

    @_ck_

    I believe 1.0 specifically has some abilities to address such a desire but I am unfamiliar with them. Sam might know.


    _ck_
    Participant

    @_ck_

    TrishaM, if you are using bb-tweaks.php you can just add the above code to the bottom of it and disable the target_blank filter. But it will work either way.

    lstelie, there is another problem with using javascript as it increases the amount of time before the page is ready. If you are going to throw in rel=”external” you might as well do target. (In fact, you don’t even need rel=”external” as you can scan the domain for each link with javascript on the fly.) But I assure you that target will be supported in browsers ten years from now, maybe even twenty. People who insist on perfect validation need to find more productive things to do with their time, there’s alot of code out there that needs to be written! ;-)

    Throw off the shackles of validation!

    (I need that as a bumper sticker)


    _ck_
    Participant

    @_ck_

    It uses the action

    do_action_ref_array( 'sort_tag_heat_map', array(&$counts) );

    which looks like

    function bb_sort_tag_heat_map( &$tag_counts ) {
    uksort($tag_counts, 'strnatcasecmp');
    }

    So it was designed to be replaced fortunately.

    First to have to unhook the existing action in your plugin:

    remove_filter('sort_tag_heat_map', 'bb_sort_tag_heat_map');

    Then put in your replacement

    add_filter('sort_tag_heat_map', 'my_sort_tag_heat_map');

    function my_sort_tag_heat_map( &$tag_counts ) {
    // put your replacement code here
    }

    According to this, it’s supposed to support your locale, but there is a bug:

    http://us.php.net/strnatcasecmp


    _ck_
    Participant

    @_ck_

    Okay this one is testing working.

    For anyone else that wants to use this, you have to replace the domain name by hand. It’s hardcoded for speed, sorry.

    All other target=”_blank” plugins should be uninstalled. Any existing links with target=”_blank” will be left in place for performance since target is not added by bbPress by default.

    <?php
    /*
    Plugin Name: Target Nofollow External Only
    Description: append target="_blank" and rel="nofollow" only on external links
    Plugin URI:
    Author: _ck_
    Version: 0.0.1
    */

    add_filter('post_text', 'target_nofollow_external_only',999); // unfortunately we have to do this on every page load and not in pre_post

    function target_nofollow_external_only( $text ) {
    $domain="travel-writers-exchange.com"; // domain to exclude from target and nofollow
    $text = preg_replace('|<a (.*)rel=['"]nofollow['"](.+)?>|iU','<a $1$2>', $text); // strip ALL nofollow
    $text = preg_replace('|<a (?=([^>]+http://))(?!([^>]+'.$domain.'))(.+)>|iU', '<a $3 rel="nofollow" target="_blank">', $text); // add back in when needed
    return $text;
    }
    ?>

    I’m not happy about the performance of this technique because it has to be done in post_text for every time a page is displayed, but there’s no other easy way around bbPress/WordPress’s unfortunate use of make_clickable with hardcoded “nofollow” in post_text.


    _ck_
    Participant

    @_ck_

    Okay I’ll play with it some more and see what I can do.

    update: the problem lies within make_clickable which has nofollow hard coded and impossible to “unfilter” at that level

    I’ll have to come up with a way to do it at display time and cleanup the mess bbpress (actually wordpress functions) create

    In reply to: Moving posts

    _ck_
    Participant

    @_ck_

    Moving topics is of course built in.

    Moving posts should not be done even though there is an old plugin to do so.

    The reason for this is because bbPress has no internal hooks to “announce” a post is being moved and it will break plugins that track data and count on posts remaining in their original topics. It can eventually cause some corruption.

    If you don’t use plugins or don’t care about corruption, the old move-it plugin may do what you want, but strongly consider the warning.

    In reply to: Customize Topic Labels

    _ck_
    Participant

    @_ck_

    You don’t have to hack anything, it’s done via a filter.

    ie.

    add_filter('bb_topic_labels', 'bb_closed_label', 10);
    add_filter('bb_topic_labels', 'bb_sticky_label', 20);

    simply remove the filter via a plugin and replace it with your own routine.

    remove_filter('bb_topic_labels', 'bb_closed_label');
    add_filter('bb_topic_labels', 'my_closed_label');
    function my_closed_label( $label ) {
    global $topic;
    if ( '0' === $topic->topic_open )
    return sprintf(__('[Read Only] %s'), $label);
    return $label;
    }


    _ck_
    Participant

    @_ck_

    bb-attachments lets you upload an image and it inserts a simple bbcode for you automatically


    _ck_
    Participant

    @_ck_

    Well we could cheat and make the plugin skip links that have your domain name or no http:// in it.

    function bb_target_blank( $text ) {
    $text = preg_replace('|<a (?=http://)(?!travel-writers-exchange.com)(.+?)>|i', '<a $3 rel="nofollow" target="_blank">', $text);
    return $text;
    }

    This is untested.

    It’s a fancy regex feature called negative lookahead.

    Try it and see what happens.

    Doing nofollow for only externals is essentially the same thing, I’ve added it to the replacement above.Make sure you have no additional tweaks for nofollow. I don’t think it’s on by default? If so, try

    remove_filter('post_text', 'bb_rel_nofollow');
    remove_filter('pre_post', 'bb_rel_nofollow');

Viewing 25 replies - 1,101 through 1,125 (of 2,186 total)