Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 29,526 through 29,550 (of 32,499 total)
  • Author
    Search Results
  • #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. :-)

    #51569
    fel64
    Member

    $forum_one_topics is not an array which is why it’s failing (although I’m surprised it’s not).

    Do you actually want the 1 latest topic from forum 1? Then use $bbdb->get_row() instead of get_results() and stop treating it as an array (basically, just take out the foreach part since you don’t have several, and replace $topic with $forum_one_topics).

    If you want all the topics from forum one, then take out the LIMIT 0, 1 bit from the query which as I understand it would give you only one result.

    Also, you have some malformed HTML just under span gray.

    #59520

    In reply to: subforums and markup

    fel64
    Member

    fel64, the string is internal to bbpress, not the template loop.

    Fair enough, shoulda checked that. So I went and looked through the code, you know, to find the problem. bb has quite an interesting structure there. Couldn’t find the problem, though, so I looked at the code in the .8.2.1 version and it’s missing a bit.

    It’s fixed in trunk. Claire, upgrade to the latest version and it’ll work just fine.

    #51568
    outchy
    Member

    sure, here is line 13:

    foreach($forum_one_topics as $topic) :

    and here is the surrounding stuff:

    <h2><?php _e('Latest Post'); ?></h2>

    <?php
    $forum_id = 1;
    $forum_one_topics = $bbdb->get_results("SELECT * FROM $bbdb->topics WHERE forum_id = $forum_id ORDER BY topic_time DESC LIMIT 0,1") ?>
    <?php
    foreach($forum_one_topics as $topic) :
    $forum_one_topic_posts = get_thread( $topic->topic_id); ?>
    Re: <a>"><?php topic_title(); ?></a>

    <span class="gray">
    <a>">
    <?php echo $topic->topic_last_poster_name; ?></a> said:</span> <span class="justify"><?php echo $forum_one_topic_posts[0]->post_text;
    endforeach;
    ?></span>

    #59432
    _ck_
    Participant

    fel64, the string is internal to bbpress, not the template loop.

    Look at forum.php template to remind yourself

    <?php while ( bb_forum() ) : ?>
    <tr<?php bb_forum_class(); ?>>

    $forum is being treated as a global and not reset back.

    I could remember and reset $forum I guess before and after the while-loop $temp=$forum; loop-here; $forum=$temp; but that’s an ugly hack. It’s got to be fixed in the core and that’s beyond my knowledge of bbpress.

    #59516

    In reply to: subforums and markup

    _ck_
    Participant

    fel64, the string is internal to bbpress, not the template loop.

    Look at forum.php template to remind yourself

    <?php while ( bb_forum() ) : ?>
    <tr<?php bb_forum_class(); ?>>

    $forum is being treated as a global and not reset back.

    I could remember and reset $forum I guess before and after the while-loop $temp=$forum; loop-here; $forum=$temp; but that’s an ugly hack. It’s got to be fixed in the core and that’s beyond my knowledge of bbpress.

    #59513

    In reply to: subforums and markup

    fel64
    Member

    Yup. Just don’t display the forum if $forum->forum_parent is true. Change the bit in your templates that goes like this:

    <?php foreach( $forums as $forum ) : ?>
    //blaaaaah HTML
    <?php endforeach; ?>

    to this sort of thing:

    <?php foreach( $forums as $forum ) :
    if( !$forum->forum_parent ) { ?>
    //blaaaaaah HTML
    <?php }
    enforeach; ?>

    (ugh colon syntax)

    [Edit] Beat me to it ck (by the way, blockquote is already allowed and you’re overwriting it. Doesn’t really matter but could add conflict problems if someone wants to allow it to have attributes). Claire, worth mentioning that this method means it will ignore any subforums without you having to tell it it’s a subforum.

    Claire, markup is like this:

    <anytag> your text here </anytag>

    so actually HTML tags go between < and >. Actual code, like php code, will be shown as code if you put backticks around it. :)

    You can also use a simplified markup like http://www.loinhead.net/files/felise (just copy that into a plugin file and activate), which means that *this* is bold, _this_ italic and this@someurl turns into <a href="someurl">this</a>, etc. More on that https://bbpress.org/forums/topic/markdown?replies=10

    #59512

    In reply to: subforums and markup

    _ck_
    Participant

    If you are trying to use <b> instead of “strong” it won’t work because it’s not the “leet” xhtml standard that bbpress wants to enforce. But you can trick bbpress to allow it with this tweak:

    function allow_extra_tags( $tags ) {
    $tags['del'] = array();
    $tags['strike'] = array();
    $tags['s'] = array();
    $tags['b'] = array();
    $tags['i'] = array();
    $tags['u'] = array();
    $tags['bq'] = array();
    $tags['blockquote'] = array();
    $tags['pre'] = array();
    $tags['hr'] = array();
    return $tags;
    }
    add_filter( 'bb_allowed_tags', 'allow_extra_tags' );

    note as you can see I allow other tags too

    #59511

    In reply to: subforums and markup

    _ck_
    Participant

    If you mean so topics in sub-forums do not show up on “latest discussions” I whipped this up to solve that:

    function filter_front_page_topics($where){
    // $exclude_forums=array ("8"); // enable this to manually specify specific forums by id #
    $forums = get_forums(); foreach ($forums as $forum) {if ($forum->forum_parent) {$exclude_forums[]=$forum->forum_id;}} // exclude ALL sub-forums
    if ( is_front()) {foreach($exclude_forums as $forum) { $where.=" AND forum_id != ".$forum." "; }}
    return $where;
    }
    add_filter( 'get_latest_topics_where', 'filter_front_page_topics');
    add_filter( 'get_latest_posts_where', 'filter_front_page_topics');

    #59498
    moopress
    Member

    this is nice. good job. keep working ;)

    Dont have any suggestion sorry :P

    #59468
    fel64
    Member

    No-one knows anything about writing plugins when they start writing them. :) You said you were learning PHP, this is your chance to put it into practice/get better. This might not work but it’s the basic way you’d go about it I think.

    add_action('register_user', 'myfunctiontochangeuserstatuswhentheyregisterheh');

    function myfunctiontochangeuserstatuswhentheyregisterheh( $user_id ) {
    //I suspect somethin' like this:
    $user = get_user( $user_id );
    $user->set_role('inactive');
    }

    #54848

    In reply to: file attachments….

    mazdakam
    Member

    :) Listen!

    i know the way of bbpress minimalistic design and minimalistic develop so

    we need attachment feature for our support to wp users sometimes they need to upload their file to show and share them it comes form my experience now lets gather to make attachment plugin :) something like wp attachment any ideas?

    #58906
    mazdakam
    Member

    ha ha i agree with _ck_ i also trasnlated favorite to subscribe (peygiri – پیگیری) :) it is much better

    #51565
    fel64
    Member

    $topic->topic_last_poster is the ID of the last poster to the topic. user_profile_link( $user_id ) echoes the url of the user’s profile. You’d do something like this I think:

    <a href="<?php user_profile_link( $topic->topic_last_poster ); ?>"><?php echo $topic->topic_last_poster_name; ?></a>

Viewing 25 results - 29,526 through 29,550 (of 32,499 total)
Skip to toolbar