Support » Plugin: WordPress Page Builder - Beaver Builder » Fix Suggestion: Do not fallback to page.php if single cpt template exists

  • Hi Beaver Builder Team,
    Here’s a fix that I think is useful.

    In beaver builder, it’s using priority 999 to always use page.php template if exists to edit the existing templates.
    But it’s possible that this page.php template is not really suitable for this, and no way theme can create separate templates even though single-fl-builder-template.php exists in theme, it’s pointless.

    Here’s the fix:

    IN bb-plugin/extensions/fl-builder-user-templates/classes-class-fl-builder-user-templates.php

    Current code:

    
    	/**
    	 * Trys to load page.php for editing a builder template.
    	 *
    	 * @since 1.0
    	 * @param string $template The current template to be loaded.
    	 * @return string
    	 */
    	static public function template_include( $template ) {
    		global $post;
    
    		if ( 'string' == gettype( $template ) && $post && 'fl-builder-template' == $post->post_type ) {
    
    			$page = locate_template( array( 'page.php' ) );
    
    			if ( ! empty( $page ) ) {
    				return $page;
    			}
    		}
    
    		return $template;
    	}
    

    Fix:

    
    	/**
    	 * Trys to load page.php for editing a builder template.
    	 *
    	 * @since 1.0
    	 * @param string $template The current template to be loaded.
    	 * @return string
    	 */
    	static public function template_include( $template ) {
    		global $post;
    
    		if ( 'string' == gettype( $template ) && $post && 'fl-builder-template' == $post->post_type ) {
    
    			$page = locate_template( array( 'single-fl-builder-template.php', 'page.php' ) );
    
    			if ( ! empty( $page ) ) {
    				return $page;
    			}
    		}
    
    		return $template;
    	}
    
Viewing 1 replies (of 1 total)
  • Plugin Contributor Ben Carlo

    (@hinampaksh)

    Hey @turtlepod,

    Thanks for the suggestion! We’ll definitely keep it in mind. If we receive more requests/tickets about this feature or something close to it from the community we’ll certainly implement it. 🙂

    Ben

Viewing 1 replies (of 1 total)
  • The topic ‘Fix Suggestion: Do not fallback to page.php if single cpt template exists’ is closed to new replies.