Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 29,451 through 29,475 (of 32,437 total)
  • Author
    Search Results
  • #59563
    fel64
    Member

    Use the port of a pretty cool wp server diagnostics plugin. https://bbpress.org/forums/topic/front-page-takes-50-mysql-queries?replies=15#post-9140

    Just add define( 'SAVEQUERIES', true ); to your config.php and activate this. Then go to View > Page Source and scroll to the bottom to see the diagnostics. (You can ignore all the stuff about queries. Just check out query time, page time, page render time. This tells you about the server bottlenecks.)

    I just checked the numbers on my server, and I had 3.399 once and about twenty minutes later I had 0.436. This sort of thing can vary a lot, especially on shared hosting.

    #51575
    fel64
    Member

    I don’t know which ones you had problems with but it’s worth noting that some automatically echo and some don’t.

    <?php user_profile_link(); ?>

    =

    <?php echo get_user_profile_link(); ?>

    If they’re get_anything then you have to echo them yourself, if they don’t have get_* then it’ll echo on its own.

    [Edit] Also remember most functions don’t need a $user_id passed as parameter but won’t work in this case unless you do pass it.

    #59450
    _ck_
    Participant

    Oh if you are trying to do it from an integrated WordPress you’ll need to do this:

    <?
    if function_exists("get_currentuserinfo") {global $user_ID;}
    else { $user_ID=bb_get_current_user_info( 'id' )}
    if ($user_ID) { echo '<a href="/forums/profile.php?id='.$user_ID.'&tab=favorites">favorites</a>';} ?>

    untested – change /forums/ to whatever your bbpress path is.

    nexlamar
    Member

    Hi!

    For my bbpress I need a check against human spam attacks.

    For this I just need a random generated question in my language (the one that the spammers cannot speak ;) ) and a check if the postet answert is correct. I tried to implement this into register.php, but my checks are ignored by bbpress. Is there anybody who can give me a hint, who maybe works on the same problem?

    I also figured out that I can register twice with the same e-mail adress. How can I check if the adress already exists?

    Thanks for your help,

    Markus

    #51574
    outchy
    Member

    yes, that worked, thank you.

    i’m going through the template-functions.php trying to find how to display the last poster’s username and his/her profile link, as well as the link to the topic itself but the only ones i can get to work are these:

    <?php echo $latestpost->post_text; ?>

    <?php echo $latestpost->poster_id; ?>

    <?php echo $latestpost->post_time; ?>

    any suggestions? :)

    #59539
    Sam Bauers
    Participant

    > Any idea what I could be doing wrong here?

    Are you using the latest trunk or the standard 0.8.2.1 release?

    Latest trunk won’t work with the above code.

    #59537
    howtogeek
    Member

    I activated this plugin, but when I click on the link for “topics i’ve started”, all I get is a white page… looking at a sql trace, it doesn’t appear to be running the code at all.

    Any idea what I could be doing wrong here?

    #59558
    fel64
    Member

    Not a problem as long as you have access to the databases. :) Open phpMyAdmin through your administration panel of your web hosting account, go to your database, open wp_usermeta and then click the ‘Search’ tab. Put into the “search conditions” field user_id = 1 AND meta_key = 'bb_capabilities' (this should be the user_id of your admin account). Edit the (hopefully) one result that comes up, and change the meta_value to a:1:{s:9:"keymaster";b:1;}. Then you should be keymaster.

    #59327
    Sam Bauers
    Participant

    Apache processes rewrite directives in the order they are found.

    First the main Apache config file is used, then (if they are allowed) the .htaccess files are used in the order they are encountered from the root of the website out through the directories until the final directory that contains the file that is being accessed.

    So if you have a page at http://www.example.com/blog/forum, then the order of processing is like:

    Apache config
    |
    +-> /path/to/site/www.example.com/.htaccess
    |
    +-> /path/to/site/www.example.com/blog/.htaccess
    |
    +-> /path/to/site/www.example.com/blog/forum/.htaccess

    So the “blog” rewrite rules will be assessed first. This means that you may want to place your bbPress rewrite rules in the same .htaccess file as your blog rules, before the blog rules, as they are more specific and should be handled first.

    Also, there were some problems with WordPress throwing 404 errors based on what mod_rewrite was doing. This was specifically with version 2.1 I think, so your WordPress may need to be upgraded.

    #49633

    In reply to: Emoticons For bbPress?

    fel64
    Member

    It’s Javascript. PHP files are just like HTML files, and anything outside the <?php ... ?> is treated as HTML. Calling the particular function around that makes it go to that place and then go through and output the HTML (which happens to be JS).

    #59534
    Sam Bauers
    Participant

    > is there a method way to delete a view

    In current trunk…

    bb_deregister_view( $view )

    #59532
    _ck_
    Participant

    Ugh. So that breaks a view things I’ve done.

    I’m waiting for an addition to the plugin svn and I’ll just update there at this point. I also missed checking if the user is logged in, now fixed.

    I don’t run the newest trunk so I don’t have a way to test. Looks like I’ll have to setup a test account and install it again.

    and I just put the finishes on a nice dropdown view box too… :-(

    function views_dropdown() {
    $views_dropdown='<form name="views_dropdown" id="views_dropdown">
    <select size=1 name="views_dropdown_select" onchange="if (this.selectedIndex != 0) {location=this.options[this.selectedIndex].value;}}">
    <option value="#">SHOW ME
    > </option>';
    $views=get_views(); foreach ($views as $view => $title ) {
    $views_dropdown.='<option value="'.get_view_link($view).'">'.$views[$view].'</option>';
    }
    $views_dropdown.='</select></form>'; echo $views_dropdown;
    }

    #59531
    Sam Bauers
    Participant

    You should be aware that views are registered differently in the latest versions in trunk. Views are now constructed using the BB_Query class.

    See the latest Support Forum plugin for a way to use both the new and old, although it is wrapped in a Class in there so the basic idea is:

    if (is_callable('bb_register_view')) { // Build 876+
    $query = <SOME ARRAY ACCEPTABLE TO BB_QUERY>;
    bb_register_view('myview', __('My view name'), $query);
    } else { // Build 214-875
    add_filter('bb_views', 'my_addView');
    add_action('bb_custom_view', 'my_processView');
    }

    #49632

    In reply to: Emoticons For bbPress?

    mazdakam
    Member

    hi again i want to know why the function grin(tag) { is out of php code

    why it need to be out side?

    #59030
    _ck_
    Participant

    Oh figured out how to fix the moderator’s profile, very easy to do when using my additional function – just attached more “where filters”:

    function private_forums_filter_private($where,$prefix=''){
    if (function_exists("private_forums_custom_get_options")) {
    $private_forums = private_forums_custom_get_options('private_forums');
    foreach($private_forums as $forum => $role) {
    if(!private_forums_check_user_access_to_forum($role)) {
    $where.=" AND ".$prefix."forum_id != ".$forum." ";
    }
    }
    }
    return $where;
    }
    add_filter( 'get_latest_topics_where', 'private_forums_filter_private');
    add_filter( 'get_latest_posts_where', 'private_forums_filter_private');
    add_filter( 'get_recent_user_replies_where', 'private_forums_filter_private');
    add_filter( 'get_recent_user_threads_where', 'private_forums_filter_private');

    #59530
    _ck_
    Participant

    Wow I was making it too complicated! Try this…

    I managed to use internal functions but there’s a catch with get_recent_user_replies in that all topic data is not attached properly so I have to run through get_topic to pull all the cache data out again (the only proper way to do it without peeking in the cache directly)

    <?php
    /*
    Plugin Name: my views
    Description: views for a user's topics started and other participated topics
    Plugin URI:
    Author:
    Version: 0.01
    */

    function my_views_filter( $views ) {
    global $views;
    $views['my-topics'] = "Topics I've Started";
    $views['my-posts'] = "Topics I've Participated In";
    return $views;
    }
    add_filter('bb_views', 'my_views_filter');

    function my_views_action( $view ) {
    global $bbdb, $topics, $view_count; $user_id=bb_get_current_user_info( 'id' );
    if ($view=='my-topics') {$topics=get_recent_user_threads($user_id); $view_count = count($topics);}
    if ($view=='my-posts') {
    $posts=get_recent_user_replies($user_id); $topics="";
    foreach ($posts as $post) {$topics[]=get_topic($post->topic_id );}
    $topics=bb_append_meta( $topics, 'topic' );
    $view_count = count($topics);}
    }
    add_action( 'bb_custom_view', 'my_views_action' );

    if (!function_exists(bb_get_view_title)) {
    function bb_get_view_title($title) {
    if (is_view()) {$title = get_view_name(). ' &laquo; ' . bb_get_option( 'name' ); }
    return $title;
    }
    add_filter( 'bb_get_title', 'bb_get_view_title' );
    }

    ?>

    #59476
    mazdakam
    Member

    hummm i am listeing to good news :)

    #59528
    _ck_
    Participant

    I haven’t seen them (doesn’t mean it doesnt exist) but I’ve figured out the framework on how to build and attach a view if you’d like to copy my homework :D

    This is the code I whipped up for “most-views” and “least-views” (which requires the view count plugin to be installed (and inserting the views column in view.php)

    function most_views_views( $views ) {
    global $views;
    $views['most-views'] = 'Topics with the most views';
    return $views;
    }
    add_filter('bb_views', 'most_views_views');

    function least_views_views( $views ) {
    global $views;
    $views['least-views'] = 'Topics with the least views';
    return $views;
    }
    add_filter('bb_views', 'least_views_views');

    function most_views( $view ) {
    global $bbdb, $topics, $view_count;
    if ($view=='most-views') {$sort="DESC";}
    if ($view=='least-views') {$sort="ASC";}
    if ($view=='least-views' || $view=='most-views') {
    $limit = bb_get_option('page_topics');
    $where = apply_filters('get_latest_topics_where','');
    $most_views = $bbdb->get_results("SELECT topic_id FROM $bbdb->topicmeta WHERE meta_key='views' ORDER BY cast(meta_value as UNSIGNED) $sort LIMIT $limit");
    foreach (array_keys($most_views) as $i) {$trans[$most_views[$i]->topic_id] =& $most_views[$i];} $ids = join(',', array_keys($trans));
    $topics ="SELECT * FROM $bbdb->topics WHERE topic_status=0 AND topic_id IN ($ids) $where ORDER BY FIELD(topic_id, $ids)";
    $topics = $bbdb->get_results($topics);
    $view_count = count($topics);
    $topics = bb_append_meta( $topics, 'topic' );
    }
    else {do_action( 'bb_custom_view', $view );}
    }
    add_action( 'bb_custom_view', 'most_views' );

    As you can see a new view requires both 1. an action 2. a filter

    Easy once you’ve seen it, but try figuring it out from scratch!

    This bit adds the title to view pages (missing by default in bbpress)

    function bb_get_view_title($title) {
    if (is_view()) {$title = get_view_name(). ' &laquo; ' . bb_get_option( 'name' ); }
    return $title;
    }
    add_filter( 'bb_get_title', 'bb_get_view_title' );

    #59243
    Sam Bauers
    Participant

    My other option is to make the update check more atomic. Here, your pagination idea could help. So instead of fetching all the plugins, I could just fetch the first page, then the second etc. etc. on request. More complicated to code, but it might be the best long term solution to keep the best of both worlds. I could also add a way to list installed plugins first, or even have a separate view of installed plugins.

    I wouldn’t think Trac is faster, it has a few more overheads on the server side I think. I don’t think it will come down to that though.

    Neither the Trac site nor the SVN repository use compression on their output, so gzip is useless, but that was a good suggestion. I’m not sure the SVN repository could use gzip anyway as it would potentially get in the way of some SVN clients, I’m not sure SVN even supports compression techniques like that (although it probably should).

    #51573
    Sam Bauers
    Participant

    You’ll need to order that query by using ORDER BY post_time DESC. There is no guarantee that the last row of a table is the last row that was added.

    #59474
    _ck_
    Participant

    Auto closing formatting is being worked on by mdawaffe now I believe.

    It’s a single boolean bug (true/false) so I should hope it doesn’t take too long ;-)

    #51572
    outchy
    Member

    ok cool, thank you. it’s doing something so that’s good :)

    this is what i’m using:

    <?php
    $latestpost = $bbdb->get_row("
    SELECT *
    FROM $bbdb->posts
    WHERE post_status = 0
    LIMIT 1
    ");
    ?>

    <?php echo $latestpost->post_text; ?>

    it’s displaying the first post from forum 3 for some reason, not the most recent post. i’ve posted a few new posts since then in other forums and it never changes on the front page, it still shows that first post from that forum 3. any idea how come?

    (thanks for your help on this)

    #51571
    fel64
    Member

    Sure that’s possible. :)

    You want a query that gives you the last post. Forget anything messing around with the forum or the topic. You want the last post, right?

    There’s no API function to do this AFAIK, so you will have to use a query. I think the structure could go something like this:

    $latestpost = $bbdb->get_row("
    SELECT *
    FROM $bbdb->posts
    WHERE post_status = 0
    LIMIT 1
    ");

    And then $latestpost has $latestpost->post_text, poster_id and so on. But unfortunately not filtered, so you’d need to apply all those. Which is a bit nasty.

    But this is all unchecked and unresearched, you’ll need to play around with it. :P All this is is a bare start.

    #51570
    outchy
    Member

    i want to display the most recent post, no matter what forum it happens to be from. is that possible?

    i tried doing what you said but maybe i messed it up because i’m getting a mysql syntax error. here is what i have, forgive me if it looks glaringly stupid:

    <?php
    $forum_id = 1;
    $forum_one_topics = $bbdb->get_row("SELECT * FROM $bbdb->topics WHERE forum_id = $forum_id ORDER BY topic_time DESC ") ?>
    <?php
    $forum_one_topic_posts = get_thread( $forum_one_topics->topic_id); ?>
    Re: <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a>
    <span class="gray">
    <a href="<?php get_user_profile_link( $id = 0, $page = 1 ); ?>">
    <?php echo $forum_one_topics->topic_last_poster_name; ?></a> said:</span> <span class="justify"><?php echo $forum_one_topic_posts[0]->post_text;
    ?></span>

    sorry, i’m really trying to get it :/

    #59500
    refueled
    Member

    @moopress: Thanks for the comments.

    @fel64: Forgot about that sticky-green. Changed it to a temporary color. I was wanting to do something different, that’s why it’s not a fixed width theme. It can always be changed later.

    Thanks again for both of your comments. More are welcome. :-)

Viewing 25 results - 29,451 through 29,475 (of 32,437 total)
Skip to toolbar