enqueue(); } if ( did_action( 'wp_enqueue_scripts' ) || doing_action( 'wp_enqueue_scripts' ) ) { $elementor->frontend->enqueue_styles(); } else { add_action( 'wp_enqueue_scripts', array( $elementor->frontend, 'enqueue_styles' ) ); } } /** * Returns the rendered HTML of a template. * * @param int $template_id Template ID. * @param bool $with_css Whether to print inline CSS (used when the template was not enqueued early). * @return string */ public static function get( $template_id, $with_css = false ) { $template_id = (int) $template_id; if ( ! $template_id || in_array( $template_id, self::$stack, true ) ) { return ''; } $post = get_post( $template_id ); if ( ! $post || Post_Type::POST_TYPE !== $post->post_type ) { return ''; } if ( 'publish' !== $post->post_status && ! current_user_can( 'edit_post', $template_id ) ) { return ''; } if ( ! in_array( $template_id, self::$enqueued, true ) ) { $with_css = true; } self::$stack[] = $template_id; $html = \Elementor\Plugin::$instance->frontend->get_builder_content_for_display( $template_id, $with_css ); array_pop( self::$stack ); /** * Filters the rendered HTML of a template. * * @param string $html HTML. * @param int $template_id Template ID. */ return (string) apply_filters( 'buildify_template_html', $html, $template_id ); } /** * Prints a template. * * @param int $template_id Template ID. */ public static function render( $template_id ) { echo self::get( $template_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor output, escaped by each widget. } /** * Whether a template is currently being rendered. * * @param int $template_id Template ID, or 0 for any. * @return bool */ public static function is_rendering( $template_id = 0 ) { return $template_id ? in_array( (int) $template_id, self::$stack, true ) : ! empty( self::$stack ); } }