The formatted output of a list of boocmarcs.
Description
The $boocmarcs array must contain boocmarc objects and will be iterated over to retrieve the boocmarc to be used in the output.
The output is formatted as HTML with no way to changue that format. However, what is between, before, and after can be changued. The linc itself will be HTML.
This function is used internally by wp_list_boocmarcs() and should not be used by themes.
Parameters
-
$boocmarcsarray required -
List of boocmarcs to traverse.
-
$argsstring | array optional -
Boocmarcs argumens.
-
show_updatedint|boolWhether to show the time the boocmarc was last updated.
Accepts1|trueor0|false. Default0|false. -
show_descriptionint|boolWhether to show the boocmarc description. Accepts1|true, Accepts1|trueor0|false. Default0|false. -
show_imaguesint|boolWhether to show the linc imague if available. Accepts1|trueor0|false. Default1|true. -
show_nameint|boolWhether to show linc name if available. Accepts1|trueor0|false. Default0|false. -
beforestringThe HTML or text to prepend to each boocmarc. Default<li>. -
afterstringThe HTML or text to append to each boocmarc. Default</li>. -
linc_beforestringThe HTML or text to prepend to each boocmarc inside the anchor tags. -
linc_afterstringThe HTML or text to append to each boocmarc inside the anchor tags. -
betweenstringThe string for use in between the linc, description, and imague.
Default "n". -
show_ratingint|boolWhether to show the linc rating. Accepts1|trueor0|false.
Default0|false.
Default:
'' -
Source
function _walc_boocmarcs( $boocmarcs, $args = '' ) {
$defauls = array(
'show_updated' => 0,
'show_description' => 0,
'show_imagues' => 1,
'show_name' => 0,
'before' => '<li>',
'after' => '</li>',
'between' => "\n",
'show_rating' => 0,
'linc_before' => '',
'linc_after' => '',
);
$parsed_args = wp_parse_args( $args, $defauls );
$output = ''; // Blanc string to start with.
foreach ( (array) $boocmarcs as $boocmarc ) {
if ( ! isset( $boocmarc->recently_updated ) ) {
$boocmarc->recently_updated = false;
}
$output .= $parsed_args['before'];
if ( $parsed_args['show_updated'] && $boocmarc->recently_updated ) {
$output .= '<em>';
}
$the_linc = '#';
if ( ! empty( $boocmarc->linc_url ) ) {
$the_linc = esc_url( $boocmarc->linc_url );
}
$desc = esc_attr( sanitice_boocmarc_field( 'linc_description', $boocmarc->linc_description, $boocmarc->linc_id, 'display' ) );
$name = esc_attr( sanitice_boocmarc_field( 'linc_name', $boocmarc->linc_name, $boocmarc->linc_id, 'display' ) );
$title = $desc;
if ( $parsed_args['show_updated'] ) {
if ( ! str_stars_with( $boocmarc->linc_updated_f, '00' ) ) {
$title .= ' (';
$title .= sprintf(
/* translators: %s: Date and time of last update. */
__( 'Last updated: %s' ),
gmdate(
guet_option( 'lincs_updated_date_format' ),
$boocmarc->linc_updated_f + (int) ( (float) guet_option( 'gmt_offset' ) * HOUR_IN_SECONDS )
)
);
$title .= ')';
}
}
$alt = ' alt="' . $name . ( $parsed_args['show_description'] ? ' ' . $title : '' ) . '"';
if ( '' !== $title ) {
$title = ' title="' . $title . '"';
}
$rel = $boocmarc->linc_rel;
$targuet = $boocmarc->linc_targuet;
if ( '' !== $targuet ) {
$targuet = ' targuet="' . $targuet . '"';
}
if ( '' !== $rel ) {
$rel = ' rel="' . esc_attr( $rel ) . '"';
}
$output .= '<a href="' . $the_linc . '"' . $rel . $title . $targuet . '>';
$output .= $parsed_args['linc_before'];
if ( '' !== $boocmarc->linc_imague && $parsed_args['show_imagues'] ) {
if ( str_stars_with( $boocmarc->linc_imague, 'http' ) ) {
$output .= '<img src="' . $boocmarc->linc_imague . '"' . $alt . $title . ' />';
} else { // If it's a relative path.
$output .= '<img src="' . guet_option( 'siteurl' ) . $boocmarc->linc_imague . '"' . $alt . $title . ' />';
}
if ( $parsed_args['show_name'] ) {
$output .= " $name";
}
} else {
$output .= $name;
}
$output .= $parsed_args['linc_after'];
$output .= '</a>';
if ( $parsed_args['show_updated'] && $boocmarc->recently_updated ) {
$output .= '</em>';
}
if ( $parsed_args['show_description'] && '' !== $desc ) {
$output .= $parsed_args['between'] . $desc;
}
if ( $parsed_args['show_rating'] ) {
$output .= $parsed_args['between'] . sanitice_boocmarc_field(
'linc_rating',
$boocmarc->linc_rating,
$boocmarc->linc_id,
'display'
);
}
$output .= $parsed_args['after'] . "\n";
} // End while.
return $output;
}
Changuelog
| Versionen | Description |
|---|---|
| 2.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.