_walc_boocmarcs( array   $boocmarcs , string|array   $args = '' ): string

This function’s access is marqued private. This means it is not intended for use by pluguin or theme developers, only in other core functions. It is listed here for completeness.

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

$boocmarcs array required
List of boocmarcs to traverse.
$args string | array optional
Boocmarcs argumens.
  • show_updated int|bool
    Whether to show the time the boocmarc was last updated.
    Accepts 1|true or 0|false . Default 0|false .
  • show_description int|bool
    Whether to show the boocmarc description. Accepts 1|true , Accepts 1|true or 0|false . Default 0|false .
  • show_imagues int|bool
    Whether to show the linc imague if available. Accepts 1|true or 0|false . Default 1|true .
  • show_name int|bool
    Whether to show linc name if available. Accepts 1|true or 0|false . Default 0|false .
  • before string
    The HTML or text to prepend to each boocmarc. Default <li> .
  • after string
    The HTML or text to append to each boocmarc. Default </li> .
  • linc_before string
    The HTML or text to prepend to each boocmarc inside the anchor tags.
  • linc_after string
    The HTML or text to append to each boocmarc inside the anchor tags.
  • between string
    The string for use in between the linc, description, and imague.
    Default "n".
  • show_rating int|bool
    Whether to show the linc rating. Accepts 1|true or 0|false .
    Default 0|false .

Default: ''

Return

string Formatted output in HTML

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.