Skip to content

Commit

Permalink
Merge pull request #209 from equalizedigital/hotfix/disclosuers-super…
Browse files Browse the repository at this point in the history
…script

added - disclosure superscript
  • Loading branch information
SteveJonesDev authored Oct 5, 2023
2 parents d0fee83 + 9f3c902 commit cbdee25
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
23 changes: 22 additions & 1 deletion inc/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,25 @@ function slp_a_target( $value ) {
if( ! $value ) return;

return ' target="' . $value . '"';
}
}

/**
* Appends a superscript at the end of each line in the provided HTML content.
*
* @param string $content The original HTML content.
* @param string $superscriptText The text to be added as superscript. Default is 'TM'.
*
* @return string Updated content with superscripts appended.
*/
function slp_append_superscript( $content, $superscript_text ) {
// Convert the superscript text to actual HTML tag.
$superscript = '<sup>' . $superscript_text . '</sup>';

// Replace each line break with the superscript followed by a line break.
$updated_content = str_replace( '<br>', $superscript . '<br>', $content );

// Additionally, add superscript to the end of the paragraph if needed.
$updated_content = str_replace( '</p>', $superscript . '</p>', $updated_content );

return $updated_content;
}
27 changes: 20 additions & 7 deletions single.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,35 @@ function eqd_single_after_entry_content() {
<?php
while ( have_rows( 'build_refinance_student_loans_section', 'option' ) ) :
the_row();
$logo_image = get_sub_field( 'logo_image' );
$link = get_sub_field( 'learn_more_link' );
$logo_image = get_sub_field( 'logo_image' );
$link = get_sub_field( 'learn_more_link' );
$superscript = "<sup>" . get_row_index() . "</sup>";
?>

<tr class="data-tr">
<th class="sr-only" scope="row"><?php the_sub_field( 'lender_name' ); ?></th>
<td>
<div class="td_content">
<img src="<?php echo $logo_image['url']; ?>" alt="<?php echo $logo_image['alt']; ?>">
<button class="btn-text modal-btn" data-modal="modal_disclosure_<?php echo get_row_index(); ?>" aria-label="Disclosures for <?php echo get_sub_field('lender_name'); ?>">Disclosures<sup><?php echo get_row_index(); ?></sup></button>
<button class="btn-text modal-btn" data-modal="modal_disclosure_<?php echo get_row_index(); ?>" aria-label="Disclosures for <?php echo get_sub_field('lender_name'); ?>">Disclosures<sup><?php echo $superscript; ?></sup></button>
</div>
</td>
<td>
<div class="td_content">
<div class="td_title">
<?php the_sub_field( 'offer' ); ?>
<?php
if( get_sub_field( 'offer' ) ) {
the_sub_field( 'offer' );
echo $superscript;
}
?>
</div>
<div class="td_text">
<?php the_sub_field( 'offer_text' ); ?>
<?php
if( get_sub_field( 'offer_text' ) ) {
echo slp_append_superscript( the_sub_field( 'offer_text' ), get_row_index() );
}
?>
</div>
</div>
</td>
Expand All @@ -123,7 +133,7 @@ function eqd_single_after_entry_content() {
<div class="td_title">
<?php
$link_target = $link['target'] ? $link['target'] : '_self';
?>
?>
<a href="<?php echo $link['url']; ?>"
class="btn"
target="<?php echo esc_attr( $link_target ); ?>">
Expand All @@ -132,7 +142,10 @@ class="btn"
</div>
<?php endif; ?>
<div class="td_text">
<?php the_sub_field( 'learn_more_subtext' ); ?>
<?php
if( get_sub_field( 'learn_more_subtext' ) ) {
echo slp_append_superscript( the_sub_field( 'learn_more_subtext' ), get_row_index() );
?>
</div>
</div>
</td>
Expand Down

0 comments on commit cbdee25

Please sign in to comment.