WordPress.org

Ready to get started?Download WordPress

Forums

.html on PAGES
Works like a charm (1 post)

5 stars
  1. Caspar
    Member
    Posted 1 year ago #

    WordPress 3.5 and .html on PAGES 1.1 worked like a charm for me. I tested in debug mode and didn't get a single warning—hence the 5 stars.

    As a side note: I needed to hack the plugin to output the “.htm” suffix instead of “.html”. Having to do so anyway, I added a (hopefully) unique prefix to all functions and removed the closing PHP tag (?>) at the end of the file for security reasons.

    Here's my final plugin code:

    add_action( 'init', 'pageshtm_html_page_permalink', -1 );
    register_activation_hook( __FILE__, 'pageshtm_active' );
    register_deactivation_hook( __FILE__, 'pageshtm_deactive' );
    
    function pageshtm_html_page_permalink() {
    	global $wp_rewrite;
    	if ( ! strpos( $wp_rewrite->get_page_permastruct(), '.htm' ) )
    		$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.htm';
    }
    add_filter( 'user_trailingslashit', 'pageshtm_no_page_slash', 66, 2 );
    
    function pageshtm_no_page_slash( $string, $type ) {
    	global $wp_rewrite;
    	if ( $wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes==true && $type == 'page' )
    		return untrailingslashit( $string );
    	else
    		return $string;
    }
    
    function pageshtm_active() {
    	global $wp_rewrite;
    	if ( ! strpos( $wp_rewrite->get_page_permastruct(), '.htm' ) )
    		$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.htm';
    
    	$wp_rewrite->flush_rules();
    }
    
    function pageshtm_deactive() {
    	global $wp_rewrite;
    	$wp_rewrite->page_structure = str_replace( '.htm', '',$wp_rewrite->page_structure );
    	$wp_rewrite->flush_rules();
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.