Skip to content

Commit 195dc6f

Browse files
authored
Merge pull request #151 from BoldGrid/issue-150
Temp workaround for issue-150
2 parents 679ff9f + eea69c8 commit 195dc6f

File tree

3 files changed

+39
-19
lines changed

3 files changed

+39
-19
lines changed

assets/js/gutenblock.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
* Create the div container, add an overlay so the user can interact
175175
* with the form in Gutenberg, then render the iframe with form
176176
*/
177-
if( '' === formID ) {
177+
if ( '' === formID ) {
178178
children.push( el( 'div', {style : {width: '100%'}},
179179
el( 'img', { className: 'weforms-block-logo', src: weFormsBlock.block_logo}),
180180
el ( 'div', null, 'weForms Forms'),
@@ -184,7 +184,7 @@
184184
children.push(
185185
el( 'div', { className: 'weforms-iframe-container' },
186186
el( 'div', { className: 'weforms-iframe-overlay' } ),
187-
el( 'iframe', { src: weFormsBlock.siteUrl + '?weforms_preview=1&weforms_iframe&form_id=' + formID, height: '0', width: '500', scrolling: 'no' })
187+
el( 'iframe', { src: weFormsBlock.siteUrl + '/?weforms_preview=1&weforms_iframe&form_id=' + formID, height: '0', width: '500', scrolling: 'no' })
188188
)
189189
)
190190
}

includes/admin/class-gutenblock.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ public function weforms_form_block() {
5757
];
5858
}
5959

60-
$block_logo = WEFORMS_ASSET_URI . '/images/icon-weforms.png';
61-
$thumbnail_logo = WEFORMS_ASSET_URI . '/images/icon-weforms.png';
62-
63-
wp_localize_script( 'weforms-forms-block', 'weFormsBlock', [
64-
'forms' => $forms,
65-
'siteUrl' => get_home_url(),
66-
'block_logo' => $block_logo,
67-
'thumbnail_logo' => $thumbnail_logo,
68-
] );
60+
$block_logo = WEFORMS_ASSET_URI . '/images/icon-weforms.png';
61+
$thumbnail_logo = WEFORMS_ASSET_URI . '/images/icon-weforms.png';
62+
63+
wp_localize_script( 'weforms-forms-block', 'weFormsBlock', array(
64+
'forms' => $forms,
65+
'siteUrl' => get_home_url(),
66+
'block_logo' => $block_logo,
67+
'thumbnail_logo' => $thumbnail_logo,
68+
'did_wp_head_run' => $did_wp_head_run,
69+
) );
6970
wp_enqueue_style( 'weforms-forms-block-style' );
7071
wp_enqueue_style( 'weforms-forms-block-editor' );
7172
}

includes/class-form-preview.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ public function __construct() {
6161
$this->form_id = isset( $_GET['form_id'] ) ? intval( $_GET['form_id'] ) : 0;
6262
}
6363

64-
add_action( 'pre_get_posts', [ $this, 'pre_get_posts' ] );
65-
add_filter( 'template_include', [ $this, 'template_include' ] );
66-
67-
add_filter( 'the_title', [ $this, 'the_title' ] );
68-
add_filter( 'the_content', [ $this, 'the_content' ] );
69-
add_filter( 'get_the_excerpt', [ $this, 'the_content' ] );
64+
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
65+
add_filter( 'the_title', array( $this, 'the_title' ) );
66+
add_filter( 'the_content', array( $this, 'the_content' ) );
67+
add_filter( 'get_the_excerpt', array( $this, 'the_content' ) );
68+
add_filter( 'home_template_hierarchy', array( $this, 'use_page_template_hierarchy' ) );
69+
add_filter( 'frontpage_template_hierarchy', array( $this, 'use_page_template_hierarchy' ) );
7070
add_filter( 'post_thumbnail_html', '__return_empty_string' );
7171
}
7272

@@ -129,12 +129,31 @@ public function pre_get_posts( $query ) {
129129
}
130130
}
131131

132+
133+
/**
134+
* Use page template types.
135+
*
136+
* Instead of just locating one page template with the highest priority,
137+
* we are going to look for any page template that matches 'page.php', 'single.php' or 'index.php'.
138+
* This resolves issues with Block Based themes that do not have a index.php.
139+
*
140+
* @since 1.6.12
141+
* @param array $templates The list of templates in descending order of priority from WordPress.
142+
*
143+
* @return array
144+
*/
145+
public function use_page_template_hierarchy( $templates ) {
146+
147+
return array( 'page.php', 'single.php', 'index.php' );
148+
}
132149
/**
133150
* Limit the page templates to singular pages only
134151
*
152+
* @deprecated 1.6.11
135153
* @return string
136154
*/
137-
public function template_include() {
138-
return locate_template( [ 'page.php', 'single.php', 'index.php' ] );
155+
public function template_include( ) {
156+
_deprecated_function( __METHOD__, 'WeForms 1.6.11' );
157+
return locate_template( array( 'page.php', 'single.php', 'index.php' ) );
139158
}
140159
}

0 commit comments

Comments
 (0)