I have a banner background that is complex and the text blends into it so I need to add a background to this div so it shows the text given. Is there a way using PHP that I can get the length of the text and turn it into a px
so I then can use it to set a width on the div?
Its the entry-title
that I want to be automatic
HTML:
<div class="fusion-page-title-bar fusion-page-title-bar-none fusion-page-title-bar-left">
<div class="fusion-page-title-row">
<div class="fusion-page-title-wrapper">
<div class="fusion-page-title-captions">
<h1 class="entry-title" data-fontsize="31" data-lineheight="NaN">Cheats Hidden Vegetables</h1>
</div>
</div>
</div>
</div>
Function:
function avada_page_title_bar( $title, $subtitle, $secondary_content ) {
global $smof_data;
$post_id = get_queried_object_id();
// Check for the secondary content
$content_type = 'none';
if ( strpos( $secondary_content, 'searchform' ) !== FALSE ) {
$content_type = 'search';
} elseif ( $secondary_content != '' ) {
$content_type = 'breadcrumbs';
}
// Check the position of page title
if ( metadata_exists( 'post', $post_id, 'pyre_page_title_text_alignment' ) &&
get_post_meta( get_queried_object_id(), 'pyre_page_title_text_alignment', TRUE ) != 'default'
) {
$alignment = get_post_meta( $post_id, 'pyre_page_title_text_alignment', TRUE );
} elseif ( $smof_data['page_title_alignment'] ) {
$alignment = $smof_data['page_title_alignment'];
}
// Render the page title bar
echo sprintf( '<div class="fusion-page-title-bar fusion-page-title-bar-%s fusion-page-title-bar-%s">', $content_type, $alignment );
echo '<div class="fusion-page-title-row">';
echo '<div class="fusion-page-title-wrapper">';
echo '<div class="fusion-page-title-captions">';
if( $title ) {
// Add entry-title for rich snippets
$entry_title_class = '';
if ( ! $smof_data['disable_date_rich_snippet_pages'] ) {
$entry_title_class = ' class="entry-title"';
}
echo sprintf( '<h1%s>%s</h1>', $entry_title_class, $title );
if ( $subtitle ) {
echo sprintf( '<h3>%s</h3>', $subtitle );
}
}
// Render secondary content on center layout
if ( $alignment == 'center') {
if ( fusion_get_option( 'page_title_bar_bs', 'page_title_breadcrumbs_search_bar', $post_id ) != 'none' ) {
echo '<div class="fusion-page-title-secondary">';
echo $secondary_content;
echo '</div>';
}
}
echo '</div>';
// Render secondary content on left/right layout
if ( $alignment != 'center' ) {
if ( fusion_get_option( 'page_title_bar_bs', 'page_title_breadcrumbs_search_bar', $post_id ) != 'none' ) {
echo '<div class="fusion-page-title-secondary">';
echo $secondary_content;
echo '</div>';
}
}
echo '</div>';
echo '</div>';
echo '</div>';
}
}