__construct();
}
/**
* Setup plugin and hook into WordPress
*
* @return none
* @since 3.0.3
*/
function __construct () {
add_filter ( 'the_content' , array ( &$this , 'push_title_to_anchor' ) , 11 );
add_filter ( 'the_excerpt' , array ( &$this , 'push_title_to_anchor' ) , 11 );
add_filter ( 'wp_get_attachment_link' , array ( &$this , 'push_title_to_anchor' ) , 11 );
}
/**
* Filter the_content and the_excerpt finding a title attribute on an
tag
* and pushing it to the parent tag if the title attribute does not exist on
* the tag.
*
* @since 3.0.3
* @param string $content The content of the post
* @return string
*/
function push_title_to_anchor ( $content ) {
$master_pattern = '%]+>
]+>%';
$anchor_pattern = '%(]+)>%';
if ( preg_match_all ( $master_pattern , $content , $links ) ) {
foreach ( $links[0] as $link ) {
$anchor_title_pattern = '%]+title=([\'"]).*?\\1[^>]+?>%';
$img_title_pattern = '%
]+(title=([\'"]).*?\\2)[^>]+?>%';
if ( preg_match ( $img_title_pattern , $link , $title ) && ! preg_match ( $anchor_title_pattern , $link ) ) {
$link_replace = preg_replace ( $anchor_pattern , '$1 ' . $title[1] . '>' , $link );
$content = str_replace ( $link , $link_replace , $content );
}
}
}
return $content;
}
}
/**
* Instantiate the ShadowboxTitlePush Class
*/
if ( ! is_admin () ) {
$ShadowboxTitlePush = new ShadowboxTitlePush ();
}