when a Bricks Payment History * element is present on the current page. * * Bricks instantiates elements — and so fires their `enqueue_scripts()` — only * during render (`Frontend::render_element()` → `Element::init()`), which runs * after `wp_head`. An element-side enqueue therefore lands in the footer and the * dashboard flashes unstyled. Bricks stores element data in postmeta, so detect our * element in the head the same way Bricks detects its own setting-specific assets: * sniff the serialised template data of each area for the element name. * * @since 2.12.3 * @return void */ public function maybe_enqueue_payment_history_assets() { if ( ! class_exists( '\Bricks\Database' ) ) { return; } foreach ( [ 'header', 'content', 'footer' ] as $area ) { $data = \Bricks\Database::get_template_data( $area ); if ( ! is_array( $data ) ) { continue; } if ( false !== strpos( (string) wp_json_encode( $data ), '"sureforms-payment-history"' ) ) { Payment_History_Shortcode::get_instance()->enqueue_assets( true ); return; } } } /** * Filter to add translatable string to the builder. * * @param array $i18n Array of translatable strings. * @since 0.0.5 * @return array $i18n */ public function bricks_translatable_strings( $i18n ) { $i18n['sureforms'] = __( 'SureForms', 'sureforms' ); return $i18n; } }