Forum Replies Created
-
In reply to: Sticky not staying on top and logos/signs.
A normal sticky is at the top, but only for the forum it’s in.
In reply to: Limit tags to a pre-defined list?Whoops, I need to use more test data next time.
Change:
foreach ($current_tags as $tag_key => $tag ) {
if( in_array( $tag->name, $allowed_tags ) )
unset( $allowed_tags[ $tag_key ] );
}to
$allowed_tags = array_flip( $allowed_tags ); // CHANGE PLACES!
foreach( $current_tags as $tag ) {
if( isset( $allowed_tags[ $tag->name ] ) )
unset( $allowed_tags[ $tag->name ] );
}
$allowed_tags = array_flip( $allowed_tags ); // CHANGE PLACES!The closing
?>
isn’t really important if there’s no non-PHP data after itIn reply to: Sticky not staying on top and logos/signs.There are actually two links when you make a topic a sticky. You need to use the “to front” link for it to be stickied on the frontpage.
In reply to: target=blank in TopicIt’s
target="_blank"
, make sure you have the underscore. Otherwise, got an example? Are you using __ck__’s plugin to add _blank?In reply to: Limit tags to a pre-defined list?<?php
/*
Plugin Name: Restrict Topic Tags
Description: Restricts tags to a pre-defined list.
Author: Kawauso
Version: 0.1
*/
$allowed_tags = array(
'test',
'test2',
);
function restrict_topic_tags_form( $args = null )
{
$defaults = array( 'topic' => 0, 'submit' => __('Add ยป'), 'list_id' => 'tags-list' );
$args = wp_parse_args( $args, $defaults );
extract( $args, EXTR_SKIP );
if ( !$topic = get_topic( get_topic_id( $topic ) ) ) {
return false;
}
if ( !bb_current_user_can( 'edit_tag_by_on', bb_get_current_user_info( 'id' ), $topic->topic_id ) ) {
return false;
}
global $page, $allowed_tags;
$current_tags = bb_get_topic_tags( $topic->topic_id );
foreach ($current_tags as $tag_key => $tag ) {
if( in_array( $tag->name, $allowed_tags ) )
unset( $allowed_tags[ $tag_key ] );
}
if( is_array( $allowed_tags ) && !empty( $allowed_tags ) ) { ?>
<form id="tag-form" method="post" action="<?php bb_uri('tag-add.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" class="add:<?php echo esc_attr( $list_id ); ?>:">
<p>
<select name="tag" id="tag">
<option value=""><?php _e("Select a tag")?></option>
<?php foreach( $allowed_tags as $tag ) { ?>
<option value="<?php echo $tag?>"><?php echo $tag?></option>
<?php } ?>
</select>
<input type="hidden" name="id" value="<?php echo $topic->topic_id; ?>" />
<input type="hidden" name="page" value="<?php echo $page; ?>" />
<?php bb_nonce_field( 'add-tag_' . $topic->topic_id ); ?>
<input type="submit" name="submit" id="tagformsub" value="<?php echo esc_attr( $submit ); ?>" />
</p>
</form>
<?php
} // End if
} // End function
function restrict_topic_tags( $tag ) {
global $allowed_tags;
// if( !in_array( $tag, $allowed_tags ) )
// return array();
return array($tag);
}
add_filter( 'bb_add_topic_tags', 'restrict_topic_tags' );Then in your theme’s
topic-tags.php
, change<?php tag_form(); ?>
to:<?php
if( function_exists( 'restrict_topic_tags_form' ) )
restrict_topic_tags_form();
else
tag_form();
?>In reply to: Admin Link in SidebarThere are template function lists if you Google around, but I don’t know if any are up-to-date for 1.0.2
I think
bb_admin_link()
andget_bb_admin_link()
would do what you’re trying to do.In reply to: How to create easy comment posting?People were asking for something similar to this before:
https://bbpress.org/forums/topic/combined-register-post
Best of luck to you if you manage to get something like that working, I found it a royal pain to bypass the various checks that non-fully registered users can’t pass.
Yep, you have to sanitize yourself, the database objects presume anything they’re passed has been already
In reply to: Put logo in the middle of header.Ah I’d be lazier than that and just put a / in front of images, so it looks for it relative to the base directory
In reply to: Delete the search facility.Add to your theme’s stylesheet:
.search { display: none; }
In reply to: Thanks for everything, Sam!Thanks for some great code Sam
In reply to: hooking a function makes mysql query to return empty$limit was passed something which wasn’t numeric because… I guess that’s what do_action() does when it doesn’t have any arguments? Doing a var_dump(), it appears to be an empty string, so I guess it just passed the default value of the argument variable.
I found it because I noticed the SQL query wasn’t valid when it was run in phpMyAdmin and then noticed that there wasn’t anything after LIMIT.
I don’t know if there’s any performance gain, but it’s how bbPress code is written iirc and in the case of calling the user table, it’s essential when you’re working with a WP/bbP integration (as the table prefix is different).
So mostly it allows for the table names to be entirely variable, which is probably better practice in case a plugin changes them.
In reply to: hooking a function makes mysql query to return emptyWhen I tried this (not using a manual call), it seemed that $limit was being passed something, but it wasn’t numeric. So I added in before the
global
line:if (!is_numeric($limit))
$limit = 5;
I also changed $query_recent_replies to:
$query_recent_replies = "SELECT * FROM $bbdb->topics JOIN $bbdb->posts ON $bbdb->topics.topic_id = $bbdb->posts.topic_id $where ORDER BY post_time DESC LIMIT $limit";
and first echo inside the foreach to:
echo "n<li>". bb_get_profile_link( array( 'id' => $recent_reply->poster_id, 'text' => get_user_display_name( $recent_reply->poster_id ) ) ) . ' on <a href="' . get_topic_link($recent_reply->topic_id);
but that’s more just my idea of cleaner code
<?php bb_profile_link( array( 'id' => get_post_author_id(), 'text' => get_post_author() ) ); ?>
@bbback: you can avoid echoing
get_
functions by dropping theget_
, there’s always an echo alias function@kirpi.it: my bad, I left it using an echo function rather than returning the output
In reply to: bbPress Codex – lolzAny chance bbPress will get a codex proper then?
In reply to: Removing brackets in .adminIn your theme’s topic.php, change
bb_topic_admin();
tobb_topic_admin( array( 'before' => '', 'after' => '' ) );
or to use<li>
instead, putbb_topic_admin( array( 'before' => '<li>', 'after' => '</li>' ) );
and put<ul>
and</ul>
around the <?php tagsIn reply to: how to get gravatar?Your Gravatar seems to display fine on the 2nd link for me
In reply to: WordPress comment on post redirects to bbpress forumIt just goes to http://fitness-passion.com/wp-comments-post.php for me
In reply to: bbPress loading slower than site.Is the site database-based or just HTML?
$wpdb and $bbdb have nice sanitizing functions and caching of results if I remember correctly
https://codex.wordpress.org/Function_Reference/wpdb_Class
They can also be used to retrieve table names for the respective package
You shouldn’t need the separate
<a>
tag, that function should be returning a complete<a>
tag with the text passed to it (or using the ID number if one is given)bb_get_profile_link(post_author()) would probably work
It’s generated by the template
logged-in.php
, which in Kakumei looks like:<p class="login">
<?php printf(__('Welcome, %1$s'), bb_get_profile_link(bb_get_current_user_info( 'name' )));?>
<?php bb_admin_link( 'before= | ' );?>
| <?php bb_logout_link(); ?>
</p>So you’d want
bb_get_profile_link(bb_get_current_user_info( 'name' ))
In reply to: So long and thanks for all the fishAren’t PHP errors hidden by default?
In reply to: Removing brackets in .adminDid you edit your active template or the copy in bb-templates? Only thing I can think of..