Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 9,226 through 9,250 (of 32,523 total)
  • Author
    Search Results
  • #159797

    In reply to: SMF Import to bbPress

    curvemeister
    Participant

    I want to offer this php script in exchange for the help Stephen’s script provided. It ran successfully on my installation, going from SMF 2.0.4 to bbPress 2.5.6 / GD bbPress Attachments 2.2. Most of my time is taken up with consulting, and I regret that I will not be providing much in the way of support for this script.

    This is a stand-alone php script that you must modify to target your SMF install. I suggest using notepad++ to edit for readability, and something like FileZilla to transfer your file to your host. Install and run the script in the root folder of your WordPress folder. I used Putty configured for an SSHconnection. Do not try to run it via http – the script will time out.

    Thanks to Stephen Edgar for providing the original php on which this is based.

    Mike Russell – final result at: http://www.curvemeister.com/forums
    ==============================================================================

    
    <?php
    //Standalone script to import smf attachments for the GD bbPress Attachments plugin
    //Execute after you have imported smf into bbPress
    require( 'wp-load.php' );
    require( 'wp-admin/includes/image.php' );
    
    $verbose = false;
    //$limit = " LIMIT 0,1";
    $limit = " LIMIT 0,99999";
    
    // source database connection
    $host="localhost";
    $uname="xxx";
    $pass="xxx";
    $database = "xxx";
    $site_url = 'http://xxx/forum';
    $forum_path = 'forum/attachments/';
    
    echo "start smf_attachments-to-bbpress\n"; flush();
    
    //get the attachment rows from SMF
    $smf_db = new wpdb($uname, $pass, $database, $host);
    $smf_rows = $smf_db->get_results("
    								SELECT * FROM <code>smf_attachments</code> 
    								WHERE file_hash != '' 
    									AND filename NOT LIKE '%thumb' 
    								ORDER BY <code>id_attach</code>"
    								.$limit);
    								
    echo "processing ".$smf_rows->num_rows." rows total\n";
    
    // process each row
    $count = 0;
    foreach ($smf_rows as $smf_attachment_row) {
    	if($verbose) { echo 'next row, id_attach = '.$smf_attachment_row->id_attach."\n"; flush(); }
    
    	//look for both a new and old style filename.  If neither exists, skip this attachment
    	$smf_filename = $forum_path.$smf_attachment_row->id_attach.'_'.$smf_attachment_row->file_hash;
    	if(!file_exists($smf_filename))
    		$smf_filename = $forum_path.$smf_attachment_row->id_attach.'_'.$smf_attachment_row->filename.$smf_attachment_row->file_hash;
    	
    	if(!file_exists($smf_filename))
    	{
    		echo "no file, skipping attachment for ".$smf_attachment_row->id_attach.", missing SMF file: ".$smf_filename."\n"; flush();
    		continue;
    	}
    	
    	$uploads = wp_upload_dir('SMF');
    	$new_upload_dir = $uploads['path'];
    	$new_full_filename = $new_upload_dir.'/'.$smf_attachment_row->filename;
    	if($verbose) { echo('old->new = '.$smf_filename.' -> '.$new_full_filename."\n"); flush(); }
    	
    	//copy the enclosed file if necessary
    	if(!file_exists($new_full_filename) && !copy($smf_filename, $new_full_filename) ) {
    		echo "cannot copy: ".$smf_filename."->".$new_full_filename."\n";
    	} else {
    		//look for bbPress's previously imported topic or reply for the current attachment
    		$parent_args = array(
    			'post_type' => array('topic', 'reply'),
    			'meta_key' => '_bbp_post_id',
    			'meta_value' => $smf_attachment_row->id_msg
    		);
    		//echo "$parent_args = ".print_r($parent_args)."\n";
    		
    		$parent_query = new WP_Query($parent_args);
    		$parent_query->get_posts();
    		if($verbose) { echo $parent_query->post_count." posts found for smf_post id ".$smf_attachment_row->id_msg."\n"; flush(); }
    
    		//normally only one post references a given enclosure, but handle possible multiples anyway ...
    		while($parent_query->have_posts()) {
    			$parent_query->the_post();
    			$post_id = get_the_ID();
    			$attachment_data = array(
    				'guid' => $uploads['url'] . '/' . basename( $new_full_filename ),
    				'post_mime_type'	=> 'image/'.$smf_attachment_row->fileext,
    				'post_title'		=> $smf_attachment_row->filename,
    				'post_status'		=> null,
    				'post_content'		=> '',
    			);
    			//if($verbose) { echo "attachment_data = ".print_r($attachment_data)."\n"; flush(); }
    			
    			$attach_id = wp_insert_attachment($attachment_data, $new_full_filename, $post_id);
    
    			//echo "attach_id = ".$attach_id."\n"; flush();
    			if($attach_id) {
    				//update_post_meta($attach_id, '_bbp_attachment', 1);
    				if($attach_metadata = wp_generate_attachment_metadata($attach_id, $new_full_filename)) {
    					//echo 'attach_metadata = '.print_r($attach_metadata)."\n"; flush();
    					wp_update_attachment_metadata( $attach_id,  $attach_metadata );
    					set_post_thumbnail( $post_id, $attach_id );				
    				} else {
    					echo 'wp_generate_attachment_metadata failed, fname = '.$new_full_filename."\n"; flush();
    				}
    			}
    			wp_reset_postdata();
    		}
    	}
    	$count++;
    	if($count%100 == 0)
    	{
    		echo $count." attachments processed\r";
    		flush();
    	}
    }
    echo "Done, processed ".$count." records\n\n";
    
    //clean up message body text
    //convert <tt> -> <br />
    mysql_query("UPDATE wp_posts SET post_content = REPLACE (post_content, \'<tt>\', \'<br />\') WHERE post_content LIKE \'%<tt>%\'");
    
    mysql_close($connection);
    exit;
    ?>
    
    #159785

    In reply to: bbPress downgrade?

    Robin W
    Moderator

    No, you’ll need to repeat whatever you did when you originally installed it.

    see

    https://codex.bbpress.org/bbpress-in-your-language/

    #159769
    nolimit966
    Participant

    Ive taken a look at the template.php file to see what id need to implement into my current functions.php breadcrumbs class but im slightly confused.

    From my code above it looks like:
    $output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>'.$output; is only outputting a maximum of 3 ancestors. Is that correct?

    Php really is not my strong point.

    #159756
    mvaneijgen
    Participant

    I still have this problem on the latest bbpress and wordpress. Im trying to embed the shortcode on the feedback-no-search.php so that it displays when there is no search result and the user can ask the question on the forum. For admins it works fine but for non-admins get the message “You cannot create new topics.”

    The fix that @satrya and @robin-w posted also doesn’t work on this version of bbpress, but again thats ia comment from a year ago.

    #159755
    mvaneijgen
    Participant

    I do and admins and moderators will see the form and can work with it, but users/subscribers will see the message “You cannot create new topics.” as described here https://bbpress.org/forums/topic/new-topic-form-shortcode-issue/ a topic from almost 3 years ago.

    I place the shortcode in the search result page if there are no instances found of what they are trying to look for, so they can ask that question on the forums.

    #159754
    Robkk
    Moderator

    id say look at the bbPress breadcrumbs code and copy that and add it to your custom breadcrumbs.

    its in bbpress>includes>common>

    then search breadcrumbs in an editor like notepad++

    #159753
    Robkk
    Moderator

    you probably can replace it with a post count tag that outputs the number of replies in a topic for example.

    i think this is it.

    <?php bbp_topic_post_count ?>

    then output some text after that.

    #159752
    Robkk
    Moderator

    bbPress doesnt output shortcodes use something like this

    https://wordpress.org/plugins/bbpress-do-short-codes/

    Robkk
    Moderator

    you really shouldn’t edit core code…i hope you havent messed something up and now are getting a domino effect of issues.

    you should also contact wp user avatar plugin support just in case too.

    i gotta say email me , so i can double check your setup

    Contact

    im mostly going to ask how you set up your forum and see if i can duplicate the issue.

    #159743
    Robkk
    Moderator

    you can hide them with CSS

    .forum-archive .status-private {
    display:none;
    }
    #159738
    Robkk
    Moderator

    what are you trying to do with the shortcode?

    it should work if you just place [bbp-topic-form] in a page or a sidebar widget like blask studio tinymce widget.

    #159737
    Robkk
    Moderator

    voice count shows how many users are in a particular topic.

    for topics

    you can edit the loop-single-topic.php file by copying it into your child theme and changing the voice count number code to whatever php tag you have from a plugin that has a specific template tag to show a posts like count.

    change <?php bbp_topic_voice_count(); ?> with what you have.

    to edit the label voice in the bbPress header you edit loop-topics.php and change <?php _e( 'Voices', 'bbpress' ); ?> and change it <?php _e( 'Likes', 'bbpress' ); ?>

    for forums

    its close to the same instead look for loop-forums.php and loop-single-forum.php

    and the php code would be similar but instead of topic_ look for forum_

    #159735
    Robkk
    Moderator

    use FTP and copy page.php and rename it to bbpress.php , then remove all the unwanted code like the read more buttn .

    This usually fixes most theme problems.

    https://codex.bbpress.org/theme-compatibility/getting-started-in-modifying-the-main-bbpress-template/

    need anymore help with this reply back , and i will give you a more detailed explaination.

    #159733

    In reply to: blurred avatar

    Robkk
    Moderator

    it is most likely that you tried to make avatars bigger with CSS when they were originally sized to be smaller in the PHP code hence why you would see them blurry because you are basically stretching a small image.

    link to the blurred avatars to double check though on your site.

    #159725
    teamoo
    Participant

    Hey Robin – I appreciate your response but my theme designer gave me some code to make it work.

    http://www.ohio-offroad.com

    For reference, this is the custom CSS we entered:

    /* bbPress WP Tweak plugin left justified text fix 3-13-2015 */
    #sidebar.sidebar-left{ text-align: initial !important; }

    #159722
    Pierre Ledoux
    Participant

    Hello,

    i want to use a widget (bbpress login) and a shortcode ([bbp-lost-pass]).

    But the appearance seems to be broken. The buttons are left. The descriptions are splitted. You can check the issues here:

    forex.die-analysten.com/login/
    forex.die-analysten.com/login/lost-pass/

    how can i fix that?

    Kind Regards
    Pierre

    #159718
    rbrynest
    Participant

    An update on this.

    I got it to work by editing the .htaccess file.

    Add this code block at the start of the file:

    <FilesMatch “^(wp-login|wp-log|index)\.php$”>
    Header set Set-Cookie wordpress_test_cookie=WP+Cookie+check
    </FilesMatch>

    Regards
    Rune

    #159711
    VojtaSvoboda
    Participant

    When I debuged WP_Query in bbpress/includes/topics/template.php on line 203, it prints:

    SELECT SQL_CALC_FOUND_ROWS  wp_2_posts.ID FROM wp_2_posts  INNER JOIN wp_2_postmeta ON ( wp_2_posts.ID = wp_2_postmeta.post_id ) WHERE 1=1  AND wp_2_posts.post_parent = 5080  AND wp_2_posts.post_type = 'post' AND (wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'closed' OR wp_2_posts.post_status = 'private' OR wp_2_posts.post_status = 'hidden') AND ( 
      wp_2_postmeta.meta_key = '_bbp_last_active_time'
    ) GROUP BY wp_2_posts.ID ORDER BY wp_2_postmeta.meta_value DESC LIMIT 0, 15

    with post_type=post, but it should be post_type=topic. Damn.

    #159706
    VojtaSvoboda
    Participant

    When I put

    <div id="bbpress-forums" data-topic-id="<?=bbp_get_topic_id()?>">

    to the template, it prints me: data-topic-id=”0″.

    #159701

    Topic: Forum Headers

    in forum Troubleshooting
    lhughes16
    Participant

    Hi, I have searched high and low for anything on putting in a header for each forum on my site’s board. For instance, I have different forums for the various groups within my organization. I’d like for when a member of a certain group clicks on the group forum, a header or a banner specifically made for that group will be displayed for their section of the board. Anyone have any ideas? Keep in mind I don’t know a lick of code and not really comfortable with manipulating code so if you have any ideas a step by step would be much appreciated. Thanks!

    nolimit966
    Participant

    Hi,

    I had this issue since i very first installed BBpress along with the plugin – WP User Avatar.

    The avatars are not showing in the forum at all. Its a completely bespoke WordPress theme with nothing in the functions.php to be doing any filtering or stripping out extensions of any type.
    Ive also disabled every single plugin except bbpress & the avatars plugin & i still get the problem.

    broken avatars with no extension

    Can anyone please help me overcome this problem?

    I did notice that in the bbpress / filters.php the line which says : add_filter( ‘bbp_get_reply_author_link’, ‘stripslashes’ ); had to be commented out because it was removing the backslashes from the avatar URL making things even worse.

    I dont like the fact ive had to manipulate core code to do this. Surely there has to be a better was to get avatars working.

    Thank you 🙂

    #159685
    Robkk
    Moderator

    last patch says 19months so i wouldnt touch it.

    maybe using a custom last edit log using the two template tags below would work

    https://codex.wordpress.org/Function_Reference/the_modified_date
    https://codex.wordpress.org/Function_Reference/the_modified_author

    #159678
    Robkk
    Moderator

    @dimplefacect

    glad you found the information you needed , the links i should have gave you either of these two

    this one is cut to the chase

    https://codex.bbpress.org/getting-started-with-bbpress/

    and this one is more explanatory and has more steps to help improve your forum.

    Step by step guide to setting up a bbPress forum – Part 1

    if you need anymore guides for bbPress the codex is a great place to look.

    #159677
    butterzeugs
    Participant

    i did it just like you sayed but still no effect 🙁

    maybe some other plugin i have to change the code ?

    #159674
    Robin W
    Moderator

    That code works exactly as described.

    please check that you have exited and re-entered your browser to clear
    that you aren’t running any caching software
    That you have only changed ’40’ to ’80’ and saved and uploaded the change

Viewing 25 results - 9,226 through 9,250 (of 32,523 total)
Skip to toolbar