Skip to content

Commit

Permalink
Fix documents query [TMZ-74]
Browse files Browse the repository at this point in the history
  • Loading branch information
nuritsha committed Oct 29, 2024
1 parent df9af1c commit b54b5a0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
30 changes: 13 additions & 17 deletions modules/template-parts/documents/document-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,20 @@ protected static function get_templates_path(): string {
* @return ?int
*/
public static function get_document_post(): ?int {
static $posts = null;

if ( is_null( $posts ) ) {
$args = array(
'post_type' => 'elementor_library',
'fields' => 'ids',
'lazy_load_term_meta' => true,
'tax_query' => [
[
'taxonomy' => self::TAXONOMY_TYPE_SLUG,
'field' => 'slug',
'terms' => static::get_type(),
],
$args = array(
'post_type' => 'elementor_library',
'fields' => 'ids',
'lazy_load_term_meta' => true,
'tax_query' => [
[
'taxonomy' => self::TAXONOMY_TYPE_SLUG,
'field' => 'slug',
'terms' => static::get_type(),
],
);
$query = new WP_Query( $args );
$posts = $query->posts;
}
],
);
$query = new WP_Query( $args );
$posts = $query->posts;
return ( 1 !== count( $posts ) ) ? null : $posts[0];
}

Expand Down
2 changes: 1 addition & 1 deletion modules/template-parts/documents/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function get_template( $name, $args ) {

$templates[] = 'footer.php';

// Avoid running wp_head hooks again
// Avoid running wp_footer hooks again
remove_all_actions( 'wp_footer' );
ob_start();
// It causes a `require_once` so, in the hook itself it will not be required again.
Expand Down
5 changes: 3 additions & 2 deletions modules/template-parts/templates/footer.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php
use HelloPlus\Modules\TemplateParts\Documents\Footer;
use HelloPlus\Includes\Utils as Theme_Utils;

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

$footer = new Footer();
$footer_doc_post = Footer::get_document_post();
$footer = Theme_Utils::elementor()->documents->get( $footer_doc_post );
$footer->print_content();
wp_footer();
?>
Expand Down

0 comments on commit b54b5a0

Please sign in to comment.