Skip to content

Commit

Permalink
Fixed editor templates not loading in some server configurations. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kobizz committed Nov 8, 2017
1 parent fe4dad8 commit 13deeb9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion core/settings/base/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function add_settings_css_rules( CSS_File $css_file ) {
}

public function on_elementor_init() {
Plugin::$instance->editor->add_editor_template( $this->get_editor_template() );
Plugin::$instance->editor->add_editor_template( $this->get_editor_template(), 'text' );
}

/**
Expand Down
47 changes: 26 additions & 21 deletions includes/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function init( $die = true ) {
return;
}

$this->init_editor_templates();

// Send MIME Type header like WP admin-header.
@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );

Expand Down Expand Up @@ -598,10 +596,20 @@ public function editor_head_trigger() {
/**
* @since 1.0.0
* @access public
* @param string $template_path - Can be either a link to template file or template HTML content
*
* @param string $template - Can be either a link to template file or template HTML content
* @param string $type Optional. Whether to handle the template as path or text
*/
public function add_editor_template( $template_path ) {
$this->_editor_templates[] = $template_path;
public function add_editor_template( $template, $type = 'path' ) {
if ( 'path' === $type ) {
ob_start();

include $template;

$template = ob_get_clean();
}

$this->_editor_templates[] = $template;
}

/**
Expand All @@ -617,16 +625,10 @@ public function wp_footer() {

$plugin->schemes_manager->print_schemes_templates();

$abs_path = str_replace( '\\', '/', ABSPATH );
$this->init_editor_templates();

foreach ( $this->_editor_templates as $editor_template ) {
$template_abs_path = str_replace( '\\', '/', substr( $editor_template, 0, strlen( ABSPATH ) ) );

if ( $template_abs_path === $abs_path ) {
include $editor_template;
} else {
echo $editor_template;
}
echo $editor_template;
}

do_action( 'elementor/editor/footer' );
Expand Down Expand Up @@ -655,13 +657,16 @@ public function __construct() {
* @access private
*/
private function init_editor_templates() {
// It can be filled from plugins
$this->_editor_templates = array_merge( $this->_editor_templates, [
__DIR__ . '/editor-templates/global.php',
__DIR__ . '/editor-templates/panel.php',
__DIR__ . '/editor-templates/panel-elements.php',
__DIR__ . '/editor-templates/repeater.php',
__DIR__ . '/editor-templates/templates.php',
] );
$template_names = [
'global',
'panel',
'panel-elements',
'repeater',
'templates',
];

foreach ( $template_names as $template_name ) {
$this->add_editor_template( __DIR__ . "/editor-templates/$template_name.php" );
}
}
}

0 comments on commit 13deeb9

Please sign in to comment.