codejp3 (@codejp3)

Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)

  • codejp3
    Participant

    @codejp3

    @tealcfr – what Robin W suggested is probably your best bet if you need it done immediately.

    Considering that there are plenty of other topics on this very same thing and there’s been a 9 year old ticket for this very thing (https://bbpress.trac.wordpress.org/ticket/2605), your options are limited. A simple and logical approach without any code like Robin suggested above, or custom queries and perhaps some custom code like I suggested before that.

    I’ve taken a look at /includes/converters/bbPress1.php and /includes/classes/class-bbp-converter-base and I think it’s realistic to make a bbPress2.php converter to use within the default bbPress importer (and would also solve the outstanding ticket #2605). If you don’t have the skills to do that, I’d consider doing it as an addition to the bbPress community, but I’d want you (and others) to test it before it gets submitted as a patch. I could have it ready for testing within a week or two. Not a good option if you’re in a rush.


    codejp3
    Participant

    @codejp3

    I will again reiterate, that any conflicting IDs will cause problems and extra steps are required, and like @robin-w said, that also includes user_ids


    codejp3
    Participant

    @codejp3

    I don’t have time to do a detailed answer right now, but what’s wrong mysqldump:
    mysqldump -u db_username -p db_name dbprefix_posts --where="post_type='forum' OR post_type='topic' OR post_type='reply'" > bbp_content.sql

    That will give you a db dump of all forum content.

    Then within phpmyadmin or whatever, doing a select query to get all of the post IDs for that forum content (forums/topics/replies):
    `
    SELECT ID FROM dbprefix_posts WHERE post_type=’forum’ OR post_type=’topic’ OR post_type=’reply’;
    `

    Export that query result from phpmyadmin which should give you a new query similar to this:
    `
    SELECT ID FROM dbprefix_posts WHERE (dbprefix_posts.ID = 5) OR (dbprefix_posts.ID = 8) OR (dbprefix_posts.ID = 11) OR (dbprefix_posts.ID = 43) OR (dbprefix_posts.ID = 86) OR (dbprefix_posts.ID = 87) OR (dbprefix_posts.ID = 88) OR (dbprefix_posts.ID = 89) OR (dbprefix_posts.ID = 91) OR (dbprefix_posts.ID = 92) OR (dbprefix_posts.ID = 93) OR (dbprefix_posts.ID = 94) OR (dbprefix_posts.ID = 95) OR (dbprefix_posts.ID = 96) OR (dbprefix_posts.ID = 97) OR (dbprefix_posts.ID = 98) OR (dbprefix_posts.ID = 99) OR (dbprefix_posts.ID = 100) OR (dbprefix_posts.ID = 110) OR (dbprefix_posts.ID = 111) OR (dbprefix_posts.ID = 112) OR (dbprefix_posts.ID = 114) OR (dbprefix_posts.ID = 115) OR (dbprefix_posts.ID = 116) OR (dbprefix_posts.ID = 117);
    `

    Then you just need to do a little find/replace to re-do the query so that it grabs all of the post_meta for those forum posts (forums/topics/replies).

    find all: dbprefix_posts
    replace with: dbprefix_postmeta

    change the beginning: ‘SELECT ID FROM’
    to: ‘SELECT * FROM’

    then find all remaining: ID
    replace with: post_id

    That will give you a new query ready to dump the post_meta like this:
    `
    SELECT * FROM dbprefix_postmeta WHERE (dbprefix_postmeta.post_id = 5) OR (dbprefix_postmeta.post_id = 8) OR (dbprefix_postmeta.post_id = 11) OR (dbprefix_postmeta.post_id = 43) OR (dbprefix_postmeta.post_id = 86) OR (dbprefix_postmeta.post_id = 87) OR (dbprefix_postmeta.post_id = 88) OR (dbprefix_postmeta.post_id = 89) OR (dbprefix_postmeta.post_id = 91) OR (dbprefix_postmeta.post_id = 92) OR (dbprefix_postmeta.post_id = 93) OR (dbprefix_postmeta.post_id = 94) OR (dbprefix_postmeta.post_id = 95) OR (dbprefix_postmeta.post_id = 96) OR (dbprefix_postmeta.post_id = 97) OR (dbprefix_postmeta.post_id = 98) OR (dbprefix_postmeta.post_id = 99) OR (dbprefix_postmeta.post_id = 100) OR (dbprefix_postmeta.post_id = 110) OR (dbprefix_postmeta.post_id = 111) OR (dbprefix_postmeta.post_id = 112) OR (dbprefix_postmeta.post_id = 114) OR (dbprefix_postmeta.post_id = 115) OR (dbprefix_postmeta.post_id = 116) OR (dbprefix_postmeta.post_id = 117);
    `

    You can then export all of the post_meta as sql dump file(s)

    Then you just have to import those dump files into the new DB, and run the bbPress fixes to re-do counts and stuff like that.

    NOTE: this approach will only work if you’re importing into a fresh DB where there are no posts with the same ID as the old DB. To import into a DB where there are existing/conflicting post IDs, a little extra work would have to be done.

    Like I said, don’t have time to give you a “polished” script to run or anything, but this should point you in the right direction.

    In reply to: TinyMCE for guests?

    codejp3
    Participant

    @codejp3

    Follow-up:

    Apparently this is only a problem on some sites with misconfiguration/other issues, and also for certain browsers.

    I am able to get the TinyMCE editor control buttons to display properly on a fresh test site, and it works well on every common browser.

    The issue at hand is on a specific site with specific issues that need to be dug into a little deeper. It is not an overall bbPress/TinyMCE issue. You can ignore this topic and not post any suggestions (unless you really want to).


    codejp3
    Participant

    @codejp3

    @robin-w or another mod – can you please delete:
    https://bbpress.org/forums/topic/template-in-block-themes/#post-232249 (#post-232249)
    https://bbpress.org/forums/topic/template-in-block-themes/#post-232250 (#post-232250)
    https://bbpress.org/forums/topic/template-in-block-themes/#post-232256 (#post-232256)
    They had issues and take up a lot of wasted space.

    Seriously done this time! No more changes/revisions! It is what it is!

    Posting a much cleaner revision of the code above.

    • This one will work with either the BBPress Style Pack plugin template (looks great!) or the default BBPress template (looks horrible!).
    • It will optionally include the required ‘template-canvas.php’ only if it’s missing.
    • It will also only affect BBPress pages, not the rest of the site.
    • It will also only affect FSE Block themes.
    • If using default BBPress templates, it includes checks for if on forum root index page and loads extras/archive-forum.php (to prevent double-listing of the forum index), and loads extras/page-front-forums.php for “the rest of bbpress” (to prevent “nothing found” errors)
    
    // function to include the wp-includes/template-canvas.php file if needed
    function fse_bbpress_template( $template ) {
    	
    	if ( is_bbpress() ) {
    	
    		$template = ABSPATH . WPINC . '/template-canvas.php';
    		
    	}
    	
    	return $template;
    	
    }
    
    // function to include the bbpress forum template file if needed
    function fse_bbp_theme_compat( $template ) {
    
    	if ( is_bbpress() ) {
    
    		// BBPress Style Pack Plugin Forums Index Template
    		if ( defined( 'BSP_PLUGIN_DIR' ) ) {
    
    			$template = BSP_PLUGIN_DIR . '/templates/bbpress.php';
    
    		} else {
    
    			// Default BBPress
    			// if current page is bbpress forum root page, load archive-forum to prevent double-listing of index
    			if ( isset( get_queried_object()->name ) ) {
    				if ( get_queried_object()->name == 'forum' ) {
    
    					$template = WP_CONTENT_DIR . '/plugins/bbpress/templates/default/extras/archive-forum.php';
    
    				}
    
    			// else, load page-front-forums or the rest of bbpress is broken with empty pages
    			} else {
    
    				$template = WP_CONTENT_DIR . '/plugins/bbpress/templates/default/extras/page-front-forums.php';
    
    			}
    			
    		}
    		
    	}
    	
    	return $template;
    
    }
    
    // main function for handling which theme file needs to be included
    if ( ! function_exists( 'fse_bbpress_support' ) ) {
    	function fse_bbpress_support() {
    		
    		// get current theme dir
    		$theme_dir = get_template_directory();
    
    		/* 
    		* Detect if FSE theme or traditional.
    		* FSE Block themes require a theme.json file.
    		* Use that to check instead of theme name or parent theme name.
    		* Perhaps a better method is available, but this works for now
    		*/ 		
    		if ( file_exists( $theme_dir . '/theme.json' ) ) {
    
    			// include wp-includes/template-canvas.php only if needed
    			if ( !basename( get_page_template() ) == 'template-canvas.php' ) {
    
    				add_filter( 'template_include', 'fse_bbpress_template' );
    
    			}
    
    			// include either the BSP template, or default BBPress template
    			add_filter ( 'bbp_template_include_theme_compat', 'fse_bbp_theme_compat' );
    
    		}
    	
    	}
    }
    add_action( 'after_setup_theme', 'fse_bbpress_support' );
    

    One issue with EVERY default BBPress template is that the header/footer/sidebar are trying to be pulled from template files that don’t exist in block themes. They’re being included, but don’t look right. I’m not sure of the best solution for that, other than to use the BBPress Style Pack Plugin which takes care of that and looks great.


    codejp3
    Participant

    @codejp3

    Using the clues in this topic, this is what I have working for ANY FSE Block theme with the wonderful style-pack plugin:

    
    function fse_bbpress_template( $template ) {
    	$template = ABSPATH . WPINC . '/template-canvas.php';
    	return $template;
    }
    
    function fse_bbp_theme_compat( $template ) {
    	$template= BSP_PLUGIN_DIR.'/templates/bbpress.php';
    	return $template;
    }
    
    if ( ! function_exists( 'fse_bbpress_support' ) ) {
    	function fse_bbpress_support() {
    		// gt current theme dir
    		$theme_dir = get_template_directory();
    
    		// Detect if FSE theme or traditional.
    		// FSE Block themes require a theme.json file.
    		// Use that to check instead of theme name or parent theme name.
    		// Perhaps a better method is available, but this works for now.
    		$fse_theme = false;
    		if ( file_exists( $theme_dir.'/theme.json' ) ) { $fse_theme = true; }
    		
    		if ( !$fse_theme ) { return; }
    		
    		// disabled because it doesn't seem to be needed, regardless of style pack 
    		// $bsp_style_settings_theme_support['twentytwentytwo_activate'] setting
    		// template-canvas.php seems to be included by default
    		
    		//add_filter( 'template_include', 'fse_bbpress_template' );
    		
    		add_filter ( 'bbp_template_include_theme_compat' , 'fse_bbp_theme_compat' );
    	
    	}
    	
    }
    add_action( 'after_setup_theme', 'fse_bbpress_support' );
    

    and this little helper function helped me figure out what template was getting loaded in the first place:

    
    function fse_bbpress_print_template() {
    	if ( is_bbpress() ) {
    		//echo at the bottom of the page visibly
    		echo get_page_template();
    		
    		// or echo the template silently as an HTML comment
    		// echo '<!-- ' . get_page_template() . ' -->';
    	}
    }
    // DISABLE THIS ACTION HOOK AS SOON AS POSSIBLE! DO NOT LEAVE IT ACTIVE WHEN DEBUGGING IS DONE!
    add_action( 'bbp_template_after_forums_loop', 'fse_bbpress_print_template' );
    

    I’ve tried this on a few different FSE Block themes, and BBPress is displaying properly, and the style tweaks from the wonderful Style-Pack plugin are being applied.

    Like I said, it’s working regardless of the $bsp_style_settings_theme_support[‘twentytwentytwo_activate’] setting within the BSP plugin, but it uses the template from the plugin so it would still need to be installed an active, even without any styling tweaks applied.

    It’s not a permanent solution, but perhaps aspects of this could be applied to the BSP plugin, or your own custom solution.

Viewing 6 replies - 1 through 6 (of 6 total)