Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Front page post thumbnail link title refactoring #241

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions content.php
Expand Up @@ -24,7 +24,7 @@
</h2>
<?php endif; ?>
<h1 class="entry-title p-name">
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'independent-publisher' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
<a href="<?php the_permalink(); ?>" title="<?php echo independent_publisher_post_link_title(); ?>" rel="bookmark"><?php the_title(); ?></a>
</h1>
</header>
<!-- .entry-header -->
Expand All @@ -39,7 +39,7 @@

<?php /* Only show featured image for Standard post and gallery post formats */ ?>
<?php if ( has_post_thumbnail() && in_array( get_post_format(), array( 'gallery', false ) ) ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'independent-publisher' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_post_thumbnail( 'independent_publisher_post_thumbnail' ); ?></a>
<a href="<?php the_permalink(); ?>" title="<?php echo independent_publisher_post_thumbnail_link_title(); ?>"><?php the_post_thumbnail( 'independent_publisher_post_thumbnail' ); ?></a>
<?php endif; ?>

<?php the_content( independent_publisher_continue_reading_text() ); ?>
Expand Down
24 changes: 22 additions & 2 deletions functions.php
Expand Up @@ -1187,7 +1187,7 @@ function independent_publisher_maybe_linkify_the_content( $content ) {
$content = independent_publisher_clean_content( $content );

// Now we can link the Quote or Aside content to itself
$content = '<a href="' . get_permalink() . '" rel="bookmark" title="' . esc_attr( sprintf( __( 'Permalink to %s', 'independent-publisher' ), the_title_attribute( 'echo=0' ) ) ) . '">' . $content . '</a>';
$content = '<a href="' . get_permalink() . '" rel="bookmark" title="' . independent_publisher_post_link_title() . '">' . $content . '</a>';
}

return $content;
Expand All @@ -1202,7 +1202,7 @@ function independent_publisher_maybe_linkify_the_content( $content ) {
*/
function independent_publisher_maybe_linkify_the_excerpt( $content ) {
if ( !is_single() ) {
$content = '<a href="' . get_permalink() . '" rel="bookmark" title="' . esc_attr( sprintf( __( 'Permalink to %s', 'independent-publisher' ), the_title_attribute( 'echo=0' ) ) ) . '">' . $content . '</a>';
$content = '<a href="' . get_permalink() . '" rel="bookmark" title="' . independent_publisher_post_link_title() . '">' . $content . '</a>';
}

return $content;
Expand Down Expand Up @@ -1295,3 +1295,23 @@ function independent_publisher_show_page_load_progress_bar() { ?>
<?php
}
endif;

if ( ! function_exists( 'independent_publisher_post_thumbnail_link_title' ) ) :
function independent_publisher_post_thumbnail_link_title() {
return independent_publisher_post_link_title_common();
}
endif;

if ( ! function_exists( 'independent_publisher_post_link_title' ) ) :
function independent_publisher_post_link_title() {
return independent_publisher_post_link_title_common();
}
endif;

if ( ! function_exists( 'independent_publisher_post_link_title_common' ) ) :
function independent_publisher_post_link_title_common() {
return esc_attr( sprintf( __( 'Permalink to %s', 'independent-publisher' ), the_title_attribute( 'echo=0' ) ) );
}
endif;

?>