Add class="thickbox" to links automatically when URL contains "TB_iframe=true" or "#TB_inline" (i.e. class="thickbox" can be omitted in iframe/ajax content)

This commit is contained in:
attosoft committed 2012-05-25 14:30:21 +00:00
1 parent 6f06cba2d9
commit c8f60368a3
1 file changed
+21
+21
View File
@@ -53,10 +53,31 @@ class auto_thickbox {
return auto_thickbox::image($anchor);
elseif ( !empty($anchor['attr']['class']) && in_array('thickbox', $anchor['attr']['class']) )
return auto_thickbox::iframe($anchor);
elseif ( strpos($anchor['attr']['href'], 'TB_iframe=true') !== false || strpos($anchor['attr']['href'], '#TB_inline') !== false )
return $this->add_thickbox_class($anchor);
else
return $anchor;
} # filter()
function add_thickbox_class($anchor) {
if ( !$anchor['attr']['class'] ) {
$anchor['attr']['class'][] = 'thickbox';
$anchor['attr']['class'][] = 'no_icon';
} else {
$no_thickbox_found;
foreach ( explode(' ', trim($this->options['no_thickbox'])) as $no_thickbox ) {
$no_thickbox_found = in_array($no_thickbox, $anchor['attr']['class']);
if ( $no_thickbox_found )
break;
}
if ( !in_array('thickbox', $anchor['attr']['class']) && !$no_thickbox_found )
$anchor['attr']['class'][] = 'thickbox';
if ( !in_array('no_icon', $anchor['attr']['class']) && !in_array('noicon', $anchor['attr']['class']) )
$anchor['attr']['class'][] = 'no_icon';
}
return $anchor;
}
/**
* image()
*