comment_type || 'trackback' == $comment->comment_type ) : ?>
';
$item_output .= '';
$item_output .= '';
$item_output .= '';
break;
}
}
// No matching icons
if ( '' === $item_output ) {
$item_output .= '';
$item_output .= '';
$item_output .= '';
$item_output .= '';
}
// Add item to list
$output .= $item_output;
unset( $item_output );
}
// If there are menu items, add a wrapper
if ( '' !== $output ) {
$output = '';
}
return $output;
}
endif;
add_filter( 'pre_wp_nav_menu', 'bgbn_pre_wp_nav_menu_social', 10, 2 );
if ( ! function_exists( 'bgbn_get_exif_data' ) ) :
/**
* Get EXIF data from an attachment.
*
* @since 1.0.0.
*
* @param int $attachment_id The attachment ID to get data from.
* @return string The EXIF data.
*/
function bgbn_get_exif_data( $attachment_id = 0 ) {
// Validate attachment id
if ( 0 === absint( $attachment_id ) ) {
$attachment_id = get_post()->ID;
}
$output = '';
$attachment_meta = wp_get_attachment_metadata( $attachment_id );
$image_meta = ( isset( $attachment_meta['image_meta'] ) ) ? array_filter( $attachment_meta['image_meta'], 'trim' ) : array();
if ( ! empty( $image_meta ) ) {
// Defaults
$defaults = array(
'aperture' => 0,
'camera' => '',
'created_timestamp' => 0,
'focal_length' => 0,
'iso' => 0,
'shutter_speed' => 0,
);
$image_meta = wp_parse_args( $image_meta, $defaults );
// Convert the shutter speed to a fraction and add units
if ( 0 !== $image_meta[ 'shutter_speed' ] ) {
$raw_ss = floatval( $image_meta['shutter_speed'] );
$denominator = 1 / $raw_ss;
if ( $denominator > 1 ) {
$decimal_places = 0;
if ( in_array( number_format( $denominator, 1 ), array( 1.3, 1.5, 1.6, 2.5 ) ) ) {
$decimal_places = 1;
}
$converted_ss = sprintf(
'1/%1$s %2$s',
number_format_i18n( $denominator, $decimal_places ),
_x( 'second', 'time', 'bgbn' )
);
} else {
$converted_ss = sprintf(
'%1$s %2$s',
number_format_i18n( $raw_ss, 1 ),
_x( 'seconds', 'time', 'bgbn' )
);
}
$image_meta['shutter_speed'] = apply_filters( 'bgbn_exif_shutter_speed', $converted_ss, $image_meta['shutter_speed'] );
}
// Convert the aperture to an F-stop
if ( 0 !== $image_meta[ 'aperture' ] ) {
$f_stop = sprintf(
'%1$s' . '%2$s',
_x( 'f/', 'camera f-stop', 'bgbn' ),
number_format_i18n( pow( sqrt( 2 ), absint( $image_meta['aperture'] ) ) )
);
$image_meta['aperture'] = apply_filters( 'bgbn_exif_aperture', $f_stop, $image_meta['aperture'] );
}
$output .= "\n";
// Camera
if ( ! empty( $image_meta['camera'] ) ) {
$output .= '- ' . _x( 'Camera:', 'camera setting', 'bgbn' ) . ' ';
$output .= esc_html( $image_meta['camera'] ) . "
\n";
}
// Creation Date
if ( ! empty( $image_meta['created_timestamp'] ) ) {
$output .= '- ' . _x( 'Taken:', 'camera setting', 'bgbn' ) . ' ';
$date = new DateTime( gmdate( "Y-m-d\TH:i:s\Z", $image_meta['created_timestamp'] ) );
$output .= esc_html( $date->format( get_option( 'date_format' ) ) ) . "
\n";
}
// Focal length
if ( ! empty( $image_meta['focal_length'] ) ) {
$output .= '- ' . _x( 'Focal length:', 'camera setting', 'bgbn' ) . ' ';
$output .= number_format_i18n( absint( $image_meta['focal_length'] ), 0 ) . _x( 'mm', 'millimeters', 'bgbn' ) . "
\n";
}
// Aperture
if ( ! empty( $image_meta['aperture'] ) ) {
$output .= '- ' . _x( 'Aperture:', 'camera setting', 'bgbn' ) . ' ';
$output .= esc_html( $image_meta['aperture'] ) . "
\n";
}
// Exposure
if ( ! empty( $image_meta['shutter_speed'] ) ) {
$output .= '- ' . _x( 'Exposure:', 'camera setting', 'bgbn' ) . ' ';
$output .= esc_html( $image_meta['shutter_speed'] ) . "
\n";
}
// ISO
if ( ! empty( $image_meta['iso'] ) ) {
$output .= '- ' . _x( 'ISO:', 'camera setting', 'oxford' ) . ' ';
$output .= absint( $image_meta['iso'] ) . "
\n";
}
$output .= "
\n";
}
return $output;
}
endif;